Windows DLL debug problems debugging a DLL

Hi,

I am writting a DLL with MSVC8. I recently switched from cuda 2.0 to 2.3 and since then I cannot run in debug mode properly : the values of the variable in the debugger are completely wrong. I already met that trouble before, it was due to some options that were different in the C++ and NVCC compilers. Now I tried many options, I didn’t find the solution. Here are the command lines :

C++

/O2 /I “C:\CUDA\include” /I “./” /I “C:\Program Files\NVIDIA Corporation\NVIDIA CUDA SDK\common\inc” /I “C:\Program Files\GnuWin32\include” /D “WIN32” /D “_DEBUG” /D “_CONSOLE” /D “_VC80_UPGRADE=0x0710” /D “_WINDLL” /D “_UNICODE” /D “UNICODE” /FD /EHsc /MTd /Fo"Debug\" /Fd"Debug\vc80.pdb" /W3 /nologo /c /Zi /errorReport:prompt

NVCC : (using build rule v2.3)
“C:\CUDA\bin\nvcc.exe” -arch sm_10 -ccbin “C:\Program Files\Microsoft Visual Studio 8\VC\bin” -use_fast_math -Xcompiler "/EHsc /W3 /nologo /O2 /Zi /MTd " -maxrregcount=32 --compile -o “Debug\template.cu.obj” “c:\Dev\CUDA\CUDAFDK\template.vcproj”

Any suggestion is very welcome !!

OK I found an issue :

change the basic runtime check from default to a given value (i.e. /RTCs) in both compilers.

if it can help someone someday…

I have question concerning the SDK though : why is there no DEBUG project ?? :">

I looked at your nvcc build rule and did not see anything like -shared or -lib. Can you tell me how you are creating a windows cuda dll?

and me. How can i make dll project which include *.cu files arn reference to cuda.dll ?
In Cuda Wizard for MVS there is only CUDAwinAPP. May be is other Cuda wizard exists?

Actually I don’t use the CUDA wizard. I create a DLL with MSVC and then add to the project the various cpp, h, and cu files. You have to set the build rules to CUDA build rules for .cu files in not set automatically, and excude from build the kernel files.

I hope it helps…

[url=“The Official NVIDIA Forums | NVIDIA”]http://forums.nvidia.com/index.php?showtopic=97928[/url] the answer is here

but i tryed to use “-lib” option of NVCC ang got *.lib library with cuda function inside

Thanks for identifying the other forum discussion. I will try this.

Take care.

Now I have a new funny trouble :

I created a DLL using with MSVC. I works fine from a MFC test application (also compiled in MSVC). Now the same DLL shows strange behaviour when called from a QT test application, compiled with MinGW. In short, the GPU seems to keep some values from one call to another. I am not using any particular initialization of the GPU (I just call cudaSetDevice). Should I ?

Now I have a new funny trouble :

I created a DLL using with MSVC. I works fine from a MFC test application (also compiled in MSVC). Now the same DLL shows strange behaviour when called from a QT test application, compiled with MinGW. In short, the GPU seems to keep some values from one call to another. I am not using any particular initialization of the GPU (I just call cudaSetDevice). Should I ?

Hey)))) Brother. I got this troble 5 min ago)))

Hey)))) Brother. I got this troble 5 min ago)))

External Media Cool ! I feel less lonely ! It doesn’t help us much, though… Let’s keep in touch !

External Media Cool ! I feel less lonely ! It doesn’t help us much, though… Let’s keep in touch !

OK i done it.
dll from MVS2008 (used getcudaparam memcpy and cufft) worked in Qt (windows with mingw).

the point: i use emulation mode (have no CUDA videocerd on laptop) in comand line
nvcc -deviceemu -I"$(CUDA_INC_PATH)" -c -o $(ConfigurationName)\dll.obj dll.dll
and linc to “cufftemu.lib”

after compilation i load my dll in *.pro file in Qt project
and use my function in main.cpp.

You can try to use my we.dll

add in pro file destination of dll, and put dll in dir where is .exe.

HEADERS += cuda_runtime.h \

cufft.h

LIBS += c:\FFTW\qw.dll
eth_project.zip (47.8 KB)

OK i done it.
dll from MVS2008 (used getcudaparam memcpy and cufft) worked in Qt (windows with mingw).

the point: i use emulation mode (have no CUDA videocerd on laptop) in comand line
nvcc -deviceemu -I"$(CUDA_INC_PATH)" -c -o $(ConfigurationName)\dll.obj dll.dll
and linc to “cufftemu.lib”

after compilation i load my dll in *.pro file in Qt project
and use my function in main.cpp.

You can try to use my we.dll

add in pro file destination of dll, and put dll in dir where is .exe.

HEADERS += cuda_runtime.h \

cufft.h

LIBS += c:\FFTW\qw.dll

Thanks for your feedback !

A few questions though : why do you need to include cudaruntime and cufft header file in you project ? I they are called only from the DLL, they should be included only in the DLL project …?

I already had troubles between QT and MSVC code in the past, due to compiler specific coding for std::string type. I had to remove all use of strings in the communication between the application and the DLL.

Thanks for your feedback !

A few questions though : why do you need to include cudaruntime and cufft header file in you project ? I they are called only from the DLL, they should be included only in the DLL project …?

I already had troubles between QT and MSVC code in the past, due to compiler specific coding for std::string type. I had to remove all use of strings in the communication between the application and the DLL.

OK, I found the bug. I had a very ugly static variable somewhere in the DLL… External Image External Image

OK, I found the bug. I had a very ugly static variable somewhere in the DLL… External Image External Image

my source is test version, headers (cufft cudart) remained from past.
sudoca we have the path to work with cuda in Qt project now that is cool.