-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·57 lines (42 loc) · 1.6 KB
/
Makefile
File metadata and controls
executable file
·57 lines (42 loc) · 1.6 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
56
57
CC = /usr/bin/g++
LD_FLAGS = -lrt
CUDA_PATH ?= /usr/local/cuda-6.5
CUDA_INC_PATH ?= $(CUDA_PATH)/include
CUDA_BIN_PATH ?= $(CUDA_PATH)/bin
CUDA_LIB_PATH ?= $(CUDA_PATH)/lib64
# CUDA code generation flags
GENCODE_FLAGS := -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35
# Common binaries
NVCC ?= $(CUDA_BIN_PATH)/nvcc
# OS-specific build flags
ifneq ($(DARWIN),)
LDFLAGS := -Xlinker -rpath $(CUDA_LIB_PATH) -L$(CUDA_LIB_PATH) -lcudart -lcufft -lcurand
CCFLAGS := -arch $(OS_ARCH)
else
ifeq ($(OS_SIZE),32)
LDFLAGS := -L$(CUDA_LIB_PATH) -lcudart -lcufft -lcurand
CCFLAGS := -m32
else
LDFLAGS := -L$(CUDA_LIB_PATH) -lcudart -lcufft -lcurand
CCFLAGS := -m64
endif
endif
# OS-architecture specific flags
ifeq ($(OS_SIZE),32)
NVCCFLAGS := -m32
else
NVCCFLAGS := -m64 --ptxas-options="-v"
endif
TARGETS = n_body_sim n_body_sim_coalesced
all: $(TARGETS)
n_body_sim: n_body_sim.cc n_body_sim_cuda.o
$(CC) $< -o $@ n_body_sim_cuda.o -O3 $(LDFLAGS) -Wall -I$(CUDA_INC_PATH) -fopenmp
n_body_sim_coalesced: n_body_sim_coalesced.cc n_body_sim_cuda_coalesced.o
$(CC) $< -o $@ n_body_sim_cuda_coalesced.o -O3 $(LDFLAGS) -Wall -I$(CUDA_INC_PATH) -fopenmp
n_body_sim_cuda.o: n_body_sim_cuda.cu
$(NVCC) $(NVCCFLAGS) -O3 $(EXTRA_NVCCFLAGS) $(GENCODE_FLAGS) -I$(CUDA_INC_PATH) -o $@ -c $<
n_body_sim_cuda_coalesced.o: n_body_sim_cuda_coalesced.cu
$(NVCC) $(NVCCFLAGS) -O3 $(EXTRA_NVCCFLAGS) $(GENCODE_FLAGS) -I$(CUDA_INC_PATH) -o $@ -c $<
clean:
rm -f *.o $(TARGETS)
again: clean $(TARGETS)