CUDA: Passing parameters to host compiler during Nsight session

被刻印的时光 ゝ 提交于 2019-12-24 15:34:28

问题


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?


回答1:


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

  1. In Solution Explorer Right click on the .cu file
  2. Execute Properties command
  3. 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

  1. In Solution Explorer Right click on the project (make sure this is your startup project)
  2. Execute Nsight User Properties command
  3. 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

  1. In Solution Explorer Right click on the project (make sure this is your startup project)
  2. Execute the Properties command
  3. 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.




回答2:


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.



来源:https://stackoverflow.com/questions/13081401/cuda-passing-parameters-to-host-compiler-during-nsight-session

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!