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

Add x86_64 asm codegen for PrimeField mul and square #176

Merged
merged 48 commits into from
May 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e5f1dbf
Added asm code generation for montgomery multiplication and squaring
jon-chuang Apr 8, 2020
8116a25
Merge branch 'master' into inline-asm
jon-chuang Apr 8, 2020
cc3d14f
add data movement
jon-chuang Apr 10, 2020
53e78e7
Failed attempt at data movement through swaps and solving corner cases
jon-chuang Apr 10, 2020
1b4ed94
data movement milestone - max 12 limbs
jon-chuang Apr 10, 2020
d3c1414
data movement milestone - max 12 limbs
jon-chuang Apr 10, 2020
dc109c8
Merge branch 'inline-asm' of https://github.com/jon-chuang/zexe into …
jon-chuang Apr 10, 2020
a4dfc3b
18 limbs
jon-chuang Apr 11, 2020
80e7d6a
break up into: assembler and arithmetic
jon-chuang Apr 15, 2020
c46481b
Add: context.
jon-chuang Apr 15, 2020
822fb30
ASM DSL with procedural macros
jon-chuang Apr 16, 2020
4a12185
conditional compilation
jon-chuang Apr 16, 2020
d6f3ba5
target_arch and target_feature. Compile with:
jon-chuang Apr 16, 2020
feff30d
minor changes in config and naming
jon-chuang Apr 18, 2020
aab30ce
readme asm instructions
jon-chuang Apr 22, 2020
d71eac6
More detailed readme instructions
jon-chuang Apr 22, 2020
dce1003
more readme edits
jon-chuang Apr 22, 2020
44516e2
cleaned up benches with macros, increasing code reuse
jon-chuang Apr 22, 2020
c6265d5
feature = n_fold
jon-chuang Apr 22, 2020
cfc3975
cleanup/refactor fields
jon-chuang Apr 22, 2020
f3c8ee9
added benchmarking support for all MNT curves
jon-chuang Apr 22, 2020
5163177
minor error
jon-chuang Apr 22, 2020
1366581
further cleanup
jon-chuang Apr 22, 2020
4901bc2
removed unneccesarily clumped features
jon-chuang Apr 22, 2020
2a3c887
update readme
jon-chuang Apr 22, 2020
6410d83
update readme
jon-chuang Apr 22, 2020
d840a2b
update readme
jon-chuang Apr 22, 2020
7faa72b
--emit=asm seemed to be hurting performance significantly... So lets …
jon-chuang Apr 22, 2020
075e2a4
remove n_fold for g2
jon-chuang Apr 23, 2020
04c8def
canonicalDeserialise
jon-chuang Apr 23, 2020
3eefaec
Merge branch 'master' into inline-asm
jon-chuang Apr 23, 2020
2fd1932
correct omitted macro ident $
jon-chuang Apr 23, 2020
270c7f0
addressed some warnings
jon-chuang Apr 23, 2020
9e1dc9c
gate bench, fix #[cfg] over if statement
jon-chuang Apr 23, 2020
ee25c1e
fmt
jon-chuang Apr 23, 2020
07a84f0
cfg_attr to avoid feature(asm) on stable
jon-chuang Apr 23, 2020
57de475
fmt + more stable cfg
jon-chuang Apr 23, 2020
a865b2e
remove unnecessary clone()s
jon-chuang Apr 23, 2020
7f80032
more readable string manipulation
jon-chuang Apr 23, 2020
1f8852c
fmt...
jon-chuang Apr 23, 2020
128bc1b
Merge branch 'master' into inline-asm
jon-chuang Apr 23, 2020
e0f5aaf
fixed omitted argument
jon-chuang Apr 23, 2020
00b59da
fmt
jon-chuang Apr 24, 2020
86ec169
Clean up features, and make nightly detection robust
Pratyush May 4, 2020
1cec7d2
Small clean up of code
Pratyush May 4, 2020
c4df769
Merge remote-tracking branch 'upstream/master' into inline-asm
Pratyush May 4, 2020
27e9c4d
Formatting
Pratyush May 4, 2020
a52841d
Fix imports and features
Pratyush May 4, 2020
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
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ Informally, the library provides the ability to create transactions that run arb

This repository contains several Rust crates that implement the different building blocks of ZEXE. The high-level structure of the repository is as follows.

* [`algebra`](algebra): Rust crate that provides finite fields and elliptic curves
* [`algebra-core`](algebra-core): Rust crate that provides generic arithmetic for finite fields and elliptic curves
* [`algebra`](algebra): Rust crate that provides concrete instantiations of some finite fields and elliptic curves
* [`crypto-primitives`](crypto-primitives): Rust crate that implements some useful cryptographic primitives (and constraints for them)
* [`dpc`](dpc): Rust crate that implements DPC schemes (the main cryptographic primitive in this repository)
* [`ff-fft`](ff-fft): Rust crate that provides efficient finite field polynomial arithmetic based on finite field FFTs
Expand Down Expand Up @@ -64,9 +65,9 @@ cargo build --release
This library comes with unit tests for each of the provided crates. Run the tests with:
```bash
cargo test
```
```

Lastly, this library comes with benchmarks for the following crates:
This library comes with benchmarks for the following crates:

- [`algebra`](algebra)
- [`dpc`](dpc)
Expand All @@ -76,6 +77,18 @@ These benchmarks require the nightly Rust toolchain; to install this, run `rustu
cargo +nightly bench
```

Compiling with `adcxq`, `adoxq` and `mulxq` instructions can lead to a 30-70% speedup. These are available on most `x86_64` platforms (Broadwell onwards for Intel and Ryzen onwards for AMD). Run the following command:
```bash
RUSTFLAGS="-C target-feature=+bmi2,+adx" cargo +nightly test/build/bench --features asm
```
Tip: If optimising for performance, your mileage may vary with passing `--emit=asm` to `RUSTFLAGS`.

To bench `algebra-benches` with greater accuracy, especially for functions with execution times on the order of nanoseconds, use the `n_fold` feature to run selected functions 1000x per iteration. To run with multiple features, make sure to double quote the features.
```bash
cargo +nightly bench --features "n_fold bls12_381"
```


## License

ZEXE is licensed under either of the following licenses, at your discretion.
Expand Down
18 changes: 17 additions & 1 deletion algebra-benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,27 @@ include = ["Cargo.toml", "src", "README.md", "LICENSE-APACHE", "LICENSE-MIT"]
license = "MIT/Apache-2.0"
edition = "2018"
publish = false
build = "build.rs"

################################# Dependencies ################################

[dev-dependencies]
algebra = { path = "../algebra", features = [ "full" ] }
algebra = { path = "../algebra" }
blake2 = "0.8.1"
rand = "0.7"
rand_xorshift = { version = "0.2" }
paste = "0.1"

[features]
asm = [ "algebra/asm"]
n_fold = []
mnt4_298 = [ "algebra/mnt4_298"]
mnt6_298 = [ "algebra/mnt6_298"]
mnt4_753 = [ "algebra/mnt4_753"]
mnt6_753 = [ "algebra/mnt6_753"]
bls12_381 = [ "algebra/bls12_381"]
bls12_377 = [ "algebra/bls12_377"]
sw6 = [ "algebra/sw6" ]

[build-dependencies]
rustc_version = "0.1.*"
183 changes: 0 additions & 183 deletions algebra-benches/benches/bls12_377/ec.rs

This file was deleted.

Loading