Skip to content

Commit

Permalink
Merge pull request #476 from pq-code-package/cbmc-test
Browse files Browse the repository at this point in the history
CBMC: add `tests cbmc` command
  • Loading branch information
mkannwischer authored Dec 3, 2024
2 parents 6ce990f + f88eeb6 commit 425bc20
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
3 changes: 1 addition & 2 deletions .github/actions/cbmc/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ runs:
- name: Run CBMC proofs (MLKEM_K=${{ inputs.mlkem_k }})
shell: ${{ env.SHELL }}
run: |
cd cbmc/proofs;
echo "::group::cbmc_${{ inputs.mlkem_k }}"
MLKEM_K=${{ inputs.mlkem_k }} ./run-cbmc-proofs.py --summarize --no-coverage -j8;
tests cbmc --k ${{ inputs.mlkem_k }};
echo "::endgroup::"
20 changes: 20 additions & 0 deletions scripts/lib/mlkem_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self):
self.run = True
self.exec_wrapper = ""
self.run_as_root = ""
self.k = "ALL"


class Base:
Expand Down Expand Up @@ -709,3 +710,22 @@ def all(opt: bool):
exit_code = exit_code or all(True)

exit(exit_code)

def cbmc(self, k):
config_logger(self.verbose)
def run_cbmc(mlkem_k):
envvars = {"MLKEM_K": mlkem_k}
cpucount = os.cpu_count()
p = subprocess.Popen(
["python3", "run-cbmc-proofs.py", "--summarize", "--no-coverage", f"-j{cpucount}"],
cwd="cbmc/proofs",
env=os.environ.copy() | envvars,
)
p.communicate()
assert p.returncode == 0
if k == "ALL":
run_cbmc("2")
run_cbmc("3")
run_cbmc("4")
else:
run_cbmc(k)
23 changes: 23 additions & 0 deletions scripts/tests
Original file line number Diff line number Diff line change
Expand Up @@ -291,5 +291,28 @@ def all(
Tests(opts).all(func, kat, nistkat, acvp)


@cli.command(
short_help="Run the CBMC proofs for all parameter sets",
context_settings={"show_default": True},
)
@click.make_pass_decorator(Options, ensure=True)
@add_options(
[
click.option(
"--k",
expose_value=False,
nargs=1,
type=click.Choice(["2", "3", "4", "ALL"]),
show_default=True,
default="ALL",
help="MLKEM parameter set (MLKEM_K).",
callback=__callback("k"),
)
]
)
def cbmc(opts: Options):
Tests(opts).cbmc(opts.k)


if __name__ == "__main__":
cli()

17 comments on commit 425bc20

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arm Cortex-A76 (Raspberry Pi 5) benchmarks

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 29175 cycles 29176 cycles 1.00
ML-KEM-512 encaps 35852 cycles 35851 cycles 1.00
ML-KEM-512 decaps 46653 cycles 46653 cycles 1
ML-KEM-768 keypair 49174 cycles 49177 cycles 1.00
ML-KEM-768 encaps 55839 cycles 55840 cycles 1.00
ML-KEM-768 decaps 71008 cycles 71009 cycles 1.00
ML-KEM-1024 keypair 72211 cycles 72213 cycles 1.00
ML-KEM-1024 encaps 81519 cycles 81523 cycles 1.00
ML-KEM-1024 decaps 102032 cycles 102027 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMD EPYC 3rd gen (c6a)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 18152 cycles 18207 cycles 1.00
ML-KEM-512 encaps 23137 cycles 23125 cycles 1.00
ML-KEM-512 decaps 30396 cycles 30388 cycles 1.00
ML-KEM-768 keypair 31050 cycles 31088 cycles 1.00
ML-KEM-768 encaps 33990 cycles 33989 cycles 1.00
ML-KEM-768 decaps 44804 cycles 44894 cycles 1.00
ML-KEM-1024 keypair 44728 cycles 44796 cycles 1.00
ML-KEM-1024 encaps 50036 cycles 50021 cycles 1.00
ML-KEM-1024 decaps 64742 cycles 64761 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMD EPYC 4th gen (c7a)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 15076 cycles 15070 cycles 1.00
ML-KEM-512 encaps 19754 cycles 19759 cycles 1.00
ML-KEM-512 decaps 26413 cycles 26401 cycles 1.00
ML-KEM-768 keypair 25586 cycles 25738 cycles 0.99
ML-KEM-768 encaps 28233 cycles 28192 cycles 1.00
ML-KEM-768 decaps 38203 cycles 38199 cycles 1.00
ML-KEM-1024 keypair 35635 cycles 35662 cycles 1.00
ML-KEM-1024 encaps 41255 cycles 41237 cycles 1.00
ML-KEM-1024 decaps 54608 cycles 54744 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intel Xeon 3rd gen (c6i)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 20326 cycles 20325 cycles 1.00
ML-KEM-512 encaps 27129 cycles 27127 cycles 1.00
ML-KEM-512 decaps 36210 cycles 36213 cycles 1.00
ML-KEM-768 keypair 34834 cycles 34857 cycles 1.00
ML-KEM-768 encaps 38193 cycles 38217 cycles 1.00
ML-KEM-768 decaps 51360 cycles 51402 cycles 1.00
ML-KEM-1024 keypair 48074 cycles 48094 cycles 1.00
ML-KEM-1024 encaps 54249 cycles 54247 cycles 1.00
ML-KEM-1024 decaps 72137 cycles 72161 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intel Xeon 4th gen (c7i)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 13864 cycles 13918 cycles 1.00
ML-KEM-512 encaps 18199 cycles 18219 cycles 1.00
ML-KEM-512 decaps 24094 cycles 24133 cycles 1.00
ML-KEM-768 keypair 22428 cycles 22423 cycles 1.00
ML-KEM-768 encaps 24506 cycles 24575 cycles 1.00
ML-KEM-768 decaps 32521 cycles 32626 cycles 1.00
ML-KEM-1024 keypair 32155 cycles 32145 cycles 1.00
ML-KEM-1024 encaps 35727 cycles 35673 cycles 1.00
ML-KEM-1024 decaps 47393 cycles 47323 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graviton3

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 19032 cycles 19032 cycles 1
ML-KEM-512 encaps 23843 cycles 23845 cycles 1.00
ML-KEM-512 decaps 31228 cycles 31230 cycles 1.00
ML-KEM-768 keypair 32332 cycles 32333 cycles 1.00
ML-KEM-768 encaps 36084 cycles 36083 cycles 1.00
ML-KEM-768 decaps 46492 cycles 46493 cycles 1.00
ML-KEM-1024 keypair 46970 cycles 46969 cycles 1.00
ML-KEM-1024 encaps 53090 cycles 53086 cycles 1.00
ML-KEM-1024 decaps 67403 cycles 67405 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arm Cortex-A55 (Snapdragon 888) benchmarks

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 58051 cycles 58016 cycles 1.00
ML-KEM-512 encaps 65739 cycles 65688 cycles 1.00
ML-KEM-512 decaps 84356 cycles 84278 cycles 1.00
ML-KEM-768 keypair 98398 cycles 98227 cycles 1.00
ML-KEM-768 encaps 110291 cycles 110272 cycles 1.00
ML-KEM-768 decaps 136959 cycles 136639 cycles 1.00
ML-KEM-1024 keypair 149545 cycles 149130 cycles 1.00
ML-KEM-1024 encaps 166765 cycles 166256 cycles 1.00
ML-KEM-1024 decaps 203329 cycles 202343 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intel Xeon 4th gen (c7i) (no-opt)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 36182 cycles 36296 cycles 1.00
ML-KEM-512 encaps 46391 cycles 46306 cycles 1.00
ML-KEM-512 decaps 61856 cycles 61607 cycles 1.00
ML-KEM-768 keypair 59068 cycles 58855 cycles 1.00
ML-KEM-768 encaps 73046 cycles 72584 cycles 1.01
ML-KEM-768 decaps 91650 cycles 91279 cycles 1.00
ML-KEM-1024 keypair 88479 cycles 88811 cycles 1.00
ML-KEM-1024 encaps 109304 cycles 109324 cycles 1.00
ML-KEM-1024 decaps 133582 cycles 132904 cycles 1.01

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMD EPYC 4th gen (c7a) (no-opt)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 45709 cycles 45946 cycles 0.99
ML-KEM-512 encaps 58758 cycles 58762 cycles 1.00
ML-KEM-512 decaps 79981 cycles 79995 cycles 1.00
ML-KEM-768 keypair 74596 cycles 74601 cycles 1.00
ML-KEM-768 encaps 91419 cycles 91466 cycles 1.00
ML-KEM-768 decaps 120104 cycles 120171 cycles 1.00
ML-KEM-1024 keypair 109864 cycles 109869 cycles 1.00
ML-KEM-1024 encaps 130993 cycles 130986 cycles 1.00
ML-KEM-1024 decaps 167584 cycles 167659 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AMD EPYC 3rd gen (c6a) (no-opt)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 52315 cycles 52330 cycles 1.00
ML-KEM-512 encaps 67782 cycles 67782 cycles 1
ML-KEM-512 decaps 92653 cycles 92630 cycles 1.00
ML-KEM-768 keypair 84684 cycles 84688 cycles 1.00
ML-KEM-768 encaps 104896 cycles 104906 cycles 1.00
ML-KEM-768 decaps 138153 cycles 137848 cycles 1.00
ML-KEM-1024 keypair 125485 cycles 125830 cycles 1.00
ML-KEM-1024 encaps 149721 cycles 149763 cycles 1.00
ML-KEM-1024 decaps 192289 cycles 192318 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intel Xeon 3rd gen (c6i) (no-opt)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 56710 cycles 56724 cycles 1.00
ML-KEM-512 encaps 71778 cycles 71764 cycles 1.00
ML-KEM-512 decaps 96333 cycles 96315 cycles 1.00
ML-KEM-768 keypair 91872 cycles 91789 cycles 1.00
ML-KEM-768 encaps 111635 cycles 111396 cycles 1.00
ML-KEM-768 decaps 144630 cycles 144613 cycles 1.00
ML-KEM-1024 keypair 134508 cycles 134534 cycles 1.00
ML-KEM-1024 encaps 159842 cycles 159964 cycles 1.00
ML-KEM-1024 decaps 201292 cycles 201356 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graviton2

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 29175 cycles 29179 cycles 1.00
ML-KEM-512 encaps 35860 cycles 35864 cycles 1.00
ML-KEM-512 decaps 46665 cycles 46672 cycles 1.00
ML-KEM-768 keypair 49225 cycles 49199 cycles 1.00
ML-KEM-768 encaps 55892 cycles 55871 cycles 1.00
ML-KEM-768 decaps 71026 cycles 70992 cycles 1.00
ML-KEM-1024 keypair 72173 cycles 72290 cycles 1.00
ML-KEM-1024 encaps 81620 cycles 81760 cycles 1.00
ML-KEM-1024 decaps 102066 cycles 102284 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graviton4

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 18267 cycles 18266 cycles 1.00
ML-KEM-512 encaps 22476 cycles 22477 cycles 1.00
ML-KEM-512 decaps 29398 cycles 29400 cycles 1.00
ML-KEM-768 keypair 30773 cycles 30773 cycles 1
ML-KEM-768 encaps 34057 cycles 34059 cycles 1.00
ML-KEM-768 decaps 43907 cycles 43910 cycles 1.00
ML-KEM-1024 keypair 44486 cycles 44482 cycles 1.00
ML-KEM-1024 encaps 50206 cycles 50207 cycles 1.00
ML-KEM-1024 decaps 63637 cycles 63631 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graviton3 (no-opt)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 45364 cycles 45372 cycles 1.00
ML-KEM-512 encaps 56172 cycles 56178 cycles 1.00
ML-KEM-512 decaps 75093 cycles 75100 cycles 1.00
ML-KEM-768 keypair 74870 cycles 74874 cycles 1.00
ML-KEM-768 encaps 89191 cycles 89188 cycles 1.00
ML-KEM-768 decaps 114560 cycles 114552 cycles 1.00
ML-KEM-1024 keypair 111077 cycles 111084 cycles 1.00
ML-KEM-1024 encaps 129998 cycles 129999 cycles 1.00
ML-KEM-1024 decaps 162583 cycles 162589 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graviton4 (no-opt)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 41913 cycles 41899 cycles 1.00
ML-KEM-512 encaps 51763 cycles 51761 cycles 1.00
ML-KEM-512 decaps 69327 cycles 69324 cycles 1.00
ML-KEM-768 keypair 69072 cycles 69050 cycles 1.00
ML-KEM-768 encaps 82683 cycles 82685 cycles 1.00
ML-KEM-768 decaps 106478 cycles 106473 cycles 1.00
ML-KEM-1024 keypair 102441 cycles 102250 cycles 1.00
ML-KEM-1024 encaps 120643 cycles 120658 cycles 1.00
ML-KEM-1024 decaps 150595 cycles 150706 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Graviton2 (no-opt)

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 71125 cycles 71118 cycles 1.00
ML-KEM-512 encaps 87854 cycles 87833 cycles 1.00
ML-KEM-512 decaps 118170 cycles 118145 cycles 1.00
ML-KEM-768 keypair 117630 cycles 117237 cycles 1.00
ML-KEM-768 encaps 139373 cycles 139206 cycles 1.00
ML-KEM-768 decaps 180122 cycles 180051 cycles 1.00
ML-KEM-1024 keypair 175417 cycles 173974 cycles 1.01
ML-KEM-1024 encaps 202895 cycles 201819 cycles 1.01
ML-KEM-1024 decaps 254246 cycles 253360 cycles 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@oqs-bot
Copy link

@oqs-bot oqs-bot commented on 425bc20 Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arm Cortex-A72 (Raspberry Pi 4) benchmarks

Benchmark suite Current: 425bc20 Previous: 6ce990f Ratio
ML-KEM-512 keypair 51511 cycles 51271 cycles 1.00
ML-KEM-512 encaps 58337 cycles 58339 cycles 1.00
ML-KEM-512 decaps 74889 cycles 74884 cycles 1.00
ML-KEM-768 keypair 87085 cycles 87804 cycles 0.99
ML-KEM-768 encaps 95891 cycles 97050 cycles 0.99
ML-KEM-768 decaps 120427 cycles 120020 cycles 1.00
ML-KEM-1024 keypair 132049 cycles 132374 cycles 1.00
ML-KEM-1024 encaps 145650 cycles 146232 cycles 1.00
ML-KEM-1024 decaps 177164 cycles 178060 cycles 0.99

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.