Intel® oneAPI Base Toolkit
Support for the core tools and libraries within the base toolkit that are used to build and deploy high-performance data-centric applications.

DPC++ setup question

Kirk
Beginner
1,997 Views

Apololgies for a total newbie question. I never tried GPU programming before.

I have Intel OneAPI version 2021.3.0 for Windows, the Intel oneAPI Programming Guide and on a suggestion there I have the book Data Parallel C++ (many authors, Apress). I'm stuck on the hello world program from the book.

I'm working on the command line, not in Visual Studio. I believe I need an argument to the setvars.bat file that I can't figure out. Normally I can run the C++ compiler without problem (icl command). I only have trouble with icx. When I use that the compile will fail because it's missing CL/sycl.hpp. If I manually add the folder ...\latest\windows\include\sysl to the INCLUDE path, then I can compile but not link. If I specifically add sycl.lib to the link command then I can link but with a warning "multiple '__CLANG_OFFLOAD_BUNDLE__openmp-s' sections". If I run the resulting binary anyway an exception is thrown.

I think I'm causing the problem by trying to modify the environment myself. There must be some parameter I need to setvars to set this stuff up properly for me, but I haven't found it.

Many thanks for your patience!

 

0 Kudos
1 Solution
ShivaniK_Intel
Moderator
1,957 Views

Hi,

 

Thanks for reaching out to us.

 

Below are the steps for initializing one API environment in Command Prompt:

Method 1:

Step 1: Open Windows Command Prompt 

Step 2 : cd <install-dir> the Intel one API installation directory (by default, C:\Program Files (x86)\Intel\oneAPI).

Step 3: Launch setvars.bat which will initialize the complete one API Environment.

ShivaniK_Intel_0-1632745581221.png

 

Method 2:

Open "Intel one API command prompt for Intel 64 for Visual Studio 2019" from the Windows Search Bar.

ShivaniK_Intel_2-1632745865928.png

This will automatically initialize the Intel one API Environment. You can use all the compilers(icl,icx,dpcpp etc)

ShivaniK_Intel_3-1632745914974.png

 

In order to check whether the environment is initialized properly or not check with the below command:

 

 

icx --version

 

 

 

Once the setvars.bat is done successfully you can compile the sample hello world program from the book Data-Parallel C++(many authors, Apress).

 

Using dpcpp :

Compilation command :dpcpp hello_world.cpp

Execution command: hello_world.exe

 

Using icx:

Compilation command : icx -fsycl -fsycl-unnamed-lambda hello_world.cpp

Execution command : hello_world.exe

 

You can refer to the attachment for the sample hello_world program.

 

Thanks & Regards

Shivani

View solution in original post

0 Kudos
5 Replies
Kirk
Beginner
1,981 Views

Possibly I found my own answer, but I hope not. If I use dpcpp rather than icx, use /I to add to the include path and explicitly list a total of 5 libraries on the link command then it compiles, links and runs. setvars creates a pretty simple environment for icl and I was expecting the same for DPC++. Perhaps that is just wrong.

0 Kudos
ShivaniK_Intel
Moderator
1,958 Views

Hi,

 

Thanks for reaching out to us.

 

Below are the steps for initializing one API environment in Command Prompt:

Method 1:

Step 1: Open Windows Command Prompt 

Step 2 : cd <install-dir> the Intel one API installation directory (by default, C:\Program Files (x86)\Intel\oneAPI).

Step 3: Launch setvars.bat which will initialize the complete one API Environment.

ShivaniK_Intel_0-1632745581221.png

 

Method 2:

Open "Intel one API command prompt for Intel 64 for Visual Studio 2019" from the Windows Search Bar.

ShivaniK_Intel_2-1632745865928.png

This will automatically initialize the Intel one API Environment. You can use all the compilers(icl,icx,dpcpp etc)

ShivaniK_Intel_3-1632745914974.png

 

In order to check whether the environment is initialized properly or not check with the below command:

 

 

icx --version

 

 

 

Once the setvars.bat is done successfully you can compile the sample hello world program from the book Data-Parallel C++(many authors, Apress).

 

Using dpcpp :

Compilation command :dpcpp hello_world.cpp

Execution command: hello_world.exe

 

Using icx:

Compilation command : icx -fsycl -fsycl-unnamed-lambda hello_world.cpp

Execution command : hello_world.exe

 

You can refer to the attachment for the sample hello_world program.

 

Thanks & Regards

Shivani

0 Kudos
Zippy_Pinhead
Beginner
1,761 Views

I am seeing a similar problem that is not fixed by running setvars.sh.

I'm running on Ubuntu Linux with Kernel version 18.04.1 (x86_64 SMP).

 

This is the error:

