Hello Support Team,
I am trying OneAPI 2021.1 and trying putting device code into a static lib. I am on Win10 platform.
Intel(R) oneAPI DPC++ Compiler 2021.1 (2020.10.0.1113)
Thread model: posix
From the documentation, the switch I should use is foffload-static-lib. Below is the command line and output. However it failed saying the switch foffload-static-lib is not recognized and hence the static lib containing device code is not linked; then the whole linking process is failed because of the unresolved symbol.
prompt>dpcpp.exe /Fe"..\Debug\CMakeDpcpp.exe" CMakeDpcpp.dir\Debug\main.obj /Zi /WX- /MDd /nologo /link /machine:x64 ..\Debug\sequential.lib -foffload-static-lib=..\Debug\parallel.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
LINK : warning LNK4044: unrecognized option '/foffload-static-lib=..\Debug\parallel.lib'; ignored
main-593307.obj : error LNK2019: unresolved external symbol "public: virtual void __cdecl mylib::IotaParallel::run(class std::array<int,10000> &,int)" (?run@IotaParallel@mylib@@UEAAXAEAV?$array@H$0CHBA@@std@@H@Z) referenced in function main
..\Debug\CMakeDpcpp.exe : fatal error LNK1120: 1 unresolved externals
dpcpp: error: linker command failed with exit code 1120 (use -v to see invocation)
Is there anything wrong?
I move the same source codes to Ubuntu Linux 18.04. dpcpp returns warning saying the switch foffload-static-lib is deprecated!
Then on Ubuntu, I directly the link static lib containing device code; the link process is completed successfully and the executable runs and executes successfully.
Then I switch back to Windows and try to link the static lib containing device code directly, the link process is completed successfully. However, the executable fails to run and returns runtime error. Below is the exception message captured from the thrown exception by the running executable:
Running on device: Intel(R) Graphics Gen9
An exception is caught while computing on device: Native API failed. Native API returns: -30 (CL_INVALID_VALUE) -30 (CL_INVALID_VALUE)
Moreover, the executable on Windows is much smaller than the size of the static lib containing the device code. I wonder the device code in the static lib is not moved into the output executable during linking.
I believe the documentation (Developer Guide and Programming Guide are not consistent to the released software, and the behavior on Windows is weird.
May Intel engineer make an investigation? Thanks.
As we have not heard back from you, we are considering that your issue has been resolved and we have answered all your queries. So 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
Have a Good day!
Thanks & Regards