Broad-Phase Collision Detection with CUDA not working Demo program from GPU Gems3 DVD . Part V . Cha

hello , first i need to mention that i`m new to this stuff.

so i found this book , GPU Gems 3 ( http://developer.nvidia.com/object/gpu-gems-3.html ) and also the DVD which contains sample code and demonstrations for many of the book’s chapters, as provided by the contributors. the most interesting subject/part, that i found in this book is in PART V . Chapter 33. LCP Algorithms for Collision Detection Using CUDA . and there is this demo on the DVD , on this subject/chapter ( the application should look like this http://http.developer.nvidia.com/GPUGems3/…nks/33fig07.jpg ) and i also found this demo on the author`s web site , available for download http://www.kipfer.de/media/GPUGems3.zip

the problem is that i cant run it, i tried running the executable files found in the /Windows folder , but i get the error : "The program cant start because cuda.dll is missing from your computer. Try reinstalling the program to fix this problem" .

so i tried compiling the project , but i get 7 errors and 1 warning :

Error 2 error: too few arguments in function call c:\Users\gogira\Desktop\source\solver.cu 950 LCPDemo

  • on this line : CUresult err = cuInit();

Error 3 error: argument of type “CUdevice” is incompatible with parameter of type “CUcontext *” c:\Users\gogira\Desktop\source\solver.cu 972 LCPDemo
-on this line : CU_SAFE_CALL( cuCtxCreate(dev) );

Error 4 error: too few arguments in function call c:\Users\gogira\Desktop\source\solver.cu 972 LCPDemo
-on this line : CU_SAFE_CALL( cuCtxCreate(dev) );

Error 5 error: too few arguments in function call c:\Users\gogira\Desktop\source\solver.cu 1101 LCPDemo
-on this line : CU_SAFE_CALL( cuCtxDetach() );

Error 6 error: identifier “cuMemAllocSystem” is undefined c:\Users\gogira\Desktop\source\solver.cu 1322 LCPDemo
-on this line : CU_SAFE_CALL( cuMemAllocSystem( (void**)&mem, s ) );

Error 7 error: identifier “cuMemFreeSystem” is undefined c:\Users\gogira\Desktop\source\solver.cu 1333 LCPDemo
-on this line : CU_SAFE_CALL( cuMemFreeSystem(mem) );

Error 8 error PRJ0019: A tool returned an error code from “Performing Custom Build Step” LCPDemo LCPDemo
-on this line : CU_SAFE_CALL( cuMemFreeSystem(mem) );

if anyone could help me on this one , please do , i really need to make this work , im studing this example for a school project . ive just started looking in the CudaReferenceManual , and trying to fix the errors myself…

but im also thinking the code is right , because its been released on a dvd and maybe i`ve got to modify some settings, or copy some files , or something …

i forgot to mention that i`m using ms visual studio 2008 , installed the newest gpu driver (i ve got a nvidia gt 320 m) , downloaded and installed the latest versions of the cuda toolkit ( 3.1 x64) and sdk , i ran the bandwidth test and also built and ran the bandwidth project , and they worked ok.

That code is pretty old, it looks like it was compiled against CUDA 1.0 or earlier.

There have been a few changes to the API since then - you need to either compile with an old verison of CUDA, or update the code to the new API (which shouldn’t be too difficult).

i managed to update the code to correspond to the new API , here`s what i modified :

CUresult err = cuInit(); —> CUresult err = cuInit(0);

CU_SAFE_CALL( cuCtxCreate(dev) ); —> CU_SAFE_CALL( cuCtxCreate(&contu, 0 , dispo) ); //CUdevice dispo; // CUcontext contu;

CU_SAFE_CALL( cuCtxDetach() ); —> CU_SAFE_CALL(cuCtxDetach(contu)); // i had to declare CUcontu global or else it gave an error saying it`s undefined

CU_SAFE_CALL( cuMemAllocSystem( (void**)&mem, s ) ); --> CU_SAFE_CALL( cuMemAllocHost( (void**)&mem, s ) );

CU_SAFE_CALL( cuMemFreeSystem(mem) ); --> CU_SAFE_CALL( cuMemFreeHost(mem) );

but now , after fixing the last error , when i`m trying to build the project , i recive 100+ errors in vector_types.h , cuda_runtime_api.h , crtdefs.h , vadefs.h :confused:

some examples :

Error 3 error C2059: syntax error : ‘string’ c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vadefs.h 50 LCPDemo
on this line : typedef unsigned __int64 uintptr_t;

Error 4 error C2059: syntax error : ‘string’ c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vadefs.h 61 LCPDemo
on this line : typedef char * va_list;

Error 6 error C2061: syntax error : identifier ‘dim3’ c:\cuda\include\vector_types.h 473 LCPDemo
on this line : host device dim3(unsigned int vx = 1, unsigned int vy = 1, unsigned int vz = 1) : x(vx), y(vy), z(vz) {}


Error 105 fatal error C1003: error count exceeds 100; stopping compilation c:\cuda\include\cuda_runtime_api.h 251 LCPDemo

i think it`s some kind of linker error … but i looked and everything seems good…
why is this happening ? what should i do ?

