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

Bug/GitHub/wconversion-1478 Check in #1623

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmake/ThrustBuildCompilerTargets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function(thrust_build_compiler_targets)
# "Oh right, this is Visual Studio."
list(APPEND cxx_compile_definitions "NOMINMAX")
else()
append_option_if_available("-Werror" cxx_compile_options)
#append_option_if_available("-Werror" cxx_compile_options)
append_option_if_available("-Wall" cxx_compile_options)
append_option_if_available("-Wextra" cxx_compile_options)
append_option_if_available("-Winit-self" cxx_compile_options)
Expand All @@ -86,6 +86,7 @@ function(thrust_build_compiler_targets)
append_option_if_available("-Wpointer-arith" cxx_compile_options)
append_option_if_available("-Wunused-local-typedef" cxx_compile_options)
append_option_if_available("-Wvla" cxx_compile_options)
append_option_if_available("-Wconversion" cxx_compile_options)

# Disable GNU extensions (flag is clang only)
append_option_if_available("-Wgnu" cxx_compile_options)
Expand Down
4 changes: 2 additions & 2 deletions examples/bucket_sort2d.cu
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ struct point_to_bucket_index : public thrust::unary_function<vec2,unsigned int>
unsigned int operator()(const vec2& v) const
{
// find the raster indices of p's bucket
unsigned int x = static_cast<unsigned int>(thrust::get<0>(v) * width);
unsigned int y = static_cast<unsigned int>(thrust::get<1>(v) * height);
unsigned int x = static_cast<unsigned int>(thrust::get<0>(v)) * width;
unsigned int y = static_cast<unsigned int>(thrust::get<1>(v)) * height;

// return the bucket's linear index
return y * width + x;
Expand Down
2 changes: 1 addition & 1 deletion examples/cuda/range_view.cu
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ __host__ __device__
void saxpy(float A, View1 X, View2 Y, View3 Z)
{
// Z = A * X + Y
const int size = X.size();
const int size = static_cast<int>(X.size());
thrust::for_each(thrust::device,
thrust::make_counting_iterator(0),
thrust::make_counting_iterator(size),
Expand Down
2 changes: 1 addition & 1 deletion examples/discrete_voronoi.cu
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ int main(void)
}

display_time(t);
std::cout <<" ( " << seeds.size() / (1e6 * t.elapsed()) << " MPixel/s ) " << std::endl;
std::cout <<" ( " << static_cast<double>(seeds.size()) / (1e6 * t.elapsed()) << " MPixel/s ) " << std::endl;

std::cout << "[Device to Host Copy]" << std::endl;
t.restart();
Expand Down
4 changes: 2 additions & 2 deletions examples/monte_carlo.cu
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ struct estimate_pi : public thrust::unary_function<unsigned int,float>
sum *= 4.0f;

// divide by N
return sum / N;
return sum / static_cast<float>(N);
}
};

Expand All @@ -70,7 +70,7 @@ int main(void)
estimate_pi(),
0.0f,
thrust::plus<float>());
estimate /= M;
estimate /= static_cast<float>(M);

std::cout << std::setprecision(3);
std::cout << "pi is approximately " << estimate << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions examples/monte_carlo_disjoint_sequences.cu
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct estimate_pi : public thrust::unary_function<unsigned int,float>
sum *= 4.0f;

// divide by N
return sum / N;
return sum / static_cast<float>(N);
}
};

Expand All @@ -76,7 +76,7 @@ int main(void)
estimate_pi(),
0.0f,
thrust::plus<float>());
estimate /= M;
estimate /= static_cast<float>(M);

std::cout << "pi is around " << estimate << std::endl;

Expand Down
2 changes: 1 addition & 1 deletion examples/sort.cu
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void initialize(thrust::device_vector<float>& v)
thrust::default_random_engine rng(123456);
thrust::uniform_int_distribution<int> dist(2, 19);
for(size_t i = 0; i < v.size(); i++)
v[i] = dist(rng) / 2.0f;
v[i] = static_cast<float>(dist(rng)) / 2.0f;
}

