CUDA 5 NSIGHT set compilation flag - cuda

In order to compile project for Kepler K20 we need to set -rdc=true flag. How can we set this flag in nsight eclipse edition? my version is CUDA 5.K20. nsight eclipse edition

To enable separate compilation in Nsight Eclipse Edition:
Open project properties
In the left-hand tree, select "Build"/"CUDA"
Select "Separate Compilation" radio button at the top of the page.
Clean the project and rebuild.
This way Nsight will specify -rdc=true both to the compiler and linker.

For additional options like -rdc, you could add them directly in the command line of the compiler settings.
In your Nsight,
Project menu -> Properties -> Build -> Settings -> Tool Settings -> NVCC Compiler
append -rdc=true to either the string of "Command" or the string of "Command line pattern"
You may also need to append this option to the NVCC linker command.

Related

Nsight Eclipse Edition 7.5 add compile command to link library

I would like to link the cusparse library using -lcusparse for the nvcc complier in Nsight, i.e. something like this
nvcc test_sparse.cu -lcusparse -o test_CUSPARSE.
Where exactly can I add this in Nsight 7.5, I only found explanations for older versions.
You could find it here if you are not using makefile project.
Project Properties -> Build -> Settings -> Tool Settings -> NVCC Linker -> Libraries

nvprof on a binary file

I have a binary of my program which is generated with nvcc compiler. I want to profile it with nvprof. I tried with nvprof ./a.out and it shows seconds for each function. While this is good for me, I want to see timeline of my application. I could have easily done this thing, if I was building my project with Nsight but unfortunately I can't do that. So, how can I invoke nvprof program outside Nsight in order to see timeline of my application?
Several ways that you can see the timeline:
In Nsight, click the profile button after compiling;
Use standalone GUI profile tool nvvp in CUDA, which can be launched by the following cmdline if /usr/local/cuda/bin (default CUDA installation binary dir) is in your $PATH. You can then lanuch your a.out in nvvp GUI to profile it and display the timeline.
$ nvvp
Use cmdline tool nvprof with -o option to generate the result file, which can be imported by Nsight and/or nvvp to display the timeline. the user manual of nvprof provides more details.
$ nvprof -o profile.result ./a.out

Cuda/output of nsight different from the command line (nvcc ) output

I run code using nvcc command and it gave correct output but when I run the same code on the nsight eclipse it gave wrong output. Any one have any idea why is this behavior.
Finally I found there is problem in one of the array allocation.While the command line doesn't make any problem the nsight does.
Nsight EE builds the projects by generating make files based on the project settings and by invoking the OS make utility to build the project. It is using nvcc compiler found in the PATH but it relies on some newer options introduced in NVCC compiler 5.0 (that is a part of the same toolkit distribution).
Please do a clean rebuild in Nsight Eclipse - it will print out the command lines used to build your application. Then you can compare that command line with the one you use outside. Possible differences are:
Nsight specifies debug flags and optimization flag when building in debug and release modes.
By default, Nsight sets the new project to build for the hardware detected on your system. NVCC default is SM 1.0.
Make sure the compiler used by Nsight and from the command line are one and the same. It is possible that you have different compilers (e.g. 4.x and 5.0) installed on your system that may generate a slightly different code.
In any case, it is likely your code has some bug that manifests itself under different compilation settings. I would recommend running CUDA memcheck on you program to ensure there is no hidden bugs.

CUDA: Passing parameters to host compiler during Nsight session

