diff --git a/dpctl/_backend.pxd b/dpctl/_backend.pxd index 22753f4bff..ee8680fdc5 100644 --- a/dpctl/_backend.pxd +++ b/dpctl/_backend.pxd @@ -47,6 +47,7 @@ cdef extern from "syclinterface/dpctl_sycl_enum_types.h": _HIP "DPCTL_HIP" _LEVEL_ZERO "DPCTL_LEVEL_ZERO" _OPENCL "DPCTL_OPENCL" + _NATIVE_CPU "DPCTL_NATIVE_CPU" _UNKNOWN_BACKEND "DPCTL_UNKNOWN_BACKEND" ctypedef enum _device_type "DPCTLSyclDeviceType": diff --git a/dpctl/_sycl_device.pyx b/dpctl/_sycl_device.pyx index 2d750c971e..a382f99e26 100644 --- a/dpctl/_sycl_device.pyx +++ b/dpctl/_sycl_device.pyx @@ -557,6 +557,8 @@ cdef class SyclDevice(_SyclDevice): return backend_type.level_zero elif BTy == _backend_type._OPENCL: return backend_type.opencl + elif BTy == _backend_type._NATIVE_CPU: + return backend_type.native_cpu else: raise ValueError("Unknown backend type.") diff --git a/dpctl/_sycl_device_factory.pyx b/dpctl/_sycl_device_factory.pyx index b94313d322..e9ae7ba762 100644 --- a/dpctl/_sycl_device_factory.pyx +++ b/dpctl/_sycl_device_factory.pyx @@ -81,6 +81,8 @@ cdef _backend_type _string_to_dpctl_sycl_backend_ty(str backend_str): return _backend_type._LEVEL_ZERO elif backend_str == "opencl": return _backend_type._OPENCL + elif backend_str == "native_cpu": + return _backend_type._NATIVE_CPU else: return _backend_type._UNKNOWN_BACKEND @@ -114,6 +116,8 @@ cdef _backend_type _enum_to_dpctl_sycl_backend_ty(BTy): return _backend_type._LEVEL_ZERO elif BTy == backend_type.opencl: return _backend_type._OPENCL + elif BTy == backend_type.native_cpu: + return _backend_type._NATIVE_CPU else: return _backend_type._UNKNOWN_BACKEND @@ -163,7 +167,7 @@ cpdef tuple get_devices( backend (str, :class:`dpctl.backend_type`, optional): A :class:`dpctl.backend_type` enum value or a string that specifies a SYCL backend. Currently, accepted values are: "cuda", - "hip", "opencl", "level_zero", or "all". + "hip", "opencl", "level_zero", "native_cpu", or "all". Default: ``dpctl.backend_type.all``. device_type (str, :class:`dpctl.device_type`, optional): A :class:`dpctl.device_type` enum value or a string that @@ -247,7 +251,7 @@ cpdef int get_num_devices( backend (str, :class:`dpctl.backend_type`, optional): A :class:`dpctl.backend_type` enum value or a string that specifies a SYCL backend. Currently, accepted values are: "cuda", - "hip", "opencl", "level_zero", or "all". + "hip", "opencl", "level_zero", "native_cpu", or "all". Default: ``dpctl.backend_type.all``. device_type (str, :class:`dpctl.device_type`, optional): A :class:`dpctl.device_type` enum value or a string that diff --git a/dpctl/_sycl_event.pyx b/dpctl/_sycl_event.pyx index 0eaa94c033..e6bf6503d2 100644 --- a/dpctl/_sycl_event.pyx +++ b/dpctl/_sycl_event.pyx @@ -336,6 +336,8 @@ cdef class SyclEvent(_SyclEvent): return backend_type.cuda elif BE == _backend_type._HIP: return backend_type.hip + elif BE == _backend_type._NATIVE_CPU: + return backend_type.native_cpu else: raise ValueError("Unknown backend type.") diff --git a/dpctl/_sycl_platform.pyx b/dpctl/_sycl_platform.pyx index d722e93b50..092c534763 100644 --- a/dpctl/_sycl_platform.pyx +++ b/dpctl/_sycl_platform.pyx @@ -310,6 +310,8 @@ cdef class SyclPlatform(_SyclPlatform): return backend_type.level_zero elif BTy == _backend_type._OPENCL: return backend_type.opencl + elif BTy == _backend_type._NATIVE_CPU: + return backend_type.native_cpu else: raise ValueError("Unknown backend type.") diff --git a/dpctl/_sycl_queue.pyx b/dpctl/_sycl_queue.pyx index a22586b71e..ae09b368de 100644 --- a/dpctl/_sycl_queue.pyx +++ b/dpctl/_sycl_queue.pyx @@ -1118,6 +1118,8 @@ cdef class SyclQueue(_SyclQueue): return backend_type.cuda elif BE == _backend_type._HIP: return backend_type.hip + elif BE == _backend_type._NATIVE_CPU: + return backend_type.native_cpu else: raise ValueError("Unknown backend type.") diff --git a/dpctl/enum_types.py b/dpctl/enum_types.py index f445ebb7f6..7dbcf2356b 100644 --- a/dpctl/enum_types.py +++ b/dpctl/enum_types.py @@ -95,6 +95,7 @@ class backend_type(Enum): cuda = auto() hip = auto() level_zero = auto() + native_cpu = auto() opencl = auto() diff --git a/libsyclinterface/helper/source/dpctl_utils_helper.cpp b/libsyclinterface/helper/source/dpctl_utils_helper.cpp index c03887a2b1..34cc333ad3 100644 --- a/libsyclinterface/helper/source/dpctl_utils_helper.cpp +++ b/libsyclinterface/helper/source/dpctl_utils_helper.cpp @@ -94,6 +94,8 @@ backend DPCTL_DPCTLBackendTypeToSyclBackend(DPCTLSyclBackendType BeTy) return backend::all; case DPCTLSyclBackendType::DPCTL_HIP: return backend::ext_oneapi_hip; + case DPCTLSyclBackendType::DPCTL_NATIVE_CPU: + return backend::ext_oneapi_native_cpu; default: throw std::runtime_error("Unsupported backend type"); } @@ -110,6 +112,8 @@ DPCTLSyclBackendType DPCTL_SyclBackendToDPCTLBackendType(backend B) return DPCTLSyclBackendType::DPCTL_OPENCL; case backend::ext_oneapi_hip: return DPCTLSyclBackendType::DPCTL_HIP; + case backend::ext_oneapi_native_cpu: + return DPCTLSyclBackendType::DPCTL_NATIVE_CPU; default: return DPCTLSyclBackendType::DPCTL_UNKNOWN_BACKEND; } diff --git a/libsyclinterface/include/syclinterface/dpctl_sycl_enum_types.h b/libsyclinterface/include/syclinterface/dpctl_sycl_enum_types.h index c66b8330f9..b489ba512e 100644 --- a/libsyclinterface/include/syclinterface/dpctl_sycl_enum_types.h +++ b/libsyclinterface/include/syclinterface/dpctl_sycl_enum_types.h @@ -56,6 +56,7 @@ typedef enum DPCTL_UNKNOWN_BACKEND = 0, DPCTL_ALL_BACKENDS = ((1<<5)-1) << 16, DPCTL_HIP = 1 << 19, + DPCTL_NATIVE_CPU = 1 << 20, // clang-format on } DPCTLSyclBackendType; diff --git a/libsyclinterface/source/dpctl_sycl_context_interface.cpp b/libsyclinterface/source/dpctl_sycl_context_interface.cpp index c27cd9a343..ac55e97147 100644 --- a/libsyclinterface/source/dpctl_sycl_context_interface.cpp +++ b/libsyclinterface/source/dpctl_sycl_context_interface.cpp @@ -195,6 +195,8 @@ DPCTLContext_GetBackend(__dpctl_keep const DPCTLSyclContextRef CtxRef) return DPCTL_CUDA; case backend::ext_oneapi_hip: return DPCTL_HIP; + case backend::ext_oneapi_native_cpu: + return DPCTL_NATIVE_CPU; default: return DPCTL_UNKNOWN_BACKEND; }