MCPcopy Create free account
hub / github.com/Kitware/VTK / PartitionSubArray

Method PartitionSubArray

Filters/Parallel/vtkPKdTree.cxx:1177–1452  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1175// If there is no third interval, the second index returned will be R+1.
1176
1177int* vtkPKdTree::PartitionSubArray(int L, int R, int K, int dim, int p1, int p2)
1178{
1179 int rootrank = this->SubGroup->getLocalRank(p1);
1180
1181 int me = this->MyId;
1182
1183 if ((me < p1) || (me > p2))
1184 {
1185 this->SubGroup->Broadcast(this->SelectBuffer.data(), 2, rootrank);
1186 return this->SelectBuffer.data();
1187 }
1188
1189 if (p1 == p2)
1190 {
1191 int* idx = this->PartitionAboutMyValue(L, R, K, dim);
1192
1193 this->SubGroup->Broadcast(idx, 2, rootrank);
1194
1195 return idx;
1196 }
1197
1198 // Each process will rearrange their subarray myL-myR into a left region
1199 // of values less than X[K], a center region of values equal to X[K], and
1200 // a right region of values greater than X[K]. "I" will be the index
1201 // of the first value in the center region, or it will equal "J" if there
1202 // is no center region. "J" will be the index to the start of the
1203 // right region, or it will be R+1 if there is no right region.
1204
1205 int tag = this->SubGroup->tag;
1206
1207 vtkSubGroup* sg = vtkSubGroup::New();
1208 sg->Initialize(p1, p2, me, tag, this->Controller->GetCommunicator());
1209
1210 int hasK = this->WhoHas(K);
1211
1212 int Krank = sg->getLocalRank(hasK);
1213
1214 int myL = this->StartVal[me];
1215 int myR = this->EndVal[me];
1216
1217 myL = std::max(myL, L);
1218 myR = std::min(myR, R);
1219
1220 // Get Kth element
1221
1222 float T;
1223
1224 if (hasK == me)
1225 {
1226 T = this->GetLocalVal(K)[dim];
1227 }
1228
1229 sg->Broadcast(&T, 1, Krank);
1230
1231 int* idx; // dividing points in rearranged sub array
1232
1233 if (hasK == me)
1234 {

Callers 1

_selectMethod · 0.95

Calls 15

PartitionAboutMyValueMethod · 0.95
WhoHasMethod · 0.95
GetLocalValMethod · 0.95
DoTransferMethod · 0.95
SwitchDoubleBufferMethod · 0.95
getLocalRankMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
maxFunction · 0.50
minFunction · 0.50
BroadcastMethod · 0.45

Tested by

no test coverage detected