Skip to content

Commit

Permalink
Fix warnings with clang host compiler.
Browse files Browse the repository at this point in the history
  • Loading branch information
alliepiper committed Apr 5, 2024
1 parent 7063e1d commit 943f268
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 10 deletions.
7 changes: 5 additions & 2 deletions examples/axes.cu
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ NVBENCH_BENCH(single_float64_axis)
void copy_sweep_grid_shape(nvbench::state &state)
{
// Get current parameters:
const int block_size = static_cast<int>(state.get_int64("BlockSize"));
const int num_blocks = static_cast<int>(state.get_int64("NumBlocks"));
const auto block_size = static_cast<unsigned int>(state.get_int64("BlockSize"));
const auto num_blocks = static_cast<unsigned int>(state.get_int64("NumBlocks"));

// Number of int32s in 256 MiB:
const std::size_t num_values = 256 * 1024 * 1024 / sizeof(nvbench::int32_t);
Expand All @@ -77,6 +77,7 @@ void copy_sweep_grid_shape(nvbench::state &state)
num_values,
in_ptr = thrust::raw_pointer_cast(in.data()),
out_ptr = thrust::raw_pointer_cast(out.data())](nvbench::launch &launch) {
(void) num_values; // clang thinks this is unused...
nvbench::copy_kernel<<<num_blocks, block_size, 0, launch.get_stream()>>>(
in_ptr,
out_ptr,
Expand Down Expand Up @@ -110,6 +111,7 @@ void copy_type_sweep(nvbench::state &state, nvbench::type_list<ValueType>)
[num_values,
in_ptr = thrust::raw_pointer_cast(in.data()),
out_ptr = thrust::raw_pointer_cast(out.data())](nvbench::launch &launch) {
(void) num_values; // clang thinks this is unused...
nvbench::copy_kernel<<<256, 256, 0, launch.get_stream()>>>(in_ptr,
out_ptr,
num_values);
Expand Down Expand Up @@ -156,6 +158,7 @@ void copy_type_conversion_sweep(nvbench::state &state,
[num_values,
in_ptr = thrust::raw_pointer_cast(in.data()),
out_ptr = thrust::raw_pointer_cast(out.data())](nvbench::launch &launch) {
(void) num_values; // clang thinks this is unused...
nvbench::copy_kernel<<<256, 256, 0, launch.get_stream()>>>(in_ptr,
out_ptr,
num_values);
Expand Down
3 changes: 2 additions & 1 deletion examples/custom_criterion.cu
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public:

protected:
// Setup the criterion in the `do_initialize()` method:
virtual void do_initialize() override
virtual void do_initialize() override
{
m_num_samples = 0;
}
Expand Down Expand Up @@ -71,6 +71,7 @@ void throughput_bench(nvbench::state &state)
state.add_global_memory_writes<nvbench::int32_t>(num_values);

state.exec(nvbench::exec_tag::no_batch, [&input, &output, num_values](nvbench::launch &launch) {
(void) num_values; // clang thinks this is unused...
nvbench::copy_kernel<<<256, 256, 0, launch.get_stream()>>>(
thrust::raw_pointer_cast(input.data()),
thrust::raw_pointer_cast(output.data()),
Expand Down
2 changes: 2 additions & 0 deletions examples/exec_tag_timer.cu
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ void mod2_inplace(nvbench::state &state)
state.exec(nvbench::exec_tag::timer,
// Lambda now takes a `timer` argument:
[&input, &data, num_values](nvbench::launch &launch, auto &timer) {
(void) num_values; // clang thinks this is unused...

// Reset working data:
thrust::copy(thrust::device.on(launch.get_stream()),
input.cbegin(),
Expand Down
1 change: 1 addition & 0 deletions examples/stream.cu
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void stream_bench(nvbench::state &state)
state.set_cuda_stream(nvbench::make_cuda_stream_view(default_stream));

state.exec([&input, &output, num_values](nvbench::launch &) {
(void) num_values; // clang thinks this is unused...
copy(thrust::raw_pointer_cast(input.data()),
thrust::raw_pointer_cast(output.data()),
num_values);
Expand Down
1 change: 1 addition & 0 deletions examples/throughput.cu
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void throughput_bench(nvbench::state &state)
state.add_global_memory_writes<nvbench::int32_t>(num_values);

state.exec([&input, &output, num_values](nvbench::launch &launch) {
(void) num_values; // clang thinks this is unused...
nvbench::copy_kernel<<<256, 256, 0, launch.get_stream()>>>(
thrust::raw_pointer_cast(input.data()),
thrust::raw_pointer_cast(output.data()),
Expand Down
4 changes: 2 additions & 2 deletions nvbench/detail/measure_cold.cu
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ measure_cold_base::measure_cold_base(state &exec_state)
{
if (m_min_samples > 0)
{
m_cuda_times.reserve(m_min_samples);
m_cpu_times.reserve(m_min_samples);
m_cuda_times.reserve(static_cast<std::size_t>(m_min_samples));
m_cpu_times.reserve(static_cast<std::size_t>(m_min_samples));
}
}

Expand Down
2 changes: 1 addition & 1 deletion testing/axes_metadata.cu
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Axis: Other
const std::string test = fmt::to_string(buffer);
const auto diff =
std::mismatch(ref.cbegin(), ref.cend(), test.cbegin(), test.cend());
const auto idx = diff.second - test.cbegin();
const auto idx = static_cast<std::size_t>(diff.second - test.cbegin());
ASSERT_MSG(test == ref,
"Differs at character {}.\n"
"Expected:\n\"{}\"\n\n"
Expand Down
8 changes: 4 additions & 4 deletions testing/stdrel_criterion.cu
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void test_const()
nvbench::detail::stdrel_criterion criterion;

criterion.initialize(params);
for (int i = 0; i < 5; i++)
for (int i = 0; i < 5; i++)
{ // nvbench wants at least 5 to compute the standard deviation
criterion.add_measurement(42.0);
}
Expand All @@ -43,7 +43,7 @@ std::vector<double> generate(double mean, double rel_std_dev, int size)
{
std::random_device rd;
std::mt19937 gen(rd());
std::vector<nvbench::float64_t> v(size);
std::vector<nvbench::float64_t> v(static_cast<std::size_t>(size));
std::normal_distribution<nvbench::float64_t> dist(mean, mean * rel_std_dev);
std::generate(v.begin(), v.end(), [&]{ return dist(gen); });
return v;
Expand All @@ -61,7 +61,7 @@ void test_stdrel()
nvbench::detail::stdrel_criterion criterion;
criterion.initialize(params);

for (nvbench::float64_t measurement: generate(mean, max_noise / 2, size))
for (nvbench::float64_t measurement: generate(mean, max_noise / 2, size))
{
criterion.add_measurement(measurement);
}
Expand All @@ -70,7 +70,7 @@ void test_stdrel()
params.set_float64("max-noise", max_noise);
criterion.initialize(params);

for (nvbench::float64_t measurement: generate(mean, max_noise * 2, size))
for (nvbench::float64_t measurement: generate(mean, max_noise * 2, size))
{
criterion.add_measurement(measurement);
}
Expand Down

0 comments on commit 943f268

Please sign in to comment.