Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanting Zhang committed Feb 19, 2024
1 parent be0c79d commit c05be74
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 42 deletions.
69 changes: 34 additions & 35 deletions msm/pippenger.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -532,10 +532,9 @@ public:
d_points = (affine_h *)&d_total_blob[offset];
}

RustError invoke(point_t& out, const affine_t* points_, size_t npoints,
const scalar_t* scalars, bool mont = true,
size_t ffi_affine_sz = sizeof(affine_t))
{
RustError invoke(point_t &out, const affine_t points[], size_t npoints,
const scalar_t *scalars, size_t nscalars,
uint32_t pidx[], bool mont = true, size_t ffi_affine_sz = sizeof(affine_t)) {
setup_scratch(points, npoints, nscalars, pidx);

std::vector<result_t> res(nwins);
Expand All @@ -554,7 +553,7 @@ public:
gpu[2].HtoD(&d_scalars[d_off], &scalars[h_off], num);
if (pidx)
gpu[2].HtoD(&d_pidx[0], &pidx[h_off], num);
digits(&d_scalars[0], num, d_digits, d_temps, mont);
digits(&d_scalars[0], num, d_digits, d_temps, mont, d_pidx);
gpu[2].record(ev);

if (points)
Expand Down Expand Up @@ -595,7 +594,7 @@ public:

gpu[2].wait(ev);
digits(&d_scalars[scalars ? 0 : h_off], num,
d_digits, d_temps, mont);
d_digits, d_temps, mont, d_pidx);
gpu[2].record(ev);

if (points) {
Expand Down Expand Up @@ -632,35 +631,35 @@ public:
return RustError{cudaSuccess};
}

RustError invoke(point_t& out, const affine_t* points, size_t npoints,
gpu_ptr_t<scalar_t> scalars, bool mont = true,
size_t ffi_affine_sz = sizeof(affine_t))
{
d_scalars = scalars;
return invoke(out, points, npoints, nullptr, mont, ffi_affine_sz);
}

RustError invoke(point_t& out, vec_t<scalar_t> scalars, bool mont = true)
{ return invoke(out, nullptr, scalars.size(), scalars, mont); }

RustError invoke(point_t& out, vec_t<affine_t> points,
const scalar_t* scalars, bool mont = true,
size_t ffi_affine_sz = sizeof(affine_t))
{ return invoke(out, points, points.size(), scalars, mont, ffi_affine_sz); }

RustError invoke(point_t& out, vec_t<affine_t> points,
vec_t<scalar_t> scalars, bool mont = true,
size_t ffi_affine_sz = sizeof(affine_t))
{ return invoke(out, points, points.size(), scalars, mont, ffi_affine_sz); }

RustError invoke(point_t& out, const std::vector<affine_t>& points,
const std::vector<scalar_t>& scalars, bool mont = true,
size_t ffi_affine_sz = sizeof(affine_t))
{
return invoke(out, points.data(),
std::min(points.size(), scalars.size()),
scalars.data(), mont, ffi_affine_sz);
}
// RustError invoke(point_t& out, const affine_t* points, size_t npoints,
// gpu_ptr_t<scalar_t> scalars, bool mont = true,
// size_t ffi_affine_sz = sizeof(affine_t))
// {
// d_scalars = scalars;
// return invoke(out, points, npoints, nullptr, mont, ffi_affine_sz);
// }

// RustError invoke(point_t& out, vec_t<scalar_t> scalars, bool mont = true)
// { return invoke(out, nullptr, scalars.size(), scalars, mont); }

// RustError invoke(point_t& out, vec_t<affine_t> points,
// const scalar_t* scalars, bool mont = true,
// size_t ffi_affine_sz = sizeof(affine_t))
// { return invoke(out, points, points.size(), scalars, mont, ffi_affine_sz); }

// RustError invoke(point_t& out, vec_t<affine_t> points,
// vec_t<scalar_t> scalars, bool mont = true,
// size_t ffi_affine_sz = sizeof(affine_t))
// { return invoke(out, points, points.size(), scalars, mont, ffi_affine_sz); }

// RustError invoke(point_t& out, const std::vector<affine_t>& points,
// const std::vector<scalar_t>& scalars, bool mont = true,
// size_t ffi_affine_sz = sizeof(affine_t))
// {
// return invoke(out, points.data(),
// std::min(points.size(), scalars.size()),
// scalars.data(), mont, ffi_affine_sz);
// }

private:
point_t integrate_row(const result_t& row, uint32_t lsbits)
Expand Down
11 changes: 6 additions & 5 deletions poc/msm-cuda/benches/msm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ fn criterion_benchmark_fp2(c: &mut Criterion) {
let name = format!("2**{}", npoints_npow);
group.bench_function(name, |b| {
b.iter(|| {
let _ = multi_scalar_mult_fp2_arkworks(&points.as_slice(), unsafe {
std::mem::transmute::<&[_], &[BigInteger256]>(
scalars.as_slice(),
)
});
let _ =
multi_scalar_mult_fp2_arkworks(&points.as_slice(), unsafe {
std::mem::transmute::<&[_], &[BigInteger256]>(
scalars.as_slice(),
)
});
})
});

Expand Down
5 changes: 3 additions & 2 deletions poc/msm-cuda/cuda/pippenger_inf.cu
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ RustError::by_value mult_pippenger_inf(point_t* out, const affine_t points[],
size_t npoints, const scalar_t scalars[],
size_t ffi_affine_sz)
{
return mult_pippenger<bucket_t>(out, points, npoints, scalars, false, ffi_affine_sz);
return mult_pippenger<bucket_t>(out, points, npoints, scalars, npoints, nullptr, false);
}

#if defined(FEATURE_BLS12_381) || defined(FEATURE_BLS12_377)
Expand All @@ -43,6 +43,7 @@ RustError::by_value mult_pippenger_fp2_inf(point_fp2_t* out, const affine_fp2_t
size_t npoints, const scalar_t scalars[],
size_t ffi_affine_sz)
{
return mult_pippenger<bucket_fp2_t>(out, points, npoints, scalars, false, ffi_affine_sz);
return mult_pippenger<bucket_fp2_t>(out, points, npoints, scalars, npoints, nullptr, false);

}
#endif

0 comments on commit c05be74

Please sign in to comment.