-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
### Description: Add a basic benchmark setup: - `benchmark` command, which has a theorem-like syntax, but doesn't get added to the environment, and runs the proof 5 times, reporting both the individual and average runtime, - similarly, a `logHeartbeats` tactic combinator, which measures the heartbeats used by an arbitrary tactic. - Add a benchmark folder, with files for SHA512 runs with: 150, 225, and 400 steps (which are the numbers I've been reporting so far) - Adds a `make benchmark` Make-target, to build the aforementioned files. Crucially, this target is *not* part of `make all`, for all our sanity's sake (running 400 steps of SHA512 for 5 times takes a while) ### Testing: What tests have been run? Did `make all` succeed for your changes? Was conformance testing successful on an Aarch64 machine? yes ### License: By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. --------- Co-authored-by: Siddharth <[email protected]> Co-authored-by: Shilpi Goel <[email protected]>
- Loading branch information
1 parent
c30cf55
commit 4414dc5
Showing
12 changed files
with
150 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/- | ||
Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Author(s): Alex Keizer | ||
-/ | ||
import Benchmarks.SHA512_150 | ||
import Benchmarks.SHA512_225 | ||
import Benchmarks.SHA512_400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/- | ||
Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Author(s): Alex Keizer | ||
-/ | ||
import Lean | ||
|
||
open Lean Parser.Command Elab.Command | ||
|
||
elab "benchmark" id:ident declSig:optDeclSig val:declVal : command => do | ||
let stx ← `(command| example $declSig:optDeclSig $val:declVal ) | ||
|
||
let n := 5 | ||
let mut runTimes := #[] | ||
let mut totalRunTime := 0 | ||
for _ in [0:n] do | ||
let start ← IO.monoMsNow | ||
elabCommand stx | ||
let endTime ← IO.monoMsNow | ||
let runTime := endTime - start | ||
runTimes := runTimes.push runTime | ||
totalRunTime := totalRunTime + runTime | ||
|
||
let avg := totalRunTime.toFloat / n.toFloat / 1000 | ||
let geomean := (totalRunTime.toFloat.pow (1.0 / n.toFloat)) / 1000.0 | ||
logInfo m!"\ | ||
{id}: | ||
average runtime over {n} runs: | ||
{avg}s | ||
geomean over {n} runs: | ||
{geomean}s | ||
indidividual runtimes: | ||
{runTimes} | ||
" | ||
|
||
/-- The default `maxHeartbeats` setting. | ||
NOTE: even if the actual default value changes at some point in the future, | ||
this value should *NOT* be updated, to ensure the percentages we've reported | ||
in previous versions remain comparable. -/ | ||
def defaultMaxHeartbeats : Nat := 200000 | ||
|
||
open Elab.Tactic in | ||
elab "logHeartbeats" tac:tactic : tactic => do | ||
let ((), heartbeats) ← withHeartbeats <| | ||
evalTactic tac | ||
let percent := heartbeats / (defaultMaxHeartbeats * 10) | ||
|
||
logInfo m!"used {heartbeats / 1000} heartbeats ({percent}% of the default maximum)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/- | ||
Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Author(s): Alex Keizer | ||
-/ | ||
import Proofs.SHA512.SHA512StepLemmas | ||
|
||
/-! | ||
### Symbolic Simulation for SHA512 | ||
This file sets up the basic shape of a simulation of SHA512 | ||
for a set number of instructions | ||
-/ | ||
|
||
namespace Benchmarks | ||
|
||
def SHA512Bench (nSteps : Nat) : Prop := | ||
∀ (s0 sf : ArmState) | ||
(_h_s0_pc : read_pc s0 = 0x1264c4#64) | ||
(_h_s0_err : read_err s0 = StateError.None) | ||
(_h_s0_sp_aligned : CheckSPAlignment s0) | ||
(_h_s0_program : s0.program = SHA512.program) | ||
(_h_run : sf = run nSteps s0), | ||
r StateField.ERR sf = StateError.None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/- | ||
Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Author(s): Alex Keizer | ||
-/ | ||
import Tactics.Sym | ||
import Benchmarks.Command | ||
import Benchmarks.SHA512 | ||
|
||
open Benchmarks | ||
|
||
benchmark sha512_150_instructions : SHA512Bench 150 := fun s0 => by | ||
intros | ||
sym_n 150 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/- | ||
Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Author(s): Alex Keizer | ||
-/ | ||
import Tactics.Sym | ||
import Benchmarks.Command | ||
import Benchmarks.SHA512 | ||
|
||
open Benchmarks | ||
|
||
benchmark sha512_225_instructions : SHA512Bench 225 := fun s0 => by | ||
intros | ||
sym_n 225 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/- | ||
Copyright (c) 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
Released under Apache 2.0 license as described in the file LICENSE. | ||
Author(s): Alex Keizer | ||
-/ | ||
import Tactics.Sym | ||
import Benchmarks.SHA512 | ||
import Benchmarks.Command | ||
|
||
open Benchmarks | ||
|
||
benchmark sha512_400_instructions : SHA512Bench 400 := fun s0 => by | ||
intros | ||
sym_n 400 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters