Cuda with mingw - updated

We developed our code on Linux, but would like to compile the Windows executable. The old version of non-gpu compiles using mingw on Windows, so I was hoping I could do the same with the CUDA version.

The strategy is to compile the kernel code with nvcc in visual studio, and the rest with gcc in mingw.

So far, we have easily compiled a .cu file (with kernel and kernel running) in visual studio. However, we still cannot compile the c code in mingw. The c code contains cuda api calls like cudaMalloc and cudaMalloc types like cudaEvent_t , so we need to include cuda.h and cuda_runtime.h. However, gcc gives warnings and errors for these headers, for example:

 ../include/host_defines.h:57:0: warning: "__cdecl" redefined 

and

 ../include/vector_functions.h:127:14: error: 'short_4' has no member named 'x' 

Any ideas on how we can include these headers and compile the c-part of the code?

+6
source share
3 answers

If you are really desperate, perhaps it will be. Nvcc is just an interface for many compilers. It calls g ++ a lot to cut comments, split the device and host code, process the mangling name, bind stuff back, etc. (Use --verbose ) to get the details.

My idea is this: you should compile the host code using mingw when compiling the device code into fat on a linux machine (as I believe, the binary code of the device does not depend on the host machine). After that, connect both parts of the code with mingw or use the driver API to dynamically load fat. Disclaimer: not tested!

+2
source

As far as I know, it is impossible to use CUDA without MSVC. So you need MSVC for nvcc to work, and you can compile CPU code using mingw and bundle everything together.

According to http://forums.nvidia.com/index.php?showtopic=30743

"There are currently no plans to support mingw."

+1
source

You can take a look at how the loop handler deals with this, see https://developer.blender.org/diffusion/B/browse/master/extern/cuew/ and https://developer.blender.org/diffusion/B /browse/master/intern/cycles/device/device_cuda.cpp

I know this is not an automatic trick, but it can help you get started.

0
source

Source: https://habr.com/ru/post/887306/


All Articles