diff --git a/src/pystencils/backend/platforms/sycl.py b/src/pystencils/backend/platforms/sycl.py index fdc19a0c4ad126e9a9e3622cf781e31125292348..52953115ab3a50139c6bfdf047cc8f9fa53714d8 100644 --- a/src/pystencils/backend/platforms/sycl.py +++ b/src/pystencils/backend/platforms/sycl.py @@ -101,7 +101,13 @@ class SyclPlatform(GenericGpu): indexing_decls = [id_decl] conds = [] - for i, dim in enumerate(dimensions[::-1]): + + # Other than in CUDA, SYCL ids are linearized in C order + # The leftmost entry of an ID varies slowest, and the rightmost entry varies fastest + # See https://registry.khronos.org/SYCL/specs/sycl-2020/html/sycl-2020.html#sec:multi-dim-linearization + + for i, dim in enumerate(dimensions): + # Slowest to fastest coord = PsExpression.make(PsConstant(i, self._ctx.index_dtype)) work_item_idx = PsSubscript(id_symbol, coord)