2021-05-05 08:23:57 +00:00
i f n d e f C U D A _ H O M E
CUDA_HOME := /usr/local/cuda
e n d i f
i f n d e f E X E R C I S E
EXERCISE = exercise1.cu
e n d i f
BUILD_DIR ?= ./build
NVCC = $( CUDA_HOME) /bin/nvcc
CXX = g++
OPT := -O2 -g
2022-05-17 13:43:44 +00:00
NVOPT := -Xcompiler -fopenmp -lineinfo ` pkg-config --cflags --libs opencv4`
2021-05-05 08:23:57 +00:00
CXXFLAGS := $( OPT) -I. $( EXT_CXXFLAGS)
LDFLAGS := -lm -lcudart $( EXT_LDFLAGS)
NVCFLAGS := $( CXXFLAGS) $( NVOPT)
NVLDFLAGS := $( LDFLAGS) -lgomp
SRCS := utils.c
OBJS := $( SRCS:%= $( BUILD_DIR) /%.o) $( EXERCISE:%= $( BUILD_DIR) /%.o)
EXE = $( EXERCISE:.cu= .exe)
$(EXE) : $( OBJS )
$( MKDIR_P) $( dir $@ )
$( NVCC) $( NVCFLAGS) $( OBJS) -o $@ $( NVLDFLAGS)
$(BUILD_DIR)/%.cu.o : %.cu
$( MKDIR_P) $( dir $@ )
$( NVCC) $( NVCFLAGS) -c $< -o $@
$(BUILD_DIR)/%.cpp.o : %.cpp
$( MKDIR_P) $( dir $@ )
$( CXX) $( CXXFLAGS) -c $< -o $@
$(BUILD_DIR)/%.c.o : %.c
$( MKDIR_P) $( dir $@ )
$( CXX) $( CXXFLAGS) -c $< -o $@
all : $( EXE )
.PHONY : run profile clean
run : $( EXE )
./$( EXE)
profile : $( EXE )
2022-11-25 14:29:06 +00:00
sudo LD_LIBRARY_PATH = $( CUDA_HOME) /lib:/usr/ext/lib:${ LD_LIBRARY_PATH } LIBRARY_PATH = /usr/ext/lib:${ LIBRARY_PATH } $( CUDA_HOME) /bin/nvprof --unified-memory-profiling off ./$( EXE)
2021-05-05 08:23:57 +00:00
metrics : $( EXE )
2022-11-25 14:29:06 +00:00
sudo LD_LIBRARY_PATH = $( CUDA_HOME) /lib:/usr/ext/lib:${ LD_LIBRARY_PATH } LIBRARY_PATH = /usr/ext/lib:${ LIBRARY_PATH } $( CUDA_HOME) /bin/nvprof --print-gpu-trace --metrics "eligible_warps_per_cycle,achieved_occupancy,sm_efficiency,ipc" ./$( EXE)
2021-05-05 08:23:57 +00:00
clean :
-rm -fr $( BUILD_DIR) *.exe *.out *~
MKDIR_P ?= mkdir -p