Intel® oneAPI Data Parallel C++
Support for Intel® oneAPI DPC++ Compiler, Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and GDB*
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
259 Discussions

Dpcpp /link flag on Windows generate executable with SYCL code not runnable on device

Tse__Amon
Beginner
308 Views

Dear Support Team,

I am trying Dpcpp 2021.1 on Win10 (Ver 2004) with SYCL running on Intel Core i7-8850H. Below are the compilation commands generated by cmake:

C:\Program Files (x86)\Intel\oneAPI\compiler\2021.1.1\windows\..\windows\bin\dpcpp.exe /W1 /Od /D USE_DPCPP /D CPU /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /WX- /EHsc /std:c++17 /MD /c /IC:\Users\amont\Documents\github\amontse\CMakeDpcpp\.. /Fo"parallel.dir\Debug\\" C:\Users\amont\Documents\github\amontse\CMakeDpcpp\parallel\iota_parallel.cpp

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX64\x64\Lib.exe /OUT:"C:\Users\amont\Documents\github\amontse\CMakeDpcpp\out\build\x64-dpcpp-Debug\Debug-CPU\Debug\parallel.lib" /NOLOGO /MACHINE:X64 parallel.dir\Debug\iota_parallel.obj

C:\Program Files (x86)\Intel\oneAPI\compiler\2021.1.1\windows\..\windows\bin\dpcpp.exe /W1 /Od /D USE_DPCPP /D CPU /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /WX- /EHsc /std:c++17 /MD /c /IC:\Users\amont\Documents\github\amontse\CMakeDpcpp\.. /Fo"sequential.dir\Debug\\" C:\Users\amont\Documents\github\amontse\CMakeDpcpp\sequential\iota_sequential.cpp

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\bin\HostX64\x64\Lib.exe /OUT:"C:\Users\amont\Documents\github\amontse\CMakeDpcpp\out\build\x64-dpcpp-Debug\Debug-CPU\Debug\sequential.lib" /NOLOGO /MACHINE:X64 sequential.dir\Debug\iota_sequential.obj

C:\Program Files (x86)\Intel\oneAPI\compiler\2021.1.1\windows\..\windows\bin\dpcpp.exe /W1 /Od /D USE_DPCPP /D CPU /D "CMAKE_INTDIR=\"Debug\"" /D _MBCS /WX- /EHsc /std:c++17 /MD /c /IC:\Users\amont\Documents\github\amontse\CMakeDpcpp\.. /Fo"CMakeDpcpp.dir\Debug\\" C:\Users\amont\Documents\github\amontse\CMakeDpcpp\main\main.cpp

C:\Program Files (x86)\Intel\oneAPI\compiler\2021.1.1\windows\..\windows\bin\dpcpp.exe /Fe"C:\Users\amont\Documents\github\amontse\CMakeDpcpp\out\build\x64-dpcpp-Debug\Debug-CPU\Debug\CMakeDpcpp.exe" CMakeDpcpp.dir\Debug\main.obj /WX- /MD /nologo /link "..\Debug-CPU\Debug\sequential.lib" "..\Debug-CPU\Debug\parallel.lib"

 

The last command is to generate the final execution from main.obj sequential.lib (C++17 code) and parallel.lib (SYCL 1.2 code). The issue is that the executable is run but with exception throw in the SYCL codes:

Running on device: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
An exception is caught while computing on device: Native API failed. Native API returns: -46 (CL_INVALID_KERNEL_NAME) -46 (CL_INVALID_KERNEL_NAME)

 

If I REMOVE the /link switch in the last command of dpcpp, the executable generated is run and completed successfully as expected.

An observation is that the executable generated with /link switch is 1/3 side of that generated without the /link switch. I guess the /link switch causes the dpcpp not putting the SPIR-V device code into the output executable.

May Intel engineer have any comment?

Amon

0 Kudos
4 Replies
RahulV_intel
Moderator
297 Views

Hi Amon,


That's right. During the final linking stage, the SPIR-V generic image (or a device-specific target image in the case of AOT compilation) combines with the host object files to generate a "fat" binary.


You may find more details about the compilation flow in the link below:

https://github.com/intel/llvm/blob/sycl/sycl/doc/CompilerAndRuntimeDesign.md


The error "CL_INVALID_KERNEL_NAME" can get triggered due to multiple reasons. It would be great if you could attach a minimal reproducible code sample that causes this error.



Thanks,

Rahul



Tse__Amon
Beginner
292 Views

Hello Rahul,

Finally I worked out the root cause of the issue: If I moved the lib containing the device code (i.e. parallel.lib in my example) BEFORE the /link switch then dpcpp.exe generates the output that the device code are execute correctly.

Regards,

Amon

RahulV_intel
Moderator
278 Views

Hi,


Good to know that it worked. Could you also let me know if I can close this thread from my end?


Thanks,

Rahul


RahulV_intel
Moderator
262 Views

Hi,


I have not heard back from you, so I will go ahead and close this thread from my end. Further responses on this thread will be considered community only.


Thanks,

Rahul


Reply