Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ end
using ADFixtures
import DifferentiationInterface as DI

# The history workflow times each tag with that tag's own `test/ADFixtures`
# (EpiAwarePackageTools 0.5.2). Fixtures from before this suite's registry
# calls, those of v0.1.0, cannot build its gradient grid or matrix cases,
# so such a revision times the convolution body alone.
const _CURRENT_FIXTURES = isdefined(ADFixtures, :benchmarked_backends)
_CURRENT_FIXTURES || @warn "test/ADFixtures predates this suite: " *
"timing the convolution body alone"

# `BENCHMARK_TIER`: `pr`, the default when unset or empty, is small enough
# for a pull request job; `full` times everything below. `pr` leaves out the
# registry scenarios, the `NoAdjoint` and `loop` arms, the forward modes and
Expand Down Expand Up @@ -78,7 +86,8 @@ const _PR_BACKENDS = ("ForwardDiff", "Mooncake reverse", "Enzyme reverse")
# `BENCHMARK_MATRIX=false` also leaves out the matrix cases' gradients,
# so a job times only the registry grid; the `primal` groups follow
# `BENCHMARK_BACKENDS` alone.
const _ALL_BACKENDS = ADFixtures.benchmarked_backends()
const _ALL_BACKENDS = _CURRENT_FIXTURES ?
ADFixtures.benchmarked_backends() : NamedTuple[]
const _SELECTED = let spec = strip(get(ENV, "BENCHMARK_BACKENDS", ""))
if isempty(spec)
nothing
Expand All @@ -88,7 +97,7 @@ const _SELECTED = let spec = strip(get(ENV, "BENCHMARK_BACKENDS", ""))
)
known = Set(["primal"; [e.name for e in _ALL_BACKENDS]])
unknown = setdiff(names, known)
isempty(unknown) || error(
isempty(unknown) || !_CURRENT_FIXTURES || error(
"unknown BENCHMARK_BACKENDS $(join(sort!(collect(unknown)), ", "))"
)
names
Expand All @@ -100,7 +109,7 @@ end
# `BENCHMARK_BACKENDS`.
const _ONLY = let only = String(strip(get(ENV, "BENCHMARK_AD_BACKEND", "")))
isempty(only) || only in [e.name for e in _ALL_BACKENDS] ||
error("unknown BENCHMARK_AD_BACKEND $only")
!_CURRENT_FIXTURES || error("unknown BENCHMARK_AD_BACKEND $only")
only
end
_selected(name) = !(_AD_ONLY && name == "primal") &&
Expand Down Expand Up @@ -168,7 +177,8 @@ using ADFixtures: MatrixCases

# Left out with `BENCHMARK_MATRIX=false` (see `BENCHMARK_BACKENDS` above)
# and in the `ad` tier.
const _MATRIX = get(ENV, "BENCHMARK_MATRIX", "true") != "false" && !_AD_ONLY
const _MATRIX = get(ENV, "BENCHMARK_MATRIX", "true") != "false" &&
!_AD_ONLY && _CURRENT_FIXTURES
# The `pr` tier times only the `rule` arm, on its three backends.
const _MATRIX_ARMS = _FULL ? ("rule", "NoAdjoint", "loop") : ("rule",)
const _MATRIX_BACKENDS = _FULL ? BENCHMARK_BACKENDS :
Expand Down
Loading