diff options
| author | Connor Moore <connor@hhmoore.ca> | 2026-02-04 17:41:15 -0500 |
|---|---|---|
| committer | Connor Moore <connor@hhmoore.ca> | 2026-02-04 17:41:15 -0500 |
| commit | 52af334d376a4dbc1825a6d8ab6e94bc09754f78 (patch) | |
| tree | af8db348857634bb352294d6867272e94f82a96c | |
| parent | 48a7af5b0c0facd9c3e99801476d44f6b218b363 (diff) | |
Cleaned up makefile to be modular.
| -rw-r--r-- | Makefile | 49 |
1 files changed, 28 insertions, 21 deletions
@@ -5,20 +5,22 @@ oneAPI = ifx FLAGS := O0 O1 O2 O3 Ofast # Also specify a default (note the conditional assignment operation, ?=) OPTFLAGS ?= O3 +# For the parallel runs, use all available processors +NPROC := $(shell nproc) -GREEN := \033[0;32m +MAGENTA := \033[1;35m RESET := \033[0m S_START:= 100 -S_END := 3500 +S_END := 300 S_STEP := 100 -L_END := 12000 +L_END := 800 L_STEP := 500 all: @mkdir -p bin/ - @echo "$(GREEN)Compiling serial and parallel binaries with $(OPTFLAGS)$(RESET)" + @echo "$(MAGENTA)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 @@ -28,28 +30,33 @@ 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; \ + echo "$(MAGENTA)Running serial runs with $$opt$(RESET)"; \ + $(MAKE) serial OPTFLAGS=$$opt; \ + echo "$(MAGENTA)Running parallel runs with $$opt$(RESET)"; \ + $(MAKE) parallel OPTFLAGS=$$opt; \ done +serial: ./bin/gfortran.serial.out ./bin/ifx.serial.out + export OMP_NUM_THREADS=1 && \ + export MKL_NUM_THREADS=1 && \ + ./bin/$(GCC).serial.out $(S_START) $(S_END) $(S_STEP) yes | tee results/$(GCC)_short_serial_$(OPTFLAGS).out; \ + ./bin/$(oneAPI).serial.out $(S_START) $(S_END) $(S_STEP) yes | tee results/$(oneAPI)_short_serial_$(OPTFLAGS).out; \ + ./bin/$(GCC).serial.out $(S_END) $(L_END) $(L_STEP) no | tee results/$(GCC)_long_serial_$(OPTFLAGS).out; \ + ./bin/$(oneAPI).serial.out $(S_END) $(L_END) $(L_STEP) no | tee results/$(oneAPI)_long_serial_$(OPTFLAGS).out; + +parallel: ./bin/gfortran.parallel.out ./bin/ifx.parallel.out + export OMP_NUM_THREADS=${NPROC} && \ + export MKL_NUM_THREADS=${NPROC} && \ + ./bin/$(GCC).parallel.out $(S_START) $(S_END) $(S_STEP) yes | tee results/$(GCC)_short_parallel_$(OPTFLAGS)_$(NPROC).out; \ + ./bin/$(oneAPI).parallel.out $(S_START) $(S_END) $(S_STEP) yes | tee results/$(oneAPI)_short_parallel_$(OPTFLAGS)_$(NPROC).out; \ + ./bin/$(GCC).parallel.out $(S_END) $(L_END) $(L_STEP) no | tee results/$(GCC)_long_parallel_$(OPTFLAGS)_$(NPROC).out; \ + ./bin/$(oneAPI).parallel.out $(S_END) $(L_END) $(L_STEP) no | tee results/$(oneAPI)_long_parallel_$(OPTFLAGS)_$(NPROC).out; + + plots: gnuplot -p plots.gnu clean: - @echo "$(GREEN)Cleaning bin/ and results/$(RESET)" + @echo "$(MAGENTA)Cleaning bin/ and results/$(RESET)" @rm -rf bin/ @rm -rf results/ |
