Skip to content

Commit

Permalink
Configure microbenchmarks to dry-run under CI. (#294)
Browse files Browse the repository at this point in the history
 * Adds a `--define run_under_ci=1` to the `bazel test` CI invocation.
 * Benchmarks are dry-run when `--define run_under_ci=1` is set.
  • Loading branch information
virajbshah authored Feb 17, 2025
1 parent 9ffef41 commit dbdb011
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,5 @@ jobs:
- name: Run build
run: bazel build -c ${{ matrix.build-config }} ...
- name: Run tests
run: bazel test -c ${{ matrix.build-config }} --test_tag_filters="-perf_counters" --test_output=errors ...
run: bazel test -c ${{ matrix.build-config }} --define run_under_ci=1 --test_tag_filters="-perf_counters" --test_output=errors ...

19 changes: 19 additions & 0 deletions gematria/experiments/access_pattern_bm/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ package(
features = ["layering_checks"],
)

# Used to dry-run benchmarks when they are invoked as part of continuous
# integration checks as `bazel test --define run_under_ci=1 ...`.
config_setting(
name = "run_under_ci",
define_values = {
"run_under_ci": "1",
},
)

# The macro BALANCE_FLUSHING_TIME is defined when this matches. This enables the
# lines of code that create and flush mock data structures in *_NoFlush
# benchmarks to cancel out the time spent doing those operations as compared to
Expand All @@ -18,6 +27,11 @@ COMMON_TEST_HDRS = ["configuration.h"]

FEATURE_OPTS = ["-mclflushopt"]

BENCHMARK_CI_OPTS = select({
":run_under_ci": ["--benchmark_dry_run"],
"//conditions:default": [],
})

BALANCE_FLUSHING_TIME_OPTS = select({
":balance_flushing_time": ["-DGEMATRIA_EXPERIMENTS_ACCESS_PATTERN_BM_BALANCE_FLUSHING_TIME"],
"//conditions:default": [],
Expand All @@ -42,6 +56,7 @@ cc_test(
"linked_list.h",
"linked_list_test.cc",
],
args = BENCHMARK_CI_OPTS,
copts = BALANCE_FLUSHING_TIME_OPTS,
deps = [
":linked_list",
Expand Down Expand Up @@ -70,6 +85,7 @@ cc_test(
"contiguous_matrix.h",
"contiguous_matrix_test.cc",
],
args = BENCHMARK_CI_OPTS,
copts = BALANCE_FLUSHING_TIME_OPTS,
deps = [
":contiguous_matrix",
Expand Down Expand Up @@ -97,6 +113,7 @@ cc_test(
"vec_of_vec_matrix.h",
"vec_of_vec_matrix_test.cc",
],
args = BENCHMARK_CI_OPTS,
copts = BALANCE_FLUSHING_TIME_OPTS,
deps = [
":vec_of_vec_matrix",
Expand All @@ -112,6 +129,7 @@ cc_test(
"stl_container.h",
"stl_container_test.cc",
],
args = BENCHMARK_CI_OPTS,
copts = BALANCE_FLUSHING_TIME_OPTS + FEATURE_OPTS, # Since templated functions using _mm_clflushopt are defined in the header.
target_compatible_with = [
"@platforms//cpu:x86_64",
Expand All @@ -130,6 +148,7 @@ cc_test(
"stl_assoc_container.h",
"stl_assoc_container_test.cc",
],
args = BENCHMARK_CI_OPTS,
copts = BALANCE_FLUSHING_TIME_OPTS + FEATURE_OPTS, # Since templated functions using _mm_clflushopt are defined in the header.
target_compatible_with = [
"@platforms//cpu:x86_64",
Expand Down

0 comments on commit dbdb011

Please sign in to comment.