This repository accompanies Data Parallel C++: Mastering DPC++ for Programming of Heterogeneous Systems using C++ and SYCL by James Reinders, Ben Ashbaugh, James Brodman, Michael Kinsner, John Pennycook, Xinmin Tian (Apress, 2020).
Many of the samples in the book are snips from the more complete files in this repository. The full files contain supporting code, such as header inclusions, which are not shown in every listing within the book. The complete listings are intended to compile and be modifiable for experimentation.
⚠️ Samples in this repository are updated to align with the most recent changes to the language and toolchains, and are more current than captured in the book text due to lag between finalization and actual publication of a print book. If experimenting with the code samples, start with the versions in this repository. DPC++ and SYCL are evolving to be more powerful and easier to use, and updates to the sample code in this repository are a good sign of forward progress!
Download the files as a zip using the green button, or clone the repository to your machine using Git.
Optimized for | Description |
---|---|
OS | Linux* Ubuntu* 18.04; Windows 10 |
Hardware | Skylake with GEN9 or newer |
Software | Intel® oneAPI DPC++/C++ Compiler |
Example: The code will attempt to execute on an available GPU and fall back to the system's CPU if a compatible GPU is not detected. The compilation device is displayed in the output along with elapsed time to render the Mandelbrot image. This helps compare different offload implementations based on the complexity of the computation.
Code samples are licensed under the MIT license. See License.txt for details.
Third-party program Licenses can be found here: third-party-programs.txt
⚠️ The samples in this repository are intended to compile with the open source project toolchain linked below, or with the 2021.1 release or newer of the DPC++ toolchain. If you have an older toolchain installed, you may encounter compilation errors due to evolution of the features and extensions.
To build and use these examples, you will need and install a DPC++ toolkit -Intel® oneAPI Base Toolkit -Intel® oneAPI HPC Toolkit -Intel® oneAPI IoT Toolkit
Alternatively, much of the toolchain can be built directly from:
Some of the Chapter 18 examples require an installation of oneDPL, which is available from:
The include folder is located at %ONEAPI_ROOT%\dev-utilities\latest\include on your development system.
Example: If running a sample in the Intel DevCloud, remember that you must specify the compute node (CPU, GPU, FPGA) and whether to run in batch or interactive mode. For more information, see the Intel® oneAPI Base Toolkit Get Started Guide (https://devcloud.intel.com/oneapi/get-started/base-toolkit/)- Setup oneAPI environment variables:
Linux Sudo: . /opt/intel/oneapi/setvars.sh
Linux User: . ~/intel/oneapi/setvars.sh
```sh
source path/to/intel/oneapi/setvars.sh
```
-
Linux: Create build files using CMake. For example, to generate build files using
make
:mkdir build && cd build cmake -G "Unix Makefiles" ..
NOTE: If you do not have oneDPL installed, you can disable compilation of those tests with the option
NODPL
cmake -G "Unix Makefiles" -DNODPL=1 ..
Build with the generated build files:
make
-
Setup oneAPI environment variables:
Windows: C:\Program Files(x86)\Intel\oneAPI\setvars.bat This will need to be run each time you open a new cmd window(non Persistent)
- Aternatively you can search for the oneAPI cmd prompt - startmenu> look for
Intel oneAPI 202*
> "Intel oneAPI command prompt for Intel 64 for Visual Studio 2017"
On Windows:
path\to\Intel\oneAPI\setvars.bat
- Aternatively you can search for the oneAPI cmd prompt - startmenu> look for
-
Windows: Create build files using CMake, specifying the DPC++ toolchain. For example, to generate build files using
ninja
:mkdir build && cd build cmake -G "Ninja" ..
NOTE: If you do not have oneDPL installed, you can disable compilation of those tests with the option
NODPL
cmake -G "Ninja" -DNODPL=1 ..
Build with the generated build files:
ninja install