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.

memcpy vs. for loop (for copying multidimensional arrays)

Hi,


I replaced the following for loop with a memcpy function. I see that the performance has degraded (in terms of increased number of clock cycles) for copying multi-dimensional arrays using memcpy function. However, I observed a performance improvement when I replaced a for loop with memcpy function to copy single dimensional arrays.

For loop:

for(k1=0;k1<5;k1++)

{

        for (i = 0; i < 2208; i++) {
                    temp_data_0[2 * i] = Rx_1_data_0[k1][2 * i];
                    temp_data_0[2 * i + 1] = Rx_1_data_0[k1][2 * i + 1];
                }

}

memcpy function:

for(k1=0;k1<5;k1++)

{

    memcpy(&(temp_data_0[0]), &(Rx_1_data_0[k1][0]), 4*(2*2208));

}

Can you please advice if there is any efficient way to copy multidimensional arrays?