New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable scoping issue leading to unexpected UndefVarError on CPU #413
Comments
Yeah this is expected and the reason why the https://juliagpu.github.io/KernelAbstractions.jl/api/#KernelAbstractions.@uniform |
OK, yeah---using |
Yeah the CPU lowering is a bit tricky, and doesn't have the best errors |
Hey, I need help here please! No matter if I add or remove @uniform or @Private in the index, I can't run the code: LoadError: UndefVarError:
LoadError: MethodError: no method matching __index_Global_Linear(::KernelAbstractions.CompilerMetadata{KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.NoDynamicCheck, CartesianIndex{2}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, KernelAbstractions.NDIteration.NDRange{2, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}}}):
ERROR: LoadError: MethodError: no method matching __index_Global_Linear(::KernelAbstractions.CompilerMetadata{KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.NoDynamicCheck, CartesianIndex{2}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, KernelAbstractions.NDIteration.NDRange{2, KernelAbstractions.NDIteration.DynamicSize, KernelAbstractions.NDIteration.DynamicSize, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}, CartesianIndices{2, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}}}):
Any ideas? Thanks! |
@ManuelCostanzo please make it easier to help you by formatting your post. I am unsure what you want to achieve? By definition |
Hi @vchuravy, I just need to access to the thread_id and block_id values after the
|
I have encountered what I think is a variable scoping issue that causes one of my KernelAbstractions kernels to fail when executing on the CPU. (GPU execution is fine.) I'm using KernelAbstractions v0.9.6 in Julia 1.9.2. Here's a minimal example that triggers the problem:
When I run this code, it fails with:
The compiler thinks that the variable
Nblocks
in theid = Nblocks
line is not defined, even though it clearly is defined via the call to@ndrange
. When I inspect the generated kernel code withcode_lowered()
, I see:The code in block 5 shows that
Nblocks
is getting set OK, but the code in block 12 shows that when theid = Nblocks
line gets translated, the compiler looks for a definition ofNblocks
in theMain
module, where it does not exist. (I redacted this listing for readability. I'm happy to provide the full listing if that would be helpful.)The issue disappears if I remove the call to
@synchronize
.Any thoughts here?
EDIT: This is probably related to (maybe even a duplicate of) #274. Also, another way I can get the issue to disappear is to move the call to
@ndrange
that definesNblocks
inside the@inbounds begin ... end
block.The text was updated successfully, but these errors were encountered: