-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:filecoin-project/neptune into hal…
…o2-pick-master-changes
- Loading branch information
Showing
22 changed files
with
454 additions
and
292 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[package] | ||
name = "neptune" | ||
description = "Poseidon hashing over BLS12-381 for Filecoin." | ||
version = "7.2.0" | ||
version = "8.1.0" | ||
authors = ["porcuquine <[email protected]>"] | ||
edition = "2018" | ||
license = "MIT OR Apache-2.0" | ||
|
@@ -10,39 +10,37 @@ resolver = "2" | |
|
||
[dependencies] | ||
lazy_static = "1.4.0" | ||
bellperson = { version = "0.22", default-features = false } | ||
bellperson = { version = "0.24", default-features = false } | ||
blake2s_simd = "0.5" | ||
blstrs = { version = "0.5.0", optional = true } | ||
blstrs = { version = "0.6.0", optional = true } | ||
byteorder = "1" | ||
ec-gpu = { version = "0.1.0", optional = true } | ||
ec-gpu-gen = { version = "0.3.0", default-features = false, optional = true } | ||
ec-gpu = { version = "0.2.0", optional = true } | ||
ec-gpu-gen = { version = "0.5.0", optional = true } | ||
ff = "0.12.0" | ||
generic-array = "0.14.4" | ||
itertools = { version = "0.8.0" } | ||
log = "0.4.8" | ||
halo2_proofs = "0.2.0" | ||
# `halo2_proofs` does not expose the feature `pasta_curves/gpu`, thus we must also import | ||
# `pasta_curves/gpu` when building with `neptune/pasta`. | ||
pasta_curves = { version = "0.4.0", optional = true } | ||
pasta_curves = { version = "0.5.1", features = ["serde"], package = "fil_pasta_curves", optional = true } | ||
rust-gpu-tools = { version = "0.5.0", default-features = false, optional = true } | ||
trait-set = "0.3.0" | ||
serde = { version = "1.0", features = ["derive"] } | ||
|
||
[dev-dependencies] | ||
blstrs = { version = "0.5.0" } | ||
blstrs = "0.6.1" | ||
criterion = "0.3" | ||
rand = "0.8.0" | ||
sha2 = "0.9" | ||
tempdir = "0.3" | ||
rand_xorshift = "0.3.0" | ||
serde_json = "1.0.53" | ||
sha2 = "0.9" | ||
|
||
[build-dependencies] | ||
blstrs = "0.5.0" | ||
ec-gpu = { version = "0.1.0", optional = true } | ||
ec-gpu-gen = { version = "0.3.0", default-features = false, optional = true } | ||
execute = "0.2.9" | ||
hex = "0.4" | ||
pasta_curves = "0.4.0" | ||
sha2 = "0.9" | ||
blstrs = "0.6.1" | ||
ec-gpu = { version = "0.2.0", optional = true } | ||
ec-gpu-gen = { version = "0.5.0", optional = true } | ||
pasta_curves = { version = "0.5.1", package = "fil_pasta_curves" } | ||
|
||
[[bench]] | ||
name = "hash" | ||
|
@@ -58,8 +56,8 @@ codegen-units = 1 | |
|
||
[features] | ||
default = [ "bellperson/default" ] | ||
cuda = ["rust-gpu-tools/cuda", "blstrs/gpu", "ec-gpu-gen/cuda", "ec-gpu"] | ||
opencl = ["rust-gpu-tools/opencl", "blstrs/gpu", "ec-gpu-gen/opencl", "ec-gpu"] | ||
cuda = ["ec-gpu-gen/cuda", "ec-gpu", "pasta_curves/gpu"] | ||
opencl = ["ec-gpu-gen/opencl", "ec-gpu", "pasta_curves/gpu"] | ||
# The supported arities for Poseidon running on the GPU are specified at compile-time. | ||
arity2 = [] | ||
arity4 = [] | ||
|
@@ -72,7 +70,6 @@ arity36 = [] | |
strengthened = [] | ||
# Compiles the "even-partial" strength GPU kernel. | ||
even-partial = [] | ||
wasm = [ "bellperson/wasm" ] | ||
# The supported fields for Poseidon running on the GPU are specified at compile-time. | ||
bls = ["blstrs/gpu"] | ||
pasta = ["pasta_curves/gpu", "even-partial"] | ||
|
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 |
---|---|---|
@@ -1,84 +1,13 @@ | ||
/// The build script is needed to compile the CUDA kernel. | ||
|
||
#[cfg(feature = "cuda")] | ||
/// The build script is used to generate the CUDA kernel and OpenCL source at compile-time, if the | ||
/// `cuda` and/or `opencl` feature is enabled. | ||
#[cfg(any(feature = "cuda", feature = "opencl"))] | ||
fn main() { | ||
use std::path::PathBuf; | ||
use std::process::Command; | ||
use std::{env, fs}; | ||
|
||
use ec_gpu_gen::Limb32; | ||
use sha2::{Digest, Sha256}; | ||
|
||
#[path = "src/proteus/sources.rs"] | ||
mod sources; | ||
|
||
let kernel_source = sources::generate_program::<Limb32>(); | ||
let out_dir = env::var("OUT_DIR").expect("OUT_DIR was not set."); | ||
|
||
// Make it possible to override the default options. Though the source and output file is | ||
// always set automatically. | ||
let mut nvcc = match env::var("NEPTUNE_CUDA_NVCC_ARGS") { | ||
Ok(args) => execute::command(format!("nvcc {}", args)), | ||
Err(_) => { | ||
let mut command = Command::new("nvcc"); | ||
command | ||
.arg("--optimize=6") | ||
// Compile with as many threads as CPUs are available. | ||
.arg("--threads=0") | ||
.arg("--fatbin") | ||
.arg("--gpu-architecture=sm_86") | ||
.arg("--generate-code=arch=compute_86,code=sm_86") | ||
.arg("--generate-code=arch=compute_80,code=sm_80") | ||
.arg("--generate-code=arch=compute_75,code=sm_75"); | ||
command | ||
} | ||
}; | ||
|
||
// Hash the source and and the compile flags. Use that as the filename, so that the kernel is | ||
// only rebuilt if any of them change. | ||
let mut hasher = Sha256::new(); | ||
hasher.update(kernel_source.as_bytes()); | ||
hasher.update(&format!("{:?}", &nvcc)); | ||
let kernel_digest = hex::encode(hasher.finalize()); | ||
|
||
let source_path: PathBuf = [&out_dir, &format!("{}.cu", &kernel_digest)] | ||
.iter() | ||
.collect(); | ||
let fatbin_path: PathBuf = [&out_dir, &format!("{}.fatbin", &kernel_digest)] | ||
.iter() | ||
.collect(); | ||
|
||
fs::write(&source_path, &kernel_source).unwrap_or_else(|_| { | ||
panic!( | ||
"Cannot write kernel source at {}.", | ||
source_path.to_str().unwrap() | ||
) | ||
}); | ||
|
||
// Only compile if the output doesn't exist yet. | ||
if !fatbin_path.as_path().exists() { | ||
let status = nvcc | ||
.arg("--output-file") | ||
.arg(&fatbin_path) | ||
.arg(&source_path) | ||
.status() | ||
.expect("Cannot run nvcc."); | ||
|
||
if !status.success() { | ||
panic!( | ||
"nvcc failed. See the kernel source at {}", | ||
source_path.to_str().unwrap() | ||
); | ||
} | ||
} | ||
|
||
// The idea to put the path to the farbin into a compile-time env variable is from | ||
// https://github.com/LutzCle/fast-interconnects-demo/blob/b80ea8e04825167f486ab8ac1b5d67cf7dd51d2c/rust-demo/build.rs | ||
println!( | ||
"cargo:rustc-env=CUDA_FATBIN={}", | ||
fatbin_path.to_str().unwrap() | ||
); | ||
let source_builder = sources::generate_program(); | ||
ec_gpu_gen::generate(&source_builder); | ||
} | ||
|
||
#[cfg(not(feature = "cuda"))] | ||
#[cfg(not(any(feature = "cuda", feature = "opencl")))] | ||
fn main() {} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
1.56.1 | ||
1.57.0 |
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
Oops, something went wrong.