Part Number: AM3358
Hi,
I am using Pocket Beagle bone with AM3358 processor. I want to perform an Interpolation function. When checked, the time taken to execute the function by the AM3358 processor on DebianOS was seen to be around 15-20 milli Sec. So, I decided to test the same code with a Linux system(Laptop), whose clock frequency is 2.0G Hz with an intel i3 processor. The time taken on Linux system was approx. 0-2 milli Sec. I assume the behavior of the AM3558 execution would be much better than the current result. I am using GCC for the compilation of the code. I am using the below command for the compilation with some optimization on AM3358.
gcc speed_test.c -Ofast -mtune=cortex-a8 -mfpu=neon -funsafe-math-optimizations --param l1-cache-size=32 --param l2-cache-size=256
For Linux system(Laptop), I am using the below command:
gcc speed_test.c -Ofast -funsafe-math-optimizations --param l1-cache-size=32 --param l2-cache-size=256
I think, I am doing something wrong in setting the configuration of GCC or the target processor. I have attached the code in the post.
Any help regarding the same would be appreciated.
Thanks & Regards,
Matt Dave.
/*Code for execution of Interpolation function*/ #include "stdio.h" #include "float.h" #include "sys/time.h" #define PER_16 16 #define PHI_90 90 float dist; int idx; int i1; float newDist; /** * @brief Find nearest point. * @param value : to be found. * x : source pointer. * len : number of points. * @retval None */ int findNearestNeighbourIndex(float value,float *x,int len) { idx=-1; dist=DBL_MAX; for(i1=0;i1<len;i1++) { newDist=(value-x[i1]); if((newDist>=0) && (newDist<dist)) { dist=newDist; idx=i1; } } return idx; } /*Function to get the current time*/ static long TimeM() { struct timeval time; gettimeofday(&time,NULL); return time.tv_sec*1000 + time.tv_usec/1000; } /** * @brief Find nearest point. * @param value : to be found. * x : source pointer. * len : number of points. * indice : previous index. * @retval idx : index of the nearest point. */ int my_findNearestNeighbourIndex(float value,float *x,int len, int indice) { volatile int s_index = 0, e_index = 0, index_offset; idx=-1; dist=DBL_MAX; index_offset = (PHI_90/3); s_index = (indice-5);//starting index if(s_index <= 0)//checks if index is out of minimum boundary limit s_index = 0; e_index = (indice+index_offset);//ending index if(e_index >= len)//checks if index is out of maximum boundary limit e_index = len; for(i1=(s_index);i1<(e_index);i1++) { newDist=(value-x[i1]); if((newDist>=0) && (newDist<dist)) { dist=newDist; idx=i1; } } return idx; } /** * @brief Interpolation Function * @param x : source pointer. * x_tam : length of x. * y : source pointer. * xx : pointer to the reference. * xx_tam : length of xx. * yy : destination pointer. * @retval None */ void interp1(float *x,int x_tam, float *y,float *xx,int xx_tam,float *yy) { float dx,dy; float slope1, intercept1; register int i,indiceEnVector; indiceEnVector=findNearestNeighbourIndex(xx[0],x,x_tam);//find the nearest signal point index with respect to timedomain points for(i=0;i<=xx_tam;i++) { if(i>0) { indiceEnVector = my_findNearestNeighbourIndex(xx[i],x,x_tam,indiceEnVector);//find the nearest signal point index with respect to timedomain points } if(indiceEnVector != -1)//checks if nearest point is found { dx = (x[(indiceEnVector+1)] - x[indiceEnVector]); //change in x units dy= (y[(indiceEnVector+1)] - y[indiceEnVector]); //change in y units slope1 = (dy/dx); // slope intercept1 = (y[indiceEnVector]-x[indiceEnVector]*slope1); // intercept is calculated c=y-mx where m is slope and x,y are points with respect to index yy[i]=(slope1*xx[i]+intercept1); // straight line equation y=mx+c to find angle domain point. } else { yy[i]=DBL_MAX; // if no nearest point is found then index is -1 and default value is returned } } } int main() { unsigned int n = 32768; float Block_Time[n]; unsigned int nn = ((PER_16 * PHI_90)); float angledomain[nn]; float signal[n]; float timedomain[nn]; long start = TimeM(); interp1(Block_Time,n,signal,timedomain,nn,angledomain); long end = TimeM(); printf("Total Time : %ld\r\n",(end-start)); //Print the time taken return 0; }