Skip to content

Application Debugger samples 2023.1 update #1387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Tools/ApplicationDebugger/array-transform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
DEPENDS ${PROJECT_NAME})
76 changes: 35 additions & 41 deletions Tools/ApplicationDebugger/array-transform/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -143,18 +143,18 @@ Perform the following steps:

2. Run the program:
```
$ ./array-transform <device>
$ ./array-transform
```
> Note: `<device>` 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 <device>
$ gdb-oneapi array-transform
```

4. Clean the program using:
Expand All @@ -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:

```
Expand All @@ -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.
Expand Down Expand Up @@ -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/).
Expand All @@ -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
...<snip>...
[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>
(cl::sycl::handler&) const::{lambda(auto:1)#1}::operator()<cl::sycl::item<1, true> >
(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>(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
...<snip>...
[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>
(cl::sycl::handler&) const::{lambda(auto:1)#1}::operator()<cl::sycl::item<1, true> >
(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>(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
...<snip>...
[SYCL] Using device: [Intel(R) Iris(R) Plus Graphics 650 [0x5927]] from [Intel(R) Level-Zero]
intelgt: gdbserver-ze started for process 18496.
...<snip>...
[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>(cl::sycl::handler&) const::{lambda(auto:1)#1}::operator()
<cl::sycl::item<1, true> >(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>(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)
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerEnvironment>CL_CONFIG_USE_NATIVE_DEBUGGER=1</LocalDebuggerEnvironment>
<LocalDebuggerEnvironment>ONEAPI_DEVICE_SELECTOR=*:cpu</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>cpu</LocalDebuggerCommandArguments>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommandArguments>cpu</LocalDebuggerCommandArguments>
<LocalDebuggerEnvironment>ONEAPI_DEVICE_SELECTOR=*:cpu</LocalDebuggerEnvironment>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>
37 changes: 23 additions & 14 deletions Tools/ApplicationDebugger/array-transform/sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand All @@ -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"
]
},
Expand All @@ -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"
]
},
Expand All @@ -52,43 +52,52 @@
"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"
]
}
],
"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"
]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <iostream>
// Location of file: <oneapi-root>/dev-utilities/<version>/include
#include "dpc_common.hpp"
#include "selector.hpp"

using namespace std;
using namespace sycl;
Expand All @@ -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<info::device::name>()
<< "] from ["
Expand Down
62 changes: 0 additions & 62 deletions Tools/ApplicationDebugger/array-transform/src/selector.hpp

This file was deleted.

2 changes: 1 addition & 1 deletion Tools/ApplicationDebugger/jacobi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
DEPENDS ${PROJECT_NAME_BUGGED})
Loading