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

[FIX] fix illegal memory accesses for uneven rows where NITEMS > 1 #3469

Closed
wants to merge 1 commit into from

Conversation

levsnv
Copy link
Contributor

@levsnv levsnv commented Feb 7, 2021

the bug results in memory corruption, which sometimes overwrites useful memory and triggers a test. only compute-sanitizer catches the illegal access right now, so no point adjusting array size.

@levsnv levsnv requested a review from a team as a code owner February 7, 2021 05:08
@levsnv levsnv added 3 - Ready for Review Ready for review by team and removed libcuml labels Feb 7, 2021
@levsnv levsnv changed the title fix illegal memory accesses for uneven rows where NITEMS > 1 [FIX] fix illegal memory accesses for uneven rows where NITEMS > 1 Feb 7, 2021
@levsnv levsnv added bug Something isn't working non-breaking Non-breaking change 4 - Waiting on Author Waiting for author to respond to review and removed 3 - Ready for Review Ready for review by team labels Feb 7, 2021
@levsnv
Copy link
Contributor Author

levsnv commented Feb 8, 2021

rerun tests (spdlog compilation errors)

Copy link
Contributor

@canonizer canonizer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to other comments: do these changes affect performance?

for (int j = 0; j < NITEMS; ++j) curr[j] = 0;
do {
#pragma unroll
for (int j = 0; j < NITEMS; ++j) {
auto n = tree[curr[j]];
mask &= ~(n.is_leaf() << j);
if (!n.is_leaf()) {
if (mask & (1 << j)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (mask & (1 << j)) {
if ((mask & (1 << j)) != 0) {

@@ -172,7 +172,8 @@ struct tree_aggregator_t {
: tmp_storage(finalize_workspace) {}

__device__ __forceinline__ void accumulate(
vec<NITEMS, float> single_tree_prediction, int tree) {
vec<NITEMS, float> single_tree_prediction, int tree, int num_rows) {
for (int i = num_rows; i < NITEMS; ++i) single_tree_prediction[i] = 0.0f;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the compiler will be able to unroll this loop.

Besides, I think it would be easier to change the loop in infer_one_tree(), this will also avoid a lot of changes:

vec<NITEMS, output_type> out;  // initialized to 0
#pragma unroll 
for (int j = 0; j < NITEMS; ++j) {
  if (j < n_rows) out[j] = tree[curr[j]].template output<output_type>();
}

raft::myAtomicAdd(votes + single_tree_prediction[item] * NITEMS + item,
1);
for (int item = 0; item < NITEMS; ++item) {
if (item < num_rows) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's always enough shared memory allocated in votes for all NITEMS, independent of how many rows are actually processed. So no need for a conditional here.

@JohnZed JohnZed added 5 - DO NOT MERGE Hold off on merging; see PR for details and removed non-breaking Non-breaking change labels Feb 10, 2021
@JohnZed
Copy link
Contributor

JohnZed commented Feb 10, 2021

Should be superseded by #3480

rapids-bot bot pushed a commit that referenced this pull request Feb 10, 2021
…#3480)

This is based on #3469. All of the credit for detecting the bug, and part of the credit for fixing it goes to @levsnv.

Authors:
  - Andy Adinets (@canonizer)

Approvers:
  - @levsnv
  - John Zedlewski (@JohnZed)

URL: #3480
@JohnZed
Copy link
Contributor

JohnZed commented Feb 10, 2021

Closed by #3480

@JohnZed JohnZed closed this Feb 10, 2021
@levsnv levsnv deleted the uneven-rows-l1 branch April 18, 2021 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4 - Waiting on Author Waiting for author to respond to review 5 - DO NOT MERGE Hold off on merging; see PR for details bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants