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.

CLA matrix multiplication in the ISR interrupt

Other Parts Discussed in Thread: CONTROLSUITE

Dear,
I want to multiply two matrices with real number elements on my Delfino F28377D microcontroller.
I tried to implement your example "cla_matrix_mpy" to use a benefits of CLA unit. But I couldn't do it and I am not sure why this happens, I want to figure out it.
My question is: can I start CLA matrix multiplication in my ISR interrupt routine, or I can do it only in the main loop of the processor (not in the processor's interrupt ISR routine) as your example "cla_matrix_mpy" shows?

Thank you!

  • Tihomir Zilic said:
    But I couldn't do it and I am not sure why this happens, I want to figure out it.

    What happens or doesn't happen?  Have you tried the example as it is?

    Tihomir Zilic said:
    My question is: can I start CLA matrix multiplication in my ISR interrupt routine, or I can do it only in the main loop of the processor (not in the processor's interrupt ISR routine) as your example "cla_matrix_mpy" shows?

    A CLA task can be started by the main CPU at any place in the code.  It can be within a C28x ISR or within the main loop.  

  • Thank you for the answer!

    I implemented the code from "cla_matrix_mpy" example into my example. I started CLA_runTest( ) in my ISR routine and this routine works normally. The problem is that I can not get the matrix z as a result of 3x3 x and y matrix multiplication.

    I have figured out that the problem could be connected to CPU1RAM data memory, because if I set in the memory configuration function "CLA_configClaMemory() " the row with  MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS5 =1;  to 0,  then I can see x,y matrices in the CSS Expressions window as they should be, but z is still zero.

    Also, there are some warnings:

    "#10247-D creating output section "Cla1ToCpuMsgRAM" without a SECTIONS specification#

    #10247-D creating output section "CpuToCla1MsgRAM" without a SECTIONS specification

    Do you have any suggestion what could I try to get the matrix z?


    Thank you!

  • Hi,

    In the example, z is placed in the section "Cla1ToCpuMsgRam" and from the console output of your build you have not defined these sections in the linker command file. if you dont assign the message rams to their correct location (0x1480 and 0x1500) the linker will place them in the first available location, which the CLA probably does not have access to -- that is why z is always zero.

    Please see the original linker command file from the example.

  • Thanks Vishal_Coelho!

    under your suggestion I solved my problem. 

    Under Linker options under -> File Search Path I needed to add "2837xD_RAM_CLA_lnk_cpu1.cmd" i.e. ( /ti/controlSUITE/device_support/F2837xD/v130/F2837xD_common/cmd/2837xD_RAM_CLA_lnk_cpu1.cmd ), and under Project Properties -> C2000 Linker -> Advanced Options -> Command File
    // Preprocessing -> --define I needed to write CLA_C.

    I also had to remove "2837xD_RAM_IQMATH_lnk_cpu1.cmd"  I was using from Linker options under -> File Search Path, I suppose it defines some sectors in the RAM memory and it fights to "2837xD_RAM_CLA_lnk_cpu1.cmd".

    All warnings have gone and the example now works!

  • Dear Vishal_Coelho,
    connecting to the previous question, a new question arose to me. The CLA matrix multiplication (dimension of matrices x and y from the example is 3x3) now works and works also when I define matrices elements to float (from uint32_t that were defined in the example). But my real problem is to multiply matrices and vectors defined as A*x, B*u, C*x, D*u where dimensions of matrices and vectors are as follows:

    #define N 7
    #define M 2
    #define K 1
    extern float A[N][N]; //NxN matrix A
    extern float B[N][M]; //NxM matrix B
    extern float C[K][N]; //KxN matrix C
    extern float D[K][M]; //KxM matrix D
    extern float x[N], u[M], y[K];

    It works for N=5 and less, but for N=7 I get error message that:
    "#10099-D program will not fit into available memory.  run placement with alignment/blocking fails for section "CpuToCla1MsgRAM" size 0xa2 page 1.  Available memory ranges:"

    My question is: could I somehow expand memory that would program fits in? Or maybe to distribute different matrix multiplications to other CLA tasks (from 1-8)?

    Thanks!

  • Looks like you cant fit all these matrices in the CpuToCla1MsgRAM, that message ram is max 0x80 words. Since this is the 2837x, you can assign these matrics to any of the LSx RAMs and the C28x should hae read access to it by default. So for example, i could assign these to RAMLS5 using the #pragma and then configure RAMLS5 to be a data RAM for the CLA (in the MemCfgRegs)

  • Dear Vishal_Coelho,

    I did as you suggested and it was successful!

    First in my .c code I defined all my matrices and vectors with new memory sections using #pragma as follows:
    #pragma DATA_SECTION(A, "newRAM")
    float A[][N];
    #pragma DATA_SECTION(B,"newRAM")
    float B[N][M];
    #pragma DATA_SECTION(C,"newRAM")
    float C[K][N];
    #pragma DATA_SECTION(D,"newRAM")
    float D[K][M];
    #pragma DATA_SECTION(x,"CpuToCla1MsgRAM")
    float x[N];
    #pragma DATA_SECTION(y,"Cla1ToCpuMsgRAM")
    float y[K];
    #pragma DATA_SECTION(u,"CpuToCla1MsgRAM")
    float u[M];
    #pragma DATA_SECTION(dx,"Cla1ToCpuMsgRAM")
    float dx[N];
    #endif //__cplusplus

    Then I defined a "newRAM" in the linker file I use 2837xD_RAM_CLA_lnk_cpu1.cmd  putting text   newRAM   : > RAMLS4, PAGE=0 bellow the comment  

    /* CLA specific sections */  . 

    And then in my .c file under the function void CLA_configClaMemory(void) I put the following code :

      // I added this two line bellow to expand CLA memory usage to LS4RAM
        MemCfgRegs.LSxMSEL.bit.MSEL_LS4 = 1; //CLA is owner
        MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS4 = 0; //data block

    Sincerely!

    Best regards!