خرید بک لینک

Vote count: 0

I'm calculating a matrix * vector product using CBLAS and BLAS for the formula itself. This is for a class where the intuition behind using Openmp is to reduce cache misses. However, at the expense of reducing the cache-misses to near zero (it's a monstrous enterprise server) my runtime has increased at rates that make cache optimizations pointless.

I've tried looking into doing nested for loops properly but I can't find anything besides what I already have. Using the ordered directive for the setting of the array memory resulted in some better times but saw the cache-misses increase significantly.

Without using OpenMP my cache-misses were mostly due to the actual initialization of the entries into the matrix instead of in the CBLAS/BLAS calculation. This makes sense due to their cache optimization formula.

Code

#include 
#include 
#include 
#include "cblas.h"
#include 

int main ( )
{
enum CBLAS_ORDER order;
enum CBLAS_TRANSPOSE transa;

double *a, *x, *y;
double alpha, beta;
int m, n, lda, incx, incy, i;

order = CblasColMajor;
transa = CblasNoTrans;

m = 16384; /* Size of Column ( the number of rows ) */
n = 16384; /* Size of Row ( the number of columns ) */
lda = 16384; /* Leading dimension of 5 * 4 matrix is 5 */
incx = 1;
incy = 1;
alpha = 1;
beta = 0;

a = (double *)malloc(sizeof(double)*m*n);
x = (double *)malloc(sizeof(double)*n);
y = (double *)malloc(sizeof(double)*n);
srand(time(NULL));
int k,j, b,id;
#pragma omp parallel shared(a, x, y) private(k, j, b)
{
#pragma omp for collapse(2)
for(k = 0; k < 16384; k++) {
   for(j = 0; j < 16384; j++) {
       a[m*k + j] = 1.0 + (rand() / ( RAND_MAX / (10.0-1.0) ) );
       //printf(" id = %dn", id);
   }
}
#pragma omp for
for(b = 0; b < 16384; b++) {
   x[b] = 1.0 + (rand() / ( RAND_MAX / (10.0 - 1.0) ));
   y[b] = 0;
}
#pragma omp barrier
//#pragma omp single
//cblas_dgemv( order, transa, m, n, alpha, a, lda, x, incx, beta,y, incy );
}
/* Print y
for( i = 0; i < n; i++ )
   printf(" y%d = %fn", i, y[i]);*/
free(a);
free(x);
free(y);
return 1;
}
asked 10 secs ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 28 فروردين 1396 ساعت: 0:41

صفحه بندی