12#ifndef vtkBlockDistribution_h
13#define vtkBlockDistribution_h
15#include "vtkABINamespace.h"
17VTK_ABI_NAMESPACE_BEGIN
85 return (this->NumElements / this->NumProcessors) +
86 (rank < this->NumElements % this->NumProcessors ? 1 : 0);
93 vtkIdType smallBlockSize = this->NumElements / this->NumProcessors;
94 vtkIdType cutoffProcessor = this->NumElements % this->NumProcessors;
95 vtkIdType cutoffIndex = cutoffProcessor * (smallBlockSize + 1);
97 if (globalIndex < cutoffIndex)
99 return globalIndex / (smallBlockSize + 1);
103 return cutoffProcessor + (globalIndex - cutoffIndex) / smallBlockSize;
119 vtkIdType estimate = rank * (this->NumElements / this->NumProcessors + 1);
120 vtkIdType cutoffProcessor = this->NumElements % this->NumProcessors;
121 if (rank < cutoffProcessor)
127 return estimate - (rank - cutoffProcessor);
A helper class that manages a block distribution of N elements of data.
vtkIdType GetGlobalIndex(vtkIdType localIndex, vtkIdType rank)
Retrieve the global index associated with the given local index on the processor with the given rank.
vtkIdType GetNumElements()
Retrieves the number of elements for which this block distribution was built.
vtkIdType GetLocalIndexOfElement(vtkIdType globalIndex)
Retrieve the local index (offset) on the processor determined by GetProcessorOfElement that refers to...
vtkIdType GetProcessorOfElement(vtkIdType globalIndex)
Retrieve the process number in [0, GetNumProcessors()) where the element with the given global index ...
vtkIdType GetNumProcessors()
Retrieves the number of processors for which this block distribution was built.
vtkIdType GetFirstGlobalIndexOnProcessor(vtkIdType rank)
Retrieve the first global index stored on the processor with the given rank.
vtkBlockDistribution(vtkIdType N, vtkIdType P)
Create a block distribution with N elements on P processors.
vtkIdType GetBlockSize(vtkIdType rank)
Get the block size for the processor with the given rank.