Dubugger not working...bugger

Jul 12, 2013 at 9:46 AM
As the topic states, i cant get the debugger working. Below is the sequence of steps ive done.

Note: i have Cuda 5.0 installed and NSight visual studio edition 3.0 installed.

1) Changed code to include the following as per the instructions on the site:
            CudafyModes.Target = eGPUType.Cuda;
            CudafyModes.DeviceId = 0;
            CudafyTranslator.Language = eLanguage.Cuda;
            CudafyModule km = CudafyTranslator.Cudafy(eArchitecture.sm_20);

            //Included this line.
            CudafyTranslator.GenerateDebug = true;

            _gpu = CudafyHost.GetDevice(eGPUType.Cuda);
            _gpu.LoadModule(km);
2) Set a break point just after this.
3) Stopped debugging once break point was hit.
4) Solution Explorer, selected "Show all files" and found the "CUDAFYSOURCETEMP.cu" file.
5) Right clicked and selected "Add to project".
6) Open NSIGHT HUD Launcher 3.0.
7) Set setting as follows:

Image

8) Clicked ok.
9) Double clicked CUDAFYSOURCETEMP.cu and set a break point in the code.
10) Went to the NSight Monitor and click "NSight Monitor Ooption" -> CUDA and the set the following:

Image

11) Went back to VS2010 and selected NSight-> Start Cuda Debugging.

once thats done, i hovered the cursor over variables, once the break point has been hit, but nothing shows up. Only ones which show something are blockDim, blockIdx and threadIdx.

Ive also opened the CUDA WarpWatch1 window, typed in a variable yet thats giving the following error "Could not resolve name "num2".

Image

Am i missing a step or something??

Thanks in advance.
Jul 15, 2013 at 10:24 AM
I was looking into this a little more over the wknd and i noticed the following in the watch window when i was trying to debug the kernel.
'FrazerMann.Profiler.UserInterface.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Dynamic\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Dynamic.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
How do i change it so that it does load the symbols as well?

Thanks
Coordinator
Jul 15, 2013 at 10:37 AM
Go to Debug::Options and Settings::Debugging::General.
I do not have this checked, but cannot say if this is the issue. There could well be some kind of dependency between the VS debugger and NSight debugger. You could also try using non-dynamic launches (they do not look as good but performance especially first launch is better).
            gpu.Launch().add(2, 7, dev_c);  // dynamic
            gpu.Launch(1, 1, "add", 2, 7, dev_c); // old school
            gpu.Launch(grids, threads, ((Action<GThread, int, int, int[]>)add), 2, 7, dev_c); // strongly typed - ugly but very safe!
Jul 15, 2013 at 10:57 AM
NickKopp wrote:
Go to Debug::Options and Settings::Debugging::General.
I do not have this checked,
Im sorry what specifically are u refering to?

Below is a pic of all the available options. Ive scanned through them but none stood out as being the issue.

Image
Jul 15, 2013 at 11:23 AM
Don't you need this to generate the debug symbols?
"CudafyTranslator.GenerateDebug = true;"
Jul 15, 2013 at 11:34 AM
"gpu.Launch(grids, threads, ((Action<GThread, int, int, int[]>)add), 2, 7, dev_c); // strongly typed - ugly but very safe!"

Actually, the compiler can infer the types from the arguments, so you can simplify to

gpu.Launch(grids, threads, add, 2, 7, dev_c);
Jul 15, 2013 at 1:29 PM
Changed 1st kernel call to what Pedritolo1 said and im now getting the following error:
            CudafyModes.Target = eGPUType.Cuda;
            CudafyModes.DeviceId = 0;
            CudafyTranslator.Language = eLanguage.Cuda;
            CudafyModule km = CudafyTranslator.Cudafy(eArchitecture.sm_20);

            //Included this line.
            CudafyTranslator.GenerateDebug = true;

            _gpu = CudafyHost.GetDevice(eGPUType.Cuda);
            _gpu.LoadModule(km);
Error:
An error has occured and the operation has been terminated.
Error decompiling System.Void FrazerMann.Profiler.UserInterface.TaskManager::Kernel1(Cudafy.GThread,System.Int32[],System.Int32[],System.Int32[],System.Int64[],System.Int64[0...,0...])

