想在程序中添加标记,用nsight分析。
按照guide中说的做下面两步:
5.1 C++ Project In order to compile your project with NVTX support in Visual Studio, use the following steps to setup your project accordingly:
[list=1]
Open the project properties dialog. Navigate to Configuration Properties > C/C++ > General.
Add the following path to the Additional Include Directories: $(NVTOOLSEXT_PATH)\include Navigate to Configuration Properties > Linker > General.
Add the following path to the Additional Library Directories: $(NVTOOLSEXT_PATH)\lib$(Platform) []Navigate to Configuration Properties > Linker > Input.
Add nvToolsExt32_1.lib or nvToolsExt64_1.lib (according to your system specifications), to the Additional Dependencies.
[/list]
5.2 CUDA (.cu file)In case you use NVTX to annotate code in .cu files, please also make sure the following configuration is setup (this is in addition to the steps discussed in the previous section):
[list=1]
Open the project properties dialog. []Navigate to Configuration Properties > CUDA C/C++ > Common.
Add the following path to the Additional Include Directories: $(NVTOOLSEXT_PATH)\include
[/list]
5.3 Copying NVTX to Project(这一步说的比较含糊,没太看懂,我是把nvToolsExt64_1.lib 拷贝到运行目录下)
然后源文件中加入:
头文件:
#include <nvToolsExt.h>
代码中加入:
nvtxRangePushA(“lean_a”);
nvtxRangePop();
编译通过,运行时出现:
1>myCuda1.cu.obj : error LNK2019: 无法解析的外部符号 __imp__nvtxRangePop@0,该符号在函数 _main 中被引用
1>myCuda1.cu.obj : error LNK2019: 无法解析的外部符号 __imp__nvtxRangePushA@4,该符号在函数 _main 中被引用
1>G:\APP_CUDA\BK\ADD_BK\Debug\ADD.exe : fatal error LNK1120: 2 个无法解析的外部命令