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.

Compiler/TDA2EVM5777: TI arm compiler takes ages to build opencv five-point.cpp

Part Number: TDA2EVM5777

Tool/software: TI C/C++ Compiler

Hi,

I came across a situation where TI arm compiler fails or taking very very long time to compile five-point.cpp from opencv package.

This particular file has long list of some polynomial coefficients calculation. Its past half hour but still its compiling. 

Not sure if it stucked somewhere or its actually compiling but taking very long time. --verbose flag to see what's happening didn't help.

How can I know the progress of compilation? How long should I wait?

Please check.

PS. Same file gets compiled very quickly within 2 minutes with gcc arm compiler.

Test procedure:

  • Extract attached zip file to <TI ARM compiler root>/bin
  • Execute this command:  ./armcl.exe -c opencv/calib3d/source/five-point.cpp -I opencv/include/ -I opencv/include/opencv2 -I opencv/include/opencv -I ../include/
  • Compiler version: TI ARM C/C++ Compiler v16.9.2.LTS

 

PC configuration:


Processor: Intel core-i7-6820HQ CPU@2.70 GHz

Installed RAM: 32 GB

OS: windows 7 64 bit

Thanks,

Shailesh

opencv.zip

  • Hi,
    Code now compiled but it took around 1 hour for this file.
    This is too much!

    Thanks,
    Shailesh
  • The problem is in the function getCoeffMat.  It contains 200 expressions in a row that are similar to ...

    A[124]=-1.*e[14]*e[19]*e[1]+e[14]*e[22]*e[4]-1.*e[14]*e[18]*e[0]-1.*e[14]*e[25]*e[7]-1.*e[14]*e[24]*e[6]-1.*e[23]*e[10]*e[1]+e[23]*e[13]*e[4]-1.*e[23]*e[16]*e[7]-1.*e[23]*e[15]*e[6]-1.*e[23]*e[9]*e[0]+e[23]*e[12]*e[3]+e[17]*e[21]*e[6]+e[17]*e[3]*e[24]+e[17]*e[22]*e[7]+e[17]*e[4]*e[25]+e[17]*e[5]*e[26]-1.*e[5]*e[24]*e[15]-1.*e[5]*e[25]*e[16]-1.*e[5]*e[18]*e[9]-1.*e[5]*e[19]*e[10]+e[26]*e[12]*e[6]+e[26]*e[3]*e[15]+e[26]*e[13]*e[7]+e[26]*e[4]*e[16]+e[11]*e[18]*e[3]+e[11]*e[0]*e[21]+e[11]*e[19]*e[4]+e[11]*e[1]*e[22]+e[11]*e[20]*e[5]+e[11]*e[2]*e[23]+e[20]*e[9]*e[3]+e[20]*e[0]*e[12]+e[20]*e[10]*e[4]+e[20]*e[1]*e[13]+e[20]*e[2]*e[14]+e[5]*e[21]*e[12]+3.*e[5]*e[23]*e[14]+e[5]*e[22]*e[13]+e[8]*e[21]*e[15]+e[8]*e[12]*e[24]+e[8]*e[23]*e[17]+e[8]*e[14]*e[26]+e[8]*e[22]*e[16]+e[8]*e[13]*e[25]+e[2]*e[18]*e[12]+e[2]*e[9]*e[21]+e[2]*e[19]*e[13]+e[2]*e[10]*e[22]+e[14]*e[21]*e[3];

    The code generation phase of the compiler works on an entire function at a time.  In this case, a representation of all 200 expressions resides in memory at once.  This causes your host system to thrash, which takes a long time.

    The answer is to split the function up into smaller functions.  In this case, I suggest you write 10 helper functions, each of which computes 20 expressions.  The first such function would start like this ...

    static void gcm0(double *e, double *A, double *ep2, double *ep3)
    {
            A[0]=e[33]*e[28]*e[32]-e[33]*e[31]*e[29]+e[30]*e[34]*e[29]-e[30]*e[28]*e[35]-e[27]*e[32]*e[34]+e[27]*e[31]*e[35];
            A[146]=.5000000000*e[6]*ep2[8]-.5000000000*e[6]*ep2[5]+.5000000000*ep3[6]+.5000000000*e[6]*ep2[7]-.5000000000*e[6]*ep2[4]+e[0]*e[2]*e[8]+e[3]*e[4]*e[7]+e[3]*e[5]*e[8]+e[0]*e[1]*e[7]-.5000000000*e[6]*ep2[1]-.5000000000*e[6]*ep2[2]+.5000000000*ep2[0]*e[6]+.5000000000*ep2[3]*e[6];
    	/* and so on */
    
    }

    Replace the first 20 expressions with a call to gcm0.  Repeat 9 more times.  

    I realize this is not much fun.  I wish there were a way to automate it.  

    Thanks and regards,

    -George

  • Thanks George for input!
    But with gcc this problem doesn't happen.
    Probably TI need to smartly automate this process in compiler.

    Regards,
    Shailesh