From b1252f2a13fab08ee352b985312635040acff886 Mon Sep 17 00:00:00 2001 From: Mihails Strasuns Date: Thu, 11 Feb 2021 16:09:07 +0100 Subject: [PATCH] [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. --- sycl/gdb/libsycl.so-gdb.py | 20 +++++++++++++++++++- sycl/test/gdb/accessors.cpp | 10 +++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/sycl/gdb/libsycl.so-gdb.py b/sycl/gdb/libsycl.so-gdb.py index b98e2c80949bf..aaa4f85f8a64e 100644 --- a/sycl/gdb/libsycl.so-gdb.py +++ b/sycl/gdb/libsycl.so-gdb.py @@ -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""" @@ -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: diff --git a/sycl/test/gdb/accessors.cpp b/sycl/test/gdb/accessors.cpp index e30d597c7e462..34ee280350509 100644 --- a/sycl/test/gdb/accessors.cpp +++ b/sycl/test/gdb/accessors.cpp @@ -19,7 +19,15 @@ typedef cl::sycl::accessor dummy; // CHECK: CXXRecordDecl {{.*}} class AccessorBaseHost definition // CHECK-NOT: CXXRecordDecl {{.*}} definition // CHECK: FieldDecl {{.*}} referenced impl {{.*}}:'std::shared_ptr' + +// 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' -