21489 SIMD question

hi,

i have a question for SIMD

using for SIMD, setting and source cord is like below

is that right?

when i check clock count, no change in clock count

#include <sys/platform.h>
#include "adi_initialize.h"
#include "simd_test.h"
#include <time.h>
#include <math.h>
#include <builtins.h>
#include <cycle_count.h>
#include <cdef21489.h>
#include <def21489.h>
#include <sysreg.h>
#include <builtins.h>

cycle_t start_count;
cycle_t final_count;

/**
* If you want to use command program arguments, then place them in the following string.
*/
char __argv_string[] = "";

int main(int argc, char *argv[])
{
int i,j;
float a=0,b=0;
/**
* Initialize managed drivers and/or services that have been added to
* the project.
* @return zero on success
*/
adi_initComponents();

/* Begin adding your custom code here */
sysreg_bit_set(sysreg_MODE1, PEYEN);
NOP();

START_CYCLE_COUNT(start_count);

#pragma SIMD_for

for(i=0;i<100000;i++)
{
a+=(float)i;
b+=(float)i;
}

STOP_CYCLE_COUNT(final_count, start_count);

return 0;
}

  • 0
    •  Analog Employees 
    on Jan 28, 2020 2:42 PM

    The compiler only produces SIMD code when optimization is enabled. That is not usually the case for the Debug configuration because optimization often results in reordering of code that makes it harder to follow the program flow.

    When the compiler does use SIMD mode, it automaticaly emits code for enabling and disabling it. SIMD mode must not be enabled manually in C/C++ code.

    In the given example, the compiler will completely optimize out the for loop because it can see that the results are not used.

    The compiler generally has to be conservative about the use of SIMD mode, because there are various circumstances where its use would be invalid. The SIMD_for pragma is intended for situations where the compiler was not able to ascertain that the use of SIMD is valid, but where the programmer is able to confirm that the following conditions are fulfilled:

    • There are no accesses to memory that does not support SIMD and LW accesses, for example L1 memory blocks in 48-bit extended precision mode or external memory on ADSP-213xx processors.

    • Memory accesses are suitably aligned where necessary for SIMD mode.

    • There are no memory accesses that rely on data stored during the previous iteration of the loop.

    • There are no memory accesses within consecutive iterations that alias each other.

    • Special constraints hold for any circular buffers used in the loop. The circular buffer length must consist of an even number of elements, and the initial value of the pointer must be aligned to point to an even element.

    Further information can be found in this section of the CCES help:

    SHARC Development Tools Documentation > C/C++ Compiler Manual for SHARC® Processors > Compiler > C/C++ Compiler Language Extensions > SIMD Support