File: echotune.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 (49 lines) | stat: -rw-r--r-- 1,284 bytes parent folder | download | duplicates (7)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <blitz/timer.h>
#include <iostream>
#include <fstream>

BZ_USING_NAMESPACE(blitz)
BZ_USING_NAMESPACE(std)

extern "C" {
    void echo_f77tuned(int& N, int& niters, float& check, int& blockSize);
}

int main()
{
    int N = 1024;
    int niters = 48;
    float check;
    double Mflops = niters * 9;
    Timer timer;

    ofstream ofs("echotune.log");

    cout << "This program decides on the best block size for a typical 2D "
         << endl << "stencil operation.  Pick the block size which has the "
         << endl << "maximum Mflops/s." << endl << endl;

    cout << "Block size\tMflops/s" << endl;

    int blockSize;

    for (blockSize=1; blockSize < 32; ++blockSize)
    {
        timer.start();
        echo_f77tuned(N, niters, check, blockSize);
        timer.stop();
        cout << blockSize << "\t" << (Mflops/timer.elapsedSeconds()) << endl;
        ofs << blockSize << "\t" << (Mflops/timer.elapsedSeconds()) << endl;
    }
    for (; blockSize < 1024; blockSize += 32)
    {
        timer.start();
        echo_f77tuned(N, niters, check, blockSize);
        timer.stop();
        cout << blockSize << "\t" << (Mflops/timer.elapsedSeconds()) << endl;
        ofs << blockSize << "\t" << (Mflops/timer.elapsedSeconds()) << endl;
    }
    
    return 0;
}