27 #ifndef vtkBlockDistribution_h
28 #define vtkBlockDistribution_h
72 : NumElements(N), NumProcessors(P)
80 return (this->NumElements / this->NumProcessors)
81 + (rank < this->NumElements % this->NumProcessors? 1 : 0);
89 vtkIdType smallBlockSize = this->NumElements / this->NumProcessors;
90 vtkIdType cutoffProcessor = this->NumElements % this->NumProcessors;
91 vtkIdType cutoffIndex = cutoffProcessor * (smallBlockSize + 1);
93 if (globalIndex < cutoffIndex)
95 return globalIndex / (smallBlockSize + 1);
99 return cutoffProcessor + (globalIndex - cutoffIndex) / smallBlockSize;
117 vtkIdType estimate = rank * (this->NumElements / this->NumProcessors + 1);
118 vtkIdType cutoffProcessor = this->NumElements % this->NumProcessors;
119 if (rank < cutoffProcessor)
125 return estimate - (rank - cutoffProcessor);
vtkIdType GetNumProcessors()
A helper class that manages a block distribution of N elements of data.
vtkIdType GetFirstGlobalIndexOnProcessor(vtkIdType rank)
vtkBlockDistribution(vtkIdType N, vtkIdType P)
vtkIdType GetLocalIndexOfElement(vtkIdType globalIndex)
vtkIdType GetBlockSize(vtkIdType rank)
vtkIdType GetProcessorOfElement(vtkIdType globalIndex)
vtkIdType GetGlobalIndex(vtkIdType localIndex, vtkIdType rank)
vtkIdType GetNumElements()