Skip to content

Commit cc43f12

Browse files
committed
ApplicationDebugger: rely on ONEAPI_DEVICE_SELECTOR to select device.
Affected samples: array-transform, jacobi. Remove the custom selector.hpp files. Update README to use ONEAPI_DEVICE_SELECTOR instead of arguments. Update sample.json files. Signed-off-by: Natalia Saiapova <[email protected]>
1 parent b0c2f81 commit cc43f12

12 files changed

+119
-238
lines changed

Tools/ApplicationDebugger/array-transform/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,4 @@ add_custom_target(run-gpu ./${PROJECT_NAME} gpu
5959
DEPENDS ${PROJECT_NAME})
6060

6161
add_custom_target(run-fpga ./${PROJECT_NAME} accelerator
62-
DEPENDS ${PROJECT_NAME})
62+
DEPENDS ${PROJECT_NAME})

Tools/ApplicationDebugger/array-transform/README.md

+35-41
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ scheduler-locking and SIMD lane views. The sample is intended
2424
for exercising the debugger, not for performance benchmarking.
2525

2626
The debugger supports debugging kernels that run on the CPU, GPU, or
27-
accelerator devices. For convenience, the `array-transform`
28-
code sample provides the ability to select the target device by passing the
29-
program `cpu`, `gpu`, or `accelerator` as the command-line argument.
27+
accelerator devices. Use the ONEAPI_DEVICE_SELECTOR environment variable
28+
to select device. The default device is Level Zero GPU device, if available.
29+
For more details on possible values of this variable see [Environment Variables](https://intel.github.io/llvm-docs/EnvironmentVariables.html#oneapi-device-selector).
3030
The selected device is displayed in the output. Concrete instructions
3131
about how to run the program and example outputs are given further
3232
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:
143143
144144
2. Run the program:
145145
```
146-
$ ./array-transform <device>
146+
$ ./array-transform
147147
```
148-
> Note: `<device>` is the type of the device type to offload the kernel.
149-
> Use `cpu`, `gpu`, or `accelerator` to select the CPU, GPU, or the
150-
> FPGA emulator device, respectively. E.g.:
148+
> Note: to specify a device type to offload the kernel, use
149+
> the `ONEAPI_DEVICE_SELECTOR` environment variable.
150+
> E.g. to restrict the offload only to CPU devices use:
151151
```
152-
$ ./array-transform cpu
152+
$ ONEAPI_DEVICE_SELECTOR=*:cpu ./array-transform
153153
```
154154
155155
3. Start a debugging session:
156156
```
157-
$ gdb-oneapi --args array-transform <device>
157+
$ gdb-oneapi array-transform
158158
```
159159
160160
4. Clean the program using:
@@ -165,14 +165,12 @@ Perform the following steps:
165165
By default, CMake configures the build for Just-in-Time (JIT)
166166
compilation of the kernel. However, it also offers an option for
167167
*Ahead-of-Time* (AoT) compilation. To compile the kernel
168-
ahead-of-time for a specific device, set the `DPCPP_COMPILE_TARGET`
168+
ahead-of-time for a specific device, set the `SYCL_COMPILE_TARGET`
169169
option to the desired device during configuration. For CPU, use the
170170
`cpu` value; for FPGA-emu, use the `fpga-emu` value. Other values are
171171
assumed to be for GPU and are passed directly to the GPU AoT
172172
compiler.
173173
174-
> *Hint:* Run `ocloc compile --help` to see available GPU device options.
175-
176174
For example, to do AoT compilation for a specific GPU device ID:
177175
178176
```
@@ -191,6 +189,8 @@ $ sycl-ls
191189
192190
In the above example, the device ID is `0x56c1`.
193191
192+
> *Hint:* Run `ocloc compile --help` to see all available GPU device options.
193+
194194
> **Note**: AoT compilation is particularly helpful in larger
195195
> applications where compiling with debug information takes
196196
> considerably longer time.
@@ -223,11 +223,11 @@ dependencies and permissions errors.
223223
224224
3. Select Menu "Debug > Start Debugging" to run the program.
225225
226-
4. The solution file is configured to pass `cpu` as the argument to the
227-
program. To select a different device, go to the project's "Configuration
228-
Properties > Debugging" and set the "Command Arguments" field.
229-
Use `gpu` or `accelerator` to target the GPU or the FPGA emulator device,
230-
respectively.
226+
4. The solution file is configured to set `ONEAPI_DEVICE_SELECTOR=*:cpu`
227+
for Local Windows Debugging. That setting causes the program to offload
228+
on a CPU device. To select a different device, go to the project's
229+
"Configuration Properties > Debugging" and edit the "Environment" field.
230+
Modify the value of `ONEAPI_DEVICE_SELECTOR` as you need.
231231
232232
For detailed instructions about starting and using the debugger,
233233
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](
236236
### Example Outputs
237237
238238
```
239-
$ gdb-oneapi -q --args ./array-transform cpu
239+
$ ONEAPI_DEVICE_SELECTOR=*:cpu gdb-oneapi -q ./array-transform
240240
Reading symbols from ./array-transform...
241-
(gdb) break 56
242-
Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 56.
241+
(gdb) break 54
242+
Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 54.
243243
(gdb) run
244244
...<snip>...
245245
[SYCL] Using device: [Intel(R) Core(TM) i9-7900X processor] from [Intel(R) OpenCL]
246246
[Switching to Thread 0x7fffe3bfe700 (LWP 925)]
247247

248-
Thread 16 "array-transform" hit Breakpoint 1, main::$_1::operator()<cl::sycl::handler>
249-
(cl::sycl::handler&) const::{lambda(auto:1)#1}::operator()<cl::sycl::item<1, true> >
250-
(cl::sycl::item<1, true>) const (this=0x7fffe3bfcfa8, index=...) at array-transform.cpp:56
251-
56 int element = in[index]; // breakpoint-here
248+
Thread 4 "array-transform" hit Breakpoint 1, main::{lambda(auto:1&)#1}::operator()<sycl::_V1::handler>(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
249+
54 int element = in[index]; // breakpoint-here
252250
(gdb)
253251
```
254252
255253
```
256-
$ gdb-oneapi -q --args ./array-transform accelerator
254+
$ ONEAPI_DEVICE_SELECTOR=*:fpga gdb-oneapi -q ./array-transform
257255
Reading symbols from ./array-transform...
258-
(gdb) break 56
259-
Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 56.
256+
(gdb) break 54
257+
Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 54.
260258
(gdb) run
261259
...<snip>...
262260
[SYCL] Using device: [Intel(R) FPGA Emulation Device] from [Intel(R) FPGA Emulation Platform for OpenCL(TM) software]
263261
[Switching to Thread 0x7fffe1ffb700 (LWP 2387)]
264262

265-
Thread 9 "array-transform" hit Breakpoint 1, main::$_1::operator()<cl::sycl::handler>
266-
(cl::sycl::handler&) const::{lambda(auto:1)#1}::operator()<cl::sycl::item<1, true> >
267-
(cl::sycl::item<1, true>) const (this=0x7fffe1ff9fa8, index=...) at array-transform.cpp:56
268-
56 int element = in[index]; // breakpoint-here
263+
Thread 6 "array-transform" hit Breakpoint 1, main::{lambda(auto:1&)#1}::operator()<sycl::_V1::handler>(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
264+
54 int element = in[index]; // breakpoint-here
269265
(gdb)
270266
```
271267
272268
```
273-
$ gdb-oneapi -q --args ./array-transform gpu
269+
$ ONEAPI_DEVICE_SELECTOR=level_zero:gpu gdb-oneapi -q ./array-transform
274270
Reading symbols from ./array-transform...
275-
(gdb) break 56
276-
Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 56.
271+
(gdb) break 54
272+
Breakpoint 1 at 0x4057b7: file array-transform.cpp, line 54.
277273
(gdb) run
278274
...<snip>...
279-
[SYCL] Using device: [Intel(R) Iris(R) Plus Graphics 650 [0x5927]] from [Intel(R) Level-Zero]
275+
intelgt: gdbserver-ze started for process 18496.
280276
...<snip>...
281-
[Switching to Thread 1073741824 lane 0]
277+
[SYCL] Using device: [Intel(R) Data Center GPU Flex Series 140 [0x56c1]] from [Intel(R) Level-Zero]
278+
[Switching to Thread 1.153 lane 0]
282279

283-
Thread 2.2 hit Breakpoint 1, with SIMD lanes [0-7], main::$_1::operator()
284-
<cl::sycl::handler>(cl::sycl::handler&) const::{lambda(auto:1)#1}::operator()
285-
<cl::sycl::item<1, true> >(cl::sycl::item<1, true>) const (this=0x2f690c0, index=...)
286-
at array-transform.cpp:56
287-
56 int element = in[index]; // breakpoint-here
280+
Thread 2.153 hit Breakpoint 1, with SIMD lanes [0-7], main::{lambda(auto:1&)#1}::operator()<sycl::_V1::handler>(sycl::_V1::handler&) const::{lambda(sycl::_V1::id<1>)#1}::operator()(sycl::_V1::id<1>) const (this=0xffffd556ab1898d0, index=...) at array-transform.cpp:54
281+
54 int element = in[index]; // breakpoint-here
288282
(gdb)
289283
```
290284
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
4-
<LocalDebuggerEnvironment>CL_CONFIG_USE_NATIVE_DEBUGGER=1</LocalDebuggerEnvironment>
4+
<LocalDebuggerEnvironment>ONEAPI_DEVICE_SELECTOR=*:cpu</LocalDebuggerEnvironment>
55
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
6-
<LocalDebuggerCommandArguments>cpu</LocalDebuggerCommandArguments>
76
</PropertyGroup>
87
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
9-
<LocalDebuggerCommandArguments>cpu</LocalDebuggerCommandArguments>
8+
<LocalDebuggerEnvironment>ONEAPI_DEVICE_SELECTOR=*:cpu</LocalDebuggerEnvironment>
109
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
1110
</PropertyGroup>
1211
</Project>

Tools/ApplicationDebugger/array-transform/sample.json

+23-14
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"guid": "4B3FDDD8-64CF-4CF3-9387-26E34F021E24",
33
"name": "Debugger: Array Transform",
44
"categories": ["Toolkit/Get Started", "Toolkit/oneAPI Tools/Application Debugger"],
5-
"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",
6-
"toolchain": ["dpcpp"],
5+
"description": "A small SYCL (C++) example that is used in the \"Get Started Guide\" of the Application Debugger to exercise major debugger functionality",
6+
"toolchain": ["icpx"],
77
"dependencies": ["debugger"],
88
"languages": [{"cpp":{}}],
99
"targetDevice": ["CPU", "GPU"],
@@ -16,16 +16,16 @@
1616
"steps": [
1717
"mkdir -p build_cpu; cd build_cpu; cmake ..",
1818
"make",
19-
"./array-transform cpu",
19+
"ONEAPI_DEVICE_SELECTOR=*:cpu ./array-transform",
2020
"make clean"
2121
]
2222
},
2323
{
2424
"id": "cpu-aot",
2525
"steps": [
26-
"mkdir -p build_cpu_aot; cd build_cpu_aot; cmake .. -DDPCPP_COMPILE_TARGET=cpu",
26+
"mkdir -p build_cpu_aot; cd build_cpu_aot; cmake .. -DSYCL_COMPILE_TARGET=cpu",
2727
"make",
28-
"./array-transform cpu",
28+
"ONEAPI_DEVICE_SELECTOR=*:cpu ./array-transform",
2929
"make clean"
3030
]
3131
},
@@ -34,16 +34,16 @@
3434
"steps": [
3535
"mkdir -p build_gpu; cd build_gpu; cmake ..",
3636
"make",
37-
"./array-transform gpu",
37+
"ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./array-transform",
3838
"make clean"
3939
]
4040
},
4141
{
4242
"id": "gpu-aot",
4343
"steps": [
44-
"mkdir -p build_gpu_aot; cd build_gpu_aot; cmake .. -DDPCPP_COMPILE_TARGET=gen9,gen12LP",
44+
"mkdir -p build_gpu_aot; cd build_gpu_aot; cmake .. -DSYCL_COMPILE_TARGET=gen9,gen12LP",
4545
"make",
46-
"./array-transform gpu",
46+
"ONEAPI_DEVICE_SELECTOR=level_zero:gpu ./array-transform",
4747
"make clean"
4848
]
4949
},
@@ -52,43 +52,52 @@
5252
"steps": [
5353
"mkdir -p build_acc; cd build_acc; cmake ..",
5454
"make",
55-
"./array-transform accelerator",
55+
"ONEAPI_DEVICE_SELECTOR=*:fpga ./array-transform",
5656
"make clean"
5757
]
5858
},
5959
{
6060
"id": "fpga-emu-aot",
6161
"steps": [
62-
"mkdir -p build_acc_aot; cd build_acc_aot; cmake .. -DDPCPP_COMPILE_TARGET=fpga-emu",
62+
"mkdir -p build_acc_aot; cd build_acc_aot; cmake .. -DSYCL_COMPILE_TARGET=fpga-emu",
6363
"make",
64-
"./array-transform accelerator",
64+
"ONEAPI_DEVICE_SELECTOR=*:fpga ./array-transform",
6565
"make clean"
6666
]
6767
}
6868
],
6969
"windows": [
7070
{
7171
"id": "cpu",
72+
"env": [
73+
"set ONEAPI_DEVICE_SELECTOR=*:cpu"
74+
],
7275
"steps": [
7376
"MSBuild array-transform.sln /t:Rebuild /p:Configuration=\"debug\"",
7477
"cd x64\\Debug",
75-
"array-transform.exe cpu"
78+
"array-transform.exe"
7679
]
7780
},
7881
{
7982
"id": "gpu",
83+
"env": [
84+
"set ONEAPI_DEVICE_SELECTOR=level_zero:gpu"
85+
],
8086
"steps": [
8187
"MSBuild array-transform.sln /t:Rebuild /p:Configuration=\"debug\"",
8288
"cd x64\\Debug",
83-
"array-transform.exe gpu"
89+
"array-transform.exe"
8490
]
8591
},
8692
{
8793
"id": "fpga-emu",
94+
"env": [
95+
"set ONEAPI_DEVICE_SELECTOR=*:fpga"
96+
],
8897
"steps": [
8998
"MSBuild array-transform.sln /t:Rebuild /p:Configuration=\"debug\"",
9099
"cd x64\\Debug",
91-
"array-transform.exe accelerator"
100+
"array-transform.exe"
92101
]
93102
}
94103
]

Tools/ApplicationDebugger/array-transform/src/array-transform.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <iostream>
1515
// Location of file: <oneapi-root>/dev-utilities/<version>/include
1616
#include "dpc_common.hpp"
17-
#include "selector.hpp"
1817

1918
using namespace std;
2019
using namespace sycl;
@@ -34,7 +33,7 @@ int main(int argc, char *argv[]) {
3433
input[i] = i + 100;
3534

3635
try {
37-
queue q(GetDevice(argc, argv), dpc_common::exception_handler);
36+
queue q(default_selector_v, dpc_common::exception_handler);
3837
cout << "[SYCL] Using device: ["
3938
<< q.get_device().get_info<info::device::name>()
4039
<< "] from ["

Tools/ApplicationDebugger/array-transform/src/selector.hpp

-62
This file was deleted.

Tools/ApplicationDebugger/jacobi/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,4 @@ add_custom_target(run-gpu ./${PROJECT_NAME_BUGGED} gpu
5656
add_custom_target(run-fpga-fixed ./${PROJECT_NAME_FIXED} accelerator
5757
DEPENDS ${PROJECT_NAME_FIXED})
5858
add_custom_target(run-fpga ./${PROJECT_NAME_BUGGED} accelerator
59-
DEPENDS ${PROJECT_NAME_BUGGED})
59+
DEPENDS ${PROJECT_NAME_BUGGED})

0 commit comments

Comments
 (0)