mirror of
https://github.com/google/benchmark.git
synced 2024-12-26 12:30:14 +08:00
Address warnings on NVIDIA nvc++ (#1573)
* Address warnings on NVIDIA nvc++ Types of warnings were being generated: 1. Deprecated warnings - solved by defining the relevant BENCHMARK_* macros for nvc++ and adding pragma suppress on a couple of .cc files 2. Setup/TearDown const vs non-const partial override - solved by adding non-const version 3. Static but not referenced - added diagnostic suppress for that file * Modified manually to comply with CD/CI * Revert partial override * Suppress warnings from tests if compiler is NVHPC --------- Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
This commit is contained in:
parent
1b507cbf10
commit
9f7dc386be
@ -243,13 +243,20 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
|
|||||||
#define BENCHMARK_INTERNAL_TOSTRING(x) BENCHMARK_INTERNAL_TOSTRING2(x)
|
#define BENCHMARK_INTERNAL_TOSTRING(x) BENCHMARK_INTERNAL_TOSTRING2(x)
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#if defined(__GNUC__) && !defined(__NVCC__) || defined(__clang__)
|
#if (defined(__GNUC__) && !defined(__NVCC__) && !defined(__NVCOMPILER)) || defined(__clang__)
|
||||||
#define BENCHMARK_BUILTIN_EXPECT(x, y) __builtin_expect(x, y)
|
#define BENCHMARK_BUILTIN_EXPECT(x, y) __builtin_expect(x, y)
|
||||||
#define BENCHMARK_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
|
#define BENCHMARK_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
|
||||||
#define BENCHMARK_DISABLE_DEPRECATED_WARNING \
|
#define BENCHMARK_DISABLE_DEPRECATED_WARNING \
|
||||||
_Pragma("GCC diagnostic push") \
|
_Pragma("GCC diagnostic push") \
|
||||||
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
|
||||||
#define BENCHMARK_RESTORE_DEPRECATED_WARNING _Pragma("GCC diagnostic pop")
|
#define BENCHMARK_RESTORE_DEPRECATED_WARNING _Pragma("GCC diagnostic pop")
|
||||||
|
#elif defined(__NVCOMPILER)
|
||||||
|
#define BENCHMARK_BUILTIN_EXPECT(x, y) __builtin_expect(x, y)
|
||||||
|
#define BENCHMARK_DEPRECATED_MSG(msg) __attribute__((deprecated(msg)))
|
||||||
|
#define BENCHMARK_DISABLE_DEPRECATED_WARNING \
|
||||||
|
_Pragma("diagnostic push") \
|
||||||
|
_Pragma("diag_suppress deprecated_entity_with_custom_message")
|
||||||
|
#define BENCHMARK_RESTORE_DEPRECATED_WARNING _Pragma("diagnostic pop")
|
||||||
#else
|
#else
|
||||||
#define BENCHMARK_BUILTIN_EXPECT(x, y) x
|
#define BENCHMARK_BUILTIN_EXPECT(x, y) x
|
||||||
#define BENCHMARK_DEPRECATED_MSG(msg)
|
#define BENCHMARK_DEPRECATED_MSG(msg)
|
||||||
|
@ -195,6 +195,10 @@ State::State(std::string name, IterationCount max_iters,
|
|||||||
#if defined(__NVCC__)
|
#if defined(__NVCC__)
|
||||||
#pragma nv_diagnostic push
|
#pragma nv_diagnostic push
|
||||||
#pragma nv_diag_suppress 1427
|
#pragma nv_diag_suppress 1427
|
||||||
|
#endif
|
||||||
|
#if defined(__NVCOMPILER)
|
||||||
|
#pragma diagnostic push
|
||||||
|
#pragma diag_suppress offset_in_non_POD_nonstandard
|
||||||
#endif
|
#endif
|
||||||
// Offset tests to ensure commonly accessed data is on the first cache line.
|
// Offset tests to ensure commonly accessed data is on the first cache line.
|
||||||
const int cache_line_size = 64;
|
const int cache_line_size = 64;
|
||||||
@ -208,6 +212,9 @@ State::State(std::string name, IterationCount max_iters,
|
|||||||
#if defined(__NVCC__)
|
#if defined(__NVCC__)
|
||||||
#pragma nv_diagnostic pop
|
#pragma nv_diagnostic pop
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__NVCOMPILER)
|
||||||
|
#pragma diagnostic pop
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void State::PauseTiming() {
|
void State::PauseTiming() {
|
||||||
|
@ -67,6 +67,9 @@ namespace benchmark {
|
|||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__NVCOMPILER)
|
||||||
|
#pragma diag_suppress declared_but_not_referenced
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
#if defined(BENCHMARK_OS_WINDOWS)
|
#if defined(BENCHMARK_OS_WINDOWS)
|
||||||
|
@ -46,6 +46,9 @@ target_link_libraries(output_test_helper PRIVATE benchmark::benchmark)
|
|||||||
macro(compile_benchmark_test name)
|
macro(compile_benchmark_test name)
|
||||||
add_executable(${name} "${name}.cc")
|
add_executable(${name} "${name}.cc")
|
||||||
target_link_libraries(${name} benchmark::benchmark_main ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(${name} benchmark::benchmark_main ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "NVHPC")
|
||||||
|
target_compile_options( ${name} PRIVATE --diag_suppress partial_override )
|
||||||
|
endif()
|
||||||
endmacro(compile_benchmark_test)
|
endmacro(compile_benchmark_test)
|
||||||
|
|
||||||
macro(compile_benchmark_test_with_main name)
|
macro(compile_benchmark_test_with_main name)
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic ignored "-Wreturn-type"
|
#pragma clang diagnostic ignored "-Wreturn-type"
|
||||||
#endif
|
#endif
|
||||||
|
BENCHMARK_DISABLE_DEPRECATED_WARNING
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic ignored "-Wreturn-type"
|
#pragma clang diagnostic ignored "-Wreturn-type"
|
||||||
#endif
|
#endif
|
||||||
|
BENCHMARK_DISABLE_DEPRECATED_WARNING
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user