« Return to Thread: CUDA and MinGW compilation trouble

Re: CUDA and MinGW compilation trouble

by bART Janssens-2 :: Rate this Message:

Reply to Author | View in Thread

On Mon, Apr 28, 2008 at 10:44 PM, Bart Janssens
<bart.janssens@...> wrote:
>  I have been trying to build the CUDA module on Win32 again. From the
>  CUDA side, things are simple, in theory, and there are two options:
>
>  1. Pass "--foreign" to nvcc. This will attempt to use gcc on win32 insead of cl.
>  2. Use nvcc to compile, i.e. pass "-c" instead of "-cuda" to nvcc.
>  This uses MSVC to compile.

Good news! Evan's CUDA module builds on Win32 now and can be linked to
K-3D using MinGW. Basically, the steps are as follows:
1. Put all functions that use CUDA in a .h/.c file, declaring them
using __declspec(dllexport) in the .h file.
2. Create a dll that exports these functions, using nvcc --shared
<flags, includes, ...> -o somelib.dll <.c and .cu source files>. This
way of calling nvcc invokes MSVC, and I think you need version 8.
3. Create a mingw import lib, using "pexports somelib.dll >
somelib.def" and then "dlltool -d somelib.def -l libsomelib.a
4. Build the rest of the module normally, linking in the import
library using -lsomelib and an -L that points to its dir

I have attached a badly hacked together patch that does this for the
cuda_bitmap module. The somelib.dll should find it's way into the path
somehow. The INSTALL command I added in my patch does nothing for some
reason, so you need to copy it manually.

For a more elegant solution, I suggest putting the cuda library of
step 2 in a subdir of k3dsdk, i.e. k3dsdk/cuda. That way, any modules
that want to use CUDA can simply include it in the
TARGET_LINK_LIBRARIES command. I think this has to be a C library,
otherwise the exported symbols are mangled in a way MinGW can't read.

While testing the resulting binary, I also turned off the
CUDA_EMULATION option. Apparently, on Win32 the hardware does get
used, so I must be having driver problems on linux. The result of
running the current dashboard test for a 3008x2000 file is 14.8s for
the CUDA version, versus 17.5s for the CPU BitmapAdd filter.

Cheers,

--
Bart


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
K3d-development mailing list
K3d-development@...
https://lists.sourceforge.net/lists/listinfo/k3d-development

k3d-cuda-mingw.diff (7K) Download Attachment

 « Return to Thread: CUDA and MinGW compilation trouble

LightInTheBox - Buy quality products at wholesale price