diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2023-06-02 15:29:25 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2023-06-02 15:29:25 +0200 |
commit | 39d1c972dcea37beca6e20be152a3da78143a7d3 (patch) | |
tree | 7ed0fbde0088a9d330da26db1f6890d903645529 /SpMV/baselines | |
parent | ff9304370fdd94e9b7e4c4262c59ac734f1a28fd (diff) |
port SpMV to dfatool; add benchmark scripts
Diffstat (limited to 'SpMV/baselines')
-rw-r--r-- | SpMV/baselines/cpu/Makefile | 25 | ||||
-rw-r--r-- | SpMV/baselines/cpu/app.c | 19 | ||||
-rwxr-xr-x | SpMV/baselines/cpu/run-opti.sh | 15 | ||||
-rwxr-xr-x | SpMV/baselines/cpu/run.sh | 25 |
4 files changed, 78 insertions, 6 deletions
diff --git a/SpMV/baselines/cpu/Makefile b/SpMV/baselines/cpu/Makefile index 9c63605..64b20db 100644 --- a/SpMV/baselines/cpu/Makefile +++ b/SpMV/baselines/cpu/Makefile @@ -1,7 +1,24 @@ -all: - gcc -o spmv -fopenmp app.c +all: spmv -clean: - rm spmv +spmv: app.c + gcc -O2 -o spmv -fopenmp app.c + +spmv_O0: app.c + gcc -o spmv_O0 -fopenmp app.c + +spmv_O2: app.c + gcc -O2 -o spmv_O2 -fopenmp app.c + +run: spmv + OMP_NUM_THREADS=4 ./spmv -f ../../data/bcsstk30.mtx -v 0 +run_O0: spmv_O0 + OMP_NUM_THREADS=4 ./spmv_O0 -f ../../data/bcsstk30.mtx -v 0 + +run_O2: spmv_O2 + OMP_NUM_THREADS=4 ./spmv_O2 -f ../../data/bcsstk30.mtx -v 0 + +clean: + rm -f spmv spmv_O0 spmv_O2 +.PHONY: all run run_O0 run_O2 clean diff --git a/SpMV/baselines/cpu/app.c b/SpMV/baselines/cpu/app.c index 46db2f0..8d360ee 100644 --- a/SpMV/baselines/cpu/app.c +++ b/SpMV/baselines/cpu/app.c @@ -29,7 +29,7 @@ int main(int argc, char** argv) { // Calculating result on CPU PRINT_INFO(p.verbosity >= 1, "Calculating result on CPU"); - omp_set_num_threads(4); + //omp_set_num_threads(4); Timer timer; startTimer(&timer); #pragma omp parallel for @@ -43,7 +43,22 @@ int main(int argc, char** argv) { outVector[rowIdx] = sum; } stopTimer(&timer); - if(p.verbosity == 0) PRINT("%f", getElapsedTime(timer)*1e3); + + + unsigned int nr_threads = 0; +#pragma omp parallel +#pragma omp atomic + nr_threads++; + + + // coomatrix / csrmatrix use uint32_t indexes and float values + printf("[::] SpMV CPU | n_threads=%u e_type=float n_elements=%u |" + " throughput_MBps=%f throughput_MOpps=%f timer0_us=%f\n", + nr_threads, csrMatrix.numNonzeros, + csrMatrix.numNonzeros * sizeof(float) / (getElapsedTime(timer)*1e6), + csrMatrix.numNonzeros / (getElapsedTime(timer)*1e6), + getElapsedTime(timer)*1e6); + //if(p.verbosity == 0) PRINT("%f", getElapsedTime(timer)*1e3); PRINT_INFO(p.verbosity >= 1, " Elapsed time: %f ms", getElapsedTime(timer)*1e3); // Deallocate data structures diff --git a/SpMV/baselines/cpu/run-opti.sh b/SpMV/baselines/cpu/run-opti.sh new file mode 100755 index 0000000..62a3e8b --- /dev/null +++ b/SpMV/baselines/cpu/run-opti.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +HOST="$(hostname)" + +echo $HOST + +make clean + +for i in $(seq 1 50); do + make run_O0 | sed 's/CPU/CPU O0/' +done | tee "${HOST}-O0.txt" + +for i in $(seq 1 50); do + make run_O2 | sed 's/CPU/CPU O2/' +done | tee "${HOST}-O2.txt" diff --git a/SpMV/baselines/cpu/run.sh b/SpMV/baselines/cpu/run.sh new file mode 100755 index 0000000..a993cc0 --- /dev/null +++ b/SpMV/baselines/cpu/run.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e + +HOST="$(hostname)" + +echo $HOST + +( + +echo "prim-benchmarks SpMV CPU (dfatool edition)" +echo "Started at $(date)" +echo "Revision $(git describe --always)" + +# default threads: 4 + +# input size depends on file -> strong scaling only + +make -B +for i in $(seq 1 50); do + for nr_threads in 88 64 44 1 2 4 6 8 12 16 20 24 32; do + OMP_NUM_THREADS=${nr_threads} timeout --foreground -k 1m 30m ./spmv -f ../../data/bcsstk30.mtx -v 0 || true + done +done +) | tee "${HOST}-explore.txt" |