Commit Graph

1551 Commits

Author SHA1 Message Date
mosfet80 7971a63070
Cache upd (#1830)
* Update bazel.yml

switch to node20 updated  actions/cache to v4

* Update pre-commit.yml

switch to node20 updated  actions/cache to v4
2024-08-02 10:56:57 +01:00
xdje42 ebb5e3922d
Move ProfilerManager Start/Stop routines closer to actual benchmark #1807 (#1818)
Previously, the Start/Stop routines were called before the benchmark function
was called and after it returned. However, what we really want is for them
to be called within the core of the benchmark:

  for (auto _ : state) {
    // This is what we want traced, not the entire BM_foo function.
  }
2024-08-01 08:42:41 +01:00
Nicholas Junge 25e5c52a11
Bump nanobind-bazel to v2.1.0, add stubgen target (#1824)
Adds a stub file for the `google_benchmark._benchmark` submodule,
generated with the new `nanobind_stubgen` rule released in nanobind_bazel
v2.1.0.

Tweaks the setup.py logic a little bit to package stub files with the
rest of the build artifacts. Also explicitly adds the generated stub and
marker files to the list of package data artifacts.

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-07-30 15:49:33 +01:00
mosfet80 ac80572f17
Update nanobind into benchmark_deps.bzl (#1826)
* Update nanobind into benchmark_deps.bzl

* Update benchmark_deps.bzl
2024-07-30 15:05:08 +01:00
mosfet80 cfb7e0a330
Update libs into .pre-commit-config.yaml (#1825) 2024-07-30 14:09:31 +01:00
dominic 378fe693a1
Use log2 now that NDK requires at least API 21 which includes it. (#1822)
Fixes #1820
2024-07-24 14:25:32 +01:00
Devon Loehr fa236ed6e6
Suppress invalid-offsetof warning for clang (#1821)
For several compilers, `benchmark.cc` suppresses a warning regarding its use of `offsetof`. This merely extends that suppression to cover clang as well.
2024-07-24 13:12:04 +01:00
Nicholas Junge df44bf7187
Revert to token authentication for PyPI wheel uploads (#1819)
Until the PyPI account is recovered, it should be possible to upload
wheels with the GitHub secrets that were previously used.

Changes the PyPI upload action sourcing to point to the v1 stable release
branch, which receives rolling updates and is the canonical way of
including the wheel publishing action.

Uploading will probably need another release, because setuptools_scm
needs to produce a clean tag that the PyPI API allows as an upload.
2024-07-23 14:49:06 +01:00
Peter Hawkins 64b5d8cd11
Update benchmark Python bindings for nanobind 2.0, and update to nanobind 2.0. (#1817)
Incorporates the nanobind_bazel change from https://github.com/google/benchmark/pull/1795.

nanobind 2.0 reworked the nanobind::enum_ class so it uses a real Python enum or intenum rather than its previous hand-rolled implementation.
https://nanobind.readthedocs.io/en/latest/changelog.html#version-2-0-0-may-23-2024

As a consequence of that change, nanobind now checks when casting an integer to a enum value that the integer corresponds to a valid enum. Counter::Flags is a bitmask, and many combinations are not valid enum members.

This change:
a) sets nb::is_arithmetic(), which means Counter::Flags becomes an IntEnum that can be freely cast to an integer.
b) defines the | operator for flags to return an integer, not an enum, avoiding the error.
c) changes Counter's constructor to accept an int, not a Counter::Flags enum. Since Counter::Flags is an IntEnum now, it can be freely coerced to an int.

If https://github.com/wjakob/nanobind/pull/599 is merged into nanobind, then we can perhaps use a flag enum here instead.
2024-07-18 16:54:02 +01:00
Dominic Hamon a6ad7fbbdc preparing for v1.8.5 2024-07-18 11:13:04 +01:00
Dominic Hamon ad2b1c9ed1 clang format yet again 2024-07-17 16:49:12 +01:00
Dominic Hamon 4b184d47a4 update actions/checkout to v4 2024-07-17 16:47:54 +01:00
Dominic Hamon 44507bc91f another reversal of something that breaks on wasm 2024-07-17 16:39:15 +01:00
Dominic Hamon 299a8b881d clang format header fixes 2024-07-17 13:27:41 +01:00
Dominic Hamon 99410f400c clang-format fixes 2024-07-17 13:25:16 +01:00
Dominic Hamon a73c039b1d roll back fatal error that breaks some platform (wasm) expectations 2024-07-17 13:18:38 +01:00
Dominic Hamon 65668db273 revert perf counters change until we can do the full version 2024-07-16 17:45:30 +01:00
Dominic Hamon 14ddd77a90 remove old travis config 2024-07-16 17:39:51 +01:00
xdje42 7c8ed6b082
[FR] Add API to provide custom profilers #1807 (#1809)
This API is akin to the MemoryManager API and lets tools provide
their own profiler which is wrapped in the same way MemoryManager is
wrapped. Namely, the profiler provides Start/Stop methods that are called
at the start/end of running the benchmark in a separate pass.

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-07-16 09:56:40 +01:00
Jiawen (Kevin) Chen d2cd246e19
Clarify the difference between `BENCHMARK_TEMPLATE_F` and `BENCHMARK_TEMPLATE_DEFINE_F` + `BENCHMARK_REGISTER_F` (#1815)
* Clarify BENCHMARK_REGISTER_F

Add comments highlighting the difference between `BENCHMARK_TEMPLATE_F` and `BENCHMARK_TEMPLATE_DEFINE_F`, mirroring those of `BENCHMARK_F ` and `BENCHMARK_DEFINE_F`.

* More informative comments.

* Update user_guide.md
2024-07-16 09:51:56 +01:00
dominic 38df9daf48
add PERF_FORMAT_TOTAL_TIME_{ENABLED,RUNNING} to support multiplexing (#1814) 2024-07-12 10:28:16 +01:00
Chris Cotter 71f4218c1a
Add -lkstat to the .pc for Solaris (#1801)
* Add -lkstat to the .pc for Solaris

This fixes linking for projects that rely on pkg-config to generate the
link line on Solaris.

Test plan: Built the project locally on Solaris and verified -kstat
appears in the .pc file

```
$ cat lib/pkgconfig/benchmark.pc  | grep Libs.private
Libs.private: -lpthread -lkstat
```

* Use BENCHMARK_PRIVATE_LINK_LIBRARIES
2024-07-03 21:16:43 +03:00
Stephen Nicholas Swatman c2146397ac
Find libpfm dependency in installed CMake configs (#1806)
Currently, Google Benchmark can be built and installed with support for
libpfm, but this can cause a problem if that installation is later
called upon by another CMake project. Indeed, while the installed CMake
configuration script correctly identifies that it needs to link against
libpfm, it doesn't try to find libpfm, meaning that the target will be
unavailable. This commit fixes this potential configuration-time error
by ensuring that an installation of Google Benchmark will correctly try
to find the libpfm dependency when it is used elsewhere.
2024-06-19 21:03:42 +03:00
Alexander Karatarakis 447752540c
[bazel] Use `includes` instead of `strip_include_prefix` (#1803)
When using `includes`, consumers will apply the headers
using `-isystem`, instead of `-I`. This will allow diagnostics
of consumers to not apply to `benchmark`.

More info:

https://bazel.build/reference/be/c-cpp#cc_library.includes

https://bazel.build/reference/be/c-cpp#cc_library.strip_include_prefix

gtest uses `includes` as well:
1d17ea141d/BUILD.bazel (L120)
2024-06-17 09:38:32 +01:00
Khem Raj 8e1823d6f5
cycleclock: Fix type conversion to match function return type on riscv64 (#1802)
Fixes builds with clang

src/cycleclock.h:213:10: error: implicit conversion changes signedness: 'uint64_t' (aka 'unsigned long') to 'int64_t' (aka 'long') [-Werror,-Wsign-conversion]
     213 |   return cycles;
         |   ~~~~~~ ^~~~~~
   1 error generated.
2024-06-11 13:37:35 +01:00
Robert Schulze 2fa4b26e58
Bump minimum required C++ version from C++11 to C++14 (#1800) 2024-06-10 11:08:49 +01:00
dominic 10199fb48e
bump standard to C++14 (#1799)
* update requirements to point to our dependencies doc

* bump standard to c++14
2024-06-07 15:22:45 +01:00
Khem Raj 7f0e99af54
cycleclock: Fix type conversion to match function return type (#1794)
fixes build with clang19

src/cycleclock.h:208:52: error: implicit conversion changes signedness: 'uint64_t' (aka 'unsigned long long') to 'int64_t' (aka 'long long') [-Werror,-Wsign-conversion]
  208 |   return (static_cast<uint64_t>(cycles_hi1) << 32) | cycles_lo;
      |   ~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~
1 error generated.
2024-05-29 06:14:54 +03:00
Roman Lebedev d77b692710
CMake: unbreak version handling for tarballs (#1793)
#1742 changed the placeholder version from `0.0.0` to `v0.0.0`,
but this line which was further dealing with it, was not updated.

Fixes https://github.com/google/benchmark/issues/1792

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-05-28 11:24:21 +01:00
Nicholas Junge 144d23cf5f
hotfix: Correct pypi-publishing action tag to v1.8.14 (#1791)
Also bump pre-commit dependencies via `pre-commit autoupdate`.
2024-05-24 09:51:41 +01:00
Steven Johnson 7f992a553d
Improve compatibility with Hexagon hardware (#1785)
The customization done via BENCHMARK_OS_QURT works just fine with the Hexagon simulator, but on at least some Hexagon hardware, both `qurt_timer_get_ticks()` and `std::chrono::now()` are broken and always return 0. This fixes the former by using the better-supported (and essentially identical `qurt_sysclock_get_hw_ticks()` call, and the latter by reading a 19.2MHz hardware counter (per suggestion from Qualcomm). Local testing seems to indicate these changes are just as robust under the simulator as before.
2024-05-23 20:08:54 +03:00
dominic a4cf155615
preparing for v1.8.4 (#1788) 2024-05-23 15:02:46 +01:00
Nicholas Junge bc946b919c
Modernize wheel building job config (#1783)
It is now possible to build Mac wheels on native machines in Github
Actions, so ARM64 Mac wheels are now built and tested on M1 machines.

Also, the artifact up-/download was migrated to v4, which made it
necessary to upload wheels to unique artifact names, and then later
stitch them together again in a subsequent job.

The cross-platform Mac build injection in setup.py was removed,
since it is no longer necessary.

I relanded a monkey-patching of Bazel build files, this time for
MODULE.bazel. This is because `rules_python` does not allow running
as the root user, which is the case in cibuildwheel+Linux (happens
in a Docker container). Since I did not see a quick way of switching
to rootless containers, and did not want to hardcode the config change
(it can apparently cause cache misses and build failures), I inject the
"ignore_root_user_error" flag into the MODULE.bazel file when running
in cibuildwheel on Linux.
2024-04-15 17:44:09 +01:00
Nicholas Junge 185c55d793
Switch git override to stable BCR tag for nanobind_bazel (#1778)
This comes following the first BCR release of nanobind_bazel.

Feature-wise, nothing substantial has changed, except that the extensions
are stripped of debug info when built in release mode, which reduces
clutter in the symbol tables.

No stubgen yet, since nanobind v2 has not been released yet.
2024-04-15 10:57:02 +01:00
David Seifert c0105603f6
Add `benchmark_main.pc` to link `main()` containing library (#1779)
This is similar to the addition in 8604c4adac (diff-eb8e49bdf5e9aafb996777a4f4302ad1efd281222bf3202eb9b77ce47496c345)
that added pkg-config support in GTest. Without this, users
need to manually find the library containing `main()`.
2024-04-14 19:05:36 +03:00
dhairya d6ce145287
Refactor: Return frequency as double (#1782)
Adjusted the GetSysctl call in sysinfo.cc to ensure the frequency
value is returned as a double rather than an integer. This helps
maintain consistency and clarity in the codebase.
2024-04-13 00:22:31 +03:00
Fanbo Meng 70916cbf71
Remove COMPILER_IBMXL macro for z/OS (#1777)
COMPILER_IBMXL identifies the Clang based IBM XL compiler (xlclang) on z/OS. This compiler is obsolete and replaced by the Open XL compiler, so the macro is no longer needed and the existing code would lead to incorrect asm syntax for Open XL.
2024-04-03 10:26:33 +01:00
Vasyl Zubko f3ec7b8820
Fix OpenBSD build (#1772) 2024-03-24 22:17:34 +03:00
PhilipDeegan d5c55e8c42
allow BENCHMARK_VERSION to be undefined (#1769) 2024-03-21 15:29:38 +03:00
Roman Lebedev 06b4a07015
clang-tidy broke the world (#1766)
`AnalyzeTemporaryDtors` option is no longer recognized by clang-tidy-18,
and that renders the whole config invalid and completely ignored... ???
2024-03-18 11:01:25 +00:00
Afanasyev Ivan ad7c3ff18b
Fix implicit conversion changes signess warning in perf_counters.cc (#1765)
`read_bytes` is `ssize_t` (and we know it's non-negative),
we need to explicitly cast it to `size_t`.
2024-03-09 15:35:18 +03:00
Nicholas Junge eaafe694d2
Add Python bindings build using bzlmod (#1764)
* Add a bzlmod Python bindings build

Uses the newly started `@nanobind_bazel` project to build nanobind
extensions. This means that we can drop all in-tree custom build defs
and build files for nanobind and the C++ Python headers.

Additionally, the temporary WORKSPACE overwrite hack naturally goes away
due to the WORKSPACE system being obsolete.

* Bump ruff -> v0.3.1, change ruff settings

The latest minor releases incurred some formatting and configuration
changes, this commit rolls them out.

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-03-07 12:28:55 +00:00
dominic c64b144f42
mitigate clang build warnings -Wconversion (#1763)
* mitigate clang build warnings -Wconversion

* ensure we have warnings set everywhere and fix some
2024-03-07 12:19:56 +00:00
Tiago Freire 654d8d6cf3
Fixed LTO issue on no discard variable (#1761)
Improve `UseCharPointer()` (thus, `DoNotOptimize()`) under MSVC LTO,
make it actually escape the pointer and prevent it from being optimized away.
2024-03-06 15:50:45 +03:00
Roman Lebedev ef88520d6f
Revert "fix some warnings" (#1762)
This reverts commit 1576991177.
2024-03-06 12:40:31 +00:00
Dominic Hamon 1576991177 fix some warnings 2024-02-20 16:51:06 +00:00
Roman Lebedev 3d85343d65
Rewrite complexity_test to use (hardcoded) manual time (#1757)
* Rewrite complexity_test to use (hardcoded) manual time

This test is fundamentally flaky, because it tried to read tea leafs,
and is inherently misbehaving in CI environments,
since there are unmitigated sources of noise.

That being said, the computed Big-O also depends on the `--benchmark_min_time=`

Fixes https://github.com/google/benchmark/issues/272

* Correctly compute Big-O for manual timings. Fixes #1758.

* complexity_test: do more stuff in empty loop

* Make all empty loops be a bit longer empty

Looks like on windows, some of these tests still fail,
i guess clock precision is too small.
2024-02-19 15:22:35 +00:00
Sam James 7f7c96a264
sysinfo.cc: Always abort on GetNumCPUs failure (#1756)
Defines a wrapper function, CheckNumCPUs, which enforces that GetNumCPUs
never returns fewer than one CPU.  There is no reasonable way to
continue if we are unable to identify the number of CPUs.

Signed-off-by: Sam James <sam@gentoo.org>
2024-02-14 20:19:46 +03:00
Sam James 385033bd11
CycleClock: Add support for Alpha architecture (#1753)
* Add support for Alpha architecture

As documented, the real cycle counter is unsafe to use here, because it
is a 32-bit integer which wraps every ~4s.  Use gettimeofday instead,
which has a limitation of a low-precision real-time-clock (~1ms), but no
wrapping.  Passes test suite.

Support parsing /proc/cpuinfo on Alpha

tabular_test: add a missing DoNotOptimize call
2024-02-14 00:04:44 +03:00
Matthias Liedtke b7ad5e0497
fix typo in GetBenchmarkVersion() (#1755) 2024-02-12 16:56:58 +00:00