Skip to content

Commit bd950a0

Browse files
ndellingwoodvqd8a
andauthored
[4.7.1] Update the bisect break condition in RCB (#2766) (#2768)
* Update the bisect break condition in RCB (#2766) * Update break condition in bisect Signed-off-by: Vinh Dang <vqdang@sandia.gov> * Remove unused file Signed-off-by: Vinh Dang <vqdang@sandia.gov> * Use FOR loop as suggested Signed-off-by: Vinh Dang <vqdang@sandia.gov> --------- Signed-off-by: Vinh Dang <vqdang@sandia.gov> * update changelog - pr 2766 Signed-off-by: Nathan Ellingwood <ndellin@sandia.gov> --------- Signed-off-by: Vinh Dang <vqdang@sandia.gov> Signed-off-by: Nathan Ellingwood <ndellin@sandia.gov> Co-authored-by: Vinh Dang <vqdang@sandia.gov>
1 parent 7b73c12 commit bd950a0

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
### New Features and Enhancements
77
- First implementation of recursive coordinate bisection (RCB) in graph [\#2708](https://github.com/kokkos/kokkos-kernels/pull/2708)
8+
- Update the bisect break condition in RCB [\#2766](https://github.com/kokkos/kokkos-kernels/pull/2766)
89
- Add setNumRows, setNumCols to sparse matrix structures [\#2700](https://github.com/kokkos/kokkos-kernels/pull/2700)
910
- Add optional argument to configure sorting algorithm used in KokkosSparse:sort_crs_matrix [\#2714](https://github.com/kokkos/kokkos-kernels/pull/2714)
1011

graph/impl/KokkosGraph_RCB_impl.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,12 @@ inline void bisect(const coors_view_type &coors_1d, const value_type &init_min_v
132132
value_type min_val = init_min_val;
133133
value_type max_val = init_max_val;
134134
value_type p1_weight, p2_weight;
135-
value_type prev_weight_ratio = 0;
136-
value_type curr_weight_ratio;
137-
while (1) {
135+
value_type weight_ratio;
136+
const int max_bisection_steps = 11;
137+
// For now, limit the number of times finding mid point to ten to make RCB work with Sierra T/F coordinates
138+
// TODO: - allow users to pass max_bisection_steps as an input parameter
139+
// - or switch to use the median, which is probably a better solution
140+
for (int bisection_step = 0; bisection_step < max_bisection_steps; ++bisection_step) {
138141
value_type mid_point = (max_val + min_val) / 2.0;
139142
p1_size = 0;
140143
p2_size = 0;
@@ -151,11 +154,9 @@ inline void bisect(const coors_view_type &coors_1d, const value_type &init_min_v
151154
p1_weight = static_cast<value_type>(p1_size);
152155
p2_weight = static_cast<value_type>(p2_size);
153156

154-
curr_weight_ratio = std::max(p1_weight, p2_weight) / std::min(p1_weight, p2_weight);
157+
weight_ratio = std::max(p1_weight, p2_weight) / std::min(p1_weight, p2_weight);
155158

156-
if (curr_weight_ratio < 1.1)
157-
break;
158-
else if (curr_weight_ratio == prev_weight_ratio)
159+
if (weight_ratio < 1.1)
159160
break;
160161
else {
161162
// Update min_val or max_val to calculate a new mid_point
@@ -164,7 +165,6 @@ inline void bisect(const coors_view_type &coors_1d, const value_type &init_min_v
164165
min_val = mid_point;
165166
else
166167
max_val = mid_point;
167-
prev_weight_ratio = curr_weight_ratio;
168168
}
169169
}
170170
}

0 commit comments

Comments
 (0)