Stack Trace for above error:
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDefinition methodDef, DecompilerContext context, IEnumerable1 parameters, ConcurrentDictionary2 localVariables)
at Cudafy.Translator.CUDAAstBuilder.CreateMethodBody(MethodDefinition method, IEnumerable1 parameters)
at Cudafy.Translator.CUDAAstBuilder.CreateMethod(MethodDefinition methodDef)
at Cudafy.Translator.CUDALanguage.DecompileMethod(MethodDefinition method, ITextOutput output, DecompilationOptions options)
at Cudafy.Translator.CudafyTranslator.DoCudafy(Type[] types)
at Cudafy.Translator.CudafyTranslator.Cudafy(ePlatform platform, eArchitecture arch, Version cudaVersion, Boolean compile, Type[] types)
at Cudafy.Translator.CudafyTranslator.Cudafy(eArchitecture arch)
at FrazerMann.Profiler.UserInterface.TaskManager.DataRetrieval() in C:\Users\FrazMann\Desktop\Market Adj Entry CUDA - MK2\FrazerMann.Profiler.UserInterface\System\TaskManager.cs:line 212
at FrazerMann.Profiler.UserInterface.MainView.btnEvaluation_Click(Object sender, EventArgs e) in C:\Users\FrazMann\Desktop\Market Adj Entry CUDA - MK2\FrazerMann.Profiler.UserInterface\View\MainView.cs:line 338
Inner exception:
Mono.Cecil.AssemblyResolutionException: Failed to resolve assembly: 'Cudafy.NET, Version=1.22.4875.21265, Culture=neutral, PublicKeyToken=63a4c9931616906b'
at Mono.Cecil.BaseAssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
at Mono.Cecil.DefaultAssemblyResolver.Resolve(AssemblyNameReference name)
at Mono.Cecil.MetadataResolver.Resolve(IAssemblyResolver resolver, TypeReference type)
at Mono.Cecil.MetadataResolver.Resolve(IAssemblyResolver resolver, MethodReference method)
at Mono.Cecil.MethodReference.Resolve()
at ICSharpCode.Decompiler.ILAst.ILAstProfiler.IntroducePropertyAccessInstructions(ILExpression expr, ILExpression parentExpr, Int32 posInParent)
at ICSharpCode.Decompiler.ILAst.ILAstProfiler.IntroducePropertyAccessInstructions(ILNode node)
at ICSharpCode.Decompiler.ILAst.ILAstProfiler.IntroducePropertyAccessInstructions(ILNode node)
at ICSharpCode.Decompiler.ILAst.ILAstProfiler.IntroducePropertyAccessInstructions(ILNode node)
at ICSharpCode.Decompiler.ILAst.ILAstProfiler.Optimize(DecompilerContext context, ILBlock method, ILAstOptimizationStep abortBeforeStep)
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable
1 parameters, ConcurrentDictionary2 localVariables)
at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDefinition methodDef, DecompilerContext context, IEnumerable
1 parameters, ConcurrentDictionary`2 localVariables)


If i dont clear out the debug folder which contains the .cu files after closing VS, when i reopen my solution it comes up with "Microsoft Visual studio has stopped working".
Jul 15, 2013 at 2:48 PM
I have no idea why you're getting that crazy error. But it's not related with "CudafyTranslator.GenerateDebug = true;", since this only adds an argument to nvcc. Besides, you'll have to call it before you call "CudafyTranslator.Cudafy", or else it won't do anything.
Jul 15, 2013 at 4:22 PM
Edited Jul 15, 2013 at 4:36 PM
I modified the code so it calls the
CudafyTranslator.GenerateDebug = true;
before
CudafyModule km = CudafyTranslator.Cudafy(eArchitecture.sm_20);
Also changed the option in debugger so that Tools-> Options -> Debugging "Just enable my code" is not selected.

Note: After changing this + remembering to click the Nsight icon in solution explorer...D'oh, it seems to work now :)

Thanks guys
Jul 15, 2013 at 5:37 PM
Good to hear. Make sure to disable CudafyTranslator.GenerateDebug once you no longer need it, since it seriously degrades performance.
Feb 7, 2014 at 4:18 PM
Hello,

I followed the described setup of Nsight: I've installed 3.2.2 version and I am using it with VS2012.
I could not debug the CUDAFYSOURCETEMP.cu file (I've unticked the the "Enable Just My Code" from the debugging options).
When I hoover over the breakpoint, the following text is shown: "Did you enable GPU Debug information in your project"? :-( I hope, I did not: I've set it before initilaizing the km module.

If I hit F5 and after a breakpoint before gpu.LoadModule(km) and I start the CUDA debugging, I've got a popup messagebox with "The debugger cannot continue running the process."
And there is an another message in the VS2012 workspace with the title: Source not available: Code not running - The current thread is not currently running code or the call stack could not be obtanied.

What have I missed?

Coud you please help me resolve this debugging issue?

Thanks in advance!
Br,
Peter
Coordinator
Feb 7, 2014 at 6:24 PM
Peter,
Difficult to say because I have never seen these issues. There are so many settings in Visual Studio and NSight. As with most problems in CUDAfy, it is most important to first ensure that CUDA/Nsight is working correctly. Can you debug a pure CUDA application? When this is working then progress to CUDAfy.
Best regards,
Nick
Feb 8, 2014 at 8:27 PM
Nick,
I was wrong hitting F5 - I have to only hit Start Cuda Debugging.
Br,
Peter