Page MenuHomec4science

Makefile.GPU.gnu
No OneTemporary

File Metadata

Created
Mon, Nov 25, 05:33

Makefile.GPU.gnu

#
PROGRAM_NAME := liblenstoolhpc_GPU.so
#all: $(PROGRAM_NAME_GPU) $(PROGRAM_NAME)
all: $(PROGRAM_NAME) $(PROGRAM_NAME_GPU)
#CXX=g++ -lm -ffast-math -ftree-loop-vectorize
#CXX=icpc
#
program_CXX_SRCS := $(wildcard *.cpp)
program_CXX_OBJS := ${program_CXX_SRCS:.cpp=.o}
#
program_C_SRCS := $(wildcard *.c)
program_C_OBJS := ${program_C_SRCS:.c=.o}
#
program_CU_SRCS := $(wildcard *.cu)
program_CU_OBJS := ${program_CU_SRCS:.cu=.cu.o}
#
# include
#
program_INCLUDE_DIRS := ./
program_INCLUDE_DIRS += $(CFITSIO_ROOT)/include
program_INCLUDE_DIRS += $(LENSTOOL_ROOT)/include
program_INCLUDE_DIRS += $(GSL_ROOT)/include
program_INCLUDE_DIRS += $(LENSTOOLHPC_ROOT)/src
program_INCLUDE_DIRS += $(CUDA_ROOT)/include/ #C++ Include directories
#
# libs
#
program_INCLUDE_LIBS += $(CFITSIO_ROOT)/lib #Include libraries
program_INCLUDE_LIBS += $(LENSTOOL_ROOT)/src
program_INCLUDE_LIBS += $(LENSTOOL_ROOT)/liblt
program_INCLUDE_LIBS += $(LENSTOOLHPC_ROOT)/src
program_INCLUDE_LIBS += $(GSL_ROOT)/lib
program_INCLUDE_LIBS += $(WCSTOOL_ROOT)
rogram_INCLUDE_LIBS += $(CUDA_ROOT)/lib64
#
#
# Compiler flags
CXXFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
CXXFLAGS += $(foreach includelib,$(program_INCLUDE_LIBS),-L$(includelib))
#CXXFLAGS += -D__WITH_LENSTOOL
include ./precision.inc
include ./gpusm.inc
CXXFLAGS += $(PRECISION) -fPIC
CXXFLAGS += -D__WITH_MPI
CXXFLAGS += -D__WITH_UM
CXXFLAGS += -D__WITH_MARLA
#CXXFLAGS += -D_double
#CXXFLAGS += -no-vec
#CXXFLAGS += -qopenmp -march=core-avx2 -g -O3 -std=c++0x -Wall -pedantic
#CXXFLAGS += -llenstoolhpc -qopenmp -xHost -g -O3 -std=c++0x -Wall -pedantic
#CXXFLAGS += -llenstoolhpc -qopenmp -axMIC-AVX512,CORE-AVX2 -g -O3 -std=c++0x -Wall -pedantic
#CXXFLAGS += -qopt-prefetch-distance=64,8 -qopt-streaming-cache-evict=0 -llenstoolhpc -qopenmp -xMIC-AVX512 -g -O3 -std=c++0x -Wall -pedantic
#LDFLAGS := -llenstool -llenstoolhpc -llt -lcfitsio -lwcs -lgsl -lgslcblas
LDFLAGS := -llenstoolhpc -llt -lcfitsio -lwcs -lgsl -lgslcblas
#
#NVFLAGS := -O3 -rdc=true -ccbin icpc -Xcompiler '-Wall -fPIC -qopenmp'
#NVFLAGS += -D__WITH_LENSTOOL
include ./cpuflags.gnu.inc
#NVFLAGS := -ccbin icpc -Xcompiler '-xHost -Wall -fPIC' #-D__WITH_LENSTOOL
NVFLAGS := -ccbin $(CXX) -Xcompiler '$(CXXFLAGS)'
include ./gpuflags.inc
#NVFLAGS += -D_double
#NVFLAGS += -gencode arch=compute_60,code=sm_60
NVFLAGS += $(GENCODE)
#NVFLAGS += -use_fast_math
NVFLAGS += $(PRECISION)
NVFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
NVFLAGS += $(foreach includelib,$(program_INCLUDE_LIBS),-L$(includelib))
#
NVLDFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
NVLDFLAGS += $(foreach includelib,$(program_INCLUDE_LIBS),-L$(includelib))
NVLDFLAGS += -lcudart -lcudadevrt
#
LDFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
LDFLAGS += $(foreach includelib,$(program_INCLUDE_LIBS),-L$(includelib))
NVLDFLAGS += $(LDFLAGS)
#
#LDFLAGS += -O3 -g -liomp5
#LDFLAGS += -qopenmp
#
#
GPU_OBJECTS = $(program_CU_OBJS)
CPU_OBJECTS = $(program_CXX_OBJS) $(program_C_OBJS)
#
%.cu.o: %.cu %.cuh
nvcc $(NVFLAGS) -o $@ -c $<
#
%.cpp: %.cpp %.h
$(CXX) $(CXXFLAGS) -o $@ $< $(CXXFLAGS)
#
$(PROGRAM_NAME): $(GPU_OBJECTS)
nvcc $(program_CU_OBJS) --shared -o liblenstoolhpc_GPU.so
#
clean:
@- $(RM) $(PROGRAM_NAME) $(OBJECTS) *~ *.o *.optrpt *.lo
distclean: clean
.PHONY: all clean distclean
gpusm:
../utils/gpu | grep "capability" | cut -d " " -f11 | paste -s -d, - > ./gpusm.inc
sed -i '1s/^/SM:=/' ./gpusm.inc
cat ./.gpusm.inc | sed -r 's/=/=sm_/g' > gpusm.inc
head -n 1 ./gpusm.inc >> gpusm.inc
cat ./gpusm.inc | sed -r 's/,sm=/,compute=/g' > .gpusm.inc
cat ./gpusm.inc | sed -r 's/,SM=/,arch=/g' > .gpusm.inc

Event Timeline