-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (48 loc) · 1.49 KB
/
Makefile
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
56
57
58
59
60
61
62
63
64
VERSION=GPU
CXX=mpicxx
CXXFLAGS=-std=c++11 -I./include -O3 -g -fopenmp -Wall
HDF5_LIBS=-L/usr/local/lib -lhdf5
HDF5_CFLAGS=-I/usr/local/include
NVCC=nvcc
ARCH=-gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70
NVCCFLAGS=-DMEMCHECK -DUSE_GPU -lineinfo $(HDF5_CFLAGS) -I./include $(ARCH) -std=c++11 -O3 -g -Xcompiler "-fopenmp -Wall -Wno-unknown-pragmas" --compiler-bindir=$(CXX)
# Default to use host compiler and flags
COMPILER=$(CXX)
FLAGS=$(CXXFLAGS)
TARGET=sputniPIC.out
SRCDIR=src
# Check go GPU or CPU path
ifeq ($(VERSION), GPU)
FILES=$(shell find $(SRCDIR) -name '*.cu' -o -name '*.cpp')
SRCS=$(subst $(SRCDIR)/sputniPIC_CPU.cpp,,${FILES})
COMPILER=$(NVCC)
COMPILER_FLAGS=$(NVCCFLAGS)
else
FILES=$(shell find $(SRCDIR) -path $(SRCDIR)/gpu -prune -o -name '*.cpp' -print)
SRCS=$(subst $(SRCDIR)/sputniPIC_GPU.cpp,,${FILES})
COMPILER=$(CXX)
COMPILER_FLAGS=$(CXXFLAGS)
endif
# Generate list of objects
OBJDIR=src
OBJS=$(subst $(SRCDIR),$(OBJDIR), $(SRCS))
OBJS:=$(subst .cpp,.o,$(OBJS))
OBJS:=$(subst .cu,.o,$(OBJS))
BIN := ./bin
all: dir $(BIN)/$(TARGET)
dir: ${BIN}
# Create bin folder
${BIN}:
mkdir -p $(BIN)
# Binary linkage
$(BIN)/$(TARGET): $(OBJS)
$(COMPILER) $(COMPILER_FLAGS) $+ -o $@ $(HDF5_LIBS)
# GPU objects
$(SRCDIR)/%.o: $(SRCDIR)/%.cu
$(NVCC) $(NVCCFLAGS) $< -c -o $@
# Host objects
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(COMPILER) $(COMPILER_FLAGS) $< -c -o $@
clean:
rm -rf $(OBJS)
rm -rf $(BIN)/*.out