CNugteren / CLBlast

Tuned OpenCL BLAS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Undefined reference to `clblast::StatusCode clblast::Gemm` on Windows with GCC with the C++ API

LostRuins opened this issue · comments

Hi, I'm not sure if it's a user error on my side. I am using the prebuild windows binaries for v1.5.3 from https://github.com/CNugteren/CLBlast/releases/tag/1.5.3

Previously, the C styled CLBlastSgemm (from clblast_c.h) is working fine. However, when attempting to switch to C++ and calling clblast::Gemm (from clblast.h), I get a linker error.

undefined reference to `clblast::StatusCode clblast::Gemm<float>(clblast::Layout, clblast::Transpose, clblast::Transpose, unsigned long long, unsigned long long, unsigned long long, float, _cl_mem*, unsigned long long, unsigned long long, _cl_mem*, unsigned long long, unsigned long long, float, _cl_mem*, unsigned long long, unsigned long long, _cl_command_queue**, _cl_event**, _cl_mem*)

I am using the exact same library for both OpenCL and clblast as before. Any ideas?

I don't have a Windows machine to test on myself, so I can't easily reproduce. But perhaps your linker settings are not correct? Can you share your linker (and compiler?) commands used?

Sure. For reference, the include files are copied to the include directory, which also contains the OpenCL CL folder, and clblast.lib and opencl.lib are in the lib directory in the project. The relevant code is in main.cpp which is trying to #include <clblast.h>

The build command:
g++ -I. -I./include -I./include/CL -O3 -std=c++11 -fPIC -DNDEBUG -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -march=native -mtune=native -DGGML_USE_CLBLAST main.cpp lib/OpenCL.lib lib/clblast.lib -o main

I have also tried suffixing -L./lib and then adding the linker flags -lclblast and -lopencl, to the same failing result, undefined reference to clblast::Gemm. Swapping to the C style CLBlastSgemm via clblast_c.h works perfectly

Windows does not have a package manager so i'm wondering if there are some incompatibilities utilizing the library this way.

Hmm, thanks for the information. I see you are using GCC, is that perhaps through WSL? If so, perhaps you should try to link against the Linux libraries instead? I'm not sure how that works, but the Windows release is not made using WSL and uses the MSVC compiler (from MS Visual Studio), and I don't think that one can then be used with GCC.

Or otherwise you'll have to compile from source. I'm working on a new release script for the next CLBlast release, which might be able to change things to get better Windows builds, but I can't promise anything.

No worries. I'm not using WSL, I am using GCC via MinGW64, powered by the w64devkit https://github.com/skeeto/w64devkit

In the end, I did a simple workaround by wrapping the function calls to clblast::Gemm directly to use CLBlastSgemm C style function and it works, so that can be considered resolved for now. Everything is working now.

I will mark this as closed, but feel free to revist anytime. Thanks :)