-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add pasta bindings * add tests and benches * refactor: re-organize build script --------- Co-authored-by: Hanting Zhang <[email protected]> Co-authored-by: François Garillot <[email protected]>
- Loading branch information
1 parent
a584fbb
commit 0965aeb
Showing
13 changed files
with
547 additions
and
85 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
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,66 @@ | ||
// Copyright Supranational LLC | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
#![allow(unused_mut)] | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use grumpkin_msm::pasta::utils::{gen_points, gen_scalars}; | ||
|
||
#[cfg(feature = "cuda")] | ||
use grumpkin_msm::cuda_available; | ||
|
||
fn criterion_benchmark(c: &mut Criterion) { | ||
let bench_npow: usize = std::env::var("BENCH_NPOW") | ||
.unwrap_or("17".to_string()) | ||
.parse() | ||
.unwrap(); | ||
let npoints: usize = 1 << bench_npow; | ||
|
||
// println!("generating {} random points, just hang on...", npoints); | ||
let mut points = gen_points(npoints); | ||
let mut scalars = gen_scalars(npoints); | ||
|
||
#[cfg(feature = "cuda")] | ||
{ | ||
unsafe { grumpkin_msm::CUDA_OFF = true }; | ||
} | ||
|
||
let mut group = c.benchmark_group("CPU"); | ||
group.sample_size(10); | ||
|
||
group.bench_function(format!("2**{} points", bench_npow), |b| { | ||
b.iter(|| { | ||
let _ = grumpkin_msm::pasta::pallas(&points, &scalars); | ||
}) | ||
}); | ||
|
||
group.finish(); | ||
|
||
#[cfg(feature = "cuda")] | ||
if unsafe { cuda_available() } { | ||
unsafe { grumpkin_msm::CUDA_OFF = false }; | ||
|
||
const EXTRA: usize = 5; | ||
let bench_npow = bench_npow + EXTRA; | ||
let npoints: usize = 1 << bench_npow; | ||
|
||
while points.len() < npoints { | ||
points.append(&mut points.clone()); | ||
} | ||
scalars.append(&mut gen_scalars(npoints - scalars.len())); | ||
|
||
let mut group = c.benchmark_group("GPU"); | ||
group.sample_size(20); | ||
|
||
group.bench_function(format!("2**{} points", bench_npow), |b| { | ||
b.iter(|| { | ||
let _ = grumpkin_msm::pasta::pallas(&points, &scalars); | ||
}) | ||
}); | ||
|
||
group.finish(); | ||
} | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
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,24 @@ | ||
// Copyright Supranational LLC | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <cuda.h> | ||
|
||
#include <ec/jacobian_t.hpp> | ||
#include <ec/xyzz_t.hpp> | ||
|
||
#include <ff/pasta.hpp> | ||
|
||
typedef jacobian_t<pallas_t> point_t; | ||
typedef xyzz_t<pallas_t> bucket_t; | ||
typedef bucket_t::affine_t affine_t; | ||
typedef vesta_t scalar_t; | ||
|
||
#include <msm/pippenger.cuh> | ||
|
||
#ifndef __CUDA_ARCH__ | ||
extern "C" | ||
RustError cuda_pippenger_pallas(point_t *out, const affine_t points[], size_t npoints, | ||
const scalar_t scalars[]) | ||
{ return mult_pippenger<bucket_t>(out, points, npoints, scalars); } | ||
#endif |
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,24 @@ | ||
// Copyright Supranational LLC | ||
// Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include <cuda.h> | ||
|
||
#include <ec/jacobian_t.hpp> | ||
#include <ec/xyzz_t.hpp> | ||
|
||
#include <ff/pasta.hpp> | ||
|
||
typedef jacobian_t<vesta_t> point_t; | ||
typedef xyzz_t<vesta_t> bucket_t; | ||
typedef bucket_t::affine_t affine_t; | ||
typedef pallas_t scalar_t; | ||
|
||
#include <msm/pippenger.cuh> | ||
|
||
#ifndef __CUDA_ARCH__ | ||
extern "C" | ||
RustError cuda_pippenger_vesta(point_t *out, const affine_t points[], size_t npoints, | ||
const scalar_t scalars[]) | ||
{ return mult_pippenger<bucket_t>(out, points, npoints, scalars); } | ||
#endif |
File renamed without changes.
Oops, something went wrong.