-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (53 loc) · 1.43 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
prc ?= 4
dim ?= 1000
option ?= generate
debug ?= no
pernode ?= 4
persocket ?= 2
# Fantastic libraries and where to find them
IBLAS := -I${OPENBLAS_HOME}/include/
LBLAS := -L${OPENBLAS_HOME}/lib/ -lopenblas -lgfortran
LCUDA := -L${CUDA_HOME}/lib64/ -lcublas -lcudart
IMPI := -I${SMPI_ROOT}/include
# Flags
INCLUDE := -I./include/
LINK := $(LCUDA)
CXXFLAGS := -O3
RUNFLAGS := -npersocket $(persocket) -npernode $(pernode) --bind-to core
# Files
MAIN := $(wildcard *.c)
EXE := $(MAIN:.c=.x)
SRC := $(wildcard src/*.c*) $(MAIN)
OBJ := $(patsubst %.cu, %.o, $(patsubst %.c, %.o, $(SRC)))
# Conditional flag to toggle the debugging
ifeq ($(debug), yes)
CXXFLAGS += -DDEBUG
EXE := $(EXE:.x=_debug.x)
endif
# Updating the dependencing in the three cases
all: $(EXE)
dgemm: CXXFLAGS += -DDGEMM
dgemm: INCLUDE += $(IBLAS)
dgemm: LINK += $(LBLAS)
dgemm: dgemm$(EXE)
cuda: CXXFLAGS += -DCUDA
cuda: cuda$(EXE)
# Compiling the object files
%.o: %.c
mpicc -c $< -o $@ $(CXXFLAGS) $(INCLUDE)
%.o: %.cu
nvcc -c $< -o $@ $(IMPI) $(INCLUDE) $(CXXFLAGS) -lcublas -lcudart
# Linking the executable
%.x: $(OBJ)
mpicc -o $@ $^ $(LINK) -O3
# Running
run: $(EXE)
mpirun -np $(prc) $(RUNFLAGS) ./$^ $(option) $(dim)
%run: %
mpirun -np $(prc) $(RUNFLAGS) ./$^$(EXE) $(option) $(dim)
clean:
@rm -f ./*.x
flush:
@rm -f ./data/matrices.txt ./data/result.txt
.PHONY: all dgemm cuda clean flush run
.INTERMEDIATE: $(OBJ)