I have a cuda (v4.2) program running under visual studio 2010, to which I pass various command line parameters. I want the host compiler to see the same parameters when I run through nsight (v2.2). I assume I have to do this via (right click project) -> nsight user settings->command line arguments, but haven't yet managed to find a syntax that doesn't crash nvcc. I'm assuming it's arranged around "--run-args " somehow?
** Clarification, after comment below:
Sure when you debug straight through VS, you enter your command arguments through the property pages/command arguments, and that all works fine. But through NSight, that gets ignored, so my question is, how to do it? My talk of compilers assumes that nsight runs up NVCC, which then invokes MSVC under the covers for non CUDA code. So I assume that NSight needs to pass any command line parameters down into VS, presumably via the options described above. Assuming all that is reasonable, I suspect I'm simply getting the syntax wrong inside "nsight user settings->command line arguments" and was wondering if anyone else has succeeded here. Clearer?
It is unclear if you are trying to pass command line arguments through nvcc to cl.exe or pass command line arguments to your application when it is launched through Visual Studio with the command Nsight CUDA Debugger (Nsight|Start CUDA Debugging).
To pass command line arguments to cl.exe when compiling a .cu file to cl.exe
In Solution Explorer Right click on the .cu file
Execute Properties command
In the "filename.cu" Property Pages
a. In the left pane Select "CUDA C/C++"\"Host"
b. Add parameters to pass to cl.exe in "Additional Compiler Options" or "Preprocessor Definitions"
Preprocessor definitions will go to both nvcc.exe and cl.exe.
Additional Compiler Options will be appended to -Xcompiler options.
To pass command line arguments to your application when it is launched using Nsight|Start CUDA Debugging
In Solution Explorer Right click on the project (make sure this is your startup project)
Execute Nsight User Properties command
In the "NVIDIA NSight User Settings: " dialog
a. In the left pane select "Launch"
b. In the right specify arguments in the field "Command line arguments".
These options will be passed to the application when you launch the application with (Nsight|Start CUDA Debugging).
To pass command line arguments to your application when it is launched using Debug|Start * Debugging
In Solution Explorer Right click on the project (make sure this is your startup project)
Execute the Properties command
In the " Property Pages" dialog
a. In the left pane select "Debugging"
b. In the right pane add arguments to the field "Command Arguments"
When editing project Properties and Nsight User Properties make sure to specify the Configuration and Platform at the top of the dialog.
Nsight VSE build system does not use the nvcc --run and --run-args options. If you launch using a Debug command your process will be launched by devenv.exe. If you launch using Nsight|Start CUDA Debugging or Nsight Analysis Tools your application will be launched by Nsight.Monitor.exe.
i would like to help but i am confused; you talk about passing run-time arguments to your host code under VS. then you say you want the compiler to see the same parameters. i think you dont mean compiler. build your project first in VS (using the Debug version of your build). (and I already compile my .cu into a ptx file so nvcc doesnt get invoked when i go into Nsight. ) Then this build runs when you invoke Nsight. I have not had to provide run time arguments. there is a place in the VS project under Debug to give command line arguments; maybe this is used when Nsight starts although i have my doubts. Also, there is the Nsight user -> command line arguments input you cite. I would think the latter is indeed the correct way to do it. perhaps your problem is that you need to fully build the project before you start Nsight.

breakpoints in cuda do not work!

with a very simple code, hello world, the breakpoint is not working.
I can't write the exact comment since it's not written in English,
but it's like 'the symbols of this document are not loaded' or something.
there's not cuda codes, just only one line printf in main function.
The working environment is windows7 64bit, vc++2008 sp1, cuda toolkit 3.1 64bits.
Please give me some explanation on this. :)
So this is just a host application (i.e. nothing to do with CUDA) doing printf that you can't debug? Have you selected "Debug" as the configuration instead of "Release"?
Are you trying to use a Visual Studio breakpoint to stop in your CUDA device code (.cu)? If that is the case, then I'm pretty sure that you can't do that. NVIDIA has released Parallel NSIGHT, which should allow you to do debugging of CUDA device code (.cu), though I don't have much experience with it myself.
Did you compile with -g -G options as noted in the documentation?
NVCC, the NVIDIA CUDA compiler driver, provides a mechanism for generating the debugging information necessary for CUDA-GDB to work properly. The -g -G option pair must be passed to NVCC when an application is compiled for ease of debugging with CUDA-GDB; for example,
nvcc -g -G foo.cu -o foo
here: https://docs.nvidia.com/cuda/cuda-gdb/index.html