14 std::ostringstream messageStream;
19 std::vector<int> cartNeighbors;
23 int myRank = myComm.
Rank();
24 int nProc = myComm.
Size();
30 std::vector<size_t> globalSizes(3,101);
34 messageStream <<
"Global size: ";
36 messageStream << std::endl;
39 messageStream <<
"Partition interval: ";
41 messageStream << std::endl;
46 size_t numX = partitionExtent[0].second - partitionExtent[0].first + 1;
47 size_t numY = partitionExtent[1].second - partitionExtent[1].first + 1;
48 size_t numZ = partitionExtent[2].second - partitionExtent[2].first + 1;
49 size_t nCells = (numX-1)*(numY-1)*(numZ-1);
50 size_t nNodes = numX*numY*numZ;
51 size_t numGlobalNodes = globalSizes[0]*globalSizes[1]*globalSizes[2];
53 bool constructorworks =
true;
57 constructorworks =
false;
59 constructorworks =
false;
61 std::vector<size_t> haloSizes(6,2);
65 bool createremotehaloextents =
true;
66 bool createlocalhaloextents =
true;
68 if(remoteHaloExtents.size() != 6)
69 createremotehaloextents =
false;
70 if(localHaloExtents.size() != 6)
71 createlocalhaloextents =
false;
73 if(!constructorworks){
77 constructorworks =
false;
82 int totalLocalHaloNodes = 0;
83 int totalRemoteHaloNodes = 0;
85 std::vector<bool> haveLeftBoundary(3,
false);
86 std::vector<bool> haveRightBoundary(3,
false);
88 for(
int iDim = 0;iDim < 3;iDim++){
89 haveLeftBoundary[iDim] = (partitionExtent[iDim].first == 0);
90 haveRightBoundary[iDim] = (partitionExtent[iDim].second == globalExtent[iDim].second);
93 for(
int iDim = 0;iDim < 3;iDim++){
98 if(haveLeftBoundary[iDim]){
99 if(!leftLocalHaloExtent.empty() ||
100 !leftRemoteHaloExtent.empty())
101 createremotehaloextents =
false;
104 totalLocalHaloNodes += leftLocalHaloExtent.
NNodes();
105 totalRemoteHaloNodes += leftRemoteHaloExtent.
NNodes();
107 for(
int hDim = 0;hDim < 3;hDim++){
111 if(leftRemoteHaloExtent[iDim].first != (partitionExtent[iDim].first - haloSizes[iDim*2]))
112 createremotehaloextents =
false;
114 if(leftRemoteHaloExtent[iDim].second != (partitionExtent[iDim].first - 1))
115 createremotehaloextents =
false;
117 if(leftLocalHaloExtent[iDim].first != partitionExtent[iDim].first)
118 createlocalhaloextents =
false;
120 if(leftLocalHaloExtent[iDim].second != (partitionExtent[iDim].first + haloSizes[iDim*2] - 1))
121 createlocalhaloextents =
false;
125 if(leftRemoteHaloExtent[hDim] != partitionExtent[hDim])
126 createremotehaloextents =
false;
128 if(leftLocalHaloExtent[hDim] != partitionExtent[hDim])
129 createlocalhaloextents =
false;
137 if(haveRightBoundary[iDim]){
138 if(!rightLocalHaloExtent.empty() ||
139 !rightRemoteHaloExtent.empty())
140 createremotehaloextents =
false;
143 totalLocalHaloNodes += rightLocalHaloExtent.
NNodes();
144 totalRemoteHaloNodes += rightRemoteHaloExtent.
NNodes();
147 for(
int hDim = 0;hDim < 3;hDim++){
151 if(rightRemoteHaloExtent[iDim].second != (partitionExtent[iDim].second + haloSizes[iDim*2]))
152 createremotehaloextents =
false;
154 if(rightRemoteHaloExtent[iDim].first != (partitionExtent[iDim].second + 1))
155 createremotehaloextents =
false;
157 if(rightLocalHaloExtent[iDim].second != partitionExtent[iDim].second)
158 createlocalhaloextents =
false;
160 if(rightLocalHaloExtent[iDim].first != (partitionExtent[iDim].second - haloSizes[iDim*2] + 1))
161 createlocalhaloextents =
false;
165 if(rightRemoteHaloExtent[hDim] != partitionExtent[hDim])
166 createremotehaloextents =
false;
168 if(rightLocalHaloExtent[hDim] != partitionExtent[hDim])
169 createlocalhaloextents =
false;
175 if(!createremotehaloextents || !createlocalhaloextents)
178 createremotehaloextents =
false;
179 createlocalhaloextents =
false;
182 if(!createremotehaloextents || !createlocalhaloextents)
185 bool setremotehaloextents =
false;
186 bool setlocalhaloextents =
false;
190 setremotehaloextents =
true;
194 setlocalhaloextents =
true;
196 if(!setremotehaloextents)
199 setremotehaloextents =
false;
202 if(!setlocalhaloextents)
205 setlocalhaloextents =
false;
207 if(!setlocalhaloextents || !setremotehaloextents)
211 testState.
AddField(
"time",
's',1,8,
"s");
212 testState.
AddField(
"U",
'n',1,8,
"stuff");
213 testState.
AddField(
"V",
'n',3,8,
"things");
214 testState.
AddField(
"iblank",
'n',1,4,
"");
215 testState.
Create(nNodes,nCells);
216 int totalNumComponents = 4;
218 std::vector<double> uVector(nNodes,0);
219 std::vector<double> vVector(nNodes*3,0);
224 for(
size_t iNode = 0;iNode < nNodes;iNode++){
226 size_t localK = iNode/(numX*numY);
227 size_t localJ = (iNode - (localK*numX*numY))/numX;
228 size_t localI = iNode%numX;
230 size_t globalK = localK + partitionExtent[2].first;
231 size_t globalJ = localJ + partitionExtent[1].first;
232 size_t globalI = localI + partitionExtent[0].first;
234 size_t globalNode = globalK * globalSizes[0]*globalSizes[1] +
235 globalJ * globalSizes[0] + globalI;
237 uVector[iNode] = globalNode;
238 vVector[iNode] = uVector[iNode] + numGlobalNodes;
239 vVector[iNode+nNodes] = vVector[iNode] + numGlobalNodes;
240 vVector[iNode+(2*nNodes)] = vVector[iNode+nNodes] + numGlobalNodes;
244 std::vector<int> stateFieldIndices(2,1);
245 stateFieldIndices[1] = 2;
248 bool configuredata =
true;
251 configuredata =
false;
253 configuredata =
false;
255 configuredata =
false;
257 bool createSimpleSendBuffers =
true;
258 bool createSimpleRecvBuffers =
true;
263 std::vector<double *> &sendBuffers(testHalo.
SendBuffers());
264 std::vector<double *> &recvBuffers(testHalo.
RecvBuffers());
266 if(sendBuffers.size() != localHaloExtents.size())
267 createSimpleSendBuffers =
false;
268 if(recvBuffers.size() != remoteHaloExtents.size())
269 createSimpleRecvBuffers =
false;
271 createSimpleSendBuffers =
false;
273 createSimpleRecvBuffers =
false;
276 bool createhalobuffers =
true;
283 bool packsimplesend =
true;
286 int numSendBuffers = sendBuffers.size();
288 for(
int iSend = 0;iSend < numSendBuffers;iSend++){
292 if(sendBuffers[iSend] != NULL){
293 std::vector<size_t> sendNodeIds;
296 size_t numSendNodes = sendExtent.
NNodes();
299 for(
size_t iVal = 0;iVal < numValsSend;iVal++){
301 size_t componentId = iVal/numSendNodes;
302 size_t sendNodeId = iVal%numSendNodes;
303 size_t partitionNodeId = sendNodeIds[sendNodeId];
305 size_t localK = partitionNodeId/(numX*numY);
306 size_t localJ = partitionNodeId/numX - localK*numY;
307 size_t localI = partitionNodeId%numX;
309 size_t globalK = localK + partitionExtent[2].first;
310 size_t globalJ = localJ + partitionExtent[1].first;
311 size_t globalI = localI + partitionExtent[0].first;
313 size_t globalNode = globalK * globalSizes[0]*globalSizes[1] +
314 globalJ * globalSizes[0] + globalI;
315 if(globalNode > numGlobalNodes)
317 double expectedValue = componentId*numGlobalNodes + globalNode;
319 if(std::abs(sendBuffers[iSend][iVal] - expectedValue) > 1.0){
320 packsimplesend =
false;
322 std::cout <<
"Node ids (send/part/global): (" << sendNodeId <<
"," << partitionNodeId
324 <<
") Comp:" << componentId <<
" Value (exp/act): (" 325 << expectedValue <<
"," << sendBuffers[iSend][iVal] <<
")" << std::endl;
331 if(!sendExtent.empty()){
332 std::cout <<
"Send extent " << iSend <<
" had no associated send buffer." 334 packsimplesend =
false;
342 packsimplesend =
false;
347 bool simplesend =
true;
348 bool completesimplerecv =
true;
351 testHalo.
SimpleSend(cartNeighbors,myCartComm);
357 bool unpacksimplerecvbuffers =
true;
358 std::vector<std::vector<double *> > &haloBuffers(testHalo.
HaloBuffers());
361 for(
int iDim = 0;iDim < 3;iDim++){
363 if(!haveLeftBoundary[iDim]){
364 size_t numHaloNodes = leftRemoteHaloExtent.
NNodes();
365 size_t kBegin = leftRemoteHaloExtent[2].first;
366 size_t kEnd = leftRemoteHaloExtent[2].second;
367 size_t jBegin = leftRemoteHaloExtent[1].first;
368 size_t jEnd = leftRemoteHaloExtent[1].second;
369 size_t iBegin = leftRemoteHaloExtent[0].first;
370 size_t iEnd = leftRemoteHaloExtent[0].second;
371 size_t haloNodeIndex = 0;
372 for(
size_t kIndex = kBegin;kIndex <= kEnd;kIndex++){
373 for(
size_t jIndex = jBegin;jIndex <= jEnd;jIndex++){
374 for(
size_t iIndex = iBegin;iIndex <= iEnd;iIndex++){
375 size_t globalNode = kIndex * globalSizes[0]*globalSizes[1] +
376 jIndex * globalSizes[0] + iIndex;
377 if(globalNode > numGlobalNodes)
379 for(
int iComponent = 0;iComponent < totalNumComponents;iComponent++){
380 int iField = (iComponent > 0 ? 1 : 0);
381 int compFac = (iField > 0 ? 1 : 0);
382 double expectedValue = iComponent*numGlobalNodes + globalNode;
383 size_t haloBufferIndex = compFac*(iComponent-1)*numHaloNodes+haloNodeIndex;
384 if(haloBuffers[iField][iDim*2][haloBufferIndex] != expectedValue){
385 messageStream <<
"R(" << myRank <<
") N(" << iIndex <<
"," 386 << jIndex <<
"," << kIndex <<
") V(" 387 << haloBuffers[iField][iDim*2][haloBufferIndex]
388 <<
"," << expectedValue <<
")" << std::endl;
389 unpacksimplerecvbuffers =
false;
398 if(!haveRightBoundary[iDim]){
399 size_t numHaloNodes = rightRemoteHaloExtent.
NNodes();
400 size_t kBegin = rightRemoteHaloExtent[2].first;
401 size_t kEnd = rightRemoteHaloExtent[2].second;
402 size_t jBegin = rightRemoteHaloExtent[1].first;
403 size_t jEnd = rightRemoteHaloExtent[1].second;
404 size_t iBegin = rightRemoteHaloExtent[0].first;
405 size_t iEnd = rightRemoteHaloExtent[0].second;
406 size_t haloNodeIndex = 0;
407 for(
size_t kIndex = kBegin;kIndex <= kEnd;kIndex++){
408 for(
size_t jIndex = jBegin;jIndex <= jEnd;jIndex++){
409 for(
size_t iIndex = iBegin;iIndex <= iEnd;iIndex++){
410 size_t globalNode = kIndex * globalSizes[0]*globalSizes[1] +
411 jIndex * globalSizes[0] + iIndex;
412 if(globalNode > numGlobalNodes)
414 for(
int iComponent = 0;iComponent < totalNumComponents;iComponent++){
415 int iField = (iComponent > 0 ? 1 : 0);
416 int compFac = (iField > 0 ? 1 : 0);
417 double expectedValue = iComponent*numGlobalNodes + globalNode;
418 size_t haloBufferIndex = compFac*(iComponent-1)*numHaloNodes+haloNodeIndex;
419 if(haloBuffers[iField][iDim*2+1][haloBufferIndex] != expectedValue){
420 messageStream <<
"R(" << myRank <<
") N(" << iIndex <<
"," 421 << jIndex <<
"," << kIndex <<
") V(" 422 << haloBuffers[iField][iDim*2+1][haloBufferIndex]
423 <<
"," << expectedValue <<
")" << std::endl;
424 unpacksimplerecvbuffers =
false;
434 if(!unpacksimplerecvbuffers)
437 unpacksimplerecvbuffers =
false;
439 if(unpacksimplerecvbuffers){
440 parallelUnitResults.
UpdateResult(
"Halo:SimpleSend",simplesend);
441 parallelUnitResults.
UpdateResult(
"Halo:CompleteSimpleRecv",completesimplerecv);
443 parallelUnitResults.
UpdateResult(
"Halo:UnpackSimpleRcvBuffers",unpacksimplerecvbuffers);
453 std::ostringstream messageStream;
462 std::vector<int> cartNeighbors;
466 int myRank = myComm.
Rank();
467 int nProc = myComm.
Size();
470 std::cout << messageStream.str() << std::endl;
475 std::vector<size_t> globalSizes(3,101);
482 messageStream <<
"Global size: ";
484 messageStream << std::endl;
487 messageStream <<
"Partition interval: ";
489 messageStream << std::endl;
491 std::cout << messageStream.str() << std::endl;
495 size_t numX = partitionExtent[0].second - partitionExtent[0].first + 1;
496 size_t numY = partitionExtent[1].second - partitionExtent[1].first + 1;
497 size_t numZ = partitionExtent[2].second - partitionExtent[2].first + 1;
498 size_t nCells = (numX-1)*(numY-1)*(numZ-1);
499 size_t nNodes = numX*numY*numZ;
500 size_t numGlobalNodes = globalSizes[0]*globalSizes[1]*globalSizes[2];
504 std::vector<bool> haveNeighbors(6,
false);
505 for(
int iN = 0;iN < 6;iN++)
506 haveNeighbors[iN] = (cartNeighbors[iN] >= 0);
509 std::vector<size_t> haloSizes(6,2);
513 int totalLocalHaloNodes = 0;
514 int totalRemoteHaloNodes = 0;
516 std::vector<bool> haveLeftBoundary(3,
false);
517 std::vector<bool> haveRightBoundary(3,
false);
519 for(
int iDim = 0;iDim < 3;iDim++){
520 haveLeftBoundary[iDim] = ((partitionExtent[iDim].first == 0) && !haveNeighbors[2*iDim]);
521 haveRightBoundary[iDim] = ((partitionExtent[iDim].second == globalExtent[iDim].second) && !haveNeighbors[2*iDim+1]);
524 bool leftremotehaloextent =
true;
525 bool leftlocalhaloextent =
true;
526 bool periodicleftremotehaloextent =
true;
527 bool periodicleftlocalhaloextent =
true;
528 bool createleftremotehaloextents =
true;
529 bool createleftlocalhaloextents =
true;
531 bool rightremotehaloextent =
true;
532 bool rightlocalhaloextent =
true;
533 bool periodicrightremotehaloextent =
true;
534 bool periodicrightlocalhaloextent =
true;
535 bool createrightremotehaloextents =
true;
536 bool createrightlocalhaloextents =
true;
539 for(
int iDim = 0;iDim < 3;iDim++){
544 messageStream <<
"LeftRemoteHalo(" << iDim <<
"): ";
546 messageStream << std::endl;
547 messageStream <<
"LeftLocalHalo(" << iDim <<
"): ";
549 messageStream << std::endl;
551 if(haveLeftBoundary[iDim]){
552 if(!leftLocalHaloExtent.empty())
553 createleftlocalhaloextents =
false;
554 if(!leftRemoteHaloExtent.empty())
555 createleftremotehaloextents =
false;
558 totalLocalHaloNodes += leftLocalHaloExtent.
NNodes();
559 totalRemoteHaloNodes += leftRemoteHaloExtent.
NNodes();
561 for(
int hDim = 0;hDim < 3;hDim++){
565 if(partitionExtent[iDim].first == 0){
567 if(leftRemoteHaloExtent[iDim].first != (globalExtent[iDim].second - haloSizes[iDim*2] + 1))
568 periodicleftremotehaloextent =
false;
569 if(leftRemoteHaloExtent[iDim].second != (globalExtent[iDim].second))
570 periodicleftremotehaloextent =
false;
571 if(leftLocalHaloExtent[iDim].first != partitionExtent[iDim].first)
572 periodicleftlocalhaloextent =
false;
573 if(leftLocalHaloExtent[iDim].second != (partitionExtent[iDim].first + haloSizes[iDim*2] - 1))
574 periodicleftlocalhaloextent =
false;
576 if(leftRemoteHaloExtent[iDim].first != (partitionExtent[iDim].first - haloSizes[iDim*2]))
577 leftremotehaloextent =
false;
578 if(leftRemoteHaloExtent[iDim].second != (partitionExtent[iDim].first - 1))
579 leftremotehaloextent =
false;
580 if(leftLocalHaloExtent[iDim].first != partitionExtent[iDim].first)
581 leftlocalhaloextent =
false;
582 if(leftLocalHaloExtent[iDim].second != (partitionExtent[iDim].first + haloSizes[iDim*2] - 1))
583 leftlocalhaloextent =
false;
588 if(partitionExtent[iDim].first == 0){
590 if(leftRemoteHaloExtent[hDim] != partitionExtent[hDim])
591 periodicleftremotehaloextent =
false;
592 if(leftLocalHaloExtent[hDim] != partitionExtent[hDim])
593 periodicleftlocalhaloextent =
false;
597 if(leftRemoteHaloExtent[hDim] != partitionExtent[hDim])
598 leftremotehaloextent =
false;
599 if(leftLocalHaloExtent[hDim] != partitionExtent[hDim])
600 leftlocalhaloextent =
false;
609 messageStream <<
"RightRemoteHalo(" << iDim <<
"): ";
611 messageStream << std::endl;
612 messageStream <<
"RightLocalHalo(" << iDim <<
"): ";
614 messageStream << std::endl;
616 if(haveRightBoundary[iDim]){
617 if(!rightLocalHaloExtent.empty())
618 createrightlocalhaloextents =
false;
619 if(!rightRemoteHaloExtent.empty())
620 createrightremotehaloextents =
false;
624 totalLocalHaloNodes += rightLocalHaloExtent.
NNodes();
625 totalRemoteHaloNodes += rightRemoteHaloExtent.
NNodes();
628 for(
int hDim = 0;hDim < 3;hDim++){
632 if(partitionExtent[iDim].second == globalExtent[iDim].second){
633 if(rightRemoteHaloExtent[iDim].second != (haloSizes[iDim*2+1]-1))
634 periodicrightremotehaloextent =
false;
635 if(rightRemoteHaloExtent[iDim].first != 0)
636 periodicrightremotehaloextent =
false;
637 if(rightLocalHaloExtent[iDim].second != partitionExtent[iDim].second)
638 periodicrightlocalhaloextent =
false;
639 if(rightLocalHaloExtent[iDim].first != (partitionExtent[iDim].second - haloSizes[iDim*2+1] + 1))
640 periodicrightlocalhaloextent =
false;
644 if(rightRemoteHaloExtent[iDim].second != (partitionExtent[iDim].second + haloSizes[iDim*2+1]))
645 rightremotehaloextent =
false;
646 if(rightRemoteHaloExtent[iDim].first != (partitionExtent[iDim].second + 1))
647 rightremotehaloextent =
false;
648 if(rightLocalHaloExtent[iDim].second != partitionExtent[iDim].second)
649 rightlocalhaloextent =
false;
650 if(rightLocalHaloExtent[iDim].first != (partitionExtent[iDim].second - haloSizes[iDim*2+1] + 1))
651 rightlocalhaloextent =
false;
656 if(partitionExtent[iDim].second == globalExtent[iDim].second){
658 if(rightRemoteHaloExtent[hDim] != partitionExtent[hDim])
659 periodicrightremotehaloextent =
false;
660 if(rightLocalHaloExtent[hDim] != partitionExtent[hDim])
661 periodicrightlocalhaloextent =
false;
665 if(rightRemoteHaloExtent[hDim] != partitionExtent[hDim])
666 rightremotehaloextent =
false;
667 if(rightLocalHaloExtent[hDim] != partitionExtent[hDim])
668 rightlocalhaloextent =
false;
675 leftremotehaloextent =
CheckResult(leftremotehaloextent,testComm);
676 leftlocalhaloextent =
CheckResult(leftlocalhaloextent,testComm);
677 periodicleftremotehaloextent =
CheckResult(periodicleftremotehaloextent,testComm);
678 periodicleftlocalhaloextent =
CheckResult(periodicleftlocalhaloextent,testComm);
679 createleftremotehaloextents =
CheckResult(createleftremotehaloextents,testComm);
680 createleftlocalhaloextents =
CheckResult(createleftlocalhaloextents,testComm);
682 parallelUnitResults.
UpdateResult(
"Halo:LRemoteHalo",leftremotehaloextent);
683 parallelUnitResults.
UpdateResult(
"Halo:LLocalHalo",leftlocalhaloextent);
684 parallelUnitResults.
UpdateResult(
"Halo:PeriodicLRemoteHalo",periodicleftremotehaloextent);
685 parallelUnitResults.
UpdateResult(
"Halo:PeriodicLLocalHalo",periodicleftlocalhaloextent);
686 parallelUnitResults.
UpdateResult(
"Halo:CreateLRemoteHalo",createleftremotehaloextents);
687 parallelUnitResults.
UpdateResult(
"Halo:CreateLLocalHalo",createleftlocalhaloextents);
689 rightremotehaloextent =
CheckResult(rightremotehaloextent,testComm);
690 rightlocalhaloextent =
CheckResult(rightlocalhaloextent,testComm);
691 periodicrightremotehaloextent =
CheckResult(periodicrightremotehaloextent,testComm);
692 periodicrightlocalhaloextent =
CheckResult(periodicrightlocalhaloextent,testComm);
693 createrightremotehaloextents =
CheckResult(createrightremotehaloextents,testComm);
694 createrightlocalhaloextents =
CheckResult(createrightlocalhaloextents,testComm);
696 parallelUnitResults.
UpdateResult(
"Halo:RRemoteHalo",rightremotehaloextent);
697 parallelUnitResults.
UpdateResult(
"Halo:RLocalHalo",rightlocalhaloextent);
698 parallelUnitResults.
UpdateResult(
"Halo:PeriodicRRemoteHalo",periodicrightremotehaloextent);
699 parallelUnitResults.
UpdateResult(
"Halo:PeriodicRLocalHalo",periodicrightlocalhaloextent);
700 parallelUnitResults.
UpdateResult(
"Halo:CreateRRemoteHalo",createrightremotehaloextents);
701 parallelUnitResults.
UpdateResult(
"Halo:CreateRLocalHalo",createrightlocalhaloextents);
711 testState.
AddField(
"time",
's',1,8,
"s");
712 testState.
AddField(
"U",
'n',1,8,
"stuff");
713 testState.
AddField(
"V",
'n',3,8,
"things");
714 testState.
AddField(
"iblank",
'n',1,4,
"");
715 testState.
Create(nNodes,nCells);
716 int totalNumComponents = 4;
718 std::vector<double> uVector(nNodes,0);
719 std::vector<double> vVector(nNodes*3,0);
724 for(
size_t iNode = 0;iNode < nNodes;iNode++){
726 size_t localK = iNode/(numX*numY);
727 size_t localJ = (iNode - (localK*numX*numY))/numX;
728 size_t localI = iNode%numX;
730 size_t globalK = localK + partitionExtent[2].first;
731 size_t globalJ = localJ + partitionExtent[1].first;
732 size_t globalI = localI + partitionExtent[0].first;
734 size_t globalNode = globalK * globalSizes[0]*globalSizes[1] +
735 globalJ * globalSizes[0] + globalI;
737 uVector[iNode] = globalNode;
738 vVector[iNode] = uVector[iNode] + numGlobalNodes;
739 vVector[iNode+nNodes] = vVector[iNode] + numGlobalNodes;
740 vVector[iNode+(2*nNodes)] = vVector[iNode+nNodes] + numGlobalNodes;
744 std::vector<int> stateFieldIndices(2,1);
745 stateFieldIndices[1] = 2;
753 std::cout <<
"ERROR WITH HALO STATE COMPONENT COUNT!!" << std::endl;
756 if(totalRemoteHaloNodes == 0 || totalLocalHaloNodes == 0){
757 std::cout <<
"ERROR WITH NO HALO NODES!!" << std::endl;
760 if(numSend == 0 || numRecv == 0){
761 std::cout <<
"ERROR WITH EMPTY COMM BUFFERS!!" << std::endl;
765 bool createSimpleSendBuffers =
true;
766 bool createSimpleRecvBuffers =
true;
768 std::vector<double *> &sendBuffers(testHalo.
SendBuffers());
769 std::vector<double *> &recvBuffers(testHalo.
RecvBuffers());
771 if(sendBuffers.size() != localHaloExtents.size())
772 createSimpleSendBuffers =
false;
773 if(recvBuffers.size() != remoteHaloExtents.size())
774 createSimpleRecvBuffers =
false;
776 createSimpleSendBuffers =
false;
778 createSimpleRecvBuffers =
false;
784 if(!createSimpleSendBuffers || !createSimpleRecvBuffers){
785 std::cout <<
"ERROR CREATING PERIODIC COMM BUFFERS!" << std::endl;
790 bool packsimplesend =
true;
793 int numSendBuffers = sendBuffers.size();
795 for(
int iSend = 0;iSend < numSendBuffers;iSend++){
799 if(sendBuffers[iSend] != NULL){
801 messageStream <<
"Send Address(" << iSend <<
"): " 802 << sendBuffers[iSend] << std::endl;
804 if(sendExtent.empty()){
805 std::cout <<
"Send extent " << iSend <<
" is empty, but " 806 <<
"has associated send buffer!!" << std::endl;
807 createSimpleSendBuffers =
false;
810 std::vector<size_t> sendNodeIds;
813 size_t numSendNodes = sendExtent.
NNodes();
816 for(
size_t iVal = 0;iVal < numValsSend;iVal++){
818 size_t componentId = iVal/numSendNodes;
819 size_t sendNodeId = iVal%numSendNodes;
820 size_t partitionNodeId = sendNodeIds[sendNodeId];
822 size_t localK = partitionNodeId/(numX*numY);
823 size_t localJ = partitionNodeId/numX - localK*numY;
824 size_t localI = partitionNodeId%numX;
826 size_t globalK = localK + partitionExtent[2].first;
827 size_t globalJ = localJ + partitionExtent[1].first;
828 size_t globalI = localI + partitionExtent[0].first;
830 size_t globalNode = globalK * globalSizes[0]*globalSizes[1] +
831 globalJ * globalSizes[0] + globalI;
832 if(globalNode > numGlobalNodes){
833 std::cout <<
"ERROR COUNTING NODES!!" << std::endl;
837 double expectedValue = componentId*numGlobalNodes + globalNode;
839 if(std::abs(sendBuffers[iSend][iVal] - expectedValue) > .5){
840 packsimplesend =
false;
842 std::cout <<
"Node ids (send/part/global): (" << sendNodeId <<
"," << partitionNodeId
844 <<
") Comp:" << componentId <<
" Value (exp/act): (" 845 << expectedValue <<
"," << sendBuffers[iSend][iVal] <<
")" << std::endl;
851 if(!sendExtent.empty()){
852 std::cout <<
"Send extent " << iSend <<
" had no associated send buffer." 854 createSimpleSendBuffers =
false;
860 parallelUnitResults.
UpdateResult(
"Halo:PeriodicSendBuffers",createSimpleSendBuffers);
863 parallelUnitResults.
UpdateResult(
"Halo:PackPeriodicSends",packsimplesend);
865 if(!packsimplesend || !createSimpleSendBuffers)
868 bool simplesend =
true;
869 bool completesimplerecv =
true;
871 testHalo.
SimpleSend(cartNeighbors,myCartComm);
875 int numRecvBuffers = recvBuffers.size();
876 bool periodiccomm =
true;
877 for(
int iRecv = 0;iRecv < numSendBuffers;iRecv++){
880 if(recvExtent.empty())
883 double *recvBuffer = recvBuffers[iRecv];
884 messageStream <<
"Recv Address(" << iRecv <<
"): " 885 << recvBuffer << std::endl;
886 size_t numRecvNodes = recvExtent.
NNodes();
887 size_t baseRecvIndex = 0;
888 size_t kStart = remoteHaloExtents[iRecv][2].first;
889 size_t kEnd = remoteHaloExtents[iRecv][2].second;
890 size_t jStart = remoteHaloExtents[iRecv][1].first;
891 size_t jEnd = remoteHaloExtents[iRecv][1].second;
892 size_t iStart = remoteHaloExtents[iRecv][0].first;
893 size_t iEnd = remoteHaloExtents[iRecv][0].second;
894 for(
size_t haloK = kStart;haloK <= kEnd;haloK++){
895 for(
size_t haloJ = jStart;haloJ <= jEnd;haloJ++){
896 for(
size_t haloI = iStart;haloI <= iEnd;haloI++){
897 size_t globalNode = haloK*globalSizes[0]*globalSizes[1] +
898 haloJ*globalSizes[0] + haloI;
899 for(
int iComponent = 0;iComponent < totalNumComponents;iComponent++){
900 double expectedValue = globalNode + iComponent*numGlobalNodes;
901 size_t recvBufferIndex = baseRecvIndex + iComponent*numRecvNodes;
902 double actualValue = recvBuffer[recvBufferIndex];
903 if(actualValue != expectedValue){
904 messageStream <<
"Rank(" << myRank <<
") Dir(" << iRecv <<
") GlobalNode(" 905 << globalNode <<
") Node[comp" 906 << iComponent <<
",n" << baseRecvIndex <<
",i" << recvBufferIndex
907 <<
"]g(" << haloI <<
"," << haloJ <<
"," << haloK <<
") RecvValue(actual,expected):(" 908 << actualValue <<
"," << expectedValue <<
")" << std::endl;
909 periodiccomm =
false;
918 parallelUnitResults.
UpdateResult(
"Halo:PeriodicCommunication",periodiccomm);
925 bool unpacksimplerecvbuffers =
true;
926 std::vector<std::vector<double *> > &haloBuffers(testHalo.
HaloBuffers());
929 for(
int iDim = 0;iDim < 3;iDim++){
931 if(!haveLeftBoundary[iDim]){
932 size_t numHaloNodes = leftRemoteHaloExtent.
NNodes();
933 size_t kBegin = leftRemoteHaloExtent[2].first;
934 size_t kEnd = leftRemoteHaloExtent[2].second;
935 size_t jBegin = leftRemoteHaloExtent[1].first;
936 size_t jEnd = leftRemoteHaloExtent[1].second;
937 size_t iBegin = leftRemoteHaloExtent[0].first;
938 size_t iEnd = leftRemoteHaloExtent[0].second;
939 size_t haloNodeIndex = 0;
940 for(
size_t kIndex = kBegin;kIndex <= kEnd;kIndex++){
941 for(
size_t jIndex = jBegin;jIndex <= jEnd;jIndex++){
942 for(
size_t iIndex = iBegin;iIndex <= iEnd;iIndex++){
943 size_t globalNode = kIndex * globalSizes[0]*globalSizes[1] +
944 jIndex * globalSizes[0] + iIndex;
945 if(globalNode > numGlobalNodes)
947 for(
int iComponent = 0;iComponent < totalNumComponents;iComponent++){
948 int iField = (iComponent > 0 ? 1 : 0);
949 int compFac = (iField > 0 ? 1 : 0);
950 double expectedValue = iComponent*numGlobalNodes + globalNode;
951 size_t haloBufferIndex = compFac*(iComponent-1)*numHaloNodes+haloNodeIndex;
952 if(haloBuffers[iField][iDim*2][haloBufferIndex] != expectedValue){
953 messageStream <<
"Rank(" << myRank <<
") GlobalNode(" << globalNode <<
") LHaloNode[" 954 << iField <<
"," << haloBufferIndex <<
"](" << iIndex <<
"," 955 << jIndex <<
"," << kIndex <<
") HaloValue(actual,expected):(" 956 << haloBuffers[iField][iDim*2][haloBufferIndex]
957 <<
"," << expectedValue <<
")" << std::endl;
958 unpacksimplerecvbuffers =
false;
967 if(!haveRightBoundary[iDim]){
968 size_t numHaloNodes = rightRemoteHaloExtent.
NNodes();
969 size_t kBegin = rightRemoteHaloExtent[2].first;
970 size_t kEnd = rightRemoteHaloExtent[2].second;
971 size_t jBegin = rightRemoteHaloExtent[1].first;
972 size_t jEnd = rightRemoteHaloExtent[1].second;
973 size_t iBegin = rightRemoteHaloExtent[0].first;
974 size_t iEnd = rightRemoteHaloExtent[0].second;
975 size_t haloNodeIndex = 0;
976 for(
size_t kIndex = kBegin;kIndex <= kEnd;kIndex++){
977 for(
size_t jIndex = jBegin;jIndex <= jEnd;jIndex++){
978 for(
size_t iIndex = iBegin;iIndex <= iEnd;iIndex++){
979 size_t globalNode = kIndex * globalSizes[0]*globalSizes[1] +
980 jIndex * globalSizes[0] + iIndex;
981 if(globalNode > numGlobalNodes)
983 for(
int iComponent = 0;iComponent < totalNumComponents;iComponent++){
984 int iField = (iComponent > 0 ? 1 : 0);
985 int compFac = (iField > 0 ? 1 : 0);
986 double expectedValue = iComponent*numGlobalNodes + globalNode;
987 size_t haloBufferIndex = compFac*(iComponent-1)*numHaloNodes+haloNodeIndex;
988 if(haloBuffers[iField][iDim*2+1][haloBufferIndex] != expectedValue){
989 messageStream <<
"Rank(" << myRank <<
") GlobalNode(" << globalNode <<
") RHaloNode[" 990 << iField <<
"," << haloBufferIndex <<
"](" << iIndex <<
"," 991 << jIndex <<
"," << kIndex <<
") HaloValue(actual,expected):(" 992 << haloBuffers[iField][iDim*2+1][haloBufferIndex]
993 <<
"," << expectedValue <<
")" << std::endl;
994 unpacksimplerecvbuffers =
false;
1008 parallelUnitResults.
UpdateResult(
"Halo:PeriodicSend",simplesend);
1009 parallelUnitResults.
UpdateResult(
"Halo:PeriodicCompleteSimpleRecv",completesimplerecv);
1010 parallelUnitResults.
UpdateResult(
"Halo:PeriodicUnpackSimpleRecv",unpacksimplerecvbuffers);
1012 if(!unpacksimplerecvbuffers)
1019 std::vector<size_t> globalSizes(3,101);
1023 std::vector<size_t> startIndices(3,5);
1024 std::vector<size_t> partitionSizes(3,6);
1025 partitionExtent.
Init(startIndices,partitionSizes);
1030 size_t nCells = 125;
1031 size_t nNodes = 216;
1033 bool constructorworks =
true;
1037 constructorworks =
false;
1039 constructorworks =
false;
1042 std::vector<size_t> haloSizes(6,2);
1046 bool createremotehaloextents =
true;
1047 bool createlocalhaloextents =
true;
1049 if(remoteHaloExtents.size() != 6)
1050 createremotehaloextents =
false;
1051 if(localHaloExtents.size() != 6)
1052 createlocalhaloextents =
false;
1055 int totalLocalHaloNodes = 0;
1056 int totalRemoteHaloNodes = 0;
1058 for(
int iDim = 0;iDim < 3;iDim++){
1065 totalLocalHaloNodes += leftLocalHaloExtent.
NNodes();
1066 totalLocalHaloNodes += rightLocalHaloExtent.
NNodes();
1067 totalRemoteHaloNodes += leftRemoteHaloExtent.
NNodes();
1068 totalRemoteHaloNodes += rightRemoteHaloExtent.
NNodes();
1070 for(
int hDim = 0;hDim < 3;hDim++){
1074 if(leftRemoteHaloExtent[iDim].first != (partitionExtent[iDim].first - haloSizes[iDim*2]))
1075 createremotehaloextents =
false;
1076 if(leftRemoteHaloExtent[iDim].second != (partitionExtent[iDim].first - 1))
1077 createremotehaloextents =
false;
1079 if(leftLocalHaloExtent[iDim].first != partitionExtent[iDim].first)
1080 createlocalhaloextents =
false;
1081 if(leftLocalHaloExtent[iDim].second != (partitionExtent[iDim].first + haloSizes[iDim*2] - 1))
1082 createlocalhaloextents =
false;
1084 if(rightRemoteHaloExtent[iDim].second != (partitionExtent[iDim].second + haloSizes[iDim*2]))
1085 createremotehaloextents =
false;
1086 if(rightRemoteHaloExtent[iDim].first != (partitionExtent[iDim].second + 1))
1087 createremotehaloextents =
false;
1089 if(rightLocalHaloExtent[iDim].second != partitionExtent[iDim].second)
1090 createlocalhaloextents =
false;
1091 if(rightLocalHaloExtent[iDim].first != (partitionExtent[iDim].second - haloSizes[iDim*2] + 1))
1092 createlocalhaloextents =
false;
1096 if(leftRemoteHaloExtent[hDim] != partitionExtent[hDim])
1097 createremotehaloextents =
false;
1098 if(rightRemoteHaloExtent[hDim] != partitionExtent[hDim])
1099 createremotehaloextents =
false;
1101 if(leftLocalHaloExtent[hDim] != partitionExtent[hDim])
1102 createlocalhaloextents =
false;
1103 if(rightLocalHaloExtent[hDim] != partitionExtent[hDim])
1104 createlocalhaloextents =
false;
1109 bool setremotehaloextents =
false;
1110 bool setlocalhaloextents =
false;
1114 setremotehaloextents =
true;
1118 setlocalhaloextents =
true;
1121 testState.
AddField(
"time",
's',1,8,
"s");
1122 testState.
AddField(
"U",
'n',1,8,
"stuff");
1123 testState.
AddField(
"V",
'n',3,8,
"things");
1124 testState.
AddField(
"iblank",
'n',1,4,
"");
1125 testState.
Create(nNodes,nCells);
1127 std::vector<double> uVector(nNodes,0);
1128 std::vector<double> vVector(nNodes*3,0);
1132 for(
int iNode = 0;iNode < nNodes;iNode++){
1133 uVector[iNode] = iNode;
1134 vVector[iNode] = uVector[iNode] + nNodes;
1135 vVector[iNode+nNodes] = vVector[iNode] + nNodes;
1136 vVector[iNode+(2*nNodes)] = vVector[iNode+nNodes] + nNodes;
1139 std::vector<int> stateFieldIndices(2,1);
1140 stateFieldIndices[1] = 2;
1143 bool configuredata =
true;
1146 configuredata =
false;
1148 configuredata =
false;
1150 configuredata =
false;
1152 bool createSimpleSendBuffers =
true;
1153 bool createSimpleRecvBuffers =
true;
1158 std::vector<double *> &sendBuffers(testHalo.
SendBuffers());
1159 std::vector<double *> &recvBuffers(testHalo.
RecvBuffers());
1161 if(sendBuffers.size() != localHaloExtents.size())
1162 createSimpleSendBuffers =
false;
1163 if(recvBuffers.size() != remoteHaloExtents.size())
1164 createSimpleRecvBuffers =
false;
1166 createSimpleSendBuffers =
false;
1168 createSimpleRecvBuffers =
false;
1171 bool createhalobuffers =
true;
1173 bool packsimplesend =
true;
1175 int numSendBuffers = sendBuffers.size();
1176 for(
int iSend = 0;iSend < numSendBuffers;iSend++){
1179 std::vector<size_t> sendNodeIds;
1181 size_t numSendNodes = sendExtent.
NNodes();
1183 for(
size_t iVal = 0;iVal < numValsSend;iVal++){
1184 size_t componentId = iVal/numSendNodes;
1185 size_t sendNodeId = iVal%numSendNodes;
1186 size_t partitionNodeId = sendNodeIds[sendNodeId];
1187 double expectedValue = componentId*nNodes + partitionNodeId;
1188 if(sendBuffers[iSend][iVal] != expectedValue){
1189 packsimplesend =
false;
1190 std::cout <<
"Node (send/par): (" << sendNodeId <<
"," << partitionNodeId
1191 <<
") Comp:" << componentId <<
" Value (exp/act): (" 1192 << expectedValue <<
"," << sendBuffers[iSend][iVal] <<
")" << std::endl;
1200 for(
int iDim = 0;iDim < 3;iDim++){
1201 size_t numCopyNodes = localHaloExtents[2*iDim].NNodes();
1204 std::memcpy(&(recvBuffers[2*iDim][0]),&(sendBuffers[2*iDim+1][0]),numBytes);
1205 std::memcpy(&(recvBuffers[2*iDim+1][0]),&(sendBuffers[2*iDim][0]),numBytes);
1213 bool unpackrecvbuffers =
true;
1214 std::vector<std::vector<double *> > &haloBuffers(testHalo.
HaloBuffers());
1216 std::vector<double *> &fieldBuffers(haloBuffers[iField]);
1218 for(
int iDim = 0;iDim < 3;iDim++){
1219 size_t numHaloNodes = localHaloExtents[2*iDim].NNodes();
1220 const double *haloBuffer0(fieldBuffers[2*iDim]);
1221 const double *haloBuffer1(fieldBuffers[2*iDim+1]);
1222 const double *sendBuffer0(&sendBuffers[2*iDim][iField*numHaloNodes]);
1223 const double *sendBuffer1(&sendBuffers[2*iDim+1][iField*numHaloNodes]);
1224 for(
int iComponent = 0;iComponent < numFieldComponents;iComponent++){
1225 size_t bufComp = iComponent * numHaloNodes;
1226 for(
int iVal = 0;iVal < numHaloNodes;iVal++){
1227 int bufIndex = bufComp + iVal;
1228 if(haloBuffer0[bufIndex] != sendBuffer1[bufIndex] ||
1229 haloBuffer1[bufIndex] != sendBuffer0[bufIndex])
1230 unpackrecvbuffers =
false;
1237 serialUnitResults.
UpdateResult(
"Halo:GlobalExtentsConstructor",constructorworks);
1238 serialUnitResults.
UpdateResult(
"Halo:CreateRemoteHaloExtents",createremotehaloextents);
1239 serialUnitResults.
UpdateResult(
"Halo:CreateLocalHaloExtents",createlocalhaloextents);
1240 serialUnitResults.
UpdateResult(
"Halo:SetRemoteHaloExtents",setremotehaloextents);
1241 serialUnitResults.
UpdateResult(
"Halo:SetLocalHaloExtents",setlocalhaloextents);
1242 serialUnitResults.
UpdateResult(
"Halo:ConfigureData",configuredata);
1243 serialUnitResults.
UpdateResult(
"Halo:CreateSimpleSendBuffers",createSimpleSendBuffers);
1244 serialUnitResults.
UpdateResult(
"Halo:CreateSimpleRecvBuffers",createSimpleRecvBuffers);
1245 serialUnitResults.
UpdateResult(
"Halo:CreateHaloBuffers",createhalobuffers);
1246 serialUnitResults.
UpdateResult(
"Halo:PackSimpleSendBuffers",packsimplesend);
1247 serialUnitResults.
UpdateResult(
"Halo:UnpackReceiveBuffers",unpackrecvbuffers);
1256 std::vector<size_t> globalSizes(3,101);
1260 std::vector<size_t> startIndices(3,5);
1261 std::vector<size_t> partitionSizes(3,8);
1262 partitionExtent.
Init(startIndices,partitionSizes);
1267 size_t nCells = 343;
1268 size_t nNodes = 512;
1270 bool constructorworks =
true;
1274 constructorworks =
false;
1276 constructorworks =
false;
1278 bool setNumThreadsWorks =
true;
1280 std::vector<pcpp::IndexIntervalType> &threadExtents(testHalo.
ThreadExtents());
1281 if(threadExtents.size() != numThreads)
1282 setNumThreadsWorks =
false;
1284 setNumThreadsWorks =
false;
1285 serialUnitResults.
UpdateResult(
"Halo:SetNumThreads",setNumThreadsWorks);
1287 std::vector<size_t> haloSizes(6,2);
1291 bool createremotehaloextents =
true;
1292 bool createlocalhaloextents =
true;
1294 if(remoteHaloExtents.size() != 6)
1295 createremotehaloextents =
false;
1296 if(localHaloExtents.size() != 6)
1297 createlocalhaloextents =
false;
1304 testState.
AddField(
"time",
's',1,8,
"s");
1305 testState.
AddField(
"U",
'n',1,8,
"stuff");
1306 testState.
AddField(
"V",
'n',3,8,
"things");
1307 testState.
AddField(
"iblank",
'n',1,4,
"");
1308 testState.
Create(nNodes,nCells);
1310 std::vector<double> uVector(nNodes,0);
1311 std::vector<double> vVector(nNodes*3,0);
1315 for(
int iNode = 0;iNode < nNodes;iNode++){
1316 uVector[iNode] = iNode;
1317 vVector[iNode] = uVector[iNode] + nNodes;
1318 vVector[iNode+nNodes] = vVector[iNode] + nNodes;
1319 vVector[iNode+(2*nNodes)] = vVector[iNode+nNodes] + nNodes;
1322 std::vector<int> stateFieldIndices(2,1);
1323 stateFieldIndices[1] = 2;
1328 bool createSimpleSendBuffers =
true;
1329 bool createSimpleRecvBuffers =
true;
1334 std::vector<double *> &sendBuffers(testHalo.
SendBuffers());
1335 std::vector<double *> &recvBuffers(testHalo.
RecvBuffers());
1338 std::vector<std::vector<double *> > &haloBuffers(testHalo.
HaloBuffers());
1340 std::vector<bool> partDirs(3,
true);
1341 partDirs[0] =
false;
1342 bool createThreadSendInd =
true;
1343 for(
int iThread = 0;iThread < numThreads;iThread++){
1344 std::vector<int> numThreadParts;
1346 iThread,numThreads,threadExtents[iThread],numThreadParts)){
1350 std::cout <<
"Thread(" << iThread <<
"): ";
1351 threadExtents[iThread].PrettyPrint(std::cout);
1352 std::cout << std::endl;
1355 createThreadSendInd =
false;
1360 int numSendBuffers = sendBuffers.size();
1361 for(
int iSend = 0;iSend < numSendBuffers;iSend++){
1362 double *sendBuffer = sendBuffers[iSend];
1364 size_t numSendNodes = sendExtent.
NNodes();
1367 size_t numThreadSend = threadSendExtent.
NNodes();
1368 if(numThreadSend > 0){
1370 std::vector<size_t> sendNodeIds;
1373 std::vector<size_t> sendBufferIndices;
1377 size_t componentIndex = iComponent*numSendNodes;
1378 for(
size_t iThreadNode = 0;iThreadNode < numThreadSend;iThreadNode++){
1379 size_t sendBufferIndex = sendBufferIndices[iThreadNode] + componentIndex;
1380 if(sendBuffer[sendBufferIndex] != -100*(iThread+1)*(iSend+1))
1381 createThreadSendInd =
false;
1387 serialUnitResults.
UpdateResult(
"Halo:CreateThreadSendIndices",createThreadSendInd);
1389 bool threadedpack =
true;
1390 for(
int iThread = 0;iThread < numThreads;iThread++){
1392 threadedpack =
false;
1395 int numSendBuffers = sendBuffers.size();
1396 for(
int iSend = 0;iSend < numSendBuffers;iSend++){
1399 std::vector<size_t> sendNodeIds;
1401 size_t numSendNodes = sendExtent.
NNodes();
1403 for(
size_t iVal = 0;iVal < numValsSend;iVal++){
1404 size_t componentId = iVal/numSendNodes;
1405 size_t sendNodeId = iVal%numSendNodes;
1406 size_t partitionNodeId = sendNodeIds[sendNodeId];
1407 double expectedValue = componentId*nNodes + partitionNodeId;
1408 if(sendBuffers[iSend][iVal] != expectedValue){
1409 threadedpack =
false;
1410 std::cout <<
"Node (send/par): (" << sendNodeId <<
"," << partitionNodeId
1411 <<
") Comp:" << componentId <<
" Value (exp/act): (" 1412 << expectedValue <<
"," << sendBuffers[iSend][iVal] <<
")" << std::endl;
1416 serialUnitResults.
UpdateResult(
"Halo:ThreadedPack",threadedpack);
1419 bool createThreadRecvInd =
true;
1420 for(
int iThread = 0;iThread < numThreads;iThread++){
1422 createThreadRecvInd =
false;
1428 int numRecvBuffers = recvBuffers.size();
1429 for(
int iRecv = 0;iRecv < numRecvBuffers;iRecv++){
1430 std::vector<double *> &remoteHaloBuffers(haloBuffers[iRecv]);
1431 double *recvBuffer = recvBuffers[iRecv];
1433 size_t numRecvNodes = haloExtent.
NNodes();
1436 size_t numThreadRecv = threadRecvExtent.
NNodes();
1437 if(numThreadRecv > 0){
1438 std::cout <<
"NumThreadRecv: " << numThreadRecv << std::endl;
1443 int componentId = 0;
1444 std::vector<size_t> recvBufferIndices;
1449 double *haloBuffer = remoteHaloBuffers[iField];
1450 for(
int iComponent = 0;iComponent < numFieldComponents;iComponent++){
1451 size_t haloComponentIndex = iComponent*numRecvNodes;
1452 size_t recvComponentIndex = numRecvNodes*componentId++;
1453 for(
size_t iThreadNode = 0;iThreadNode < numThreadRecv;iThreadNode++){
1454 size_t recvBufferIndex = recvBufferIndices[iThreadNode] + recvComponentIndex;
1455 size_t haloBufferIndex = recvBufferIndices[iThreadNode] + haloComponentIndex;
1456 if(recvBuffer[recvBufferIndex] != -100*(iThread+1)+(iRecv+1))
1457 createThreadRecvInd =
false;
1458 if(haloBuffer[haloBufferIndex] != -100*(iThread+1)+(iRecv+1))
1459 createThreadRecvInd =
false;
1466 serialUnitResults.
UpdateResult(
"Halo:CreateThreadRecvIndices",createThreadRecvInd);
1470 for(
int iDim = 0;iDim < 3;iDim++){
1471 size_t numCopyNodes = localHaloExtents[2*iDim].NNodes();
1474 std::memcpy(&(recvBuffers[2*iDim][0]),&(sendBuffers[2*iDim+1][0]),numBytes);
1475 std::memcpy(&(recvBuffers[2*iDim+1][0]),&(sendBuffers[2*iDim][0]),numBytes);
1480 bool unpackthreaded =
true;
1481 for(
int iThread = 0;iThread < numThreads;iThread++)
1483 unpackthreaded =
false;
1487 std::vector<double *> &fieldBuffers(haloBuffers[iField]);
1489 for(
int iDim = 0;iDim < 3;iDim++){
1490 size_t numHaloNodes = localHaloExtents[2*iDim].NNodes();
1491 const double *haloBuffer0(fieldBuffers[2*iDim]);
1492 const double *haloBuffer1(fieldBuffers[2*iDim+1]);
1493 const double *sendBuffer0(&sendBuffers[2*iDim][iField*numHaloNodes]);
1494 const double *sendBuffer1(&sendBuffers[2*iDim+1][iField*numHaloNodes]);
1495 for(
int iComponent = 0;iComponent < numFieldComponents;iComponent++){
1496 size_t bufComp = iComponent * numHaloNodes;
1497 for(
int iVal = 0;iVal < numHaloNodes;iVal++){
1498 int bufIndex = bufComp + iVal;
1499 if(haloBuffer0[bufIndex] != sendBuffer1[bufIndex] ||
1500 haloBuffer1[bufIndex] != sendBuffer0[bufIndex])
1501 unpackthreaded =
false;
1506 serialUnitResults.
UpdateResult(
"Halo:ThreadedUnPack",unpackthreaded);
std::vector< int > cartDecompDirections
void SetNumThreads(int numThreadsIn)
int CreateThreadRecvIndices(int threadId)
Create receive buffers for state data from neighboring processors.
std::vector< double * > & SendBuffers()
std::vector< std::vector< double * > > & HaloBuffers()
int PostSimpleReceives(std::vector< int > &sourceRanks, CommunicatorType &inComm)
void TestHaloPeriodic(ix::test::results ¶llelUnitResults, pcpp::CommunicatorType &testComm)
int SimplePartitionInterval(const pcpp::IndexIntervalType &inInterval, std::vector< bool > partDirection, int partID, int numPart, pcpp::IndexIntervalType &outInterval, std::vector< int > &numPartitions)
Multi-dimensional interval partitioning (non-MPI)
std::vector< pcpp::IndexIntervalType > & RemoteHaloExtents()
void GetFlatIndices(const sizeextent &extent, ContainerType &indices) const
std::vector< int > numFieldComponents
int SetStateFields(const std::vector< int > &inFieldIndices)
int CartNeighbors(std::vector< int > &neighborRanks)
int CompleteSimpleReceives(CommunicatorType &inComm)
std::vector< pcpp::IndexIntervalType > & ThreadExtents()
int UnpackReceiveBuffers()
void TestHaloThreaded(ix::test::results &serialUnitResults)
int CreateSimpleRecvBuffers()
Create receive buffers for state data from neighboring processors.
void RenewStream(std::ostringstream &outStream)
bool CheckResult(bool &localResult, pcpp::CommunicatorType &testComm)
pcpp::IndexIntervalType & PartitionExtent()
void CartesianSetup(std::ostream &outStream, const std::vector< int > &cartCoords, const std::vector< int > &cartDims)
virtual size_t Create(size_t number_of_nodes=0, size_t number_of_cells=0)
void SetNeighbors(const std::vector< bool > &inNeighbors)
std::vector< pcpp::IndexIntervalType > CreateRemoteHaloExtents(const pcpp::IndexIntervalType &globalExtent, const pcpp::IndexIntervalType &partitionExtent, std::vector< size_t > &haloSizes)
void SetThreadExtent(int myThreadId, pcpp::IndexIntervalType threadInterval)
void ConfigureData(const state::base &inState)
Encapsulating class for collections of test results.
void TestHaloParallel(ix::test::results ¶llelUnitResults, pcpp::CommunicatorType &testComm)
std::vector< int > isPeriodic
void Everyone(const std::string &outString, std::ostream &outStream, fixtures::CommunicatorType &comm)
int Check(comm::Ops op=comm::MAXOP)
void SetLocalHaloExtents(const std::vector< pcpp::IndexIntervalType > haloExtents)
Main encapsulation of MPI.
int UnpackSimpleRecvBuffers(int threadId)
Testing constructs for unit testing.
std::vector< int > & StateFieldIndices()
int CreateThreadSendIndices(int threadId)
Creates send buffers for each whole local halo extent.
void Overlap(const sizeextent &inextent, sizeextent &outextent) const
int SimpleSend(std::vector< int > &neighborRanks, CommunicatorType &inComm)
int PartitionCartesianExtent(const pcpp::IndexIntervalType &globalExtent, const std::vector< int > &cartDims, const std::vector< int > &cartCoords, pcpp::IndexIntervalType &partExtent, std::ostream &messageStream)
Get local sub-interval of an n-dimensional integer interval.
std::vector< double * > & RecvBuffers()
void SetRemoteHaloExtents(const std::vector< pcpp::IndexIntervalType > haloExtents)
void Init(const ContainerType &inflatextent)
void UpdateResult(const std::string &name, const ValueType &result)
Updates an existing test result.
std::ostream & PrettyPrint(std::ostream &outStream) const
int SetupCartesianTopology(pcpp::CommunicatorType ¶llelCommunicator, pcpp::ParallelTopologyInfoType &topologyInfo, pcpp::CommunicatorType &topoCommunicator, std::ostream &messageStream)
Sets up a communicator with Cartesian topology.
Simple Block Structured Mesh object.
void AddField(const std::string &name, char loc, unsigned int ncomp, unsigned int dsize, const std::string &unit)
int CreateSimpleSendBuffers()
Creates send buffers for each whole local halo extent.
int PackSimpleSendBuffers(const state::base &inX, int threadId)
Packs a send buffer with all components of state fields.
void SetFieldBuffer(const std::string &name, void *buf)
std::vector< pcpp::IndexIntervalType > CreateLocalHaloExtents(const pcpp::IndexIntervalType &globalExtent, const pcpp::IndexIntervalType &partitionExtent, std::vector< size_t > &haloSizes)
void TestHaloBasic(ix::test::results &serialUnitResults)
std::vector< int > & CartDimensions()
void InitSimple(const ContainerType &inSize)
pcpp::IndexIntervalType & GlobalExtent()
std::vector< pcpp::IndexIntervalType > & LocalHaloExtents()
std::vector< int > & CartCoordinates()