From 4a4a5e03859ba520a0b609d7a6120cbe40363f07 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Fri, 10 Apr 2020 00:20:43 -0700 Subject: [PATCH 1/6] [SYCL]: Add lspi utility for listing devices discovered/selected by SYCL RT Change-Id: I9ce0f40d97aa6008c9b860342a8efd9c6e62fa3c Signed-off-by: Sergey V Maslov --- sycl/test/plugins/lspi_gpu_cuda.cpp | 24 ++++ sycl/test/plugins/lspi_gpu_opencl.cpp | 18 +++ sycl/tools/CMakeLists.txt | 8 ++ sycl/tools/lspi.cpp | 167 ++++++++++++++++++++++++++ 4 files changed, 217 insertions(+) create mode 100644 sycl/test/plugins/lspi_gpu_cuda.cpp create mode 100644 sycl/test/plugins/lspi_gpu_opencl.cpp create mode 100644 sycl/tools/lspi.cpp diff --git a/sycl/test/plugins/lspi_gpu_cuda.cpp b/sycl/test/plugins/lspi_gpu_cuda.cpp new file mode 100644 index 0000000000000..dc78bc8dfe2e5 --- /dev/null +++ b/sycl/test/plugins/lspi_gpu_cuda.cpp @@ -0,0 +1,24 @@ +// REQUIERS: gpu, cuda + +// RUN: lspi --verbose >%t.default.out +// RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-OPENCL,CHECK-CUSTOM-GPU-OPENCL --input-file %t.default.out + +// RUN: env SYCL_BE=PI_OPENCL lspi --verbose >%t.opencl.out +// RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-OPENCL,CHECK-CUSTOM-GPU-OPENCL --input-file %t.opencl.out + +// CHECK-BUILTIN-GPU-OPENCL: gpu_selector(){{.*}}GPU : OpenCL +// CHECK-CUSTOM-GPU-OPENCL: custom_selector(gpu){{.*}}GPU : OpenCL + +// RUN: env SYCL_BE=PI_CUDA lspi --verbose >%t.cuda.out +// RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-CUDA,CHECK-CUSTOM-GPU-CUDA --input-file %t.cuda.out + +// CHECK-BUILTIN-GPU-CUDA: gpu_selector(){{.*}}GPU : CUDA +// CHECK-CUSTOM-GPU-CUDA: custom_selector(gpu){{.*}}GPU : CUDA + +//==------- lspi_gpu_cuda.cpp - SYCL test for discovered/selected devices --==// +// +// 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 +// +//===----------------------------------------------------------------------===// diff --git a/sycl/test/plugins/lspi_gpu_opencl.cpp b/sycl/test/plugins/lspi_gpu_opencl.cpp new file mode 100644 index 0000000000000..78dd8870e1469 --- /dev/null +++ b/sycl/test/plugins/lspi_gpu_opencl.cpp @@ -0,0 +1,18 @@ +// REQUIRES: gpu + +// RUN: lspi --verbose >%t.default.out +// RUN: FileCheck %s --check-prefixes=CHECK-GPU-BUILTIN,CHECK-GPU-CUSTOM --input-file %t.default.out + +// RUN: env SYCL_BE=PI_OPENCL lspi --verbose >%t.opencl.out +// RUN: FileCheck %s --check-prefixes=CHECK-GPU-BUILTIN,CHECK-GPU-CUSTOM --input-file %t.opencl.out + +// CHECK-GPU-BUILTIN: gpu_selector(){{.*}}GPU : OpenCL +// CHECK-GPU-CUSTOM: custom_selector(gpu){{.*}}GPU : OpenCL + +//==------- lspi_gpu_opencl.cpp - SYCL test for discovered/selected devices===// +// +// 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 +// +//===----------------------------------------------------------------------===// diff --git a/sycl/tools/CMakeLists.txt b/sycl/tools/CMakeLists.txt index c90f55acd508b..066d50d12981a 100644 --- a/sycl/tools/CMakeLists.txt +++ b/sycl/tools/CMakeLists.txt @@ -4,6 +4,14 @@ set(CMAKE_CXX_EXTENSIONS OFF) # TODO: move each tool in its own sub-directory +add_executable(lspi lspi.cpp) +add_dependencies(lspi sycl) +target_include_directories(lspi PRIVATE "${sycl_inc_dir}") +target_link_libraries(lspi + PRIVATE sycl + PRIVATE OpenCL::Headers + PRIVATE ${OpenCL_LIBRARIES}) + add_executable(get_device_count_by_type get_device_count_by_type.cpp) add_dependencies(get_device_count_by_type ocl-headers ocl-icd) diff --git a/sycl/tools/lspi.cpp b/sycl/tools/lspi.cpp new file mode 100644 index 0000000000000..d2d8de998790b --- /dev/null +++ b/sycl/tools/lspi.cpp @@ -0,0 +1,167 @@ +//==----------- lspi.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 +// +//===----------------------------------------------------------------------===// +// +// The "lspi" utility lists all platforms/devices discovered by PI similar to +// how lscl prints this for OpenCL devices. It can probably be eventually merged +// with the more complex "check-sycl" utility. +// +// There are two types of output: +// concise (default) and +// verbose (enabled with any argument). +// +// In verbose mode it also prints, which devices would be chose by various SYCL +// device selectors. +// +#include + +#include +#include +#include + +using namespace cl::sycl; +using namespace std; + +// Controls verbose output vs. concise. +bool verbose = false; + +// Trivial custom selector that selects a device of the given type. +class custom_selector : public device_selector { + info::device_type MType; + +public: + custom_selector(info::device_type Type) : MType(Type) {} + int operator()(const device &Dev) const override { + return Dev.get_info() == MType ? 1 : -1; + } +}; + +static void printDeviceInfo(const device &Device, const string &Prepend) { + auto DeviceType = Device.get_info(); + string DeviceTypeName; + switch (DeviceType) { + case info::device_type::cpu: + DeviceTypeName = "CPU "; + break; + case info::device_type::gpu: + DeviceTypeName = "GPU "; + break; + case info::device_type::host: + DeviceTypeName = "HOST"; + break; + case info::device_type::accelerator: + DeviceTypeName = "ACC "; + break; + default: + DeviceTypeName = "??? "; + break; + } + + auto DeviceVersion = Device.get_info(); + auto DeviceName = Device.get_info(); + auto DeviceVendor = Device.get_info(); + auto DeviceDriverVersion = Device.get_info(); + + if (verbose) { + cout << Prepend << "Type : " << DeviceTypeName << std::endl; + cout << Prepend << "Version : " << DeviceVersion << std::endl; + cout << Prepend << "Name : " << DeviceName << std::endl; + cout << Prepend << "Vendor : " << DeviceVendor << std::endl; + cout << Prepend << "Driver : " << DeviceDriverVersion << std::endl; + } else { + cout << Prepend << DeviceTypeName << ": " << DeviceVersion << "[ " + << DeviceDriverVersion << " ]" << std::endl; + } +} + +static void printSelectorChoice(const device_selector &Selector, + const std::string &Prepend) { + try { + const auto &Dev = device(Selector); + printDeviceInfo(Dev, Prepend); + + } catch (const cl::sycl::runtime_error &Exception) { + // Truncate long string so it can fit in one-line + std::string What = Exception.what(); + if (What.length() > 50) + What = What.substr(0, 50) + "..."; + + if (verbose) { + cout << Prepend << "Type : " << What << std::endl; + cout << Prepend << "Version : " << What << std::endl; + cout << Prepend << "Name : " << What << std::endl; + cout << Prepend << "Vendor : " << What << std::endl; + cout << Prepend << "Driver : " << What << std::endl; + } else { + cout << Prepend << What << std::endl; + } + } +} + +int main(int argc, char **argv) { + + // Any options trigger verbose output. + if (argc > 1) { + verbose = true; + if (!std::getenv("SYCL_PI_TRACE")) { + // Enable trace of PI discovery. + // setenv("SYCL_PI_TRACE", "1", true); + } + } + + auto Platforms = platform::get_platforms(); + if (verbose) + cout << "Platforms: " << Platforms.size() << std::endl; + + uint32_t PlatformNum = 0; + for (const auto &Platform : Platforms) { + ++PlatformNum; + if (verbose) { + auto PlatformVersion = Platform.get_info(); + auto PlatformName = Platform.get_info(); + auto PlatformVendor = Platform.get_info(); + cout << "Platform [#" << PlatformNum << "]:" << std::endl; + cout << " Version : " << PlatformVersion << std::endl; + cout << " Name : " << PlatformName << std::endl; + cout << " Vendor : " << PlatformVendor << std::endl; + } + auto Devices = Platform.get_devices(); + if (verbose) + cout << " Devices : " << Devices.size() << std::endl; + uint32_t DeviceNum = 0; + for (const auto &Device : Devices) { + ++DeviceNum; + if (verbose) + cout << " Device [#" << DeviceNum << "]:" << std::endl; + printDeviceInfo(Device, verbose ? " " : ""); + } + } + + if (!verbose) { + return 0; + } + + // Print the selectors choice in one-line always + verbose = false; + + // Print built-in device selectors choice + printSelectorChoice(default_selector(), "default_selector() : "); + printSelectorChoice(host_selector(), "host_selector() : "); + printSelectorChoice(accelerator_selector(), "accelerator_selector() : "); + printSelectorChoice(cpu_selector(), "cpu_selector() : "); + printSelectorChoice(gpu_selector(), "gpu_selector() : "); + + // Print trivial custom selectors choice + printSelectorChoice(custom_selector(info::device_type::gpu), + "custom_selector(gpu) : "); + printSelectorChoice(custom_selector(info::device_type::cpu), + "custom_selector(cpu) : "); + printSelectorChoice(custom_selector(info::device_type::accelerator), + "custom_selector(acc) : "); + + return 0; +} From 2452093a00d68ea53b0fb72513029fa8274adad7 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Mon, 27 Apr 2020 16:53:59 -0700 Subject: [PATCH 2/6] [SYCL] address review comments Signed-off-by: Sergey V Maslov --- sycl/CMakeLists.txt | 1 + sycl/test/plugins/lspi_gpu_cuda.cpp | 2 +- sycl/tools/CMakeLists.txt | 11 +-- sycl/tools/sycl-ls/CMakeLists.txt | 13 ++++ sycl/tools/{lspi.cpp => sycl-ls/sycl-ls.cpp} | 72 +++++++++----------- 5 files changed, 48 insertions(+), 51 deletions(-) mode change 100644 => 100755 sycl/CMakeLists.txt mode change 100644 => 100755 sycl/test/plugins/lspi_gpu_cuda.cpp mode change 100644 => 100755 sycl/tools/CMakeLists.txt create mode 100755 sycl/tools/sycl-ls/CMakeLists.txt rename sycl/tools/{lspi.cpp => sycl-ls/sycl-ls.cpp} (64%) mode change 100644 => 100755 diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt old mode 100644 new mode 100755 index 61049b9e0a3f6..8e6c7b8008d52 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -232,6 +232,7 @@ add_custom_target( sycl-toolchain llvm-link llvm-objcopy sycl-post-link + sycl-ls COMMENT "Building SYCL compiler toolchain..." ) diff --git a/sycl/test/plugins/lspi_gpu_cuda.cpp b/sycl/test/plugins/lspi_gpu_cuda.cpp old mode 100644 new mode 100755 index dc78bc8dfe2e5..a1b8fabfdb578 --- a/sycl/test/plugins/lspi_gpu_cuda.cpp +++ b/sycl/test/plugins/lspi_gpu_cuda.cpp @@ -1,4 +1,4 @@ -// REQUIERS: gpu, cuda +// REQUIRES: gpu, cuda // RUN: lspi --verbose >%t.default.out // RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-OPENCL,CHECK-CUSTOM-GPU-OPENCL --input-file %t.default.out diff --git a/sycl/tools/CMakeLists.txt b/sycl/tools/CMakeLists.txt old mode 100644 new mode 100755 index 066d50d12981a..6fb4b21c3842d --- a/sycl/tools/CMakeLists.txt +++ b/sycl/tools/CMakeLists.txt @@ -2,16 +2,9 @@ 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(lspi lspi.cpp) -add_dependencies(lspi sycl) -target_include_directories(lspi PRIVATE "${sycl_inc_dir}") -target_link_libraries(lspi - PRIVATE sycl - PRIVATE OpenCL::Headers - PRIVATE ${OpenCL_LIBRARIES}) +add_subdirectory(sycl-ls) +# 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) diff --git a/sycl/tools/sycl-ls/CMakeLists.txt b/sycl/tools/sycl-ls/CMakeLists.txt new file mode 100755 index 0000000000000..26dbf61d5941e --- /dev/null +++ b/sycl/tools/sycl-ls/CMakeLists.txt @@ -0,0 +1,13 @@ +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +add_executable(sycl-ls sycl-ls.cpp) +add_dependencies(sycl-ls sycl) +target_include_directories(sycl-ls PRIVATE "${sycl_inc_dir}") +target_link_libraries(sycl-ls + PRIVATE + sycl + OpenCL::Headers + ${OpenCL_LIBRARIES} +) diff --git a/sycl/tools/lspi.cpp b/sycl/tools/sycl-ls/sycl-ls.cpp old mode 100644 new mode 100755 similarity index 64% rename from sycl/tools/lspi.cpp rename to sycl/tools/sycl-ls/sycl-ls.cpp index d2d8de998790b..b8bc96cfb5eb9 --- a/sycl/tools/lspi.cpp +++ b/sycl/tools/sycl-ls/sycl-ls.cpp @@ -1,4 +1,4 @@ -//==----------- lspi.cpp ---------------------------------------------------==// +//==----------- sycl-ls.cpp ------------------------------------------------==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,15 +6,14 @@ // //===----------------------------------------------------------------------===// // -// The "lspi" utility lists all platforms/devices discovered by PI similar to -// how lscl prints this for OpenCL devices. It can probably be eventually merged -// with the more complex "check-sycl" utility. +// The "sycl-ls" utility lists all platforms/devices discovered by PI similar to +// how lscl prints this for OpenCL devices. // // There are two types of output: // concise (default) and -// verbose (enabled with any argument). +// verbose (enabled with --verbose). // -// In verbose mode it also prints, which devices would be chose by various SYCL +// In verbose mode it also prints, which devices would be chosen by various SYCL // device selectors. // #include @@ -24,10 +23,9 @@ #include using namespace cl::sycl; -using namespace std; // Controls verbose output vs. concise. -bool verbose = false; +bool verbose; // Trivial custom selector that selects a device of the given type. class custom_selector : public device_selector { @@ -40,9 +38,9 @@ class custom_selector : public device_selector { } }; -static void printDeviceInfo(const device &Device, const string &Prepend) { +static void printDeviceInfo(const device &Device, const std::string &Prepend) { auto DeviceType = Device.get_info(); - string DeviceTypeName; + std::string DeviceTypeName; switch (DeviceType) { case info::device_type::cpu: DeviceTypeName = "CPU "; @@ -57,7 +55,7 @@ static void printDeviceInfo(const device &Device, const string &Prepend) { DeviceTypeName = "ACC "; break; default: - DeviceTypeName = "??? "; + DeviceTypeName = "UNKNOWN"; break; } @@ -67,14 +65,14 @@ static void printDeviceInfo(const device &Device, const string &Prepend) { auto DeviceDriverVersion = Device.get_info(); if (verbose) { - cout << Prepend << "Type : " << DeviceTypeName << std::endl; - cout << Prepend << "Version : " << DeviceVersion << std::endl; - cout << Prepend << "Name : " << DeviceName << std::endl; - cout << Prepend << "Vendor : " << DeviceVendor << std::endl; - cout << Prepend << "Driver : " << DeviceDriverVersion << std::endl; + std::cout << Prepend << "Type : " << DeviceTypeName << std::endl; + std::cout << Prepend << "Version : " << DeviceVersion << std::endl; + std::cout << Prepend << "Name : " << DeviceName << std::endl; + std::cout << Prepend << "Vendor : " << DeviceVendor << std::endl; + std::cout << Prepend << "Driver : " << DeviceDriverVersion << std::endl; } else { - cout << Prepend << DeviceTypeName << ": " << DeviceVersion << "[ " - << DeviceDriverVersion << " ]" << std::endl; + std::cout << Prepend << DeviceTypeName << ": " << DeviceVersion << "[ " + << DeviceDriverVersion << " ]" << std::endl; } } @@ -89,33 +87,25 @@ static void printSelectorChoice(const device_selector &Selector, std::string What = Exception.what(); if (What.length() > 50) What = What.substr(0, 50) + "..."; - - if (verbose) { - cout << Prepend << "Type : " << What << std::endl; - cout << Prepend << "Version : " << What << std::endl; - cout << Prepend << "Name : " << What << std::endl; - cout << Prepend << "Vendor : " << What << std::endl; - cout << Prepend << "Driver : " << What << std::endl; - } else { - cout << Prepend << What << std::endl; - } + std::cout << Prepend << What << std::endl; } } int main(int argc, char **argv) { - // Any options trigger verbose output. - if (argc > 1) { + // See if verbose output is requested + if (argc == 1) + verbose = false; + else if (argc == 2 && std::string(argv[1]) == "--verbose") verbose = true; - if (!std::getenv("SYCL_PI_TRACE")) { - // Enable trace of PI discovery. - // setenv("SYCL_PI_TRACE", "1", true); - } + else { + std::cout << "Usage: sycl-ls [--verbose]" << std::endl; + return -1; } auto Platforms = platform::get_platforms(); if (verbose) - cout << "Platforms: " << Platforms.size() << std::endl; + std::cout << "Platforms: " << Platforms.size() << std::endl; uint32_t PlatformNum = 0; for (const auto &Platform : Platforms) { @@ -124,19 +114,19 @@ int main(int argc, char **argv) { auto PlatformVersion = Platform.get_info(); auto PlatformName = Platform.get_info(); auto PlatformVendor = Platform.get_info(); - cout << "Platform [#" << PlatformNum << "]:" << std::endl; - cout << " Version : " << PlatformVersion << std::endl; - cout << " Name : " << PlatformName << std::endl; - cout << " Vendor : " << PlatformVendor << std::endl; + std::cout << "Platform [#" << PlatformNum << "]:" << std::endl; + std::cout << " Version : " << PlatformVersion << std::endl; + std::cout << " Name : " << PlatformName << std::endl; + std::cout << " Vendor : " << PlatformVendor << std::endl; } auto Devices = Platform.get_devices(); if (verbose) - cout << " Devices : " << Devices.size() << std::endl; + std::cout << " Devices : " << Devices.size() << std::endl; uint32_t DeviceNum = 0; for (const auto &Device : Devices) { ++DeviceNum; if (verbose) - cout << " Device [#" << DeviceNum << "]:" << std::endl; + std::cout << " Device [#" << DeviceNum << "]:" << std::endl; printDeviceInfo(Device, verbose ? " " : ""); } } From 9b6c8e2317f21a117af10117df3f74d124edf2e3 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Tue, 28 Apr 2020 14:44:06 -0700 Subject: [PATCH 3/6] [SYCL] address review comments #2 Signed-off-by: Sergey V Maslov --- sycl/CMakeLists.txt | 1 + sycl/test/plugins/sycl-ls-gpu-cuda.cpp | 15 +++++++++++++++ ...lspi_gpu_opencl.cpp => sycl-ls-gpu-opencl.cpp} | 8 ++++---- ...{lspi_gpu_cuda.cpp => sycl-ls-gpu-sycl-be.cpp} | 10 +++++----- sycl/test/plugins/sycl-ls.cpp | 11 +++++++++++ sycl/tools/sycl-ls/CMakeLists.txt | 5 ----- sycl/tools/sycl-ls/sycl-ls.cpp | 2 +- 7 files changed, 37 insertions(+), 15 deletions(-) create mode 100755 sycl/test/plugins/sycl-ls-gpu-cuda.cpp rename sycl/test/plugins/{lspi_gpu_opencl.cpp => sycl-ls-gpu-opencl.cpp} (74%) mode change 100644 => 100755 rename sycl/test/plugins/{lspi_gpu_cuda.cpp => sycl-ls-gpu-sycl-be.cpp} (75%) create mode 100755 sycl/test/plugins/sycl-ls.cpp diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 8e6c7b8008d52..454a8f62e635e 100755 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -282,6 +282,7 @@ set( SYCL_TOOLCHAIN_DEPLOY_COMPONENTS llvm-link llvm-objcopy sycl-post-link + sycl-ls clang-resource-headers opencl-headers sycl-headers diff --git a/sycl/test/plugins/sycl-ls-gpu-cuda.cpp b/sycl/test/plugins/sycl-ls-gpu-cuda.cpp new file mode 100755 index 0000000000000..8a2a9aca5b2c0 --- /dev/null +++ b/sycl/test/plugins/sycl-ls-gpu-cuda.cpp @@ -0,0 +1,15 @@ +// REQUIRES: gpu, cuda + +// RUN: env SYCL_BE=PI_CUDA sycl-ls --verbose >%t.cuda.out +// RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-CUDA,CHECK-CUSTOM-GPU-CUDA --input-file %t.cuda.out + +// CHECK-BUILTIN-GPU-CUDA: gpu_selector(){{.*}}GPU :{{.*}}CUDA +// CHECK-CUSTOM-GPU-CUDA: custom_selector(gpu){{.*}}GPU :{{.*}}CUDA + +//==---- sycl-ls-gpu-cuda.cpp - SYCL test for discovered/selected devices --==// +// +// 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 +// +//===----------------------------------------------------------------------===// diff --git a/sycl/test/plugins/lspi_gpu_opencl.cpp b/sycl/test/plugins/sycl-ls-gpu-opencl.cpp old mode 100644 new mode 100755 similarity index 74% rename from sycl/test/plugins/lspi_gpu_opencl.cpp rename to sycl/test/plugins/sycl-ls-gpu-opencl.cpp index 78dd8870e1469..58a04c6ab4c3a --- a/sycl/test/plugins/lspi_gpu_opencl.cpp +++ b/sycl/test/plugins/sycl-ls-gpu-opencl.cpp @@ -1,15 +1,15 @@ -// REQUIRES: gpu +// REQUIRES: gpu, opencl -// RUN: lspi --verbose >%t.default.out +// RUN: sycl-ls --verbose >%t.default.out // RUN: FileCheck %s --check-prefixes=CHECK-GPU-BUILTIN,CHECK-GPU-CUSTOM --input-file %t.default.out -// RUN: env SYCL_BE=PI_OPENCL lspi --verbose >%t.opencl.out +// RUN: env SYCL_BE=PI_OPENCL sycl-ls --verbose >%t.opencl.out // RUN: FileCheck %s --check-prefixes=CHECK-GPU-BUILTIN,CHECK-GPU-CUSTOM --input-file %t.opencl.out // CHECK-GPU-BUILTIN: gpu_selector(){{.*}}GPU : OpenCL // CHECK-GPU-CUSTOM: custom_selector(gpu){{.*}}GPU : OpenCL -//==------- lspi_gpu_opencl.cpp - SYCL test for discovered/selected devices===// +//==-- sycl-ls-gpu-opencl.cpp - SYCL test for discovered/selected devices -===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/sycl/test/plugins/lspi_gpu_cuda.cpp b/sycl/test/plugins/sycl-ls-gpu-sycl-be.cpp similarity index 75% rename from sycl/test/plugins/lspi_gpu_cuda.cpp rename to sycl/test/plugins/sycl-ls-gpu-sycl-be.cpp index a1b8fabfdb578..02d217941de24 100755 --- a/sycl/test/plugins/lspi_gpu_cuda.cpp +++ b/sycl/test/plugins/sycl-ls-gpu-sycl-be.cpp @@ -1,21 +1,21 @@ -// REQUIRES: gpu, cuda +// REQUIRES: gpu, cuda, opencl -// RUN: lspi --verbose >%t.default.out +// RUN: sycl-ls --verbose >%t.default.out // RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-OPENCL,CHECK-CUSTOM-GPU-OPENCL --input-file %t.default.out -// RUN: env SYCL_BE=PI_OPENCL lspi --verbose >%t.opencl.out +// RUN: env SYCL_BE=PI_OPENCL sycl-ls --verbose >%t.opencl.out // RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-OPENCL,CHECK-CUSTOM-GPU-OPENCL --input-file %t.opencl.out // CHECK-BUILTIN-GPU-OPENCL: gpu_selector(){{.*}}GPU : OpenCL // CHECK-CUSTOM-GPU-OPENCL: custom_selector(gpu){{.*}}GPU : OpenCL -// RUN: env SYCL_BE=PI_CUDA lspi --verbose >%t.cuda.out +// RUN: env SYCL_BE=PI_CUDA sycl-ls --verbose >%t.cuda.out // RUN: FileCheck %s --check-prefixes=CHECK-BUILTIN-GPU-CUDA,CHECK-CUSTOM-GPU-CUDA --input-file %t.cuda.out // CHECK-BUILTIN-GPU-CUDA: gpu_selector(){{.*}}GPU : CUDA // CHECK-CUSTOM-GPU-CUDA: custom_selector(gpu){{.*}}GPU : CUDA -//==------- lspi_gpu_cuda.cpp - SYCL test for discovered/selected devices --==// +//==---- sycl-ls-gpu-sycl-be.cpp - SYCL test for discovered/selected devices --==// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/sycl/test/plugins/sycl-ls.cpp b/sycl/test/plugins/sycl-ls.cpp new file mode 100755 index 0000000000000..c9baaf508da0a --- /dev/null +++ b/sycl/test/plugins/sycl-ls.cpp @@ -0,0 +1,11 @@ +// RUN: sycl-ls --verbose | grep "Device \[" | wc -l >%t.verbose.out +// RUN: sycl-ls | wc -l >%t.concise.out +// RUN: diff %t.verbose.out %t.concise.out + +//==---- sycl-ls.cpp - SYCL test for consistency of sycl-ls output ---------==// +// +// 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 +// +//===----------------------------------------------------------------------===// diff --git a/sycl/tools/sycl-ls/CMakeLists.txt b/sycl/tools/sycl-ls/CMakeLists.txt index 26dbf61d5941e..79a022841efb0 100755 --- a/sycl/tools/sycl-ls/CMakeLists.txt +++ b/sycl/tools/sycl-ls/CMakeLists.txt @@ -1,7 +1,3 @@ -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) -set(CMAKE_CXX_EXTENSIONS OFF) - add_executable(sycl-ls sycl-ls.cpp) add_dependencies(sycl-ls sycl) target_include_directories(sycl-ls PRIVATE "${sycl_inc_dir}") @@ -9,5 +5,4 @@ target_link_libraries(sycl-ls PRIVATE sycl OpenCL::Headers - ${OpenCL_LIBRARIES} ) diff --git a/sycl/tools/sycl-ls/sycl-ls.cpp b/sycl/tools/sycl-ls/sycl-ls.cpp index b8bc96cfb5eb9..c2bcaef05e4cc 100755 --- a/sycl/tools/sycl-ls/sycl-ls.cpp +++ b/sycl/tools/sycl-ls/sycl-ls.cpp @@ -7,7 +7,7 @@ //===----------------------------------------------------------------------===// // // The "sycl-ls" utility lists all platforms/devices discovered by PI similar to -// how lscl prints this for OpenCL devices. +// how clinfo prints this for OpenCL devices. // // There are two types of output: // concise (default) and From 2e503e933964da8ac6056e2f840e2e7b603d2535 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Wed, 29 Apr 2020 17:32:20 -0700 Subject: [PATCH 4/6] [SYCL] address review comments #3 Signed-off-by: Sergey V Maslov --- sycl/tools/sycl-ls/sycl-ls.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sycl/tools/sycl-ls/sycl-ls.cpp b/sycl/tools/sycl-ls/sycl-ls.cpp index c2bcaef05e4cc..f3909723f422f 100755 --- a/sycl/tools/sycl-ls/sycl-ls.cpp +++ b/sycl/tools/sycl-ls/sycl-ls.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// // -// The "sycl-ls" utility lists all platforms/devices discovered by PI similar to -// how clinfo prints this for OpenCL devices. +// The "sycl-ls" utility lists all platforms/devices discovered by SYCL similar +// to how clinfo prints this for OpenCL devices. // // There are two types of output: // concise (default) and @@ -100,7 +100,7 @@ int main(int argc, char **argv) { verbose = true; else { std::cout << "Usage: sycl-ls [--verbose]" << std::endl; - return -1; + return EXIT_FAILURE; } auto Platforms = platform::get_platforms(); @@ -132,7 +132,7 @@ int main(int argc, char **argv) { } if (!verbose) { - return 0; + return EXIT_SUCCESS; } // Print the selectors choice in one-line always @@ -153,5 +153,5 @@ int main(int argc, char **argv) { printSelectorChoice(custom_selector(info::device_type::accelerator), "custom_selector(acc) : "); - return 0; + return EXIT_SUCCESS; } From 9255a4dfc08f0cbf2a50ca51ecbaae3b7d26b511 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Thu, 30 Apr 2020 08:50:30 -0700 Subject: [PATCH 5/6] [SYCL] address review comments #4 Signed-off-by: Sergey V Maslov --- sycl/CMakeLists.txt | 0 sycl/tools/CMakeLists.txt | 0 sycl/tools/sycl-ls/CMakeLists.txt | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 sycl/CMakeLists.txt mode change 100755 => 100644 sycl/tools/CMakeLists.txt mode change 100755 => 100644 sycl/tools/sycl-ls/CMakeLists.txt diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/sycl/tools/CMakeLists.txt b/sycl/tools/CMakeLists.txt old mode 100755 new mode 100644 diff --git a/sycl/tools/sycl-ls/CMakeLists.txt b/sycl/tools/sycl-ls/CMakeLists.txt old mode 100755 new mode 100644 From 89ad5b03f80a84f751057addecf221e83e7c1327 Mon Sep 17 00:00:00 2001 From: Sergey V Maslov Date: Thu, 30 Apr 2020 14:25:44 -0700 Subject: [PATCH 6/6] [SYCL] address review comments #5 Signed-off-by: Sergey V Maslov --- sycl/include/CL/sycl/handler.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/sycl/include/CL/sycl/handler.hpp b/sycl/include/CL/sycl/handler.hpp index 49767539bc683..a66bfa97d1802 100644 --- a/sycl/include/CL/sycl/handler.hpp +++ b/sycl/include/CL/sycl/handler.hpp @@ -107,8 +107,6 @@ template struct get_kernel_name_t { __SYCL_EXPORT device getDeviceFromHandler(handler &); -device getDeviceFromHandler(handler &); - } // namespace detail namespace intel {