------------------------------------------------------------------------------
| 360 | |
| 361 | //------------------------------------------------------------------------------ |
| 362 | int vtkDIYAggregateDataSetFilter::MoveData(int inputExtent[6], int wholeExtent[6], |
| 363 | int outputExtent[6], std::map<int, std::string>& serializedDataSets, |
| 364 | std::vector<std::string>& receivedDataSets) |
| 365 | { |
| 366 | vtkMPIController* controller = |
| 367 | vtkMPIController::SafeDownCast(vtkMultiProcessController::GetGlobalController()); |
| 368 | |
| 369 | vtkNew<vtkIdList> processesIReceiveFrom; |
| 370 | this->ComputeProcessesIReceiveFrom(inputExtent, wholeExtent, outputExtent, processesIReceiveFrom); |
| 371 | |
| 372 | // map to keep track of the size of data I receive from each process |
| 373 | std::vector<int> receiveSizes(processesIReceiveFrom->GetNumberOfIds(), 0); |
| 374 | std::vector<vtkMPICommunicator::Request> sizeReceiveRequests( |
| 375 | processesIReceiveFrom->GetNumberOfIds()); |
| 376 | for (vtkIdType i = 0; i < processesIReceiveFrom->GetNumberOfIds(); i++) |
| 377 | { |
| 378 | controller->NoBlockReceive( |
| 379 | receiveSizes.data() + i, 1, processesIReceiveFrom->GetId(i), 9318, sizeReceiveRequests[i]); |
| 380 | } |
| 381 | |
| 382 | std::vector<vtkMPICommunicator::Request> sizeSendRequests(serializedDataSets.size()); |
| 383 | int counter = 0; |
| 384 | for (const auto& it : serializedDataSets) |
| 385 | { |
| 386 | int size = static_cast<int>(it.second.size()); |
| 387 | controller->NoBlockSend(&size, 1, it.first, 9318, sizeSendRequests[counter]); |
| 388 | counter++; |
| 389 | } |
| 390 | |
| 391 | controller->WaitAll(static_cast<int>(sizeReceiveRequests.size()), sizeReceiveRequests.data()); |
| 392 | std::vector<vtkMPICommunicator::Request> dataReceiveRequests( |
| 393 | processesIReceiveFrom->GetNumberOfIds()); |
| 394 | std::vector<unsigned char*> dataArrays; |
| 395 | for (vtkIdType i = 0; i < processesIReceiveFrom->GetNumberOfIds(); i++) |
| 396 | { |
| 397 | int size = receiveSizes[i]; |
| 398 | dataArrays.push_back(new unsigned char[size + 1]); |
| 399 | dataArrays.back()[size] = '\0'; |
| 400 | controller->NoBlockReceive( |
| 401 | dataArrays.back(), size, processesIReceiveFrom->GetId(i), 9319, dataReceiveRequests[i]); |
| 402 | } |
| 403 | |
| 404 | std::vector<vtkMPICommunicator::Request> dataSendRequests(serializedDataSets.size()); |
| 405 | counter = 0; |
| 406 | // deal with problems with not being able to get direct access to the string's memory. |
| 407 | // in the future we may want to look at ways to make this more memory efficient. for |
| 408 | // now it's not too bad though in that it really only has 2 copies of the sent data |
| 409 | // to a single process since it clears out the string after it copies it over |
| 410 | // to sendData. |
| 411 | std::vector<std::vector<unsigned char>> sendData(serializedDataSets.size()); |
| 412 | for (auto it : serializedDataSets) |
| 413 | { |
| 414 | int size = static_cast<int>(it.second.size()); |
| 415 | sendData[counter].resize(size); |
| 416 | for (int i = 0; i < size; i++) |
| 417 | { |
| 418 | sendData[counter][i] = static_cast<unsigned char>(it.second[i]); |
| 419 | } |
no test coverage detected