mirror of
https://github.com/pseXperiments/icicle.git
synced 2026-01-08 23:17:54 -05:00
Feat/m31 (#547)
This PR adds support of the m31 Field --------- Co-authored-by: Jeremy Felder <jeremy.felder1@gmail.com>
This commit is contained in:
@@ -9,6 +9,7 @@ members = [
|
||||
"icicle-curves/icicle-bn254",
|
||||
"icicle-curves/icicle-grumpkin",
|
||||
"icicle-fields/icicle-babybear",
|
||||
"icicle-fields/icicle-m31",
|
||||
"icicle-fields/icicle-stark252",
|
||||
"icicle-hash",
|
||||
]
|
||||
|
||||
19
wrappers/rust/icicle-fields/icicle-m31/Cargo.toml
Normal file
19
wrappers/rust/icicle-fields/icicle-m31/Cargo.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "icicle-m31"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
description = "Rust wrapper for the CUDA implementation of m31 prime field by Ingonyama"
|
||||
homepage.workspace = true
|
||||
repository.workspace = true
|
||||
|
||||
[dependencies]
|
||||
icicle-core = { workspace = true }
|
||||
icicle-cuda-runtime = { workspace = true }
|
||||
|
||||
[build-dependencies]
|
||||
cmake = "0.1.50"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
devmode = ["icicle-core/devmode"]
|
||||
29
wrappers/rust/icicle-fields/icicle-m31/build.rs
Normal file
29
wrappers/rust/icicle-fields/icicle-m31/build.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
use cmake::Config;
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-env-changed=CXXFLAGS");
|
||||
println!("cargo:rerun-if-changed=../../../../icicle");
|
||||
|
||||
// Base config
|
||||
let mut config = Config::new("../../../../icicle/");
|
||||
config
|
||||
.define("FIELD", "m31")
|
||||
.define("CMAKE_BUILD_TYPE", "Release")
|
||||
.define("EXT_FIELD", "ON");
|
||||
|
||||
if let Ok(cuda_arch) = env::var("CUDA_ARCH") {
|
||||
config.define("CUDA_ARCH", &cuda_arch);
|
||||
}
|
||||
|
||||
// Build
|
||||
let out_dir = config
|
||||
.build_target("icicle_field")
|
||||
.build();
|
||||
|
||||
println!("cargo:rustc-link-search={}/build/lib", out_dir.display());
|
||||
|
||||
println!("cargo:rustc-link-lib=ingo_field_m31");
|
||||
println!("cargo:rustc-link-lib=stdc++");
|
||||
println!("cargo:rustc-link-lib=cudart");
|
||||
}
|
||||
33
wrappers/rust/icicle-fields/icicle-m31/src/field.rs
Normal file
33
wrappers/rust/icicle-fields/icicle-m31/src/field.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use icicle_core::field::{Field, MontgomeryConvertibleField};
|
||||
use icicle_core::traits::{FieldConfig, FieldImpl, GenerateRandom};
|
||||
use icicle_core::{impl_field, impl_scalar_field};
|
||||
use icicle_cuda_runtime::device::check_device;
|
||||
use icicle_cuda_runtime::device_context::DeviceContext;
|
||||
use icicle_cuda_runtime::error::CudaError;
|
||||
use icicle_cuda_runtime::memory::{DeviceSlice, HostOrDeviceSlice};
|
||||
|
||||
pub(crate) const SCALAR_LIMBS: usize = 1;
|
||||
pub(crate) const EXTENSION_LIMBS: usize = 4;
|
||||
|
||||
impl_scalar_field!("m31", m31, SCALAR_LIMBS, ScalarField, ScalarCfg, Fr);
|
||||
impl_scalar_field!(
|
||||
"m31_extension",
|
||||
m31_extension,
|
||||
EXTENSION_LIMBS,
|
||||
ExtensionField,
|
||||
ExtensionCfg,
|
||||
Fr
|
||||
);
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{ExtensionField, ScalarField};
|
||||
use icicle_core::impl_field_tests;
|
||||
use icicle_core::tests::*;
|
||||
|
||||
impl_field_tests!(ScalarField);
|
||||
mod extension {
|
||||
use super::*;
|
||||
|
||||
impl_field_tests!(ExtensionField);
|
||||
}
|
||||
}
|
||||
2
wrappers/rust/icicle-fields/icicle-m31/src/lib.rs
Normal file
2
wrappers/rust/icicle-fields/icicle-m31/src/lib.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod field;
|
||||
pub mod vec_ops;
|
||||
26
wrappers/rust/icicle-fields/icicle-m31/src/vec_ops/mod.rs
Normal file
26
wrappers/rust/icicle-fields/icicle-m31/src/vec_ops/mod.rs
Normal file
@@ -0,0 +1,26 @@
|
||||
use crate::field::{ExtensionCfg, ExtensionField, ScalarCfg, ScalarField};
|
||||
|
||||
use icicle_core::error::IcicleResult;
|
||||
use icicle_core::impl_vec_ops_field;
|
||||
use icicle_core::traits::IcicleResultWrap;
|
||||
use icicle_core::vec_ops::{BitReverseConfig, VecOps, VecOpsConfig};
|
||||
use icicle_cuda_runtime::device_context::DeviceContext;
|
||||
use icicle_cuda_runtime::error::CudaError;
|
||||
use icicle_cuda_runtime::memory::HostOrDeviceSlice;
|
||||
|
||||
impl_vec_ops_field!("m31", m31, ScalarField, ScalarCfg);
|
||||
impl_vec_ops_field!("m31_extension", m31_extension, ExtensionField, ExtensionCfg);
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod tests {
|
||||
use crate::field::{ExtensionField, ScalarField};
|
||||
use icicle_core::impl_vec_add_tests;
|
||||
use icicle_core::vec_ops::tests::*;
|
||||
|
||||
impl_vec_add_tests!(ScalarField);
|
||||
mod extension {
|
||||
use super::*;
|
||||
|
||||
impl_vec_add_tests!(ExtensionField);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user