-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
44 lines (33 loc) · 1.13 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
# Compiler and Flags
CXX = g++
NVCC = nvcc
CXXFLAGS = -std=c++11 -O3
NVCCFLAGS = -std=c++11 -O3
# Include directories
INCLUDES = -I.
# Object files
OBJS = main.o csr_matrix.o cpu_matrix_multiply.o gpu_matrix_multiply.o
# Executable
TARGET = matrix_multiply
# Default target
all: $(TARGET)
# Link the object files into the executable
$(TARGET): $(OBJS)
$(NVCC) $(NVCCFLAGS) $(OBJS) -o $(TARGET)
# Compile the main.cpp file
main.o: main.cpp csr_matrix.h cpu_matrix_multiply.h
$(CXX) $(CXXFLAGS) $(INCLUDES) -c main.cpp
# Compile the csr_matrix.cpp file
csr_matrix.o: csr_matrix.cpp csr_matrix.h
$(CXX) $(CXXFLAGS) $(INCLUDES) -c csr_matrix.cpp
# Compile the cpu_matrix_multiply.cpp file
cpu_matrix_multiply.o: cpu_matrix_multiply.cpp cpu_matrix_multiply.h csr_matrix.h
$(CXX) $(CXXFLAGS) $(INCLUDES) -c cpu_matrix_multiply.cpp
# Compile the gpu_matrix_multiply.cu file
gpu_matrix_multiply.o: gpu_matrix_multiply.cu csr_matrix.h
$(NVCC) $(NVCCFLAGS) $(INCLUDES) -c gpu_matrix_multiply.cu
# Clean target: removes all object files and the executable
clean:
rm -f $(OBJS) $(TARGET)
# Phony targets to avoid filename conflicts
.PHONY: all clean