i managed to update the code to correspond to the new API , here`s what i modified :

CUresult err = cuInit(); —> CUresult err = cuInit(0);

CU_SAFE_CALL( cuCtxCreate(dev) ); —> CU_SAFE_CALL( cuCtxCreate(&contu, 0 , dispo) ); //CUdevice dispo; // CUcontext contu;

CU_SAFE_CALL( cuCtxDetach() ); —> CU_SAFE_CALL(cuCtxDetach(contu)); // i had to declare CUcontu global or else it gave an error saying it`s undefined

CU_SAFE_CALL( cuMemAllocSystem( (void**)&mem, s ) ); --> CU_SAFE_CALL( cuMemAllocHost( (void**)&mem, s ) );

CU_SAFE_CALL( cuMemFreeSystem(mem) ); --> CU_SAFE_CALL( cuMemFreeHost(mem) );

but now , after fixing the last error , when i`m trying to build the project , i recive 100+ errors in vector_types.h , cuda_runtime_api.h , crtdefs.h , vadefs.h :confused:

some examples :

Error 3 error C2059: syntax error : ‘string’ c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vadefs.h 50 LCPDemo
on this line : typedef unsigned __int64 uintptr_t;

Error 4 error C2059: syntax error : ‘string’ c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\vadefs.h 61 LCPDemo
on this line : typedef char * va_list;

Error 6 error C2061: syntax error : identifier ‘dim3’ c:\cuda\include\vector_types.h 473 LCPDemo
on this line : host device dim3(unsigned int vx = 1, unsigned int vy = 1, unsigned int vz = 1) : x(vx), y(vy), z(vz) {}


Error 105 fatal error C1003: error count exceeds 100; stopping compilation c:\cuda\include\cuda_runtime_api.h 251 LCPDemo

i think it`s some kind of linker error … but i looked and everything seems good…
why is this happening ? what should i do ?

i also tried the other way , i installed the oldest cuda toolkit 1.1 + SDK , but this also gives me an error : A tool returned an error code from “Performing Custom Build Step”

… this is my Configuration Properties → Custom Build Step → General:
Command Line =
“$(CUDA_BIN_PATH)\nvcc.exe” -ccbin “$(VCInstallDir)bin” -c -D_DEBUG -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/Od,/Zi,/MTd -I”$(CUDA_INC_PATH)” -I./ -o $(ConfigurationName)\lcp.obj lcp.cu

Configuration Properties → Custom Build Step → General:
Outputs = $(ConfigurationName)\lcp.obj

and the project settings :
Configuration Properties → C/C++ → General:
Additional Include Directories = $(CUDA_INC_PATH);”C:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\common\inc”

Configuration Properties → C/C++ → General:
Debug Information Format = Program Database (/Zi)

Configuration Properties → C/C++ → Code Generation:
Runtime Library = Multi-threaded Debug (/MTd)

Configuration Properties → Linker → General:
Enable incremental linking = No (/INCREMENTAL:NO)

Configuration Properties → Linker -> General:
Additional Library Directories = “C:\CUDA\lib”;”C:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\common\lib”

Configuration Properties → Linker → Input:
Additional Dependencies = cudart.lib cutil32D.lib

Configuration Properties → Linker → Optimization:
Enable COMDAT folding = Do Not Remove Redundant COMDATs (/OPT:NOICF)

please if you have any suggestions let me know … i really need to make this work … it`s for my summer school practice :|

i also tried the other way , i installed the oldest cuda toolkit 1.1 + SDK , but this also gives me an error : A tool returned an error code from “Performing Custom Build Step”

… this is my Configuration Properties → Custom Build Step → General:
Command Line =
“$(CUDA_BIN_PATH)\nvcc.exe” -ccbin “$(VCInstallDir)bin” -c -D_DEBUG -DWIN32 -D_CONSOLE -D_MBCS -Xcompiler /EHsc,/W3,/nologo,/Wp64,/Od,/Zi,/MTd -I”$(CUDA_INC_PATH)” -I./ -o $(ConfigurationName)\lcp.obj lcp.cu

Configuration Properties → Custom Build Step → General:
Outputs = $(ConfigurationName)\lcp.obj

and the project settings :
Configuration Properties → C/C++ → General:
Additional Include Directories = $(CUDA_INC_PATH);”C:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\common\inc”

Configuration Properties → C/C++ → General:
Debug Information Format = Program Database (/Zi)

Configuration Properties → C/C++ → Code Generation:
Runtime Library = Multi-threaded Debug (/MTd)

Configuration Properties → Linker → General:
Enable incremental linking = No (/INCREMENTAL:NO)

Configuration Properties → Linker -> General:
Additional Library Directories = “C:\CUDA\lib”;”C:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\common\lib”

Configuration Properties → Linker → Input:
Additional Dependencies = cudart.lib cutil32D.lib

Configuration Properties → Linker → Optimization:
Enable COMDAT folding = Do Not Remove Redundant COMDATs (/OPT:NOICF)

please if you have any suggestions let me know … i really need to make this work … it`s for my summer school practice :|

Hi,

Does someone have the updated version of this program? I’m receiving the exact errors as mentioned above.

Apart from that, it is impossible for me to find good working examples of collision detection under latest CUDA versions (I’m running CUDA 5.5). Maybe someone could assist with some useful link? Right now I know a little about OpenGL and would like to study the CUDA OpenGL interoperability.

Thanks!