Skip to content

Commit

Permalink
Fix out-of-bounds atomic writes in spmv fixup kernel.
Browse files Browse the repository at this point in the history
This fix was suggested in PR NVIDIA#160.
  • Loading branch information
alliepiper committed Jul 30, 2021
1 parent 2806a16 commit d5ca37a
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cub/agent/agent_spmv_orig.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -647,9 +647,24 @@ struct AgentSpmv
if (threadIdx.x == 0)
{
if (HAS_ALPHA)
{
tile_carry.value *= spmv_params.alpha;
}

tile_carry.key += tile_start_coord.x;
if (tile_carry.key >= spmv_params.num_rows)
{
// Prevent the AgentSegmentFixup kernel from updating
// out-of-bounds values.
// FIXME This creates several no-op atomicAdd(..., 0) calls.
// Ideally the fixup kernel would be aware of the keys. This
// should be possible as the fixup kernel is only used by spmv.
// This should give a perf boost by eliminating these
// unneccessary global atomic updates.
tile_carry.key = spmv_params.num_rows - 1;
tile_carry.value = ValueT{};
};

d_tile_carry_pairs[tile_idx] = tile_carry;
}
}
Expand Down

0 comments on commit d5ca37a

Please sign in to comment.