Skip to content

Commit 0bc6866

Browse files
committed
c/nondominated_kung.h (compact_rows): Do not use restrict. Only compact if r_size has decreased.
1 parent d9eafed commit 0bc6866

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

c/nondominated_kung.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,13 +330,14 @@ debug_half_size_with_duplicates(const double ** restrict rows, size_t size)
330330
#define half_size_with_duplicates debug_half_size_with_duplicates
331331
#endif
332332

333+
// The pointers cannot be restrict because the memory regions overlap.
333334
static inline size_t
334-
compact_rows(const double ** restrict r, size_t r_size,
335-
const double ** restrict s, size_t s_size, size_t size)
335+
compact_rows(const double ** r, size_t r_size,
336+
const double ** s, size_t s_size, size_t old_r_size)
336337
{
337338
size_t new_size = r_size + s_size;
338-
ASSUME(new_size <= size);
339-
if (new_size < size) { // Compact nondominated rows
339+
ASSUME(r_size <= old_r_size);
340+
if (r_size < old_r_size) { // Compact nondominated rows
340341
for (size_t k = 0; k < s_size; k++)
341342
r[r_size + k] = s[k];
342343
}
@@ -535,6 +536,8 @@ kung_merge_nobase(const double ** restrict r, size_t r_size,
535536
assert(check_nondom(r2, r2_size));
536537
assert(check_nondom(s2, s2_size));
537538
}
539+
540+
size_t old_s1_size = s1_size;
538541
if (r1_size > 0) {
539542
DEBUG2_PRINT("Solve sub-problem (R1, S1)\n");
540543
// Solve sub-problem (R1, S1)
@@ -546,7 +549,7 @@ kung_merge_nobase(const double ** restrict r, size_t r_size,
546549
s2_size = kung_merge_rec_dim(r, r1_size, s2, s2_size, dim);
547550
}
548551
}
549-
size_t new_size = compact_rows(s, s1_size, s2, s2_size, s_size);
552+
size_t new_size = compact_rows(s, s1_size, s2, s2_size, old_s1_size);
550553
DEBUG2_PRINT("kung_merge: return S = %zu\n", new_size);
551554
DEBUG2(print_rows(s, new_size, dim));
552555
assert(check_nondom(s, new_size));
@@ -746,6 +749,7 @@ maxima_rec(const double ** restrict rows, size_t size, dimension_t dim,
746749
const double ** s = rows + r_size;
747750
DEBUG2(printf_rows("maxima_rec: S", s, s_size, dim, "s_size"));
748751

752+
size_t old_r_size = r_size;
749753
if (r_size > 1)
750754
r_size = (r_size <= KUNG_SMALL_THRESHOLD)
751755
? maxima_brute_force_filter_dom(rows, r_size, dim, keep_weakly)
@@ -759,7 +763,7 @@ maxima_rec(const double ** restrict rows, size_t size, dimension_t dim,
759763
DEBUG2(printf_rows("maxima_rec2: S", s, s_size, dim, "s_size"));
760764

761765
s_size = kung_merge_rec_dim(rows, r_size, s, s_size, dim);
762-
size_t new_size = compact_rows(rows, r_size, s, s_size, size);
766+
size_t new_size = compact_rows(rows, r_size, s, s_size, old_r_size);
763767
DEBUG2_PRINT("maxima_rec2: r U s = %zu\n", new_size);
764768
DEBUG2(print_rows(rows, new_size, dim));
765769
assert(check_nondom(rows, new_size));

0 commit comments

Comments
 (0)