examples/sycl/tbb-resumable-tasks-sycl/README.md
tbb-resumable-tasks-sycl SampleThe tbb-resumable-tasks-sycl sample illustrates how the computational kernel can be split for execution between CPU and GPU using Intel® oneAPI Threading Building Blocks (oneTBB) resumable task and parallel_for. The TBB resumable task uses SYCL* to implement GPU calculations, while the parallel_for algorithm does the CPU part of calculations. This tbb-resumable-tasks-sycl sample code is implemented using C++ and SYCL* for CPU and GPU.
| Optimized for | Description |
|---|---|
| OS | Linux* Ubuntu* 18.04 |
| Windows* 10, 11 | |
| Hardware | Skylake with GEN9 or newer |
| Software | Intel® oneAPI DPC++ Compiler |
| What you will learn | How to offload the computation to GPU using Intel® oneAPI DPC++ Compiler |
| Time to complete | 15 minutes |
The purpose of this sample is to show how during execution, a computational kernel can be split between CPU and GPU using TBB resumable tasks and TBB parallel_for.
TBB resumable tasks in SYCL* explained.
When working with the Command Line Interface (CLI), you should configure the Intel® oneAPI Toolkit using environment variables. Set up your CLI environment by sourcing the setvars script every time you open a new terminal window. This practice ensures your compiler, libraries, and tools are ready for development.
Note: If you have not already done so, set up your CLI environment by sourcing the
setvarsscript located in the root of your oneAPI installation.Linux*:
- For system wide installations:
. /opt/intel/oneapi/setvars.sh- For private installations:
. ~/intel/oneapi/setvars.sh- For non-POSIX* shells, like csh, use the following command:
$ bash -c 'source <install-dir>/setvars.sh ; exec csh'Windows*:
C:\"Program Files (x86)"\Intel\oneAPI\setvars.bat- For Windows PowerShell*, use the following command:
cmd.exe "/K" '"C:\Program Files (x86)\Intel\oneAPI\setvars.bat" && powershell'Microsoft Visual Studio*:
- Open a command prompt window and execute
setx SETVARS_CONFIG " ". This only needs to be set once and will automatically execute thesetvarsscript every time Visual Studio is launched.For more information on environment variables, see "Use the setvars Script" for Linux or macOS, or Windows.
You can use Modulefiles scripts to set up your development environment. The modulefiles scripts work with all Linux shells.
If you wish to fine tune the list of components and the version of those components, use a setvars config file to set up your development environment.
You can use Visual Studio Code (VS Code*) extensions to set your environment, create launch configurations, and browse and download samples.
The basic steps to build and run a sample using VS Code include:
To learn more about the extensions and how to configure the oneAPI environment, see the Using Visual Studio Code* to Develop Intel® oneAPI Applications.
* Build tbb-resumable-tasks-sycl program
cd tbb-resumable-tasks-sycl &&
mkdir build &&
cd build &&
cmake .. && make VERBOSE=1
* Run the program
make run
* Clean the program
make clean
None
start index for GPU = 0; end index for GPU = 8
start index for CPU = 8; end index for CPU = 16
Heterogeneous triad correct.
c_array: 0 1.5 3 4.5 6 7.5 9 10.5 12 13.5 15 16.5 18 19.5 21 22.5
c_gold : 0 1.5 3 4.5 6 7.5 9 10.5 12 13.5 15 16.5 18 19.5 21 22.5
Built target run
If an error occurs, troubleshoot the problem using the Diagnostics Utility for oneAPI. Learn more.