-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into address-normalization-simproc
- Loading branch information
Showing
21 changed files
with
259 additions
and
186 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
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,54 @@ | ||
/- | ||
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 | ||
-- geomean = exp(log((a₁ a₂ ... aₙ)^1/n)) = | ||
-- exp(1/n * (log a₁ + log a₂ + log aₙ)). | ||
let mut totalRunTimeLog := 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 | ||
totalRunTimeLog := totalRunTimeLog + Float.log runTime.toFloat | ||
|
||
let avg := totalRunTime.toFloat / n.toFloat / 1000 | ||
let geomean := (Float.exp (totalRunTimeLog / 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
Oops, something went wrong.