开发者

Debuging CUDA kernels called from .NET code in VS2008, emulation mode

CUDA has an option to compile code in emulation mode, which is supported in the .rules file they provide.

I have C# .NET 3.5 SP1 code that calls a native dll, using DllImport, the native dll is compiled via VS2008 using nvcc and its function is to transfer memory from and to CUDA and to invoke CUDA kernels.

When the CUDA kernels are correct, everything runs fine, but when there is a bug, I can only step in to the code until the title of the kernels and see the parameters they receive. (I enabled debugging native code in the startup-project's debug options.)

I have tried compiling with emulation mode, however I get the CUDA error "mixed device execution" when calling the CUDA memcopy host-->device. I tried switching the alloc+deallo开发者_StackOverflow中文版c+memcopy with their equivalent non-CUDA versions, but then the same error occurs when invoking the kernels.

What did I do wrong in my attempt to using the debug-emulation mode?

P.S. I tried this on Vista x64 SP1 + VS2008, with the same solution complied in both x86 and x64, neither worked in emulation mode, both worked in non-emulation mode.


From the CUDA Programming Guide p44:

When compiling an application in this mode (using the -deviceemu option), the device code is compiled for and runs on the host, allowing the programmer to use the host’s native debugging support to debug the application as if it were a host application. The preprocessor macro DEVICE_EMULATION is defined in this mode. All code for an application, including any libraries used, must be compiled consistently either for device emulation or for device execution. Linking code compiled for device emulation with code compiled for device execution causes the following runtime error to be returned upon initialization: cudaErrorMixedDeviceExecution.

Do you just have a single DLL which you've recompiled for EMU or are there other DLLs which aren't for example the CUDA utils library?

This works as I'd expect on Win7 x64 compiling Debug|x86 with EMU enabled.

Here are the compiler and linker settings I'm using:

 "C:\Program Files\CUDA\bin64\nvcc.exe"   -m32 -arch sm_10 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -deviceemu -D_DEVICEEMU   -Xcompiler "/EHsc /W3 /nologo /Od /Zi   /MT  "  -maxrregcount=32  --compile -o "int\x86\Debug\NBody.DomainModel.Native.cu.obj" "c:\Src\NBody\trunk\NBody.DomainModel.Native\NBody.DomainModel.Native.vcproj"

/VERBOSE /OUT:"c:\Src\NBody\trunk\NBody.DomainModel.Native\bin\x86\Debug\NBody.DomainModel.Native.dll" /INCREMENTAL /NOLOGO /LIBPATH:"C:\Program Files\CUDA\lib64\..\lib" /DLL /MANIFEST /MANIFESTFILE:"int\x86\Debug\NBody.DomainModel.Native.dll.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /NODEFAULTLIB:"libcmt" /DEBUG /ASSEMBLYDEBUG /PDB:"c:\Src\NBody\trunk\NBody.DomainModel.Native\bin\x86\Debug\NBody.DomainModel.Native.pdb" /DYNAMICBASE /FIXED:No /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT cudart.lib


The issue was caused by a missing build event to copy the SDK emulation DLLS (only the TOOLKIT DLLs were copied) and a few regular libs instead of emulation libs.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