-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (42 loc) · 1.2 KB
/
Makefile
File metadata and controls
55 lines (42 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# Detect OS and set executable extension
ifeq ($(OS),Windows_NT)
EXE_EXT = .exe
else
EXE_EXT =
endif
CUDA_PATH ?= /usr/local/cuda
HOST_COMPILER = g++
NVCC = $(CUDA_PATH)/bin/nvcc -ccbin $(HOST_COMPILER)
# select one of these for Debug vs. Release
NVCC_DBG = -g -G -m64
NVCC_RELEASE = -O3 -lineinfo -m64
# NVCCFLAGS = $(NVCC_DBG)
NVCCFLAGS = $(NVCC_RELEASE)
GENCODE_FLAGS = -gencode arch=compute_89,code=sm_89
REPORT_DIR = reports
NSYS = $(CUDA_PATH)/bin/nsys
NCU = $(CUDA_PATH)/bin/ncu
TAG ?= run
cpuart: main.cpp
$(HOST_COMPILER) -o cpuart$(EXE_EXT) main.cpp
cudart: main.cu
$(NVCC) $(NVCCFLAGS) $(GENCODE_FLAGS) -o cudart$(EXE_EXT) main.cu
$(REPORT_DIR):
mkdir -p $(REPORT_DIR)
profile_basic: cudart | $(REPORT_DIR)
$(NSYS) profile \
-t cuda \
--stats=true \
-o $(REPORT_DIR)/nsys_$(TAG) \
./cudart$(EXE_EXT) > out.ppm
profile_compute: cudart | $(REPORT_DIR)
$(NCU) \
-o $(REPORT_DIR)/ncu_$(TAG) \
./cudart$(EXE_EXT) > out.ppm
profile_metrics: cudart | $(REPORT_DIR)
$(NCU) \
--metrics achieved_occupancy,inst_executed,inst_fp_32,inst_fp_64,inst_integer \
-o $(REPORT_DIR)/ncu_metrics_$(TAG) \
./cudart$(EXE_EXT) > out.ppm
clean:
rm -f cudart$(EXE_EXT) cpuart$(EXE_EXT) out.ppm out.jpg