This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VM: Performing complex multiplication using pointwiseMatrixMatrixMultiply kernel of MMALIB

Part Number: TDA4VM

Hi,

      Does the linear algebra kernel of MMALIB support pointwise complex matrix multiplication? If No, is there any guidelines to perform complex multiplication using MMA OR we have to use C7 compiler intrinsic to implement the custom complex multiplication function.

Regards,

Attiya

  • Hi Attiya,

    What datatype would the real and imaginary parts of the complex number be in this situation?

    Best,

    Asha

  • Hi Asha,

    Thanks for the quick reply. It is in an interleaved form (|REAL0|IMAG0|REAL1|IMAG1|....|REALN|IMAGN|). Basically we can say INT32 Real comes first followed by INT32 Imaginary. 

    Attiya

  • Hi Attiya,

    When you refer to "pointwise complex matrix multiplication" are you referring to a mathematical operation that looks like below? 

    (a + jb) * (c + jd) = (a*c) + j(b*d)

    or are you looking for standard complex multiplication, as defined here?

    Best,

    Asha

  • Hi Asha,

    I am looking for standard pointwise complex multiplication as defined in the link you shared. I have two vectors of complex values in an interleaved form and I want to do pointwise standard complex multiplicaton. What I mean by pointwise is that it's not a matrix multiplication. I want to take one complex sample from each vector at a time and do standard complex multiplication and save it into a resultant complex vector in an interleaved form.

    Attiya

  • Hi Attiya,

    In that case, I don't believe the pointwiseMatrixMatrixMultiply function would work in this case since it's simply performing a C(i,j) = A(i,j) * B(i,j) operation. It would not do all the multiplies that you would need. 

    To go back to your original question, complex multiplication on MMA could theoretically work but we don't have any good guidelines of this, and we do not have an existing MMA-based kernel that would accomplish what you are looking for. 

    I would recommend looking into a C7x based solution, as the compiler offers intrinsics that perform complex multiplication. 

    Best,

    Asha

  • Hi Asha,

    I was thinking to call pointwiseMatrixMatrixMultiply function four times for each of the internal pointwise multiplication. My question was around the Stride parameter if I can skip every other element while performing bulk of pointwise multiplication.

    Seems like you are not recommending going for that route as all the data rearrangement will come in afterwards to get the interleaved form back in the resultant vector. Just a quick question: Do you think C71x compiler intrinsic will be as fast as the MMALIB in my case?

    Attiya

  • Hi Attiya,

    To achieve pointwise matrix multiplication on the MMA architecture, the MMA has reduced throughput (as opposed to a standard matrix multiplication) to achieve the calculation. I talked with our development team on this, and it looks like the C7x intrinsic approach over computing the pointwise multiplications on the MMA would result in better performance for the use-case of complex multiplication.  It looks like the C7x instruction that would be best suited for your application (VCMPYR1WW) which is designed for complex multiplication would result in an ii of 1, and I believe has the output data format you are looking for. 

    Best,

    Asha

  • Hi Asha,

    Thank you for all the help, appreciate it.

    Attiya