Skip to content

[SYCL][GDB] Fix xmethod script for local accessors on Host #3203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion sycl/gdb/libsycl.so-gdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,23 @@ def offset(self, dim):
def data(self):
return self.payload()['MData']

class HostAccessorLocal(HostAccessor):
"""For Host device memory layout"""

def index(self, arg):
if arg.type.code == gdb.TYPE_CODE_INT:
return int(arg)
# https://github.com/intel/llvm/blob/97272b7ebd569bfa13811913a31e30f926559217/sycl/include/CL/sycl/accessor.hpp#L1049-L1053
result = 0;
for dim in range(self.depth):
result = result * \
self.payload()['MSize']['common_array'][dim] + \
arg['common_array'][dim];
return result;

def data(self):
return self.payload()['MMem']

class DeviceAccessor(Accessor):
"""For CPU/GPU memory layout"""

Expand Down Expand Up @@ -88,7 +105,8 @@ def __call__(self, obj, arg):
# try all accessor implementations until one of them works:
accessors = [
DeviceAccessor(obj, self.result_type, self.depth),
HostAccessor(obj, self.result_type, self.depth)
HostAccessor(obj, self.result_type, self.depth),
HostAccessorLocal(obj, self.result_type, self.depth)
]
for accessor in accessors:
try:
Expand Down
10 changes: 9 additions & 1 deletion sycl/test/gdb/accessors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ typedef cl::sycl::accessor<int, 1, cl::sycl::access::mode::read> dummy;
// CHECK: CXXRecordDecl {{.*}} class AccessorBaseHost definition
// CHECK-NOT: CXXRecordDecl {{.*}} definition
// CHECK: FieldDecl {{.*}} referenced impl {{.*}}:'std::shared_ptr<sycl::detail::AccessorImplHost>'

// LocalAccessorImplHost must have MSize and MMem fields

// CHECK: CXXRecordDecl {{.*}} class LocalAccessorImplHost definition
// CHECK-NOT: CXXRecordDecl {{.*}} definition
// CHECK: FieldDecl {{.*}} referenced MSize
// CHECK-NOT: CXXRecordDecl {{.*}} definition
// CHECK: FieldDecl {{.*}} referenced MMem

// CHECK: CXXRecordDecl {{.*}} class accessor definition
// CHECK-NOT: CXXRecordDecl {{.*}} definition
// CHECK: public {{.*}}:'sycl::detail::AccessorBaseHost'