AnsweredAssumed Answered

How to organize buffers in memory for optimization ?

Question asked by pereira on Jul 28, 2016
Latest reply on Oct 3, 2016 by Jithul_Janardhanan

Hi !

In the following code, I have two versions that have the exact same results in terms of cycles.

But I was told that by placing buffers in different memory sections, I would have better results in terms of MIPS when doing operations like additions, or multiplications.

In this case, console returns : Number of cycles : 3041, in both cases...

 

Did I miss something ?

 

Using ADSP-21489 in Simulation mode.

 

#include <stdio.h>

#include <stdlib.h>

#include <cycle_count.h>

 

#define VERSION_1

 

#ifdef VERSION_1

section ("seg_pmda") int a_buffer[2048];

section ("seg_dmda") int b_buffer[2048];

section ("seg_dmdb") int c_buffer[2048];

#else

section ("seg_dmda") int a_buffer[2048];

section ("seg_dmda") int b_buffer[2048];

section ("seg_dmda") int c_buffer[2048];

#endif

 

int main(int argc, char *argv[])

{

    for(i = 0 ; i < 2048 ; i++)

    {

        a_buffer[i] = i;

        b_buffer[i] = i;

    }

   

    int* p_a = &a_buffer[0];

    int* p_b = &b_buffer[0];

    int* p_c = &c_buffer[0];

   

    START_CYCLE_COUNT(start_count);

    #pragma SIMD_for

    for(i = 0 ; i < 2018 ; i++)

    {

        *p_c++ = *p_a++ * *p_b++;

    }

    STOP_CYCLE_COUNT(final_count,start_count);

    PRINT_CYCLES("Number of cycles : ",final_count);  

}

Outcomes