I am Intel employee (a summer intern) working with integration DPC++ inside the existed C++ project. The idea of the integration is that DPC++ code will compiled via dpcpp compiler into static library, and then the rest of codebase of the existed project, compiled via g++/clang++/visual studio compiler (non dpcpp compiler) will use the library. And this works on compiling step, but in runtime I have gotten an error about a wrong kernal name like this:
Device: Intel(R) Core(TM) i7-6950X CPU @ 3.00GHz
terminate called after throwing an instance of 'cl::sycl::runtime_error'
what(): No kernel named _ZTS9VectorAdd was found -46 (CL_INVALID_KERNEL_NAME)
PLEASE submit a bug report to https://software.intel.com/en-us/support/priority-support and include the crash backtrace.
Aborted (core dumped)
(you see VectorAdd because for testing purpose I have use DPC++ VectorAdd example code (which I have tested before in separate build, and the code was working) inside the the existed project dpcpp library).
I also have reproduce the problem in small project and found is solution: building rest of the project via clang++ from DPC++ environment with flag '-fsycl', but I hope this not the only solution of the problem, because it is too limited (and clang++ (from the environment) and dpcpp can't build the existed project due some strange llvm-link errors, so this is not a option for the integration project). Also building dynamic library instead of static also solve the problem, but it is more complicated variant of integration.
So, is this problem (and if it is a problem at all instead of compiler limitation) can be solved, or moving DPC++ code inside static library for using from external common C++ code is impossible?
We are able to reproduce the same error with the static library linking. We are checking with the team and will get back to you regarding the same.
Also, since you mentioned that it is working with a dynamic library ("Also building dynamic library instead of static also solve the problem"). Could you please share the exact steps you followed.
Thanks & Regards
I have attached commands needed to build the test project with dynamic library. Also, notice, that I use LD_LIBRARY_PATH, when i have run executable, - this env variable store additional paths for OS for shared libraries and needed for finding DPC++ shared libraries and builded the shared library from previous commands.
Thanks for providing the required details to debug the issue.!
In my opinion, the static library fails because the device side execution(kernel) is dependent on DPC++/llvm-sycl runtime. So, when you are trying to perform a link step with g++, the compiler probably doesn't know how to proceed with the kernel execution. Hence we see the error "CL_INVALID_KERNEL_NAME".
Whereas in the case of the dynamic library the .so shared library file creation ensures that the required information for the device kernel execution is present. Hence we don't see any error.
dpcpp -fPIC -shared -o libvectoradd.so vector-add.o
However, we have escalated this issue to the concerned team.
Thanks for bringing it up to us.!
I hope, the issue can be resolved, for some additional dpcpp compiler flag or something like that, because obviously working with static libraries more easy, that with dynamic because of lack of need for dynamic libraries lookup on start.
Also, status of the issue important for my work project, so how I can get notification, if the issue will be resolved? Is the issue resolving (if it is will happen) will be mentioned in DPC++ Compiler Release Notes?