Intel® oneAPI DPC++/C++ Compiler
Talk to fellow users of Intel® oneAPI DPC++/C++ Compiler and companion tools like Intel® oneAPI DPC++ Library, Intel® DPC++ Compatibility Tool, and Intel® Distribution for GDB*
718 Discussions

CL_INVALID_KERNEL_NAME when built with -fsycl-targets=spir64_gen-unknown-unknown-sycldevice

Shukla__Gagandeep
6,186 Views

Hi,

I'm facing a strange issue when I build my sycl code with flag -fsycl-targets=spir64_gen-unknown-unknown-sycldevice, I get exception -

Native API failed. Native API returns: -46 (CL_INVALID_KERNEL_NAME) -46 (CL_INVALID_KERNEL_NAME)

Code works fine when used without that flag but I can't do that because I have several sycl functions in my code and I get LLVM out of memory error.

I can reproduce the issue in the attached code. app.cpp contains main, lib.cpp contains a simple sycl function. When library gets compiled with -fsycl-targets or -fsycl-link-targets flag, I get the error.

Regards,
Gagan

 

0 Kudos
17 Replies
GouthamK_Intel
Moderator
6,170 Views

Hi Gagandeep,

We are able to reproduce the same error on our end.

Could you please try the below command? let us know the output of it.


  1. dpcpp -c app.cpp -o app.o
  2. dpcpp -fsycl -fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend "-device skl" lib.cpp app.o -o myout


Thanks & Regards

Goutham


0 Kudos
Shukla__Gagandeep
6,163 Views

Hi Gautham,

The command you gave works but my issue is that in my actual project, I'm using CMake as build tool. There are many libraries that get compiled individually and then get linked with application binary.

The sample code + cmake files that I gave actually replicate my build process along with the issue I face and I have to solve this issue within those constraints. I can not directly compile files on command line

Regards,
Gagan

 

0 Kudos
GouthamK_Intel
Moderator
6,136 Views

Hi Gagan,

We are working on your issue. We will get back to you soon.


Regards

Goutham


0 Kudos
GouthamK_Intel
Moderator
6,127 Views

Hi Gagan,

We have analysed your CMake configuration, we observed that there are some issues during the linking stage. you need to provide the -fsycl-targets and Xsycl-target-backend during the linking stage too.

So you can try providing -fsycl-targets and -Xs to cmake exe linker flag.

Command:

cmake -DCMAKE_EXE_LINKER_FLAGS='-fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xs "-device kbl"' ..

 

Let us know if you face any further issues.

Have a Good day!

 

Thanks & Regards

Goutham

0 Kudos
Shukla__Gagandeep
6,117 Views

Hi Gautham,

The solution you provided worked with the test code that I shared with you but when I added the same to my actual code, it failed at link stage. Error I get is:

[100%] Linking CXX executable ../../bin/cycles
InvalidFunctionCall: Unexpected llvm intrinsic:
 llvm.exp.f32 [Src: /netbatch/donb1852340_00/runDir/09/20200827_000000/llvm/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp:2358  ]
dpcpp: error: llvm-spirv command failed with exit code 6 (use -v to see invocation)
src/app/CMakeFiles/cycles.dir/build.make:221: recipe for target 'bin/cycles' failed
make[2]: *** [bin/cycles] Error 6
CMakeFiles/Makefile2:510: recipe for target 'src/app/CMakeFiles/cycles.dir/all' failed
make[1]: *** [src/app/CMakeFiles/cycles.dir/all] Error 2
Makefile:148: recipe for target 'all' failed
make: *** [all] Error 2

I added

add_compile_options(
   -fsycl-targets=spir64_gen-unknown-unknown-sycldevice
)

To my library that contains OneAPI code, cleaned up my build folder and used the command you provided to run cmake.

If I build oneapi library without above compile option, I get following error:

