From e1467ce7652e04f91562e8d5403f0e0646a9997e Mon Sep 17 00:00:00 2001 From: Alexey Bader Date: Tue, 21 Apr 2020 15:25:17 +0300 Subject: [PATCH] [SYCL][NFC] Remove outdated sycl-check tool Signed-off-by: Alexey Bader --- sycl/tools/CMakeLists.txt | 18 +-- sycl/tools/sycl-check.cpp | 299 -------------------------------------- 2 files changed, 2 insertions(+), 315 deletions(-) delete mode 100644 sycl/tools/sycl-check.cpp diff --git a/sycl/tools/CMakeLists.txt b/sycl/tools/CMakeLists.txt index 30cf06533241b..c90f55acd508b 100644 --- a/sycl/tools/CMakeLists.txt +++ b/sycl/tools/CMakeLists.txt @@ -2,6 +2,8 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +# TODO: move each tool in its own sub-directory + add_executable(get_device_count_by_type get_device_count_by_type.cpp) add_dependencies(get_device_count_by_type ocl-headers ocl-icd) @@ -15,19 +17,3 @@ target_compile_definitions(get_device_count_by_type PRIVATE $<$:USE_PI_CUDA> ) - -add_executable(sycl-check sycl-check.cpp) -add_dependencies(sycl-check sycl) -target_include_directories(sycl-check PRIVATE "${sycl_inc_dir}") -target_link_libraries(sycl-check - PRIVATE - sycl - OpenCL::Headers - ${OpenCL_LIBRARIES}) - -#Minimum supported version of Intel's OCL GPU and CPU devices -target_compile_definitions(sycl-check - PRIVATE - MIN_INTEL_OCL_GPU_VERSION=\"18.47.11882\" - MIN_INTEL_OCL_CPU_VERSION=\"18.1.0.0901\",\"7.6.0.1202\" -) diff --git a/sycl/tools/sycl-check.cpp b/sycl/tools/sycl-check.cpp deleted file mode 100644 index 82de5f52cb03f..0000000000000 --- a/sycl/tools/sycl-check.cpp +++ /dev/null @@ -1,299 +0,0 @@ -//==----------- sycl-check.cpp ---------------------------------------------==// -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -//===----------------------------------------------------------------------===// - -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace cl; - -// The base class every class that want to perform some action on -// cl::sycl::device. -class Action { -public: - // This function will be called for each cl::sycl::device - // Indentation should be printed as a beginning of each line the method prints - virtual void visit(const sycl::device &Device, - const std::string &Indentation) = 0; - virtual ~Action() = default; -}; - -// The class prints if the device is a default device of this type -class PrintIfDefaultDevice : public Action { - // Contains default device of each type - // Using cl_device_id as SYCL implementation always create new - // cl::sycl::device object instead of reusing existing one. - std::vector m_DefaultDevices; - -public: - PrintIfDefaultDevice() { - // Fill vector of default devices for comparing in future - try { - sycl::cpu_selector CPUSelector; - m_DefaultDevices.push_back(sycl::device(CPUSelector).get()); - } catch (cl::sycl::invalid_parameter_error &) { - } - - try { - sycl::gpu_selector GPUSelector; - m_DefaultDevices.push_back(sycl::device(GPUSelector).get()); - } catch (cl::sycl::invalid_parameter_error &) { - } - - try { - sycl::accelerator_selector AcceleratorSelector; - m_DefaultDevices.push_back(sycl::device(AcceleratorSelector).get()); - } catch (cl::sycl::invalid_parameter_error &) { - } - } - - void visit(const sycl::device &Device, - const std::string &Indentation) override { - auto DefaultIt = std::find(m_DefaultDevices.begin(), m_DefaultDevices.end(), - Device.get()); - - if (DefaultIt != m_DefaultDevices.end()) - std::cout << Indentation - << "NOTE! The device is a DEFAULT device of this type" - << std::endl; - } -}; - -// The class prints generic info about the device -class PrintGenericInfo : public Action { - std::string convertDeviceType2String(sycl::info::device_type DeviceType) { - switch (DeviceType) { - case sycl::info::device_type::cpu: - return std::string("CPU"); - break; - case sycl::info::device_type::gpu: - return std::string("GPU"); - break; - case sycl::info::device_type::accelerator: - return std::string("ACCELERATOR"); - break; - case sycl::info::device_type::custom: - return std::string("CUSTOM"); - break; - case sycl::info::device_type::all: - case sycl::info::device_type::host: - case sycl::info::device_type::automatic: - default: - assert(!"Should be concrete OpenCL device"); - return std::string("UNKNOWN"); - break; - }; - } - -public: - PrintGenericInfo() = default; - void visit(const sycl::device &Device, - const std::string &Indentation) override { - - const sycl::info::device_type DeviceType = - Device.get_info(); - - const std::string DeviceName = Device.get_info(); - - const std::string DeviceVendor = - Device.get_info(); - - const std::string DeviceDriverVersion = - Device.get_info(); - - std::cout << Indentation - << "Type : " << convertDeviceType2String(DeviceType) - << std::endl; - - std::cout << Indentation << "Name : " << DeviceName << std::endl; - std::cout << Indentation << "Vendor : " << DeviceVendor - << std::endl; - std::cout << Indentation << "Driver version : " << DeviceDriverVersion - << std::endl; - } -}; - -// The class prints warning if the device is not tested or the driver version -// is too low -class PrintIfDeviceSupported : public Action { - - // Convert std::string "42.13.53" to std::vector {42, 13, 53} - std::vector convertToInts(const std::string SourceString) { - std::vector Result; - std::stringstream SStream(SourceString); - size_t Value = 0; - - while (SStream >> Value) { - Result.push_back(Value); - - if (SStream.peek() == '.') - SStream.ignore(); - } - return Result; - } - - void checkDriverVersion(const std::vector &RefVersionsStr, - const std::string &CurVersionStr, - const std::string &Indentation) { - - // Convert to vector of integers - const std::vector CurVersion = convertToInts(CurVersionStr); - - for (const std::string &RefVersionStr : RefVersionsStr) { - - // Convert to vector of integers - const std::vector RefVersion = convertToInts(RefVersionStr); - - // Check branch version - if (CurVersion[0] != RefVersion[0]) { - continue; - } - - // Check sizes - bool CheckPassed = CurVersion.size() == RefVersion.size(); - // Checking version going from major version to minor - for (size_t I = 1; CheckPassed && I < RefVersion.size(); ++I) - if (CurVersion[I] < RefVersion[I]) - CheckPassed = false; - - if (false == CheckPassed) { - std::cout << Indentation << "WARNING! The device driver version it too " - "low and not supported." - << std::endl; - std::cout - << Indentation - << "NOTE! The minimum supported driver version for this device is " - << RefVersionStr << std::endl; - } - return; - } - - std::cout << Indentation - << "WARNING! The device driver version is unrecognized" - << std::endl; - } - -public: - PrintIfDeviceSupported() = default; - void visit(const sycl::device &Device, - const std::string &Indentation) override { - - const std::string IntelName("Intel"); - const std::vector MinIntelOCLGPUVersion = { - MIN_INTEL_OCL_GPU_VERSION}; - const std::vector MinIntelOCLCPUVersion = { - MIN_INTEL_OCL_CPU_VERSION}; - - const sycl::info::device_type DeviceType = - Device.get_info(); - const std::string DeviceName = Device.get_info(); - const std::string DeviceDriverVersion = - Device.get_info(); - - // If Intel's device - if (DeviceName.find(IntelName) != std::string::npos) - switch (DeviceType) { - case sycl::info::device_type::cpu: - checkDriverVersion(MinIntelOCLCPUVersion, DeviceDriverVersion, - Indentation); - return; - case sycl::info::device_type::gpu: - checkDriverVersion(MinIntelOCLGPUVersion, DeviceDriverVersion, - Indentation); - return; - case sycl::info::device_type::accelerator: - std::cout << Indentation - << "WARNING! The device is not officially supported." - << std::endl; - return; - case sycl::info::device_type::custom: - case sycl::info::device_type::all: - case sycl::info::device_type::host: - case sycl::info::device_type::automatic: - default: - assert(!"Should be concrete OpenCL device"); - return; - } - // Non-Intel devices were not tested - std::cout << Indentation - << "WARNING! The device is not officially supported." - << std::endl; - } -}; - -// The class prints if the device is a default device of this type -class CheckSPIRVSupport : public Action { -public: - void visit(const sycl::device &Device, - const std::string &Indentation) override { - - const std::vector MinimumDeviceVersion = {2, 1}; - - const std::string DeviceVersionStr = - Device.get_info(); - std::vector DeviceVersion = {0, 0}; - - if (!DeviceVersionStr.compare(0, 10, "OpenCL 2.2")) - DeviceVersion = {2, 2}; - else if (!DeviceVersionStr.compare(0, 10, "OpenCL 2.1")) - DeviceVersion = {2, 1}; - else if (!DeviceVersionStr.compare(0, 10, "OpenCL 2.0")) - DeviceVersion = {2, 0}; - else if (!DeviceVersionStr.compare(0, 10, "OpenCL 1.2")) - DeviceVersion = {1, 2}; - else if (!DeviceVersionStr.compare(0, 10, "OpenCL 1.0")) - DeviceVersion = {1, 0}; - - if (DeviceVersion[0] < MinimumDeviceVersion[0] || - DeviceVersion[1] < MinimumDeviceVersion[1]) { - std::cout << Indentation - << "WARNING! Device doesn't support SPIRV format." << std::endl; - return; - } - } -}; - -int main() { - try { - std::vector> Actions; - // Fill vector of actions to be performed on each device - // Note! Actions are performed in order they are placed in vector - Actions.emplace_back(new PrintGenericInfo()); - Actions.emplace_back(new PrintIfDefaultDevice()); - Actions.emplace_back(new PrintIfDeviceSupported()); - Actions.emplace_back(new CheckSPIRVSupport()); - - std::cout << "Available OpenCL devices:" << std::endl; - size_t DeviceNumber = 0; - for (const sycl::device &Device : sycl::device::get_devices()) { - - // SYCL host device is not OpenCL device, skipping... - if (Device.get_info() == - sycl::info::device_type::host) - continue; - - std::cout << "Device [" << DeviceNumber << "]:" << std::endl; - - const std::string Tab(" "); - for (std::unique_ptr &Act : Actions) { - Act->visit(Device, Tab); - } - ++DeviceNumber; - } - } catch (...) { - std::cout << "Unhandled error happened." << std::endl; - return 1; - } - return 0; -}