@@ -113,13 +113,38 @@ macro synchronize()
113
113
end
114
114
115
115
"""
116
- @index(Global)
117
- @index(Local)
118
- @index(Global, Cartesian)
116
+ @index
117
+
118
+ The `@index` macro can be used to give you the index of a workitem within a kernel
119
+ function. It supports both the production of a linear index or a cartesian index.
120
+ A cartesian index is a general N-dimensional index that is derived from the iteration space.
121
+
122
+ # Index granularity
123
+
124
+ - `Global`: Used to access global memory.
125
+ - `Group`: The index of the `workgroup`.
126
+ - `Local`: The within `workgroup` index.
127
+
128
+ # Index kind
129
+
130
+ - `Linear`: Produces an `Int64` that can be used to linearly index into memory.
131
+ - `Global`: Produces a `CartesianIndex{N}` that can be used to index into memory.
132
+
133
+ If the index kind is not provided it defaults to `Linear`, this is suspect to change.
134
+
135
+ # Examples
136
+
137
+ ```julia
138
+ @index(Global, Linear)
139
+ @index(Global, Cartesian)
140
+ @index(Local, Cartesian)
141
+ @index(Group, Linear)
142
+ @index(Global)
143
+ ```
119
144
"""
120
145
macro index (locale, args... )
121
- if ! (locale === :Global || locale === :Local )
122
- error (" @index requires as first argument either :Global or :Local " )
146
+ if ! (locale === :Global || locale === :Local || locale === :Group )
147
+ error (" @index requires as first argument either :Global, :Local or :Group " )
123
148
end
124
149
125
150
if length (args) >= 1
142
167
# ##
143
168
144
169
function __index_Local_Linear end
170
+ function __index_Group_Linear end
145
171
function __index_Global_Linear end
146
172
147
173
function __index_Local_Cartesian end
174
+ function __index_Group_Cartesian end
148
175
function __index_Global_Cartesian end
149
176
150
177
struct ConstAdaptor end
0 commit comments