@@ -76,7 +76,7 @@ template<typename T>
76
76
void clientRequest (T *t, int i, char **requestStreamClient);
77
77
78
78
template <typename T>
79
- void clientRequestAllAtOnce (T *t,
79
+ void clientRequestSearch (T *t,
80
80
ESMCI::VM *vm,
81
81
char **requestStreamClient);
82
82
@@ -156,7 +156,7 @@ void accessLookup(
156
156
}
157
157
158
158
// Fill buffers
159
- clientRequestAllAtOnce (t, vm, requestStreamClient);
159
+ clientRequestSearch (t, vm, requestStreamClient);
160
160
161
161
// Communicate buffers
162
162
for (int ii=localPet+petCount-1 ; ii>localPet; ii--){
@@ -456,7 +456,7 @@ template<typename IT1>
456
456
457
457
458
458
template <typename IT1, typename IT2>
459
- void clientRequestAllAtOnce (FillLinSeqVectInfo<IT1,IT2> *fillLinSeqVectInfo,
459
+ void clientRequestSearch (FillLinSeqVectInfo<IT1,IT2> *fillLinSeqVectInfo,
460
460
ESMCI::VM *vm, char **requestStreamClient){
461
461
const int localDeCount = fillLinSeqVectInfo->localDeCount ;
462
462
const int *localDeElementCount = fillLinSeqVectInfo->localDeElementCount ;
@@ -854,7 +854,7 @@ template<typename IT1, typename IT2>
854
854
855
855
856
856
template <typename IT1, typename IT2>
857
- void clientRequestAllAtOnce (FillPartnerDeInfo<IT1,IT2> *fillPartnerDeInfo,
857
+ void clientRequestSearch (FillPartnerDeInfo<IT1,IT2> *fillPartnerDeInfo,
858
858
ESMCI::VM *vm, char **requestStreamClient){
859
859
const int localPetfpDEI = fillPartnerDeInfo->localPet ;
860
860
const Interval<IT1> *seqIndexIntervalIn =
@@ -1104,6 +1104,121 @@ template<typename IT1, typename IT2>
1104
1104
}
1105
1105
}
1106
1106
}
1107
+
1108
+ virtual void messagePrepareSearch (VMK *vmk,
1109
+ int sendIndexOffset, int iiStart, int iiEnd,
1110
+ vector<char *> &sendBuffer
1111
+ )const {
1112
+
1113
+ // Get Pet info
1114
+ int petCount = vmk->getNpets ();
1115
+ int localPet = vmk->getMypet ();
1116
+
1117
+ // Memory to hold pointers into buffers
1118
+ int **bufferIntArray = new int *[petCount];
1119
+
1120
+ // Get beginning of buffers
1121
+ for (int ii=sendIndexOffset-iiStart; ii>sendIndexOffset-iiEnd; ii--){
1122
+ int dstPet = ii%petCount; // fold back into [0,..,petCount-1] range
1123
+ bufferIntArray[dstPet] = (int *)(sendBuffer[dstPet]);
1124
+ }
1125
+
1126
+ // Find where eqch SeqInd goes
1127
+ for (int j=0 ; j<localDeCount; j++){
1128
+ int de = localDeToDeMap[j]; // global DE number
1129
+ if (haloRimFlag){
1130
+ // loop over the halo rim elements for localDe j
1131
+ for (int k=0 ; k<array->getRimElementCount ()[j]; k++){
1132
+ const std::vector<std::vector<SeqIndex<IT> > > *rimSeqIndex;
1133
+ array->getRimSeqIndex (&rimSeqIndex);
1134
+ SeqIndex<IT> seqIndex = (*rimSeqIndex)[j][k];
1135
+ if (seqIndex.valid ()){
1136
+ IT seqInd = seqIndex.decompSeqIndex ;
1137
+
1138
+ // Figure out which Pet it's on
1139
+ Interval<IT> tmpInt;
1140
+ tmpInt.min =0 ;
1141
+ tmpInt.max =seqInd;
1142
+ tmpInt.count =0 ;
1143
+
1144
+ const Interval<IT> *seqIndPos = std::lower_bound (seqIndexInterval, seqIndexInterval+petCount, tmpInt);
1145
+ int dstPet=(int )(seqIndPos-seqIndexInterval);
1146
+ if (dstPet >= petCount) continue ;
1147
+ if (dstPet == localPet) continue ;
1148
+
1149
+ IT seqIndMin = seqIndexInterval[dstPet].min ;
1150
+ IT seqIndMax = seqIndexInterval[dstPet].max ;
1151
+
1152
+ if (seqInd >= seqIndMin && seqInd <= seqIndMax){
1153
+ IT seqIndCount = seqIndexInterval[dstPet].count ;
1154
+ int lookupIndex = (int )(seqInd - seqIndMin);
1155
+ if (tensorMixFlag)
1156
+ lookupIndex += (seqIndex.tensorSeqIndex - 1 )
1157
+ * (int )seqIndCount;
1158
+
1159
+ int *bufferInt = bufferIntArray[dstPet];
1160
+
1161
+ *bufferInt++ = lookupIndex;
1162
+ *bufferInt++ = de;
1163
+
1164
+ bufferIntArray[dstPet]=bufferInt;
1165
+ }
1166
+ }
1167
+ }
1168
+ }else {
1169
+ // loop over all elements in the exclusive region for localDe j
1170
+ ArrayElement arrayElement (array, j, true , false , false );
1171
+ while (arrayElement.isWithin ()){
1172
+ SeqIndex<IT> seqIndex = arrayElement.getSequenceIndex <IT>();
1173
+ IT seqInd = seqIndex.decompSeqIndex ;
1174
+
1175
+ // Figure out which Pet it's on
1176
+ Interval<IT> tmpInt;
1177
+ tmpInt.min =0 ;
1178
+ tmpInt.max =seqInd;
1179
+ tmpInt.count =0 ;
1180
+
1181
+ const Interval<IT> *seqIndPos = std::lower_bound (seqIndexInterval, seqIndexInterval+petCount, tmpInt);
1182
+ int dstPet=(int )(seqIndPos-seqIndexInterval);
1183
+
1184
+ // If not found, then skip (?)
1185
+ if (dstPet >= petCount) {
1186
+ arrayElement.next ();
1187
+ continue ;
1188
+ }
1189
+
1190
+ // If it's this PET, then skip, because those are handled later
1191
+ if (dstPet == localPet) {
1192
+ arrayElement.next ();
1193
+ continue ;
1194
+ }
1195
+
1196
+ IT seqIndMin = seqIndexInterval[dstPet].min ;
1197
+ IT seqIndMax = seqIndexInterval[dstPet].max ;
1198
+
1199
+ if (seqInd >= seqIndMin && seqInd <= seqIndMax){
1200
+ IT seqIndCount = seqIndexInterval[dstPet].count ;
1201
+ int lookupIndex = (int )(seqInd - seqIndMin);
1202
+ if (tensorMixFlag)
1203
+ lookupIndex += (seqIndex.tensorSeqIndex - 1 ) * (int )seqIndCount;
1204
+
1205
+ int *bufferInt = bufferIntArray[dstPet];
1206
+
1207
+ *bufferInt++ = lookupIndex;
1208
+ *bufferInt++ = de;
1209
+
1210
+ bufferIntArray[dstPet]=bufferInt;
1211
+ }
1212
+ arrayElement.next ();
1213
+ } // end while over all exclusive elements
1214
+ }
1215
+ }
1216
+
1217
+ // Free memory holding pointers into buffers
1218
+ delete [] bufferIntArray;
1219
+ }
1220
+
1221
+
1107
1222
virtual void messageProcess (int srcPet, int dstPet, char *buffer){
1108
1223
int count = messageSizeCount (srcPet, dstPet);
1109
1224
int *bufferInt = (int *)buffer;
@@ -1275,6 +1390,32 @@ template<typename IT1, typename IT2>
1275
1390
seqIntervFactorListLookupIndexToPet[dstPet].front ()),
1276
1391
messageSizeCount (srcPet, dstPet)*sizeof (int ));
1277
1392
}
1393
+
1394
+ virtual void messagePrepareSearch (VMK *vmk,
1395
+ int sendIndexOffset, int iiStart, int iiEnd,
1396
+ vector<char *> &sendBuffer
1397
+ )const {
1398
+
1399
+ // Get Pet info
1400
+ int petCount = vmk->getNpets ();
1401
+ int localPet = vmk->getMypet ();
1402
+
1403
+
1404
+ // localPet acts as a sender, constructs message and sends to receiver
1405
+ for (int ii=sendIndexOffset-iiStart; ii>sendIndexOffset-iiEnd; ii--){
1406
+ // localPet-dependent shifted loop reduces communication contention
1407
+ int dstPet = ii%petCount; // fold back into [0,..,petCount-1] range
1408
+ // send message to Pet "i"
1409
+ int size = messageSize (localPet, dstPet);
1410
+ if (size>0 ){
1411
+
1412
+ // Just use the usual 1 PET messagePrepare
1413
+ messagePrepare (localPet, dstPet, sendBuffer[dstPet]);
1414
+ }
1415
+ }
1416
+
1417
+ }
1418
+
1278
1419
virtual void messageProcess (int srcPet, int dstPet, char *buffer){
1279
1420
int *bufferInt = (int *)buffer;
1280
1421
for (int i=0 ; i<messageSizeCount (srcPet, dstPet); i++){
@@ -1364,6 +1505,30 @@ template<typename IT1, typename IT2>
1364
1505
else if (typekindFactors == ESMC_TYPEKIND_I8)
1365
1506
fillStream<ESMC_I8>(srcPet, dstPet, buffer);
1366
1507
}
1508
+
1509
+ virtual void messagePrepareSearch (VMK *vmk,
1510
+ int sendIndexOffset, int iiStart, int iiEnd,
1511
+ vector<char *> &sendBuffer
1512
+ )const {
1513
+
1514
+ // Get Pet info
1515
+ int petCount = vmk->getNpets ();
1516
+ int localPet = vmk->getMypet ();
1517
+
1518
+ // localPet acts as a sender, constructs message and sends to receiver
1519
+ for (int ii=sendIndexOffset-iiStart; ii>sendIndexOffset-iiEnd; ii--){
1520
+ // localPet-dependent shifted loop reduces communication contention
1521
+ int dstPet = ii%petCount; // fold back into [0,..,petCount-1] range
1522
+ // send message to Pet "i"
1523
+ int size = messageSize (localPet, dstPet);
1524
+ if (size>0 ){
1525
+
1526
+ // Just use the usual 1 PET messagePrepare
1527
+ messagePrepare (localPet, dstPet, sendBuffer[dstPet]);
1528
+ }
1529
+ }
1530
+ }
1531
+
1367
1532
virtual void messageProcess (int srcPet, int dstPet, char *buffer){
1368
1533
ESMC_TypeKind_Flag typekindFactors =
1369
1534
SetupSeqIndexFactorLookup<IT>::typekindFactors;
0 commit comments