Skip to content

Commit eab762b

Browse files
authored
[SYCL][InvokeSIMD][Doc] Update spec for simd_mask (#8668)
We decided that instead boolean args should convert to any valid simd_mask<T, N>. This new design has been implemented. Update the spec to match the new design. Signed-off-by: Sarnie, Nick <[email protected]>
1 parent 02efe98 commit eab762b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

sycl/doc/extensions/experimental/sycl_ext_oneapi_invoke_simd.asciidoc

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,10 @@ In order to invoke the SIMD function, `invoke_simd` converts each argument
210210
in the `args` parameter pack according to the following rules:
211211

212212
- Arguments of type `bool` are converted to type
213-
`sycl::ext::oneapi::experimental::simd_mask<bool, N>`, where `N` is the sub-group size of
214-
the calling kernel. Element `i` of the SIMD type represents the value from
213+
`sycl::ext::oneapi::experimental::simd_mask<T, N>`, where `N` is the sub-group size of
214+
the calling kernel, and `T` is a user-specified type supported by
215+
`sycl::ext::oneapi::experimental::simd_mask`.
216+
Element `i` of the SIMD type represents the value from
215217
the work-item with sub-group local ID `i`.
216218

217219
- All other arithmetic arguments of type `T` are converted to type
@@ -241,7 +243,7 @@ cannot deduce the type of `Callable`.
241243
The return value of an `invoke_simd` function is subject to the same mapping
242244
rules in reverse:
243245

244-
- Return values of type `sycl::ext::oneapi::experimental::simd_mask<bool, N>` are converted
246+
- Return values of type `sycl::ext::oneapi::experimental::simd_mask<T, N>` are converted
245247
to `bool`, and the value in element `i` of the SIMD type is returned to the
246248
work-item with sub-group local ID `i`.
247249

@@ -282,14 +284,14 @@ by this specification. Otherwise, the implementation must issue a proper diagnos
282284

283285
The following algorithm to determine the sub-group size may be employed:
284286
- If any of the actual SPMD arguments is non-uniform, the specification requires
285-
that the corresponding SIMD argument must have `simd<T, N>` or `simd_mask<bool, N>`
287+
that the corresponding SIMD argument must have `simd<T, N>` or `simd_mask<T, N>`
286288
type, and `N` must be equal to the the sub-group size. The implementation may
287289
iterate through the supported sub-group sizes at compile time and check whether the
288290
function object is invocable with given sub-group size. There must be
289291
exactly one such sub-group size and it must match `N` or the user program is not
290292
well-formed.
291293
- Otherwise, if the return type of the SIMD target function is `simd<T, N>` or
292-
`simd_mask<bool, N>`, then the sub-group size is `N`.
294+
`simd_mask<T, N>`, then the sub-group size is `N`.
293295
- Otherwise (all arguments and the return type are uniform) the SIMD target is
294296
fully uniform and it can be invoked with any sub-group size.
295297

@@ -312,7 +314,7 @@ sycl::ext::oneapi::experimental::simd<float, 8> scale(sycl::ext::oneapi::experim
312314
return x * n;
313315
}
314316
315-
sycl::ext::oneapi::experimental::simd<float, 8> masked_scale(sycl::ext::oneapi::experimental::simd<float, 8> x, float n, sycl::ext::oneapi::experimental::simd_mask<bool, 8> mask)
317+
sycl::ext::oneapi::experimental::simd<float, 8> masked_scale(sycl::ext::oneapi::experimental::simd<float, 8> x, float n, sycl::ext::oneapi::experimental::simd_mask<float, 8> mask)
316318
{
317319
std::experimental::where(mask, x) *= n;
318320
return x;
@@ -330,7 +332,7 @@ q.parallel_for(..., sycl::nd_item<1> it) [[sycl::reqd_sub_group_size(8)]]
330332
331333
// invoke SIMD function with a mask parameter
332334
// x values from each work-item be a simd<float, 8>
333-
// mask values from each work-item are combined into a simd_mask<bool, 8>
335+
// mask values from each work-item are combined into a simd_mask<float, 8>
334336
bool mask = (it.get_local_id(0) % 2);
335337
float z = sycl::ext::oneapi::experimental::invoke_simd(sg, masked_scale, x, sycl::ext::oneapi::experimental::uniform(n), mask);
336338
});

0 commit comments

Comments
 (0)