-
Notifications
You must be signed in to change notification settings - Fork 70
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
Simple Block Reduce Fails when using while
loops
#330
Comments
Hm I need to think through the semantics of while loops on the CPU... #262 You can use This looks like a scope issue. In general I was thinking that instead of impliementing block reduce in KA we would provide a |
On the CPU the while loop misses an index into the thread-local while s > 0
begin
var"##N#486" = length((KernelAbstractions.__workitems_iterspace)(__ctx__))
begin
#= /home/andreinicusan/.julia/packages/KernelAbstractions/DqITC/src/macros.jl:264 =#
for var"##I#485" = (KernelAbstractions.__workitems_iterspace)(__ctx__)
#= /home/andreinicusan/.julia/packages/KernelAbstractions/DqITC/src/macros.jl:265 =#
(KernelAbstractions.__validindex)(__ctx__, var"##I#485") || continue
#= /home/andreinicusan/.julia/packages/KernelAbstractions/DqITC/src/macros.jl:266 =#
bi = KernelAbstractions.__index_Group_Linear(__ctx__, var"##I#485")
ti = KernelAbstractions.__index_Local_Linear(__ctx__, var"##I#485")
gi = KernelAbstractions.__index_Global_Linear(__ctx__, var"##I#485")
#= /home/andreinicusan/.julia/packages/KernelAbstractions/DqITC/src/macros.jl:267 =#
if ti < s[(KernelAbstractions.__index_Local_Linear)(__ctx__, var"##I#485")]
#= REPL[18]:21 =#
cache[ti] += cache[ti + s[(KernelAbstractions.__index_Local_Linear)(__ctx__, var"##I#485")]]
end
#= /home/andreinicusan/.julia/packages/KernelAbstractions/DqITC/src/macros.jl:268 =#
end
end
end
I notice that the Does the Also - would a |
On the GPU I see: [...]
bs = ((#= /home/andreinicusan/.julia/packages/KernelAbstractions/DqITC/src/KernelAbstractions.jl:127 =#
(KernelAbstractions.groupsize)(__ctx__)))[1]
[...]
var"#177#s" = KernelAbstractions.bs ÷ 2
while s > 0
[...] Why is Analog for Thanks for the quick reply, I'll be using |
So one thing to think through is what a |
Yeah the
But we certainly couldn't support |
We could solve break through introducing a mask... |
Hi, thank you for developing this library - I would like to write optimised kernels for common GPU algorithms such as reduce, scan, radix sort, etc. similar to CUB but available on all KernelAbstractions platforms. The resulting "KA standard library" (KALib? Caleb?) could be used as a benchmark for future KA development & optimisation - and I can use the lessons along the way to populate the "Writing Kernels" section in the documentation. Big plans, but...
I'm implementing the block-wise reduce following this tutorial with this simple-looking code:
It shouldn't be more exotic than the example code in the docs - however, these two lines:
Produce the following errors:
I tried following the code using Cthulhu.jl, but the errors appear simple: it's calling div(::Any, ::Int64) and >(::Any, ::Int64), so I assume the
bs = @uniform @groupsize()[1]
and@private s = bs ÷ 2
are not inferred as being integers.If I switch the arrays and device to
CPU()
I get the following error:Would you know why these errors appear or how I could investigate (and fix..) them?
Thanks,
Leonard
The text was updated successfully, but these errors were encountered: