I use the program given below to examine the runtime of certain statements. The macro multiExeMM generates code for MM matrix multiplications. In the example below MM=10000. The compiler then needs 30 minutes (!) for compilation of the 40000 statements. For MM=1000 the compiler only needs 15 seconds. Why is compilation for MM=10000 so long? Can I change some options to make it faster?
Code:
int led = 13;
#define NN 10
#define MM 10000
#define multiExe1 {\
yy1=a11*x1+a12*x2 ; \
yy2=a21*x1+a22*x2 ;\
x1=yy1 ;\
x2=yy2 ;\
}
#define multiExe5 {\
multiExe1 \
multiExe1 \
multiExe1 \
multiExe1 \
multiExe1 \
}
#define multiExe25 {\
multiExe5 \
multiExe5 \
multiExe5 \
multiExe5 \
multiExe5 \
}
#define multiExe100 {\
multiExe25 \
multiExe25 \
multiExe25 \
multiExe25 \
}
#define multiExe500 {\
multiExe100 \
multiExe100 \
multiExe100 \
multiExe100 \
multiExe100 \
}
#define multiExe1000 {\
multiExe500 \
multiExe500 \
}
#define multiExe10000 {\
multiExe1000 \
multiExe1000 \
multiExe1000 \
multiExe1000 \
multiExe1000 \
multiExe1000 \
multiExe1000 \
multiExe1000 \
multiExe1000 \
multiExe1000 \
}
float x1,x2,yy1,yy2 ;
float phi1,phiNNMM ;
float a11,a12,a21,a22 ;
float b11,b12,b21,b22 ;
float xshb1,xshb2 ;
void setup() {
pinMode(led, OUTPUT);
Serial.begin(115200);
delay(500) ;
Serial.println("teensy40timingMat22Mul1...") ;
Serial.print("F_CPU=") ; Serial.println(F_CPU) ;
Serial.print("MM =") ; Serial.println(MM) ;
phi1=PI/7/NN ;
phiNNMM=MM*NN*phi1 ;
a11=cos(phi1) ;
a12=sin(phi1) ;
a21=-sin(phi1) ;
a22=cos(phi1) ;
if(a11==1.0){ Serial.println("a11==1 !") ; }
if(a12==0.0){ Serial.println("a12==0 !") ; }
b11=cos(phiNNMM) ;
b12=sin(phiNNMM) ;
b21=-sin(phiNNMM) ;
b22=cos(phiNNMM) ;
x1=1.0 ; x2=0.0 ;
xshb1=b11*x1+b12*x2 ;
xshb2=b21*x1+b22*x2 ;
x1=1.0 ; x2=0.0 ;
uint32_t microsStart=micros() ;
for(int k=0 ; k<NN ; k++){
multiExe10000
}
uint32_t microsStop=micros() ;
int32_t microsCount=microsStop-microsStart ;
float microsTime=microsCount*1e-6 ;
Serial.printf("micros: start=%10i stop=%10i count=%5i time=%8.3f us cyclesPerBlock= %10.5f\n",microsStart,microsStop,microsCount,microsTime/1e-6,(microsTime/(NN*MM)*F_CPU)) ;
Serial.printf("x1 =%15.10f x2 =%15.10f\n",x1,x2) ;
Serial.printf("xshb1=%15.10f xshb2=%15.10f\n",xshb1,xshb2) ;
}
void loop() { }