void initialize(thrust::device_vector< thrust::pair<int,int> >& v)
Expand Down
2 changes: 1 addition & 1 deletion testing/async/inclusive_scan/counting_iterator.cu
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct test_counting_iterator
{
void operator()(std::size_t num_values) const
{
num_values = unittest::truncate_to_max_representable<T>(num_values);
num_values = static_cast<std::size_t>(unittest::truncate_to_max_representable<T>(num_values));
testing::async::test_policy_overloads<invoker<T>>::run(num_values);
}
};
Expand Down
4 changes: 2 additions & 2 deletions testing/cuda/for_each.cu
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void TestForEachDeviceSeq(const size_t n)
thrust::host_vector<T> h_input = unittest::random_integers<T>(n);

for(size_t i = 0; i < n; i++)
h_input[i] = ((size_t) h_input[i]) % output_size;
h_input[i] = static_cast<T>(((size_t) h_input[i]) % output_size);

thrust::device_vector<T> d_input = h_input;

Expand Down Expand Up @@ -105,7 +105,7 @@ void TestForEachDeviceDevice(const size_t n)
thrust::host_vector<T> h_input = unittest::random_integers<T>(n);

for(size_t i = 0; i < n; i++)
h_input[i] = ((size_t) h_input[i]) % output_size;
h_input[i] = static_cast<T>(((size_t) h_input[i]) % output_size);

thrust::device_vector<T> d_input = h_input;

Expand Down
4 changes: 2 additions & 2 deletions testing/cuda/gather.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void TestGatherDevice(ExecutionPolicy exec, const size_t n)
thrust::host_vector<unsigned int> h_map = unittest::random_integers<unsigned int>(n);

for(size_t i = 0; i < n; i++)
h_map[i] = h_map[i] % source_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(source_size);

thrust::device_vector<unsigned int> d_map = h_map;

Expand Down Expand Up @@ -117,7 +117,7 @@ void TestGatherIfDevice(ExecutionPolicy exec, const size_t n)
thrust::host_vector<unsigned int> h_map = unittest::random_integers<unsigned int>(n);

for(size_t i = 0; i < n; i++)
h_map[i] = h_map[i] % source_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(source_size);

thrust::device_vector<unsigned int> d_map = h_map;

Expand Down
2 changes: 1 addition & 1 deletion testing/cuda/scan_by_key.cu
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void TestScanByKeyDevice(ExecutionPolicy exec)
thrust::host_vector<int> h_vals = unittest::random_integers<int>(n);
for(size_t i = 0; i < n; i++)
{
h_vals[i] = i % 10;
h_vals[i] = static_cast<int>(i % 10);
}
thrust::device_vector<int> d_vals = h_vals;

Expand Down
4 changes: 2 additions & 2 deletions testing/cuda/scatter.cu
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void TestScatterDevice(ExecutionPolicy exec)

for(size_t i = 0; i < n; i++)
{
h_map[i] = h_map[i] % output_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(output_size);
}

thrust::device_vector<unsigned int> d_map = h_map;
Expand Down Expand Up @@ -82,7 +82,7 @@ void TestScatterIfDevice(ExecutionPolicy exec)

for(size_t i = 0; i < n; i++)
{
h_map[i] = h_map[i] % output_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(output_size);
}

thrust::device_vector<unsigned int> d_map = h_map;
Expand Down
8 changes: 5 additions & 3 deletions testing/for_each.cu
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void TestForEach(const size_t n)
thrust::host_vector<T> h_input = unittest::random_integers<T>(n);

for(size_t i = 0; i < n; i++)
h_input[i] = ((size_t) h_input[i]) % output_size;
h_input[i] = static_cast<T>(((size_t) h_input[i]) % output_size);

thrust::device_vector<T> d_input = h_input;

Expand Down Expand Up @@ -232,7 +232,7 @@ void TestForEachN(const size_t n)
thrust::host_vector<T> h_input = unittest::random_integers<T>(n);

for(size_t i = 0; i < n; i++)
h_input[i] = ((size_t) h_input[i]) % output_size;
h_input[i] = static_cast<T>(((size_t) h_input[i]) % output_size);

thrust::device_vector<T> d_input = h_input;

Expand Down Expand Up @@ -280,7 +280,8 @@ void _TestForEachWithLargeTypes(void)
thrust::host_vector< FixedVector<T,N> > h_data(n);

