Skip to content

Commit c4d2487

Browse files
bors[bot]vchuravy
andauthored
Merge #35
35: add a block syntax for uniform r=vchuravy a=vchuravy bors r+ Co-authored-by: Valentin Churavy <v.churavy@gmail.com>
2 parents 7649ff5 + 878bf7b commit c4d2487

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/macros.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,16 @@ function split(stmts)
119119

120120
loops = WorkgroupLoop[]
121121
for stmt in stmts.args
122-
if isexpr(stmt, :macrocall) && stmt.args[1] === Symbol("@synchronize")
123-
loop = WorkgroupLoop(deepcopy(indicies), current, allocations)
124-
push!(loops, loop)
125-
allocations = Any[]
126-
current = Any[]
127-
continue
122+
if isexpr(stmt, :macrocall)
123+
if stmt.args[1] === Symbol("@synchronize")
124+
loop = WorkgroupLoop(deepcopy(indicies), current, allocations)
125+
push!(loops, loop)
126+
allocations = Any[]
127+
current = Any[]
128+
continue
129+
elseif stmt.args[1] === Symbol("@uniform")
130+
push!(allocations, stmt)
131+
end
128132
elseif isexpr(stmt, :(=))
129133
rhs = stmt.args[2]
130134
if isexpr(rhs, :macrocall)

test/localmem.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ end
88

99
@kernel function localmem(A)
1010
N = @uniform prod(groupsize())
11+
@uniform begin
12+
N2 = prod(groupsize())
13+
end
1114
I = @index(Global, Linear)
1215
i = @index(Local, Linear)
1316
lmem = @localmem Int (N,) # Ok iff groupsize is static
1417
lmem[i] = i
1518
@synchronize
16-
A[I] = lmem[N - i + 1]
19+
A[I] = lmem[N2 - i + 1]
1720
end
1821

1922
function harness(backend, ArrayT)

0 commit comments

Comments
 (0)