Skip to content

Commit

Permalink
Benchmark cleanup #56
Browse files Browse the repository at this point in the history
  • Loading branch information
nakatamaho committed Sep 24, 2022
1 parent 7953033 commit 817c86b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
19 changes: 14 additions & 5 deletions benchmark/mplapack/dpotf2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,24 @@
#define ___DOUBLE_BENCH___
#include <mplapack_benchmark.h>

// https://netlib.org/lapack/lawnspdf/lawn41.pdf p.120
double flops_potrf(int n_i) {
double adds, muls, flops;
double n;
n = (double)n_i;
muls = (1. / 6.) * n * n * n + 0.5 * n * n + (1. / 3.) * n;
adds = (1. / 6.) * n * n * n - (1. / 6.) * n;
flops = muls + adds;
return flops;
}

int main(int argc, char *argv[]) {
double mtemp, dummy;
double elapsedtime;
char uplo = 'u';
int STEP = 1, TOTALSTEPS = 400, info;
int STEP = 1, TOTALSTEPS = 400, n = 1, info;
int lda;
int i, j, n, k, p;
int i, j, k, p;

using Clock = std::chrono::high_resolution_clock;
using std::chrono::duration_cast;
Expand All @@ -64,7 +75,6 @@ int main(int argc, char *argv[]) {
}
}
}

for (p = 0; p < TOTALSTEPS; p++) {
lda = n;
double *a = new double[lda * n];
Expand All @@ -85,13 +95,12 @@ int main(int argc, char *argv[]) {
for (i = 0; i < lda * n; i++) {
a[i] = a_ref[i];
}

auto t1 = Clock::now();
dpotf2_f77(&uplo, &n, a, &lda, &info);
auto t2 = Clock::now();
elapsedtime = (double)duration_cast<nanoseconds>(t2 - t1).count() / 1.0e9;
printf(" n MFLOPS uplo\n");
printf("%5d %10.3f %c\n", (int)n, ((double)n * (double)n * (double)n / 3.0) / elapsedtime * MFLOPS, uplo);
printf("%5d %10.3f %c\n", (int)n, flops_potrf(n) / elapsedtime * MFLOPS, uplo);
delete[] a_ref;
delete[] a;
n = n + STEP;
Expand Down
13 changes: 12 additions & 1 deletion benchmark/mplapack/dpotrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@
#define ___DOUBLE_BENCH___
#include <mplapack_benchmark.h>

// https://netlib.org/lapack/lawnspdf/lawn41.pdf p.120
double flops_potrf(int n_i) {
double adds, muls, flops;
double n;
n = (double)n_i;
muls = (1. / 6.) * n * n * n + 0.5 * n * n + (1. / 3.) * n;
adds = (1. / 6.) * n * n * n - (1. / 6.) * n;
flops = muls + adds;
return flops;
}

int main(int argc, char *argv[]) {
double mtemp, dummy;
double elapsedtime;
Expand Down Expand Up @@ -89,7 +100,7 @@ int main(int argc, char *argv[]) {
auto t2 = Clock::now();
elapsedtime = (double)duration_cast<nanoseconds>(t2 - t1).count() / 1.0e9;
printf(" n MFLOPS uplo\n");
printf("%5d %10.3f %c\n", (int)n, ((double)n * (double)n * (double)n / 3.0) / elapsedtime * MFLOPS, uplo);
printf("%5d %10.3f %c\n", (int)n, flops_potrf(n) / elapsedtime * MFLOPS, uplo);
delete[] a_ref;
delete[] a;
n = n + STEP;
Expand Down

0 comments on commit 817c86b

Please sign in to comment.