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.

TMS320C6713B: Pitch shifter code optimization

Part Number: TMS320C6713B

Hello,
I am currently working on the real-time pitch shifter algorithm using DSK6713 and CCS v5.3. My code is working fine, but only with the sampling frequency up to 8 kHz. I cannot use the higher sampling frequency because it takes me too much time (~0,024sec.) to process frame with 1024 samples. To use 44kHz the current frame should be processed in time <0,00582sec, so I would need to optimize my code 4 times. 

The most significant time (~2,353,044 cycles) takes the calculation of magnitude and phase, e.g.:

for(i = 0; i < 1024; i++){
	a = 2*i;
  	r[i]   = sqrt(fft_in[a]*fft_in[a] + fft_in[a+1]*fft_in[a+1]);
  	phi[i] = atan2(fft_in[a+1], fft_in[a]);
  }
and computing phase increment:
float mod(float a, float N) {return a - N*floor(a/N);}


for (i=0; i<1024;i++){ phase_out[i] = mod(phi[i]-phi0[i]-omega[i]+M_PI, -2*M_PI) + M_PI; delta_phi[i] = omega[i] + phase_out[i]; phi0[i] = phi[i]; psi[i] = mod(psi[i]+delta_phi[i]*tstretch_ratio+M_PI, -2*M_PI) + M_PI; }

How could I optimize this code to increase the execution speed? 

Thanks and regards,
Ka

  • Ka,

    The C6713 is an old processor. Why must you use that processor?

    Try the C6748 or C6657 to get better performance.

    You mention nothing about what optimization steps you have taken already, so we cannot address question other than to point you to the Wiki articles on C6000 optimization. Search TI.com for those.

    Your code does not make sense to me, having the mod() function definition immediately followed by a for-loop. This does not appear to be valid C code.

    Regards,
    RandyP
  • Ka,

    There are multiple ways to optimize the code that you have :

    1. DSP compiler based optimization:
    the more information you provide regarding your data types and how many times your loops will iterate the better it performs at parallel processing the data. This has been explained in detail in the app notes below:
    www.ti.com/.../sprabg7.pdf (Optimizing loops on TI DSP )
    www.ti.com/.../sprabf2.pdf (Introduction to optimization for C6000 DSP)
    www.ti.com/.../spru187u.pdf (Optimzing using TI Compiler)

    2. Optimize using TI DSP libraries:
    FastMath Library: http://www.ti.com/tool/mathlib
    DSPLIB: http://www.ti.com/tool/SPRC265

    3. Soc level optimization:
    If you are running code out of DDR, then you need to turn on the cache and potentially relocate critical data into internal DSP memory or on chip memory. you can also use EDMA to move data in and out of DSP internal memory from DDR.
    www.ti.com/.../spru656a.pdf (Cache user guide)
    www.ti.com/.../spru234c.pdf (EDMA User guide)

    Regards,
    Rahul