Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/527 #530

Merged
merged 3 commits into from
Aug 11, 2023
Merged

Bug/527 #530

merged 3 commits into from
Aug 11, 2023

Conversation

SSoelvsten
Copy link
Owner

@SSoelvsten SSoelvsten commented Aug 11, 2023

Hotfix to close #527 .

Essentially we remove the faulty computation that was trying to safe-guard against TPIE overflowing. This call to TPIE's memory_usage called it with such a large value that we ran into undefined behaviour (see the discussion in #527).

While I was thinking to add a safe-guard for TPIE's max memory, it just seems best to trust this piece of code and know, that we never call it with so large values that Clang introduces undefined behaviour.

Within TPIE's data structures, e.g. tpie::array<T>, there is the memory_usage(size)
function to derive the amount of memory to use for a certain number of elements. Yet
if one calls this function with size derived from memory_fits(64UINT_MAX) then you
end up with undefined behaviour. Specifically, Clang 15 has (an intermediate?) result
cast to a 32 bit unsigned integer (unsigned long) rather than a 64 bit one (unsigned
long long).

The proper solution is to change the specific piece of code, such that there is no
unexpected downcasting. The quickfix is to just change Adiar's code to just assert
whether we are outside TPIE's safe territory of 4 PiB of RAM (which is very
realistic anyway).
@SSoelvsten SSoelvsten added the 🔥 bug Something isn't working label Aug 11, 2023
@SSoelvsten SSoelvsten self-assigned this Aug 11, 2023
@codecov
Copy link

codecov bot commented Aug 11, 2023

Codecov Report

Patch coverage: 100.000% and project coverage change: +0.029% 🎉

Comparison is base (f91a0d8) 97.094% compared to head (69e33d4) 97.124%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@              Coverage Diff              @@
##              main      #530       +/-   ##
=============================================
+ Coverage   97.094%   97.124%   +0.029%     
=============================================
  Files           82        82               
  Lines         5644      5632       -12     
=============================================
- Hits          5480      5470       -10     
+ Misses         164       162        -2     
Files Changed Coverage Δ
...rc/adiar/internal/data_structures/priority_queue.h 100.000% <100.000%> (+4.000%) ⬆️
src/adiar/internal/data_structures/sorter.h 100.000% <100.000%> (+2.381%) ⬆️
src/adiar/internal/memory.h 100.000% <100.000%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This sanity check probably has unintended consequences. Let us just trust TPIE
instead and know that we never are going to call these functions with so large
values that we will see the undefined behaviour of Clang.
@github-actions
Copy link

Benchmark Report 🟢

origin/bug/527 is a regression of 0.13% (compared to origin/main).

Minimum running time (s) for 9-Queens:

origin/main origin/bug/527
0.25 0.25
Raw Data

Running times (s) for 9-Queens:

origin/main origin/bug/527
0.25 0.25
0.30 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25
0.25 0.25

@github-actions
Copy link

Benchmark Report 🟢

origin/bug/527 is a regression of 0.45% (compared to origin/main).

Minimum running time (s) for 12-Queens:

origin/main origin/bug/527
14.90 14.96
Raw Data

Running times (s) for 12-Queens:

origin/main origin/bug/527
14.98 15.14
14.99 15.02
15.15 14.99
15.03 14.96
14.97 15.03
15.11 15.02
14.90 15.02
15.04 14.98
14.94 14.98
14.90 15.01
14.93 15.05
14.96 15.02
14.99 15.01
14.99 14.97
14.98 15.05
15.10 15.11

@github-actions
Copy link

Benchmark Report 🟡

origin/bug/527 is a regression of 1.92% (compared to origin/main).

Minimum running time (s) for 14-Queens:

origin/main origin/bug/527
424.48 432.62
Raw Data

Running times (s) for 14-Queens:

origin/main origin/bug/527
578.16 437.96
431.69 432.62
432.40 436.20
424.48 433.34

@SSoelvsten SSoelvsten merged commit c4c9d75 into main Aug 11, 2023
@SSoelvsten SSoelvsten deleted the bug/527 branch August 11, 2023 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔥 bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Discrepancy between memory_fits(...) and memory_usage(...)
1 participant