-
Notifications
You must be signed in to change notification settings - Fork 150
Fixes for stricter compilers #1703
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
base: main
Are you sure you want to change the base?
Conversation
Added [[fallthrough]] attribute to switch cases in team_sum function for clarity and correctness. Initialized seed_index to 0 to avoid potential uninitialized variable usage and remove an unused variable
|
Thank you for your contribution. Much appreciated. Looking at your other PRs, would you be opposed to combining them into this PR (#1703)?
We can test these together. We can set the title for this PR to say |
| for (uint32_t j = 0; j < num_distilation; j++) { | ||
| // Select a node randomly and compute the distance to it | ||
| IndexT seed_index; | ||
| IndexT seed_index = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not completely convinced that there is a problem here. seed_index's uninitialized value isn't read.
But this does indicate that this can be tightened up.
| IndexT seed_index; | ||
| IndexT seed_index = 0; | ||
| if (valid_i) { | ||
| // uint32_t gid = i + (num_pickup * (j + (num_distilation * block_id))); | ||
| uint32_t gid = block_id + (num_blocks * (i + (num_pickup * j))); | ||
| if (seed_ptr && (gid < num_seeds)) { | ||
| seed_index = seed_ptr[gid]; | ||
| } else { | ||
| seed_index = device::xorshift64(gid ^ rand_xor_mask) % dataset_desc.size; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An argument can be made to use an IIFE for this variable. That would also allow it to be const:
IndexT const seed_index = [&] {
if (valid_i) {
// uint32_t gid = i + (num_pickup * (j + (num_distilation * block_id)));
uint32_t gid = block_id + (num_blocks * (i + (num_pickup * j)));
if (seed_ptr && (gid < num_seeds)) {
return seed_ptr[gid];
} else {
return device::xorshift64(gid ^ rand_xor_mask) % dataset_desc.size;
}
}
}();| case 3: x += raft::shfl_xor(x, 4); | ||
| case 2: x += raft::shfl_xor(x, 2); | ||
| case 1: x += raft::shfl_xor(x, 1); | ||
| case 5: x += raft::shfl_xor(x, 16); [[fallthrough]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
/ok to test 9827f5a |
Updated copyright date.
Added [[fallthrough]] attribute to switch cases in team_sum function for clarity and correctness. Initialized seed_index to 0 to avoid potential uninitialized variable usage and remove an unused variable