Skip to content

Commit b1252f2

Browse files
[SYCL][GDB] Fix xmethod script for local accessors on Host
Previous version of script didn't take into account that local accessors have a slightly different index calculation logic on Host and need to be treated specially. For Device the same script should still be applicable.
1 parent 33a2868 commit b1252f2

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

sycl/gdb/libsycl.so-gdb.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ def offset(self, dim):
5656
def data(self):
5757
return self.payload()['MData']
5858

59+
class HostAccessorLocal(HostAccessor):
60+
"""For Host device memory layout"""
61+
62+
def index(self, arg):
63+
if arg.type.code == gdb.TYPE_CODE_INT:
64+
return int(arg)
65+
# https://github.com/intel/llvm/blob/97272b7ebd569bfa13811913a31e30f926559217/sycl/include/CL/sycl/accessor.hpp#L1049-L1053
66+
result = 0;
67+
for dim in range(self.depth):
68+
result = result * \
69+
self.payload()['MSize']['common_array'][dim] + \
70+
arg['common_array'][dim];
71+
return result;
72+
73+
def data(self):
74+
return self.payload()['MMem']
75+
5976
class DeviceAccessor(Accessor):
6077
"""For CPU/GPU memory layout"""
6178

@@ -88,7 +105,8 @@ def __call__(self, obj, arg):
88105
# try all accessor implementations until one of them works:
89106
accessors = [
90107
DeviceAccessor(obj, self.result_type, self.depth),
91-
HostAccessor(obj, self.result_type, self.depth)
108+
HostAccessor(obj, self.result_type, self.depth),
109+
HostAccessorLocal(obj, self.result_type, self.depth)
92110
]
93111
for accessor in accessors:
94112
try:

sycl/test/gdb/accessors.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ typedef cl::sycl::accessor<int, 1, cl::sycl::access::mode::read> dummy;
1919
// CHECK: CXXRecordDecl {{.*}} class AccessorBaseHost definition
2020
// CHECK-NOT: CXXRecordDecl {{.*}} definition
2121
// CHECK: FieldDecl {{.*}} referenced impl {{.*}}:'std::shared_ptr<sycl::detail::AccessorImplHost>'
22+
23+
// LocalAccessorImplHost must have MSize and MMem fields
24+
25+
// CHECK: CXXRecordDecl {{.*}} class LocalAccessorImplHost definition
26+
// CHECK-NOT: CXXRecordDecl {{.*}} definition
27+
// CHECK: FieldDecl {{.*}} referenced MSize
28+
// CHECK-NOT: CXXRecordDecl {{.*}} definition
29+
// CHECK: FieldDecl {{.*}} referenced MMem
30+
2231
// CHECK: CXXRecordDecl {{.*}} class accessor definition
2332
// CHECK-NOT: CXXRecordDecl {{.*}} definition
2433
// CHECK: public {{.*}}:'sycl::detail::AccessorBaseHost'
25-

0 commit comments

Comments
 (0)