[100%] Linking CXX executable ../../bin/cycles
llvm-link: Not enough positional command line arguments specified!
Must specify at least 1 positional argument: See: /home/kuljeet/intel/oneapi/compiler/2021.1-beta09/linux/bin/llvm-link --help
dpcpp: error: sycl-link command failed with exit code 1 (use -v to see invocation)
src/app/CMakeFiles/cycles.dir/build.make:221: recipe for target 'bin/cycles' failed
make[2]: *** [bin/cycles] Error 1
CMakeFiles/Makefile2:510: recipe for target 'src/app/CMakeFiles/cycles.dir/all' failed
make[1]: *** [src/app/CMakeFiles/cycles.dir/all] Error 2
Makefile:148: recipe for target 'all' failed
make: *** [all] Error 2

I'm not even sure what else to try.

Regards,
Gagan

 

0 Kudos
GouthamK_Intel
Moderator
6,101 Views

Hi Gagan,

Could you please try adding -Xsycl-target-backend along with -fsycl-targets in add_compile_options.

-Xsycl-target-backend "-device skl"  // Device depending on your hardware, e.g., skl

 

If you still face any errors, please provide the logs of CMake with verbose ON.

cmake -DCMAKE_EXE_LINKER_FLAGS='-fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xs "-device skl"' -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON ..

make V=1

 

Also, provide the details of the device for which you are targeting.

 

Regards

Goutham

 

0 Kudos
Shukla__Gagandeep
6,088 Views

Hi Gautham,

I'm still getting the error:

InvalidFunctionCall: Unexpected llvm intrinsic:
 llvm.exp.f32 [Src: /netbatch/donb1852340_00/runDir/09/20200827_000000/llvm/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp:2358  ]
dpcpp: error: llvm-spirv command failed with exit code 6 (use -v to see invocation)
make[2]: *** [bin/cycles] Error 6
make[1]: *** [src/app/CMakeFiles/cycles.dir/all] Error 2
make: *** [all] Error 2

Attached zip contains cmake and make log.

Target device info:

platform_name       : Intel(R) OpenCL HD Graphics
platform_version    : OpenCL 2.1 
platform_vendor     : Intel(R) Corporation
vendor_name         : Intel(R) Gen9 HD Graphics NEO
vendor_id           : 32902
vendor              : Intel(R) Corporation
driver_version      : 20.28.17293
version             : OpenCL 2.1 NEO 
opencl_c_version    : OpenCL C 2.0 

Regards,
Gagan

 

 

 

0 Kudos
GouthamK_Intel
Moderator
6,074 Views

Hi Gagan,

From the logs that you have attached it is little difficult to pinpoint the exact issue. It would be helpful if you can isolate the exact issue you are facing and provide a small reproducer of it.

Also, provide steps to reproduce the exact issue you are facing if possible.


Thanks & Regards

Goutham


0 Kudos
Shukla__Gagandeep
6,048 Views

Hi Gautham,

Please find attached sample workspace which can reproduce the error I am facing.

Steps to reproduce are:

cmake -DCMAKE_EXE_LINKER_FLAGS='-fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend "-device skl"' ..
make

and the error I get is:

InvalidFunctionCall: Unexpected llvm intrinsic:
 llvm.ctpop.i32 [Src: /netbatch/donb1852340_00/runDir/09/20200827_000000/llvm/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp:2358  ]
dpcpp: error: llvm-spirv command failed with exit code 6 (use -v to see invocation)
app/CMakeFiles/test_app.dir/build.make:103: recipe for target 'app/test_app' failed
make[2]: *** [app/test_app] Error 6
CMakeFiles/Makefile2:133: recipe for target 'app/CMakeFiles/test_app.dir/all' failed
make[1]: *** [app/CMakeFiles/test_app.dir/all] Error 2
Makefile:102: recipe for target 'all' failed
make: *** [all] Error 2

Regards,
Gagan

 

0 Kudos
GouthamK_Intel
Moderator
6,038 Views

Hi Gagan,

Thanks for the reproducer. We are able to reproduce it on beta09.

However, since beta10 has released, could you please give it a try and let us know if you face any issues.

Also, please do migrate the entire application with beta10 dpct and compile it.


