- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are there any examples showing how to use those functions: cblas_dgemm_pack_get_size(), cblas_dgemm_pack(), cblas_dgemm_compute() ? I would like to realize a specialized GEMM with a packed matrix B. Thanks.
This is my code. I have two questions:
①The function cblas_dgemm_pack_get_size() returns a very large number 7767808 when I want to pack the matrix B whose element type is double and dimension equals to 256 * 256.
②The difference between C1 and C2 is larger than 1.0e-6.
int main(int argc, const char* argv[])
{
// matrix parameters
int M, N, K;
int LDA, LDB, LDC;
printf("[INPUT] input M N K\n");
if(scanf("%d %d %d", &M, &N, &K) == 3){
printf("[TRUE] true parameters for scanf\n");
}
else{
printf("[FALSE] false parameters for scanf\n");
exit(EXIT_FAILURE);
}
// matrix buffer, column major
LDA = M, LDB = K, LDC = M;
double *A = NULL,
*B = NULL, *B_PACK = NULL,
*C1 = NULL, *C2 = NULL;
double alpha = 0.000001, beta = 0.000001;
A = (double *) malloc (sizeof(double) * M * K);
B = (double *) malloc (sizeof(double) * K * N);
C1 = (double *) malloc (sizeof(double) * M * N);
C2 = (double *) malloc (sizeof(double) * M * N);
gen_matrix(A, M, K), gen_matrix(B, K, N), gen_matrix(C1, M, N); // initialize matrix A、B、C1
matrix_copy(C1, M, N, C2); // copy the value from C1 to C2
B_PACK = (double *) malloc (cblas_dgemm_pack_get_size(CblasBMatrix, M, N, K));
cblas_dgemm_pack(CblasColMajor, CblasBMatrix, CblasNoTrans, M, N, K, alpha, B, LDB, B_PACK);
cblas_dgemm(CblasColMajor, CblasNoTrans, CblasNoTrans, M, N, K, alpha, A, LDA, B, LDB, beta, C1, LDC);
cblas_dgemm_compute(CblasColMajor, CblasNoTrans, CblasNoTrans, M, N, K, A, LDA, B_PACK , LDB, beta, C2, LDC);
double diff = max_abs_diff(M, N, C1, LDC, C2, LDC);
printf("diff = %lf\n", diff); // returns the maximum absolute difference over
// corresponding elements of matrices A and B.
return 0;
}
Link Copied
0 Replies
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page