File: iter.cpp

package info (click to toggle)
blitz%2B%2B 1%3A0.10-3.2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,276 kB
  • ctags: 12,037
  • sloc: cpp: 70,465; sh: 11,116; fortran: 1,510; python: 1,246; f90: 852; makefile: 701
file content (33 lines) | stat: -rw-r--r-- 770 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <blitz/array.h>
#include <blitz/timer.h>

int main() {
    using namespace blitz;

    typedef Array<double,3> Image;
    Image A(512,512,512);
    Timer timer;

    A = 0.0;
    timer.start();
    for (unsigned j=0;j<10;++j) {
        for (Image::iterator i=A.begin(),end=A.end();i!=end;++i) {
            const TinyVector<int,3> pos = i.position();
            *i += pos(0)+pos(1)+pos(2);
        }
    }
    timer.stop();
    double flops = 10.0*512*512*512*2;
    double seconds = timer.elapsedSeconds();

    double timePerOp = seconds / flops;

    cout << "ops = " << flops << endl
         << "seconds = " << seconds << endl;

    double Mflops = flops / seconds / 1.0e+6;
    cout << "Mflops = " << Mflops << endl;

    return 0;
}