Skip to content

Commit b1854df

Browse files
committed
Update benchmarks
This mainly updates benchmarks to address an issue with perfcounters introduced through a refactoring. The issue was fixed in google/benchmark#1308. The only other change is in XRay - there was an update in the `State` API - field accessors. Differential Revision: https://reviews.llvm.org/D121343
1 parent aa1e969 commit b1854df

File tree

235 files changed

+5463
-9836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

235 files changed

+5463
-9836
lines changed

MicroBenchmarks/XRay/FDRMode/fdrmode-bench.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,14 @@ volatile bool log_initialized = false;
6969

7070
[[clang::xray_never_instrument]] static void BM_XRayFDRMultiThreaded(
7171
benchmark::State& state) {
72-
if (state.thread_index == 0) {
72+
if (state.thread_index() == 0) {
7373
SetUpXRayFDRMultiThreaded(state);
7474
}
7575
for (auto _ : state) {
7676
val = EmptyFunction();
7777
benchmark::DoNotOptimize(val);
7878
}
79-
if (state.thread_index == 0) {
79+
if (state.thread_index() == 0) {
8080
TearDownXRayFDRMultiThreaded(state);
8181
}
8282
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
Checks: 'clang-analyzer-*,readability-redundant-*,performance-*'
3+
WarningsAsErrors: 'clang-analyzer-*,readability-redundant-*,performance-*'
4+
HeaderFilterRegex: '.*'
5+
AnalyzeTemporaryDtors: false
6+
FormatStyle: none
7+
User: user

MicroBenchmarks/libs/benchmark/AUTHORS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ David Coeurjolly <[email protected]>
2121
Deniz Evrenci <[email protected]>
2222
Dirac Research
2323
Dominik Czarnota <[email protected]>
24+
Dominik Korman <[email protected]>
25+
Donald Aingworth <[email protected]>
2426
Eric Backus <[email protected]>
2527
Eric Fiselier <[email protected]>
2628
Eugene Zhuk <[email protected]>
@@ -50,7 +52,9 @@ Paul Redmond <[email protected]>
5052
Radoslav Yovchev <[email protected]>
5153
Roman Lebedev <[email protected]>
5254
Sayan Bhattacharjee <[email protected]>
55+
5356
Shuo Chen <[email protected]>
57+
Staffan Tjernstrom <[email protected]>
5458
Steinar H. Gunderson <[email protected]>
5559
Stripe, Inc.
5660
Tobias Schmidt <[email protected]>

MicroBenchmarks/libs/benchmark/BUILD.bazel

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1-
load("@rules_cc//cc:defs.bzl", "cc_library")
2-
31
licenses(["notice"])
42

3+
load("//:config/generate_export_header.bzl", "generate_export_header")
4+
5+
posix_copts = [
6+
"-fvisibility=hidden",
7+
"-fvisibility-inlines-hidden",
8+
]
9+
10+
# Generate header to provide ABI export symbols
11+
generate_export_header(
12+
out = "include/benchmark/export.h",
13+
lib = "benchmark",
14+
static_define = "BENCHMARK_STATIC_DEFINE",
15+
)
16+
517
config_setting(
618
name = "qnx",
719
constraint_values = ["@platforms//os:qnx"],
@@ -29,13 +41,24 @@ cc_library(
2941
],
3042
exclude = ["src/benchmark_main.cc"],
3143
),
32-
hdrs = ["include/benchmark/benchmark.h"],
44+
hdrs = [
45+
"include/benchmark/benchmark.h",
46+
"include/benchmark/export.h", # From generate_export_header
47+
],
3348
linkopts = select({
3449
":windows": ["-DEFAULTLIB:shlwapi.lib"],
3550
"//conditions:default": ["-pthread"],
3651
}),
3752
strip_include_prefix = "include",
3853
visibility = ["//visibility:public"],
54+
copts = select({
55+
":windows": [],
56+
"//conditions:default": posix_copts,
57+
}),
58+
local_defines = select({
59+
":windows": ["benchmark_EXPORTS"],
60+
"//conditions:default": [],
61+
}),
3962
)
4063

4164
cc_library(
@@ -45,6 +68,10 @@ cc_library(
4568
strip_include_prefix = "include",
4669
visibility = ["//visibility:public"],
4770
deps = [":benchmark"],
71+
copts = select({
72+
":windows": [],
73+
"//conditions:default": posix_copts,
74+
}),
4875
)
4976

5077
cc_library(

MicroBenchmarks/libs/benchmark/CMakeLists.txt

Lines changed: 43 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,31 @@ foreach(p
1313
endif()
1414
endforeach()
1515

16-
project (benchmark VERSION 1.5.4 LANGUAGES CXX)
16+
project (benchmark VERSION 1.6.1 LANGUAGES CXX)
1717

1818
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON)
1919
option(BENCHMARK_ENABLE_EXCEPTIONS "Enable the use of exceptions in the benchmark library." ON)
2020
option(BENCHMARK_ENABLE_LTO "Enable link time optimisation of the benchmark library." OFF)
2121
option(BENCHMARK_USE_LIBCXX "Build and test using libc++ as the standard library." OFF)
22+
option(BENCHMARK_ENABLE_WERROR "Build Release candidates with -Werror." ON)
23+
option(BENCHMARK_FORCE_WERROR "Build Release candidates with -Werror regardless of compiler issues." OFF)
24+
25+
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "PGI")
26+
# PGC++ maybe reporting false positives.
27+
set(BENCHMARK_ENABLE_WERROR OFF)
28+
endif()
29+
if(BENCHMARK_FORCE_WERROR)
30+
set(BENCHMARK_ENABLE_WERROR ON)
31+
endif(BENCHMARK_FORCE_WERROR)
32+
2233
if(NOT MSVC)
2334
option(BENCHMARK_BUILD_32_BITS "Build a 32 bit version of the library." OFF)
2435
else()
2536
set(BENCHMARK_BUILD_32_BITS OFF CACHE BOOL "Build a 32 bit version of the library - unsupported when using MSVC)" FORCE)
2637
endif()
2738
option(BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark. (Projects embedding benchmark may want to turn this OFF.)" ON)
39+
option(BENCHMARK_ENABLE_DOXYGEN "Build documentation with Doxygen." OFF)
40+
option(BENCHMARK_INSTALL_DOCS "Enable installation of documentation." ON)
2841

2942
# Allow unmet dependencies to be met using CMake's ExternalProject mechanics, which
3043
# may require downloading the source code.
@@ -33,10 +46,14 @@ option(BENCHMARK_DOWNLOAD_DEPENDENCIES "Allow the downloading and in-tree buildi
3346
# This option can be used to disable building and running unit tests which depend on gtest
3447
# in cases where it is not possible to build or find a valid version of gtest.
3548
option(BENCHMARK_ENABLE_GTEST_TESTS "Enable building the unit tests which depend on gtest" ON)
49+
option(BENCHMARK_USE_BUNDLED_GTEST "Use bundled GoogleTest. If disabled, the find_package(GTest) will be used." ON)
3650

3751
option(BENCHMARK_ENABLE_LIBPFM "Enable performance counters provided by libpfm" OFF)
3852

39-
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
53+
# Export only public symbols
54+
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
55+
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
56+
4057
if(MSVC)
4158
# As of CMake 3.18, CMAKE_SYSTEM_PROCESSOR is not set properly for MSVC and
4259
# cross-compilation (e.g. Host=x86_64, target=aarch64) requires using the
@@ -109,9 +126,13 @@ set(GENERIC_LIB_VERSION ${VERSION})
109126
string(SUBSTRING ${VERSION} 0 1 GENERIC_LIB_SOVERSION)
110127

111128
# Import our CMake modules
112-
include(CheckCXXCompilerFlag)
113129
include(AddCXXCompilerFlag)
130+
include(CheckCXXCompilerFlag)
131+
include(CheckLibraryExists)
114132
include(CXXFeatureCheck)
133+
include(GenerateExportHeader)
134+
135+
check_library_exists(rt shm_open "" HAVE_LIB_RT)
115136

116137
if (BENCHMARK_BUILD_32_BITS)
117138
add_required_cxx_compiler_flag(-m32)
@@ -160,9 +181,11 @@ else()
160181
add_cxx_compiler_flag(-Wall)
161182
add_cxx_compiler_flag(-Wextra)
162183
add_cxx_compiler_flag(-Wshadow)
163-
add_cxx_compiler_flag(-Werror RELEASE)
164-
add_cxx_compiler_flag(-Werror RELWITHDEBINFO)
165-
add_cxx_compiler_flag(-Werror MINSIZEREL)
184+
if(BENCHMARK_ENABLE_WERROR)
185+
add_cxx_compiler_flag(-Werror RELEASE)
186+
add_cxx_compiler_flag(-Werror RELWITHDEBINFO)
187+
add_cxx_compiler_flag(-Werror MINSIZEREL)
188+
endif()
166189
if (NOT BENCHMARK_ENABLE_TESTING)
167190
# Disable warning when compiling tests as gtest does not use 'override'.
168191
add_cxx_compiler_flag(-Wsuggest-override)
@@ -181,9 +204,11 @@ else()
181204
add_cxx_compiler_flag(-wd1786)
182205
endif()
183206
# Disable deprecation warnings for release builds (when -Werror is enabled).
184-
add_cxx_compiler_flag(-Wno-deprecated RELEASE)
185-
add_cxx_compiler_flag(-Wno-deprecated RELWITHDEBINFO)
186-
add_cxx_compiler_flag(-Wno-deprecated MINSIZEREL)
207+
if(BENCHMARK_ENABLE_WERROR)
208+
add_cxx_compiler_flag(-Wno-deprecated RELEASE)
209+
add_cxx_compiler_flag(-Wno-deprecated RELWITHDEBINFO)
210+
add_cxx_compiler_flag(-Wno-deprecated MINSIZEREL)
211+
endif()
187212
if (NOT BENCHMARK_ENABLE_EXCEPTIONS)
188213
add_cxx_compiler_flag(-fno-exceptions)
189214
endif()
@@ -307,7 +332,15 @@ if (BENCHMARK_ENABLE_TESTING)
307332
if (BENCHMARK_ENABLE_GTEST_TESTS AND
308333
NOT (TARGET gtest AND TARGET gtest_main AND
309334
TARGET gmock AND TARGET gmock_main))
310-
include(GoogleTest)
335+
if (BENCHMARK_USE_BUNDLED_GTEST)
336+
include(GoogleTest)
337+
else()
338+
find_package(GTest CONFIG REQUIRED)
339+
add_library(gtest ALIAS GTest::gtest)
340+
add_library(gtest_main ALIAS GTest::gtest_main)
341+
add_library(gmock ALIAS GTest::gmock)
342+
add_library(gmock_main ALIAS GTest::gmock_main)
343+
endif()
311344
endif()
312345
add_subdirectory(test)
313346
endif()

MicroBenchmarks/libs/benchmark/CONTRIBUTORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Albert Pretorius <[email protected]>
2727
Alex Steele <[email protected]>
2828
Andriy Berestovskyy <[email protected]>
2929
Arne Beer <[email protected]>
30+
Bátor Tallér <[email protected]>
3031
Billy Robert O'Neal III <[email protected]> <[email protected]>
3132
3233
Christian Wassermann <[email protected]>
@@ -38,6 +39,8 @@ David Coeurjolly <[email protected]>
3839
Deniz Evrenci <[email protected]>
3940
4041
Dominik Czarnota <[email protected]>
42+
Dominik Korman <[email protected]>
43+
Donald Aingworth <[email protected]>
4144
Eric Backus <[email protected]>
4245
Eric Fiselier <[email protected]>
4346
Eugene Zhuk <[email protected]>

MicroBenchmarks/libs/benchmark/LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,33 @@
200200
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201201
See the License for the specific language governing permissions and
202202
limitations under the License.
203+
204+
205+
BSD 3-Clause License
206+
207+
Copyright (c) [year], [fullname]
208+
209+
Redistribution and use in source and binary forms, with or without
210+
modification, are permitted provided that the following conditions are met:
211+
212+
1. Redistributions of source code must retain the above copyright notice, this
213+
list of conditions and the following disclaimer.
214+
215+
2. Redistributions in binary form must reproduce the above copyright notice,
216+
this list of conditions and the following disclaimer in the documentation
217+
and/or other materials provided with the distribution.
218+
219+
3. Neither the name of the copyright holder nor the names of its
220+
contributors may be used to endorse or promote products derived from
221+
this software without specific prior written permission.
222+
223+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
224+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
225+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
226+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
227+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
228+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
229+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
230+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
231+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
232+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 commit comments

Comments
 (0)