Floating Point Performance LPC1768 vs LPC4088
.
LPC1768 µs/100op | int | float | double |
a=b | 4.5 | 4.5 | 10 |
c=a+b | 9 | 73 | 114 |
c=a*b | 9.5 | 57 | 115 |
c=a/b | 13 | 85 | 188 |
a=sqrt(b) / int->float/double | 23/26 | 128 | 277 |
a=log(b) / float/double->int | 23/29 | 943 | 2995 |
LPC4088 µs/100op | int | float | double |
a=b | 3 | 3 | 8 |
c=a+b | 7 | 9 | 124 |
c=a*b | 7 | 9 | 105 |
c=a/b | 10 | 19 | 149 |
a=sqrt(b) / int->float/double | 6/23 | 27 | 178 |
a=log(b) / float/double->int | 8/26 | 124 | 2721 |
The silly test
#include "mbed.h" void floatPerf() { #define FTEST #ifdef FTEST #define FLT float #else #define FLT int32_t #endif const int n=10; FLT a[n]; FLT b[n]; FLT c[n*n]; double d[n*n]; float disco = 0.0; for(int i=0; i<n; ++i) { a[i]=i*-12.3-4.5; b[i]=i*12.3+4.5; } while(1) { wait_ms(500); disco = 0.0; uint32_t t1 = us_ticker_read(); for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) c[i*n+j]= a[j]; uint32_t te = us_ticker_read()-t1; for(int i=0; i<n*n; ++i) disco+=c[i]; //printf("%f\n",disco); t1 = us_ticker_read(); for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) c[i*n+j]=a[i]+b[j]; uint32_t ts = us_ticker_read()-t1; for(int i=0; i<n*n; ++i) disco-=c[i]; //printf("%f\n",disco); t1 = us_ticker_read(); for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) c[i*n+j]=a[i]*b[j]; uint32_t tm = us_ticker_read()-t1; for(int i=0; i<n*n; ++i) disco+=c[i]; //printf("%f\n",disco); t1 = us_ticker_read(); for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) c[i*n+j]=a[i]/b[j]; uint32_t td = us_ticker_read()-t1; for(int i=0; i<n*n; ++i) disco-=c[i]; //printf("%f\n",disco); t1 = us_ticker_read(); for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) #ifdef FTEST {c[i*n+j]=sqrt(b[j]); /*printf("%f sqrt %f\n",b[j],c[i*n+j]);*/} #else d[i*n+j]=c[i*n+j]; #endif uint32_t tsq = us_ticker_read()-t1; for(int i=0; i<n*n; ++i) #ifdef FTEST disco+=c[i]; #else disco+=d[i]; #endif //printf("%f\n",disco); t1 = us_ticker_read(); for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) #ifdef FTEST {c[i*n+j]=log(b[j]); /*printf("%f log %f\n",b[j],c[i*n+j]);*/} #else c[i*n+j]=d[i*n+j]; #endif uint32_t tln = us_ticker_read()-t1; for(int i=0; i<n*n; ++i) disco-=c[i]; printf("%f %u %u %u %u %u %u\n",disco,te,ts,tm,td,tsq,tln); } } int main() { floatPerf(); return 0; }
Please log in to post comments.