Post Go back to editing

Referencing diffrent large sized array buffers in blackfin by using L1, L2 and external memory

Category: Software
Product Number: ADSP-BF609
Software Version: CCES 12.2.1

HI,

I am developing an template matching algorithm in Blackfin(BF-609), for that i am using many image buffers with size 128*128 of complex_fract32 , fract32. While i am defining them in my code without enabling external memory usage setting in LDF settings then i am getting some fatal errors like OUT OF L1 MEMORY , out of L2 memory. But if enable external memory usage then errors got cleared but it takes more time to compute .

For example, if I only use rfft2d_fr16() with four array buffers which is done without enable use external memory setting is takes 2ms ,
but while i am using the same function by enabling external memory usage I am getting more than 7ms. Why?

I need explanation on this L1,L2 usage , I checked help contents but my answere was not cleared .

so Can you tell me how can use L1 and L2 memories in Core0 of Bf609 by helping with some initializations and definitions, And tell me about app.ldf settings what to mention and how to mention and provide some examples.

because i need to implent my algorithm with low time by using internal memory most preferable than external memory.


Thanks & regards,
Santhosh.

Thread Notes

  • Hi Santhosh,

    Thank you for your inquiry.

    You have to use the #pragma section("section_name") directive to force your specific code/data into L1 and L2 memory. Use this before each function or variable that you want to place in L1 and L2 memory. This pragma will only affect the next symbol and if you use this pragma right before a function, that function alone will be placed in the section.

    You can provide any name in section name. But the memory section name should as it is named in app.ldf file. We have given details as commented below.

    For example:

    #pragma section("custom_section_name")
    int Array[Size];

    Also, add the appropriate INPUT_SECTIONS commands to your LDF in a suitable place in app.ldf, like below.
    custom_section_name //Output section
    {
    INPUT_SECTIONS( $OBJS_LIBS(custom_section_name) ) // Input section
    } > mem_block0_bw // Memory section

    OR

    If you need to place all the data/function in particular memory section (where contains the available memory to map all those together),then the way is to map the object file to particular memory section.

    For example, if you create a test.c,test1.c,test3.c -> which contains the declaration, then it creates a object file called "test.doj, test1.doj,..." while building. So, you can map the whole object file(Test.doj) in different memory section you preferred, this is done by simply adding the following line to an appropriate section in the LDF:

    INPUT_SECTIONS( Test.doj(seg_dmda) )
    INPUT_SECTIONS( Test.doj(seg_code) )

    Your LDF should then be roughly of the form:

    PROCESSOR CORE_0
    {
    ...
    dxe_block1_data_prio0_bw BW
    {
    FORCE_CONTIGUITY
    INPUT_SECTION_ALIGN(4)
    INPUT_SECTIONS( test.doj(seg_int_data) )
    } > mem_block1_bw
    ...

    }

    And, you have to let the linker knows the location of the "test.doj", this can be done by including the path of the test.doj, by go to project properties > C/C++ Build > Settings > Tools Settings > CrossCore Blackfin Linker > General > Library Search directories(-L). Click on (+) button and browse workspace and select the "project > Debug > Src" folder.

    To prevent modifications being over written by the tools, You should apply any your modification to the sections which allow customization of the LDF by users. The sections are denoted by:

    /*$VDSG<insert-user-ldf-commands> */
    /* Text inserted between these $VDSG comments will be preserved */
    /*$VDSG<insert-user-ldf-commands> */

    Text inserted between these $VDSG comments will be preserved and any changes made outside of $VDSG section will be lost when the LDF is regenerated.

    Please refer in CCES help for more information:
    CrossCore® Embedded Studio 2.x.x > Blackfin® Development Tools Documentation > C/C++ Compiler and Library Manual for Blackfin® Processors > Compiler > C/C++ Compiler Language Extensions > Pragmas > Linking Control Pragmas > #pragma section/#pragma default_section

    You can also enable the 'Generate Symbol Map' option under the 'General' options for the Linker. This will produce an XML map file, detailing all objects and memory usage/placement within your application which can be viewed in CCES's internal browser, via Right-clicking on the Proj_name_map.xml in CCES project explorer > open with > Other > internal web browser.

    It shows the memory sections declared in the LDF, their start and end bounds and - most importantly - their free/used space. Using this map file you can determine whether there is perhaps a memory section that is being under-used that you could place more data into.

    Also, could you please try with two Linker Optimization options enabled and see whether this could help from below Ezone thread.
    ez.analog.com/.../474583

    If you are still facing out of memory, could you please share us your complete project, This will help us to assist you further.

    Hope this helps.

    Regards,
    Santhakumari.V

  • Hi Santhakumari  ,

    Thank you for your response, and here i am providing below how my application flow how it  looks like.

    section("sdram_bank0") unsigned short EPPI_frame[384*288];

    fract32 main_image[64*64];

    fract32 template_image[32*32];

    fract32 padding_tmplate[128*128];

    fract32 padding_main[128*128];

    section("sdram_bank0")  complex_fract32 temp[128*128];

    complex_fract32 Twiddle_table[(128*3)/4];

    complex_fract32 output1[128*128];

    complex_fract32 output2[128*128];

    complex_fract32 multiplication[128*128];

    complex_fract32 corr_out[128*128];

    fract32 temp[128*128];

    fract32 Lsum[95*95];

    fract32 Lsum2[95*95];

    double diff_local[95*95];

    double NxCC[95*95];

    double Numerator[95*95];

    double denominator[95*95];

    int main()
    {


    twiddle2d_fr32();


    while(1)

    {
    //application regarding template matching
    // here i am using all above mentioned data buffers for FFT , complex multiplication, IFFT, and  Normalisation.

    }

    }
    Here my application taking huge time of execution more tha 50ms, my question is can i get this application below 15ms and if it possible then help me .

    I am suspecting memory accessing time playing key role here, if you help me in arranging my data buffers to optimize my application speed it will help me a lot and any tool or application settings if need.

    Thank you  ,
    Santhosh.

  • Hi Santhosh,

    ADSP-BF609 dual core processors contain a hierarchical memory model (L1-L2-L3) similar to that in previous Blackfin devices. Thus, the memory related optimization techniques discussed in System Optimization Techniques for Blackfin® Processors (EE-324) apply for ADSP-BF609 processors also.

    Please find the below link for the application note EE-324.
    http://www.analog.com/media/en/technical-documentation/application-notes/EE_324_Rev_1_07_2007.pdf

    Also, please refer to the EE note and corresponding example code in below path for code optimization of Blackfin processor.
    https://www.analog.com/media/en/technical-documentation/application-notes/EE362.pdf

    https://www.analog.com/media/en/technical-documentation/application-notes/EE362V01.zip


    You can also refer the CCES help.
    CrossCore® Embedded Studio 2.x.x > Blackfin® Development Tools Documentation > C/C++ Compiler and Library Manual for Blackfin® Processors > Optimal Performance from C/C++ Source Code

    Hope This helps.

    Regards,
    Santhakumari.V

  • Hi Santhakumri  ,

    Thank you for your response, I am going thru your answere and I will get back to you.

    Thanks,
    Santhosh