Skip to content

Commit

Permalink
Add libpfm4 git repository to enable use of perf counters by benchmar…
Browse files Browse the repository at this point in the history
…ks. (google#15)
  • Loading branch information
virajbshah authored Aug 7, 2023
1 parent 4eca0be commit 5b56fa1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
27 changes: 26 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,35 @@ git_repository(
tag = "release-1.12.1",
)

# We use a patched version of google/benchmark/BUILD.bazel to keep the name
# used to refer to libpfm4 and its targets consistent with other dependencies.
git_repository(
name = "com_github_google_benchmark",
patch_args = ["-p1"],
patches = ["@//:benchmark_build.patch"],
remote = "https://github.com/google/benchmark.git",
tag = "v1.8.0",
tag = "v1.8.2",
)

# rules_foreign_cc is required to build libpfm4 since it is originally
# configured to be built using GNU Make.
git_repository(
name = "rules_foreign_cc",
commit = "816905a078773405803e86635def78b61d2f782d",
remote = "https://github.com/bazelbuild/rules_foreign_cc.git",
)

# Dependencies needed by rules_foreign_cc, in turn needed to build libpfm4.
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")

rules_foreign_cc_dependencies()

# Used by benchmark to capture metrics using perf counter counters.
git_repository(
name = "pfm",
build_file = "@llvm-raw//utils/bazel/third_party_build:pfm.BUILD",
remote = "https://git.code.sf.net/p/perfmon2/libpfm4",
tag = "v4.13.0",
)

git_repository(
Expand Down
18 changes: 18 additions & 0 deletions benchmark_build.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
diff --git a/BUILD.bazel b/BUILD.bazel
index 60d31d2..5789203 100644

This patch is applied to google/benchmark/BUILD.bazel, renaming the dependency
@libpfm//:libpfm to @pfm://pfm to be uniform with other dependencies
co-dependent on libpfm4.

--- a/BUILD.bazel
+++ b/BUILD.bazel
@@ -66,7 +66,7 @@ cc_library(
"//conditions:default": [],
}),
deps = select({
- ":perfcounters": ["@libpfm//:libpfm"],
+ ":perfcounters": ["@pfm//:pfm"],
"//conditions:default": [],
}),
)
6 changes: 3 additions & 3 deletions gematria/experiments/access_pattern_bm/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Experiment - access pattern benchmarks
# Experiment - access pattern benchmarks

This directory contains a set of microbenchmarks used to prototype data sets of
basic blocks and functions augmented with cache hit and miss ratios.
Expand All @@ -7,12 +7,12 @@ basic blocks and functions augmented with cache hit and miss ratios.

The benchmarks can be built using
```bash
bazel build -c opt //gematria/experiments/access_pattern_bm/...
bazel build -c opt --define pfm=true //gematria/experiments/access_pattern_bm/...
```
or, if timing measurements between flushing and non-flushing benchmarks are to
be compared, using
```bash
bazel build -c opt --define balance_flushing_time=true //gematria/experiments/access_pattern_bm/...
bazel build -c opt --define pfm=true --define balance_flushing_time=true //gematria/experiments/access_pattern_bm/...
```
and built binaries for each benchmark can be found down the corresponding
path in `bazel-bin`.
Expand Down

0 comments on commit 5b56fa1

Please sign in to comment.