Created
December 24, 2020 14:22
-
-
Save ogrisel/efcfca806b39bb51d4ce695bad167b9c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <math.h> | |
#include <float.h> | |
#include "cblas.h" | |
int main() { | |
int found_error; | |
int k; | |
int i; | |
int n = 1000; | |
int m = 10; | |
while (m <= 1000) { | |
k = 2; | |
while (k <= 512) { | |
found_error = 0; | |
printf("dgemm m=%d, n=%d, k=%d\n", m, n, k); | |
double *a = (double*) malloc(sizeof(double) * m * k); | |
double *b = (double*) malloc(sizeof(double) * n * k); | |
double *c = (double*) malloc(sizeof(double) * m * n); | |
for (i=0; i<m*k; i++) { | |
a[i] = 1.0; | |
} | |
for (i=0; i<n*k; i++) { | |
b[i] = 1.0; | |
} | |
for (i=0; i<m*n; i++) { | |
c[i] = 0.0; | |
} | |
cblas_dgemm(CblasRowMajor, CblasNoTrans, CblasTrans, m, n, k, 1., a, k, b, k, 0.0, c, n); | |
for (i=0; i<m*n; i++) { | |
if (isnan(c[i]) | c[i] < k - 1e-12 | c[i] > k + 1e-12) { | |
printf("c[%d]=%f\n", i, c[i]); | |
found_error = 1; | |
} | |
} | |
if (!found_error) { | |
printf("dgemm ok\n"); | |
} | |
free(a); | |
free(b); | |
free(c); | |
k *= 2; | |
} | |
m *= 2; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment