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 := 20000 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; \ ./bin/$(oneAPI).parallel.out $(S_START) $(S_END) $(S_STEP) yes > results/$(oneAPI)_short_parallel; \ echo "$(GREEN)Running parallel long runs with $$opt$(RESET)"; \ ./bin/$(GCC).parallel.out $(S_END) $(L_END) $(L_STEP) no > results/$(GCC)_long_parallel; \ ./bin/$(oneAPI).parallel.out $(S_END) $(L_END) $(L_STEP) no > results/$(oneAPI)_long_parallel; \ done plots: gnuplot -p plots.gnu clean: @echo "$(GREEN)Cleaning bin/ and results/$(RESET)" @rm -rf bin/ @rm -rf results/