From cea8fa97c956b4fb072d4133dc4e342efa160988 Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Tue, 27 Apr 2021 22:50:05 -0500 Subject: [PATCH 1/2] Improvements to the print info functions. - print_device_info now prints the filter string. Device type is no longer separately printed out. Device profile is not printed any more. - print_platform_info now has various verbosity levels to control amount of information that is printed. --- .../helper/include/dpctl_utils_helper.h | 18 ++++ .../helper/source/dpctl_utils_helper.cpp | 63 +++++++----- .../include/dpctl_sycl_device_manager.h | 12 ++- .../include/dpctl_sycl_platform_manager.h | 16 ++- .../source/dpctl_sycl_device_manager.cpp | 57 +++++------ .../source/dpctl_sycl_platform_manager.cpp | 97 ++++++++++--------- .../tests/test_sycl_platform_interface.cpp | 21 +++- dpctl/_backend.pxd | 2 +- dpctl/_sycl_platform.pyx | 81 ++++++++++++++-- dpctl/tests/test_sycl_platform.py | 28 ++++++ 10 files changed, 274 insertions(+), 121 deletions(-) diff --git a/dpctl-capi/helper/include/dpctl_utils_helper.h b/dpctl-capi/helper/include/dpctl_utils_helper.h index 1da40286b6..b6f50cb2f7 100644 --- a/dpctl-capi/helper/include/dpctl_utils_helper.h +++ b/dpctl-capi/helper/include/dpctl_utils_helper.h @@ -178,3 +178,21 @@ DPCTL_DPCTLPartitionAffinityDomainTypeToSycl( DPCTL_API DPCTLPartitionAffinityDomainType DPCTL_SyclPartitionAffinityDomainToDPCTLType( sycl::info::partition_affinity_domain PartitionAffinityDomain); + +/*! + * @brief Gives the index of the given device with respective to all the other + * devices of the same type in the device's platform. + * + * The relative device id of a device (Device) is computed by looking up the + * position of Device in the ``std::vector`` returned by calling the + * ``get_devices(Device.get_info())`` function + * for Device's platform. A relative device id of -1 indicates that the relative + * id could not be computed. + * + * @param Device A ``sycl::device`` object whose relative id is to be + * computed. + * @return A relative id corresponding to the device, -1 indicates that a + * relative id value could not be computed. + */ +DPCTL_API +int64_t DPCTL_GetRelativeDeviceId(const sycl::device &Device); diff --git a/dpctl-capi/helper/source/dpctl_utils_helper.cpp b/dpctl-capi/helper/source/dpctl_utils_helper.cpp index 3091393f90..03d61e72ba 100644 --- a/dpctl-capi/helper/source/dpctl_utils_helper.cpp +++ b/dpctl-capi/helper/source/dpctl_utils_helper.cpp @@ -37,22 +37,22 @@ std::string DPCTL_DeviceTypeToStr(info::device_type devTy) std::stringstream ss; switch (devTy) { case info::device_type::cpu: - ss << "cpu" << '\n'; + ss << "cpu"; break; case info::device_type::gpu: - ss << "gpu" << '\n'; + ss << "gpu"; break; case info::device_type::accelerator: - ss << "accelerator" << '\n'; + ss << "accelerator"; break; case info::device_type::custom: - ss << "custom" << '\n'; + ss << "custom"; break; case info::device_type::host: - ss << "host" << '\n'; + ss << "host"; break; default: - ss << "unknown" << '\n'; + ss << "unknown"; } return ss.str(); } @@ -169,58 +169,58 @@ std::string DPCTL_AspectToStr(aspect aspectTy) std::stringstream ss; switch (aspectTy) { case aspect::host: - ss << "host" << '\n'; + ss << "host"; break; case aspect::cpu: - ss << "cpu" << '\n'; + ss << "cpu"; break; case aspect::gpu: - ss << "gpu" << '\n'; + ss << "gpu"; break; case aspect::accelerator: - ss << "accelerator" << '\n'; + ss << "accelerator"; break; case aspect::custom: - ss << "custom" << '\n'; + ss << "custom"; break; case aspect::fp16: - ss << "fp16" << '\n'; + ss << "fp16"; break; case aspect::fp64: - ss << "fp64" << '\n'; + ss << "fp64"; break; case aspect::int64_base_atomics: - ss << "int64_base_atomics" << '\n'; + ss << "int64_base_atomics"; break; case aspect::int64_extended_atomics: - ss << "int64_extended_atomics" << '\n'; + ss << "int64_extended_atomics"; break; case aspect::image: - ss << "image" << '\n'; + ss << "image"; break; case aspect::online_compiler: - ss << "online_compiler" << '\n'; + ss << "online_compiler"; break; case aspect::online_linker: - ss << "online_linker" << '\n'; + ss << "online_linker"; break; case aspect::queue_profiling: - ss << "queue_profiling" << '\n'; + ss << "queue_profiling"; break; case aspect::usm_device_allocations: - ss << "usm_device_allocations" << '\n'; + ss << "usm_device_allocations"; break; case aspect::usm_host_allocations: - ss << "usm_host_allocations" << '\n'; + ss << "usm_host_allocations"; break; case aspect::usm_shared_allocations: - ss << "usm_shared_allocations" << '\n'; + ss << "usm_shared_allocations"; break; case aspect::usm_restricted_shared_allocations: - ss << "usm_restricted_shared_allocations" << '\n'; + ss << "usm_restricted_shared_allocations"; break; case aspect::usm_system_allocator: - ss << "usm_system_allocator" << '\n'; + ss << "usm_system_allocator"; break; default: throw runtime_error("Unsupported aspect type", -1); @@ -428,3 +428,18 @@ DPCTLPartitionAffinityDomainType DPCTL_SyclPartitionAffinityDomainToDPCTLType( throw runtime_error("Unsupported partition_affinity_domain type", -1); } } + +int64_t DPCTL_GetRelativeDeviceId(const device &Device) +{ + auto relid = -1; + auto p = Device.get_platform(); + auto dt = Device.get_info(); + auto dev_vec = p.get_devices(dt); + int64_t id = 0; + for (const auto &d_i : dev_vec) { + if (Device == d_i) + relid = id; + ++id; + } + return relid; +} diff --git a/dpctl-capi/include/dpctl_sycl_device_manager.h b/dpctl-capi/include/dpctl_sycl_device_manager.h index 467ab9cff6..fefa8e7af4 100644 --- a/dpctl-capi/include/dpctl_sycl_device_manager.h +++ b/dpctl-capi/include/dpctl_sycl_device_manager.h @@ -116,10 +116,18 @@ DPCTL_API void DPCTLDeviceMgr_PrintDeviceInfo(__dpctl_keep const DPCTLSyclDeviceRef DRef); /*! - * @brief Gives the index of the given device in the vector returned get_devices - * for the platform associated with DRef for the device type of DRef. + * @brief Gives the index of the given device with respective to all the other + * devices of the same type in the device's platform. + * + * The relative device id of a device (Device) is computed by looking up the + * position of Device in the ``std::vector`` returned by calling the + * ``get_devices(Device.get_info())`` function + * for Device's platform. A relative device id of -1 indicates that the relative + * id could not be computed. * * @param DRef A #DPCTLSyclDeviceRef opaque pointer. + * @return A relative id corresponding to the device, -1 indicates that a + * relative id value could not be computed. * @ingroup DeviceManager */ DPCTL_API diff --git a/dpctl-capi/include/dpctl_sycl_platform_manager.h b/dpctl-capi/include/dpctl_sycl_platform_manager.h index 4881ace6b9..c456941760 100644 --- a/dpctl-capi/include/dpctl_sycl_platform_manager.h +++ b/dpctl-capi/include/dpctl_sycl_platform_manager.h @@ -45,10 +45,24 @@ DPCTL_DECLARE_VECTOR(Platform) /*! * @brief Prints out information about the sycl::platform argument. + * + * The helper function is used to print metadata about a given platform. The + * amount of information printed out is controlled by the verbosity level. + * + * Verbosity level 0: Prints only the name of the platform. + * Verbosity level 1: Prints the name, version, vendor, backend, number of + * devices in the platform. + * Verbosity level 2: Prints everything in level 1 and also prints the name, + * version, and filter string for each device in the + * platform. + * * @param PRef A #DPCTLSyclPlatformRef opaque pointer. + * @param verbosity Verbosilty level to control how much information is + * printed out. */ DPCTL_API -void DPCTLPlatformMgr_PrintInfo(__dpctl_keep const DPCTLSyclPlatformRef PRef); +void DPCTLPlatformMgr_PrintInfo(__dpctl_keep const DPCTLSyclPlatformRef PRef, + size_t verbosity); /*! @} */ diff --git a/dpctl-capi/source/dpctl_sycl_device_manager.cpp b/dpctl-capi/source/dpctl_sycl_device_manager.cpp index e2c8072502..364585896b 100644 --- a/dpctl-capi/source/dpctl_sycl_device_manager.cpp +++ b/dpctl-capi/source/dpctl_sycl_device_manager.cpp @@ -49,17 +49,17 @@ void print_device_info(const device &Device) std::stringstream ss; ss << std::setw(4) << " " << std::left << std::setw(16) << "Name" - << Device.get_info() << '\n'; - ss << std::setw(4) << " " << std::left << std::setw(16) << "Driver version" - << Device.get_info() << '\n'; - ss << std::setw(4) << " " << std::left << std::setw(16) << "Vendor" - << Device.get_info() << '\n'; - ss << std::setw(4) << " " << std::left << std::setw(16) << "Profile" - << Device.get_info() << '\n'; - ss << std::setw(4) << " " << std::left << std::setw(16) << "Device type"; - - auto devTy = Device.get_info(); - ss << DPCTL_DeviceTypeToStr(devTy); + << Device.get_info() << '\n' + << std::setw(4) << " " << std::left << std::setw(16) << "Driver version" + << Device.get_info() << '\n' + << std::setw(4) << " " << std::left << std::setw(16) << "Vendor" + << Device.get_info() << '\n' + << std::setw(4) << " " << std::left << std::setw(16) << "Profile" + << Device.get_info() << '\n' + << std::setw(4) << " " << std::left << std::setw(16) << "Filter string" + << Device.get_platform().get_backend() << ":" + << DPCTL_DeviceTypeToStr(Device.get_info()) + << ":" << DPCTL_GetRelativeDeviceId(Device) << '\n'; std::cout << ss.str(); } @@ -67,15 +67,16 @@ void print_device_info(const device &Device) struct DeviceCacheBuilder { using DeviceCache = std::unordered_map; - /* This function implements a workaround to the current lack of a default - * context per root device in DPC++. The map stores a "default" context for - * each root device, and the QMgrHelper uses the map whenever it creates a - * new queue for a root device. By doing so, we avoid the performance - * overhead of context creation for every queue. + /* This function implements a workaround to the current lack of a + * default context per root device in DPC++. The map stores a "default" + * context for each root device, and the QMgrHelper uses the map + * whenever it creates a new queue for a root device. By doing so, we + * avoid the performance overhead of context creation for every queue. * - * The singleton pattern implemented here ensures that the map is created - * once in a thread-safe manner. Since, the map is ony read post-creation we - * do not need any further protection to ensure thread-safety. + * The singleton pattern implemented here ensures that the map is + * created once in a thread-safe manner. Since, the map is ony read + * post-creation we do not need any further protection to ensure + * thread-safety. */ static const DeviceCache &getDeviceCache() { @@ -190,26 +191,16 @@ void DPCTLDeviceMgr_PrintDeviceInfo(__dpctl_keep const DPCTLSyclDeviceRef DRef) auto Device = unwrap(DRef); if (Device) print_device_info(*Device); - else { + else std::cout << "Device is not valid (NULL). Cannot print device info.\n"; - } } int64_t DPCTLDeviceMgr_GetRelativeId(__dpctl_keep const DPCTLSyclDeviceRef DRef) { auto Device = unwrap(DRef); - if (Device) { - auto p = Device->get_platform(); - auto dt = Device->get_info(); - auto dev_vec = p.get_devices(dt); - int64_t id = 0; - for (auto &d_i : dev_vec) { - if (*Device == d_i) - return id; - ++id; - } - return -1; - } + if (Device) + return DPCTL_GetRelativeDeviceId(*Device); + return -1; } diff --git a/dpctl-capi/source/dpctl_sycl_platform_manager.cpp b/dpctl-capi/source/dpctl_sycl_platform_manager.cpp index ce1bff2c46..11a4b65cf2 100644 --- a/dpctl-capi/source/dpctl_sycl_platform_manager.cpp +++ b/dpctl-capi/source/dpctl_sycl_platform_manager.cpp @@ -40,46 +40,60 @@ namespace { DEFINE_SIMPLE_CONVERSION_FUNCTIONS(platform, DPCTLSyclPlatformRef); -void platform_print_info_impl(const platform &p) +void platform_print_info_impl(const platform &p, size_t verbosity) { std::stringstream ss; - auto vendor = p.get_info(); - if (vendor.empty()) - vendor = "unknown"; + if (verbosity > 2) { + std::cerr << "Illegal verbosity level. Accepted values are 0, 1, or 2. " + "Defaulting to verbosity level 0.\n"; + verbosity = 0; + } + + if (verbosity == 0) + ss << p.get_info() << " " + << p.get_info() << '\n'; - ss << std::setw(4) << " " << std::left << std::setw(12) << "Name" - << p.get_info() << '\n'; - ss << std::setw(4) << " " << std::left << std::setw(12) << "Version" - << p.get_info() << '\n'; - ss << std::setw(4) << " " << std::left << std::setw(12) << "Vendor" - << vendor << '\n'; - ss << std::setw(4) << " " << std::left << std::setw(12) << "Profile" - << p.get_info() << '\n'; - ss << std::setw(4) << " " << std::left << std::setw(12) << "Backend"; - p.is_host() ? (ss << "unknown") : (ss << p.get_backend()); - ss << '\n'; + if (verbosity > 0) { + auto vendor = p.get_info(); + if (vendor.empty()) + vendor = "unknown"; - // Get number of devices on the platform - auto devices = p.get_devices(); + ss << std::setw(4) << " " << std::left << std::setw(12) << "Name" + << p.get_info() << '\n' + << std::setw(4) << " " << std::left << std::setw(12) << "Version" + << p.get_info() << '\n' + << std::setw(4) << " " << std::left << std::setw(12) << "Vendor" + << vendor << '\n' + << std::setw(4) << " " << std::left << std::setw(12) << "Backend"; + p.is_host() ? (ss << "unknown") : (ss << p.get_backend()); + ss << '\n'; - ss << std::setw(4) << " " << std::left << std::setw(12) << "Devices" - << devices.size() << '\n'; - // Print some of the device information - for (auto dn = 0ul; dn < devices.size(); ++dn) { - ss << std::setw(6) << " " << std::left << std::setw(12) << "Device " - << dn << '\n'; - ss << std::setw(8) << " " << std::left << std::setw(20) << "Name" - << devices[dn].get_info() << '\n'; - ss << std::setw(8) << " " << std::left << std::setw(20) - << "Driver version" - << devices[dn].get_info() << '\n'; - ss << std::setw(8) << " " << std::left << std::setw(20) - << "Device type"; + // Get number of devices on the platform + auto devices = p.get_devices(); + ss << std::setw(4) << " " << std::left << std::setw(12) << "Num Devices" + << devices.size() << '\n'; - auto devTy = devices[dn].get_info(); - ss << DPCTL_DeviceTypeToStr(devTy); + if (verbosity == 2) + // Print some of the device information + for (auto dn = 0ul; dn < devices.size(); ++dn) { + ss << std::setw(6) << " " << std::left << "# " << dn << '\n' + << std::setw(8) << " " << std::left << std::setw(20) + << "Name" << devices[dn].get_info() + << '\n' + << std::setw(8) << " " << std::left << std::setw(20) + << "Version" + << devices[dn].get_info() + << '\n' + << std::setw(8) << " " << std::left << std::setw(20) + << "Filter string" + << devices[dn].get_platform().get_backend() << ":" + << DPCTL_DeviceTypeToStr( + devices[dn].get_info()) + << ":" << DPCTL_GetRelativeDeviceId(devices[dn]) << '\n'; + } } + std::cout << ss.str(); } @@ -90,25 +104,12 @@ void platform_print_info_impl(const platform &p) #include "dpctl_vector_templ.cpp" #undef EL -/*! - * Prints out the following sycl::info::platform attributes for the platform: - * - info::platform::name - * - info::platform::version - * - info::platform::vendor - * - info::platform::profile - * - backend (opencl, cuda, level-zero, host) - * - number of devices on the platform - * - * Additionally, for each device associated with the platform print out: - * - info::device::name - * - info::device::driver_version - * - type of the device based on the aspects cpu, gpu, accelerator. - */ -void DPCTLPlatformMgr_PrintInfo(__dpctl_keep const DPCTLSyclPlatformRef PRef) +void DPCTLPlatformMgr_PrintInfo(__dpctl_keep const DPCTLSyclPlatformRef PRef, + size_t verbosity) { auto p = unwrap(PRef); if (p) { - platform_print_info_impl(*p); + platform_print_info_impl(*p, verbosity); } else { std::cout << "Platform reference is NULL.\n"; diff --git a/dpctl-capi/tests/test_sycl_platform_interface.cpp b/dpctl-capi/tests/test_sycl_platform_interface.cpp index b436d22857..3333f563be 100644 --- a/dpctl-capi/tests/test_sycl_platform_interface.cpp +++ b/dpctl-capi/tests/test_sycl_platform_interface.cpp @@ -166,7 +166,7 @@ TEST_P(TestDPCTLSyclPlatformInterface, ChkCopy) TEST_P(TestDPCTLSyclPlatformInterface, ChkPrintInfo) { - EXPECT_NO_FATAL_FAILURE(DPCTLPlatformMgr_PrintInfo(PRef)); + EXPECT_NO_FATAL_FAILURE(DPCTLPlatformMgr_PrintInfo(PRef, 0)); } TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetName) @@ -189,9 +189,24 @@ TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetBackend) check_platform_backend(PRef); } -TEST_F(TestDPCTLSyclDefaultPlatform, ChkPrintInfo) +TEST_F(TestDPCTLSyclDefaultPlatform, ChkPrintInfo0) { - EXPECT_NO_FATAL_FAILURE(DPCTLPlatformMgr_PrintInfo(PRef)); + EXPECT_NO_FATAL_FAILURE(DPCTLPlatformMgr_PrintInfo(PRef, 0)); +} + +TEST_F(TestDPCTLSyclDefaultPlatform, ChkPrintInfo1) +{ + EXPECT_NO_FATAL_FAILURE(DPCTLPlatformMgr_PrintInfo(PRef, 1)); +} + +TEST_F(TestDPCTLSyclDefaultPlatform, ChkPrintInfo2) +{ + EXPECT_NO_FATAL_FAILURE(DPCTLPlatformMgr_PrintInfo(PRef, 2)); +} + +TEST_F(TestDPCTLSyclDefaultPlatform, ChkPrintInfo3) +{ + EXPECT_NO_FATAL_FAILURE(DPCTLPlatformMgr_PrintInfo(PRef, 3)); } TEST(TestGetPlatforms, Chk) diff --git a/dpctl/_backend.pxd b/dpctl/_backend.pxd index f6e747d24b..f78aca60ef 100644 --- a/dpctl/_backend.pxd +++ b/dpctl/_backend.pxd @@ -247,7 +247,7 @@ cdef extern from "dpctl_sycl_platform_manager.h": cdef DPCTLSyclPlatformRef DPCTLPlatformVector_GetAt( DPCTLPlatformVectorRef, size_t index) - cdef void DPCTLPlatformMgr_PrintInfo(const DPCTLSyclPlatformRef) + cdef void DPCTLPlatformMgr_PrintInfo(const DPCTLSyclPlatformRef, size_t) cdef extern from "dpctl_sycl_platform_interface.h": diff --git a/dpctl/_sycl_platform.pyx b/dpctl/_sycl_platform.pyx index 0a8d627841..86342d6483 100644 --- a/dpctl/_sycl_platform.pyx +++ b/dpctl/_sycl_platform.pyx @@ -175,10 +175,43 @@ cdef class SyclPlatform(_SyclPlatform): "a SYCL filter selector string." ) - def print_platform_info(self): + def print_platform_info(self, verbosity=0): """ Print information about the SYCL platform. + + The level of information printed out by the function can be controlled + by the optional ``vebosity`` setting. + + - **Verbosity level 0**: Prints out the list of platforms and their + names. + - **Verbosity level 1**: Prints out the name, version, vendor, + backend, number of devices for each platform. + - **Verbosity level 2**: At the highest level of verbosity + everything in the previous levels along with the name, version, + and filter string for each device is printed. + + Args: + verbosity (optional): Defaults to 0. + The verbosity controls how much information is printed by the + function. 0 is the lowest level set by default and 2 is the + highest level to print the most verbose output. + """ - DPCTLPlatformMgr_PrintInfo(self._platform_ref) + cdef size_t v = 0 + + if not isinstance(verbosity, int): + print( + "Illegal verbosity level. Accepted values are 0, 1, or 2. " + "Using the default verbosity level of 0." + ) + else: + v = (verbosity) + if v > 2: + print( + "Illegal verbosity level. Accepted values are 0, 1, or 2. " + "Using the default verbosity level of 0." + ) + v = 0 + DPCTLPlatformMgr_PrintInfo(self._platform_ref, v) @property def vendor(self): @@ -220,13 +253,22 @@ cdef class SyclPlatform(_SyclPlatform): raise ValueError("Unknown backend type.") -def lsplatform(): +def lsplatform(verbosity=0): """ - Prints out the list of available SYCL platforms and various information - about each platform. + Prints out the list of available SYCL platforms, and optionally extra + metadata about each platform. + + The level of information printed out by the function can be controlled by + the optional ``vebosity`` setting. + + - **Verbosity level 0**: Prints out the list of platforms and their names. + - **Verbosity level 1**: Prints out the name, version, vendor, backend, + number of devices for each platform. + - **Verbosity level 2**: At the highest level of verbosity everything in the + previous levels along with the name, version, and filter string for each + device is printed. - Currently, this function prints a list of all SYCL platforms that - are available on the system and the list of devices for each platform. + At verbosity level 2 (highest level) the following output is generated. :Example: On a system with an OpenCL CPU driver, OpenCL GPU driver, @@ -270,19 +312,40 @@ def lsplatform(): Driver version 1.0.18513 Device type gpu + Args: + verbosity (optional): Defaults to 0. + The verbosity controls how much information is printed by the + function. 0 is the lowest level set by default and 2 is the highest + level to print the most verbose output. """ cdef DPCTLPlatformVectorRef PVRef = NULL + cdef size_t v = 0 cdef size_t size = 0 cdef DPCTLSyclPlatformRef PRef = NULL + if not isinstance(verbosity, int): + print( + "Illegal verbosity level. Accepted values are 0, 1, or 2. " + "Using the default verbosity level of 0." + ) + else: + v = (verbosity) + if v > 2: + print( + "Illegal verbosity level. Accepted values are 0, 1, or 2. " + "Using the default verbosity level of 0." + ) + v = 0 + PVRef = DPCTLPlatform_GetPlatforms() if PVRef is not NULL: size = DPCTLPlatformVector_Size(PVRef) for i in range(size): - print("Platform ", i, "::") + if v != 0: + print("Platform ", i, "::") PRef = DPCTLPlatformVector_GetAt(PVRef, i) - DPCTLPlatformMgr_PrintInfo(PRef) + DPCTLPlatformMgr_PrintInfo(PRef, v) DPCTLPlatform_Delete(PRef) DPCTLPlatformVector_Delete(PVRef) diff --git a/dpctl/tests/test_sycl_platform.py b/dpctl/tests/test_sycl_platform.py index 4ade1e9ea5..188c03ebbc 100644 --- a/dpctl/tests/test_sycl_platform.py +++ b/dpctl/tests/test_sycl_platform.py @@ -133,6 +133,34 @@ def test_lsplatform(): pytest.fail("Encountered an exception inside lsplatform().") +def test_lsplatform0(): + try: + dpctl.lsplatform(0) + except Exception: + pytest.fail("Encountered an exception inside lsplatform().") + + +def test_lsplatform1(): + try: + dpctl.lsplatform(1) + except Exception: + pytest.fail("Encountered an exception inside lsplatform().") + + +def test_lsplatform2(): + try: + dpctl.lsplatform(2) + except Exception: + pytest.fail("Encountered an exception inside lsplatform().") + + +def test_lsplatform3(): + try: + dpctl.lsplatform(3) + except Exception: + pytest.fail("Encountered an exception inside lsplatform().") + + def test_get_platforms(): try: platforms = dpctl.get_platforms() From bde3ff2d6a882620822f1ea789d3bf44d983684b Mon Sep 17 00:00:00 2001 From: Diptorup Deb Date: Tue, 4 May 2021 15:33:47 -0500 Subject: [PATCH 2/2] Convert prints to warnings --- dpctl/_sycl_platform.pyx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dpctl/_sycl_platform.pyx b/dpctl/_sycl_platform.pyx index 86342d6483..d96f9dd430 100644 --- a/dpctl/_sycl_platform.pyx +++ b/dpctl/_sycl_platform.pyx @@ -46,6 +46,8 @@ from ._backend cimport ( # noqa: E211 _backend_type, ) +import warnings + from .enum_types import backend_type __all__ = [ @@ -199,14 +201,14 @@ cdef class SyclPlatform(_SyclPlatform): cdef size_t v = 0 if not isinstance(verbosity, int): - print( + warnings.warn( "Illegal verbosity level. Accepted values are 0, 1, or 2. " "Using the default verbosity level of 0." ) else: v = (verbosity) if v > 2: - print( + warnings.warn( "Illegal verbosity level. Accepted values are 0, 1, or 2. " "Using the default verbosity level of 0." ) @@ -331,7 +333,7 @@ def lsplatform(verbosity=0): else: v = (verbosity) if v > 2: - print( + warnings.warn( "Illegal verbosity level. Accepted values are 0, 1, or 2. " "Using the default verbosity level of 0." )