/mobile Handheld Friendly website

 performance measurements

Each table row shows performance measurements for this C++ g++ program with a particular command-line input value N.

 N  CPU secs Elapsed secs Memory KB Code B ≈ CPU Load
5000.240.24868452  4% 4% 0% 100%
3,0008.488.48872452  1% 100% 1% 0%
5,50028.4628.48872452  0% 100% 1% 1%

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.

 notes

gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1)

 spectral-norm C++ g++ program source code

// The Computer Language Benchmarks Game
// http://benchmarksgame.alioth.debian.org/
//
// Original C contributed by Sebastien Loisel
// Conversion to C++ by Jon Harrop
// Compile: g++ -O3 -o spectralnorm spectralnorm.cpp


#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <vector>
#include <iostream>
#include <iomanip>

using namespace std;

double eval_A(int i, int j) { return 1.0 / ((i+j)*(i+j+1)/2 + i + 1); }

void eval_A_times_u(const vector<double> &u, vector<double> &Au)
{
  for(int i=0; i<u.size(); i++)
    for(int j=0; j<u.size(); j++) Au[i] += eval_A(i,j) * u[j];
}

void eval_At_times_u(const vector<double> &u, vector<double> &Au)
{
  for(int i=0; i<u.size(); i++)
    for(int j=0; j<u.size(); j++) Au[i] += eval_A(j,i) * u[j];
}

void eval_AtA_times_u(const vector<double> &u, vector<double> &AtAu)
{ vector<double> v(u.size()); eval_A_times_u(u, v); eval_At_times_u(v, AtAu); }

int main(int argc, char *argv[])
{
  int N = ((argc == 2) ? atoi(argv[1]) : 2000);
  vector<double> u(N), v(N);

  fill(u.begin(), u.end(), 1);

  for(int i=0; i<10; i++) {
    eval_AtA_times_u(u, v);
    fill(u.begin(), u.end(), 0);
    eval_AtA_times_u(v, u);
  }

  double vBv=0, vv=0;
  for(int i=0; i<N; i++) { vBv += u[i]*v[i]; vv += v[i]*v[i]; }

  cout << setprecision(10) << sqrt(vBv/vv) << endl;

  return 0;
}

 make, command-line, and program output logs

Thu, 24 Apr 2014 00:06:57 GMT

MAKE:
/usr/bin/g++ -c -pipe -O3 -fomit-frame-pointer -march=native -mfpmath=sse -msse2 -fopenmp -O0 spectralnorm.c++ -o spectralnorm.c++.o &&  \
        /usr/bin/g++ spectralnorm.c++.o -o spectralnorm.gpp_run -fopenmp 
rm spectralnorm.c++
0.37s to complete and log all make actions

COMMAND LINE:
./spectralnorm.gpp_run 5500

PROGRAM OUTPUT:
1.274224153

Revised BSD license

  Home   Conclusions   License   Play