- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

That is why there is a cautionary note at the beginning of Appendix D:

### "Warning

Users of the CBLAS interface should be aware that the CBLAS are just a C interface to the BLAS, which is based on the FORTRAN standard and subject to the FORTRAN standard restrictions. In particular, the output parameters should not be referenced through more than one argument."

"In the descriptions of CBLAS interfaces, links provided for each function group lead to the descriptions of the respective Fortran-interface BLAS functions."

From the MKL documentation page for ?GEMM, we have

` A`, `B` and `C` are matrices:

` op( A)` is an

`m`-by-

`k`matrix,

` op( B)` is a

`k`-by-

`n`matrix,

` C` is an `m`-by-`n` matrix.

For your example, op(A)=ay' is 3 X 1, op(B)=ax is 1 X 5. Thus, arguments #4, #5, #6, which are *m,n,k*, should be 3,5,1, not 3,5,5 as you have.

One could probe the consequences of how the incorrect arguments that you provided caused the mystefying behavior in the results that you observed, but I do not think that it is worthwhile. Your conjecture as to initialization being the cause turns out to be incorrect since, when argument *beta* = 0, the matrix C need not be initialized, as the documentation clearly states.

The next time you post a similar query, it would make it easier to analyze the reported problem if you gave a complete example that could be compiled and run to reproduce the problem.

[cpp]#include#include main(){ float ax[]={5, 2, 6, 1, 7}, ay[]={8, 1, 7}; float aa[5*3]; int i,j; cblas_sgemm( CblasRowMajor, CblasTrans, CblasNoTrans, 3, 5, 1, 1.0f, ay, 3, ax, 5, 0.0f, aa, 5 ); for(i=0; i<3; i++){ for(j=0; j<5; j++)printf("%9.4f ",aa[5*i+j]); printf("n"); } } [/cpp]

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

if(beta != 0.0){

for(i...) for(j...)

C

+= ...

}

else{

for(i...) for(j...)

C

}

else{

for(i...) for(j...)

C

= ...

}

I have seen code with this structure in the Fortran-77 sources of BLAS and Lapack.

}

I have seen code with this structure in the Fortran-77 sources of BLAS and Lapack.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Precisely, mecej4. The code treats beta == 0.0 as a special case and does C = alpha*op(A)*op(B). It DOES NOT explicity multiply the entries of C with 0.0.

This behaviour is described in MKL Reference Manual, under the entry for C matrix.All Level3 BLAS should havethe same behaviour except from TRSM and TRMM. There is no C matrix for TRSM and TRMM.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page