| 1 |
// MPIGMRSmacro.idp file.. version 0. |
| 2 |
// include in MPIGMRES.edp file .. |
| 3 |
// Frederic Hecht 2010 |
| 4 |
// LGPL licence |
| 5 |
// Author [email protected] |
| 6 |
// ------------------------------- |
| 7 |
|
| 8 |
// macro to def // send-recv message |
| 9 |
// ----------------------------------- |
| 10 |
|
| 11 |
|
| 12 |
func real maxM(matrix & A) |
| 13 |
{ |
| 14 |
int[int] I(1),J(1); |
| 15 |
real[int] C(1); |
| 16 |
[I,J,C] =A; |
| 17 |
return C.max ; |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
macro InitU(n,Vh,Th,aTh,U) |
| 22 |
Vh[int] U(n); |
| 23 |
for(int j=0;j<n;++j) |
| 24 |
{ |
| 25 |
Th=aTh[j]; |
| 26 |
U[j]=0; |
| 27 |
} |
| 28 |
//EOM |
| 29 |
|
| 30 |
|
| 31 |
macro ISendRecvAny(comm,jpart,Si,Ri) |
| 32 |
{ /* sorry no Irecv of complex objet ...*/ |
| 33 |
int n= jpart.n,nn=n+n; |
| 34 |
if(vdebug) cout << mpirank << " --ISendRecvAny " << n << endl; |
| 35 |
mpiRequest[int] rq(nn); |
| 36 |
|
| 37 |
for (int j=0;j<n;++j) |
| 38 |
Irecv(processor(jpart[j],comm,rq[j]),Ri[j]); |
| 39 |
if(vdebug) cout << mpirank << " ++ISendRecvAny " << n << endl; |
| 40 |
|
| 41 |
for (int j=0;j<n;++j) |
| 42 |
Isend(processor(jpart[j],comm,rq[n+j]),Si[j]); |
| 43 |
for (int j=0;j<nn;++j) |
| 44 |
{ |
| 45 |
int k= mpiWaitAny(rq); |
| 46 |
if(vdebug) |
| 47 |
cout << " ++ISendRecvAny wait: get " << k << endl; |
| 48 |
} |
| 49 |
} |
| 50 |
//EOM |
| 51 |
|
| 52 |
|
| 53 |
macro SendRecvAny(comm,jpart,Si,Ri) |
| 54 |
{ verbosity=200; |
| 55 |
int n= jpart.n; |
| 56 |
for (int j=0;j<n;++j) |
| 57 |
processor(comm,jpart[j]) << Si[j]; |
| 58 |
cout << " ** wait revc " << endl; |
| 59 |
for (int j=0;j<n;++j) |
| 60 |
processor(comm,jpart[j]) >> Ri[j]; |
| 61 |
} |
| 62 |
// EOM |
| 63 |
|
| 64 |
|
| 65 |
macro CheckUV(comm,jpart,Si,Ri) |
| 66 |
{ |
| 67 |
int ipart=mpiRank(comm); |
| 68 |
int n= jpart.n; |
| 69 |
int[int] rn(n),sn(n),in(n); |
| 70 |
for (int j=0;j<n;++j) |
| 71 |
{ sn[j]= Si[j][].n; |
| 72 |
processor(jpart[j],comm) << sn[j]; |
| 73 |
processor(jpart[j],comm) << ipart; |
| 74 |
} |
| 75 |
for (int j=0;j<n;++j) |
| 76 |
processor(jpart[j],comm) >> rn[j]; |
| 77 |
for (int j=0;j<n;++j) |
| 78 |
processor(jpart[j],comm) >> in[j]; |
| 79 |
|
| 80 |
int err=0; |
| 81 |
for (int j=0;j<n;++j) |
| 82 |
{ |
| 83 |
int rj=Ri[j][].n; |
| 84 |
err += rj != rn[j]; |
| 85 |
cout << rj << " s ========= r " << rn[j] << " " << ipart << " <-> " << in[j] << " " << err << endl; |
| 86 |
|
| 87 |
} |
| 88 |
assert(err==0); |
| 89 |
}//EOM |
| 90 |
|
| 91 |
|
| 92 |
macro SendRecvUV(comm,jpart,Si,Ri) |
| 93 |
{ |
| 94 |
int n= jpart.n; |
| 95 |
mpiRequest[int] rq(n); |
| 96 |
for (int j=0;j<n;++j) |
| 97 |
Irecv(processor(jpart[j],comm,rq[j]), Ri[j][]); |
| 98 |
|
| 99 |
for (int j=0;j<n;++j) |
| 100 |
processor(jpart[j],comm) << Si[j][]; |
| 101 |
/* for (int j=0;j<n;++j) |
| 102 |
processor(jpart[j],comm) >> Ri[j][];*/ |
| 103 |
|
| 104 |
for (int j=0;j<n;++j) |
| 105 |
int k= mpiWaitAny(rq); |
| 106 |
} |
| 107 |
// EOF |
| 108 |
|
| 109 |
|