2
//@+node:gcross.20081103140450.3:@thin scalapack_test.C
6
//@+node:gcross.20081103140450.4:scalapack_test declarations
10
#include "blitz/blitz.h"
11
#include "blitz/array.h"
12
#include "blitz/indexexpr.h"
13
#include "blitz/range.h"
14
#include "blitz/tinyvec.h"
15
#include "blitz/tinyvec-et.h"
16
#include "blitz/array/domain.h"
17
#include "blitz/array/expr.h"
18
#include "blitz/array/fastiter.h"
22
//#include "charm++.h"
29
using namespace blitz;
35
int& type() { return descriptor[0]; }
36
int& context() { return descriptor[1]; }
37
int& number_of_rows() { return descriptor[2]; }
38
int& number_of_columns() { return descriptor[3]; }
39
int& row_blocking_factor() { return descriptor[4]; }
40
int& column_blocking_factor() { return descriptor[5]; }
41
int& first_process_row() { return descriptor[6]; }
42
int& first_process_column() { return descriptor[7]; }
43
int& leading_dimension() { return descriptor[8]; }
44
operator int*() { return descriptor; }
48
//@-node:gcross.20081103140450.4:scalapack_test declarations
49
//@+node:gcross.20081103140450.5:main
50
int main(int argc,char **argv) {
54
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
57
Cblacs_get(0,0,&mpi_context); // get system default context
58
int blacs_context = mpi_context;
60
Cblacs_gridinit(&blacs_context,"Row Major Ordering",2,2);
62
Descriptor descriptor;
63
descriptor.type() = 1;
64
descriptor.context() = blacs_context;
65
descriptor.number_of_rows() = 6;
66
descriptor.number_of_columns() = 6;
67
descriptor.row_blocking_factor() = 3;
68
descriptor.column_blocking_factor() = 3;
69
descriptor.first_process_row() = 0;
70
descriptor.first_process_column() = 0;
71
descriptor.leading_dimension() = 3;
74
Array<double,2> Alocal(6,6), Blocal(6,6);
81
Alocal = 0.0,1.0,8.0,27.0,64.0,125.0,
82
1.0,4.0,15.0,40.0,85.0,156.0,
83
8.0,15.0,32.0,65.0,120.0,203.0,
84
27.0,40.0,65.0,108.0,175.0,272.0,
85
64.0,85.0,120.0,175.0,256.0,369.0,
86
125.0,156.0,203.0,272.0,369.0,500.0;
88
Blocal = 20515.0,26144.0,35081.0,48676.0,68279.0,95240.0,
89
26144.0,33403.0,45016.0,62789.0,88528.0,124039.0,
90
35081.0,45016.0,61147.0,86132.0,122629.0,173296.0,
91
48676.0,62789.0,86132.0,122827.0,176996.0,252761.0,
92
68279.0,88528.0,122629.0,176996.0,258043.0,372184.0,
93
95240.0,124039.0,173296.0,252761.0,372184.0,541315.0;
95
Array<double,2> A(3,3,fortranArray);
96
Array<double,2> B(3,3,fortranArray);
100
A = Alocal(Range(0,2),Range(0,2));
101
B = Blocal(Range(0,2),Range(0,2));
104
A = Alocal(Range(0,2),Range(3,5));
105
B = Blocal(Range(0,2),Range(3,5));
108
A = Alocal(Range(3,5),Range(0,2));
109
B = Blocal(Range(3,5),Range(0,2));
112
A = Alocal(Range(3,5),Range(3,5));
113
B = Blocal(Range(3,5),Range(3,5));
117
PBLAS::solve<double>(6,6,A.data(),1,1,(int*)descriptor,IPIV,B.data(),1,1,(int*)descriptor);
119
MPI_Barrier(MPI_COMM_WORLD);
122
cout << rank << A << endl;
123
cout << rank << B << endl;
129
//@-node:gcross.20081103140450.5:main
132
//@-node:gcross.20081103140450.3:@thin scalapack_test.C