[Maya & CUDA build customization] Maya plugin CUDA compile problem

Hi guys,

i’m currently trying to find my way into accelerating my Maya Plugins with CUDA.
My setup is the following: I have a deformer plugin, in its deform method i would like to
execute a simple kernel to do some vector math.

I have set up VS2010 and the NVidia Toolkit and all the sample files compile correctly.
When i want to compile the CUDA version of my plugin, and i use the “CUDA Build Customization” to setup the compilation of .cu files i get the following error:


1> C:\Program Files\Autodesk\Maya2012\include\maya/MTypes.h(270): error : invalid redeclaration of type name “short2”
1> c:\program files
vidia gpu computing toolkit\cuda\v5.0\include\vector_types.h(145): here

Problem: The CUDA vector-types.h header redeclares the same basic types as MTypes.h does.

Solution from another thread: Use namespace for #include directive! (Maya Plug-in conflicts with CUDA Namespace conflict between <vector> - CUDA Programming and Performance - NVIDIA Developer Forums)

But this does not work for me, since i dont even include any CUDA headers in my header file. The Build customization seems to set everything up in a way, so that this is not neccessary. (Even if i try to include CUDA headers in a namespace i get the same error…)

How do you get around this problem? Is there a way to specify everything manually to avoid the build customization?

So, i think i figured out what caused the problem:

Noobish as i am i just renamed my .cpp into .cu and applied the cuda build customizations to it.
I figured that this would make sense since the docs tell that nvcc will automatically seperate the device code from the host code. Each section is then compiled by either the nvcc or the MSVS standard c++ compiler.
And if you have a .cu which is compiled with the nvcc, the nvcc will automatically include the needed headers. Since i always compiled .cu’s i never had to include any cuda specific headers…

I now seperated the cuda functionality from the Maya plugin functionality and now i can compile .cu files and .cpp and link them up properly.

Cheers,
Timm

Thanks for tip !