summaryrefslogtreecommitdiff
path: root/Makefile
blob: 52de7984f6d152e7390a9a87cf6067c4a1920562 (plain)
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
GCC     = gfortran
oneAPI  = ifx

# These flags will be looped over to generate different datasets
FLAGS  := O0 O1 O2 O3 Ofast
# Also specify a default (note the conditional assignment operation, ?=)
OPTFLAGS ?= O3

GREEN  := \033[0;32m
RESET  := \033[0m

S_START:= 100
S_END  := 3500
S_STEP := 100

L_END  := 12000
L_STEP := 500

all:
	@mkdir -p bin/
	@echo "$(GREEN)Compiling serial and parallel binaries with $(OPTFLAGS)$(RESET)"
	$(GCC) matrixproduct.f90 -o bin/$(GCC).serial.out -$(OPTFLAGS) -fexternal-blas -lopenblas -march=native
	$(oneAPI) matrixproduct.f90 -o bin/$(oneAPI).serial.out -qmkl=sequential -$(OPTFLAGS) -heap-arrays -xHost
	$(GCC) matrixproduct.f90 -o bin/$(GCC).parallel.out -$(OPTFLAGS) -fexternal-blas -lopenblas -march=native -fopenmp
	$(oneAPI) matrixproduct.f90 -o bin/$(oneAPI).parallel.out -qmkl=parallel -$(OPTFLAGS) -heap-arrays -xHost -fopenmp

tests: clean
	@mkdir -p results/
	@for opt in $(FLAGS); do \
                $(MAKE) all OPTFLAGS=$$opt; \
                echo "$(GREEN)Running serial short runs with $$opt$(RESET)"; \
                export OMP_NUM_THREADS=1; \
                export MKL_NUM_THREADS=1; \
                ./bin/$(GCC).serial.out $(S_START) $(S_END) $(S_STEP) yes > results/$(GCC)_short_serial_$$opt.out; \
                ./bin/$(oneAPI).serial.out $(S_START) $(S_END) $(S_STEP) yes > results/$(oneAPI)_short_serial_$$opt.out; \
                echo "$(GREEN)Running serial long runs with $$opt$(RESET)"; \
                ./bin/$(GCC).serial.out $(S_END) $(L_END) $(L_STEP) no > results/$(GCC)_long_serial_$$opt.out; \
                ./bin/$(oneAPI).serial.out $(S_END) $(L_END) $(L_STEP) no > results/$(oneAPI)_long_serial_$$opt.out; \
                echo "$(GREEN)Running parallel short runs with $$opt$(RESET)"; \
                export OMP_NUM_THREADS=8; \
                export MKL_NUM_THREADS=8; \
                ./bin/$(GCC).parallel.out $(S_START) $(S_END) $(S_STEP) yes > results/$(GCC)_short_parallel_$$opt.out; \
                ./bin/$(oneAPI).parallel.out $(S_START) $(S_END) $(S_STEP) yes > results/$(oneAPI)_short_parallel_$$opt.out; \
                echo "$(GREEN)Running parallel long runs with $$opt$(RESET)"; \
                ./bin/$(GCC).parallel.out $(S_END) $(L_END) $(L_STEP) no > results/$(GCC)_long_parallel_$$opt.out; \
                ./bin/$(oneAPI).parallel.out $(S_END) $(L_END) $(L_STEP) no > results/$(oneAPI)_long_parallel_$$opt.out; \
	done

plots:
	gnuplot -p plots.gnu

clean:
	@echo "$(GREEN)Cleaning bin/ and results/$(RESET)"
	@rm -rf bin/
	@rm -rf results/