AnsweredAssumed Answered

How can I do to improve calculation speed?

Question asked by Li Hongrun on Oct 11, 2017
Latest reply on Oct 12, 2017 by jian ma

Hi,all:

        I am using 5775K to do some study,and I find that the code below cost me about 200ms,especially calculate the sum of square and the function sqrt ,how can I do to improve calculation speed? Thank you!!!#5775k

 

void calc_magnitude_doppler( fft_value_t* inAddr, magnitude_t* outAddr){
fft_value_t real, img;
uint64_t quad;
 double sqroot;
uint16_t x, y;

uint32_t MAX,MIN;
for(y=0; y<FFT_NUM_SAMPLES; y++){
// Do it for one chirp
for(x=0;x<FFT_NUM_CHIRPS;x++){

// Pointer to values
real = *(inAddr + (x * FFT_NUM_SAMPLES * 2));
img = *(inAddr + (x * FFT_NUM_SAMPLES * 2) + 1);

 

// Calculate magnitude
quad = (uint64_t)((int64_t)real*real + (int64_t)img*img);
sqroot = sqrt((double)quad);
//sqroot = (double)new_sqrt((float)quad);

 

// Save Value
*(outAddr) = (magnitude_t)sqroot;

// Adjust pointer
outAddr++;
}
// Adjust Pointer
inAddr+=2;
}
}

Outcomes