#------------------------------------------------------------------------------- # Programs and flags # Define CXX and NVCC in environment or make.inc, if needed. -include make.inc NVCC ?= nvcc CXXFLAGS = -std=c++11 -O3 -Wall -MMD NVCCFLAGS = -std=c++11 -O3 -Xcompiler "-Wall -Wno-unused-function" LDFLAGS = -std=c++11 # Compile for CUDA architecture in ${GPU_TARGET}. # (See SLATE or MAGMA Makefiles for more general code to compile for # multiple architectures.) # code=sm_XY is binary for CUDA architecture X.Y. # code=compute_XY is PTX for forward compatability for CUDA architecture >= X.Y. ifeq ("$(GPU_TARGET)","Kepler") NVCCFLAGS += -gencode arch=compute_30,code=sm_30 \ -gencode arch=compute_30,code=compute_30 endif ifeq ("$(GPU_TARGET)","Maxwell") NVCCFLAGS += -gencode arch=compute_50,code=sm_50 \ -gencode arch=compute_50,code=compute_50 endif ifeq ("$(GPU_TARGET)","Pascal") NVCCFLAGS += -gencode arch=compute_60,code=sm_60 \ -gencode arch=compute_60,code=compute_60 endif ifeq ("$(GPU_TARGET)","Volta") NVCCFLAGS += -gencode arch=compute_70,code=sm_70 \ -gencode arch=compute_70,code=compute_70 endif ifeq ("$(GPU_TARGET)","Turing") NVCCFLAGS += -gencode arch=compute_75,code=sm_75 \ -gencode arch=compute_75,code=compute_75 endif # Extract CUDADIR, assuming nvcc is installed in ${CUDADIR}/bin/nvcc, # with parallel ${CUDADIR}/include and ${CUDADIR}/lib directories. nvcc_path := ${shell which ${NVCC}} nvcc_dir := ${dir ${nvcc_path}} # %/=% strips trailing slash CUDADIR := ${dir ${nvcc_dir:%/=%}} CUDADIR := ${CUDADIR:%/=%} # CUDA libraries CPPFLAGS += -I${CUDADIR}/include LDFLAGS += -L${CUDADIR}/lib LIBS += -lcudart -lcublas -lnvToolsExt #------------------------------------------------------------------------------- # Makefile settings. .SUFFIXES: .DELETE_ON_ERROR: .SECONDARY: #------------------------------------------------------------------------------- # Files src = ${wildcard *.cc} hdr = ${wildcard *.hh} obj = ${addsuffix .o, ${basename ${src}}} dep = ${addsuffix .d, ${basename ${src}}} pch = ${addsuffix .pch, ${basename ${hdr}}} exe = ${basename ${src}} cu_src = ${wildcard *.cu} cu_hdr = ${wildcard *.cuh} cu_obj = ${addsuffix .o, ${basename ${cu_src}}} cu_exe = ${basename ${cu_src}} obj += ${cu_obj} exe += ${cu_exe} #------------------------------------------------------------------------------- # Rules all: ${exe} ${cu_exe} %: %.o ${CXX} ${LDFLAGS} ${LIBS} -o $@ $^ %.o: %.cc ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c -o $@ $< %.o: %.cu ${NVCC} ${NVCCFLAGS} ${CPPFLAGS} -c -o $@ $< # Compiler-generated header dependencies. -include ${dep} # nvcc can't take -MMD due to tmp files, so manually add dependency. ${cu_obj}: util.hh #---------- # Pre-compile headers to test for independence, not for inclusion. pch: ${pch} %.pch: %.hh ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c -o $@ $< #---------- clean: -rm -f ${exe} ${cu_exe} ${obj} ${cu_obj} ${dep} ${pch} # *.cc push: rsync -av Makefile *.hh *.cu *.sh saturn:sc19/ ornl: rsync -av Makefile *.hh *.cu *.sh ornl:sc19/ #------------------------------------------------------------------------------- # For Makefile debugging echo: @echo "CXX = '${CXX}'" @echo "NVCC = '${NVCC}'" @echo @echo "nvcc_path = '${nvcc_path}'" @echo "nvcc_dir = '${nvcc_dir}'" @echo "CUDADIR = '${CUDADIR}'" @echo "GPU_TARGET = '${GPU_TARGET}'" @echo @echo "CXXFLAGS = '${CXXFLAGS}'" @echo "NVCCFLAGS = '${NVCCFLAGS}'" @echo "CPPFLAGS = '${CPPFLAGS}'" @echo "LDFLAGS = '${LDFLAGS}'" @echo "LIBS = '${LIBS}'" @echo @echo "src = ${src}" @echo "obj = ${obj}" @echo "dep = ${dep}" @echo "exe = ${exe}" @echo @echo "hdr = ${hdr}" @echo "pch = ${pch}"