mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-30 11:41:14 +00:00
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:
@@ -1,4 +1,4 @@
|
|||||||
function(nvbench_write_config_header filepath)
|
function(nvbench_write_config_header in_file out_file)
|
||||||
if (NVBench_ENABLE_NVML)
|
if (NVBench_ENABLE_NVML)
|
||||||
set(NVBENCH_HAS_NVML 1)
|
set(NVBENCH_HAS_NVML 1)
|
||||||
endif()
|
endif()
|
||||||
@@ -7,5 +7,5 @@ function(nvbench_write_config_header filepath)
|
|||||||
set(NVBENCH_HAS_CUPTI 1)
|
set(NVBENCH_HAS_CUPTI 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
configure_file("${NVBench_SOURCE_DIR}/cmake/config.cuh.in" "${filepath}")
|
configure_file("${in_file}" "${out_file}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -60,7 +60,9 @@ file_to_string("../docs/cli_help_axis.md"
|
|||||||
cli_help_axis_text
|
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)
|
# nvbench (nvbench::nvbench)
|
||||||
add_library(nvbench SHARED ${srcs})
|
add_library(nvbench SHARED ${srcs})
|
||||||
|
|||||||
34
nvbench/config.cuh.in
Normal file
34
nvbench/config.cuh.in
Normal 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
|
||||||
@@ -44,8 +44,13 @@ void csv_printer::do_print_benchmark_results(const benchmark_vector &benches)
|
|||||||
{
|
{
|
||||||
return v;
|
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);
|
return fmt::format("{}", v);
|
||||||
};
|
};
|
||||||
|
NVBENCH_MSVC_POP_WARNING()
|
||||||
|
|
||||||
// Prepare table:
|
// Prepare table:
|
||||||
nvbench::internal::table_builder table;
|
nvbench::internal::table_builder table;
|
||||||
|
|||||||
@@ -39,6 +39,11 @@
|
|||||||
namespace nvbench
|
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>
|
template <typename ExecTags, typename KernelLauncher>
|
||||||
void state::exec(ExecTags tags, KernelLauncher &&kernel_launcher)
|
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
|
} // namespace nvbench
|
||||||
|
|||||||
@@ -229,8 +229,13 @@ void markdown_printer::do_print_benchmark_results(
|
|||||||
{
|
{
|
||||||
return v;
|
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);
|
return fmt::format("{}", v);
|
||||||
};
|
};
|
||||||
|
NVBENCH_MSVC_POP_WARNING()
|
||||||
|
|
||||||
// Start printing benchmarks
|
// Start printing benchmarks
|
||||||
fmt::memory_buffer buffer;
|
fmt::memory_buffer buffer;
|
||||||
@@ -368,8 +373,13 @@ std::string markdown_printer::do_format_default(const summary &data)
|
|||||||
{
|
{
|
||||||
return v;
|
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);
|
return fmt::format("{}", v);
|
||||||
};
|
};
|
||||||
|
NVBENCH_MSVC_POP_WARNING()
|
||||||
|
|
||||||
return std::visit(format_visitor, data.get_value("value"));
|
return std::visit(format_visitor, data.get_value("value"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <nvbench/named_values.cuh>
|
#include <nvbench/named_values.cuh>
|
||||||
|
|
||||||
|
#include <nvbench/config.cuh>
|
||||||
#include <nvbench/detail/throw.cuh>
|
#include <nvbench/detail/throw.cuh>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
#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;
|
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,
|
NVBENCH_THROW(std::runtime_error,
|
||||||
"Unknown variant type for entry '{}'.",
|
"Unknown variant type for entry '{}'.",
|
||||||
name);
|
name);
|
||||||
},
|
},
|
||||||
this->get_value(name));
|
this->get_value(name));
|
||||||
|
NVBENCH_MSVC_POP_WARNING()
|
||||||
}
|
}
|
||||||
|
|
||||||
nvbench::int64_t named_values::get_int64(const std::string &name) const
|
nvbench::int64_t named_values::get_int64(const std::string &name) const
|
||||||
|
|||||||
Reference in New Issue
Block a user