findOwnerOfGhost optimization and refactor
parent
3e945c75b4
commit
44f174a571
@ -1,48 +1,29 @@
|
|||||||
#include "MatchBoxPC.h"
|
#include "MatchBoxPC.h"
|
||||||
|
|
||||||
|
|
||||||
//TODO parallelize this
|
|
||||||
/// Find the owner of a ghost node:
|
/// Find the owner of a ghost node:
|
||||||
MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance,
|
MilanInt findOwnerOfGhost(MilanLongInt vtxIndex, MilanLongInt *mVerDistance,
|
||||||
MilanInt myRank, MilanInt numProcs) {
|
MilanInt myRank, MilanInt numProcs)
|
||||||
|
{
|
||||||
|
|
||||||
MilanLongInt mStartInd = mVerDistance[myRank];
|
MilanLongInt mStartInd = mVerDistance[myRank];
|
||||||
MilanInt Start = 0;
|
MilanInt Start = 0;
|
||||||
MilanInt End = numProcs;
|
MilanInt End = numProcs;
|
||||||
MilanInt Current = 0;
|
MilanInt Current = 0;
|
||||||
|
|
||||||
#if 0
|
while (Start <= End)
|
||||||
if ( vtxIndex < mStartInd )
|
{
|
||||||
End = myRank;
|
|
||||||
else
|
|
||||||
Start = myRank;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
while ( Start <= End ) {
|
|
||||||
Current = (End + Start) / 2;
|
Current = (End + Start) / 2;
|
||||||
// CASE-1:
|
// CASE-1:
|
||||||
if ( mVerDistance[Current] == vtxIndex ) {
|
if (mVerDistance[Current] == vtxIndex) return Current;
|
||||||
while ( mVerDistance[Current+1] == vtxIndex ) {
|
else // CASE 2:
|
||||||
Current++;
|
|
||||||
if ( Current == numProcs )
|
|
||||||
return (-1);
|
|
||||||
}
|
|
||||||
return (Current);
|
|
||||||
}
|
|
||||||
else { //CASE 2:
|
|
||||||
if (mVerDistance[Current] > vtxIndex)
|
if (mVerDistance[Current] > vtxIndex)
|
||||||
End = Current - 1;
|
End = Current - 1;
|
||||||
else // CASE 3:
|
else // CASE 3:
|
||||||
Start = Current + 1;
|
Start = Current + 1;
|
||||||
}
|
|
||||||
} // End of While()
|
} // End of While()
|
||||||
if ( Current == 0 )
|
|
||||||
return (Current);
|
|
||||||
else {
|
|
||||||
if (mVerDistance[Current] > vtxIndex)
|
if (mVerDistance[Current] > vtxIndex)
|
||||||
return (Current - 1);
|
return (Current - 1);
|
||||||
else
|
|
||||||
return (Current);
|
return Current;
|
||||||
} //End of else
|
|
||||||
return (-1); //It should not reach here!
|
|
||||||
} // End of findOwnerOfGhost()
|
} // End of findOwnerOfGhost()
|
||||||
|
Loading…
Reference in New Issue