-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
35 lines (25 loc) · 723 Bytes
/
Makefile
File metadata and controls
35 lines (25 loc) · 723 Bytes
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
# Compilers
NVCC := nvcc
CFLAGS := -O3 --std=c++20
CUDAFLAGS := -arch=sm_86 -lcusparse
# Directories
BUILD_DIR := build
OBJECTS_DIR := $(BUILD_DIR)/objects
SRC_DIR := src
CUDA_DIR := /usr/local/cuda/include
# Files
SRC_FILES := $(wildcard $(SRC_DIR)/*.cu)
HEADER_FILES := $(wildcard $(SRC_DIR)/*.h)
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cu, $(OBJECTS_DIR)/%.o, $(SRC_FILES))
TARGET := $(BUILD_DIR)/run.out
# Rules
all: $(TARGET)
$(TARGET): $(OBJ_FILES)
@mkdir -p $(BUILD_DIR)
$(NVCC) $(CFLAGS) $(CUDAFLAGS) -o $@ $^
$(OBJECTS_DIR)/%.o: $(SRC_DIR)/%.cu $(HEADER_FILES)
@mkdir -p $(OBJECTS_DIR)
$(NVCC) $(CFLAGS) $(CUDAFLAGS) -I$(CUDA_DIR) -I$(SRC_DIR) -c $< -o $@
clean:
rm -rf $(BUILD_DIR)
.PHONY: all clean