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

Notify multicore<->WASM compatibility issues #121

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ The implementations were originally ported from [matterlabs/pairing](https://git
* Various features related to serialization and deserialization of curve points and field elements.
* Curve-specific optimizations and benchmarking capabilities.

## Controlling parallelism

`halo2curves` currently uses [rayon](https://github.com/rayon-rs/rayon) for parallel
computation. The `RAYON_NUM_THREADS` environment variable can be used to set the number of
threads.

You can disable `rayon` by disabling the `"multicore"` feature.
Warning! halo2curves will lose access to parallelism if you disable the `"multicore"` feature.
This will significantly degrade performance.

Notice that if the `multicore` feature is active, the library will not compile to any `wasm` target.
This is because WASM architectures at the time of writing this still don't handle parallelism properly.
See: [Rayon: Usage with WwbAssembly](https://github.com/rayon-rs/rayon#usage-with-webassembly) for more info.
CPerezz marked this conversation as resolved.
Show resolved Hide resolved
CPerezz marked this conversation as resolved.
Show resolved Hide resolved

CPerezz marked this conversation as resolved.
Show resolved Hide resolved
## Benchmarks

Benchmarking is supported through the use of Rust's built-in test framework. Benchmarks can be run without assembly optimizations:
Expand Down
9 changes: 9 additions & 0 deletions src/multicore.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
#[cfg(all(
feature = "multicore",
target_arch = "wasm32",
not(target_feature = "atomics")
))]
compile_error!(
"The multicore feature flag is not supported on wasm32 architectures without atomics"
);

pub use maybe_rayon::{
iter::{IntoParallelIterator, IntoParallelRefMutIterator, ParallelIterator},
join, scope, Scope,
Expand Down
Loading