This content describes the steps needed to use an external host compiler (G++*) along with the Intel® oneAPI DPC++/C++ Compiler.
In this example, you will use a host compiler to generate the host objects and perform the final link. The host compiler needs to know where to find the required headers and libraries. Follow the example instructions to build a Data Parallel C++ (DPC++) program using a G++ Compiler (g++) for host code and an Intel® oneAPI DPC++/C++ Compiler (dpcpp) for DPC++ code.
This example includes the following:
Follow the Get Started with the Intel® oneAPI Base Toolkit for Linux* guide to set up the build environment:
source /opt/intel/oneapi/setvars.sh
export LIBDIR=<Location of libsycl.so> export INCLUDEDIR=<Location of SYCL headers>
dpcpp -c a.cpp -fPIC -o a.o dpcpp -c b.cpp -fPIC -o b.o
dpcpp -fsycl-device-only -Xclang -fsycl-int-header=a_host.h a.cpp dpcpp -fsycl-device-only -Xclang -fsycl-int-header=b_host.h b.cpp
g++ -std=c++17 -c a.cpp -o a_host.o -include a_host.h -fPIC -I$INCLUDEDIR g++ -std=c++17 -c b.cpp -o b_host.o -include b_host.h -fPIC -I$INCLUDEDIR
g++ -std=c++17 main.cpp -c -fPIC -I$INCLUDEDIR
dpcpp -fPIC -fsycl -fsycl-link a.o b.o -o device.o
Create an archive libuser.a that contains the necessary host and device objects:
ar -rcs libuser.a a_host.o b_host.o device.o
g++ main.o a_host.o b_host.o device.o -L$LIBDIR -lOpenCL -lsycl -o finalexe.exe
Build the final.exe with an archive:
g++ main.o -Wl,--whole-archive libuser.a -Wl,--no-whole-archive -L$LIBDIR -lOpenCL -lsycl -o finalexe.exe
Windows is not supported in this release.
The compiler has two options that let you use an external compiler to perform host side compilation. The options are: