Suppress warnings on MSVC Debug builds.

Also moved the config.cuh.in template into the source directory where
it'll be easier to find.
This commit is contained in:
Allison Vacanti
2021-12-21 19:34:36 -05:00
parent edf2018fd7
commit 288b1564e0
8 changed files with 66 additions and 28 deletions

View File

@@ -1,4 +1,4 @@
function(nvbench_write_config_header filepath)
function(nvbench_write_config_header in_file out_file)
if (NVBench_ENABLE_NVML)
set(NVBENCH_HAS_NVML 1)
endif()
@@ -7,5 +7,5 @@ function(nvbench_write_config_header filepath)
set(NVBENCH_HAS_CUPTI 1)
endif()
configure_file("${NVBench_SOURCE_DIR}/cmake/config.cuh.in" "${filepath}")
configure_file("${in_file}" "${out_file}")
endfunction()

View File

@@ -1,25 +0,0 @@
/*
* Copyright 2021 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 with the LLVM exception
* (the "License"); you may not use this file except in compliance with
* the License.
*
* You may obtain a copy of the License at
*
* http://llvm.org/foundation/relicensing/LICENSE.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
// Defined if NVBench has been built with NVML support.
#cmakedefine NVBENCH_HAS_NVML
// Defined if NVBench has been built with CUPTI support.
#cmakedefine NVBENCH_HAS_CUPTI

View File

@@ -60,7 +60,9 @@ file_to_string("../docs/cli_help_axis.md"
cli_help_axis_text
)
nvbench_write_config_header("${NVBench_BINARY_DIR}/nvbench/config.cuh")
nvbench_write_config_header(config.cuh.in
"${NVBench_BINARY_DIR}/nvbench/config.cuh"
)
# nvbench (nvbench::nvbench)
add_library(nvbench SHARED ${srcs})

34
nvbench/config.cuh.in Normal file
View File

@@ -0,0 +1,34 @@
/*
* Copyright 2021 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 with the LLVM exception
* (the "License"); you may not use this file except in compliance with
* the License.
*
* You may obtain a copy of the License at
*
* http://llvm.org/foundation/relicensing/LICENSE.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
// Defined if NVBench has been built with NVML support.
#cmakedefine NVBENCH_HAS_NVML
// Defined if NVBench has been built with CUPTI support.
#cmakedefine NVBENCH_HAS_CUPTI
#ifdef _MSC_VER
#define NVBENCH_MSVC_PUSH_DISABLE_WARNING(code) \
__pragma(warning(push)) __pragma(warning(disable : code))
#define NVBENCH_MSVC_POP_WARNING() __pragma(warning(pop))
#else
#define NVBENCH_MSVC_PUSH_DISABLE_WARNING(code)
#define NVBENCH_MSVC_POP_WARNING()
#endif

View File

@@ -44,8 +44,13 @@ void csv_printer::do_print_benchmark_results(const benchmark_vector &benches)
{
return v;
}
// warning C4702: unreachable code
// This is a future-proofing fallback that's currently unused.
NVBENCH_MSVC_PUSH_DISABLE_WARNING(4702)
return fmt::format("{}", v);
};
NVBENCH_MSVC_POP_WARNING()
// Prepare table:
nvbench::internal::table_builder table;

View File

@@ -39,6 +39,11 @@
namespace nvbench
{
// warning C4702: unreachable code
// Several spurious instances in this function. MSVC 2019 seems to forget that
// sometimes the constexpr branch /isn't/ taken.
NVBENCH_MSVC_PUSH_DISABLE_WARNING(4702)
template <typename ExecTags, typename KernelLauncher>
void state::exec(ExecTags tags, KernelLauncher &&kernel_launcher)
{
@@ -142,4 +147,6 @@ void state::exec(ExecTags tags, KernelLauncher &&kernel_launcher)
}
}
NVBENCH_MSVC_POP_WARNING()
} // namespace nvbench

View File

@@ -229,8 +229,13 @@ void markdown_printer::do_print_benchmark_results(
{
return v;
}
// warning C4702: unreachable code
// This is a future-proofing fallback that's currently unused.
NVBENCH_MSVC_PUSH_DISABLE_WARNING(4702)
return fmt::format("{}", v);
};
NVBENCH_MSVC_POP_WARNING()
// Start printing benchmarks
fmt::memory_buffer buffer;
@@ -368,8 +373,13 @@ std::string markdown_printer::do_format_default(const summary &data)
{
return v;
}
// warning C4702: unreachable code
// This is a future-proofing fallback that's currently unused.
NVBENCH_MSVC_PUSH_DISABLE_WARNING(4702)
return fmt::format("{}", v);
};
NVBENCH_MSVC_POP_WARNING()
return std::visit(format_visitor, data.get_value("value"));
}

View File

@@ -18,6 +18,7 @@
#include <nvbench/named_values.cuh>
#include <nvbench/config.cuh>
#include <nvbench/detail/throw.cuh>
#include <fmt/format.h>
@@ -92,11 +93,15 @@ named_values::type named_values::get_type(const std::string &name) const
{
return nvbench::named_values::type::string;
}
// warning C4702: unreachable code
// This is a future-proofing check, it'll be reachable if something breaks
NVBENCH_MSVC_PUSH_DISABLE_WARNING(4702)
NVBENCH_THROW(std::runtime_error,
"Unknown variant type for entry '{}'.",
name);
},
this->get_value(name));
NVBENCH_MSVC_POP_WARNING()
}
nvbench::int64_t named_values::get_int64(const std::string &name) const