Thanks & Regards

Goutham


0 Kudos
Shukla__Gagandeep
6,012 Views

Hi Gautham,

I tried converting code using beta10. It has not converted any of the cuda bring up functions like cuInit, cuDeviceGet, cuDeviceGetAttribute, cuMemInfo, cuMemAlloc, cuMemHostAlloc, cuTexObjectCreate .... etc. Datatype conversion across files from intX, floatX to sycl::intX, sycl::floatX has been missed at several places.

And my old code is not even compiling. beta10 is not recognizing dpct::image_info, dpct::image_base_p or dpct::create_image(), dpct::image_accessor, ~image_base().

Regards,
Gagan

 

0 Kudos
GouthamK_Intel
Moderator
5,975 Views

Hi Gagandeep,

Thanks for reporting the issue, we are able to reproduce the error which you are facing.

We are forwarding this thread to the concerned internal team.


Thanks & Regards

Goutham


0 Kudos
Shukla__Gagandeep
5,968 Views

Hi,

Update with beta10:

I was able to resolve all the API changes that are done in beta 10 and result of compilation is still the same. I get following error

[100%] Linking CXX executable ../../bin/cycles
InvalidFunctionCall: Unexpected llvm intrinsic:
 llvm.ctpop.i32 [Src: /netbatch/donb2965411_00/runDir/88/20201005_160000/llvm/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp:2399  ]
dpcpp: error: llvm-spirv command failed with exit code 6 (use -v to see invocation)
src/app/CMakeFiles/cycles.dir/build.make:221: recipe for target 'bin/cycles' failed
make[2]: *** [bin/cycles] Error 6
CMakeFiles/Makefile2:510: recipe for target 'src/app/CMakeFiles/cycles.dir/all' failed
make[1]: *** [src/app/CMakeFiles/cycles.dir/all] Error 2
Makefile:148: recipe for target 'all' failed
make: *** [all] Error 2

when compiled with

cmake -DCMAKE_EXE_LINKER_FLAGS='-fsycl-targets=spir64_gen-unknown-unknown-sycldevice -Xsycl-target-backend "-device skl"' ..

If there is any thing I can try in the mean time, please let me know.

Regards,
Gagan

 

0 Kudos
Sravani_K_Intel
Moderator
5,964 Views

Hi Gagandeep,

 

Please try compiling with the flag -fno-sycl-early-optimizations.

There is a known issue in Beta10 which is causing this error for some intrinsics and ctpop is one of them.


0 Kudos
Shukla__Gagandeep
5,911 Views

Now the error is

InvalidFunctionCall: Unexpected llvm intrinsic:
 llvm.exp.f32 [Src: /netbatch/donb2965411_00/runDir/88/20201005_160000/llvm/llvm-spirv/lib/SPIRV/SPIRVWriter.cpp:2399  ]
dpcpp: error: llvm-spirv command failed with exit code 6 (use -v to see invocation)
src/app/CMakeFiles/cycles.dir/build.make:220: recipe for target 'bin/cycles' failed
make[2]: *** [bin/cycles] Error 6
CMakeFiles/Makefile2:509: recipe for target 'src/app/CMakeFiles/cycles.dir/all' failed
make[1]: *** [src/app/CMakeFiles/cycles.dir/all] Error 2
Makefile:148: recipe for target 'all' failed
make: *** [all] Error 2

Regards,
Gagan

0 Kudos
Sravani_K_Intel
Moderator
5,615 Views

Hi Gagan,


Sorry for the delayed response.

Did you get a chance to verify this with the DPC++ Compiler from the oneAPI Gold release? If you still have issues, please attach the reproducer after migrating with Intel(R) DPC++ Compatibility Tool version 2021.1.


Thank you.


0 Kudos
Sravani_K_Intel
Moderator
5,573 Views

This issue has been resolved and we will no longer respond to this thread. If you require additional assistance from Intel, please start a new thread. Any further interaction in this thread will be considered community only


0 Kudos
Reply