diff --git a/Tools/ApplicationDebugger/array-transform/CMakeLists.txt b/Tools/ApplicationDebugger/array-transform/CMakeLists.txt index f6cea4ec47..56d41e599c 100644 --- a/Tools/ApplicationDebugger/array-transform/CMakeLists.txt +++ b/Tools/ApplicationDebugger/array-transform/CMakeLists.txt @@ -59,4 +59,4 @@ add_custom_target(run-gpu ./${PROJECT_NAME} gpu DEPENDS ${PROJECT_NAME}) add_custom_target(run-fpga ./${PROJECT_NAME} accelerator - DEPENDS ${PROJECT_NAME}) \ No newline at end of file + DEPENDS ${PROJECT_NAME}) diff --git a/Tools/ApplicationDebugger/array-transform/README.md b/Tools/ApplicationDebugger/array-transform/README.md index 2cbf3d3527..17fae2b5ea 100644 --- a/Tools/ApplicationDebugger/array-transform/README.md +++ b/Tools/ApplicationDebugger/array-transform/README.md @@ -24,9 +24,9 @@ scheduler-locking and SIMD lane views. The sample is intended for exercising the debugger, not for performance benchmarking. The debugger supports debugging kernels that run on the CPU, GPU, or -accelerator devices. For convenience, the `array-transform` -code sample provides the ability to select the target device by passing the -program `cpu`, `gpu`, or `accelerator` as the command-line argument. +accelerator devices. Use the ONEAPI_DEVICE_SELECTOR environment variable +to select device. The default device is Level Zero GPU device, if available. +For more details on possible values of this variable see [Environment Variables](https://intel.github.io/llvm-docs/EnvironmentVariables.html#oneapi-device-selector). The selected device is displayed in the output. Concrete instructions about how to run the program and example outputs are given further below. For complete setup and usage instructions, see [Get Started with Intel® Distribution for GDB* on Linux* OS Host](https://software.intel.com/en-us/get-started-with-debugging-dpcpp) @@ -143,18 +143,18 @@ Perform the following steps: 2. Run the program: ``` - $ ./array-transform + $ ./array-transform ``` - > Note: `` is the type of the device type to offload the kernel. - > Use `cpu`, `gpu`, or `accelerator` to select the CPU, GPU, or the - > FPGA emulator device, respectively. E.g.: + > Note: to specify a device type to offload the kernel, use + > the `ONEAPI_DEVICE_SELECTOR` environment variable. + > E.g. to restrict the offload only to CPU devices use: ``` - $ ./array-transform cpu + $ ONEAPI_DEVICE_SELECTOR=*:cpu ./array-transform ``` 3. Start a debugging session: ``` - $ gdb-oneapi --args array-transform + $ gdb-oneapi array-transform ``` 4. Clean the program using: @@ -165,14 +165,12 @@ Perform the following steps: By default, CMake configures the build for Just-in-Time (JIT) compilation of the kernel. However, it also offers an option for *Ahead-of-Time* (AoT) compilation. To compile the kernel -ahead-of-time for a specific device, set the `DPCPP_COMPILE_TARGET` +ahead-of-time for a specific device, set the `SYCL_COMPILE_TARGET` option to the desired device during configuration. For CPU, use the `cpu` value; for FPGA-emu, use the `fpga-emu` value. Other values are assumed to be for GPU and are passed directly to the GPU AoT compiler. -> *Hint:* Run `ocloc compile --help` to see available GPU device options. - For example, to do AoT compilation for a specific GPU device ID: ``` @@ -191,6 +189,8 @@ $ sycl-ls In the above example, the device ID is `0x56c1`. +> *Hint:* Run `ocloc compile --help` to see all available GPU device options. + > **Note**: AoT compilation is particularly helpful in larger > applications where compiling with debug information takes > considerably longer time. @@ -223,11 +223,11 @@ dependencies and permissions errors. 3. Select Menu "Debug > Start Debugging" to run the program. -4. The solution file is configured to pass `cpu` as the argument to the - program. To select a different device, go to the project's "Configuration - Properties > Debugging" and set the "Command Arguments" field. - Use `gpu` or `accelerator` to target the GPU or the FPGA emulator device, - respectively. +4. The solution file is configured to set `ONEAPI_DEVICE_SELECTOR=*:cpu` + for Local Windows Debugging. That setting causes the program to offload + on a CPU device. To select a different device, go to the project's + "Configuration Properties > Debugging" and edit the "Environment" field. + Modify the value of `ONEAPI_DEVICE_SELECTOR` as you need. For detailed instructions about starting and using the debugger, please see [Get Started with Intel® Distribution for GDB* on Windows* OS Host](https://www.intel.com/content/www/us/en/develop/documentation/get-started-with-debugging-dpcpp-windows/). @@ -236,55 +236,49 @@ please see [Get Started with Intel® Distribution for GDB* on Windows* OS Host]( ### Example Outputs ``` -$ gdb-oneapi -q --args ./array-transform cpu +$ ONEAPI_DEVICE_SELECTOR=*:cpu gdb-oneapi -q ./array-transform Reading symbols from ./array-transform... -(gdb) break 56 -Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 56. +(gdb) break 54 +Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 54. (gdb) run ...... [SYCL] Using device: [Intel(R) Core(TM) i9-7900X processor] from [Intel(R) OpenCL] [Switching to Thread 0x7fffe3bfe700 (LWP 925)] -Thread 16 "array-transform" hit Breakpoint 1, main::$_1::operator() -(cl::sycl::handler&) const::{lambda(auto:1)#1}::operator() > -(cl::sycl::item<1, true>) const (this=0x7fffe3bfcfa8, index=...) at array-transform.cpp:56 -56 int element = in[index]; // breakpoint-here +Thread 4 "array-transform" hit Breakpoint 1, main::{lambda(auto:1&)#1}::operator()(sycl::_V1::handler&) const::{lambda(sycl::_V1::id<1>)#1}::operator()(sycl::_V1::id<1>) const (this=0x7fffc85582c8, index=sycl::_V1::id<1> = {...}) at array-transform.cpp:54 +54 int element = in[index]; // breakpoint-here (gdb) ``` ``` -$ gdb-oneapi -q --args ./array-transform accelerator +$ ONEAPI_DEVICE_SELECTOR=*:fpga gdb-oneapi -q ./array-transform Reading symbols from ./array-transform... -(gdb) break 56 -Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 56. +(gdb) break 54 +Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 54. (gdb) run ...... [SYCL] Using device: [Intel(R) FPGA Emulation Device] from [Intel(R) FPGA Emulation Platform for OpenCL(TM) software] [Switching to Thread 0x7fffe1ffb700 (LWP 2387)] -Thread 9 "array-transform" hit Breakpoint 1, main::$_1::operator() -(cl::sycl::handler&) const::{lambda(auto:1)#1}::operator() > -(cl::sycl::item<1, true>) const (this=0x7fffe1ff9fa8, index=...) at array-transform.cpp:56 -56 int element = in[index]; // breakpoint-here +Thread 6 "array-transform" hit Breakpoint 1, main::{lambda(auto:1&)#1}::operator()(sycl::_V1::handler&) const::{lambda(sycl::_V1::id<1>)#1}::operator()(sycl::_V1::id<1>) const (this=0x7fffc08cef48, index=sycl::_V1::id<1> = {...}) at array-transform.cpp:54 +54 int element = in[index]; // breakpoint-here (gdb) ``` ``` -$ gdb-oneapi -q --args ./array-transform gpu +$ ONEAPI_DEVICE_SELECTOR=level_zero:gpu gdb-oneapi -q ./array-transform Reading symbols from ./array-transform... -(gdb) break 56 -Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 56. +(gdb) break 54 +Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 54. (gdb) run ...... -[SYCL] Using device: [Intel(R) Iris(R) Plus Graphics 650 [0x5927]] from [Intel(R) Level-Zero] +intelgt: gdbserver-ze started for process 18496. ...... -[Switching to Thread 1073741824 lane 0] +[SYCL] Using device: [Intel(R) Data Center GPU Flex Series 140 [0x56c1]] from [Intel(R) Level-Zero] +[Switching to Thread 1.153 lane 0] -Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], main::$_1::operator() -(cl::sycl::handler&) const::{lambda(auto:1)#1}::operator() - >(cl::sycl::item<1, true>) const (this=0x2f690c0, index=...) -at array-transform.cpp:56 -56 int element = in[index]; // breakpoint-here +Thread 2.153 hit Breakpoint 1, with SIMD lanes [0-7], main::{lambda(auto:1&)#1}::operator()(sycl::_V1::handler&) const::{lambda(sycl::_V1::id<1>)#1}::operator()(sycl::_V1::id<1>) const (this=0xffffd556ab1898d0, index=...) at array-transform.cpp:54 +54 int element = in[index]; // breakpoint-here (gdb) ``` diff --git a/Tools/ApplicationDebugger/array-transform/array-transform.vcxproj.user b/Tools/ApplicationDebugger/array-transform/array-transform.vcxproj.user index dd7725379a..224473013b 100644 --- a/Tools/ApplicationDebugger/array-transform/array-transform.vcxproj.user +++ b/Tools/ApplicationDebugger/array-transform/array-transform.vcxproj.user @@ -1,12 +1,11 @@  - CL_CONFIG_USE_NATIVE_DEBUGGER=1 + ONEAPI_DEVICE_SELECTOR=*:cpu WindowsLocalDebugger - cpu - cpu + ONEAPI_DEVICE_SELECTOR=*:cpu WindowsLocalDebugger diff --git a/Tools/ApplicationDebugger/array-transform/sample.json b/Tools/ApplicationDebugger/array-transform/sample.json index 2da41809f5..3fe0f005a4 100644 --- a/Tools/ApplicationDebugger/array-transform/sample.json +++ b/Tools/ApplicationDebugger/array-transform/sample.json @@ -2,8 +2,8 @@ "guid": "4B3FDDD8-64CF-4CF3-9387-26E34F021E24", "name": "Debugger: Array Transform", "categories": ["Toolkit/Get Started", "Toolkit/oneAPI Tools/Application Debugger"], - "description": "A small Data Parallel C++ (DPC++) example that is used in the \"Get Started Guide\" of the Application Debugger to exercise major debugger functionality", - "toolchain": ["dpcpp"], + "description": "A small SYCL (C++) example that is used in the \"Get Started Guide\" of the Application Debugger to exercise major debugger functionality", + "toolchain": ["icpx"], "dependencies": ["debugger"], "languages": [{"cpp":{}}], "targetDevice": ["CPU", "GPU"], @@ -16,16 +16,16 @@ "steps": [ "mkdir -p build_cpu; cd build_cpu; cmake ..", "make", - "./array-transform cpu", + "ONEAPI_DEVICE_SELECTOR=*:cpu ./array-transform", "make clean" ] }, { "id": "cpu-aot", "steps": [ - "mkdir -p build_cpu_aot; cd build_cpu_aot; cmake .. -DDPCPP_COMPILE_TARGET=cpu", + "mkdir -p build_cpu_aot; cd build_cpu_aot; cmake .. -DSYCL_COMPILE_TARGET=cpu", "make", - "./array-transform cpu", + "ONEAPI_DEVICE_SELECTOR=*:cpu ./array-transform", "make clean" ] }, @@ -34,16 +34,16 @@ "steps": [ "mkdir -p build_gpu; cd build_gpu; cmake ..", "make", - "./array-transform gpu", + "ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./array-transform", "make clean" ] }, { "id": "gpu-aot", "steps": [ - "mkdir -p build_gpu_aot; cd build_gpu_aot; cmake .. -DDPCPP_COMPILE_TARGET=gen9,gen12LP", + "mkdir -p build_gpu_aot; cd build_gpu_aot; cmake .. -DSYCL_COMPILE_TARGET=gen9,gen12LP", "make", - "./array-transform gpu", + "ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./array-transform", "make clean" ] }, @@ -52,16 +52,16 @@ "steps": [ "mkdir -p build_acc; cd build_acc; cmake ..", "make", - "./array-transform accelerator", + "ONEAPI_DEVICE_SELECTOR=*:fpga ./array-transform", "make clean" ] }, { "id": "fpga-emu-aot", "steps": [ - "mkdir -p build_acc_aot; cd build_acc_aot; cmake .. -DDPCPP_COMPILE_TARGET=fpga-emu", + "mkdir -p build_acc_aot; cd build_acc_aot; cmake .. -DSYCL_COMPILE_TARGET=fpga-emu", "make", - "./array-transform accelerator", + "ONEAPI_DEVICE_SELECTOR=*:fpga ./array-transform", "make clean" ] } @@ -69,26 +69,35 @@ "windows": [ { "id": "cpu", + "env": [ + "set ONEAPI_DEVICE_SELECTOR=*:cpu" + ], "steps": [ "MSBuild array-transform.sln /t:Rebuild /p:Configuration=\"debug\"", "cd x64\\Debug", - "array-transform.exe cpu" + "array-transform.exe" ] }, { "id": "gpu", + "env": [ + "set ONEAPI_DEVICE_SELECTOR=level_zero:gpu" + ], "steps": [ "MSBuild array-transform.sln /t:Rebuild /p:Configuration=\"debug\"", "cd x64\\Debug", - "array-transform.exe gpu" + "array-transform.exe" ] }, { "id": "fpga-emu", + "env": [ + "set ONEAPI_DEVICE_SELECTOR=*:fpga" + ], "steps": [ "MSBuild array-transform.sln /t:Rebuild /p:Configuration=\"debug\"", "cd x64\\Debug", - "array-transform.exe accelerator" + "array-transform.exe" ] } ] diff --git a/Tools/ApplicationDebugger/array-transform/src/array-transform.cpp b/Tools/ApplicationDebugger/array-transform/src/array-transform.cpp index dc29300df1..4dd1bcdb59 100644 --- a/Tools/ApplicationDebugger/array-transform/src/array-transform.cpp +++ b/Tools/ApplicationDebugger/array-transform/src/array-transform.cpp @@ -14,7 +14,6 @@ #include // Location of file: /dev-utilities//include #include "dpc_common.hpp" -#include "selector.hpp" using namespace std; using namespace sycl; @@ -34,7 +33,7 @@ int main(int argc, char *argv[]) { input[i] = i + 100; try { - queue q(GetDevice(argc, argv), dpc_common::exception_handler); + queue q(default_selector_v, dpc_common::exception_handler); cout << "[SYCL] Using device: [" << q.get_device().get_info() << "] from [" diff --git a/Tools/ApplicationDebugger/array-transform/src/selector.hpp b/Tools/ApplicationDebugger/array-transform/src/selector.hpp deleted file mode 100644 index 607140a0c6..0000000000 --- a/Tools/ApplicationDebugger/array-transform/src/selector.hpp +++ /dev/null @@ -1,62 +0,0 @@ -//============================================================== -// Copyright (C) Intel Corporation -// -// SPDX-License-Identifier: MIT -// ============================================================= - -#include -#include - -// Custom device selector to select a device of the specified type. -// The platform of the device has to contain the phrase "Intel". If -// the platform or the type are not as expected, print an error -// and exit. - -using namespace std; -using namespace sycl; - -// Return the device type based on the program arguments. - -static info::device_type GetDeviceType(int argc, char* argv[]) { - if (argc < 2) { - cerr << "Usage: " << argv[0] << " " - << "\n"; - exit(1); - } - - string type_arg{argv[1]}; - info::device_type type; - - if (type_arg.compare("host") == 0) - type = info::device_type::host; - else if (type_arg.compare("cpu") == 0) - type = info::device_type::cpu; - else if (type_arg.compare("gpu") == 0) - type = info::device_type::gpu; - else if (type_arg.compare("accelerator") == 0) - type = info::device_type::accelerator; - else { - cerr << "fail; unrecognized device type '" << type_arg << "'\n"; - exit(-1); - } - - return type; -} - -// Return the device based on the program arguments. - -static device GetDevice(int argc, char* argv[]) { - info::device_type type = GetDeviceType(argc, argv); - vector devices = device::get_devices(type); - if (type == info::device_type::host) - return devices[0]; - - for (const device &dev : devices) { - string platform_name = dev.get_platform().get_info(); - - if (platform_name.find("Intel") != string::npos) - return dev; - } - cerr << "Device not found: " << argv[1] << "\n"; - exit(1); -} diff --git a/Tools/ApplicationDebugger/jacobi/CMakeLists.txt b/Tools/ApplicationDebugger/jacobi/CMakeLists.txt index d9c7accdec..01f7cccd92 100755 --- a/Tools/ApplicationDebugger/jacobi/CMakeLists.txt +++ b/Tools/ApplicationDebugger/jacobi/CMakeLists.txt @@ -56,4 +56,4 @@ add_custom_target(run-gpu ./${PROJECT_NAME_BUGGED} gpu add_custom_target(run-fpga-fixed ./${PROJECT_NAME_FIXED} accelerator DEPENDS ${PROJECT_NAME_FIXED}) add_custom_target(run-fpga ./${PROJECT_NAME_BUGGED} accelerator - DEPENDS ${PROJECT_NAME_BUGGED}) \ No newline at end of file + DEPENDS ${PROJECT_NAME_BUGGED}) diff --git a/Tools/ApplicationDebugger/jacobi/README.md b/Tools/ApplicationDebugger/jacobi/README.md index 806ff67727..22fbefe161 100755 --- a/Tools/ApplicationDebugger/jacobi/README.md +++ b/Tools/ApplicationDebugger/jacobi/README.md @@ -60,9 +60,9 @@ The sample is intended for exercising the debugger, not for performance benchmarking. The debugger supports debugging kernels that run on the CPU, GPU, or accelerator -devices. For convenience, the `jacobi` code sample provides the ability to -select the target device by using a command-line argument of `cpu`, `gpu`, or -`accelerator`. +devices. Use the ONEAPI_DEVICE_SELECTOR environment variable +to select device. The default device is Level Zero GPU device, if available. +For more details on possible values of this variable see [Environment Variables](https://intel.github.io/llvm-docs/EnvironmentVariables.html#oneapi-device-selector). For an overview of the Jacobi method, please refer to the Wikipedia article on the [Jacobi method](https://en.wikipedia.org/wiki/Jacobi_method). @@ -280,21 +280,19 @@ Perform the following steps: 2. Run the buggy program: ``` - $ ./jacobi-bugged + $ ./jacobi-bugged ``` - - > Note: `` is the type of the device to offload the kernel. - > Use `cpu`, `gpu`, or `accelerator` to select the CPU, GPU, or the - > FPGA emulator device, respectively. E.g.: - + > Note: to specify a device type to offload the kernel, use + > the `ONEAPI_DEVICE_SELECTOR` environment variable. + > E.g. to restrict the offload only to CPU devices use: ``` - $ ./jacobi-bugged cpu + $ ONEAPI_DEVICE_SELECTOR=*:cpu ./jacobi-bugged ``` -3. Start a debugging session: +3. Start a debugging session on a CPU device: ``` - $ gdb-oneapi --args jacobi-bugged + $ ONEAPI_DEVICE_SELECTOR=*:cpu gdb-oneapi jacobi-bugged ``` 4. Clean the program using: @@ -311,26 +309,12 @@ For instructions about starting and using the debugger, please see The selected device is displayed in the output. -#### No device specified - -If no device is specified both programs `jacobi-bugged` and `jacobi-fixed` return an error: - -``` -$ ./jacobi-bugged -Usage: ./jacobi-bugged -``` - -``` -$ ./jacobi-fixed -Usage: ./jacobi-fixed -``` - #### CPU When run, the original `jacobi-bugged` program shows the first bug: ``` -$ ./jacobi-bugged cpu +$ ONEAPI_DEVICE_SELECTOR=*:cpu ./jacobi-bugged [SYCL] Using device: [Intel(R) Core(TM) i7-7567U processor] from [Intel(R) OpenCL] Iteration 0, relative error = 2.71116 Iteration 20, relative error = 1.70922 @@ -345,7 +329,7 @@ Hint: figure out which elements are farthest from 1.0. Once the first bug is fixed, the second bug becomes visible: ``` -$ ./jacobi-bugged cpu +$ ONEAPI_DEVICE_SELECTOR=*:cpu ./jacobi-bugged [SYCL] Using device: [Intel(R) Core(TM) i7-7567U processor] from [Intel(R) OpenCL] Iteration 0, relative error = 2.71068 Iteration 20, relative error = 1.77663 @@ -371,7 +355,7 @@ Once this bug is fixed, while offloading to CPU you receive the correct result: which are the same as in `jacobi-fixed` for the offload to CPU device: ``` -$ ./jacobi-fixed cpu +$ ONEAPI_DEVICE_SELECTOR=*:cpu ./jacobi-fixed [SYCL] Using device: [Intel(R) Core(TM) i7-7567U processor] from [Intel(R) OpenCL] Iteration 0, relative error = 2.7581 Iteration 20, relative error = 0.119557 @@ -384,11 +368,15 @@ success; the relative error (9.97509e-05) is below the desired tolerance 0.0001 #### GPU Start debugging GPU only after first two bugs are fixed on CPU. +To debug on Intel GPU device, the device must be Level Zero. The Level +Zero GPU device, if available, is the default choice when no +`ONEAPI_DEVICE_SELECTOR` is specified. It corresponds to +`ONEAPI_DEVICE_SELECTOR=level_zero:gpu`. Bug 3 is immediately hit while offloading to GPU: ``` -$ ./jacobi-bugged gpu +$ ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./jacobi-bugged [SYCL] Using device: [Intel(R) Iris(R) Plus Graphics 650 [0x5927]] from [Intel(R) Level-Zero] fail; Bug 3. Fix it on GPU. The relative error has invalid value after iteration 0. @@ -406,7 +394,7 @@ Once all three bugs are fixed, the output of the program should be the same as for `jacobi-fixed` with the offload to GPU device: ``` -$ ./jacobi-fixed gpu +$ ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./jacobi-fixed [SYCL] Using device: [Intel(R) Iris(R) Plus Graphics 650 [0x5927]] from [Intel(R) Level-Zero] Iteration 0, relative error = 2.7581 Iteration 20, relative error = 0.119557 @@ -421,7 +409,7 @@ success; the relative error (9.97509e-05) is below the desired tolerance 0.0001 While offloading to FPGA emulation device, only first two bugs appear (similar to CPU): ``` -$ ./jacobi-bugged accelerator +$ ONEAPI_DEVICE_SELECTOR=*:fpga ./jacobi-bugged [SYCL] Using device: [Intel(R) FPGA Emulation Device] from [Intel(R) FPGA Emulation Platform for OpenCL(TM) software] Iteration 0, relative error = 2.71116 Iteration 20, relative error = 1.70922 @@ -436,7 +424,7 @@ Hint: figure out which elements are farthest from 1.0. And after fixing the first bug: ``` -$ ./jacobi-bugged accelerator +$ ONEAPI_DEVICE_SELECTOR=*:fpga ./jacobi-bugged [SYCL] Using device: [Intel(R) FPGA Emulation Device] from [Intel(R) FPGA Emulation Platform for OpenCL(TM) software] Iteration 0, relative error = 2.71068 Iteration 20, relative error = 1.77663 @@ -462,7 +450,7 @@ After both bugs are fixed, the output of `jacobi-bugged` should become the same `jacobi-fixed`: ``` -$ ./jacobi-fixed accelerator +$ ONEAPI_DEVICE_SELECTOR=*:fpga ./jacobi-fixed [SYCL] Using device: [Intel(R) FPGA Emulation Device] from [Intel(R) FPGA Emulation Platform for OpenCL(TM) software] Iteration 0, relative error = 2.7581 Iteration 20, relative error = 0.119557 diff --git a/Tools/ApplicationDebugger/jacobi/sample.json b/Tools/ApplicationDebugger/jacobi/sample.json index a1c6687aae..78a909a2b0 100755 --- a/Tools/ApplicationDebugger/jacobi/sample.json +++ b/Tools/ApplicationDebugger/jacobi/sample.json @@ -2,8 +2,8 @@ "guid": "CFAC8EF8-E362-4054-ABE3-A04EEBEBCB46", "name": "Jacobi", "categories": ["Toolkit/oneAPI Tools/Application Debugger"], - "description": "A small Data Parallel C++ (DPC++) example which solves a harcoded linear system with Jacobi iteration. The sample includes two versions of the same program: with and without bugs.", - "toolchain": ["dpcpp"], + "description": "A small SYCL (C++) example which solves a harcoded linear system with Jacobi iteration. The sample includes two versions of the same program: with and without bugs.", + "toolchain": ["icpx"], "dependencies": ["debugger"], "languages": [{"cpp":{}}], "targetDevice": ["CPU", "GPU"], @@ -16,7 +16,7 @@ "steps": [ "mkdir -p build_cpu_bugged; cd build_cpu_bugged; cmake ..", "make", - "./jacobi-bugged cpu", + "ONEAPI_DEVICE_SELECTOR=*:cpu ./jacobi-bugged", "make clean" ] }, @@ -25,7 +25,7 @@ "steps": [ "mkdir -p build_gpu_bugged; cd build_gpu_bugged; cmake ..", "make", - "./jacobi-bugged gpu", + "ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./jacobi-bugged", "make clean" ] }, @@ -34,7 +34,7 @@ "steps": [ "mkdir -p build_acc_bugged; cd build_acc_bugged; cmake ..", "make", - "./jacobi-bugged accelerator", + "ONEAPI_DEVICE_SELECTOR=*:fpga ./jacobi-bugged", "make clean" ] }, @@ -43,7 +43,7 @@ "steps": [ "mkdir -p build_cpu_fixed; cd build_cpu_fixed; cmake ..", "make", - "./jacobi-fixed cpu", + "ONEAPI_DEVICE_SELECTOR=*:cpu ./jacobi-fixed", "make clean" ] }, @@ -52,7 +52,7 @@ "steps": [ "mkdir -p build_gpu_fixed; cd build_gpu_fixed; cmake ..", "make", - "./jacobi-fixed gpu", + "ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./jacobi-fixed", "make clean" ] }, @@ -61,7 +61,7 @@ "steps": [ "mkdir -p build_acc_fixed; cd build_acc_fixed; cmake ..", "make", - "./jacobi-fixed accelerator", + "ONEAPI_DEVICE_SELECTOR=*:fpga ./jacobi-fixed", "make clean" ] } @@ -69,50 +69,68 @@ "windows": [ { "id": "cpu-bugged", + "env": [ + "set ONEAPI_DEVICE_SELECTOR=*:cpu" + ], "steps": [ "MSBuild jacobi.sln /t:Rebuild /p:Configuration=\"debug\"", "cd x64\\Debug", - "jacobi-bugged.exe cpu" + "jacobi-bugged.exe" ] }, { "id": "gpu-bugged", + "env": [ + "set ONEAPI_DEVICE_SELECTOR=level_zero:gpu" + ], "steps": [ "MSBuild jacobi.sln /t:Rebuild /p:Configuration=\"debug\"", "cd x64\\Debug", - "jacobi-bugged.exe gpu" + "jacobi-bugged.exe" ] }, { "id": "fpga-emu-bugged", + "env": [ + "set ONEAPI_DEVICE_SELECTOR=*:fpga" + ], "steps": [ "MSBuild jacobi.sln /t:Rebuild /p:Configuration=\"debug\"", "cd x64\\Debug", - "jacobi-bugged.exe accelerator" + "jacobi-bugged.exe" ] }, { "id": "cpu-fixed", + "env": [ + "set ONEAPI_DEVICE_SELECTOR=*:cpu" + ], "steps": [ "MSBuild jacobi.sln /t:Rebuild /p:Configuration=\"debug\"", "cd x64\\Debug", - "jacobi-fixed.exe cpu" + "jacobi-fixed.exe" ] }, { "id": "gpu-fixed", + "env": [ + "set ONEAPI_DEVICE_SELECTOR=level_zero:gpu" + ], "steps": [ "MSBuild jacobi.sln /t:Rebuild /p:Configuration=\"debug\"", "cd x64\\Debug", - "jacobi-fixed.exe gpu" + "jacobi-fixed.exe" ] }, { "id": "fpga-emu-fixed", + "env": [ + "set ONEAPI_DEVICE_SELECTOR=*:fpga" + ], "steps": [ "MSBuild jacobi.sln /t:Rebuild /p:Configuration=\"debug\"", "cd x64\\Debug", - "jacobi-fixed.exe accelerator" + "jacobi-fixed.exe" ] } ] diff --git a/Tools/ApplicationDebugger/jacobi/src/jacobi-bugged.cpp b/Tools/ApplicationDebugger/jacobi/src/jacobi-bugged.cpp index e8ecf6c1bb..1ef8ca9741 100644 --- a/Tools/ApplicationDebugger/jacobi/src/jacobi-bugged.cpp +++ b/Tools/ApplicationDebugger/jacobi/src/jacobi-bugged.cpp @@ -15,7 +15,6 @@ #include // Location of file: /dev-utilities//include #include "dpc_common.hpp" -#include "selector.hpp" using namespace std; using namespace sycl; @@ -194,7 +193,7 @@ int main(int argc, char *argv[]) { // Iteration counter. int k = 0; try { - queue q(GetDevice(argc, argv), dpc_common::exception_handler); + queue q(default_selector_v, dpc_common::exception_handler); cout << "[SYCL] Using device: [" << q.get_device().get_info() << "] from [" << q.get_device().get_platform().get_info() diff --git a/Tools/ApplicationDebugger/jacobi/src/jacobi-fixed.cpp b/Tools/ApplicationDebugger/jacobi/src/jacobi-fixed.cpp index 2eb1a53a47..255b5df2a0 100644 --- a/Tools/ApplicationDebugger/jacobi/src/jacobi-fixed.cpp +++ b/Tools/ApplicationDebugger/jacobi/src/jacobi-fixed.cpp @@ -15,7 +15,6 @@ #include // Location of file: /dev-utilities//include #include "dpc_common.hpp" -#include "selector.hpp" using namespace std; using namespace sycl; @@ -202,7 +201,7 @@ int main(int argc, char *argv[]) { // Iteration counter. int k = 0; try { - queue q(GetDevice(argc, argv), dpc_common::exception_handler); + queue q(default_selector_v, dpc_common::exception_handler); cout << "[SYCL] Using device: [" << q.get_device().get_info() << "] from [" << q.get_device().get_platform().get_info() diff --git a/Tools/ApplicationDebugger/jacobi/src/selector.hpp b/Tools/ApplicationDebugger/jacobi/src/selector.hpp deleted file mode 100755 index 607140a0c6..0000000000 --- a/Tools/ApplicationDebugger/jacobi/src/selector.hpp +++ /dev/null @@ -1,62 +0,0 @@ -//============================================================== -// Copyright (C) Intel Corporation -// -// SPDX-License-Identifier: MIT -// ============================================================= - -#include -#include - -// Custom device selector to select a device of the specified type. -// The platform of the device has to contain the phrase "Intel". If -// the platform or the type are not as expected, print an error -// and exit. - -using namespace std; -using namespace sycl; - -// Return the device type based on the program arguments. - -static info::device_type GetDeviceType(int argc, char* argv[]) { - if (argc < 2) { - cerr << "Usage: " << argv[0] << " " - << "\n"; - exit(1); - } - - string type_arg{argv[1]}; - info::device_type type; - - if (type_arg.compare("host") == 0) - type = info::device_type::host; - else if (type_arg.compare("cpu") == 0) - type = info::device_type::cpu; - else if (type_arg.compare("gpu") == 0) - type = info::device_type::gpu; - else if (type_arg.compare("accelerator") == 0) - type = info::device_type::accelerator; - else { - cerr << "fail; unrecognized device type '" << type_arg << "'\n"; - exit(-1); - } - - return type; -} - -// Return the device based on the program arguments. - -static device GetDevice(int argc, char* argv[]) { - info::device_type type = GetDeviceType(argc, argv); - vector devices = device::get_devices(type); - if (type == info::device_type::host) - return devices[0]; - - for (const device &dev : devices) { - string platform_name = dev.get_platform().get_info(); - - if (platform_name.find("Intel") != string::npos) - return dev; - } - cerr << "Device not found: " << argv[1] << "\n"; - exit(1); -}