From f0d93b68e5a73352d2ec40a4d15f144ea255f865 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Sun, 4 Oct 2020 02:35:10 -0500 Subject: [PATCH 01/12] Add wrapper functions over device properties used inside Numba. --- backends/include/dppl_sycl_device_interface.h | 50 +++++++ backends/include/dppl_utils.h | 11 +- .../source/dppl_sycl_device_interface.cpp | 124 +++++++++++++++--- backends/source/dppl_utils.cpp | 5 + 4 files changed, 172 insertions(+), 18 deletions(-) diff --git a/backends/include/dppl_sycl_device_interface.h b/backends/include/dppl_sycl_device_interface.h index 01e3c08101..f1619ffcae 100644 --- a/backends/include/dppl_sycl_device_interface.h +++ b/backends/include/dppl_sycl_device_interface.h @@ -102,6 +102,56 @@ DPPL_API __dppl_give const char* DPPLDevice_GetDriverInfo (__dppl_keep const DPPLSyclDeviceRef DRef); +/*! + * @brief Wrapper over device.get_info(). + * + * @param DRef Opaque pointer to a sycl::device + * @return Returns the valid result if device exists else returns 0. + */ +DPPL_API +uint32_t +DPPLDevice_GetMaxComputeUnites (__dppl_keep const DPPLSyclDeviceRef DRef); + +/*! + * @brief Wrapper for get_info. + * + * @param DRef Opaque pointer to a sycl::device + * @return Returns the valid result if device exists else returns 0. + */ +DPPL_API +uint32_t +DPPLDevice_GetMaxNumSubGroups (__dppl_keep const DPPLSyclDeviceRef DRef); + /*! * @brief Returns a C string for the device name. * diff --git a/backends/include/dppl_utils.h b/backends/include/dppl_utils.h index 3a19bf3e45..be523622ba 100644 --- a/backends/include/dppl_utils.h +++ b/backends/include/dppl_utils.h @@ -24,6 +24,7 @@ #pragma once +#include "dppl_data_types.h" #include "Support/DllExport.h" #include "Support/ExternC.h" #include "Support/MemOwnershipAttrs.h" @@ -31,11 +32,19 @@ DPPL_C_EXTERN_C_BEGIN /*! - * @brief Deletes the C String argument + * @brief Deletes the C String argument. * * @param str C string to be deleted */ DPPL_API void DPPLCString_Delete (__dppl_take const char* str); +/*! + * @brief Deletes an array of size_t elements. + * + * @param arr Array to be deleted. + */ +DPPL_API +void DPPLSize_t_Array_Delete (__dppl_take size_t* arr); + DPPL_C_EXTERN_C_END diff --git a/backends/source/dppl_sycl_device_interface.cpp b/backends/source/dppl_sycl_device_interface.cpp index 2ef55fd322..0c3bb77af2 100644 --- a/backends/source/dppl_sycl_device_interface.cpp +++ b/backends/source/dppl_sycl_device_interface.cpp @@ -103,53 +103,143 @@ void DPPLDevice_Delete (__dppl_take DPPLSyclDeviceRef DRef) bool DPPLDevice_IsAccelerator (__dppl_keep const DPPLSyclDeviceRef DRef) { - return unwrap(DRef)->is_accelerator(); + auto D = unwrap(DRef); + if(D) { + return unwrap(DRef)->is_accelerator(); + } + return false; } bool DPPLDevice_IsCPU (__dppl_keep const DPPLSyclDeviceRef DRef) { - return unwrap(DRef)->is_cpu(); + auto D = unwrap(DRef); + if(D) { + return unwrap(DRef)->is_cpu(); + } + return false; + } bool DPPLDevice_IsGPU (__dppl_keep const DPPLSyclDeviceRef DRef) { - return unwrap(DRef)->is_gpu(); + auto D = unwrap(DRef); + if(D) { + return unwrap(DRef)->is_gpu(); + } + return false; } bool DPPLDevice_IsHost (__dppl_keep const DPPLSyclDeviceRef DRef) { - return unwrap(DRef)->is_host(); + auto D = unwrap(DRef); + if(D) { + return unwrap(DRef)->is_host(); + } + return false; +} + + +uint32_t +DPPLDevice_GetMaxComputeUnites (__dppl_keep const DPPLSyclDeviceRef DRef) +{ + auto D = unwrap(DRef); + if(D) { + return D->get_info(); + } + return 0; + +} + +uint32_t +DPPLDevice_GetMaxWorkItemDims (__dppl_keep const DPPLSyclDeviceRef DRef) +{ + auto D = unwrap(DRef); + if(D) { + return D->get_info(); + } + return 0; +} + +__dppl_keep size_t* +DPPLDevice_GetMaxWorkItemSizes (__dppl_keep const DPPLSyclDeviceRef DRef) +{ + size_t *sizes = nullptr; + auto D = unwrap(DRef); + if(D) { + auto id_sizes = D->get_info(); + sizes = new size_t[3]; + for(auto i = 0ul; i < 3; ++i) { + sizes[i] = id_sizes[i]; + } + } + return sizes; +} + +size_t +DPPLDevice_GetMaxWorkGroupSize (__dppl_keep const DPPLSyclDeviceRef DRef) +{ + auto D = unwrap(DRef); + if(D) { + return D->get_info(); + } + return 0; +} + +uint32_t +DPPLDevice_GetMaxNumSubGroups (__dppl_keep const DPPLSyclDeviceRef DRef) +{ + auto D = unwrap(DRef); + if(D) { + return D->get_info(); + } + return 0; } __dppl_give const char* DPPLDevice_GetName (__dppl_keep const DPPLSyclDeviceRef DRef) { - auto name = unwrap(DRef)->get_info(); - auto cstr_name = new char [name.length()+1]; - std::strcpy (cstr_name, name.c_str()); - return cstr_name; + auto D = unwrap(DRef); + if(D) { + auto name = unwrap(DRef)->get_info(); + auto cstr_name = new char [name.length()+1]; + std::strcpy (cstr_name, name.c_str()); + return cstr_name; + } + return nullptr; } __dppl_give const char* DPPLDevice_GetVendorName (__dppl_keep const DPPLSyclDeviceRef DRef) { - auto vendor = unwrap(DRef)->get_info(); - auto cstr_vendor = new char [vendor.length()+1]; - std::strcpy (cstr_vendor, vendor.c_str()); - return cstr_vendor; + auto D = unwrap(DRef); + if(D) { + auto vendor = unwrap(DRef)->get_info(); + auto cstr_vendor = new char [vendor.length()+1]; + std::strcpy (cstr_vendor, vendor.c_str()); + return cstr_vendor; + } + return nullptr; } __dppl_give const char* DPPLDevice_GetDriverInfo (__dppl_keep const DPPLSyclDeviceRef DRef) { - auto driver = unwrap(DRef)->get_info(); - auto cstr_driver = new char [driver.length()+1]; - std::strcpy (cstr_driver, driver.c_str()); - return cstr_driver; + auto D = unwrap(DRef); + if(D) { + auto driver = unwrap(DRef)->get_info(); + auto cstr_driver = new char [driver.length()+1]; + std::strcpy (cstr_driver, driver.c_str()); + return cstr_driver; + } + return nullptr; } bool DPPLDevice_IsHostUnifiedMemory (__dppl_keep const DPPLSyclDeviceRef DRef) { - return unwrap(DRef)->get_info(); + auto D = unwrap(DRef); + if(D) { + return D->get_info(); + } + return false; } diff --git a/backends/source/dppl_utils.cpp b/backends/source/dppl_utils.cpp index b3e4206679..f18bd94f78 100644 --- a/backends/source/dppl_utils.cpp +++ b/backends/source/dppl_utils.cpp @@ -29,3 +29,8 @@ void DPPLCString_Delete (__dppl_take const char* str) { delete[] str; } + +void DPPLSize_t_Array_Delete (__dppl_take size_t* arr) +{ + delete[] arr; +} \ No newline at end of file From c07a8eda5c13cdc6f4d190f29d85cb5af4ef4b46 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Sun, 4 Oct 2020 23:17:48 -0500 Subject: [PATCH 02/12] Add unit test cases for dppl_sycl_device_interface.cpp --- backends/tests/CMakeLists.txt | 1 + backends/tests/test_sycl_device_interface.cpp | 230 ++++++++++++++++++ backends/tests/test_sycl_kernel_interface.cpp | 6 +- 3 files changed, 234 insertions(+), 3 deletions(-) create mode 100644 backends/tests/test_sycl_device_interface.cpp diff --git a/backends/tests/CMakeLists.txt b/backends/tests/CMakeLists.txt index 08e7f9f9ff..86233ef7d5 100644 --- a/backends/tests/CMakeLists.txt +++ b/backends/tests/CMakeLists.txt @@ -23,6 +23,7 @@ else() link_directories(${GTEST_LIB_DIR}) set(PYDPPL_BACKEND_TEST_CASES + test_sycl_device_interface test_sycl_kernel_interface test_sycl_platform_interface test_sycl_program_interface diff --git a/backends/tests/test_sycl_device_interface.cpp b/backends/tests/test_sycl_device_interface.cpp new file mode 100644 index 0000000000..4f209d5b4f --- /dev/null +++ b/backends/tests/test_sycl_device_interface.cpp @@ -0,0 +1,230 @@ +//===----- test_sycl_device_interface.cpp - DPPL-SYCL interface -*- C++ -*-===// +// +// Python Data Parallel Processing Library (PyDPPL) +// +// Copyright 2020 Intel Corporation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// This file has unit test cases for functions defined in +/// dppl_sycl_kernel_interface.h. +/// +//===----------------------------------------------------------------------===// + +#include "dppl_sycl_device_interface.h" +#include "dppl_sycl_queue_interface.h" +#include "dppl_sycl_queue_manager.h" +#include "dppl_utils.h" + +#include +#include + +using namespace cl::sycl; + + +struct TestDPPLSyclDeviceInterface : public ::testing::Test +{ + DPPLSyclDeviceRef OpenCL_cpu = nullptr; + DPPLSyclDeviceRef OpenCL_gpu = nullptr; + + TestDPPLSyclDeviceInterface () + { + if(DPPLQueueMgr_GetNumQueues(DPPL_OPENCL, DPPL_CPU)) { + auto Q = DPPLQueueMgr_GetQueue(DPPL_OPENCL, DPPL_CPU, 0); + OpenCL_cpu = DPPLQueue_GetDevice(Q); + DPPLQueue_Delete(Q); + } + + if(DPPLQueueMgr_GetNumQueues(DPPL_OPENCL, DPPL_GPU)) { + auto Q = DPPLQueueMgr_GetQueue(DPPL_OPENCL, DPPL_GPU, 0); + OpenCL_gpu = DPPLQueue_GetDevice(Q); + DPPLQueue_Delete(Q); + } + } + + ~TestDPPLSyclDeviceInterface () + { + DPPLDevice_Delete(OpenCL_cpu); + DPPLDevice_Delete(OpenCL_gpu); + } + +}; + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetDriverInfo) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto DriverInfo = DPPLDevice_GetDriverInfo(OpenCL_cpu); + EXPECT_TRUE(DriverInfo != nullptr); + DPPLCString_Delete(DriverInfo); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetDriverInfo) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto DriverInfo = DPPLDevice_GetDriverInfo(OpenCL_gpu); + EXPECT_TRUE(DriverInfo != nullptr); + DPPLCString_Delete(DriverInfo); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxComputeUnites) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto n = DPPLDevice_GetMaxComputeUnites(OpenCL_cpu); + EXPECT_TRUE(n != 0); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxComputeUnites) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL GPU device found."); + + auto n = DPPLDevice_GetMaxComputeUnites(OpenCL_gpu); + EXPECT_TRUE(n != 0); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkItemDims) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto n = DPPLDevice_GetMaxWorkItemDims(OpenCL_cpu); + EXPECT_TRUE(n != 0); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkItemDims) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL GPU device found."); + + auto n = DPPLDevice_GetMaxWorkItemDims(OpenCL_gpu); + EXPECT_TRUE(n != 0); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkItemSizes) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL GPU device found."); + + auto item_sizes = DPPLDevice_GetMaxWorkItemSizes(OpenCL_cpu); + EXPECT_TRUE(item_sizes != nullptr); + DPPLSize_t_Array_Delete(item_sizes); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkGroupSize) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto n = DPPLDevice_GetMaxWorkGroupSize(OpenCL_cpu); + EXPECT_TRUE(n != 0); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkGroupSize) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL GPU device found."); + + auto n = DPPLDevice_GetMaxWorkGroupSize(OpenCL_gpu); + EXPECT_TRUE(n != 0); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxNumSubGroups) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto n = DPPLDevice_GetMaxNumSubGroups(OpenCL_cpu); + EXPECT_TRUE(n != 0); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxNumSubGroups) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL GPU device found."); + + auto n = DPPLDevice_GetMaxNumSubGroups(OpenCL_gpu); + EXPECT_TRUE(n != 0); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetName) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto DevName = DPPLDevice_GetName(OpenCL_cpu); + EXPECT_TRUE(DevName != nullptr); + DPPLCString_Delete(DevName); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetName) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto DevName = DPPLDevice_GetName(OpenCL_gpu); + EXPECT_TRUE(DevName != nullptr); + DPPLCString_Delete(DevName); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetVendorName) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto VendorName = DPPLDevice_GetVendorName(OpenCL_cpu); + EXPECT_TRUE(VendorName != nullptr); + DPPLCString_Delete(VendorName); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetVendorName) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto VendorName = DPPLDevice_GetVendorName(OpenCL_gpu); + EXPECT_TRUE(VendorName != nullptr); + DPPLCString_Delete(VendorName); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_IsCPU) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + EXPECT_TRUE(DPPLDevice_IsCPU(OpenCL_cpu)); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_IsGPU) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + EXPECT_TRUE(DPPLDevice_IsGPU(OpenCL_gpu)); +} + +int +main (int argc, char** argv) +{ + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + return ret; +} \ No newline at end of file diff --git a/backends/tests/test_sycl_kernel_interface.cpp b/backends/tests/test_sycl_kernel_interface.cpp index 4777e6e654..b07592c202 100644 --- a/backends/tests/test_sycl_kernel_interface.cpp +++ b/backends/tests/test_sycl_kernel_interface.cpp @@ -112,7 +112,7 @@ TEST_F (TestDPPLSyclKernelInterface, CheckGetNumArgs) int main (int argc, char** argv) { - ::testing::InitGoogleTest(&argc, argv); - int ret = RUN_ALL_TESTS(); - return ret; + ::testing::InitGoogleTest(&argc, argv); + int ret = RUN_ALL_TESTS(); + return ret; } From 614acd49beec3c4a2285254c0356270654f405f3 Mon Sep 17 00:00:00 2001 From: etotmeni Date: Mon, 12 Oct 2020 11:01:49 -0500 Subject: [PATCH 03/12] change and fixes for existing funcs --- backends/include/dppl_sycl_device_interface.h | 8 +-- .../source/dppl_sycl_device_interface.cpp | 2 +- backends/tests/test_sycl_device_interface.cpp | 20 ++++-- dpctl/_sycl_core.pxd | 15 ++++ dpctl/backend.pxd | 13 +++- dpctl/sycl_core.pyx | 56 +++++++++++++-- dpctl/tests/__init__.py | 1 + dpctl/tests/test_sycl_device.py | 72 +++++++++++++++++++ 8 files changed, 170 insertions(+), 17 deletions(-) create mode 100644 dpctl/tests/test_sycl_device.py diff --git a/backends/include/dppl_sycl_device_interface.h b/backends/include/dppl_sycl_device_interface.h index f1619ffcae..d0176f8303 100644 --- a/backends/include/dppl_sycl_device_interface.h +++ b/backends/include/dppl_sycl_device_interface.h @@ -110,10 +110,10 @@ DPPLDevice_GetDriverInfo (__dppl_keep const DPPLSyclDeviceRef DRef); */ DPPL_API uint32_t -DPPLDevice_GetMaxComputeUnites (__dppl_keep const DPPLSyclDeviceRef DRef); +DPPLDevice_GetMaxComputeUnits (__dppl_keep const DPPLSyclDeviceRef DRef); /*! - * @brief Wrapper for get_info(). * * @param DRef Opaque pointer to a sycl::device * @return Returns the valid result if device exists else returns 0. @@ -123,7 +123,7 @@ uint32_t DPPLDevice_GetMaxWorkItemDims (__dppl_keep const DPPLSyclDeviceRef DRef); /*! - * @brief Wrapper for get_info(). * * @param DRef Opaque pointer to a sycl::device * @return Returns the valid result if device exists else returns Null. @@ -133,7 +133,7 @@ __dppl_keep size_t* DPPLDevice_GetMaxWorkItemSizes (__dppl_keep const DPPLSyclDeviceRef DRef); /*! - * @brief Wrapper for get_info(). * * @param DRef Opaque pointer to a sycl::device * @return Returns the valid result if device exists else returns 0. diff --git a/backends/source/dppl_sycl_device_interface.cpp b/backends/source/dppl_sycl_device_interface.cpp index 0c3bb77af2..acd2079d1f 100644 --- a/backends/source/dppl_sycl_device_interface.cpp +++ b/backends/source/dppl_sycl_device_interface.cpp @@ -141,7 +141,7 @@ bool DPPLDevice_IsHost (__dppl_keep const DPPLSyclDeviceRef DRef) uint32_t -DPPLDevice_GetMaxComputeUnites (__dppl_keep const DPPLSyclDeviceRef DRef) +DPPLDevice_GetMaxComputeUnits (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); if(D) { diff --git a/backends/tests/test_sycl_device_interface.cpp b/backends/tests/test_sycl_device_interface.cpp index 4f209d5b4f..2b213de742 100644 --- a/backends/tests/test_sycl_device_interface.cpp +++ b/backends/tests/test_sycl_device_interface.cpp @@ -83,21 +83,21 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetDriverInfo) DPPLCString_Delete(DriverInfo); } -TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxComputeUnites) +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxComputeUnits) { if(!OpenCL_cpu) GTEST_SKIP_("Skipping as no OpenCL CPU device found."); - auto n = DPPLDevice_GetMaxComputeUnites(OpenCL_cpu); + auto n = DPPLDevice_GetMaxComputeUnits(OpenCL_cpu); EXPECT_TRUE(n != 0); } -TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxComputeUnites) +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxComputeUnits) { if(!OpenCL_gpu) GTEST_SKIP_("Skipping as no OpenCL GPU device found."); - auto n = DPPLDevice_GetMaxComputeUnites(OpenCL_gpu); + auto n = DPPLDevice_GetMaxComputeUnits(OpenCL_gpu); EXPECT_TRUE(n != 0); } @@ -122,13 +122,23 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkItemDims) TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkItemSizes) { if(!OpenCL_cpu) - GTEST_SKIP_("Skipping as no OpenCL GPU device found."); + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); auto item_sizes = DPPLDevice_GetMaxWorkItemSizes(OpenCL_cpu); EXPECT_TRUE(item_sizes != nullptr); DPPLSize_t_Array_Delete(item_sizes); } +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkItemSizes) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL GPU device found."); + + auto item_sizes = DPPLDevice_GetMaxWorkItemSizes(OpenCL_gpu); + EXPECT_TRUE(item_sizes != nullptr); + DPPLSize_t_Array_Delete(item_sizes); +} + TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkGroupSize) { if(!OpenCL_cpu) diff --git a/dpctl/_sycl_core.pxd b/dpctl/_sycl_core.pxd index a95e5f28c5..757d8a81de 100644 --- a/dpctl/_sycl_core.pxd +++ b/dpctl/_sycl_core.pxd @@ -28,6 +28,7 @@ # cython: language_level=3 from .backend cimport * +from libc.stdint cimport uint32_t cdef class SyclContext: @@ -48,10 +49,24 @@ cdef class SyclDevice: cdef const char *_vendor_name cdef const char *_device_name cdef const char *_driver_version + cdef uint32_t _max_compute_units + cdef uint32_t _max_work_item_dims + cdef size_t* _max_work_item_sizes + cdef size_t _max_work_group_size + cdef uint32_t _max_num_sub_groups @staticmethod cdef SyclDevice _create (DPPLSyclDeviceRef dref) cdef DPPLSyclDeviceRef get_device_ref (self) + cpdef get_device_name (self) + cpdef get_device_type (self) + cpdef get_vendor_name (self) + cpdef get_driver_version (self) + cpdef get_max_compute_units (self) + cpdef get_max_work_item_dims (self) + cpdef get_max_work_item_sizes (self) + cpdef get_max_work_group_size (self) + cpdef get_max_num_sub_groups (self) cdef class SyclEvent: diff --git a/dpctl/backend.pxd b/dpctl/backend.pxd index c7cecae87a..d7907ecd89 100644 --- a/dpctl/backend.pxd +++ b/dpctl/backend.pxd @@ -28,10 +28,12 @@ # cython: language_level=3 from libcpp cimport bool +from libc.stdint cimport uint32_t cdef extern from "dppl_utils.h": cdef void DPPLCString_Delete (const char *str) + cdef void DPPLSize_t_Array_Delete (size_t* arr) cdef extern from "dppl_sycl_enum_types.h": cdef enum _backend_type 'DPPLSyclBEType': @@ -96,10 +98,15 @@ cdef extern from "dppl_sycl_device_interface.h": cdef bool DPPLDevice_IsCPU (const DPPLSyclDeviceRef DRef) cdef bool DPPLDevice_IsGPU (const DPPLSyclDeviceRef DRef) cdef bool DPPLDevice_IsHost (const DPPLSyclDeviceRef DRef) - cdef const char* DPPLDevice_GetDriverInfo (const DPPLSyclDeviceRef DRef) - cdef const char* DPPLDevice_GetName (const DPPLSyclDeviceRef DRef) - cdef const char* DPPLDevice_GetVendorName (const DPPLSyclDeviceRef DRef) + cpdef const char* DPPLDevice_GetDriverInfo (const DPPLSyclDeviceRef DRef) + cpdef const char* DPPLDevice_GetName (const DPPLSyclDeviceRef DRef) + cpdef const char* DPPLDevice_GetVendorName (const DPPLSyclDeviceRef DRef) cdef bool DPPLDevice_IsHostUnifiedMemory (const DPPLSyclDeviceRef DRef) + cpdef uint32_t DPPLDevice_GetMaxComputeUnits (const DPPLSyclDeviceRef DRef) + cpdef uint32_t DPPLDevice_GetMaxWorkItemDims (const DPPLSyclDeviceRef DRef) + cpdef size_t* DPPLDevice_GetMaxWorkItemSizes (const DPPLSyclDeviceRef DRef) + cpdef size_t DPPLDevice_GetMaxWorkGroupSize (const DPPLSyclDeviceRef DRef) + cpdef uint32_t DPPLDevice_GetMaxNumSubGroups (const DPPLSyclDeviceRef DRef) cdef extern from "dppl_sycl_event_interface.h": diff --git a/dpctl/sycl_core.pyx b/dpctl/sycl_core.pyx index ea1916fc46..af2747a3b6 100644 --- a/dpctl/sycl_core.pyx +++ b/dpctl/sycl_core.pyx @@ -117,6 +117,11 @@ cdef class SyclDevice: ret._vendor_name = DPPLDevice_GetVendorName(dref) ret._device_name = DPPLDevice_GetName(dref) ret._driver_version = DPPLDevice_GetDriverInfo(dref) + ret._max_compute_units = DPPLDevice_GetMaxComputeUnits(dref) + ret._max_work_item_dims = DPPLDevice_GetMaxWorkItemDims(dref) + ret._max_work_item_sizes = DPPLDevice_GetMaxWorkItemSizes(dref) + ret._max_work_group_size = DPPLDevice_GetMaxWorkGroupSize(dref) + ret._max_num_sub_groups = DPPLDevice_GetMaxNumSubGroups(dref) return ret def __dealloc__ (self): @@ -130,12 +135,12 @@ cdef class SyclDevice: ''' DPPLDevice_DumpInfo(self._device_ref) - def get_device_name (self): + cpdef get_device_name (self): ''' Returns the name of the device as a string ''' return self._device_name.decode() - def get_device_type (self): + cpdef get_device_type (self): ''' Returns the type of the device as a `device_type` enum ''' if DPPLDevice_IsGPU(self._device_ref): @@ -145,12 +150,12 @@ cdef class SyclDevice: else: raise ValueError("Unknown device type.") - def get_vendor_name (self): + cpdef get_vendor_name (self): ''' Returns the device vendor name as a string ''' return self._vendor_name.decode() - def get_driver_version (self): + cpdef get_driver_version (self): ''' Returns the OpenCL software driver version as a string in the form: major number.minor number, if this SYCL device is an OpenCL device. Returns a string class @@ -158,6 +163,49 @@ cdef class SyclDevice: ''' return self._driver_version.decode() + cpdef get_max_compute_units (self): + ''' Returns the number of parallel compute units + available to the device. The minimum value is 1. + ''' + return self._max_compute_units + + cpdef get_max_work_item_dims (self): + ''' Returns the maximum dimensions that specify + the global and local work-item IDs used by the + data parallel execution model. The minimum + value is 3 if this SYCL device is not of device + type info::device_type::custom. + ''' + return self._max_work_item_dims + + cpdef get_max_work_item_sizes (self): + ''' Returns the maximum number of work-items + that are permitted in each dimension of the + work-group of the nd_range. The minimum + value is (1; 1; 1) for devices that are not of + device type info::device_type::custom. + ''' + max_work_item_sizes = [] + for n in range(3): + max_work_item_sizes.append(self._max_work_item_sizes[n]) + DPPLSize_t_Array_Delete(self._max_work_item_sizes) + return tuple(max_work_item_sizes) + + cpdef get_max_work_group_size (self): + ''' Returns the maximum number of work-items + that are permitted in a work-group executing a + kernel on a single compute unit. The minimum + value is 1. + ''' + return self._max_work_group_size + + cpdef get_max_num_sub_groups (self): + ''' Returns the maximum number of sub-groups + in a work-group for any kernel executed on the + device. The minimum value is 1. + ''' + return self._max_num_sub_groups + cdef DPPLSyclDeviceRef get_device_ref (self): ''' Returns the DPPLSyclDeviceRef pointer for this class. ''' diff --git a/dpctl/tests/__init__.py b/dpctl/tests/__init__.py index f04131d53a..a53980d17a 100644 --- a/dpctl/tests/__init__.py +++ b/dpctl/tests/__init__.py @@ -23,6 +23,7 @@ ##===----------------------------------------------------------------------===## from .test_dump_functions import * +from .test_sycl_device import * from .test_sycl_kernel_submit import * from .test_sycl_program import * from .test_sycl_queue import * diff --git a/dpctl/tests/test_sycl_device.py b/dpctl/tests/test_sycl_device.py new file mode 100644 index 0000000000..9295616d3b --- /dev/null +++ b/dpctl/tests/test_sycl_device.py @@ -0,0 +1,72 @@ +##===------------- test_sycl_device.py - dpctl -------*- Python -*---------===## +## +## Data Parallel Control (dpctl) +## +## Copyright 2020 Intel Corporation +## +## Licensed under the Apache License, Version 2.0 (the "License"); +## you may not use this file except in compliance with the License. +## You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## +##===----------------------------------------------------------------------===## +## +## \file +## Defines unit test cases for the SyclDevice classes defined in sycl_core.pyx. +##===----------------------------------------------------------------------===## + +import dpctl +import unittest + +@unittest.skipIf(not dpctl.has_sycl_platforms(), "No SYCL platforms available") +class TestSyclDevice (unittest.TestCase): + + def test_get_max_compute_units (self): + q = dpctl.get_current_queue() + try: + max_compute_units = q.get_sycl_device().get_max_compute_units() + except Exception: + self.fail("Encountered an exception inside get_max_compute_units().") + self.assertNotEqual(max_compute_units, 0) + + def test_get_max_work_item_dims (self): + q = dpctl.get_current_queue() + try: + max_work_item_dims = q.get_sycl_device().get_max_work_item_dims() + except Exception: + self.fail("Encountered an exception inside get_max_work_item_dims().") + self.assertNotEqual(max_work_item_dims, 0) + + def test_get_max_work_item_sizes (self): + q = dpctl.get_current_queue() + try: + max_work_item_sizes = q.get_sycl_device().get_max_work_item_sizes() + except Exception: + self.fail("Encountered an exception inside get_max_work_item_sizes().") + self.assertNotEqual(max_work_item_sizes, (None, None, None)) + + def test_get_max_work_group_size (self): + q = dpctl.get_current_queue() + try: + max_work_group_size = q.get_sycl_device().get_max_work_group_size() + except Exception: + self.fail("Encountered an exception inside get_max_work_group_size().") + self.assertNotEqual(max_work_group_size, 0) + + def test_get_max_num_sub_groups (self): + q = dpctl.get_current_queue() + try: + max_num_sub_groups = q.get_sycl_device().get_max_num_sub_groups() + except Exception: + self.fail("Encountered an exception inside get_max_num_sub_groups().") + self.assertNotEqual(max_num_sub_groups, 0) + +if __name__ == '__main__': + unittest.main() From f3582d9677eb96b393103e379315f347fc8f749f Mon Sep 17 00:00:00 2001 From: etotmeni Date: Tue, 13 Oct 2020 07:48:04 -0500 Subject: [PATCH 04/12] Add device::aspects for int64_base_atomics and int64_extended_atomics --- backends/include/dppl_sycl_device_interface.h | 20 +++++++++++ .../source/dppl_sycl_device_interface.cpp | 20 +++++++++++ backends/tests/test_sycl_device_interface.cpp | 36 +++++++++++++++++++ dpctl/_sycl_core.pxd | 4 +++ dpctl/backend.pxd | 2 ++ dpctl/sycl_core.pyx | 12 +++++++ dpctl/tests/test_sycl_device.py | 16 +++++++++ 7 files changed, 110 insertions(+) diff --git a/backends/include/dppl_sycl_device_interface.h b/backends/include/dppl_sycl_device_interface.h index d0176f8303..6a416e7fc9 100644 --- a/backends/include/dppl_sycl_device_interface.h +++ b/backends/include/dppl_sycl_device_interface.h @@ -152,6 +152,26 @@ DPPL_API uint32_t DPPLDevice_GetMaxNumSubGroups (__dppl_keep const DPPLSyclDeviceRef DRef); +/*! + * @brief Wrapper over device.get_info. + * + * @param DRef Opaque pointer to a sycl::device + * @return Returns true if device has int64_base_atomics else returns false. + */ +DPPL_API +bool +DPPLDevice_GetAspectsBaseAtomics (__dppl_keep const DPPLSyclDeviceRef DRef); + +/*! + * @brief Wrapper over device.get_info. + * + * @param DRef Opaque pointer to a sycl::device + * @return Returns true if device has int64_extended_atomics else returns false. + */ +DPPL_API +bool +DPPLDevice_GetAspectsExtendedAtomics (__dppl_keep const DPPLSyclDeviceRef DRef); + /*! * @brief Returns a C string for the device name. * diff --git a/backends/source/dppl_sycl_device_interface.cpp b/backends/source/dppl_sycl_device_interface.cpp index acd2079d1f..57ad2c49ed 100644 --- a/backends/source/dppl_sycl_device_interface.cpp +++ b/backends/source/dppl_sycl_device_interface.cpp @@ -196,6 +196,26 @@ DPPLDevice_GetMaxNumSubGroups (__dppl_keep const DPPLSyclDeviceRef DRef) return 0; } +bool +DPPLDevice_GetAspectsBaseAtomics (__dppl_keep const DPPLSyclDeviceRef DRef) +{ + auto D = unwrap(DRef); + if(D) { + return D->has(aspect::int64_base_atomics); + } + return false; +} + +bool +DPPLDevice_GetAspectsExtendedAtomics (__dppl_keep const DPPLSyclDeviceRef DRef) +{ + auto D = unwrap(DRef); + if(D) { + return D->has(aspect::int64_extended_atomics); + } + return false; +} + __dppl_give const char* DPPLDevice_GetName (__dppl_keep const DPPLSyclDeviceRef DRef) { diff --git a/backends/tests/test_sycl_device_interface.cpp b/backends/tests/test_sycl_device_interface.cpp index 2b213de742..aa684ef085 100644 --- a/backends/tests/test_sycl_device_interface.cpp +++ b/backends/tests/test_sycl_device_interface.cpp @@ -175,6 +175,42 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxNumSubGroups) EXPECT_TRUE(n != 0); } +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetAspectsBaseAtomics) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto n = DPPLDevice_GetAspectsBaseAtomics(OpenCL_cpu); + EXPECT_TRUE(n != false); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetAspectsBaseAtomics) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL GPU device found."); + + auto n = DPPLDevice_GetAspectsBaseAtomics(OpenCL_gpu); + EXPECT_TRUE(n != false); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetAspectsExtendedAtomics) +{ + if(!OpenCL_cpu) + GTEST_SKIP_("Skipping as no OpenCL CPU device found."); + + auto n = DPPLDevice_GetAspectsExtendedAtomics(OpenCL_cpu); + EXPECT_TRUE(n != false); +} + +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetAspectsExtendedAtomics) +{ + if(!OpenCL_gpu) + GTEST_SKIP_("Skipping as no OpenCL GPU device found."); + + auto n = DPPLDevice_GetAspectsExtendedAtomics(OpenCL_gpu); + EXPECT_TRUE(n != false); +} + TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetName) { if(!OpenCL_cpu) diff --git a/dpctl/_sycl_core.pxd b/dpctl/_sycl_core.pxd index 757d8a81de..0d1eb7db6d 100644 --- a/dpctl/_sycl_core.pxd +++ b/dpctl/_sycl_core.pxd @@ -54,6 +54,8 @@ cdef class SyclDevice: cdef size_t* _max_work_item_sizes cdef size_t _max_work_group_size cdef uint32_t _max_num_sub_groups + cdef bool _aspects_base_atomics + cdef bool _aspects_extended_atomics @staticmethod cdef SyclDevice _create (DPPLSyclDeviceRef dref) @@ -67,6 +69,8 @@ cdef class SyclDevice: cpdef get_max_work_item_sizes (self) cpdef get_max_work_group_size (self) cpdef get_max_num_sub_groups (self) + cpdef get_aspects_base_atomics (self) + cpdef get_aspects_extended_atomics (self) cdef class SyclEvent: diff --git a/dpctl/backend.pxd b/dpctl/backend.pxd index d7907ecd89..b281dbd8b9 100644 --- a/dpctl/backend.pxd +++ b/dpctl/backend.pxd @@ -107,6 +107,8 @@ cdef extern from "dppl_sycl_device_interface.h": cpdef size_t* DPPLDevice_GetMaxWorkItemSizes (const DPPLSyclDeviceRef DRef) cpdef size_t DPPLDevice_GetMaxWorkGroupSize (const DPPLSyclDeviceRef DRef) cpdef uint32_t DPPLDevice_GetMaxNumSubGroups (const DPPLSyclDeviceRef DRef) + cpdef bool DPPLDevice_GetAspectsBaseAtomics (const DPPLSyclDeviceRef DRef) + cpdef bool DPPLDevice_GetAspectsExtendedAtomics (const DPPLSyclDeviceRef DRef) cdef extern from "dppl_sycl_event_interface.h": diff --git a/dpctl/sycl_core.pyx b/dpctl/sycl_core.pyx index af2747a3b6..95eda03dba 100644 --- a/dpctl/sycl_core.pyx +++ b/dpctl/sycl_core.pyx @@ -122,6 +122,8 @@ cdef class SyclDevice: ret._max_work_item_sizes = DPPLDevice_GetMaxWorkItemSizes(dref) ret._max_work_group_size = DPPLDevice_GetMaxWorkGroupSize(dref) ret._max_num_sub_groups = DPPLDevice_GetMaxNumSubGroups(dref) + ret._aspects_base_atomics = DPPLDevice_GetAspectsBaseAtomics(dref) + ret._aspects_extended_atomics = DPPLDevice_GetAspectsExtendedAtomics(dref) return ret def __dealloc__ (self): @@ -163,6 +165,16 @@ cdef class SyclDevice: ''' return self._driver_version.decode() + cpdef get_aspects_base_atomics (self): + ''' Returns true if device has int64_base_atomics else returns false. + ''' + return self._aspects_base_atomics + + cpdef get_aspects_extended_atomics (self): + ''' Returns true if device has int64_extended_atomics else returns false. + ''' + return self._aspects_extended_atomics + cpdef get_max_compute_units (self): ''' Returns the number of parallel compute units available to the device. The minimum value is 1. diff --git a/dpctl/tests/test_sycl_device.py b/dpctl/tests/test_sycl_device.py index 9295616d3b..f800d57c4d 100644 --- a/dpctl/tests/test_sycl_device.py +++ b/dpctl/tests/test_sycl_device.py @@ -68,5 +68,21 @@ def test_get_max_num_sub_groups (self): self.fail("Encountered an exception inside get_max_num_sub_groups().") self.assertNotEqual(max_num_sub_groups, 0) + def test_get_aspects_base_atomics (self): + q = dpctl.get_current_queue() + try: + aspects_base_atomics = q.get_sycl_device().get_aspects_base_atomics() + except Exception: + self.fail("Encountered an exception inside get_aspects_base_atomics().") + self.assertNotEqual(aspects_base_atomics, False) + + def test_get_aspects_extended_atomics (self): + q = dpctl.get_current_queue() + try: + aspects_extended_atomics = q.get_sycl_device().get_aspects_extended_atomics() + except Exception: + self.fail("Encountered an exception inside get_aspects_extended_atomics().") + self.assertNotEqual(aspects_extended_atomics, False) + if __name__ == '__main__': unittest.main() From e3c901d580bb94dce19717ac9099e529aeb2cab9 Mon Sep 17 00:00:00 2001 From: etotmeni Date: Wed, 14 Oct 2020 11:15:01 -0500 Subject: [PATCH 05/12] Fixes according comments --- backends/include/dppl_sycl_device_interface.h | 8 +-- .../source/dppl_sycl_device_interface.cpp | 50 +++++++++---------- backends/source/dppl_utils.cpp | 4 +- backends/tests/test_sycl_device_interface.cpp | 43 ++++++++++------ dpctl/_sycl_core.pxd | 8 +-- dpctl/backend.pxd | 4 +- dpctl/sycl_core.pyx | 14 +++--- dpctl/tests/test_sycl_device.py | 12 ++--- 8 files changed, 78 insertions(+), 65 deletions(-) diff --git a/backends/include/dppl_sycl_device_interface.h b/backends/include/dppl_sycl_device_interface.h index 6a416e7fc9..df92e454f5 100644 --- a/backends/include/dppl_sycl_device_interface.h +++ b/backends/include/dppl_sycl_device_interface.h @@ -1,4 +1,4 @@ -//===--- dppl_sycl_device_interface.h - DPPL-SYCL interface ---*---C++ -*---===// +//===--- dppl_sycl_device_interface.h - dpctl-C_API interface ---*---C++ -*---===// // // Python Data Parallel Processing Library (PyDPPL) // @@ -126,7 +126,7 @@ DPPLDevice_GetMaxWorkItemDims (__dppl_keep const DPPLSyclDeviceRef DRef); * @brief Wrapper for get_info(). * * @param DRef Opaque pointer to a sycl::device - * @return Returns the valid result if device exists else returns Null. + * @return Returns the valid result if device exists else returns NULL. */ DPPL_API __dppl_keep size_t* @@ -160,7 +160,7 @@ DPPLDevice_GetMaxNumSubGroups (__dppl_keep const DPPLSyclDeviceRef DRef); */ DPPL_API bool -DPPLDevice_GetAspectsBaseAtomics (__dppl_keep const DPPLSyclDeviceRef DRef); +DPPLDevice_HasInt64BaseAtomics (__dppl_keep const DPPLSyclDeviceRef DRef); /*! * @brief Wrapper over device.get_info. @@ -170,7 +170,7 @@ DPPLDevice_GetAspectsBaseAtomics (__dppl_keep const DPPLSyclDeviceRef DRef); */ DPPL_API bool -DPPLDevice_GetAspectsExtendedAtomics (__dppl_keep const DPPLSyclDeviceRef DRef); +DPPLDevice_HasInt64ExtendedAtomics (__dppl_keep const DPPLSyclDeviceRef DRef); /*! * @brief Returns a C string for the device name. diff --git a/backends/source/dppl_sycl_device_interface.cpp b/backends/source/dppl_sycl_device_interface.cpp index 57ad2c49ed..02b24487b0 100644 --- a/backends/source/dppl_sycl_device_interface.cpp +++ b/backends/source/dppl_sycl_device_interface.cpp @@ -1,4 +1,4 @@ -//===--- dppl_sycl_device_interface.cpp - DPPL-SYCL interface --*- C++ -*--===// +//===--- dppl_sycl_device_interface.cpp - dpctl-C_API interface --*- C++ -*--===// // // Python Data Parallel Processing Library (PyDPPL) // @@ -104,8 +104,8 @@ void DPPLDevice_Delete (__dppl_take DPPLSyclDeviceRef DRef) bool DPPLDevice_IsAccelerator (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { - return unwrap(DRef)->is_accelerator(); + if (D) { + return D->is_accelerator(); } return false; } @@ -113,8 +113,8 @@ bool DPPLDevice_IsAccelerator (__dppl_keep const DPPLSyclDeviceRef DRef) bool DPPLDevice_IsCPU (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { - return unwrap(DRef)->is_cpu(); + if (D) { + return D->is_cpu(); } return false; @@ -123,8 +123,8 @@ bool DPPLDevice_IsCPU (__dppl_keep const DPPLSyclDeviceRef DRef) bool DPPLDevice_IsGPU (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { - return unwrap(DRef)->is_gpu(); + if (D) { + return D->is_gpu(); } return false; } @@ -133,8 +133,8 @@ bool DPPLDevice_IsGPU (__dppl_keep const DPPLSyclDeviceRef DRef) bool DPPLDevice_IsHost (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { - return unwrap(DRef)->is_host(); + if (D) { + return D->is_host(); } return false; } @@ -144,7 +144,7 @@ uint32_t DPPLDevice_GetMaxComputeUnits (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { + if (D) { return D->get_info(); } return 0; @@ -155,7 +155,7 @@ uint32_t DPPLDevice_GetMaxWorkItemDims (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { + if (D) { return D->get_info(); } return 0; @@ -166,7 +166,7 @@ DPPLDevice_GetMaxWorkItemSizes (__dppl_keep const DPPLSyclDeviceRef DRef) { size_t *sizes = nullptr; auto D = unwrap(DRef); - if(D) { + if (D) { auto id_sizes = D->get_info(); sizes = new size_t[3]; for(auto i = 0ul; i < 3; ++i) { @@ -180,7 +180,7 @@ size_t DPPLDevice_GetMaxWorkGroupSize (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { + if (D) { return D->get_info(); } return 0; @@ -190,27 +190,27 @@ uint32_t DPPLDevice_GetMaxNumSubGroups (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { + if (D) { return D->get_info(); } return 0; } bool -DPPLDevice_GetAspectsBaseAtomics (__dppl_keep const DPPLSyclDeviceRef DRef) +DPPLDevice_HasInt64BaseAtomics (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { + if (D) { return D->has(aspect::int64_base_atomics); } return false; } bool -DPPLDevice_GetAspectsExtendedAtomics (__dppl_keep const DPPLSyclDeviceRef DRef) +DPPLDevice_HasInt64ExtendedAtomics (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { + if (D) { return D->has(aspect::int64_extended_atomics); } return false; @@ -220,8 +220,8 @@ __dppl_give const char* DPPLDevice_GetName (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { - auto name = unwrap(DRef)->get_info(); + if (D) { + auto name = D->get_info(); auto cstr_name = new char [name.length()+1]; std::strcpy (cstr_name, name.c_str()); return cstr_name; @@ -233,8 +233,8 @@ __dppl_give const char* DPPLDevice_GetVendorName (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { - auto vendor = unwrap(DRef)->get_info(); + if (D) { + auto vendor = D->get_info(); auto cstr_vendor = new char [vendor.length()+1]; std::strcpy (cstr_vendor, vendor.c_str()); return cstr_vendor; @@ -246,8 +246,8 @@ __dppl_give const char* DPPLDevice_GetDriverInfo (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { - auto driver = unwrap(DRef)->get_info(); + if (D) { + auto driver = D->get_info(); auto cstr_driver = new char [driver.length()+1]; std::strcpy (cstr_driver, driver.c_str()); return cstr_driver; @@ -258,7 +258,7 @@ DPPLDevice_GetDriverInfo (__dppl_keep const DPPLSyclDeviceRef DRef) bool DPPLDevice_IsHostUnifiedMemory (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); - if(D) { + if (D) { return D->get_info(); } return false; diff --git a/backends/source/dppl_utils.cpp b/backends/source/dppl_utils.cpp index f18bd94f78..52cfce96e7 100644 --- a/backends/source/dppl_utils.cpp +++ b/backends/source/dppl_utils.cpp @@ -1,4 +1,4 @@ -//===--------- dppl_utils.cpp - DPPL-SYCL interface ----*---- C++ ----*----===// +//===--------- dppl_utils.cpp - dpctl-C_API interface ----*---- C++ ----*----===// // // Python Data Parallel Processing Library (PyDPPL) // @@ -33,4 +33,4 @@ void DPPLCString_Delete (__dppl_take const char* str) void DPPLSize_t_Array_Delete (__dppl_take size_t* arr) { delete[] arr; -} \ No newline at end of file +} diff --git a/backends/tests/test_sycl_device_interface.cpp b/backends/tests/test_sycl_device_interface.cpp index aa684ef085..2538324ccb 100644 --- a/backends/tests/test_sycl_device_interface.cpp +++ b/backends/tests/test_sycl_device_interface.cpp @@ -1,4 +1,4 @@ -//===----- test_sycl_device_interface.cpp - DPPL-SYCL interface -*- C++ -*-===// +//===----- test_sycl_device_interface.cpp - dpctl-C_API interface -*- C++ -*-===// // // Python Data Parallel Processing Library (PyDPPL) // @@ -20,7 +20,7 @@ /// /// \file /// This file has unit test cases for functions defined in -/// dppl_sycl_kernel_interface.h. +/// dppl_sycl_device_interface.h. /// //===----------------------------------------------------------------------===// @@ -31,6 +31,7 @@ #include #include +#include using namespace cl::sycl; @@ -175,40 +176,52 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxNumSubGroups) EXPECT_TRUE(n != 0); } -TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetAspectsBaseAtomics) +//TODO: Update when DPC++ properly supports aspects +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_HasInt64BaseAtomics) { if(!OpenCL_cpu) GTEST_SKIP_("Skipping as no OpenCL CPU device found."); - auto n = DPPLDevice_GetAspectsBaseAtomics(OpenCL_cpu); - EXPECT_TRUE(n != false); + auto atomics = DPPLDevice_HasInt64BaseAtomics(OpenCL_cpu); + auto D = reinterpret_cast(OpenCL_cpu); + auto has_atomics= D->has(aspect::int64_base_atomics); + EXPECT_TRUE(has_atomics == atomics); } -TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetAspectsBaseAtomics) +//TODO: Update when DPC++ properly supports aspects +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_HasInt64BaseAtomics) { if(!OpenCL_gpu) GTEST_SKIP_("Skipping as no OpenCL GPU device found."); - auto n = DPPLDevice_GetAspectsBaseAtomics(OpenCL_gpu); - EXPECT_TRUE(n != false); + auto atomics = DPPLDevice_HasInt64BaseAtomics(OpenCL_gpu); + auto D = reinterpret_cast(OpenCL_gpu); + auto has_atomics= D->has(aspect::int64_base_atomics); + EXPECT_TRUE(has_atomics == atomics); } -TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetAspectsExtendedAtomics) +//TODO: Update when DPC++ properly supports aspects +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_HasInt64ExtendedAtomics) { if(!OpenCL_cpu) GTEST_SKIP_("Skipping as no OpenCL CPU device found."); - auto n = DPPLDevice_GetAspectsExtendedAtomics(OpenCL_cpu); - EXPECT_TRUE(n != false); + auto atomics = DPPLDevice_HasInt64ExtendedAtomics(OpenCL_cpu); + auto D = reinterpret_cast(OpenCL_cpu); + auto has_atomics= D->has(aspect::int64_extended_atomics); + EXPECT_TRUE(has_atomics == atomics); } -TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetAspectsExtendedAtomics) +//TODO: Update when DPC++ properly supports aspects +TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_HasInt64ExtendedAtomics) { if(!OpenCL_gpu) GTEST_SKIP_("Skipping as no OpenCL GPU device found."); - auto n = DPPLDevice_GetAspectsExtendedAtomics(OpenCL_gpu); - EXPECT_TRUE(n != false); + auto atomics = DPPLDevice_HasInt64ExtendedAtomics(OpenCL_gpu); + auto D = reinterpret_cast(OpenCL_gpu); + auto has_atomics= D->has(aspect::int64_extended_atomics); + EXPECT_TRUE(has_atomics == atomics); } TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetName) @@ -273,4 +286,4 @@ main (int argc, char** argv) ::testing::InitGoogleTest(&argc, argv); int ret = RUN_ALL_TESTS(); return ret; -} \ No newline at end of file +} diff --git a/dpctl/_sycl_core.pxd b/dpctl/_sycl_core.pxd index 0d1eb7db6d..bfff0be362 100644 --- a/dpctl/_sycl_core.pxd +++ b/dpctl/_sycl_core.pxd @@ -54,8 +54,8 @@ cdef class SyclDevice: cdef size_t* _max_work_item_sizes cdef size_t _max_work_group_size cdef uint32_t _max_num_sub_groups - cdef bool _aspects_base_atomics - cdef bool _aspects_extended_atomics + cdef bool _int64_base_atomics + cdef bool _int64_extended_atomics @staticmethod cdef SyclDevice _create (DPPLSyclDeviceRef dref) @@ -69,8 +69,8 @@ cdef class SyclDevice: cpdef get_max_work_item_sizes (self) cpdef get_max_work_group_size (self) cpdef get_max_num_sub_groups (self) - cpdef get_aspects_base_atomics (self) - cpdef get_aspects_extended_atomics (self) + cpdef has_int64_base_atomics (self) + cpdef has_int64_extended_atomics (self) cdef class SyclEvent: diff --git a/dpctl/backend.pxd b/dpctl/backend.pxd index b281dbd8b9..8b3d3f36eb 100644 --- a/dpctl/backend.pxd +++ b/dpctl/backend.pxd @@ -107,8 +107,8 @@ cdef extern from "dppl_sycl_device_interface.h": cpdef size_t* DPPLDevice_GetMaxWorkItemSizes (const DPPLSyclDeviceRef DRef) cpdef size_t DPPLDevice_GetMaxWorkGroupSize (const DPPLSyclDeviceRef DRef) cpdef uint32_t DPPLDevice_GetMaxNumSubGroups (const DPPLSyclDeviceRef DRef) - cpdef bool DPPLDevice_GetAspectsBaseAtomics (const DPPLSyclDeviceRef DRef) - cpdef bool DPPLDevice_GetAspectsExtendedAtomics (const DPPLSyclDeviceRef DRef) + cpdef bool DPPLDevice_HasInt64BaseAtomics (const DPPLSyclDeviceRef DRef) + cpdef bool DPPLDevice_HasInt64ExtendedAtomics (const DPPLSyclDeviceRef DRef) cdef extern from "dppl_sycl_event_interface.h": diff --git a/dpctl/sycl_core.pyx b/dpctl/sycl_core.pyx index 95eda03dba..91eefe234a 100644 --- a/dpctl/sycl_core.pyx +++ b/dpctl/sycl_core.pyx @@ -122,8 +122,8 @@ cdef class SyclDevice: ret._max_work_item_sizes = DPPLDevice_GetMaxWorkItemSizes(dref) ret._max_work_group_size = DPPLDevice_GetMaxWorkGroupSize(dref) ret._max_num_sub_groups = DPPLDevice_GetMaxNumSubGroups(dref) - ret._aspects_base_atomics = DPPLDevice_GetAspectsBaseAtomics(dref) - ret._aspects_extended_atomics = DPPLDevice_GetAspectsExtendedAtomics(dref) + ret._int64_base_atomics = DPPLDevice_HasInt64BaseAtomics(dref) + ret._int64_extended_atomics = DPPLDevice_HasInt64ExtendedAtomics(dref) return ret def __dealloc__ (self): @@ -131,6 +131,7 @@ cdef class SyclDevice: DPPLCString_Delete(self._device_name) DPPLCString_Delete(self._vendor_name) DPPLCString_Delete(self._driver_version) + DPPLSize_t_Array_Delete(self._max_work_item_sizes) def dump_device_info (self): ''' Print information about the SYCL device. @@ -165,15 +166,15 @@ cdef class SyclDevice: ''' return self._driver_version.decode() - cpdef get_aspects_base_atomics (self): + cpdef has_int64_base_atomics (self): ''' Returns true if device has int64_base_atomics else returns false. ''' - return self._aspects_base_atomics + return self._int64_base_atomics - cpdef get_aspects_extended_atomics (self): + cpdef has_int64_extended_atomics (self): ''' Returns true if device has int64_extended_atomics else returns false. ''' - return self._aspects_extended_atomics + return self._int64_extended_atomics cpdef get_max_compute_units (self): ''' Returns the number of parallel compute units @@ -200,7 +201,6 @@ cdef class SyclDevice: max_work_item_sizes = [] for n in range(3): max_work_item_sizes.append(self._max_work_item_sizes[n]) - DPPLSize_t_Array_Delete(self._max_work_item_sizes) return tuple(max_work_item_sizes) cpdef get_max_work_group_size (self): diff --git a/dpctl/tests/test_sycl_device.py b/dpctl/tests/test_sycl_device.py index f800d57c4d..3491c6e0e1 100644 --- a/dpctl/tests/test_sycl_device.py +++ b/dpctl/tests/test_sycl_device.py @@ -68,20 +68,20 @@ def test_get_max_num_sub_groups (self): self.fail("Encountered an exception inside get_max_num_sub_groups().") self.assertNotEqual(max_num_sub_groups, 0) - def test_get_aspects_base_atomics (self): + def test_has_int64_base_atomics (self): q = dpctl.get_current_queue() try: - aspects_base_atomics = q.get_sycl_device().get_aspects_base_atomics() + aspects_base_atomics = q.get_sycl_device().has_int64_base_atomics() except Exception: - self.fail("Encountered an exception inside get_aspects_base_atomics().") + self.fail("Encountered an exception inside has_int64_base_atomics().") self.assertNotEqual(aspects_base_atomics, False) - def test_get_aspects_extended_atomics (self): + def test_has_int64_extended_atomics (self): q = dpctl.get_current_queue() try: - aspects_extended_atomics = q.get_sycl_device().get_aspects_extended_atomics() + aspects_extended_atomics = q.get_sycl_device().has_int64_extended_atomics() except Exception: - self.fail("Encountered an exception inside get_aspects_extended_atomics().") + self.fail("Encountered an exception inside has_int64_extended_atomics().") self.assertNotEqual(aspects_extended_atomics, False) if __name__ == '__main__': From 19abe76c8c25404b8d6dc87fbb6866908db57e4a Mon Sep 17 00:00:00 2001 From: etotmeni Date: Wed, 14 Oct 2020 12:02:34 -0500 Subject: [PATCH 06/12] Fix tests --- backends/tests/test_sycl_device_interface.cpp | 17 ++++++++--------- dpctl/tests/test_sycl_device.py | 8 ++++---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/backends/tests/test_sycl_device_interface.cpp b/backends/tests/test_sycl_device_interface.cpp index 2538324ccb..0b0076702a 100644 --- a/backends/tests/test_sycl_device_interface.cpp +++ b/backends/tests/test_sycl_device_interface.cpp @@ -31,7 +31,6 @@ #include #include -#include using namespace cl::sycl; @@ -90,7 +89,7 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxComputeUnits) GTEST_SKIP_("Skipping as no OpenCL CPU device found."); auto n = DPPLDevice_GetMaxComputeUnits(OpenCL_cpu); - EXPECT_TRUE(n != 0); + EXPECT_TRUE(n > 0); } TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxComputeUnits) @@ -99,7 +98,7 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxComputeUnits) GTEST_SKIP_("Skipping as no OpenCL GPU device found."); auto n = DPPLDevice_GetMaxComputeUnits(OpenCL_gpu); - EXPECT_TRUE(n != 0); + EXPECT_TRUE(n > 0); } TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkItemDims) @@ -108,7 +107,7 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkItemDims) GTEST_SKIP_("Skipping as no OpenCL CPU device found."); auto n = DPPLDevice_GetMaxWorkItemDims(OpenCL_cpu); - EXPECT_TRUE(n != 0); + EXPECT_TRUE(n > 0); } TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkItemDims) @@ -117,7 +116,7 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkItemDims) GTEST_SKIP_("Skipping as no OpenCL GPU device found."); auto n = DPPLDevice_GetMaxWorkItemDims(OpenCL_gpu); - EXPECT_TRUE(n != 0); + EXPECT_TRUE(n > 0); } TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkItemSizes) @@ -146,7 +145,7 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkGroupSize) GTEST_SKIP_("Skipping as no OpenCL CPU device found."); auto n = DPPLDevice_GetMaxWorkGroupSize(OpenCL_cpu); - EXPECT_TRUE(n != 0); + EXPECT_TRUE(n > 0); } TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkGroupSize) @@ -155,7 +154,7 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkGroupSize) GTEST_SKIP_("Skipping as no OpenCL GPU device found."); auto n = DPPLDevice_GetMaxWorkGroupSize(OpenCL_gpu); - EXPECT_TRUE(n != 0); + EXPECT_TRUE(n > 0); } TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxNumSubGroups) @@ -164,7 +163,7 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxNumSubGroups) GTEST_SKIP_("Skipping as no OpenCL CPU device found."); auto n = DPPLDevice_GetMaxNumSubGroups(OpenCL_cpu); - EXPECT_TRUE(n != 0); + EXPECT_TRUE(n > 0); } TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxNumSubGroups) @@ -173,7 +172,7 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxNumSubGroups) GTEST_SKIP_("Skipping as no OpenCL GPU device found."); auto n = DPPLDevice_GetMaxNumSubGroups(OpenCL_gpu); - EXPECT_TRUE(n != 0); + EXPECT_TRUE(n > 0); } //TODO: Update when DPC++ properly supports aspects diff --git a/dpctl/tests/test_sycl_device.py b/dpctl/tests/test_sycl_device.py index 3491c6e0e1..fbef13a1ca 100644 --- a/dpctl/tests/test_sycl_device.py +++ b/dpctl/tests/test_sycl_device.py @@ -34,7 +34,7 @@ def test_get_max_compute_units (self): max_compute_units = q.get_sycl_device().get_max_compute_units() except Exception: self.fail("Encountered an exception inside get_max_compute_units().") - self.assertNotEqual(max_compute_units, 0) + self.assertTrue(max_compute_units > 0) def test_get_max_work_item_dims (self): q = dpctl.get_current_queue() @@ -42,7 +42,7 @@ def test_get_max_work_item_dims (self): max_work_item_dims = q.get_sycl_device().get_max_work_item_dims() except Exception: self.fail("Encountered an exception inside get_max_work_item_dims().") - self.assertNotEqual(max_work_item_dims, 0) + self.assertTrue(max_work_item_dims > 0) def test_get_max_work_item_sizes (self): q = dpctl.get_current_queue() @@ -58,7 +58,7 @@ def test_get_max_work_group_size (self): max_work_group_size = q.get_sycl_device().get_max_work_group_size() except Exception: self.fail("Encountered an exception inside get_max_work_group_size().") - self.assertNotEqual(max_work_group_size, 0) + self.assertTrue(max_work_group_size > 0) def test_get_max_num_sub_groups (self): q = dpctl.get_current_queue() @@ -66,7 +66,7 @@ def test_get_max_num_sub_groups (self): max_num_sub_groups = q.get_sycl_device().get_max_num_sub_groups() except Exception: self.fail("Encountered an exception inside get_max_num_sub_groups().") - self.assertNotEqual(max_num_sub_groups, 0) + self.assertTrue(max_num_sub_groups > 0) def test_has_int64_base_atomics (self): q = dpctl.get_current_queue() From e509c238010a1b64f713501a6829810a9db81446 Mon Sep 17 00:00:00 2001 From: etotmeni Date: Mon, 19 Oct 2020 10:22:14 -0500 Subject: [PATCH 07/12] Codestyle --- dpctl/tests/test_sycl_device.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/dpctl/tests/test_sycl_device.py b/dpctl/tests/test_sycl_device.py index fbef13a1ca..43136dbaa3 100644 --- a/dpctl/tests/test_sycl_device.py +++ b/dpctl/tests/test_sycl_device.py @@ -26,9 +26,9 @@ import unittest @unittest.skipIf(not dpctl.has_sycl_platforms(), "No SYCL platforms available") -class TestSyclDevice (unittest.TestCase): +class TestSyclDevice(unittest.TestCase): - def test_get_max_compute_units (self): + def test_get_max_compute_units(self): q = dpctl.get_current_queue() try: max_compute_units = q.get_sycl_device().get_max_compute_units() @@ -36,7 +36,7 @@ def test_get_max_compute_units (self): self.fail("Encountered an exception inside get_max_compute_units().") self.assertTrue(max_compute_units > 0) - def test_get_max_work_item_dims (self): + def test_get_max_work_item_dims(self): q = dpctl.get_current_queue() try: max_work_item_dims = q.get_sycl_device().get_max_work_item_dims() @@ -44,7 +44,7 @@ def test_get_max_work_item_dims (self): self.fail("Encountered an exception inside get_max_work_item_dims().") self.assertTrue(max_work_item_dims > 0) - def test_get_max_work_item_sizes (self): + def test_get_max_work_item_sizes(self): q = dpctl.get_current_queue() try: max_work_item_sizes = q.get_sycl_device().get_max_work_item_sizes() @@ -52,7 +52,7 @@ def test_get_max_work_item_sizes (self): self.fail("Encountered an exception inside get_max_work_item_sizes().") self.assertNotEqual(max_work_item_sizes, (None, None, None)) - def test_get_max_work_group_size (self): + def test_get_max_work_group_size(self): q = dpctl.get_current_queue() try: max_work_group_size = q.get_sycl_device().get_max_work_group_size() @@ -60,7 +60,7 @@ def test_get_max_work_group_size (self): self.fail("Encountered an exception inside get_max_work_group_size().") self.assertTrue(max_work_group_size > 0) - def test_get_max_num_sub_groups (self): + def test_get_max_num_sub_groups(self): q = dpctl.get_current_queue() try: max_num_sub_groups = q.get_sycl_device().get_max_num_sub_groups() @@ -68,7 +68,7 @@ def test_get_max_num_sub_groups (self): self.fail("Encountered an exception inside get_max_num_sub_groups().") self.assertTrue(max_num_sub_groups > 0) - def test_has_int64_base_atomics (self): + def test_has_int64_base_atomics(self): q = dpctl.get_current_queue() try: aspects_base_atomics = q.get_sycl_device().has_int64_base_atomics() @@ -76,7 +76,7 @@ def test_has_int64_base_atomics (self): self.fail("Encountered an exception inside has_int64_base_atomics().") self.assertNotEqual(aspects_base_atomics, False) - def test_has_int64_extended_atomics (self): + def test_has_int64_extended_atomics(self): q = dpctl.get_current_queue() try: aspects_extended_atomics = q.get_sycl_device().has_int64_extended_atomics() @@ -84,5 +84,5 @@ def test_has_int64_extended_atomics (self): self.fail("Encountered an exception inside has_int64_extended_atomics().") self.assertNotEqual(aspects_extended_atomics, False) -if __name__ == '__main__': +if __name__ == "__main__": unittest.main() From 245cafcfca59fcc5cbd958b09443f6b7c23df228 Mon Sep 17 00:00:00 2001 From: etotmeni Date: Mon, 19 Oct 2020 13:18:13 -0500 Subject: [PATCH 08/12] Codestyle --- dpctl/tests/test_sycl_device.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dpctl/tests/test_sycl_device.py b/dpctl/tests/test_sycl_device.py index 43136dbaa3..de61400bb1 100644 --- a/dpctl/tests/test_sycl_device.py +++ b/dpctl/tests/test_sycl_device.py @@ -25,9 +25,9 @@ import dpctl import unittest + @unittest.skipIf(not dpctl.has_sycl_platforms(), "No SYCL platforms available") class TestSyclDevice(unittest.TestCase): - def test_get_max_compute_units(self): q = dpctl.get_current_queue() try: @@ -84,5 +84,6 @@ def test_has_int64_extended_atomics(self): self.fail("Encountered an exception inside has_int64_extended_atomics().") self.assertNotEqual(aspects_extended_atomics, False) + if __name__ == "__main__": unittest.main() From 1c151b9afc14fd97d106dd647404f8a53fa7b663 Mon Sep 17 00:00:00 2001 From: etotmeni Date: Wed, 21 Oct 2020 05:45:35 -0500 Subject: [PATCH 09/12] Some fixes + add tests for level0 gpu --- .../source/dppl_sycl_device_interface.cpp | 4 +- backends/tests/CMakeLists.txt | 2 +- backends/tests/test_sycl_device_interface.cpp | 116 ++++++++++++++++++ dpctl/_sycl_core.pxd | 2 +- dpctl/backend.pxd | 10 +- dpctl/tests/test_sycl_device.py | 35 ++++-- 6 files changed, 152 insertions(+), 17 deletions(-) diff --git a/backends/source/dppl_sycl_device_interface.cpp b/backends/source/dppl_sycl_device_interface.cpp index 1b92ca8f25..0dbf2affe1 100644 --- a/backends/source/dppl_sycl_device_interface.cpp +++ b/backends/source/dppl_sycl_device_interface.cpp @@ -117,7 +117,6 @@ bool DPPLDevice_IsCPU (__dppl_keep const DPPLSyclDeviceRef DRef) return D->is_cpu(); } return false; - } bool DPPLDevice_IsGPU (__dppl_keep const DPPLSyclDeviceRef DRef) @@ -148,7 +147,6 @@ DPPLDevice_GetMaxComputeUnits (__dppl_keep const DPPLSyclDeviceRef DRef) return D->get_info(); } return 0; - } uint32_t @@ -234,7 +232,7 @@ DPPLDevice_GetVendorName (__dppl_keep const DPPLSyclDeviceRef DRef) { auto D = unwrap(DRef); if (D) { - auto vendor = D->get_info(); + auto vendor = D->get_info(); auto cstr_vendor = new char [vendor.length()+1]; std::strcpy (cstr_vendor, vendor.c_str()); return cstr_vendor; diff --git a/backends/tests/CMakeLists.txt b/backends/tests/CMakeLists.txt index d7f1731766..d0efc5ebfe 100644 --- a/backends/tests/CMakeLists.txt +++ b/backends/tests/CMakeLists.txt @@ -22,7 +22,7 @@ else() link_directories(${GTEST_LIB_DIR}) - set(PYDPPL_BACKEND_TEST_CASES + set(DPCTL_C_API_TEST_CASES test_sycl_device_interface test_sycl_kernel_interface test_sycl_platform_interface diff --git a/backends/tests/test_sycl_device_interface.cpp b/backends/tests/test_sycl_device_interface.cpp index 0b0076702a..e035b53def 100644 --- a/backends/tests/test_sycl_device_interface.cpp +++ b/backends/tests/test_sycl_device_interface.cpp @@ -39,6 +39,7 @@ struct TestDPPLSyclDeviceInterface : public ::testing::Test { DPPLSyclDeviceRef OpenCL_cpu = nullptr; DPPLSyclDeviceRef OpenCL_gpu = nullptr; + DPPLSyclDeviceRef OpenCL_level_zero = nullptr; TestDPPLSyclDeviceInterface () { @@ -53,12 +54,19 @@ struct TestDPPLSyclDeviceInterface : public ::testing::Test OpenCL_gpu = DPPLQueue_GetDevice(Q); DPPLQueue_Delete(Q); } + + if(DPPLQueueMgr_GetNumQueues(DPPL_LEVEL_ZERO, DPPL_GPU)) { + auto Q = DPPLQueueMgr_GetQueue(DPPL_LEVEL_ZERO, DPPL_GPU, 0); + OpenCL_level_zero = DPPLQueue_GetDevice(Q); + DPPLQueue_Delete(Q); + } } ~TestDPPLSyclDeviceInterface () { DPPLDevice_Delete(OpenCL_cpu); DPPLDevice_Delete(OpenCL_gpu); + DPPLDevice_Delete(OpenCL_level_zero); } }; @@ -83,6 +91,16 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetDriverInfo) DPPLCString_Delete(DriverInfo); } +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetDriverInfo) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + auto DriverInfo = DPPLDevice_GetDriverInfo(OpenCL_level_zero); + EXPECT_TRUE(DriverInfo != nullptr); + DPPLCString_Delete(DriverInfo); +} + TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxComputeUnits) { if(!OpenCL_cpu) @@ -101,6 +119,15 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxComputeUnits) EXPECT_TRUE(n > 0); } +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetMaxComputeUnits) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + auto n = DPPLDevice_GetMaxComputeUnits(OpenCL_level_zero); + EXPECT_TRUE(n > 0); +} + TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkItemDims) { if(!OpenCL_cpu) @@ -119,6 +146,15 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkItemDims) EXPECT_TRUE(n > 0); } +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetMaxWorkItemDims) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + auto n = DPPLDevice_GetMaxWorkItemDims(OpenCL_level_zero); + EXPECT_TRUE(n > 0); +} + TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkItemSizes) { if(!OpenCL_cpu) @@ -139,6 +175,16 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkItemSizes) DPPLSize_t_Array_Delete(item_sizes); } +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetMaxWorkItemSizes) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + auto item_sizes = DPPLDevice_GetMaxWorkItemSizes(OpenCL_level_zero); + EXPECT_TRUE(item_sizes != nullptr); + DPPLSize_t_Array_Delete(item_sizes); +} + TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxWorkGroupSize) { if(!OpenCL_cpu) @@ -157,6 +203,15 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkGroupSize) EXPECT_TRUE(n > 0); } +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetMaxWorkGroupSize) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + auto n = DPPLDevice_GetMaxWorkGroupSize(OpenCL_level_zero); + EXPECT_TRUE(n > 0); +} + TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetMaxNumSubGroups) { if(!OpenCL_cpu) @@ -175,6 +230,15 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxNumSubGroups) EXPECT_TRUE(n > 0); } +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetMaxNumSubGroups) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + auto n = DPPLDevice_GetMaxNumSubGroups(OpenCL_level_zero); + EXPECT_TRUE(n > 0); +} + //TODO: Update when DPC++ properly supports aspects TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_HasInt64BaseAtomics) { @@ -199,6 +263,18 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_HasInt64BaseAtomics) EXPECT_TRUE(has_atomics == atomics); } +//TODO: Update when DPC++ properly supports aspects +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_HasInt64BaseAtomics) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + auto atomics = DPPLDevice_HasInt64BaseAtomics(OpenCL_level_zero); + auto D = reinterpret_cast(OpenCL_level_zero); + auto has_atomics= D->has(aspect::int64_base_atomics); + EXPECT_TRUE(has_atomics == atomics); +} + //TODO: Update when DPC++ properly supports aspects TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_HasInt64ExtendedAtomics) { @@ -223,6 +299,18 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_HasInt64ExtendedAtomics) EXPECT_TRUE(has_atomics == atomics); } +//TODO: Update when DPC++ properly supports aspects +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_HasInt64ExtendedAtomics) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + auto atomics = DPPLDevice_HasInt64ExtendedAtomics(OpenCL_level_zero); + auto D = reinterpret_cast(OpenCL_level_zero); + auto has_atomics= D->has(aspect::int64_extended_atomics); + EXPECT_TRUE(has_atomics == atomics); +} + TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetName) { if(!OpenCL_cpu) @@ -243,6 +331,16 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetName) DPPLCString_Delete(DevName); } +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetName) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + auto DevName = DPPLDevice_GetName(OpenCL_level_zero); + EXPECT_TRUE(DevName != nullptr); + DPPLCString_Delete(DevName); +} + TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_GetVendorName) { if(!OpenCL_cpu) @@ -263,6 +361,16 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetVendorName) DPPLCString_Delete(VendorName); } +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetVendorName) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + auto VendorName = DPPLDevice_GetVendorName(OpenCL_level_zero); + EXPECT_TRUE(VendorName != nullptr); + DPPLCString_Delete(VendorName); +} + TEST_F (TestDPPLSyclDeviceInterface, CheckOCLCPU_IsCPU) { if(!OpenCL_cpu) @@ -279,6 +387,14 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_IsGPU) EXPECT_TRUE(DPPLDevice_IsGPU(OpenCL_gpu)); } +TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_IsGPU) +{ + if(!OpenCL_level_zero) + GTEST_SKIP_("Skipping as no Level0 GPU device found."); + + EXPECT_TRUE(DPPLDevice_IsGPU(OpenCL_level_zero)); +} + int main (int argc, char** argv) { diff --git a/dpctl/_sycl_core.pxd b/dpctl/_sycl_core.pxd index 49d23cb653..66cbccef9a 100644 --- a/dpctl/_sycl_core.pxd +++ b/dpctl/_sycl_core.pxd @@ -51,7 +51,7 @@ cdef class SyclDevice: cdef const char *_driver_version cdef uint32_t _max_compute_units cdef uint32_t _max_work_item_dims - cdef size_t* _max_work_item_sizes + cdef size_t *_max_work_item_sizes cdef size_t _max_work_group_size cdef uint32_t _max_num_sub_groups cdef bool _int64_base_atomics diff --git a/dpctl/backend.pxd b/dpctl/backend.pxd index 01d853484a..584ae79fd8 100644 --- a/dpctl/backend.pxd +++ b/dpctl/backend.pxd @@ -33,7 +33,7 @@ from libc.stdint cimport uint32_t cdef extern from "dppl_utils.h": cdef void DPPLCString_Delete (const char *str) - cdef void DPPLSize_t_Array_Delete (size_t* arr) + cdef void DPPLSize_t_Array_Delete (size_t *arr) cdef extern from "dppl_sycl_enum_types.h": cdef enum _backend_type 'DPPLSyclBackendType': @@ -99,13 +99,13 @@ cdef extern from "dppl_sycl_device_interface.h": cdef bool DPPLDevice_IsCPU (const DPPLSyclDeviceRef DRef) cdef bool DPPLDevice_IsGPU (const DPPLSyclDeviceRef DRef) cdef bool DPPLDevice_IsHost (const DPPLSyclDeviceRef DRef) - cpdef const char* DPPLDevice_GetDriverInfo (const DPPLSyclDeviceRef DRef) - cpdef const char* DPPLDevice_GetName (const DPPLSyclDeviceRef DRef) - cpdef const char* DPPLDevice_GetVendorName (const DPPLSyclDeviceRef DRef) + cpdef const char *DPPLDevice_GetDriverInfo (const DPPLSyclDeviceRef DRef) + cpdef const char *DPPLDevice_GetName (const DPPLSyclDeviceRef DRef) + cpdef const char *DPPLDevice_GetVendorName (const DPPLSyclDeviceRef DRef) cdef bool DPPLDevice_IsHostUnifiedMemory (const DPPLSyclDeviceRef DRef) cpdef uint32_t DPPLDevice_GetMaxComputeUnits (const DPPLSyclDeviceRef DRef) cpdef uint32_t DPPLDevice_GetMaxWorkItemDims (const DPPLSyclDeviceRef DRef) - cpdef size_t* DPPLDevice_GetMaxWorkItemSizes (const DPPLSyclDeviceRef DRef) + cpdef size_t *DPPLDevice_GetMaxWorkItemSizes (const DPPLSyclDeviceRef DRef) cpdef size_t DPPLDevice_GetMaxWorkGroupSize (const DPPLSyclDeviceRef DRef) cpdef uint32_t DPPLDevice_GetMaxNumSubGroups (const DPPLSyclDeviceRef DRef) cpdef bool DPPLDevice_HasInt64BaseAtomics (const DPPLSyclDeviceRef DRef) diff --git a/dpctl/tests/test_sycl_device.py b/dpctl/tests/test_sycl_device.py index de61400bb1..e222a55542 100644 --- a/dpctl/tests/test_sycl_device.py +++ b/dpctl/tests/test_sycl_device.py @@ -29,7 +29,10 @@ @unittest.skipIf(not dpctl.has_sycl_platforms(), "No SYCL platforms available") class TestSyclDevice(unittest.TestCase): def test_get_max_compute_units(self): - q = dpctl.get_current_queue() + try: + q = dpctl.get_current_queue() + except Exception: + self.fail("Encountered an exception inside get_current_queue().") try: max_compute_units = q.get_sycl_device().get_max_compute_units() except Exception: @@ -37,7 +40,10 @@ def test_get_max_compute_units(self): self.assertTrue(max_compute_units > 0) def test_get_max_work_item_dims(self): - q = dpctl.get_current_queue() + try: + q = dpctl.get_current_queue() + except Exception: + self.fail("Encountered an exception inside get_current_queue().") try: max_work_item_dims = q.get_sycl_device().get_max_work_item_dims() except Exception: @@ -45,7 +51,10 @@ def test_get_max_work_item_dims(self): self.assertTrue(max_work_item_dims > 0) def test_get_max_work_item_sizes(self): - q = dpctl.get_current_queue() + try: + q = dpctl.get_current_queue() + except Exception: + self.fail("Encountered an exception inside get_current_queue().") try: max_work_item_sizes = q.get_sycl_device().get_max_work_item_sizes() except Exception: @@ -53,7 +62,10 @@ def test_get_max_work_item_sizes(self): self.assertNotEqual(max_work_item_sizes, (None, None, None)) def test_get_max_work_group_size(self): - q = dpctl.get_current_queue() + try: + q = dpctl.get_current_queue() + except Exception: + self.fail("Encountered an exception inside get_current_queue().") try: max_work_group_size = q.get_sycl_device().get_max_work_group_size() except Exception: @@ -61,7 +73,10 @@ def test_get_max_work_group_size(self): self.assertTrue(max_work_group_size > 0) def test_get_max_num_sub_groups(self): - q = dpctl.get_current_queue() + try: + q = dpctl.get_current_queue() + except Exception: + self.fail("Encountered an exception inside get_current_queue().") try: max_num_sub_groups = q.get_sycl_device().get_max_num_sub_groups() except Exception: @@ -69,7 +84,10 @@ def test_get_max_num_sub_groups(self): self.assertTrue(max_num_sub_groups > 0) def test_has_int64_base_atomics(self): - q = dpctl.get_current_queue() + try: + q = dpctl.get_current_queue() + except Exception: + self.fail("Encountered an exception inside get_current_queue().") try: aspects_base_atomics = q.get_sycl_device().has_int64_base_atomics() except Exception: @@ -77,7 +95,10 @@ def test_has_int64_base_atomics(self): self.assertNotEqual(aspects_base_atomics, False) def test_has_int64_extended_atomics(self): - q = dpctl.get_current_queue() + try: + q = dpctl.get_current_queue() + except Exception: + self.fail("Encountered an exception inside get_current_queue().") try: aspects_extended_atomics = q.get_sycl_device().has_int64_extended_atomics() except Exception: From d19a63d339d8dec0670525430b8598e380a29558 Mon Sep 17 00:00:00 2001 From: etotmeni Date: Thu, 22 Oct 2020 03:31:29 -0500 Subject: [PATCH 10/12] Change names in tests level0gpu --- backends/tests/test_sycl_device_interface.cpp | 76 +++++++++---------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/backends/tests/test_sycl_device_interface.cpp b/backends/tests/test_sycl_device_interface.cpp index e035b53def..43da260e39 100644 --- a/backends/tests/test_sycl_device_interface.cpp +++ b/backends/tests/test_sycl_device_interface.cpp @@ -39,7 +39,7 @@ struct TestDPPLSyclDeviceInterface : public ::testing::Test { DPPLSyclDeviceRef OpenCL_cpu = nullptr; DPPLSyclDeviceRef OpenCL_gpu = nullptr; - DPPLSyclDeviceRef OpenCL_level_zero = nullptr; + DPPLSyclDeviceRef OpenCL_Level0_gpu = nullptr; TestDPPLSyclDeviceInterface () { @@ -57,7 +57,7 @@ struct TestDPPLSyclDeviceInterface : public ::testing::Test if(DPPLQueueMgr_GetNumQueues(DPPL_LEVEL_ZERO, DPPL_GPU)) { auto Q = DPPLQueueMgr_GetQueue(DPPL_LEVEL_ZERO, DPPL_GPU, 0); - OpenCL_level_zero = DPPLQueue_GetDevice(Q); + OpenCL_Level0_gpu = DPPLQueue_GetDevice(Q); DPPLQueue_Delete(Q); } } @@ -66,7 +66,7 @@ struct TestDPPLSyclDeviceInterface : public ::testing::Test { DPPLDevice_Delete(OpenCL_cpu); DPPLDevice_Delete(OpenCL_gpu); - DPPLDevice_Delete(OpenCL_level_zero); + DPPLDevice_Delete(OpenCL_Level0_gpu); } }; @@ -91,12 +91,12 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetDriverInfo) DPPLCString_Delete(DriverInfo); } -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetDriverInfo) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_GetDriverInfo) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - auto DriverInfo = DPPLDevice_GetDriverInfo(OpenCL_level_zero); + auto DriverInfo = DPPLDevice_GetDriverInfo(OpenCL_Level0_gpu); EXPECT_TRUE(DriverInfo != nullptr); DPPLCString_Delete(DriverInfo); } @@ -119,12 +119,12 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxComputeUnits) EXPECT_TRUE(n > 0); } -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetMaxComputeUnits) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_GetMaxComputeUnits) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - auto n = DPPLDevice_GetMaxComputeUnits(OpenCL_level_zero); + auto n = DPPLDevice_GetMaxComputeUnits(OpenCL_Level0_gpu); EXPECT_TRUE(n > 0); } @@ -146,12 +146,12 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkItemDims) EXPECT_TRUE(n > 0); } -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetMaxWorkItemDims) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_GetMaxWorkItemDims) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - auto n = DPPLDevice_GetMaxWorkItemDims(OpenCL_level_zero); + auto n = DPPLDevice_GetMaxWorkItemDims(OpenCL_Level0_gpu); EXPECT_TRUE(n > 0); } @@ -175,12 +175,12 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkItemSizes) DPPLSize_t_Array_Delete(item_sizes); } -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetMaxWorkItemSizes) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_GetMaxWorkItemSizes) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - auto item_sizes = DPPLDevice_GetMaxWorkItemSizes(OpenCL_level_zero); + auto item_sizes = DPPLDevice_GetMaxWorkItemSizes(OpenCL_Level0_gpu); EXPECT_TRUE(item_sizes != nullptr); DPPLSize_t_Array_Delete(item_sizes); } @@ -203,12 +203,12 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxWorkGroupSize) EXPECT_TRUE(n > 0); } -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetMaxWorkGroupSize) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_GetMaxWorkGroupSize) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - auto n = DPPLDevice_GetMaxWorkGroupSize(OpenCL_level_zero); + auto n = DPPLDevice_GetMaxWorkGroupSize(OpenCL_Level0_gpu); EXPECT_TRUE(n > 0); } @@ -230,12 +230,12 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetMaxNumSubGroups) EXPECT_TRUE(n > 0); } -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetMaxNumSubGroups) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_GetMaxNumSubGroups) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - auto n = DPPLDevice_GetMaxNumSubGroups(OpenCL_level_zero); + auto n = DPPLDevice_GetMaxNumSubGroups(OpenCL_Level0_gpu); EXPECT_TRUE(n > 0); } @@ -264,13 +264,13 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_HasInt64BaseAtomics) } //TODO: Update when DPC++ properly supports aspects -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_HasInt64BaseAtomics) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_HasInt64BaseAtomics) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - auto atomics = DPPLDevice_HasInt64BaseAtomics(OpenCL_level_zero); - auto D = reinterpret_cast(OpenCL_level_zero); + auto atomics = DPPLDevice_HasInt64BaseAtomics(OpenCL_Level0_gpu); + auto D = reinterpret_cast(OpenCL_Level0_gpu); auto has_atomics= D->has(aspect::int64_base_atomics); EXPECT_TRUE(has_atomics == atomics); } @@ -300,13 +300,13 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_HasInt64ExtendedAtomics) } //TODO: Update when DPC++ properly supports aspects -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_HasInt64ExtendedAtomics) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_HasInt64ExtendedAtomics) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - auto atomics = DPPLDevice_HasInt64ExtendedAtomics(OpenCL_level_zero); - auto D = reinterpret_cast(OpenCL_level_zero); + auto atomics = DPPLDevice_HasInt64ExtendedAtomics(OpenCL_Level0_gpu); + auto D = reinterpret_cast(OpenCL_Level0_gpu); auto has_atomics= D->has(aspect::int64_extended_atomics); EXPECT_TRUE(has_atomics == atomics); } @@ -331,12 +331,12 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetName) DPPLCString_Delete(DevName); } -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetName) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_GetName) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - auto DevName = DPPLDevice_GetName(OpenCL_level_zero); + auto DevName = DPPLDevice_GetName(OpenCL_Level0_gpu); EXPECT_TRUE(DevName != nullptr); DPPLCString_Delete(DevName); } @@ -361,12 +361,12 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_GetVendorName) DPPLCString_Delete(VendorName); } -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_GetVendorName) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_GetVendorName) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - auto VendorName = DPPLDevice_GetVendorName(OpenCL_level_zero); + auto VendorName = DPPLDevice_GetVendorName(OpenCL_Level0_gpu); EXPECT_TRUE(VendorName != nullptr); DPPLCString_Delete(VendorName); } @@ -387,12 +387,12 @@ TEST_F (TestDPPLSyclDeviceInterface, CheckOCLGPU_IsGPU) EXPECT_TRUE(DPPLDevice_IsGPU(OpenCL_gpu)); } -TEST_F (TestDPPLSyclDeviceInterface, CheckLevelZero_IsGPU) +TEST_F (TestDPPLSyclDeviceInterface, CheckLevel0GPU_IsGPU) { - if(!OpenCL_level_zero) + if(!OpenCL_Level0_gpu) GTEST_SKIP_("Skipping as no Level0 GPU device found."); - EXPECT_TRUE(DPPLDevice_IsGPU(OpenCL_level_zero)); + EXPECT_TRUE(DPPLDevice_IsGPU(OpenCL_Level0_gpu)); } int From 6bd898d1d665de6fe3b1201f71d4aea2702a928c Mon Sep 17 00:00:00 2001 From: etotmeni Date: Fri, 23 Oct 2020 04:14:10 -0500 Subject: [PATCH 11/12] Update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a815f2ffdd..e15d41f23c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added +- Device descriptors "max_compute_units", "max_work_item_dimensions", "max_work_item_sizes", "max_work_group_size", "max_num_sub_groups" and "aspects" for int64 atomics inside dpctl C API and inside the dpctl.SyclDevice class. + ### Removed - The Legacy OpenCL interface. From c26f332fa8459df2894f599b9188bc5fe7134d61 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 23 Oct 2020 15:55:22 -0500 Subject: [PATCH 12/12] Fix import _backend in _sycl_core.pxd --- dpctl/_sycl_core.pxd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dpctl/_sycl_core.pxd b/dpctl/_sycl_core.pxd index 66cbccef9a..89a74dca57 100644 --- a/dpctl/_sycl_core.pxd +++ b/dpctl/_sycl_core.pxd @@ -27,7 +27,7 @@ # distutils: language = c++ # cython: language_level=3 -from .backend cimport * +from ._backend cimport * from libc.stdint cimport uint32_t