Skip to content

Commit

Permalink
Benchmark cleanup
Browse files Browse the repository at this point in the history
Related to #56
  • Loading branch information
nakatamaho committed Sep 24, 2022
1 parent f0ee27d commit 9b93a0e
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 42 deletions.
3 changes: 2 additions & 1 deletion benchmark/mpblas/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
bench_PROGRAMS =
bench_DATA = \
Raxpy1.plt.in Raxpy2.plt.in Raxpy3.plt.in \
Rcopy1.plt Rcopy2.plt Rcopy3.plt Rdot1.plt Rdot2.plt Rdot3.plt \
Rcopy1.plt Rcopy2.plt Rcopy3.plt \
Rdot1.plt.in Rdot2.plt.in Rdot3.plt.in \
Rgemm1.plt Rgemm2.plt Rgemm3.plt \
Rgemm_cuda.plt \
Rgemv1.plt Rgemv2.plt Rgemv3.plt \
Expand Down
9 changes: 7 additions & 2 deletions benchmark/mpblas/Raxpy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

int main(int argc, char *argv[]) {
mplapackint n;
mplapackint incx = 1, incy = 1, STEP = 97, N0 = 1, LOOPS = 3, TOTALSTEPS = 3000;
mplapackint incx = 1, incy = 1, STEP = 97, N0 = 1, LOOPS = 3, TOTALSTEPS = 3092;
REAL alpha, dummy, *dummywork;
double elapsedtime;
int i, p;
Expand Down Expand Up @@ -88,6 +88,7 @@ int main(int argc, char *argv[]) {
REAL *x = new REAL[n];
REAL *y = new REAL[n];
REAL *y_ref = new REAL[n];
REAL *z = new REAL[n];
if (check_flag) {
for (i = 0; i < n; i++) {
x[i] = randomnumber(dummy);
Expand All @@ -99,7 +100,10 @@ int main(int argc, char *argv[]) {
auto t2 = Clock::now();
elapsedtime = (double)duration_cast<nanoseconds>(t2 - t1).count() / 1.0e9;
(*mpblas_ref)(n, alpha, x, incx, y_ref, incy);
diff = Rlange(&normtype, (mplapackint)n, (mplapackint)1, y_ref, 1, dummywork);
for (i = 0; i < n; i++) {
z[i] = y[i] - y_ref[i];
}
diff = Rlange(&normtype, (mplapackint)n, (mplapackint)1, z, 1, dummywork);
diffr = cast2double(diff);
printf(" n MFLOPS error\n");
printf("%10d %10.3f %10.3f\n", (int)n, (2.0 * (double)n) / elapsedtime * MFLOPS, diffr);
Expand All @@ -120,6 +124,7 @@ int main(int argc, char *argv[]) {
printf(" n MFLOPS LOOPS\n");
printf("%10d %10.3f %d\n", (int)n, (2.0 * (double)n) / elapsedtime * MFLOPS, (int)LOOPS);
}
delete[] z;
delete[] y_ref;
delete[] y;
delete[] x;
Expand Down
4 changes: 2 additions & 2 deletions benchmark/mpblas/Raxpy3.plt.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ set terminal pdf

plot "log.Raxpy.double_opt" using 1:2 title 'double (OpenMP)' with lines linewidth 1, \
"log.Raxpy.double" using 1:2 title 'double' with lines linewidth 1, \
"log.daxpy.ref" using 1:2 title 'double (Ref.BLAS)' with lines linewidth 1, \
"log.daxpy.openblas" using 1:2 title 'double (OpenBLAS)' with lines linewidth 1
"log.daxpy.ref" using 1:2 title 'double (Ref.BLAS)' with lines linewidth 1, \
"log.daxpy.openblas" using 1:2 title 'double (OpenBLAS)' with lines linewidth 1
14 changes: 7 additions & 7 deletions benchmark/mpblas/Rdot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

int main(int argc, char *argv[]) {
mplapackint n;
mplapackint incx = 1, incy = 1, STEP = 97, N0 = 1, LOOP = 3, TOTALSTEPS = 3000;
mplapackint incx = 1, incy = 1, STEP = 97, N0 = 1, LOOPS = 3, TOTALSTEPS = 3092;
REAL dummy, ans, ans_ref;
double elapsedtime;
int i, p;
Expand All @@ -63,8 +63,8 @@ int main(int argc, char *argv[]) {
STEP = atoi(argv[++i]);
} else if (strcmp("-NOCHECK", argv[i]) == 0) {
check_flag = 0;
} else if (strcmp("-LOOP", argv[i]) == 0) {
LOOP = atoi(argv[++i]);
} else if (strcmp("-LOOPS", argv[i]) == 0) {
LOOPS = atoi(argv[++i]);
} else if (strcmp("-TOTALSTEPS", argv[i]) == 0) {
TOTALSTEPS = atoi(argv[++i]);
}
Expand Down Expand Up @@ -107,15 +107,15 @@ int main(int argc, char *argv[]) {
y[i] = randomnumber(dummy);
}
elapsedtime = 0.0;
for (int j = 0; j < LOOP; j++) {
for (int j = 0; j < LOOPS; j++) {
auto t1 = Clock::now();
ans = Rdot(n, x, incx, y, incy);
auto t2 = Clock::now();
elapsedtime = elapsedtime + (double)duration_cast<nanoseconds>(t2 - t1).count() / 1.0e9;
}
elapsedtime = elapsedtime / (double)LOOP;
printf(" n MFLOPS\n");
printf("%10d %10.3f\n", (int)n, (2.0 * (double)n) / elapsedtime * MFLOPS);
elapsedtime = elapsedtime / (double)LOOPS;
printf(" n MFLOPS LOOPS\n");
printf("%10d %10.3f %d\n", (int)n, (2.0 * (double)n) / elapsedtime * MFLOPS, (int)LOOPS);
}
delete[] y;
delete[] x;
Expand Down
8 changes: 3 additions & 5 deletions benchmark/mpblas/Rdot1.plt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ set xlabel font "Helvetica,20"
set ylabel font "Helvetica,20"
set key font "Helvetica,16"
set title font "Helvetica,20"
set title "Rdot on %%MODELNAME%%"
set title "Rdot on AMD Ryzen Threadripper 3970X 32-Core Processor "
set xlabel "Dimension"
set ylabel "MFLOPS"
#set terminal postscript eps color enhanced
set key above
set terminal pdf

plot \
Expand All @@ -14,6 +14,4 @@ plot \
"log.Rdot._Float64x" using 1:2 title '\_Float64x' with lines linewidth 1, \
"log.Rdot._Float64x_opt" using 1:2 title '\_Float64x (OpenMP)' with lines linewidth 1, \
"log.Rdot.dd" using 1:2 title 'double double' with lines linewidth 1, \
"log.Rdot.dd_opt" using 1:2 title 'double double (OpenMP)' with lines linewidth 1, \
"log.Rdot.double" using 1:2 title 'double' with lines linewidth 1

"log.Rdot.dd_opt" using 1:2 title 'double double (OpenMP)' with lines linewidth 1
17 changes: 17 additions & 0 deletions benchmark/mpblas/Rdot1.plt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set xlabel font "Helvetica,20"
set ylabel font "Helvetica,20"
set key font "Helvetica,16"
set title font "Helvetica,20"
set title "Rdot on %%MODELNAME%%"
set xlabel "Dimension"
set ylabel "MFLOPS"
set key above
set terminal pdf

plot \
"log.Rdot._Float128" using 1:2 title '\_Float128' with lines linewidth 1, \
"log.Rdot._Float128_opt" using 1:2 title '\_Float128 (OpenMP)' with lines linewidth 1, \
"log.Rdot._Float64x" using 1:2 title '\_Float64x' with lines linewidth 1, \
"log.Rdot._Float64x_opt" using 1:2 title '\_Float64x (OpenMP)' with lines linewidth 1, \
"log.Rdot.dd" using 1:2 title 'double double' with lines linewidth 1, \
"log.Rdot.dd_opt" using 1:2 title 'double double (OpenMP)' with lines linewidth 1
4 changes: 2 additions & 2 deletions benchmark/mpblas/Rdot2.plt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ set xlabel font "Helvetica,20"
set ylabel font "Helvetica,20"
set key font "Helvetica,16"
set title font "Helvetica,20"
set title "Rdot on %%MODELNAME%%"
set title "Rdot on AMD Ryzen Threadripper 3970X 32-Core Processor "
set xlabel "Dimension"
set ylabel "MFLOPS"
#set terminal postscript eps color enhanced
set key above
set terminal pdf

plot \
Expand Down
17 changes: 17 additions & 0 deletions benchmark/mpblas/Rdot2.plt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set xlabel font "Helvetica,20"
set ylabel font "Helvetica,20"
set key font "Helvetica,16"
set title font "Helvetica,20"
set title "Rdot on %%MODELNAME%%"
set xlabel "Dimension"
set ylabel "MFLOPS"
set key above
set terminal pdf

plot \
"log.Rdot.mpfr" using 1:2 title 'MPFR 512bit' with lines linewidth 1, \
"log.Rdot.mpfr_opt" using 1:2 title 'MPFR 512bit(OpenMP)' with lines linewidth 1, \
"log.Rdot.gmp" using 1:2 title 'GMP 512bit' with lines linewidth 1, \
"log.Rdot.gmp_opt" using 1:2 title 'GMP 512bit(OpenMP)' with lines linewidth 1, \
"log.Rdot.qd" using 1:2 title 'quad-double' with lines linewidth 1, \
"log.Rdot.qd_opt" using 1:2 title 'quad-double(OpenMP)' with lines linewidth 1
9 changes: 6 additions & 3 deletions benchmark/mpblas/Rdot3.plt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ set xlabel font "Helvetica,20"
set ylabel font "Helvetica,20"
set key font "Helvetica,16"
set title font "Helvetica,20"
set title "Rdot on %%MODELNAME%%"
set title "Rdot on AMD Ryzen Threadripper 3970X 32-Core Processor "
set xlabel "Dimension"
set ylabel "MFLOPS"
#set terminal postscript eps color enhanced
set key above
set terminal pdf

plot "log.Rdot.double_opt" using 1:2 title 'double (OpenMP)' with lines linewidth 1
plot "log.Rdot.double_opt" using 1:2 title 'double (OpenMP)' with lines linewidth 1, \
"log.Rdot.double" using 1:2 title 'double' with lines linewidth 1, \
"log.ddot.ref" using 1:2 title 'double (Ref.BLAS)' with lines linewidth 1, \
"log.ddot.openblas" using 1:2 title 'double (OpenBLAS)' with lines linewidth 1

15 changes: 15 additions & 0 deletions benchmark/mpblas/Rdot3.plt.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
set xlabel font "Helvetica,20"
set ylabel font "Helvetica,20"
set key font "Helvetica,16"
set title font "Helvetica,20"
set title "Rdot on %%MODELNAME%%"
set xlabel "Dimension"
set ylabel "MFLOPS"
set key above
set terminal pdf

plot "log.Rdot.double_opt" using 1:2 title 'double (OpenMP)' with lines linewidth 1, \
"log.Rdot.double" using 1:2 title 'double' with lines linewidth 1, \
"log.ddot.ref" using 1:2 title 'double (Ref.BLAS)' with lines linewidth 1, \
"log.ddot.openblas" using 1:2 title 'double (OpenBLAS)' with lines linewidth 1

31 changes: 16 additions & 15 deletions benchmark/mpblas/ddot.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2010
* Copyright (c) 2008-2022
* Nakata, Maho
* All rights reserved.
*
Expand Down Expand Up @@ -35,11 +35,9 @@
#define ___DOUBLE_BENCH___
#include <mplapack_benchmark.h>

#define TOTALSTEPS 1000

int main(int argc, char *argv[]) {
int n;
int incx = 1, incy = 1, STEP, N0;
int incx = 1, incy = 1, STEP = 97, N0 = 1, LOOPS = 3, TOTALSTEPS = 3000;
double dummy, ans, ans_ref;
double mOne = -1;
double elapsedtime;
Expand All @@ -51,20 +49,19 @@ int main(int argc, char *argv[]) {
using std::chrono::nanoseconds;

// initialization
N0 = 1;
STEP = 1;
if (argc != 1) {
for (i = 1; i < argc; i++) {
if (strcmp("-N", argv[i]) == 0) {
N0 = atoi(argv[++i]);
} else if (strcmp("-STEP", argv[i]) == 0) {
STEP = atoi(argv[++i]);
} else if (strcmp("-NOCHECK", argv[i]) == 0) {
check_flag = 0;
} else if (strcmp("-LOOPS", argv[i]) == 0) {
LOOPS = atoi(argv[++i]);
} else if (strcmp("-TOTALSTEPS", argv[i]) == 0) {
TOTALSTEPS = atoi(argv[++i]);
}
}
}

n = N0;
for (p = 0; p < TOTALSTEPS; p++) {
double *x = new double[n];
Expand All @@ -73,12 +70,16 @@ int main(int argc, char *argv[]) {
x[i] = randomnumber(dummy);
y[i] = randomnumber(dummy);
}
auto t1 = Clock::now();
ans = ddot_f77(&n, x, &incx, y, &incy);
auto t2 = Clock::now();
elapsedtime = elapsedtime + (double)duration_cast<nanoseconds>(t2 - t1).count() / 1.0e9;
printf(" n MFLOPS\n");
printf("%10d %10.3f\n", (int)n, (2.0 * (double)n) / elapsedtime * MFLOPS);
elapsedtime = 0.0;
for (int j = 0; j < LOOPS; j++) {
auto t1 = Clock::now();
ans = ddot_f77(&n, x, &incx, y, &incy);
auto t2 = Clock::now();
elapsedtime = elapsedtime + (double)duration_cast<nanoseconds>(t2 - t1).count() / 1.0e9;
}
elapsedtime = elapsedtime / (double)LOOPS;
printf(" n MFLOPS loops\n");
printf("%10d %10.3f %d\n", (int)n, (2.0 * (double)n) / elapsedtime * MFLOPS, LOOPS);
delete[] y;
delete[] x;
n = n + STEP;
Expand Down
4 changes: 2 additions & 2 deletions benchmark/mpblas/go.Raxpy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ else
LDPATHPREFIX="LD_LIBRARY_PATH=%%PREFIX%%/lib:$LD_LIBRARY_PATH"
fi

env $LDPATHPREFIX ./daxpy_ref -STEP 7 -TOTALSTEPS 42000 -LOOPS 3 >& log.daxpy.ref
env $LDPATHPREFIX ./daxpy_openblas -STEP 7 -TOTALSTEPS 42000 -LOOPS 3 >& log.daxpy.openblas
env $LDPATHPREFIX ./daxpy_ref -STEP 7 -TOTALSTEPS 42857 -LOOPS 3 >& log.daxpy.ref
env $LDPATHPREFIX ./daxpy_openblas -STEP 7 -TOTALSTEPS 42857 -LOOPS 3 >& log.daxpy.openblas

####
MPLIBS="_Float128 _Float64x dd double"
Expand Down
9 changes: 6 additions & 3 deletions benchmark/mpblas/go.Rdot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ else
LDPATHPREFIX="LD_LIBRARY_PATH=%%PREFIX%%/lib:$LD_LIBRARY_PATH"
fi

env $LDPATHPREFIX ./ddot_ref -STEP 7 -TOTALSTEPS 42857 -LOOPS 3 >& log.ddot.ref
env $LDPATHPREFIX ./ddot_openblas -STEP 7 -TOTALSTEPS 42857 -LOOPS 3 >& log.ddot.openblas

####
MPLIBS="_Float128 _Float64x dd double"

Expand Down Expand Up @@ -35,9 +38,9 @@ else
MODELNAME="unknown"
fi

$SED -i -e "s/%%MODELNAME%%/$MODELNAME/g" Rdot1.plt
$SED -i -e "s/%%MODELNAME%%/$MODELNAME/g" Rdot2.plt
$SED -i -e "s/%%MODELNAME%%/$MODELNAME/g" Rdot3.plt
$SED -e "s/%%MODELNAME%%/$MODELNAME/g" Rdot1.plt.in > Rdot1.plt
$SED -e "s/%%MODELNAME%%/$MODELNAME/g" Rdot2.plt.in > Rdot2.plt
$SED -e "s/%%MODELNAME%%/$MODELNAME/g" Rdot3.plt.in > Rdot3.plt
####

gnuplot Rdot1.plt > Rdot1.pdf
Expand Down

0 comments on commit 9b93a0e

Please sign in to comment.