-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (71 loc) · 2.56 KB
/
Makefile
File metadata and controls
97 lines (71 loc) · 2.56 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# Optional: Enable GUI (requires GLUI built and paths adjusted)
GUI_SUPPORT = 1
# Detect mpirun for MPI support
HAS_MPIRUN = $(shell which mpirun > /dev/null; echo $$?)
ifeq ($(HAS_MPIRUN), 0)
MPI_SUPPORT = 1
else
MPI_SUPPORT = 0
endif
# ---------------------------------------------------------------------
# CUDA detection (system-installed CUDA)
# ---------------------------------------------------------------------
NVCC ?= $(shell which nvcc)
ifeq ($(NVCC),)
$(error nvcc not found. Please install CUDA Toolkit.)
endif
# For distro-installed CUDA, headers are in /usr/include
CUDAROOT ?= /usr
# ---------------------------------------------------------------------
# Compiler selection
# ---------------------------------------------------------------------
ifeq ($(MPI_SUPPORT), 1)
CXX = mpic++
else
CXX = g++
endif
# ---------------------------------------------------------------------
# Flags
# ---------------------------------------------------------------------
CFLAGS = -g -D MPI_SUPPORT=$(MPI_SUPPORT) -D GUI_SUPPORT=$(GUI_SUPPORT) \
-Wno-deprecated-declarations -ffast-math
CCFLAGS = -I. -I./src/include -I$(CUDAROOT)/include -O3 -g
# MX250 = Pascal = sm_61 (this is correct for your GPU)
CUDAFLAGS = -use_fast_math \
-gencode arch=compute_61,code=sm_61 \
--ptxas-options --maxrregcount=20
# System CUDA libraries (no hardcoded lib64 path)
LIBCUDA = -lcudart
FRAMEWORKS = -lglut -lGLU -lGL $(LIBCUDA)
# GUI support (optional)
ifeq ($(GUI_SUPPORT),1)
CCFLAGS += -I./src/glui/include
FRAMEWORKS += -lglui
LINKFLAGS += -L./src/glui/lib/linux
endif
# ---------------------------------------------------------------------
# Build targets
# ---------------------------------------------------------------------
VPATH = obj
EXECUTABLE = hairrazor
BATCH = batch
BATCH_SRC = src/batch.cpp
CC_SRC = $(filter-out $(BATCH_SRC),$(wildcard src/*.cpp))
OBJECTS = $(subst src/,$(VPATH)/,$(CC_SRC:.cpp=.o)) $(VPATH)/skelft.o
CUDAFILE = src/gaps.cu
all: $(EXECUTABLE) $(BATCH)
$(BATCH): $(BATCH_SRC)
$(NVCC) -D MPI_SUPPORT=$(MPI_SUPPORT) $(CCFLAGS) $(CUDAFLAGS) -o $@ $< $(LIBCUDA)
$(EXECUTABLE): $(OBJECTS)
$(CXX) -o $(EXECUTABLE) $(OBJECTS) $(CCFLAGS) $(LINKFLAGS) $(FRAMEWORKS)
$(VPATH)/skelft.o: $(CUDAFILE)
$(NVCC) -c $(CCFLAGS) $(CUDAFLAGS) -o $@ $(CUDAFILE)
$(VPATH)/%.o: src/%.cpp $(VPATH)/.sentinel
$(CXX) -MMD $(CFLAGS) $(CCFLAGS) -c -o $@ $<
$(VPATH)/.sentinel:
mkdir -p $(dir $(OBJECTS))
touch $@
clean:
-rm -rf output $(VPATH) $(EXECUTABLE) $(BATCH)
DEPS := $(OBJECTS:.o=.d)
-include $(DEPS)