Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
7117 Discussions

Sparse BLAS initialization of C in C=(alpha*A*B + beta* C) when beta=0.0

AndrewC
New Contributor III
554 Views
There are a number of Sparse BLAS routines such as mkl_?cscmm etc that compute, say,C=(alpha*A*B + beta* C) or similar.

I would assume that if beta==0.0 that the matrix C does not need to be initialized to 0.0 ( or any other value). That is that MKL will not do the beta*C operation if beta is identically 0.0. It is not clear from the documentation.

I ask this as I have found this NOT to be the case with mkl_?cscmm. I was not initializing C. Most of the time this is ok, as all entries of beta*C will evaluate to 0.0. However, sometimes, the un-initialized memory of C would randomly be some kind of NaN, and beta(0.0) * NaNevaluatedto a NaN which polluted the resultant matrix.

zgemm(3) does not have this 'problem'. It specifically says "When beta is equal to zero, then c need not be set on input".

0 Kudos
1 Solution
Gennady_F_Intel
Moderator
554 Views
Vasci, yes this is the bug and we will work at this problem in the next version.
--Gennady


Hi Vasci,

The problem you reported was fixed in the version 10.2.
This version available for download from intel registration center: https://registrationcenter.intel.com/

I am closing the issue.
You can reopen this issue within 30 days or open a new one
if you will encounter further problem with this issue.

Regards, Gennady
Please see below the output for the MKL 10.1 and MKL 10.2 versions:

==================== MKL 10.1 ==========================

EXAMPLE PROGRAM FOR COMPRESSED SPARSE ROW FORMAT ROUTINES

INPUT DATA FOR MKL_DCSCMM
WITH TRIANGULAR MATRIX
M = 5 N = 2
ALPHA = 1.0 BETA = 0.0
TRANS = 'T'
Input matrix
1.0 5.0
1.0 4.0
1.0 3.0
1.0 2.0
1.0 1.0

OUTPUT DATA FOR MKL_DCSCMM
WITH TRIANGULAR MATRIX
>>>> -1.$ >>>> -1.$
>>>> -1.$ >>>> -1.$
>>>> -1.$ >>>> -1.$
>>>> -1.$ >>>> -1.$
>>>> -1.$ >>>> -1.$
Press any key to continue . . .


==================== MKL 10.2 ===========================

EXAMPLE PROGRAM FOR COMPRESSED SPARSE ROW FORMAT ROUTINES

INPUT DATA FOR MKL_DCSCMM
WITH TRIANGULAR MATRIX
M = 5 N = 2
ALPHA = 1.0 BETA = 0.0
TRANS = 'T'
Input matrix
1.0 5.0
1.0 4.0
1.0 3.0
1.0 2.0
1.0 1.0

OUTPUT DATA FOR MKL_DCSCMM
WITH TRIANGULAR MATRIX
>>>> -5.0 >>>> -11.0
>>>> 13.0 >>>> 28.0
>>>> 6.0 >>>> 16.0
>>>> 7.0 >>>> 14.0
>>>> -5.0 >>>> -5.0
Press any key to continue . . .

--Gennady

View solution in original post

0 Kudos
3 Replies
Gennady_F_Intel
Moderator
554 Views
Vasci, yes this is the bug and we will work at this problem in the next version.
--Gennady

0 Kudos
juhar
Beginner
554 Views
But 0 * NaNshould equal NaN, no?
As in:
double n = 0 * std::numeric_limits::quiet_NaN();
printf("%f", n);
which outputs: 1.#QNAN0
0 Kudos
Gennady_F_Intel
Moderator
555 Views
Vasci, yes this is the bug and we will work at this problem in the next version.
--Gennady


Hi Vasci,

The problem you reported was fixed in the version 10.2.
This version available for download from intel registration center: https://registrationcenter.intel.com/

I am closing the issue.
You can reopen this issue within 30 days or open a new one
if you will encounter further problem with this issue.

Regards, Gennady
Please see below the output for the MKL 10.1 and MKL 10.2 versions:

==================== MKL 10.1 ==========================

EXAMPLE PROGRAM FOR COMPRESSED SPARSE ROW FORMAT ROUTINES

INPUT DATA FOR MKL_DCSCMM
WITH TRIANGULAR MATRIX
M = 5 N = 2
ALPHA = 1.0 BETA = 0.0
TRANS = 'T'
Input matrix
1.0 5.0
1.0 4.0
1.0 3.0
1.0 2.0
1.0 1.0

OUTPUT DATA FOR MKL_DCSCMM
WITH TRIANGULAR MATRIX
>>>> -1.$ >>>> -1.$
>>>> -1.$ >>>> -1.$
>>>> -1.$ >>>> -1.$
>>>> -1.$ >>>> -1.$
>>>> -1.$ >>>> -1.$
Press any key to continue . . .


==================== MKL 10.2 ===========================

EXAMPLE PROGRAM FOR COMPRESSED SPARSE ROW FORMAT ROUTINES

INPUT DATA FOR MKL_DCSCMM
WITH TRIANGULAR MATRIX
M = 5 N = 2
ALPHA = 1.0 BETA = 0.0
TRANS = 'T'
Input matrix
1.0 5.0
1.0 4.0
1.0 3.0
1.0 2.0
1.0 1.0

OUTPUT DATA FOR MKL_DCSCMM
WITH TRIANGULAR MATRIX
>>>> -5.0 >>>> -11.0
>>>> 13.0 >>>> 28.0
>>>> 6.0 >>>> 16.0
>>>> 7.0 >>>> 14.0
>>>> -5.0 >>>> -5.0
Press any key to continue . . .

--Gennady
0 Kudos
Reply