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

'omatadd' and aliasing

DavidCortes
Beginner
440 Views

Functions 'omatadd' perform the following operation:
C := alpha*op(A) + beta*op(B)

In the documentation for 'omatadd':
https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-c/2023-0/mkl-omatadd.html

It mentions:
> Note that different arrays must not overlap.

However, compared to other functions, here each value in the inputs is involved in only one resulting value in the outputs. In theory, if this function were to be implemented with a naive C for-loop, it should work correctly even if one of the input and output arrays is aliased.

From some experiments, it seems to work correctly for the following operation:
B := alpha*A + 1*B

i.e. passing the same input under both B and C, which is unclear whether it counts as "overlap" or not.

Is this function guaranteed to provide the correct output if one of the inputs with no-trans "op" is passed as the output C?

i.e. is it possible to use this function to perform the following operation?
B := alpha*op(A) + beta*B

If so, would be very helpful to add this in the documentation, or at the very least to clarify whether aliasing counts as arrays "overlapping" or not.

0 Kudos
1 Solution
Andrew_Barker
Employee
426 Views

The kind of operation you are doing is supported in oneMKL 2023.0 and later. The requirements are better described in the DPCPP documentation (https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2024-0/omatadd.html), specifically:

  • A and C may point to the same memory if op(A) is non-transpose and lda = ldc;

  • B and C may point to the same memory if op(B) is non-transpose and ldb = ldc.

I agree that the documentation for the C API is incomplete and will make a note to try to get that updated. Thank you for pointing this out.

View solution in original post

0 Kudos
1 Reply
Andrew_Barker
Employee
427 Views

The kind of operation you are doing is supported in oneMKL 2023.0 and later. The requirements are better described in the DPCPP documentation (https://www.intel.com/content/www/us/en/docs/onemkl/developer-reference-dpcpp/2024-0/omatadd.html), specifically:

  • A and C may point to the same memory if op(A) is non-transpose and lda = ldc;

  • B and C may point to the same memory if op(B) is non-transpose and ldb = ldc.

I agree that the documentation for the C API is incomplete and will make a note to try to get that updated. Thank you for pointing this out.

0 Kudos
Reply