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

Method BuildOutputTrees

Filters/ParallelMPI/vtkHyperTreeGridRedistribute.cxx:772–839  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

770}
771//------------------------------------------------------------------------------
772void vtkHyperTreeGridRedistribute::BuildOutputTrees(vtkBitArray* descriptorSendBuffer,
773 std::vector<int>& descriptorSizesReceivedBuffer, std::vector<int>& descriptorsByteOffsets)
774{
775 // Build output trees from descriptors received from other processes
776
777 std::vector<int> descriptorRecvSizePerPart(this->NumPartitions);
778 std::vector<int> descriptorRecvOffsets(this->NumPartitions, 0);
779 for (int part = 0, treeId = 0; part < this->NumPartitions; part++)
780 {
781 int descriptorTotalSize = 0;
782 for (int tree = 0; tree < this->NbTreesReceivedPerPart[part]; tree++)
783 {
784 descriptorTotalSize += descriptorSizesReceivedBuffer[treeId];
785 treeId++;
786 }
787
788 // Round to the nearest higher byte size
789 int byteAlignedSize = ::GetNumberOfBytes(descriptorTotalSize) * 8;
790 descriptorRecvSizePerPart[part] = byteAlignedSize / 8;
791 if (part > 0)
792 {
793 descriptorRecvOffsets[part] =
794 descriptorRecvOffsets[part - 1] + descriptorRecvSizePerPart[part - 1];
795 }
796 }
797
798 int totalRecvSize =
799 std::accumulate(descriptorRecvSizePerPart.begin(), descriptorRecvSizePerPart.end(), 0);
800 vtkNew<vtkBitArray> descriptorRecv;
801 descriptorRecv->SetNumberOfTuples(totalRecvSize * 8);
802
803 this->MPIComm->AllToAllVVoidArray(descriptorSendBuffer->GetPointer(0),
804 this->NbDescriptorsBytesPerPart.data(), descriptorsByteOffsets.data(),
805 descriptorRecv->GetPointer(0), descriptorRecvSizePerPart.data(), descriptorRecvOffsets.data(),
806 VTK_UNSIGNED_CHAR);
807
808 for (int part = 0, currentTreeId = 0, descriptorReadOffset = 0; part < this->NumPartitions;
809 part++)
810 {
811 for (int id = 0; id < this->NbTreesReceivedPerPart[part]; id++)
812 {
813 int descriptorSize = descriptorSizesReceivedBuffer[currentTreeId];
814
815 vtkHyperTree* newTree =
816 this->OutputHTG->GetTree(this->TreeIdsReceivedBuffer[currentTreeId], true);
817 newTree->BuildFromBreadthFirstOrderDescriptor(
818 descriptorRecv, descriptorSize, descriptorReadOffset);
819
820 descriptorReadOffset += descriptorSize;
821
822 currentTreeId++;
823 }
824
825 // When changing rank we reveive descriptors from, make sure we're reading a new byte
826 descriptorReadOffset = ::GetNumberOfBytes(descriptorReadOffset) * 8;
827 }
828
829 // Add existing trees

Callers 1

ProcessTreesMethod · 0.95

Calls 12

GetNumberOfBytesFunction · 0.85
AllToAllVVoidArrayMethod · 0.80
assertFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
SetNumberOfTuplesMethod · 0.45
GetPointerMethod · 0.45
dataMethod · 0.45
GetTreeMethod · 0.45
GetLocalProcessIdMethod · 0.45
CopyStructureMethod · 0.45

Tested by

no test coverage detected