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.

LS vs GS memory and cla file interaction



Dear TI,

     If I write a *.cla file, it is correctly compiling anything directly in the *.cla file.  However if I include a support function, say ComplexMatrix.h and I call a function in the *.cla file say I call:

ComplexMatrix_DoSomething( parameters );

It is placing the ComplexMatrix_DoSomething function in GSxMemory with the main CPU application.

So the question is...

Case 1:

I have myFile.cla

I call MyFunc(params) from another file call it...  myFile2.c and myFile2.h

I include myFile2.h in myFile.cla. 

Everything compiles and links fine, but I find that the actual function in myFile2.c is place in GSxRam (main CPU linker file puts it there) and it successful puts all functions IN myfile.cla in the LSx ram.

In Case 1... myFile.cla is the ONLY file that calls myFunc(params) so no usage of myFUnc(params) in a file in the CPU main function

Case 2:

I have a common support functions like complexmatrix, where I use complex matrix data in both the CLA and the CPU code... so I will call various functions like:

ComplexMatrix_Add(params) or ComplexMatrix_GetData(params), and I will do this in the myFile.cla code and the myCPUfile.c (a file associated with the application running on the CPU)

In this case both the CLA and the CPU will call the function to operate on data.  I include the associated header file say ComplexMatrix.h in both the CPU code, and the myFile.cla code.

My understanding was to use the compiler test for

#if defined(__TMS320C28XX_CLA__)

#elif defined(__TMS320C28XX__)

 

#endif

I think the main objective is:

How can I write one function that can be called by both the CLA and CPU...

and also, if I write that one function but it happens to only be called by say the CLA how to get it to recognize that it is only called by the CLA and complile the CLA version of it.

So if I write ComplexMatrix_Add(params) and I'm going to call it from  (Assume written in C for now not assembler) how can I include it in a file called myCLA.cla and myCPU.c (both including ComplexMatrix.h) and have it create the ComplexMatrix_Add(params) function that gets put in LSx memory (ClaProg is default memory space) and a copy in CPU GSx memory... without duplication?

 

Or am I forced to separate everything that will go on the CLA into a *.cla file?

 

I'm thinking because the CLA has different assembler, that it will have to compile two different copies of the same function, so when the CLA calls it it gets a CLA version of it, and when the CPU calls it it gets the CPU version...

it feels like I'll have to have ComplexMatrix.c

and ComplexMatrix.cla

even though they could be identical files, so that it compiles one (.c one) for the CPU and copiles the other (.cla) for the CLA.

However if the files are identical, I would have duplicate function names, so this goes down the path of having

ComplexMatrix_AddCLA(params)

ComplexMatrix_AddCPU(params)

which I'd very much like to avoid ...

 

Hopefully you see the goal of not having to maintain two duplicate copies of CPU and CLA c code for common support functions.

Any suggestions on how to accomplish that?

  • Hi Rob,

    The reason the code is being placed in GS (.text) is that its in a .c file so the C28x compiler compiles it. The CLA compiler only acts on .cla file.

    What you can do is this

    1. define the function in a single .c file, say single_func.c

    #ifdef _TMSc28x__

    foo_c28x()

    #elif defined (__TMS320FCLA__)

    foo_cla()

    #else 

    #error "Something is wrong"

    #endif// 

    {

    code here

    }

    2. in a .cla file

    #include single_func.c

    Now when you build the preprocesser will substitute the code in the .cla file and once the CLA compiler is invoked it will recognize the function foo_cla() and compile for the CLA - it will stick it in Cla1Prog.

    The C28x compiler will compile the file, single_func.c, for the c28x and stick the code in .text. You end up with the same function compiled twice, with different names on different ISAs in different memory sections, but it allows you to maintain a single function.

  • Vishal_Coelho said:

    Hi Rob,

    The reason the code is being placed in GS (.text) is that its in a .c file so the C28x compiler compiles it. The CLA compiler only acts on .cla file.

    What you can do is this

    1. define the function in a single .c file, say single_func.c

    #ifdef _TMSc28x__

    foo_c28x()

    #elif defined (__TMS320FCLA__)

    foo_cla()

    #else 

    #error "Something is wrong"

    #endif// 

    {

    code here

    }

    2. in a .cla file

    #include single_func.c

    Now when you build the preprocesser will substitute the code in the .cla file and once the CLA compiler is invoked it will recognize the function foo_cla() and compile for the CLA - it will stick it in Cla1Prog.

    The C28x compiler will compile the file, single_func.c, for the c28x and stick the code in .text. You end up with the same function compiled twice, with different names on different ISAs in different memory sections, but it allows you to maintain a single function.

    Can you tell me the function of "foo_c28x()"and "foo_cla()",how to write these two functions. thank you !