for(size_t i = 0; i < h_data.size(); i++)
h_data[i] = FixedVector<T,N>(i);
//h_data[i] = static_cast<T>(FixedVector<T,N>(i));
h_data[i] = FixedVector<T,N>(static_cast<int>(i));

thrust::device_vector< FixedVector<T,N> > d_data = h_data;

Expand Down Expand Up @@ -321,6 +322,7 @@ void _TestForEachNWithLargeTypes(void)
thrust::host_vector< FixedVector<T,N> > h_data(n);

for(size_t i = 0; i < h_data.size(); i++)
//h_data[i] = static_cast<T>(FixedVector<T,N>(i));
h_data[i] = FixedVector<T,N>(i);

thrust::device_vector< FixedVector<T,N> > d_data = h_data;
Expand Down
8 changes: 4 additions & 4 deletions testing/gather.cu
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void TestGather(const size_t n)
thrust::host_vector<unsigned int> h_map = unittest::random_integers<unsigned int>(n);

for(size_t i = 0; i < n; i++)
h_map[i] = h_map[i] % source_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(source_size);

thrust::device_vector<unsigned int> d_map = h_map;

Expand Down Expand Up @@ -118,7 +118,7 @@ void TestGatherToDiscardIterator(const size_t n)
thrust::host_vector<unsigned int> h_map = unittest::random_integers<unsigned int>(n);

for(size_t i = 0; i < n; i++)
h_map[i] = h_map[i] % source_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(source_size);

thrust::device_vector<unsigned int> d_map = h_map;

Expand Down Expand Up @@ -244,7 +244,7 @@ void TestGatherIf(const size_t n)
thrust::host_vector<unsigned int> h_map = unittest::random_integers<unsigned int>(n);

for(size_t i = 0; i < n; i++)
h_map[i] = h_map[i] % source_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(source_size);

thrust::device_vector<unsigned int> d_map = h_map;

Expand Down Expand Up @@ -282,7 +282,7 @@ void TestGatherIfToDiscardIterator(const size_t n)
thrust::host_vector<unsigned int> h_map = unittest::random_integers<unsigned int>(n);

for(size_t i = 0; i < n; i++)
h_map[i] = h_map[i] % source_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(source_size);

thrust::device_vector<unsigned int> d_map = h_map;

Expand Down
3 changes: 2 additions & 1 deletion testing/pair_transform.cu
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ struct add_pairs
__host__ __device__
Pair1 operator()(const Pair1 &x, const Pair2 &y)
{
return thrust::make_pair(x.first + y.first, x.second + y.second);
return thrust::make_pair(x.first + static_cast<decltype(x.first)>(y.first),
x.second + static_cast<decltype(x.second)>(y.second));
} // end operator()
}; // end add_pairs

Expand Down
2 changes: 1 addition & 1 deletion testing/reduce.cu
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ template<typename T>
__host__ __device__
T operator()(T lhs, T rhs) const
{
return ((lhs % 10) + (rhs % 10)) % 10;
return static_cast<T>(((lhs % 10) + (rhs % 10)) % 10);
}
};

Expand Down
8 changes: 4 additions & 4 deletions testing/scan_by_key.cu
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void TestInclusiveScanByKey(const size_t n)

thrust::host_vector<T> h_vals = unittest::random_integers<int>(n);
for(size_t i = 0; i < n; i++)
h_vals[i] = static_cast<int>(i % 10);
h_vals[i] = static_cast<T>(i % 10);
thrust::device_vector<T> d_vals = h_vals;

thrust::host_vector<T> h_output(n);
Expand Down Expand Up @@ -406,7 +406,7 @@ void TestExclusiveScanByKey(const size_t n)
thrust::host_vector<T> h_vals = unittest::random_integers<int>(n);
for(size_t i = 0; i < n; i++)
{
h_vals[i] = static_cast<int>(i % 10);
h_vals[i] = static_cast<T>(i % 10);
}
thrust::device_vector<T> d_vals = h_vals;

