@@ -59,7 +59,6 @@ template <class ScalarType>
5959CGraphPartitioning<ScalarType>::~CGraphPartitioning () {}
6060
6161template <class ScalarType >
62-
6362class CLevelScheduling final : public CGraphPartitioning<ScalarType> {
6463 private:
6564 ScalarType nPointDomain;
@@ -81,15 +80,13 @@ class CLevelScheduling final : public CGraphPartitioning<ScalarType> {
8180 maxLevelWidth = 0ul ;
8281 }
8382
84- CLevelScheduling () = delete ; // Removing default constructor
85-
8683 /* !
8784 * \brief Divides the levels into groups of chains depending on the preset GPU block and warp size.
8885 * \param[in] levelOffsets - Represents the vector array containing the ordered list of starting rows of each level.
8986 * \param[in] chainPtr - Represents the vector array containing the ordered list of starting levels of each chain.
9087 * \param[in] rowsPerBlock - Represents the maximum number of rows that can be accomodated per CUDA block.
9188 */
92- void CalculateChain (vector<ScalarType> levelOffsets, vector<ScalarType>& chainPtr, unsigned short rowsPerBlock) {
89+ void CalculateChain (const vector<ScalarType>& levelOffsets, vector<ScalarType>& chainPtr, unsigned short rowsPerBlock) {
9390 ScalarType levelWidth = 0 ;
9491
9592 /* This is not a magic number. We are simply initializing
@@ -115,34 +112,33 @@ class CLevelScheduling final : public CGraphPartitioning<ScalarType> {
115112 /* !
116113 * \brief Reorders the points according to the levels
117114 * \param[in] pointList - Ordered array that contains the list of all mesh points.
118- * \param[in] inversePointList - Array utilized to access the index of each point in pointList.
119115 * \param[in] levelOffsets - Vector array containing the ordered list of starting rows of each level.
116+ * \param[out] reorderedPointList - Reordered list of points after applying level scheduling.
120117 */
121- void Reorder (vector<ScalarType>& pointList, vector<ScalarType>& inversePointList, vector<ScalarType> levelOffsets) {
118+ void Reorder (const vector<ScalarType>& pointList, const vector<ScalarType>& levelOffsets,
119+ vector<ScalarType>& reorderedPointList) {
120+ auto levelOffsetsCursor = levelOffsets;
121+
122122 for (auto localPoint = 0ul ; localPoint < nPointDomain; ++localPoint) {
123123 const auto globalPoint = pointList[localPoint];
124- inversePointList[levelOffsets [levels[localPoint]]++] = globalPoint;
124+ reorderedPointList[levelOffsetsCursor [levels[localPoint]]++] = globalPoint;
125125 }
126-
127- pointList = std::move (inversePointList);
128126 }
129127
130128 /* !
131129 * \brief Reorders the points according to the levels
132- * \param[in] pointList - Ordered array that contains the list of all mesh points.
130+ * \param[in,out ] pointList - Ordered array that contains the list of all mesh points.
133131 * \param[in] levelOffsets - Vector array containing the ordered list of starting rows of each level.
134132 * \param[in] chainPtr - Represents the vector array containing the ordered list of starting levels of each chain.
135133 * \param[in] rowsPerBlock - Represents the maximum number of rows that can be accomodated per CUDA block.
136134 */
137135 void Partition (vector<ScalarType>& pointList, vector<ScalarType>& levelOffsets, vector<ScalarType>& chainPtr,
138136 unsigned short rowsPerBlock) override {
139- vector<ScalarType> inversePointList;
140- inversePointList.reserve (nPointDomain);
141- levels.reserve (nPointDomain);
137+ vector<ScalarType> inversePointList (nPointDomain);
138+ levels.resize (nPointDomain, 0ul );
142139
143140 for (auto point = 0ul ; point < nPointDomain; point++) {
144141 inversePointList[pointList[point]] = point;
145- levels[point] = 0 ;
146142 }
147143
148144 // Local Point - Ordering of the points post the RCM ordering
@@ -175,7 +171,8 @@ class CLevelScheduling final : public CGraphPartitioning<ScalarType> {
175171 levelOffsets[iLevel] += levelOffsets[iLevel - 1 ];
176172 }
177173
178- Reorder (pointList, inversePointList, levelOffsets);
174+ Reorder (pointList, levelOffsets, inversePointList);
175+ pointList = std::move (inversePointList);
179176
180177 CalculateChain (levelOffsets, chainPtr, rowsPerBlock);
181178 }
0 commit comments