-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
100 lines (83 loc) · 2.91 KB
/
Copy pathMakefile
File metadata and controls
100 lines (83 loc) · 2.91 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
97
98
99
100
# ====================================================================
# Makefile for CUDA NeRF Project (Corrected & Final Version)
# ====================================================================
# --- Compiler and Flags ---
CXX := g++
NVCC := nvcc
EXEC := nerf_app
# --- Build Configuration ---
# Set to 1 for a debug build, e.g., `make DEBUG=1`
DEBUG ?= 0
# GPU Architecture (can be overridden from command line)
ARCH ?= 86
# Set to 1 to enable CUTLASS fused GEMM kernels, e.g., `make USE_CUTLASS=1`
USE_CUTLASS ?= 0
# --- Include Paths ---
INCLUDES := -I/usr/local/cuda-13.0/include \
-I./include \
-I/usr/local/include \
-I/usr/local/include/opencv4 \
-I$(HOME)/cutlass/include \
-I$(HOME)/cutlass/tools/util/include
# --- Compiler Flags ---
BASE_CXXFLAGS := -std=c++17 -Wall
# --- Create a clean way to toggle debug flags ---
ifeq ($(DEBUG), 1)
OPTIMIZER_FLAGS := -O0
DEBUGGER_FLAGS := -g -G
HOST_DEBUG_FLAGS := -g
# Don't use -Werror in debug builds
HOST_CXXFLAGS := $(BASE_CXXFLAGS)
else
OPTIMIZER_FLAGS := -O3
DEBUGGER_FLAGS :=
HOST_CXXFLAGS := $(BASE_CXXFLAGS)
endif
# --- CUTLASS GEMM flag ---
ifeq ($(USE_CUTLASS), 1)
CUTLASS_FLAG := -DUSE_CUTLASS_GEMM
else
CUTLASS_FLAG :=
endif
# --- FIX: Removed $(BASE_CXXFLAGS) from the start of this line ---
NVCCFLAGS := --expt-relaxed-constexpr \
$(OPTIMIZER_FLAGS) -rdc=true $(DEBUGGER_FLAGS) \
-gencode arch=compute_$(ARCH),code=sm_$(ARCH) \
-diag-suppress=549 -diag-suppress=20096 \
-DCUB_IGNORE_DEPRECATED_API \
-DTHRUST_IGNORE_DEPRECATED_CPP_DIALECT \
$(CUTLASS_FLAG) \
-Xcompiler "-fopenmp" \
-Xcompiler "$(HOST_CXXFLAGS)"
# C++ Compiler flags now also use the debug/release settings
CXXFLAGS := $(HOST_CXXFLAGS) $(HOST_DEBUG_FLAGS)
# --- Linker Flags and Libraries ---
LDFLAGS := -L/usr/local/lib -L/usr/local/cuda-13.0/lib64 -Xcompiler -fopenmp
LDLIBS := -lopencv_core -lopencv_imgcodecs -lopencv_highgui -lopencv_imgproc \
-lcublas -lcublasLt -lcudart -lcusolver -lnccl -lgomp
# --- Source Files and Objects (Automatic Discovery) ---
SRC_DIRS := . src/nerf src/dataset
SRCS := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.cu) $(wildcard $(dir)/*.cpp))
OBJS := $(SRCS:.cu=.o)
OBJS := $(OBJS:.cpp=.o)
DEPS := $(OBJS:.o=.d)
# --- Build Rules ---
all: $(EXEC)
# Use the C++ compiler for robust linking
$(EXEC): $(OBJS)
$(NVCC) -rdc=true $(DEBUGGER_FLAGS) $^ -o $@ $(LDFLAGS) $(LDLIBS)
@echo "✅ Linking complete. Executable created: $(EXEC)"
# Rule to compile .cu files
%.o: %.cu
$(NVCC) $(INCLUDES) $(NVCCFLAGS) -c $< -o $@ -MMD -MP
# Rule to compile .cpp files
%.o: %.cpp
$(CXX) $(INCLUDES) $(CXXFLAGS) -c $< -o $@ -MMD -MP
# --- Dependency Handling ---
-include $(DEPS)
# --- Clean Rule ---
clean:
@echo "🧹 Cleaning up generated files..."
rm -f $(EXEC) $(OBJS) $(DEPS)
@echo "Cleanup complete."
.PHONY: all clean