The Intel® oneAPI DPC++/C++ Compiler provides optimizations that help your applications to run faster on Intel® 64 and IA-32 (Windows* and Linux* only) architectures, with support for the latest C, C++, and DPC++ language standards (including C++17). This compiler produces optimized code that can run significantly faster by taking advantage of the ever-increasing core count and vector register width in Intel® Xeon® processors and compatible processors. The Intel® Compiler will help you boost application performance through superior optimizations and Single Instruction Multiple Data (SIMD) vectorization, integration with Intel® Performance Libraries, and by leveraging the latest OpenMP* 5.0 parallel programming model.
The Intel® oneAPI DPC++/C++ Compiler compiles C++-based SYCL* source files for a wide range of compute accelerators.
The Intel® oneAPI DPC++/C++ Compiler is part of the Intel® oneAPI Toolkits.
Windows*
The compiler integrates into the following versions of Microsoft Visual Studio*:
For full functionality within Visual Studio, including debugging and development, Visual Studio* Community Edition or higher is required. Visual Studio* Express Edition allows only command-line builds. For all versions, Microsoft C++ support must be selected as part of the Visual Studio install. For Visual Studio* 2015 and later, you must use a custom install to select this option.
You typically do not need to set the environment variables on Windows*, as the compiler command-line window sets these variables for you automatically. If you need to set the environment variables, run the environment script as described in the suite-specific Get Started documentation.
<install_dir> is the installation directory. By default, it is C:\Program Files (x86)\IntelSWTools.
Linux*
Before you can use the compiler, you must first set the environment variables by sourcing the environment script using the initialization utility to initialize all the tools in one step:
Use the steps below to compile and execute SYCL code.
#include <CL/sycl.hpp>
int main() {
// Creating SYCL queue
cl::sycl::queue Queue;
// Creating buffer of 4 ints
cl::sycl::buffer<cl::sycl::cl_int, 1> Buffer(4);
// Size of index space for kernel
cl::sycl::range<1> NumOfWorkItems{Buffer.get_count()};
// Submitting command group to queue
Queue.submit([&](cl::sycl::handler &cgh) {
// Getting write only access to the buffer on a device
auto Accessor = Buffer.get_access<cl::sycl::access::mode::write>(cgh);
// Executing kernel
cgh.parallel_for<class FillBuffer>(
NumOfWorkItems, [=](cl::sycl::id<1> WIid) {
// Fill buffer with indexes
Accessor[WIid] = (cl::sycl::cl_int)WIid.get(0);
});
});
// Getting read only access to the buffer on the host
const auto HostAccessor = Buffer.get_access<cl::sycl::access::mode::read>();
// Check that the results are correct
bool MismatchFound = false;
for (size_t I = 0; I < Buffer.get_count(); ++I) {
if (HostAccessor[I] != I) {
std::cout << "The result is incorrect for element: " << I
<< " , expected: " << I << " , got: " << HostAccessor[I]
<< std::endl;
MismatchFound = true;
}
}
if (!MismatchFound) {
std::cout << "The results are correct!" << std::endl;
}
return MismatchFound;
}
dpcpp simple-sycl-app.cpp -o simple-sycl-app
./simple-sycl-app
You will see the following output:The results are correct!
To specify the device, SYCL provides the abstract cl::sycl::device_selector class, which you can subclass to define how the runtime selects the device. The method operator() of the SYCL device_selector is an abstract member function, which takes a reference to a SYCL device and returns an integer score. This abstract member function can be implemented in a derived class and provide a logic for selecting a SYCL device. The SYCL runtime uses the device with the highest returned score. This object can be passed to the cl::sycl::queue and cl::sycl::device constructors.
This example illustrates how to use the device_selector to create a device and queue objects that are bound to a GPU:
#include <CL/sycl.hpp>
int main() {
class NEOGPUDeviceSelector : public cl::sycl::device_selector {
public:
int operator()(const cl::sycl::device &Device) const override {
using namespace cl::sycl::info;
const std::string DeviceName = Device.get_info<device::name>();
const std::string DeviceVendor = Device.get_info<device::vendor>();
return Device.is_gpu() && (DeviceName.find("HD Graphics NEO") != std::string::npos);
}
};
NEOGPUDeviceSelector Selector;
try {
cl::sycl::queue Queue(Selector);
cl::sycl::device Device(Selector);
} catch (cl::sycl::invalid_parameter_error &E) {
std::cout << E.what() << std::endl;
}
}
Start using the compiler from the command line, as outlined above, or within an IDE.
Follow the steps below to invoke the compiler using the command line from within Microsoft Visual Studio*.
You must have a version of Microsoft Visual Studio* installed to use the compiler.
Step 1: Open a command prompt.
Step 2: Invoke the compiler.
Use the command below to invoke the compiler from the command line:
Use the command below to display all available compiler options:
Use the commands below to invoke the compiler from the command line.
Follow the steps below to invoke the compiler from within Microsoft Visual Studio*.
Step 1: Build a binary:
Step 2: Set build configurations.
Switch to the Intel® oneAPI DPC++/C++ Compiler from the Microsoft Visual Studio* C++ Compiler
Switch to the Microsoft Visual Studio* C++ Compiler from the Intel® oneAPI DPC++/C++ Compiler
This action updates the solution file to use the Microsoft Visual Studio C++ compiler. All configurations of affected projects are automatically cleaned unless you select Do not clean project(s). If you choose not to clean projects, you will need to rebuild updated projects to ensure all source files are compiled with the new compiler.
Follow the steps below to invoke the compiler from within the Eclipse* CDT.
Step 1: Install the Intel® Compiler Eclipse CDT plugin.
Step 2: Build a new project or open an existing project.
Step 3: Set build configurations.
Content |
Description and Links |
---|---|
Visit the Release Notes page for known issues and the most up-to-date information. |
|
Provides details on the Intel® oneAPI DPC++/C++ Compiler programming model, including details about DPC++, programming for various target accelerators, and introductions to the Intel® oneAPI libraries. |
|
Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference |
Explore Intel® oneAPI DPC++/C++ Compiler features and setup and get more detailed information about compiler options, attributes, and more. |
SYCL Specification Version 1.2.1 PDF |
The SYCL Specification PDF, explains how SYCL integrates OpenCL devices with modern C++: https://www.khronos.org/registry/SYCL/specs/sycl-1.2.1.pdf |
SYCL Overview site |
An overview of SYCL: https://www.khronos.org/sycl/ |
The GNU* C++ Library |
Using dual ABI: https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html |
Intel technologies may require enabled hardware, software or service activation.
No product or component can be absolutely secure.
Your costs and results may vary.
© Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names and brands may be claimed as the property of others.
No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document.
The products described may contain design defects or errors known as errata which may cause the product to deviate from published specifications. Current characterized errata are available on request.
Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.