toddb@zippy $ icx -fsycl -fsycl-unnamed-lambda hello_world.cpp
hello_world.cpp:1:10: fatal error: 'CL/sycl.hpp' file not found
#include <CL/sycl.hpp>
^~~~~~~~~~~~~
1 error generated.


This is the output from setvars.sh:

:: initializing oneAPI environment ...
-bash: BASH_VERSION = 4.4.20(1)-release
:: advisor -- latest
:: ccl -- latest
:: compiler -- latest
:: dal -- latest
:: debugger -- latest
:: dev-utilities -- latest
:: dnnl -- latest
:: dpcpp-ct -- latest
:: dpl -- latest
:: intelpython -- latest
:: ipp -- latest
:: ippcp -- latest
:: mkl -- latest
:: mpi -- latest
:: tbb -- latest
:: vpl -- latest
:: vtune -- latest
:: oneAPI environment initialized ::

 

Here is my $PATH variable value:

toddb@zippy $ echo $PATH
/Developer/NVIDIA/CUDA-5.5/bin:/opt/intel/compilers_and_libraries_2020.4.304/linux/bin/intel64:/opt/intel/compilers_and_libraries_2020.4.304/linux/bin:/opt/intel/compilers_and_libraries_2020.4.304/linux/mpi/intel64/libfabric/bin:/opt/intel/compilers_and_libraries_2020.4.304/linux/mpi/intel64/bin:/opt/intel/oneapi/vtune/2021.7.1/bin64:/opt/intel/oneapi/vpl/2021.4.0/bin:/opt/intel/oneapi/mpi/2021.3.0//libfabric/bin:/opt/intel/oneapi/mpi/2021.3.0//bin:/opt/intel/oneapi/mkl/2021.3.0/bin/intel64:/opt/intel/oneapi/intelpython/latest/bin:/opt/intel/oneapi/intelpython/latest/condabin:/opt/intel/oneapi/dpcpp-ct/2021.3.0/bin:/opt/intel/oneapi/dev-utilities/2021.3.0/bin:/opt/intel/oneapi/debugger/10.2.4/gdb/intel64/bin:/opt/intel/oneapi/compiler/2021.3.0/linux/lib/oclfpga/llvm/aocl-bin:/opt/intel/oneapi/compiler/2021.3.0/linux/lib/oclfpga/bin:/opt/intel/oneapi/compiler/2021.3.0/linux/bin/intel64:/opt/intel/oneapi/compiler/2021.3.0/linux/bin:/opt/intel/oneapi/advisor/2021.3.0/bin64:/home/toddb/.todd_bin:/usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/toddb/bin

 

Thank you in advance for any help with this issue.

 

-Zippy

0 Kudos
Zippy_Pinhead
Beginner
1,751 Views

I am using Ubuntu 18.04.6 on x86_64.

 

When I first tried to run your hello_world.cpp, I was seeing this error:

toddb@zippy $ icx -fsycl -fsycl-unnamed-lambda hello_world.cpp
hello_world.cpp:1:10: fatal error: 'CL/sycl.hpp' file not found
#include <CL/sycl.hpp>
^~~~~~~~~~~~~
1 error generated.

 

That error was caused by the install of

$ apt install intel-basekit

 

failing to require the package "intel-oneapi-compiler-dpcpp-cpp-common" as a prequequisite.

Once I installed "intel-oneapi-compiler-dpcpp-cpp-common" by hand, I am now getting these errors when I try to compile your hello_world.cpp:

 

toddb@zippy $ dpcpp hello_world.cpp
In file included from hello_world.cpp:1:
In file included from /opt/intel/oneapi/compiler/latest/linux/include/sycl/CL/sycl.hpp:11:
In file included from /opt/intel/oneapi/compiler/latest/linux/include/sycl/CL/sycl/accessor.hpp:13:
In file included from /opt/intel/oneapi/compiler/latest/linux/include/sycl/CL/sycl/buffer.hpp:11:
In file included from /opt/intel/oneapi/compiler/latest/linux/include/sycl/CL/sycl/detail/buffer_impl.hpp:19:
/opt/intel/oneapi/compiler/latest/linux/include/sycl/CL/sycl/types.hpp:2336:48: error: 'T' does not refer to a value
using FieldT = decltype(__builtin_field_type(T, NumFieldsToCheck - 1));
^
/opt/intel/oneapi/compiler/latest/linux/include/sycl/CL/sycl/types.hpp:2333:20: note: declared here
template <typename T, unsigned NumFieldsToCheck>
^
...
<many more similar errors>

 

Do you have any suggestions?

 

-Zippy

0 Kudos
ShivaniK_Intel
Moderator
1,846 Views

Hi,


Thanks for accepting our solution. If you need any additional information, please post a new question as this thread will be no longer monitored by Intel.


Thanks & Regards

Shivani


0 Kudos
Reply