/mobile Handheld Friendly website
Ubuntu : Intel® Q6600® one core |
Each table row shows performance measurements for this C gcc program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 500 | 0.02 | 0.02 | ? | 669 | 0% 0% 0% 100% |
| 3,000 | 0.88 | 0.89 | 70,848 | 669 | 2% 0% 2% 100% |
| 5,500 | 3.76 | 3.77 | 236,904 | 669 | 1% 0% 1% 100% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read spectral-norm benchmark to see what this program should do.
gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
/* The Computer Language Benchmarks Game * http://benchmarksgame.alioth.debian.org/ * * Contributed by Sebastien Loisel * Modified by Alex Belits */ #include <stdio.h> #include <stdlib.h> #include <math.h> double *A_global=NULL; int N_global; double eval_A(int i, int j) { return 1.0/((i+j)*(i+j+1)/2+i+1); } int prepare_A(int N) { int i,j; N_global=N; A_global=(double*)malloc(N*N*sizeof(double)); if(A_global==NULL) return -1; for(i=0;i<N;i++) { for(j=0;j<N;j++) { A_global[i*N+j]=eval_A(i,j); } } return 0; } double get_A(int i, int j) { return A_global[i*N_global+j]; } void eval_A_times_u(int N, const double u[], double Au[]) { int i,j,n2; double t0,t1; n2=N&~1; for(i=0;i<n2;i+=2) { t0=0; t1=0; for(j=0;j<N;j++) { t0+=get_A(i,j)*u[j]; t1+=get_A(i+1,j)*u[j]; } Au[i]=t0; Au[i+1]=t1; } if(i!=N) { t0=0; for(j=0;j<N;j++) { t0+=get_A(i,j)*u[j]; } Au[i]=t0; } } void eval_At_times_u(int N, const double u[], double Au[]) { int i,j,n4; double t0,t1,t2,t3; n4=N&~3; for(i=0;i<n4;i+=4) { t0=0; t1=0; t2=0; t3=0; for(j=0;j<N;j++) { t0+=get_A(j,i)*u[j]; t1+=get_A(j,i+1)*u[j]; t2+=get_A(j,i+2)*u[j]; t3+=get_A(j,i+3)*u[j]; } Au[i]=t0; Au[i+1]=t1; Au[i+2]=t2; Au[i+3]=t3; } for(;i<N;i++) { t0=0; for(j=0;j<N;j++) { t0+=get_A(j,i)*u[j]; } Au[i]=t0; } } void eval_AtA_times_u(int N, const double u[], double AtAu[]) { double v[N]; eval_A_times_u(N,u,v); eval_At_times_u(N,v,AtAu); } int main(int argc, char *argv[]) { int i; int N = ((argc == 2) ? atoi(argv[1]) : 2000); double u[N],v[N],vBv,vv; if(prepare_A(N)){ printf("Insufficient memory\n"); return 1; } for(i=0;i<N;i++) u[i]=1; for(i=0;i<10;i++) { eval_AtA_times_u(N,u,v); eval_AtA_times_u(N,v,u); } vBv=vv=0; for(i=0;i<N;i++) { vBv+=u[i]*v[i]; vv+=v[i]*v[i]; } printf("%0.9f\n",sqrt(vBv/vv)); free(A_global); return 0; }
Sat, 27 Apr 2013 21:06:24 GMT MAKE: /usr/bin/gcc -pipe -Wall -O3 -fomit-frame-pointer -march=native -fopenmp -mfpmath=sse -msse2 spectralnorm.gcc-2.c -o spectralnorm.gcc-2.gcc_run -lm rm spectralnorm.gcc-2.c 0.23s to complete and log all make actions COMMAND LINE: ./spectralnorm.gcc-2.gcc_run 5500 PROGRAM OUTPUT: 1.274224153