Skip to content

Commit 52b16fa

Browse files
authored
NVTX3 and NSight Systems update. (#54)
1 parent 3a495ce commit 52b16fa

File tree

4 files changed

+42
-7
lines changed

4 files changed

+42
-7
lines changed

posts/nvtx/Makefile

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,24 @@ CC=gcc
2828
CXX=g++
2929
NVCC=nvcc
3030

31+
NVTX_INCLUDE ?= $(CUDA_HOME)/include
32+
3133
BINARIES=manual_nvtx compiler_inst_nvtx
3234

3335
all: $(BINARIES)
3436

3537
inst_nvtx.o: inst_nvtx.cpp Makefile
36-
g++ -export-dynamic -fPIC -I${CUDA_ROOT}/include -c inst_nvtx.cpp
38+
g++ -export-dynamic -fPIC -I$(NVTX_INCLUDE) -c inst_nvtx.cpp
3739

3840
manual_nvtx: manual_nvtx.cu Makefile
39-
nvcc -Xcompiler -export-dynamic -DUSE_NVTX -lnvToolsExt -o manual_nvtx manual_nvtx.cu
41+
nvcc -Xcompiler -export-dynamic -DUSE_NVTX -ldl -o manual_nvtx manual_nvtx.cu
4042

4143
compiler_inst_nvtx: compiler_inst_nvtx.cu Makefile inst_nvtx.o
42-
nvcc -Xcompiler -export-dynamic -Xcompiler -fPIC -Xcompiler -finstrument-functions inst_nvtx.o -ldl -lnvToolsExt -o compiler_inst_nvtx compiler_inst_nvtx.cu
44+
nvcc -Xcompiler -export-dynamic -Xcompiler -fPIC -Xcompiler -finstrument-functions inst_nvtx.o -ldl -o compiler_inst_nvtx compiler_inst_nvtx.cu
4345

4446
clean:
4547
rm -f *.o $(BINARIES)
4648

4749
run: $(BINARIES)
48-
nvprof -o compiler_inst_nvtx.nvvp ./compiler_inst_nvtx
49-
nvprof -o manual_nvtx.nvvp ./manual_nvtx
50+
nsys profile --trace=cuda,nvtx -o compiler_inst_nvtx ./compiler_inst_nvtx
51+
nsys profile --trace=cuda,nvtx -o manual_nvtx ./manual_nvtx

posts/nvtx/env_hpc_sdk.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright (c) 2024, NVIDIA CORPORATION. All rights reserved.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions
5+
# are met:
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
# * Redistributions in binary form must reproduce the above copyright
9+
# notice, this list of conditions and the following disclaimer in the
10+
# documentation and/or other materials provided with the distribution.
11+
# * Neither the name of NVIDIA CORPORATION nor the names of its
12+
# contributors may be used to endorse or promote products derived
13+
# from this software without specific prior written permission.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
if [ -v HPCSDK_RELEASE ]; then
28+
echo "Running with NVIDIA HPC SDK"
29+
if [ ! -v CUDA_HOME ] || [ ! -d ${CUDA_HOME} ]; then
30+
export CUDA_HOME=$(nvc++ -cuda -printcudaversion |& grep "CUDA Path" | awk -F '=' '{print $2}')
31+
echo "Setting CUDA_HOME=${CUDA_HOME}"
32+
fi
33+
fi

posts/nvtx/inst_nvtx.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*/
2727

2828
#include <stdio.h>
29-
#include "nvToolsExt.h"
29+
#include "nvtx3/nvToolsExt.h"
3030
#include <dlfcn.h>
3131
#include <cxxabi.h>
3232

posts/nvtx/manual_nvtx.cu

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <cstdio>
2929

3030
#ifdef USE_NVTX
31-
#include "nvToolsExt.h"
31+
#include "nvtx3/nvToolsExt.h"
3232

3333
const uint32_t colors[] = { 0xff00ff00, 0xff0000ff, 0xffffff00, 0xffff00ff, 0xff00ffff, 0xffff0000, 0xffffffff };
3434
const int num_colors = sizeof(colors)/sizeof(uint32_t);

0 commit comments

Comments
 (0)