mirror of
https://github.com/google/benchmark.git
synced 2024-12-27 13:00:36 +08:00
Fix build with Intel compiler (#631)
* Set -Wno-deprecated-declarations for Intel Intel compiler silently ignores -Wno-deprecated-declarations so warning no. 1786 must be explicitly suppressed. * Make std::int64_t → double casts explicit While std::int64_t → double is a perfectly conformant implicit conversion, Intel compiler warns about it. Make them explicit via static_cast<double>. * Make std::int64_t → int casts explicit Intel compiler warns about emplacing an std::int64_t into an int container. Just make the conversion explicit via static_cast<int>. * Cleanup Intel -Wno-deprecated-declarations workaround logic
This commit is contained in:
parent
5946795e82
commit
0c21bc369a
@ -142,6 +142,12 @@ else()
|
|||||||
# Disable warnings regarding deprecated parts of the library while building
|
# Disable warnings regarding deprecated parts of the library while building
|
||||||
# and testing those parts of the library.
|
# and testing those parts of the library.
|
||||||
add_cxx_compiler_flag(-Wno-deprecated-declarations)
|
add_cxx_compiler_flag(-Wno-deprecated-declarations)
|
||||||
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||||
|
# Intel silently ignores '-Wno-deprecated-declarations',
|
||||||
|
# warning no. 1786 must be explicitly disabled.
|
||||||
|
# See #631 for rationale.
|
||||||
|
add_cxx_compiler_flag(-wd1786)
|
||||||
|
endif()
|
||||||
# Disable deprecation warnings for release builds (when -Werror is enabled).
|
# Disable deprecation warnings for release builds (when -Werror is enabled).
|
||||||
add_cxx_compiler_flag(-Wno-deprecated RELEASE)
|
add_cxx_compiler_flag(-Wno-deprecated RELEASE)
|
||||||
add_cxx_compiler_flag(-Wno-deprecated RELWITHDEBINFO)
|
add_cxx_compiler_flag(-Wno-deprecated RELWITHDEBINFO)
|
||||||
|
@ -36,10 +36,10 @@ BigOFunc* FittingCurve(BigO complexity) {
|
|||||||
return [](int64_t n) -> double { return std::pow(n, 3); };
|
return [](int64_t n) -> double { return std::pow(n, 3); };
|
||||||
case oLogN:
|
case oLogN:
|
||||||
/* Note: can't use log2 because Android's GNU STL lacks it */
|
/* Note: can't use log2 because Android's GNU STL lacks it */
|
||||||
return [](int64_t n) { return kLog2E * log(n); };
|
return [](int64_t n) { return kLog2E * log(static_cast<double>(n)); };
|
||||||
case oNLogN:
|
case oNLogN:
|
||||||
/* Note: can't use log2 because Android's GNU STL lacks it */
|
/* Note: can't use log2 because Android's GNU STL lacks it */
|
||||||
return [](int64_t n) { return kLog2E * n * log(n); };
|
return [](int64_t n) { return kLog2E * n * log(static_cast<double>(n)); };
|
||||||
case o1:
|
case o1:
|
||||||
default:
|
default:
|
||||||
return [](int64_t) { return 1.0; };
|
return [](int64_t) { return 1.0; };
|
||||||
|
@ -85,7 +85,7 @@ std::vector<int> ConstructRandomVector(int64_t size) {
|
|||||||
std::vector<int> v;
|
std::vector<int> v;
|
||||||
v.reserve(static_cast<int>(size));
|
v.reserve(static_cast<int>(size));
|
||||||
for (int i = 0; i < size; ++i) {
|
for (int i = 0; i < size; ++i) {
|
||||||
v.push_back(std::rand() % size);
|
v.push_back(static_cast<int>(std::rand() % size));
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ BENCHMARK(BM_Complexity_O_N)
|
|||||||
BENCHMARK(BM_Complexity_O_N)
|
BENCHMARK(BM_Complexity_O_N)
|
||||||
->RangeMultiplier(2)
|
->RangeMultiplier(2)
|
||||||
->Range(1 << 10, 1 << 16)
|
->Range(1 << 10, 1 << 16)
|
||||||
->Complexity([](int64_t n) -> double { return n; });
|
->Complexity([](int64_t n) -> double { return static_cast<double>(n); });
|
||||||
BENCHMARK(BM_Complexity_O_N)
|
BENCHMARK(BM_Complexity_O_N)
|
||||||
->RangeMultiplier(2)
|
->RangeMultiplier(2)
|
||||||
->Range(1 << 10, 1 << 16)
|
->Range(1 << 10, 1 << 16)
|
||||||
@ -142,7 +142,7 @@ BENCHMARK(BM_Complexity_O_N_log_N)
|
|||||||
BENCHMARK(BM_Complexity_O_N_log_N)
|
BENCHMARK(BM_Complexity_O_N_log_N)
|
||||||
->RangeMultiplier(2)
|
->RangeMultiplier(2)
|
||||||
->Range(1 << 10, 1 << 16)
|
->Range(1 << 10, 1 << 16)
|
||||||
->Complexity([](int64_t n) { return kLog2E * n * log(n); });
|
->Complexity([](int64_t n) { return kLog2E * n * log(static_cast<double>(n)); });
|
||||||
BENCHMARK(BM_Complexity_O_N_log_N)
|
BENCHMARK(BM_Complexity_O_N_log_N)
|
||||||
->RangeMultiplier(2)
|
->RangeMultiplier(2)
|
||||||
->Range(1 << 10, 1 << 16)
|
->Range(1 << 10, 1 << 16)
|
||||||
|
Loading…
Reference in New Issue
Block a user