Skip to content

Commit 4a562df

Browse files
authored
Merge pull request #118 from JuliaGPU/sb/docs
add docs for localmem, private and uniform macros
2 parents 76b9b4a + e11f90a commit 4a562df

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/KernelAbstractions.jl

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ function groupsize end
121121

122122
"""
123123
@localmem T dims
124+
125+
Declare storage that is local to a workgroup.
124126
"""
125127
macro localmem(T, dims)
126128
# Stay in sync with CUDAnative
@@ -133,6 +135,15 @@ end
133135

134136
"""
135137
@private T dims
138+
139+
Declare storage that is local to each item in the workgroup. This can be safely used
140+
across [`@synchronize`](@ref) statements. On a CPU, this will allocate additional implicit
141+
dimensions to ensure correct localization.
142+
143+
For storage that only persists between `@synchronize` statements, an `MArray` can be used
144+
instead.
145+
146+
See also [`@uniform`](@ref).
136147
"""
137148
macro private(T, dims)
138149
quote
@@ -141,14 +152,17 @@ macro private(T, dims)
141152
end
142153

143154
"""
144-
@uniform value
155+
@uniform expr
156+
157+
`expr` is evaluated outside the workitem scope. This is useful for variable declarations
158+
that span workitems, or are reused across `@synchronize` statements.
145159
"""
146160
macro uniform(value)
147161
esc(value)
148162
end
149163

150164
"""
151-
@synchronize()
165+
@synchronize()
152166
153167
After a `@synchronize` statement all read and writes to global and local memory
154168
from each thread in the workgroup are visible in from all other threads in the
@@ -161,7 +175,7 @@ macro synchronize()
161175
end
162176

163177
"""
164-
@synchronize(cond)
178+
@synchronize(cond)
165179
166180
After a `@synchronize` statement all read and writes to global and local memory
167181
from each thread in the workgroup are visible in from all other threads in the
@@ -178,7 +192,7 @@ macro synchronize(cond)
178192
end
179193

180194
"""
181-
@print(items...)
195+
@print(items...)
182196
183197
This is a unified print statement.
184198
@@ -220,7 +234,7 @@ macro print(items...)
220234
end
221235

222236
"""
223-
@index
237+
@index
224238
225239
The `@index` macro can be used to give you the index of a workitem within a kernel
226240
function. It supports both the production of a linear index or a cartesian index.

0 commit comments

Comments
 (0)