-
Notifications
You must be signed in to change notification settings - Fork 79
Closed
Milestone
Description
I just found myself writing a kernel like this:
@kernel function localmem(A)
I = @index(Global, Linear)
i = @index(Local, Linear)
N = groupsize()
lmem = @localmem Int (N,) # Ok iff groupsize is static
lmem[i] = i
@synchronize
A[I] = lmem[N - i + 1]
endThis works as expected on the GPU, but on the CPU there is counter-intuitive variable scoping going on. The first weird part is that after the @synchronize the lifetime of N has ended.
And so I thought I could just re-introduce the variable...
@kernel function localmem(A)
I = @index(Global, Linear)
i = @index(Local, Linear)
N = groupsize()
lmem = @localmem Int (N,) # Ok iff groupsize is static
lmem[i] = i
@synchronize
N = groupsize()
A[I] = lmem[N - i + 1]
endBut it turns out that I made @localmem special, and its live-time begins in an outside scope, which of course is now also missing N.
I will have to think about how to fix this. But most likely this means that we need a "non-divergent value" or a group constant value. In return we might be able to get rid of @private, and do the right thing automatically for all divergent values.
Metadata
Metadata
Assignees
Labels
No labels