- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hi,
I am trying to multiply a 4x1 matrix (a column vector) by a 1x3 matrix (row vector) using dgemm. The code is attached, I can't seem to get the parameters right. The attached version outputs "MKL ERROR: Parameter 11 was incorrect on entry to cblas_dgemm". I tried different values and couldn't get it right.
Any clues?
Thanks,
Hagai.
multcolumnrow.cpp
Link kopiert
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hagai,
According to the mkl_cblas.h cblas_gemm function has the follwing interface:
void cblas_dgemm(const CBLAS_ORDER Order, const CBLAS_TRANSPOSE TransA,
const CBLAS_TRANSPOSE TransB, const MKL_INT M, const MKL_INT N,
const MKL_INT K, const double alpha, const double *A,
const MKL_INT lda, const double *B, const MKL_INT ldb,
const double beta, double *C, const MKL_INT ldc);
MKL ERROR: Parameter 11 was incorrect on entry to cblas_dgemm
This means, that ldb argument is wrong in your example.
Please use the following arguments:
cblas_dgemm(
CblasRowMajor,
CblasNoTrans,
CblasNoTrans,
HEIGHT,
WIDTH,
1,
1.0,
ColumnVector,
1, // !!!
RowVector,
WIDTH, // !!!
1.0,
Result,
WIDTH); // !!!
So, the result is:
2 2 2
2 2 2
2 2 2
2 2 2
Thanks
--Victor
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hagai.
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
BTW,you need tochange PrintMatrix function to see results correctly:
(I used i+1)
void PrintMatrix(double* pMatrix, const size_t nRows, const size_t nCols)
{
for (size_t i=0; i
for (size_t j=0; j
cout << pMatrix[i * nCols + j] << 't'; // !!!
}
cout << endl;
}
cout << endl;
}
int main()
{
double ColumnVector[HEIGHT];
double RowVector[WIDTH];
double Result[WIDTH * HEIGHT];
for (int i=0; i
PrintMatrix(ColumnVector, HEIGHT, 1);
for (int i=0; i
PrintMatrix(RowVector, 1, WIDTH);
cblas_dgemm(
CblasRowMajor,
CblasNoTrans,
CblasNoTrans,
HEIGHT,
WIDTH,
1,
1.0,
ColumnVector,
1,
RowVector,
WIDTH,
1.0,
Result,
WIDTH);
PrintMatrix(Result, HEIGHT, WIDTH);
return 0;
}
Pleaselook at MKL examples/cblas/source/cblas_dgemmx.c file for more details.
Thanks
--Victor
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hagai,
According to the mkl_cblas.h cblas_gemm function has the follwing interface:
void cblas_dgemm(const CBLAS_ORDER Order, const CBLAS_TRANSPOSE TransA,
const CBLAS_TRANSPOSE TransB, const MKL_INT M, const MKL_INT N,
const MKL_INT K, const double alpha, const double *A,
const MKL_INT lda, const double *B, const MKL_INT ldb,
const double beta, double *C, const MKL_INT ldc);
MKL ERROR: Parameter 11 was incorrect on entry to cblas_dgemm
This means, that ldb argument is wrong in your example.
Please use the following arguments:
cblas_dgemm(
CblasRowMajor,
CblasNoTrans,
CblasNoTrans,
HEIGHT,
WIDTH,
1,
1.0,
ColumnVector,
1, // !!!
RowVector,
WIDTH, // !!!
1.0,
Result,
WIDTH); // !!!
So, the result is:
2 2 2
2 2 2
2 2 2
2 2 2
Thanks
--Victor
Hello Victor Pasco,
i am trying to do same with the dgemm(..) but it still does not work for me. I am multiplying an A:= 16x4 with B:= 4x1. alpha=1.0, beta=1.0. a,b are stored in rows so the first parameters have to be "T" for transposed right?
dgemm("T","T",&sixteen,&one,&four,α,a,&sixteen,b,&four,β,c,&sixteen);
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
Hello Victor Pasco,
i am trying to do same with the dgemm(..) but it still does not work for me. I am multiplying an A:= 16x4 with B:= 4x1. alpha=1.0, beta=1.0. a,b are stored in rows so the first parameters have to be "T" for transposed right?
dgemm("T","T",&sixteen,&one,&four,α,a,&sixteen,b,&four,β,c,&sixteen);
Hagai,
So, you decided to not use CBLAS while you have alreadyworking sources.
And what's error message now?Or it's another problem.
Did you look at corresponding BLAS examples (on FORTRAN) and MKL docs to correctly pass arguments from C/C++?
Thanks
--Victor
- Als neu kennzeichnen
- Lesezeichen
- Abonnieren
- Stummschalten
- RSS-Feed abonnieren
- Kennzeichnen
- Anstößigen Inhalt melden
- RSS-Feed abonnieren
- Thema als neu kennzeichnen
- Thema als gelesen kennzeichnen
- Diesen Thema für aktuellen Benutzer floaten
- Lesezeichen
- Abonnieren
- Drucker-Anzeigeseite