Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Refactor GridEvenShare::total_tiles to int32.
Browse files Browse the repository at this point in the history
This value will always be representable with an int, and all usages
of it treat it as a 32-bit int. Changing the type avoids some casts
at usage sites.
  • Loading branch information
alliepiper committed Feb 10, 2021
1 parent 63e2ad4 commit e0a6736
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cub/grid/grid_even_share.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ struct GridEvenShare
{
private:

OffsetT total_tiles;
int total_tiles;
int big_shares;
OffsetT big_share_items;
OffsetT normal_share_items;
Expand Down Expand Up @@ -130,11 +130,11 @@ public:
this->block_offset = num_items_; // Initialize past-the-end
this->block_end = num_items_; // Initialize past-the-end
this->num_items = num_items_;
this->total_tiles = cub::DivideAndRoundUp(num_items_, tile_items);
this->grid_size = CUB_MIN(static_cast<int>(total_tiles), max_grid_size);
OffsetT avg_tiles_per_block = total_tiles / grid_size;
// leftover grains go to big blocks
this->big_shares = static_cast<int>(total_tiles - (avg_tiles_per_block * grid_size));
this->total_tiles = static_cast<int>(cub::DivideAndRoundUp(num_items_, tile_items));
this->grid_size = CUB_MIN(total_tiles, max_grid_size);
int avg_tiles_per_block = total_tiles / grid_size;
// leftover grains go to big blocks:
this->big_shares = total_tiles - (avg_tiles_per_block * grid_size);
this->normal_share_items = avg_tiles_per_block * tile_items;
this->normal_base_offset = big_shares * tile_items;
this->big_share_items = normal_share_items + tile_items;
Expand Down

0 comments on commit e0a6736

Please sign in to comment.