Expand Down Expand Up @@ -443,7 +443,7 @@ void TestInclusiveScanByKeyInPlace(const size_t n)
thrust::host_vector<T> h_vals = unittest::random_integers<int>(n);
for(size_t i = 0; i < n; i++)
{
h_vals[i] = static_cast<int>(i % 10);
h_vals[i] = static_cast<T>(i % 10);
}
thrust::device_vector<T> d_vals = h_vals;

Expand Down Expand Up @@ -477,7 +477,7 @@ void TestExclusiveScanByKeyInPlace(const size_t n)
thrust::host_vector<T> h_vals = unittest::random_integers<int>(n);
for(size_t i = 0; i < n; i++)
{
h_vals[i] = static_cast<int>(i % 10);
h_vals[i] = static_cast<T>(i % 10);
}
thrust::device_vector<T> d_vals = h_vals;

Expand Down
8 changes: 4 additions & 4 deletions testing/scatter.cu
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void TestScatter(const size_t n)
thrust::host_vector<unsigned int> h_map = unittest::random_integers<unsigned int>(n);

for(size_t i = 0; i < n; i++)
h_map[i] = h_map[i] % output_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(output_size);

thrust::device_vector<unsigned int> d_map = h_map;

Expand All @@ -124,7 +124,7 @@ void TestScatterToDiscardIterator(const size_t n)
thrust::host_vector<unsigned int> h_map = unittest::random_integers<unsigned int>(n);

for(size_t i = 0; i < n; i++)
h_map[i] = h_map[i] % output_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(output_size);

thrust::device_vector<unsigned int> d_map = h_map;

Expand Down Expand Up @@ -241,7 +241,7 @@ void TestScatterIf(const size_t n)
thrust::host_vector<unsigned int> h_map = unittest::random_integers<unsigned int>(n);

for(size_t i = 0; i < n; i++)
h_map[i] = h_map[i] % output_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(output_size);

thrust::device_vector<unsigned int> d_map = h_map;

Expand All @@ -267,7 +267,7 @@ void TestScatterIfToDiscardIterator(const size_t n)
thrust::host_vector<unsigned int> h_map = unittest::random_integers<unsigned int>(n);

for(size_t i = 0; i < n; i++)
h_map[i] = h_map[i] % output_size;
h_map[i] = h_map[i] % static_cast<unsigned int>(output_size);

thrust::device_vector<unsigned int> d_map = h_map;

Expand Down
2 changes: 1 addition & 1 deletion testing/set_difference_by_key.cu
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void TestSetDifferenceByKeyMultiset(const size_t n)
{
int temp = static_cast<int>(*i);
temp %= 13;
*i = temp;
*i = static_cast<T>(temp);
}

thrust::host_vector<T> h_a_key(vec.begin(), vec.begin() + n);
Expand Down
2 changes: 1 addition & 1 deletion testing/set_intersection_by_key.cu
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void TestSetIntersectionByKeyMultiset(const size_t n)
{
int temp = static_cast<int>(*i);
temp %= 13;
*i = temp;
*i = static_cast<T>(temp);
}

thrust::host_vector<T> h_a_key(vec.begin(), vec.begin() + n);
Expand Down
2 changes: 1 addition & 1 deletion testing/set_symmetric_difference.cu
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void TestSetSymmetricDifferenceMultiset(const size_t n)
{
int temp = static_cast<int>(*i);
temp %= 13;
*i = temp;
*i = static_cast<T>(temp);
}

thrust::host_vector<T> h_a(vec.begin(), vec.begin() + n);
Expand Down
2 changes: 1 addition & 1 deletion testing/set_symmetric_difference_by_key.cu
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void TestSetSymmetricDifferenceByKeyMultiset(const size_t n)
{
int temp = static_cast<int>(*i);
temp %= 13;
*i = temp;
*i = static_cast<T>(temp);
}

thrust::host_vector<T> h_a_key(vec.begin(), vec.begin() + n);
Expand Down
2 changes: 1 addition & 1 deletion testing/set_union_by_key.cu
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void TestSetUnionByKeyMultiset(const size_t n)
{
int temp = static_cast<int>(*i);
temp %= 13;
*i = temp;
*i = static_cast<T>(temp);
}

thrust::host_vector<T> h_a_key(vec.begin(), vec.begin() + n);
Expand Down
Loading