Revision: 63013 https://developer.blender.org/rBL63013 Author: sergey Date: 2022-08-25 12:01:20 +0200 (Thu, 25 Aug 2022) Log Message: ----------- Add missing Sycl libraries
Added Paths: ----------- tags/blender-3.3-release/lib/linux_centos7_x86_64/dpcpp/lib/libsycl.so.5.7.0-7 tags/blender-3.3-release/lib/linux_centos7_x86_64/dpcpp/lib/libsycl.so.5.7.0-7-gdb.py Added: tags/blender-3.3-release/lib/linux_centos7_x86_64/dpcpp/lib/libsycl.so.5.7.0-7 =================================================================== (Binary files differ) Index: tags/blender-3.3-release/lib/linux_centos7_x86_64/dpcpp/lib/libsycl.so.5.7.0-7 =================================================================== --- tags/blender-3.3-release/lib/linux_centos7_x86_64/dpcpp/lib/libsycl.so.5.7.0-7 2022-08-25 09:49:41 UTC (rev 63012) +++ tags/blender-3.3-release/lib/linux_centos7_x86_64/dpcpp/lib/libsycl.so.5.7.0-7 2022-08-25 10:01:20 UTC (rev 63013) Property changes on: tags/blender-3.3-release/lib/linux_centos7_x86_64/dpcpp/lib/libsycl.so.5.7.0-7 ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +application/octet-stream \ No newline at end of property Added: tags/blender-3.3-release/lib/linux_centos7_x86_64/dpcpp/lib/libsycl.so.5.7.0-7-gdb.py =================================================================== --- tags/blender-3.3-release/lib/linux_centos7_x86_64/dpcpp/lib/libsycl.so.5.7.0-7-gdb.py (rev 0) +++ tags/blender-3.3-release/lib/linux_centos7_x86_64/dpcpp/lib/libsycl.so.5.7.0-7-gdb.py 2022-08-25 10:01:20 UTC (rev 63013) @@ -0,0 +1,358 @@ +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +import re +import gdb +import gdb.xmethod +import gdb.printing + +### XMethod implementations ### + + +class Accessor: + """Generalized base class for buffer index calculation""" + + def memory_range(self, dim): + pass + + def offset(self, dim): + pass + + def data(self): + pass + + def __init__(self, obj, result_type, depth): + self.obj = obj + self.result_type = result_type + self.depth = depth + + def index(self, arg): + if arg.type.unqualified().strip_typedefs().code == gdb.TYPE_CODE_INT: + return int(arg) + # unwrap if inside item + try: + arg = arg["MImpl"]["MIndex"] + except: + pass + result = 0 + for dim in range(self.depth): + result = ( + result * self.memory_range(dim) + + self.offset(dim) + + arg["common_array"][dim] + ) + return result + + def value(self, arg): + return self.data().cast(self.result_type.pointer())[self.index(arg)] + + +class HostAccessor(Accessor): + """For Host device memory layout""" + + def payload(self): + return self.obj["impl"]["_M_ptr"].dereference() + + def memory_range(self, dim): + return self.payload()["MMemoryRange"]["common_array"][dim] + + def offset(self, dim): + return self.payload()["MOffset"]["common_array"][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) + 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""" + + def memory_range(self, dim): + return self.obj["impl"]["MemRange"]["common_array"][dim] + + def offset(self, dim): + return self.obj["impl"]["Offset"]["common_array"][dim] + + def data(self): + return self.obj["MData"] + + +class AccessorOpIndex(gdb.xmethod.XMethodWorker): + """Generic implementation for N-dimensional ID""" + + def __init__(self, class_type, result_type, depth): + self.class_type = class_type + self.result_type = result_type + self.depth = depth + + def get_arg_types(self): + return gdb.lookup_type("sycl::_V1::id<%s>" % self.depth) + + def get_result_type(self, *args): + return self.result_type + + def __call__(self, obj, arg): + # No way to easily figure out which devices is currently being used, + # try all accessor implementations until one of them works: + accessors = [ + DeviceAccessor(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: + return accessor.value(arg) + except: + pass + + print("Failed to call '%s.operator[](%s)" % (obj.type, arg.type)) + + return None + + +class AccessorOpIndex1D(AccessorOpIndex): + """Introduces an extra overload for 1D case that takes plain size_t""" + + def get_arg_types(self): + assert self.depth == 1 + return gdb.lookup_type("size_t") + + +class AccessorOpIndexItemTrue(AccessorOpIndex): + """Introduces an extra overload for item wrapper""" + + def get_arg_types(self): + return gdb.lookup_type("sycl::_V1::item<%s, true>" % self.depth) + + +class AccessorOpIndexItemFalse(AccessorOpIndex): + """Introduces an extra overload for item wrapper""" + + def get_arg_types(self): + return gdb.lookup_type("sycl::_V1::item<%s, false>" % self.depth) + + +class AccessorMatcher(gdb.xmethod.XMethodMatcher): + """Entry point for sycl::_V1::accessor""" + + def __init__(self): + gdb.xmethod.XMethodMatcher.__init__(self, "AccessorMatcher") + + def match(self, class_type, method_name): + if method_name != "operator[]": + return None + + result = re.match("^sycl::_V1::accessor<.+>$", class_type.tag) + if result is None: + return None + + depth = int(class_type.template_argument(1)) + result_type = class_type.template_argument(0) + + methods = [AccessorOpIndex(class_type, result_type, depth)] + try: + method = AccessorOpIndexItemTrue(class_type, result_type, depth) + method.get_arg_types() + methods.append(method) + except: + pass + try: + method = AccessorOpIndexItemFalse(class_type, result_type, depth) + method.get_arg_types() + methods.append(method) + except: + pass + if depth == 1: + methods.append(AccessorOpIndex1D(class_type, result_type, depth)) + return methods + + +class PrivateMemoryOpCall(gdb.xmethod.XMethodWorker): + """Provides operator() overload for h_item argument""" + + class ItemBase: + """Wrapper for sycl::_V1::detail::ItemBase which reimplements index calculation""" + + def __init__( + self, + obj, + ): + result = re.match("^sycl::_V1::detail::ItemBase<(.+), (.+)>$", str(obj.type)) + self.dim = int(result[1]) + self.with_offset = result[2] == "true" + self.obj = obj + + def get_linear_id(self): + index = self.obj["MIndex"]["common_array"] + extent = self.obj["MExtent"]["common_array"] + + if self.with_offset: + offset = self.obj["MOffset"]["common_array"] + if self.dim == 1: + return index[0] - offset[0] + elif self.dim == 2: + return (index[0] - offset[0]) * extent[1] + (index[1] - offset[1]) + else: + return ( + ((index[0] - offset[0]) * extent[1] * extent[2]) + + ((index[1] - offset[1]) * extent[2]) + + (index[2] - offset[2]) + ) + else: + if self.dim == 1: + return index[0] + elif self.dim == 2: + return index[0] * extent[1] + index[1] + else: + return ( + (index[0] * extent[1] * extent[2]) + + (index[1] * extent[2]) + + index[2] + ) + + def __init__(self, result_type, dim): + self.result_type = result_type + self.dim = dim + + def get_arg_types(self): + return gdb.lookup_type("sycl::_V1::h_item<%s>" % self.dim) + + def get_result_type(self, *args): + return self.result_type + + def __call__(self, obj, *args): + if obj["Val"].type.tag.endswith(self.result_type): + # On device private_memory is a simple wrapper over actual value + return obj["Val"] + else: + # On host it wraps a unique_ptr to an array of items + item_base = args[0]["localItem"]["MImpl"] + item_base = self.ItemBase(item_base) + index = item_base.get_linear_id() + return obj["Val"]["_M_t"]["_M_t"]["_M_head_impl"][index] + + +class PrivateMemoryMatcher(gdb.xmethod.XMethodMatcher): + """Entry point for sycl::_V1::private_memory""" + + def __init__(self): + gdb.xmethod.XMethodMatcher.__init__(self, "PrivateMemoryMatcher") + + def match(self, class_type, method_name): + if method_name != "operator()": + return None + + result = re.match( + "^sycl::_V1::private_memory<((cl::)?(sycl::_V1::)?id<.+>), (.+)>$", class_type.tag + ) + if result is None: + return None + return PrivateMemoryOpCall(result[1], result[4]) + + +gdb.xmethod.register_xmethod_matcher(None, AccessorMatcher(), replace=True) +gdb.xmethod.register_xmethod_matcher(None, PrivateMemoryMatcher(), replace=True) + +### Pretty-printer implementations ### + + +class SyclArrayPrinter: + """Print an object deriving from sycl::_V1::detail::array""" + + class ElementIterator: + def __init__(self, data, size): + self.data = data + self.size = size + self.count = 0 + + def __iter__(self): + return self + + def __next__(self): + if self.count == self.size: + raise StopIteration + count = self.count + self.count = self.count + 1 + try: + elt = self.data[count] + except: @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs