Commit Graph

1576 Commits

Author SHA1 Message Date
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
Roman Lebedev b04cec1bf9
Deflake CI (#1751)
* `complexity_test`: deflake, same as https://github.com/google/benchmark/issues/272

As it can be seen in e.g. https://github.com/google/benchmark/actions/runs/7711328637/job/21016492361
We may get `65: BM_Complexity_O1_BigO                           0.00 N^2        0.00 N^2  `

* `user_counters_tabular_test`: deflake

We were still getting zero times there. Perhaps this is better?
2024-02-02 18:39:46 +03:00
Roman Lebedev e990563876
Add `BENCHMARK_TEMPLATE[12]_CAPTURE`, fusion of `BENCHMARK_CAPTURE` and `BENCHMARK_TEMPLATE` (#1747)
Test coverage isn't great, but not worse than the existing one.

You'd think `BENCHMARK_CAPTURE` would suffice,
but you can't pass `func<targs>` to it (due to the `<` and `>`),
and when passing `(func<targs>)` we get issues with brackets.
So i'm not sure if we can fully avoid this helper.

That being said, if there is only a single template argument,
`BENCHMARK_CAPTURE()` works fine if we avoid using function name.
2024-01-30 12:44:36 +00:00
dominic 30a37e1b0b
set library version in bazel (#1746)
* set library version in bazel
2024-01-29 13:48:04 +00:00
Roman Lebedev 17bc235ab3
Output library / schema versions in JSON context block (#1742)
* CMake: `get_git_version()`: just use `--dirty` flag of `git describe`

* CMake: move version normalization out of `get_git_version()`

Mainly, i want `get_git_version()` to return true version,
not something sanitized.

* JSON reporter: store library version and schema version in `context`

* Tools: discard inputs with unexpected `json_schema_version`

* Extract version string into `GetBenchmarkVersiom()`

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-01-29 13:15:43 +00:00
Dominic Hamon 8e2d258644 ignore new bzlmod lock file 2024-01-29 13:06:57 +00:00
Dominic Hamon faef450eb9 changes to run bazel migration scripts
part of #1743
2024-01-29 13:02:29 +00:00
Nicholas Junge 4682db08bc
Bump pre-commit dependencies (#1740)
Also fix a mypy error in `tools.gbench.util` - the condition behaves the
same as before, but in the new mypy version, the old condition results
in an unreachable code error for the final `return False` statement.

This is most likely a bug in mypy's reachability analysis, but the fix
is easy enough here to circumvent it.
2024-01-18 13:35:57 +00:00
Aleksey 3d293cd67a
Fix C-style typecasting in QNX-specific code (#1739)
C-style typecasting breaks the build due to `-Werror=old-style-cast` which should remain in place.
2024-01-16 12:28:04 +00:00
Roman Lebedev ea71a14891
Docs: `reducing_variance.md`: proofreading, fix typos (#1736) 2024-01-10 09:37:39 +00:00
Ananta Bastola 882f6f5ae0
fix(cmakelists.txt): enforce CMake to find PFM or fail when BENCHMARK_ENABLE_LIBPFM is ON (#1705)
Fixes #1702
2024-01-09 18:34:42 +03:00
Benny Tordrup 54e4327190
Issue 1734: Streams not flushed if not running actual benchmarks (#1735)
Consistently flush Out and Err streams, otherwise they might not get flushed
and the output lost when using custom streams.

Fixes #1734.
2024-01-09 17:59:10 +03:00
Roman Lebedev 96d820f73f
tools/compare: don't actually discard valid (but zero) `pvalue` (#1733)
* tools/compare: when dumping json, pretty-print it

It's rather completely non-human-readable otherwise.
I can't imagine the filesize really matters,
and if it does, it should just be compressed later on.

* tools/compare: add failing test

* tools/compare: don't actually discard valid (but zero) `pvalue`

So, this is embarressing. For a very large number of repetitions,
we can end up with pvalue of a true zero, and it obviously compares false,
and we treat it as-if we failed to compute it...
2024-01-08 09:57:00 +00:00
Benny Tordrup e61e332df9
Issue1731 created console does not receive output (#1732)
* Instead of directly comparing std::cout and GetOutputStream(), the underlying buffers are retreived via rdbuf(), and then compared.

* Instead of fflush(stdout), call out.flush().
Use out << FormatString() instead of vprintf

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-01-05 14:08:28 +00:00
Dominic Hamon 4575fc415f Merge branch 'aqrose-aidi-sdk-team-main' 2024-01-05 10:41:54 +00:00
FantasqueX a6b78ef168
Change Fixture to use non-const SetUp and TearDown in example (#1723)
Const SetUp and TearDown were deprecated in https://github.com/google/benchmark/pull/285

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-01-05 10:35:20 +00:00
Li-Yu Yu 07c98d5a44
Avoid leaking LFS flags to reverse dependencies (#1730)
Follow up of #1725.

`defines` propagates to reverse dependencies, while `local_defines`
don't. If we use `defines` then there's risk of ODR violation:

Suppose a user have a cc_library foo that depends on bar and benchmark:

    cc_library(name = "foo", deps = [":bar", "@com_github_google_benchmark//:benchmark"])

And bar has a class that has LFS-dependant ABI:

    cc_library(name = "foo")

    class Bar {
        off_t member;
    };

Bar would be compiled without LFS, but linked to foo when assuming LFS is enabled.

So we limit LFS to within the library only. benchmark does not have
LFS dependant public ABIs so it should be fine.
2024-01-05 10:27:12 +00:00
dhmemi e0ec670d20 style: re-format BUILD file with buildifier. 2024-01-05 11:23:23 +08:00
Abhina Sree e3824e7503
fix per-thread timing error on z/OS (#1719)
Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-01-04 11:07:01 +00:00
Tommy Chiang c213e41eb9
Enable Large-file Support (#1726)
* Enable Large-file Support

This should fix https://github.com/google/benchmark/issues/1725

* Use whitespaces instead of tab in BUILD.bazel

---------

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-01-04 10:50:33 +00:00
aurel32 99bdb2127d
CycleClock: use RDTIME instead of RDCYCLE on RISC-V (#1727)
Starting with Linux 6.6 [1], RDCYCLE is a privileged instruction on
RISC-V and can't be used directly from userland. There is a sysctl
option to change that as a transition period, but it will eventually
disappear.

Use RDTIME instead, which while less accurate has the advantage of being
synchronized between CPU (and thus monotonic) and of constant frequency.

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cc4c07c89aada16229084eeb93895c95b7eabaa3

Co-authored-by: dominic <510002+dmah42@users.noreply.github.com>
2024-01-04 09:16:40 +00:00
hamptonm1 e523e454f2
Update perf_counters_gtest.cc (#1728) 2024-01-04 09:11:07 +00:00
Afanasyev Ivan 2d2e07e3c5
Fix division by zero for low frequency timers for CV statistics (#1724) 2024-01-03 12:40:59 +00:00
dhmemi 3028899d61 fix: fail to import gbench in bazel and python3.12 2023-12-22 10:24:23 +08:00
Abhina Sree 7b52bf7346
define HOST_NAME_MAX for z/oS (#1717) 2023-12-20 17:18:37 +00:00
IS 6b7e86c5c8
Fix mis-matching argument in closing tag for cmake macro (#1714) (#1715)
Co-authored-by: Iakov Sergeev <yahontu@gmail.com>
2023-12-20 09:54:55 +00:00