Skip to content

Commit 2f0f381

Browse files
authored
[SYCL][ESIMD] Support get_multi_ptr in ESIMD context (#10638)
accessor::get_pointer() is now deprecated in favor of get_multi_ptr. This also fixes a number of tests that use deprecated get_pointer: accessor::get_pointer() has been changed to conform to a recent change to the SYCL specification, where it now returns multi_ptr rather than a raw pointer, where the result of get_pointer is being cast to uintptr_t, and there is no conversion operator from multi_ptr, so it's necessary to retrieve the raw pointer first. get_multi_ptr is used instead.
1 parent ed79eed commit 2f0f381

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

llvm/lib/SYCLLowerIR/ESIMD/ESIMDVerifier.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ static const char *LegalSYCLFunctions[] = {
3939
"^sycl::_V1::local_accessor<.+>::local_accessor",
4040
"^sycl::_V1::local_accessor<.+>::__init_esimd",
4141
"^sycl::_V1::local_accessor<.+>::get_pointer",
42+
"^sycl::_V1::local_accessor<.+>::get_multi_ptr",
4243
"^sycl::_V1::local_accessor_base<.+>::local_accessor_base",
4344
"^sycl::_V1::local_accessor_base<.+>::__init_esimd",
4445
"^sycl::_V1::local_accessor_base<.+>::getQualifiedPtr",
@@ -67,6 +68,7 @@ static const char *LegalSYCLFunctions[] = {
6768

6869
static const char *LegalSYCLFunctionsInStatelessMode[] = {
6970
"^sycl::_V1::accessor<.+>::get_pointer.+",
71+
"^sycl::_V1::accessor<.+>::get_multi_ptr.+",
7072
"^sycl::_V1::accessor<.+>::getPointerAdjusted",
7173
"^sycl::_V1::accessor<.+>::getTotalOffset",
7274
"^sycl::_V1::accessor<.+>::getLinearIndex",

sycl/test-e2e/InvokeSimd/Regression/nbarrier_exec_in_order.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ ESIMD_INLINE void ESIMD_CALLEE_nbarrier(local_accessor<int, 1> local_acc,
5353

5454
esimd::simd<int, VL> val(local_id);
5555

56-
unsigned int slm_base = static_cast<uint32_t>(reinterpret_cast<std::uintptr_t>(local_acc.get_pointer()));
56+
unsigned int slm_base =
57+
static_cast<uint32_t>(reinterpret_cast<std::uintptr_t>(
58+
local_acc.get_multi_ptr<access::decorated::no>().get_raw()));
5759

5860
/* Each thread operates on a region of memory (global or slm) that overlaps
5961
* with that of the previous and next threads.

sycl/test-e2e/InvokeSimd/Regression/nbarrier_loop.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,9 @@ ESIMD_INLINE void ESIMD_CALLEE_nbarrier(local_accessor<int, 1> local_acc,
6060
unsigned int prods[2] = {2, 1}; // number of producers
6161

6262
// Producer writes to SLM, consumer reads what producer wrote.
63-
unsigned int slm_base = static_cast<uint32_t>(
64-
reinterpret_cast<std::uintptr_t>(local_acc.get_pointer()));
63+
unsigned int slm_base =
64+
static_cast<uint32_t>(reinterpret_cast<std::uintptr_t>(
65+
local_acc.get_multi_ptr<access::decorated::no>().get_raw()));
6566

6667
esimd::barrier();
6768

sycl/test-e2e/InvokeSimd/Regression/nbarrier_multiple_wg.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ ESIMD_INLINE void ESIMD_CALLEE_nbarrier(local_accessor<int, 1> local_acc,
6464
unsigned int global_off = VL * (is_producer ? global_id : (global_id - 1));
6565

6666
unsigned int slm_base =
67-
static_cast<uint32_t>(
68-
reinterpret_cast<std::uintptr_t>(local_acc.get_pointer()));
67+
static_cast<uint32_t>(reinterpret_cast<std::uintptr_t>(
68+
local_acc.get_multi_ptr<access::decorated::no>().get_raw()));
6969
unsigned int slm_off = slm_base + global_off * sizeof(int);
7070

7171
esimd::barrier();

sycl/test/esimd/esimd_verify.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ using namespace sycl;
1010
using namespace sycl::ext::intel::esimd;
1111

1212
// CHECK-NEGATIVE-DAG: error: function 'sycl::_V1::multi_ptr<{{.+}}> sycl::_V1::accessor<{{.+}}>::get_pointer<{{.+}}>() const' is not supported in ESIMD context
13+
// CHECK-NEGATIVE-DAG: error: function 'std::conditional<true, sycl::_V1::multi_ptr{{.+}}>::type sycl::_V1::accessor<{{.+}}>::get_multi_ptr<{{.+}}>() const' is not supported in ESIMD context
1314
// CHECK-NEGATIVE-DAG: error: function '{{.+}} sycl::_V1::accessor<{{.+}}>::operator[]<{{.+}}>({{.+}}) const' is not supported in ESIMD context
1415
// CHECK-NEGATIVE-DAG: error: function '{{.+}}combine(int const&)' is not supported in ESIMD context
1516

@@ -21,13 +22,19 @@ test0(accessor<int, 1, access::mode::read_write, access::target::device> &acc)
2122
return acc.get_pointer();
2223
}
2324

24-
SYCL_EXTERNAL void
25+
SYCL_EXTERNAL auto
2526
test1(accessor<int, 1, access::mode::read_write, access::target::device> &acc)
2627
SYCL_ESIMD_FUNCTION {
28+
return acc.get_multi_ptr<access::decorated::no>();
29+
}
30+
31+
SYCL_EXTERNAL void
32+
test2(accessor<int, 1, access::mode::read_write, access::target::device> &acc)
33+
SYCL_ESIMD_FUNCTION {
2734
acc[0] = 0;
2835
}
2936

30-
void test2(sycl::handler &cgh, int *buf) {
37+
void test3(sycl::handler &cgh, int *buf) {
3138
auto reduction = sycl::reduction(buf, sycl::plus<int>());
3239
cgh.parallel_for<class Test2>(sycl::range<1>(1), reduction,
3340
[=](sycl::id<1>, auto &reducer)

0 commit comments

Comments
 (0)