Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bench): PoC of integration with zkalc #425

Merged
merged 12 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
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
22 changes: 20 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ jobs:
run: |
pacman -S --needed --noconfirm mingw-w64-x86_64-gmp mingw-w64-x86_64-llvm
nimble refresh --verbose -y
nimble install --verbose -y gmp@#head jsony asynctools yaml@1.1.0
nimble install --verbose -y gmp@#head jsony asynctools yaml@1.1.0 cliche

cd constantine
go mod download -modfile=go_test.mod
Expand All @@ -272,7 +272,7 @@ jobs:
shell: bash
run: |
nimble refresh --verbose -y
nimble install --verbose -y gmp@#head jsony asynctools yaml@1.1.0
nimble install --verbose -y gmp@#head jsony asynctools yaml@1.1.0 cliche

cd constantine
go mod download -modfile=go_test.mod
Expand Down Expand Up @@ -337,6 +337,24 @@ jobs:
cd constantine
CTT_ASM=0 cargo test -- --nocapture

- name: Compile Constantine Zkalc benchmark (no assembly)
# Skip 32-bit as that would need clang-multilib or -m32
# Skip Windows as clang throws fatal error LNK1107
if: matrix.target.BACKEND == 'NO_ASM' && matrix.target.cpu != 'i386' && runner.os != 'Windows'
shell: bash
run: |
cd constantine
CTT_ASM=0 nimble make_zkalc

- name: Compile Constantine Zkalc benchmark (with assembly)
# Skip 32-bit as that would need clang-multilib or -m32
# Skip Windows as clang throws fatal error LNK1107
if: matrix.target.BACKEND == 'ASM' && matrix.target.cpu != 'i386' && runner.os != 'Windows'
shell: bash
run: |
cd constantine
nimble make_zkalc

- name: Run Constantine in-depth tests (Unix - with GMP, with Assembly)
if: runner.os != 'Windows' && matrix.target.BACKEND == 'ASM'
shell: bash
Expand Down
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Executables shall be put in an ignored build/ directory
# Build artifacts shall be put in an ignored build/ directory
# Ignore dynamic, static libs and libtool archive files
# -----------------------------------------------------------------------------------------
build/
Expand Down Expand Up @@ -54,4 +54,5 @@ Cargo.lock
# Perf artifacts
# -----------------------------------------------------------------------------------------
perf.data
perf.data.old
perf.data.old
*.bench.json
5 changes: 3 additions & 2 deletions benchmarks/bench_elliptic_parallel_template.nim
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ proc multiAddParallelBench*(EC: typedesc, numInputs: int, iters: int) =
type BenchMsmContext*[EC] = object
tp: Threadpool
numInputs: int
coefs: seq[getBigInt(EC.F.Name, kScalarField)]
coefs: seq[getBigInt(EC.getName(), kScalarField)]
points: seq[affine(EC)]

proc createBenchMsmContext*(EC: typedesc, inputSizes: openArray[int]): BenchMsmContext[EC] =
Expand All @@ -66,6 +66,7 @@ proc createBenchMsmContext*(EC: typedesc, inputSizes: openArray[int]): BenchMsmC
const bits = EC.getScalarField().bits()
type ECaff = affine(EC)

result.numInputs = maxNumInputs
result.points = newSeq[ECaff](maxNumInputs)
result.coefs = newSeq[BigInt[bits]](maxNumInputs)

Expand All @@ -81,7 +82,7 @@ proc createBenchMsmContext*(EC: typedesc, inputSizes: openArray[int]): BenchMsmC
var tmp = threadRng.random_unsafe(EC)
tmp.clearCofactor()
points[i].affine(tmp)
coefs[i] = rng.random_unsafe(BigInt[bits])
coefs[i] = threadRng.random_unsafe(BigInt[bits])

let chunks = balancedChunksPrioNumber(0, maxNumInputs, result.tp.numThreads)

Expand Down
Loading
Loading