Skip to content

Commit bff60ff

Browse files
committed
sycl: adjust to_sycl_range for ComputeCpp 1.1.6+
1 parent e8556ed commit bff60ff

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

src/sycl/sycl_utils.hpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@
2323
#include <vector>
2424
#include <CL/sycl.hpp>
2525

26+
// Intel(R) oneAPI DPC++ Compiler uses reversed global work-item IDs starting
27+
// from 10-24-2019.
28+
// ComputeCpp version >= 1.1.6 uses reversed global work-item IDs.
29+
#if defined(DNNL_SYCL_DPCPP) && (__SYCL_COMPILER_VERSION >= 20191024)
30+
#define DNNL_SYCL_REVERSE_RANGE 1
31+
#elif defined(DNNL_SYCL_COMPUTECPP) \
32+
&& (COMPUTECPP_VERSION_MAJOR > 1 \
33+
|| (COMPUTECPP_VERSION_MAJOR == 1 \
34+
&& (COMPUTECPP_VERSION_MINOR > 1 \
35+
|| (COMPUTECPP_VERSION_MINOR == 1 \
36+
&& COMPUTECPP_VERSION_PATCH >= 6))))
37+
#define DNNL_SYCL_REVERSE_RANGE 1
38+
#else
39+
#define DNNL_SYCL_REVERSE_RANGE 0
40+
#endif
41+
2642
namespace dnnl {
2743
namespace impl {
2844
namespace sycl {
@@ -31,7 +47,7 @@ using buffer_u8_t = cl::sycl::buffer<uint8_t, 1>;
3147

3248
inline cl::sycl::range<3> to_sycl_range(const compute::nd_range_t &range) {
3349
auto *global_range = range.global_range();
34-
#if defined(DNNL_SYCL_DPCPP) && (__SYCL_COMPILER_VERSION >= 20191024)
50+
#if DNNL_SYCL_REVERSE_RANGE
3551
auto sycl_global_range = cl::sycl::range<3>(
3652
global_range[2], global_range[1], global_range[0]);
3753
#else
@@ -54,7 +70,7 @@ inline cl::sycl::nd_range<3> to_sycl_nd_range(
5470
sycl_global_range, cl::sycl::range<3>(1, 1, 1));
5571
}
5672

57-
#if defined(DNNL_SYCL_DPCPP) && (__SYCL_COMPILER_VERSION >= 20191024)
73+
#if DNNL_SYCL_REVERSE_RANGE
5874
auto sycl_local_range = cl::sycl::range<3>(
5975
local_range[2], local_range[1], local_range[0]);
6076
#else
@@ -68,4 +84,6 @@ inline cl::sycl::nd_range<3> to_sycl_nd_range(
6884
} // namespace impl
6985
} // namespace dnnl
7086

87+
#undef DNNL_SYCL_REVERSE_RANGE
88+
7189
#endif

0 commit comments

Comments
 (0)