Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
7234 Discussions

Error linking against SYCL on Windows (for interfacing with oneMKL)

tbesard
Beginner
1,542 Views
I'm working on a C wrapper for oneMKL (for the purpose of using the library from Julia, where we only have a C FFI). The library can be found here: https://github.com/JuliaGPU/oneAPI.jl/tree/master/deps

I'm compiling this library on a Linux buildbot where I pull the necessary oneAPI 2024.0.0 packages from Conda, and link a shared library using my own simple CMake script that relies on the system Clang compiler (because from this cross-build environment I can't execute the Intel compiler):

 

add_library(oneapi_support SHARED files...)

target_link_libraries(oneapi_support
mkl_sycl
mkl_intel_ilp64
mkl_sequential
mkl_core
sycl
OpenCL
pi_level_zero
)

 

I'm redistributing the resulting shared library together with the libraries it needs. This works perfectly, on Linux.
 
I now want to do the same for native Windows. Now using a MinGW-based environment, I again pull the necessary win-64 packages from Conda, and try to build a shared library. For one, I have to adjust my list of target libraries as things seem to be named differently on Windows (is this expected?):
target_link_libraries(oneapi_support
mkl_sycl
mkl_intel_ilp64_dll
mkl_sequential.2
mkl_core.2
sycl7
OpenCL
pi_level_zero
)

 

However, even then I'm running into a linker error:

 

[1/1] Linking CXX shared library liboneapi_support.dll
ninja: job failed: : && /opt/bin/x86_64-w64-mingw32-libgfortran5-cxx11/x86_64-w64-mingw32-clang++ --sysroot=/opt/x86_64-w64-mingw32/x86_64-w64-mingw32/sys-root/ -O2 -g -DNDEBUG -L/workspace/destdir/bin -shared -o liboneapi_support.dll -Wl,--out-implib,liboneapi_support.dll.a -Wl,--major-image-version,0,--minor-image-version,0 CMakeFiles/oneapi_support.dir/src/sycl.cpp.obj CMakeFiles/oneapi_support.dir/src/onemkl.cpp.obj -lmkl_sycl -lmkl_intel_ilp64_dll -lmkl_sequential.2 -lmkl_core.2 -lsycl7 -lOpenCL -lpi_level_zero -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && :
ld.lld: error: undefined symbol: __declspec(dllimport) sycl::_V1::ext::oneapi::level_zero::make_platform(unsigned long long)
>>> referenced by /workspace/srcdir/oneAPI.jl/deps/src/sycl.cpp:9
>>> CMakeFiles/oneapi_support.dir/src/sycl.cpp.obj:(syclPlatformCreate)

 

This despite sycl7.dll and sycl7.lib being available on the library search path, and containing the symbol that's being listed here:
# nm /workspace/destdir/bin/sycl7.lib | grep make_platform
0000000000000000 T ?make_platform@level_zero@oneapi@ext@_V1@sycl@@YA?AVplatform@45@_K@Z
0000000000000000 I __imp_?make_platform@level_zero@oneapi@ext@_V1@sycl@@YA?AVplatform@45@_K@Z

 

Using ld instead of ldd throws a similar error:
ld: CMakeFiles/oneapi_support.dir/src/sycl.cpp.obj: in function `syclPlatformCreate':
/workspace/srcdir/oneAPI.jl/deps/src/sycl.cpp:9: undefined reference to `__imp__ZN4sycl3_V13ext6oneapi10level_zero13make_platformEy'

 

What am I doing wrong here? The full build script can be found in https://github.com/JuliaPackaging/Yggdrasil/pull/8285
0 Kudos
1 Reply
tbesard
Beginner
1,513 Views

It seems like this is a C++ ABI incompatibility between my MinGW-produced objects, and sycl7.dll as compiled with MSVC, as shown above by the different manglings for the make_platform function. I also don't think this is easy to fix, as it's more than the name mangling being incompatible. Although Clang seems to offer some kind of ABI compatibility? https://clang.llvm.org/docs/MSVCCompatibility.html

 

It's too bad oneMKL and other oneAPI libraries don't offer a simple, portable C API like all other vendor libraries do.

0 Kudos
Reply