cortex-mcmsis

Cortex M4 DSP: Maximum of table int16_t


I would like to accelerate the following code which computes the maximum value of a table:

int16_t max = 0;
int16_t *in16 = (int16_t *)myptr;
for (i = 0; i < 256; i++) {
    int16_t val = *in16++;
    if (val > max)
    max = val;
}
return max;

Is there a Cortex M4 DSP instruction that computes the maximum of adjacent values. I can't find any.

In CMSIS, I see "arm_max_q15". How is implemented this function?


Solution

  • There doesn't seem to be much acceleration possible. The code of arm_max_q15 is here: https://github.com/ARM-software/CMSIS/blob/master/CMSIS/DSP_Lib/Source/StatisticsFunctions/arm_max_q15.c