~gcrosswhite/charon/trunk

« back to all changes in this revision

Viewing changes to src/matmulspeed.C

  • Committer: Gregory Crosswhite
  • Date: 2009-04-14 20:37:52 UTC
  • Revision ID: gcross@phys.washington.edu-20090414203752-aayz9j7fqmrzccun
Cleared out all but the simplest and most solid functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//@+leo-ver=4-thin
2
 
//@+node:gcross.20081204190733.4:@thin matmulspeed.C
3
 
//@@language cplusplus
4
 
 
5
 
#include "matmulspeed.h"
6
 
#include "matrix_multiplication.h"
7
 
 
8
 
matmulspeed::matmulspeed(CkArgMsg *m) {
9
 
    CProxy_matmulspeed self(thishandle);
10
 
    self.runTest();
11
 
}
12
 
 
13
 
void doTest(int I, int J, int K) {
14
 
    typedef Array<double,2> Matrix;
15
 
 
16
 
    CProxy_MatrixMultiplier<double> multiplier = CProxy_MatrixMultiplier<double>::ckNew(I,J,K);
17
 
    CkGroupID mCastGrpId = CProxy_CkMulticastMgr::ckNew();
18
 
    Array<CProxySection_MatrixMultiplier<double>,2> A_section_matrix(I,J), B_section_matrix(J,K), C_section_matrix(I,K);
19
 
    MatrixMultiplier<double>::build_section_matrices(
20
 
        multiplier,
21
 
        I,J,K,
22
 
        mCastGrpId,
23
 
        A_section_matrix,
24
 
        B_section_matrix,
25
 
        C_section_matrix
26
 
    );
27
 
    Array<CkCallback,2> C_callback_matrix(I,K);
28
 
    MatrixMultiplier<double>::build_thread_delay_callback_matrix(mCastGrpId,C_section_matrix,C_callback_matrix);
29
 
 
30
 
    {
31
 
        Matrix A_data(23,11);
32
 
        Matrix B_data(11,13);
33
 
        Matrix C_data(23,13), correct_C_data(23,13);
34
 
 
35
 
        cout << "Loading matrix A..." << endl;
36
 
        //@        << A data >>
37
 
        //@+node:gcross.20081204190733.12:<< A data >>
38
 
        //@-node:gcross.20081204190733.12:<< A data >>
39
 
        //@nl
40
 
        cout << "Loading matrix B..." << endl;
41
 
        //@        << B data >>
42
 
        //@+node:gcross.20081204190733.13:<< B data >>
43
 
        //@-node:gcross.20081204190733.13:<< B data >>
44
 
        //@nl
45
 
        cout << "Loading matrix C..." << endl;
46
 
        //@        << C data >>
47
 
        //@+node:gcross.20081204190733.14:<< C data >>
48
 
        //@-node:gcross.20081204190733.14:<< C data >>
49
 
        //@nl
50
 
 
51
 
        MatrixMultiplier<double>::broadcast_A_data(0,A_section_matrix,A_data);
52
 
        MatrixMultiplier<double>::broadcast_B_data(0,B_section_matrix,B_data);
53
 
        MatrixMultiplier<double>::gather_results(C_callback_matrix,C_data);
54
 
        assert(sum(abs(C_data-correct_C_data))<1e-8);
55
 
        cout << "They agree!" << endl;
56
 
    }
57
 
 
58
 
    multiplier.ckDestroy();
59
 
}
60
 
 
61
 
#include <ctime>
62
 
 
63
 
void matmulspeed::runTest() {
64
 
 
65
 
    clock_t timestamp = clock();
66
 
    doTest(1,1,1);
67
 
    cout << (clock()-timestamp) << endl;
68
 
 
69
 
    CkExitAfterQuiescence();
70
 
 
71
 
}
72
 
 
73
 
#include "matmulspeed.def.h"
74
 
 
75
 
//@-node:gcross.20081204190733.4:@thin matmulspeed.C
76
 
//@-leo