28 #ifndef vtkBlockDistribution_h
29 #define vtkBlockDistribution_h
89 : NumElements(N), NumProcessors(P)
97 return (this->NumElements / this->NumProcessors)
98 + (rank < this->NumElements % this->NumProcessors? 1 : 0);
106 vtkIdType smallBlockSize = this->NumElements / this->NumProcessors;
107 vtkIdType cutoffProcessor = this->NumElements % this->NumProcessors;
108 vtkIdType cutoffIndex = cutoffProcessor * (smallBlockSize + 1);
110 if (globalIndex < cutoffIndex)
112 return globalIndex / (smallBlockSize + 1);
116 return cutoffProcessor + (globalIndex - cutoffIndex) / smallBlockSize;
134 vtkIdType estimate = rank * (this->NumElements / this->NumProcessors + 1);
135 vtkIdType cutoffProcessor = this->NumElements % this->NumProcessors;
136 if (rank < cutoffProcessor)
142 return estimate - (rank - cutoffProcessor);
vtkIdType GetNumProcessors()
Retrieves the number of processors for which this block distribution was built.
A helper class that manages a block distribution of N elements of data.
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 GetLocalIndexOfElement(vtkIdType globalIndex)
Retrieve the local index (offset) on the processor determined by GetProcessorOfElement that refers to...
vtkIdType GetBlockSize(vtkIdType rank)
Get the block size for the processor with the given rank.
vtkIdType GetProcessorOfElement(vtkIdType globalIndex)
Retrieve the process number in [0, GetNumProcessors()) where the element with the given global index ...
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.