1

The short version:

I try to compile MAGMA and get complains about missing symbols:

testing_cgemm.o:testing_cgemm.cpp:(.text+0x2e7): undefined reference to `cudaMalloc' 
testing_cgemm.o:testing_cgemm.cpp:(.text+0xbff): undefined reference to `cudaFree'

Checking for these symbols in both 32 and 64 bit in the cuda libs I get the following:

$ /C/Coding/Mingw-w64-tdm/bin/nm C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v4.0/lib/x64/cudart.lib | grep cudaMalloc
 0000000000000000 I __imp_cudaMalloc
 0000000000000000 T cudaMalloc

$ nm C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v4.0/lib/Win32/cudart.lib | grep cudaMalloc
 00000000 I __imp__cudaMalloc@8
 00000000 T _cudaMalloc@8

So the 64 bit libs look ok and they link right. However the 32bit lib (the second output) has some decorations at the method name. This is where I'm stuck.

The questions

What does those decorations mean? Are the 32bit not plain C? Is there any chance to link them right?

The context

I want to compile MAGMA on Windows 7 (64 bit) (both 32 and 64 bit finally) and link it to my program compiled with gcc. The problem is that Cuda on Windows does not support the Mingw/MSys toolchain, I'm familiar with. Cuda compilation using nvcc on Windows seems to require the Visual Studio C compiler cl.exe. I installed Cuda 4.0 (64bit downloads) and built the examples (using VS2008) successfully in both 32 and 64 bit variants - proving that Cuda is installed in both bitnesses.

MAGMA however does not provide a solution for Visual Studio, and I'm not experienced enough to generate one since it involves also a good portion of Fortran code to be compiled. Therefore I tried to use both toolchains (MinGW & VS2008) together. I adopted the make.inc file to my paths and perform the build in three steps. First using Msys/Mingw for the compilation of all the Fortran stuff, and after running into the errors of nvcc which is not able to find cl.exe I switch over to the VS command promt (x86 or x64, depending on the bitness to be built). The latter steps finishes with an library archive file libmagmablas.a which looks right.

However then the problems begin. Using the TDM 64bit compiler (gcc-4.5) everything seems to work correctly also for the compilation and linking of the MAGMA examples, but the .exe files fail promptly upon calling cuInit(). (I think it's a compiler bug/incompatability since the same happens when I compile the Cuda examples using this Mingw-w64 toolchain). Therefore, I switched to the 32bit Mingw-w64 toolchain which were able to compile the Cuda examples. Compiling MAGMA with it, repeating all the steps above goes well until the linking step of the MAGMA examples. There is complains about missing symbols:

testing_cgemm.o:testing_cgemm.cpp:(.text+0x2e7): undefined reference to `cudaMalloc' 
testing_cgemm.o:testing_cgemm.cpp:(.text+0xbff): undefined reference to `cudaFree'

Checking for these symbols in the cuda libs I get the following:

$ /C/Coding/Mingw-w64-tdm/bin/nm C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v4.0/lib/x64/cudart.lib | grep cudaMalloc
 0000000000000000 I __imp_cudaMalloc
 0000000000000000 T cudaMalloc

$ nm C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v4.0/lib/Win32/cudart.lib | grep cudaMalloc
 00000000 I __imp__cudaMalloc@8
 00000000 T _cudaMalloc@8

So the 64 bit libs look ok and they link right. However the 32bit lib (the second output) has some decorations at the method name. This is where I'm stuck.

What does those decorations mean? Are the 32bit not plain C? Is there any chance to link them right?

4
  • Can you link dynamically with loadproc instead? Aug 8, 2011 at 11:26
  • I habe not tried to build shared libraries for MAGMA yet. Would you really expect any benefit from it?
    – FFox
    Aug 8, 2011 at 12:22
  • Yes, it's handled completely different from static linking! Aug 8, 2011 at 17:01
  • Also FFox looks like he knows stuff. Aug 8, 2011 at 17:01

1 Answer 1

1

The 32-bit symbols are the standard Windows decoration for __stdcall functions (also known as __pascal in the 16-bit days). Given CUDA's lack of support for GCC on Windows (and seriously, this is not a path you want to go down), my guess is that the cuda.h headers aren't defining CUDAAPI properly.

3
  • If the CUDAAPI wasn't defined right by the headers, why does it work out in 64 bit?
    – FFox
    Aug 8, 2011 at 14:43
  • There's only one calling convention (and consequently one decoration scheme) on 64-bit Windows.
    – ChrisV
    Aug 8, 2011 at 14:58
  • 1
    Thanks for clarifying that! Also I think you are right concerning the API the host_defines.h include a section discreminating between GNUC and WIN32 defining CUDARTAPI as __stdcall in the latter case, while leaving it empty (__cdecl as default in my understanding) for GNUC.
    – FFox
    Aug 8, 2011 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.