Commit Graph

1510 Commits

Author SHA1 Message Date
dominic ff8d44c928
fix #1446 by removing the address operator (#1538)
* fix #1446 by removing the address operator

* add test

* format

---------

Co-authored-by: Thomas <thomas.maierbacher@rohde-schwarz.com>
Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2023-02-06 16:34:47 +00:00
JbR 4c9cee34f2
Fixing issue with ARM64EC and MSVC (#1514)
Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-02-06 15:58:14 +00:00
Chris Kennelly 53df805dc8
Deprecate constant reference API to DoNotOptimize. (#1493)
The compiler assume that a constant reference, even though escaped via asm
volatile, is unchanged.  The const-ref interface is deprecated to discourage
new uses of it, as subtle compiler optimizations (invariant hoisting, etc.) can
occur.

Within microbenchmarks for Abseil's hashtables, BM_FindMiss_Hot
(c0eaa90671/fleetbench/swissmap/hot_swissmap_benchmark.cc (L48))
has a `const uint32_t key` is passed to to the lookup of a hashtable.
With the `key` marked `const`, LLVM hoists part of the lookup
calculation outside of the loop.

With the `const` removed, this hoisting does not occur.

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2023-02-06 15:50:37 +00:00
dominic 94083ca441
remove best effort support for ubuntu 18.04 (#1537)
* remove deprecated ubuntu-18.04 target

* update docs

* force an apt update for perfcounters
2023-02-06 15:37:26 +00:00
dominic 1318865305
try disabling liquid for jekyll to fix curly braces (#1536)
* try disabling liquid for jekyll to fix curly braces

* do it properly with commented out tags
2023-02-06 14:01:16 +00:00
Nicholas Junge 80a3c5e4d9
Switch bindings implementation to `nanobind` (#1526)
* End support for Python 3.7, update cibuildwheel and publish actions

Removes Python 3.7 from the support matrix, since it does not support
PEP590 vectorcalls.

Bumps the `cibuildwheel` and `pypa-publish` actions to their latest
available versions respectively.

* Add nanobind to the Bazel dependencies, add a BUILD file

The build file builds nanobind as a static `cc_library`. Currently,
the git SHA points to HEAD, since some necessary features have not
been included in a release yet.

* Delete pybind11 BUILD file

* Switch bindings implementation to nanobind

Switches over the binding tool to `nanobind` from `pybind11`. Most
changes in the build setup itself were drop-in replacements of existing
code changed to nanobind names, no new concepts needed to be
implemented.

Sets the minimum required macOS to 10.14 for full C++17 support. Also,
to avoid ambiguities in Bazel, build for macOS 11 on Mac ARM64.

* Use Bazel select for linker options

Guards against unknown linker option errors by selecting required
linker options for nanobind only on macOS, where they are relevant.

Other changes:
* Bump cibuildwheel action to v2.12.0
* Bump Bazel for aarch64 linux wheels to 6.0.0
* Remove C++17 flag from build files since it is present in setup.py `bazel build` command
* Bump nanobind commit to current HEAD (TBD: Bump to next stable release)

* Unbreak Windows builds of nanobind-based bindings

Guards compiler options behind a new `select` macro choosing between
MSVC and not MSVC.

Other changes:
* Inject the proper C++17 standard cxxopt in the `setup.py` build
command.
* Bump nanobind to current HEAD.
* Make `macos` a benchmark-wide condition, with public visibility to
allow its use in the nanobind BUILD file.

* Fall back to `nb::implicitly_convertible` for Counter construction

Since `benchmark::Counter` only has a constructor for `double`,
the nanobind `nb::init_implicit` template cannot be used. Therefore,
to support implicit construction from ints, we fall back to the
`nb::implicitly_convertible` template instead.
2023-02-06 13:07:17 +00:00
Nicholas Junge f59d021ebc
Modernize setup.py, extend Python bindings CI (#1535)
distutils is deprecated and will be removed in Python 3.12, so this
commit modernizes the Python bindings `setup.py` file in order to
future-proof the code.

On top of this, type hints were added for all of the convenience
functions to make static type checking adoption easier in the future,
if desired.

A context manager was added to temporarily write the Python include
path to the Bazel WORKSPACE file - but unlike previously, the
WORKSPACE file is reverted to its previous state after the build to not
produce changes on every rebuild.

Lastly, the Python bindings test matrix was extended to all major
platforms to create a more complete picture of the current state of
the bindings, especially with regards to upcoming wheel builds.
2023-02-03 09:47:02 +00:00
Vy Nguyen 5e78bedfb0
Add quick instructions on how to enable sans checks (#1529)
Co-authored-by: dominic hamon <510002+dmah42@users.noreply.github.com>
2023-01-17 14:18:57 +00:00
SunBlack cfbc94960f
Fix Clang-Tidy warnings readability-else-after-return (#1528) 2023-01-16 12:28:48 +00:00
Vy Nguyen a3235d7b69
Include the benchmark's family-name in State (#1511)
* Include the benchmark's family-name in State

For compat with internal library, where State::name() returns the benchmark's family name.

* added missing files from prev commit

* fix field-init order error

* added test
2023-01-10 16:48:17 +00:00
SunBlack fe65457e80
Fix typos found by codespell (#1519) 2023-01-10 12:25:32 +00:00
SunBlack 37faf6f975
Fix Clang-Tidy warnings related to modernize-use-override (#1523) 2023-01-09 17:52:18 +00:00
Yury Fedorov 62edc4fb00
Bug fix variable 'actual_iterations' set but not used (#1517)
* Bug fix variable 'actual_iterations' set but not used

Compiling the project in clang 15 without -Wno-unused-but-set-variable flag the following error is generated:

benchmark-src/test/options_test.cc:70:10: error: variable 'actual_iterations' set but not used [-Werror,-Wunused-but-set-variable]
  size_t actual_iterations = 0;
         ^

* Adjust according formatting of `clang-format`

Co-authored-by: dominic hamon <510002+dmah42@users.noreply.github.com>
2022-12-19 14:03:11 +00:00
Dominic Hamon fe5a386b40 add more docs to index 2022-12-19 12:35:00 +00:00
Nicholas Junge dfd2ae520a
Add a `benchmark_deps.bzl` function to Google Benchmark (#1520)
* Add `benchmark_workspace.bzl` function

This commit adds a `benchmark_workspace.bzl` function to Google
Benchmark. It is intended to be used as a means to pull in Google
Benchmark's build dependencies in its own Bazel workspace, as well
as in workspaces of downstream projects.

* Migrate WORKSPACE to use the newly created benchmark_deps.bzl

This commit changes Google Benchmark's own WORKSPACE to use the newly
created `benchmark_deps.bzl` function.
2022-12-19 11:12:32 +00:00
dominic hamon da652a7486
Try removing attempt to set the C++ standard (#1464)
* Try removing attempt to set the C++ standard

Fixes #1460 #1462

* set the standard to 11

* spell it right

* had it right the first time

* require std 11

* plumb through the standard to cxxfeaturecheck

* use policy instead

* can't use policy just yet

* Update CXXFeatureCheck.cmake

* fix CXX_STANDARD_REQUIRED statement

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-12-10 19:42:44 -04:00
Jessy De Lannoit e67028c510
Fixes incorrect wide string conversion on win32 (#1516)
* fixes incorrect wide string conversion on win32

* removed redundant error checks
2022-12-06 11:51:41 +00:00
Maxim Smolskiy 2257fa4d6a
Return option benchmark_perf_counters to help output (#1508)
* Return option benchmark_perf_counters to help output

* Add guard HAVE_LIBPFM
2022-11-12 03:50:16 +03:00
Vy Nguyen 9714eb8d11
Removed deprecated function (#1506)
* Removed deprecated function

* updated tests too

* restore comment

Co-authored-by: dominic hamon <dominichamon@users.noreply.github.com>
2022-11-11 15:12:12 +00:00
Dominic Hamon d572f47773 version bump for release 2022-11-11 14:01:03 +00:00
Raghu Raja 398a8ac2e8
[bazel] Build libpfm as a dependency to allow collection of perf counters (#1408)
* Build libpfm as a dependency to allow collection of perf counters

This commit builds libpfm using rules_foreign_cc and lets the default
build of the benchmark library support perf counter collection without
needing additional work from users.

Tested with a custom target:

```
bazel run \
        --override_repository=com_github_google_benchmark=/home/raghu/benchmark \
        -c opt :test-bench -- "--benchmark_perf_counters=INSTRUCTIONS,CYCLES"
Using profile: local

<snip>

----------------------------------------------------------------------
Benchmark            Time             CPU   Iterations UserCounters...
----------------------------------------------------------------------
BM_Test      0.279 ns        0.279 ns   1000000000 CYCLES=1.00888 INSTRUCTIONS=2

```

Signed-off-by: Raghu Raja <raghu@enfabrica.net>

* Adding myself to the CONTRIBUTORS file per CLA guidance

Enfabrica has already signed a corporate CLA.

Signed-off-by: Raghu Raja <raghu@enfabrica.net>

Signed-off-by: Raghu Raja <raghu@enfabrica.net>
2022-10-31 11:03:59 +00:00
Nicholas Junge 4eaa0c896d
Add information for supported Python versions to setup.py (#1502)
Adds qualifiers for Python 3.9-3.11 indicating them being supported in the Python bindings building.

Support for Python 3.6 was removed, so the indicator for Python 3.6 was removed.
2022-10-18 11:23:59 +01:00
Roman Lebedev db4f581fbb
Partially revert "Do not depend on unversioned python binary (#1496)" (#1501)
As predicted, the cmake part of the change is contentious.
https://github.com/google/benchmark/pull/1496#issuecomment-1276508266

This partially reverts commit 229bc5a937.
2022-10-13 10:03:29 +01:00
Matthias Braun 229bc5a937
Do not depend on unversioned python binary (#1496)
Some linux distributions no longer provide `python` binary and require
usage of `python3` instead. This changes the scripts here and uses
cmake `find_package(Python3` when running python.

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-10-10 14:46:41 +03:00
rorth 12e0d70a43
Fix Solaris compilation (#1499) (#1500)
This patch fixes compilation on Solaris, addressing the problems reported
in Issue #1499:

* Provide `HOST_NAME_MAX` definition.
* Match `sysconf(3C)` return type.
* Avoid `-Wcast-qual` warnings with `libkstat(3KSTAT)` functions.
* Avoid clash with `<floatingpoint.h>` `single` typedef.
2022-10-06 09:18:55 +01:00
Marat Dukhan d2a8a4ee41
Support for QuRT OS (Hexagon RTOS) (#1497) 2022-10-04 20:43:27 +01:00
Dominic Hamon 49aa374da9
bump cmake dep and docs (#1468)
* bump cmake dep and docs
2022-09-14 15:11:37 +01:00
Nicholas Junge 9265511257
Bump pybind11 version to enable Python 3.11 wheel builds (#1489)
This commit bumps the pybind11 version to 2.10.0, which is the first
pybind version coming with Python 3.11 support. This change is necessary
to facilitate wheel builds for Python 3.11 and upward, as changes to
Python internals in 3.11 broke compatibility with older pybind11
versions.

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-09-13 15:01:46 +01:00
Matt Armstrong 1c26d8a337
Discuss sources of variance in the user guide (#1481)
* Discuss sources of variance in the user guide

* Mention cpufreq/boost

* Pull variance material into a new document

Add reducing_variance.md as a place to discuss things related to variance
and, in the future, statistical interpretation of benchmark results.

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-09-09 15:41:10 +01:00
Matt Armstrong becf80f3a9
Stop using pandas.Timedelta (fixes #1482) (#1483)
The pandas.Timedelta class truncates to integral nanoseconds, which throws
away sub-nanosecond precision present in benchmark JSON.  Switch to
floating point multiplication, which preserves it.

Fixes #1482
Tentatively fixes #1477.
2022-09-08 20:26:58 +03:00
Vy Nguyen db55c89f31
Eliminate usage of deprecated API in sysinfo.cc (#1474)
* Eliminate usage of deprecated  API in sysinfo.cc

The `std::wstring_convert` is deprecated in C++17.
Since this code is in the windows branch, we could use the win32 API (MultiByteToWideChar)

* ran clang-format
2022-08-30 15:32:46 +01:00
Nicholas Junge ff629d847c
Enable aarch64 Linux wheel builds, use cibuildwheel action directly (#1472)
This commit enables arm64 Linux wheel builds for Python.
It also changes the build procedure on Linux using
cibuildwheel in GitHub Actions. Instead of the more granular, verbose
approach that was used until now, we opt for the GitHub Action released
by cibuildwheel directly.

We also change the Bazel install procedure in the manylinux Docker
container image. Previously, Bazel was installed from an added RHEL repo, since that is
the recommended official way of installing Bazel on CentOS platforms.
However, the last successful build available for manylinux2014 has been Bazel 4,
which is showing its age with the release of Bazel 6 coming up as of this commit.

After this change, prebuilt Bazel binaries are downloaded using
wget directly from the Bazel GitHub release page. Since Bazel is built
for both x86 and arm64 on Linux, we immediately gain wheel build
support for these architectures. However, since the architecture
of the manylinux image is aarch64 instead of arm64,
a shell script was added that normalizes aarch64 to arm64,
and installs the correct arm64 Bazel binary if necessary.
2022-08-30 13:35:50 +01:00
AJ Heller 13196fff84
Clean up test documentation formatting (#1475) 2022-08-27 20:41:33 +03:00
babbaj 2a78e8cbe9
use CMAKE_INSTALL_FULL in pkg-config file (#1473) 2022-08-23 23:28:02 +03:00
Pavel V. Sysolyatin e8baf26225
Link error when use as static library on windows. (#1470) 2022-08-18 11:19:51 +01:00
Dominic Hamon 77d1e74d29
add debug option for enabling more output for failed cxxfeaturechecks (#1467)
fixes #1466
2022-08-10 20:42:27 +01:00
Björn Daase 4366d66385
FIx typo in benchmark.h (#1465) 2022-08-10 17:46:55 +01:00
Dominic Hamon af32e3fe1a
run ClearRegisteredBenchmarks at exit (#1463) 2022-08-08 21:34:20 +01:00
Cezary Skrzyński a476d0fd8e
Avoid deprecation warning in NVHPC (#1459)
* Avoid deprecation warning in NVHPC

* Use more general NVCC identification macro
2022-08-08 15:57:48 +01:00
Dominic Hamon 974cd5a5c5
Ensure we don't need benchmark installed to pass c++ feature checks (#1456)
* Ensure we don't need benchmark installed to pass c++ feature checks

Requires removal of some dependencies on benchmark.h from internal
low-level headers, which is a good thing.

Also added better logging to the feature check cmake module.
2022-08-04 15:33:35 +01:00
Vy Nguyen 5eb16eebb3
Explicitly cast int literals to int8_t in tests to silence implicit-conversion warnings (#1455)
* Explicitly cast int literals to int8_t in tests so silence implicit-conversion warnings

Error came from:
```
: error: implicit conversion loses integer precision: 'const int' to 'const signed char' [-Werror,-Wimplicit-int-conversion]
```

* clang format

* undo deleted line
2022-08-04 09:18:19 +01:00
Vy Nguyen 1cca1d091c
Fixed build issues on window (#1449)
* Fixed build issues on window

- Added missing dlimport/export attributes in function definitions. (They are needed in both decls and defs)
- Removed dlimport/dlexprt attribute in private field. (global_context is not exported anywhere).

* fixed incorrect include path

* undo changes w.r.t HelperPrintf

* removed forward decl of private variable - instead, introduce a getter and use it.

* Removed forward decl from benchmark_gtest too

Co-authored-by: Dominic Hamon <dominichamon@users.noreply.github.com>
2022-08-03 09:44:35 +01:00
Dominic Hamon 7d48eff772
remove unnecessary generated include directory (#1451) 2022-07-29 15:18:19 +01:00
Yuri Khan 892f29589d
Initialize help hook before actually parsing the command line (#1447) 2022-07-26 16:33:32 +01:00
Vy Nguyen 141b554e3a
Remove stray comment and added missing header (#1444)
- The export.h is no longer generated, so removed the comment.
- Added export.h to benchmark_main
2022-07-26 09:00:49 +01:00
Dominic Hamon 361e8d1cfe version bump 2022-07-25 12:35:38 +01:00
maochongxin ef7f75fb18
simplified code (#1439) 2022-07-21 12:34:02 +01:00
Dominic Hamon e27c93073f
use target_compile_definitions (#1440) 2022-07-21 11:50:01 +01:00
Dominic Hamon 7b3ac07517
Stop generating the export header and just check it in (#1435)
* Stop generating the export header and just check it in

* format the new header

* support windows

* format the header again

* avoid depending on internal macro

* ensure we define the right thing for windows static builds

* support older cmake

* and for tests
2022-07-20 20:34:39 +01:00
Dominic Hamon d845b7b3a2 Also fix the SOVERSION for benchmark_main 2022-07-19 09:14:35 +01:00