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

Commit

Permalink
Fix numeric conversion warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
alliepiper committed Jan 22, 2021
1 parent dd5b0f1 commit 2658013
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cub/device/dispatch/dispatch_histogram.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ struct DipatchHistogram
for (int channel = 0; channel < NUM_ACTIVE_CHANNELS; ++channel)
{
int bins = num_output_levels[channel] - 1;
LevelT scale = (upper_level[channel] - lower_level[channel]) / bins;
LevelT scale = static_cast<LevelT>((upper_level[channel] - lower_level[channel]) / bins);

privatized_decode_op[channel].Init(num_output_levels[channel], upper_level[channel], lower_level[channel], scale);

Expand Down
2 changes: 1 addition & 1 deletion cub/device/dispatch/dispatch_scan.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ struct DispatchScan:

// Number of input tiles
int tile_size = Policy::BLOCK_THREADS * Policy::ITEMS_PER_THREAD;
int num_tiles = (num_items + tile_size - 1) / tile_size;
int num_tiles = static_cast<int>((num_items + tile_size - 1) / tile_size);

// Specify temporary storage allocation requirements
size_t allocation_sizes[1];
Expand Down
5 changes: 3 additions & 2 deletions cub/grid/grid_even_share.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ public:
this->block_end = num_items_; // Initialize past-the-end
this->num_items = num_items_;
this->total_tiles = (num_items_ + tile_items - 1) / tile_items;
this->grid_size = CUB_MIN(total_tiles, max_grid_size);
this->grid_size = CUB_MIN(static_cast<int>(total_tiles), max_grid_size);
OffsetT avg_tiles_per_block = total_tiles / grid_size;
this->big_shares = total_tiles - (avg_tiles_per_block * grid_size); // leftover grains go to big blocks
// leftover grains go to big blocks
this->big_shares = static_cast<int>(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
2 changes: 1 addition & 1 deletion test/half.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct half_t
{ /* normal */
ir |= ia >> (24 - 11);
ia = ia << (32 - (24 - 11));
ir = ir + ((14 + shift) << 10);
ir = static_cast<uint16_t>(ir + ((14 + shift) << 10));
}
/* IEEE-754 round to nearest of even */
if ((ia > 0x80000000) || ((ia == 0x80000000) && (ir & 1)))
Expand Down
24 changes: 12 additions & 12 deletions test/test_device_histogram.cu
Original file line number Diff line number Diff line change
Expand Up @@ -402,15 +402,15 @@ struct ScaleTransform<float>
float scale; // Bin scaling factor

void Init(
int num_levels, // Number of levels in array
float max, // Max sample level (exclusive)
float min, // Min sample level (inclusive)
float scale) // Bin scaling factor
int _num_levels, // Number of levels in array
float _max, // Max sample level (exclusive)
float _min, // Min sample level (inclusive)
float _scale) // Bin scaling factor
{
this->num_levels = num_levels;
this->max = max;
this->min = min;
this->scale = 1.0f / scale;
this->num_levels = _num_levels;
this->max = _max;
this->min = _min;
this->scale = 1.0f / _scale;
}

// Functor for converting samples to bin-ids (num_levels is returned if sample is out of range)
Expand Down Expand Up @@ -603,7 +603,7 @@ void TestEven(
num_levels[channel],
upper_level[channel],
lower_level[channel],
((upper_level[channel] - lower_level[channel]) / bins));
static_cast<LevelT>(((upper_level[channel] - lower_level[channel]) / bins)));
}

InitializeBins<NUM_CHANNELS, NUM_ACTIVE_CHANNELS>(
Expand Down Expand Up @@ -1025,14 +1025,14 @@ void TestEven(

// Find smallest level increment
int max_bins = max_num_levels - 1;
LevelT min_level_increment = max_level / max_bins;
LevelT min_level_increment = static_cast<LevelT>(max_level / max_bins);

// Set upper and lower levels for each channel
for (int channel = 0; channel < NUM_ACTIVE_CHANNELS; ++channel)
{
int num_bins = num_levels[channel] - 1;
lower_level[channel] = (max_level - (num_bins * min_level_increment)) / 2;
upper_level[channel] = (max_level + (num_bins * min_level_increment)) / 2;
lower_level[channel] = static_cast<LevelT>((max_level - (num_bins * min_level_increment)) / 2);
upper_level[channel] = static_cast<LevelT>((max_level + (num_bins * min_level_increment)) / 2);
}

// Test pointer-based samples
Expand Down
16 changes: 8 additions & 8 deletions test/test_iterator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -243,14 +243,14 @@ void TestCounting(T base)

// Initialize reference data
T h_reference[8];
h_reference[0] = base + 0; // Value at offset 0
h_reference[1] = base + 100; // Value at offset 100
h_reference[2] = base + 1000; // Value at offset 1000
h_reference[3] = base + 10000; // Value at offset 10000
h_reference[4] = base + 1; // Value at offset 1
h_reference[5] = base + 21; // Value at offset 21
h_reference[6] = base + 11; // Value at offset 11
h_reference[7] = base + 0; // Value at offset 0;
h_reference[0] = static_cast<T>(base + 0); // Value at offset 0
h_reference[1] = static_cast<T>(base + 100); // Value at offset 100
h_reference[2] = static_cast<T>(base + 1000); // Value at offset 1000
h_reference[3] = static_cast<T>(base + 10000); // Value at offset 10000
h_reference[4] = static_cast<T>(base + 1); // Value at offset 1
h_reference[5] = static_cast<T>(base + 21); // Value at offset 21
h_reference[6] = static_cast<T>(base + 11); // Value at offset 11
h_reference[7] = static_cast<T>(base + 0); // Value at offset 0;

CountingInputIterator<T> d_itr(base);
Test(d_itr, h_reference);
Expand Down
21 changes: 13 additions & 8 deletions test/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -1063,10 +1063,15 @@ CUB_VEC_OVERLOAD(double, double)
*/
struct TestFoo
{
long long x;
int y;
short z;
char w;
using x_t = long long;
using y_t = int;
using z_t = short;
using w_t = char;

x_t x;
y_t y;
z_t z;
w_t w;

// Factory
static __host__ __device__ __forceinline__ TestFoo MakeTestFoo(long long x, int y, short z, char w)
Expand All @@ -1078,10 +1083,10 @@ struct TestFoo
// Assignment from int operator
__host__ __device__ __forceinline__ TestFoo& operator =(int b)
{
x = b;
y = b;
z = b;
w = b;
x = static_cast<x_t>(b);
y = static_cast<y_t>(b);
z = static_cast<z_t>(b);
w = static_cast<w_t>(b);
return *this;
}

Expand Down

0 comments on commit 2658013

Please sign in to comment.