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

CPU poseidon hash #611

Open
wants to merge 234 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
234 commits
Select commit Hold shift + click to select a range
4fa154d
enable CI for V3
yshekel May 16, 2024
5410d07
basic cmake scripts and test
yshekel May 16, 2024
d7f86e6
errors and device_api interface
yshekel May 16, 2024
b3fad0f
mock cpu backend for device API
yshekel May 20, 2024
755a44d
CPU backend implemented with basic test
yshekel May 21, 2024
5bbdb0f
device API tests: async, error, invalid device
yshekel May 21, 2024
d5aac95
CUDA backend device
yshekel May 21, 2024
0af022a
verify valid device
yshekel May 21, 2024
7ade66b
vectorAdd api for int type
yshekel May 22, 2024
fdec847
vectorAdd operates on Field type
yshekel May 22, 2024
d15edcb
add config struct to vec ops
yshekel May 23, 2024
8d9c2b1
cuda backend for vector add + test CPU vs CUDA
yshekel May 23, 2024
e4e1b3f
refactored runtime APIs to use thread local device
yshekel May 23, 2024
b50d6aa
spelling
yshekel May 23, 2024
513b45f
ci compilation fix
yshekel May 23, 2024
ff1017e
renamed icicle_fe to icicle_v3
yshekel May 27, 2024
8b8d778
use CONCAT_EXPAND() macro to generate symbols per field/curve
yshekel May 27, 2024
0dcece4
CPU vec ops is template
yshekel May 27, 2024
ade9651
ntt and empty CPU backend
yshekel May 27, 2024
37e4faf
cmake update to force load on Clang and AppleClang too
yshekel May 27, 2024
0a48a5d
refactored to snake case
yshekel May 28, 2024
3ae2799
add vec-sub and vec-mul apis
yshekel May 28, 2024
608880d
generic dispatcher class
yshekel May 28, 2024
4fcd5eb
libs are built with names based on the field/curve
yshekel May 28, 2024
7068723
config extension
yshekel May 28, 2024
0216068
removed include/icicle from incdir to force include with icicle prefix
yshekel May 28, 2024
b1abf09
refactored apis to be template with specialization
yshekel May 30, 2024
42b659b
removed redundant includes
yshekel May 30, 2024
e40c661
removed extern C from backend APIs to avoid linkage issues
yshekel May 30, 2024
eda61b2
matrix transpose
yshekel May 30, 2024
c07eb08
ntt init domain API
yshekel May 30, 2024
ba2a03f
ntt release domain API
yshekel May 30, 2024
c4c7744
ntt init/release domain for cpu backend and test
yshekel May 30, 2024
c1e2a55
generate_scalars() API
yshekel May 30, 2024
c226771
scalar_convert_montgomery() API
yshekel May 30, 2024
2b4a4c2
vec ops size i32->u64
yshekel May 30, 2024
eb5a6f9
removed field specific APIs from shared headers. Will move the field …
yshekel May 30, 2024
fe12616
extension field vector ops and ntt APIs
yshekel May 30, 2024
6d0b326
curve lib and test
yshekel Jun 2, 2024
874ebf5
icicle and backends are now shared libs
yshekel Jun 2, 2024
87323a6
msm api with issue for result type
yshekel Jun 2, 2024
0e0470d
api to load backend libraries
yshekel Jun 2, 2024
e5b12bb
fix mac linkage issue due to missing linkage to icicle_device
yshekel Jun 2, 2024
4f8fe83
format files
yshekel Jun 2, 2024
aab5d0d
macro for unique identifiers
yshekel Jun 4, 2024
4faace4
small refactor to curve headers to avoid linkage errors with external…
yshekel Jun 4, 2024
87f725d
msm API now returns projective type
yshekel Jun 4, 2024
d55dc49
curve tests should only be built for curves, not field
yshekel Jun 4, 2024
53d73d3
disable NTT for unsupported fields
yshekel Jun 4, 2024
b435181
fix symbol redefinition when registering an API for multiple backends…
yshekel Jun 4, 2024
d3d2966
missing ext in msm config
yshekel Jun 4, 2024
e524db3
introduce log mechanism
yshekel Jun 4, 2024
3c028bf
msm precompute bases API
yshekel Jun 4, 2024
212068c
icicle_device links to dl
yshekel Jun 4, 2024
954b0e1
ffi extern curve methods
yshekel Jun 4, 2024
bd436f2
missing matrix transpose for ext field and moved generate scalars api
yshekel Jun 4, 2024
632fb91
missing G2 ifdef
yshekel Jun 4, 2024
729d1c0
montgomery conversion G1
yshekel Jun 4, 2024
4318aa1
MSM G2
yshekel Jun 6, 2024
e2237ec
montgomery conversion G2
yshekel Jun 6, 2024
c04a3ab
github workflow bug fix
yshekel Jun 6, 2024
5b5fbfb
avoid template specialization for curves where g2_affine is same type…
yshekel Jun 6, 2024
4e7b886
ecntt api
yshekel Jun 6, 2024
6671c3b
define options in main cmake
yshekel Jun 6, 2024
c94bcad
CUDA vector ops
yshekel Jun 9, 2024
0390650
transpose and montgomery CUDA apis
yshekel Jun 9, 2024
0e4af8f
montgomery conversion CUDA
yshekel Jun 9, 2024
aea2dba
CUDA ntt
yshekel Jun 9, 2024
42490af
fix order of loaded libs
yshekel Jun 10, 2024
41962b6
icicle curve links to icicle_field
yshekel Jun 10, 2024
091c9ba
montgomery conversion for cuda
yshekel Jun 13, 2024
6fe6916
CUDA ecntt
yshekel Jun 13, 2024
77eb89f
get_device_properties() added to device api
yshekel Jun 13, 2024
59843ee
no ECNTT for grumpkin
yshekel Jun 13, 2024
baae668
fixed cuda ntt headers
yshekel Jun 13, 2024
3309044
rust runtime crate
yshekel Jun 13, 2024
da007d1
mac compilation fix and api to query device availability
yshekel Jun 14, 2024
3b92f60
rust runtime crate progress
yshekel Jun 16, 2024
83cdf41
rust runtime crate copy to/from device test
yshekel Jun 17, 2024
9ae8d44
rust runtime crate streams
yshekel Jun 17, 2024
acb49eb
rust runtime crate async ops
yshekel Jun 17, 2024
ff6306c
rust ci
yshekel Jun 17, 2024
42f774a
fix identification of changed files
yshekel Jun 17, 2024
c5b75f7
minor rust ci fix
yshekel Jun 17, 2024
25d53e8
small cmake refactor, and install target
yshekel Jun 18, 2024
a86ebb4
simple v3 rust example
yshekel Jun 19, 2024
15abeb9
rust v3 icicle-core crate
yshekel Jun 19, 2024
5c85599
rust v3 babybear crate
yshekel Jun 19, 2024
754f7bc
ConfigExtension is now pointer in config for easier bindings
yshekel Jun 19, 2024
d8115c0
ConfigExtension rust wrapper
yshekel Jun 19, 2024
a1c0c8e
rust icicle-core vec_ops config and default device API
yshekel Jun 20, 2024
ca4281d
refactored device class to own the type string
yshekel Jun 20, 2024
59ff2d9
refactored rust vec_ops config to avoid taking ownership of stream bu…
yshekel Jun 20, 2024
ffc68c2
wrap() errors and install icicle into the deps cargo build dir
yshekel Jun 23, 2024
df290c0
rust v3 vec ops, api to list registered devices and config-extension …
yshekel Jun 23, 2024
e67ac86
rust matrix transpose
yshekel Jun 23, 2024
de650b8
rust v3 ntt
yshekel Jun 24, 2024
29c83c7
eplaced runtime_errors with icicle macro for throwing exceptions
yshekel Jun 25, 2024
3072f6c
test utilities to facilitate loading backends and choosing devices at…
yshekel Jun 25, 2024
6627b7b
rust missing ntt tests
yshekel Jun 25, 2024
86b757a
stark252 rust crate
yshekel Jun 25, 2024
d9248b7
bn254 curve crate
yshekel Jun 26, 2024
e14be6f
rust ecntt
yshekel Jun 26, 2024
6578125
rust bls curves
yshekel Jun 26, 2024
0cdfb84
bw6-761 rust crate
yshekel Jun 26, 2024
2da454a
rust grumpkin curve
yshekel Jun 27, 2024
45c0e3e
rust bls12-377 build.rs fix
yshekel Jun 27, 2024
f223656
rust msm
yshekel Jun 27, 2024
763b736
msm for cuda backend
yshekel Jun 30, 2024
7ed3cc7
matrix ops consolidated to vec ops, some TODO fixed
yshekel Jun 30, 2024
f230519
missing MSM cuda test
yshekel Jun 30, 2024
48269e3
bit reverse api and test, including cpu and cuda backends
yshekel Jul 1, 2024
401b5b8
bit reverse in rust
yshekel Jul 1, 2024
1146f56
rust ci merge build and test for faster ci
yshekel Jul 1, 2024
fe28f8f
reintroduced ntt tests against risc0 and lambdaworks
yshekel Jul 2, 2024
3e50854
field and curve host arithmetic tests
yshekel Jul 2, 2024
8a6cf02
msm test multi-device bug fix: allocate stream on correct device
yshekel Jul 2, 2024
b8e9f90
fix field tests compilation and find nvcc via cmake
yshekel Jul 2, 2024
6b095e6
track memory allocations via MemoryTracker and query pointer to devic…
yshekel Jul 3, 2024
40693a0
polynomial API V3
yshekel Jul 3, 2024
ef85fcc
ecntt bug fix from v2
yshekel Jul 4, 2024
be7cbba
polynomial tests fix regarding msm
yshekel Jul 4, 2024
ec596c3
rust polynomials
yshekel Jul 4, 2024
5a7c0cc
print domain size when ntt fails on that. same domain size for ntt an…
yshekel Jul 4, 2024
76cf23d
ecntt bug fix from V2
yshekel Jul 4, 2024
ca7fb84
switch device when releasing memory of inactive device
yshekel Jul 7, 2024
36c8799
NTT simple cpu backend (#533)
ShanieWinitz Jul 15, 2024
74f7a3c
move tracking logic to runtime.cpp rather than device API
yshekel Jul 8, 2024
e49540d
polynomial refactor to be multi-device
yshekel Jul 8, 2024
caf3b4f
add generic copy and copy_async with auto device inference
yshekel Jul 15, 2024
9b46b84
api for memset and tests for copy() and memset()
yshekel Jul 15, 2024
de88ad1
minor: CPU_REF reuse device_api class like CPU
yshekel Jul 15, 2024
4d0b1a0
removed device_id from polynomial view
yshekel Jul 15, 2024
87a25af
use icicle runtime apis in polynomial implementation instead of cuda …
yshekel Jul 16, 2024
0c8a849
move default polynomial context from cuda backend to icicle FE
yshekel Jul 16, 2024
091a193
add slice api to vec ops
yshekel Jul 16, 2024
61af965
add api for mul scalar and use in poly backend
yshekel Jul 16, 2024
028f59c
use vec_mul in polynomial api insted of another kernel
yshekel Jul 16, 2024
f13f24c
add vec_div api
yshekel Jul 16, 2024
6f8c480
use vector_div in polynomial backend
yshekel Jul 16, 2024
0885195
add vec_ops apis for scalar+-vector and use in polynomial backend
yshekel Jul 16, 2024
749d3f9
add vec_op api for find highest non zero idx of vector, and CUDA backend
yshekel Jul 16, 2024
8ade7ef
use vector_add in polynomial backend to add monomial inplace
yshekel Jul 16, 2024
06243e5
add polynomial evaluation api and cuda backend. Use it in poly backend
yshekel Jul 16, 2024
db19c38
split default poly backend from cuda and support CPU too
yshekel Jul 17, 2024
9c35aaa
add doxygen comments to frontend APIs
yshekel Jul 17, 2024
0409c6f
replace msm config bases_size with boolean flag indicating bases are …
yshekel Jul 17, 2024
d3b27a7
randomize device for C++ polynomial tests
yshekel Jul 17, 2024
7de94ff
fix bug in cuda MSM when scalars are in montgomery form
yshekel Jul 17, 2024
afe4831
skip fast twiddles for domains smaller than 16
yshekel Jul 18, 2024
cd33533
move cuda backend to private repo and clone it in ci
yshekel Jul 18, 2024
934f934
pull cuda backend when building in ci
yshekel Jul 18, 2024
a8e794f
use ssh-key in ci workflows to pull cuda backend
yshekel Jul 18, 2024
1baabd9
add feature to rust crates to choose local/remote cuda backend
yshekel Jul 18, 2024
4f47c9d
remove redundant link to stdc++ in build.rs scripts
yshekel Jul 18, 2024
58780f0
fix compilation issues for mac
yshekel Jul 18, 2024
bdf3cd5
add info logs to NTT test to find the issue
yshekel Jul 21, 2024
05d918f
let PR choose the cuda-backend branch to use
yshekel Jul 21, 2024
b52191f
field generation update from V2
yshekel Jul 24, 2024
49beb32
add script for generating C apis
yshekel Jul 24, 2024
fc2ac41
refactor msm example
yshekel Jul 24, 2024
9618e6d
split backend registration part to backend headers to avoid dep on co…
yshekel Jul 24, 2024
99e5853
update readme of C++ msm example
yshekel Jul 25, 2024
454fe5b
update ntt-best-practice and msm examples to V3
yshekel Jul 25, 2024
b07d020
update ntt example for V3
yshekel Jul 25, 2024
c302aeb
refactor pedersen-commintment example to V3
yshekel Jul 28, 2024
63dcd4e
remove multiply c++ example and fixed some readme
yshekel Jul 28, 2024
68802bc
refactor C++ example polynomial-multiplication for V3
yshekel Jul 28, 2024
a5a8bf8
refactor C++ example poly-api
yshekel Jul 28, 2024
445eec8
refactor C++ example risc0
yshekel Jul 28, 2024
8d03fb6
trigger examples build in ci
yshekel Jul 28, 2024
2a3dcd7
fix format
yshekel Jul 28, 2024
10963fb
refactor rust example msm
yshekel Jul 28, 2024
131e22d
fix example C++ msm, missing G2 flag
yshekel Jul 28, 2024
5d821d3
refactor C++ examples to work with install-dir, or build from source …
yshekel Jul 28, 2024
f8661ac
update rust examples msm and ntt to support installed backend dir
yshekel Jul 28, 2024
65ca51c
update Rust examples to support installed backend
yshekel Jul 28, 2024
dc1b2fc
fix: bug where wrong polynomial factory is used to construct polynomi…
yshekel Jul 30, 2024
4a4b254
rename template files to not format them
yshekel Jul 30, 2024
a45746f
fix rust examples calling load_backend() with removed param
yshekel Jul 30, 2024
5332f4c
minor update to rust poly example
yshekel Jul 30, 2024
d08088a
add runtime api to load backend from default installdir and use it ev…
yshekel Jul 31, 2024
cccd6c1
add ntt benchmark for rust
yshekel Jul 31, 2024
e95b562
simplify C++ examples by loading backend from default install dir
yshekel Jul 31, 2024
389ce1c
fix rust bw761 curve missing ICICLE backend install path and fix exam…
yshekel Aug 1, 2024
0bd5854
add rust benchmark for msm
yshekel Aug 1, 2024
7734676
add rust ntt benchmark for fields too
yshekel Aug 1, 2024
7b833af
add rust ecntt benchmark
yshekel Aug 1, 2024
73dd80b
update ntt api to accept config by const
yshekel Aug 1, 2024
908a6c5
move backend-specific-config to open part to avoid installing it
yshekel Aug 1, 2024
0797cb2
add error enumeartion for license error
yshekel Aug 6, 2024
0712d79
Add tasks manager classes to ease multithreading for cpu (#573)
Koren-Brand Aug 11, 2024
b7d3108
add accumulate (vec_ops) for v3
emirsoyturk Aug 13, 2024
02cbe8a
add rust wrapper and ext field for accumulate
emirsoyturk Aug 13, 2024
e8a968f
CI ref and revision
emirsoyturk Aug 13, 2024
89ea2a5
clang-format fix
emirsoyturk Aug 13, 2024
b5c090c
CI ref
emirsoyturk Aug 13, 2024
c49033a
[FEAT] Add accumulation function in vec_ops for v3
emirsoyturk Aug 14, 2024
af5c92e
refacor docs structure for V3
yshekel Aug 13, 2024
5f6f61a
update introduction doc
yshekel Aug 13, 2024
704ea44
doc ICICLE overview
yshekel Aug 13, 2024
5cc4c37
backend doc
yshekel Aug 13, 2024
b844c92
multi device doc
yshekel Aug 13, 2024
d173d58
icicle libraries doc
yshekel Aug 13, 2024
b539750
tmp getting started doc
yshekel Aug 13, 2024
c27c2d0
getting started build install doc
yshekel Aug 15, 2024
d10a968
fix spelling
yshekel Aug 15, 2024
06bac2a
programmers guide
yshekel Aug 15, 2024
ada75ef
CPP programmers guide
yshekel Aug 15, 2024
6d2fa10
CPP programmer guide cont
yshekel Aug 15, 2024
42046db
Rust programmers guide
yshekel Aug 15, 2024
b77b06c
doc updates
yshekel Aug 18, 2024
aba3e97
msm doc
yshekel Aug 18, 2024
8943e57
polynomials update
yshekel Aug 18, 2024
aaf1894
ntt docs
yshekel Aug 18, 2024
2dfa66e
vec-ops docs
yshekel Aug 18, 2024
89f437a
docs update
yshekel Aug 18, 2024
ad26694
implement multithread CPU vec ops (#577)
mickeyasa Aug 19, 2024
424c28e
docs updates
yshekel Aug 19, 2024
b811ac5
typos
yshekel Aug 19, 2024
9759cef
allow tests to run on CPU only but fail in TearDownTestSuite to avoid…
yshekel Aug 19, 2024
0d447c9
make features (G2,ecntt) default on (#583)
yshekel Aug 21, 2024
a62ab2e
use ccache if available (#585)
yshekel Aug 22, 2024
dc272a9
First commit of cpu_poseidon
Aug 29, 2024
3be24f1
WIP
Aug 29, 2024
a4669c1
WIP
Aug 29, 2024
62bf300
code review
mickeyasa Aug 29, 2024
53d0cb8
WIP
Aug 29, 2024
0b8016e
WIP
Aug 31, 2024
6ce6426
WIP
Aug 31, 2024
883f0e3
Commit for PR
Sep 11, 2024
22186fe
Resolve Miki's comments.
Sep 12, 2024
dd9baed
Fix typo.
Sep 12, 2024
d0e9681
Remove "struct PoseidonConstants"
Sep 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
25 changes: 12 additions & 13 deletions .github/changed-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,20 @@ golang:
- go.mod
- .github/workflows/golang.yml
rust:
- wrappers/rust/**/*
- wrappers/rust_v3/**/*
- '!wrappers/rust/README.md'
- .github/workflows/rust.yml
- .github/workflows/v3_rust.yml
cpp:
- icicle/**/*.cu
- icicle/**/*.cuh
- icicle/**/*.cpp
- icicle/**/*.hpp
- icicle/**/*.c
- icicle/**/*.h
- icicle/CMakeLists.txt
- .github/workflows/cpp_cuda.yml
- icicle/cmake/Common.cmake
- icicle/cmake/CurvesCommon.cmake
- icicle/cmake/FieldsCommon.cmake
- icicle_v3/**/*.cu
- icicle_v3/**/*.cuh
- icicle_v3/**/*.cpp
- icicle_v3/**/*.hpp
- icicle_v3/**/*.c
- icicle_v3/**/*.h
- icicle_v3/CMakeLists.txt
- .github/workflows/v3.yml
- icicle_v3/cmake/curve.cmake
- icicle_v3/cmake/field.cmake
examples:
- examples/**/*
- .github/workflows/examples.yml
3 changes: 2 additions & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ on:
pull_request:
branches:
- main
- V2
- V3
- yshekel/V3

jobs:
spelling-checker:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/cpp_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ name: C++/CUDA
on:
pull_request:
branches:
- main
- V2
- main
push:
branches:
- main
- V2
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
55 changes: 41 additions & 14 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# This workflow is a demo of how to run all examples in the Icicle repository.
# For each language directory (c++, Rust, etc.) the workflow
# (1) loops over all examples (msm, ntt, etc.) and
# (2) runs ./compile.sh and ./run.sh in each directory.
# The script ./compile.sh should compile the example and ./run.sh should run it.
# For each language directory (c++, Rust, etc.) the workflow
# (1) loops over all examples (msm, ntt, etc.) and
# (2) runs ./run.sh in each directory.
# Each script should return 0 for success and 1 otherwise.

name: Examples

on:
pull_request:
branches:
- main
- V2
- V3
- yshekel/V3 # TODO remove when merged to V3
push:
branches:
- main
- V2
- V3

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand All @@ -25,12 +23,42 @@ jobs:
check-changed-files:
uses: ./.github/workflows/check-changed-files.yml

extract-cuda-backend-branch:
name: Extract cuda branch name
runs-on: ubuntu-22.04
outputs:
cuda-backend-branch: ${{ steps.extract.outputs.cuda-backend-branch }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract Private Branch from PR Description
id: extract
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DESCRIPTION=$(gh pr view ${{ github.event.pull_request.number }} --json body -q '.body')
echo "PR Description: $DESCRIPTION"
CUDA_BE_BRANCH=$(echo "$DESCRIPTION" | grep -oP 'cuda-backend-branch:\s*\K[^\s]+') || true
if [ -z "$CUDA_BE_BRANCH" ]; then
CUDA_BE_BRANCH="main" # Default branch if not specified
fi
echo "Extracted CUDA Backend Branch: $CUDA_BE_BRANCH"
echo "::set-output name=cuda-backend-branch::$CUDA_BE_BRANCH"

run-examples:
runs-on: [self-hosted, Linux, X64, icicle, examples]
needs: check-changed-files
needs: [check-changed-files, extract-cuda-backend-branch]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout CUDA Backend
uses: actions/checkout@v4
with:
repository: ingonyama-zk/icicle-cuda-backend
path: ./icicle_v3/backend/cuda
token: ${{ secrets.GITHUB_TOKEN }}
ssh-key: ${{ secrets.CUDA_PULL_KEY }}
ref: ${{ needs.extract-cuda-backend-branch.outputs.cuda-backend-branch }}
- name: c++ examples
working-directory: ./examples/c++
if: needs.check-changed-files.outputs.cpp_cuda == 'true' || needs.check-changed-files.outputs.examples == 'true'
Expand All @@ -40,11 +68,10 @@ jobs:
if [ -d "$dir" ]; then
echo "Running command in $dir"
cd $dir
./compile.sh
./run.sh
./run.sh -d CUDA
cd -
fi
done
done
- name: Rust examples
working-directory: ./examples/rust
if: needs.check-changed-files.outputs.rust == 'true' || needs.check-changed-files.outputs.examples == 'true'
Expand All @@ -54,7 +81,7 @@ jobs:
if [ -d "$dir" ]; then
echo "Running command in $dir"
cd $dir
cargo run --release
./run.sh -d CUDA
cd -
fi
done
done
6 changes: 2 additions & 4 deletions .github/workflows/golang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ name: GoLang
on:
pull_request:
branches:
- main
- V2
- main
push:
branches:
- main
- V2
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ name: Rust
on:
pull_request:
branches:
- main
- V2
- main
push:
branches:
- main
- V2
- main

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
126 changes: 126 additions & 0 deletions .github/workflows/v3.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: C++/CUDA

on:
pull_request:
branches:
- V3
- yshekel/V3 # TODO remove when merged to V3
push:
branches:
- V3

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-changed-files:
uses: ./.github/workflows/check-changed-files.yml

check-format:
name: Check Code Format
runs-on: ubuntu-22.04
needs: check-changed-files
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check clang-format
if: needs.check-changed-files.outputs.cpp_cuda == 'true'
run: if [[ $(find ./ \( -path ./icicle/build -prune -o -path ./**/target -prune -o -path ./examples -prune \) -iname *.h -or -iname *.cuh -or -iname *.cu -or -iname *.c -or -iname *.cpp | xargs clang-format --dry-run -ferror-limit=1 -style=file 2>&1) ]]; then echo "Please run clang-format"; exit 1; fi

extract-cuda-backend-branch:
name: Extract cuda branch name
runs-on: ubuntu-22.04
outputs:
cuda-backend-branch: ${{ steps.extract.outputs.cuda-backend-branch }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract Private Branch from PR Description
id: extract
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DESCRIPTION=$(gh pr view ${{ github.event.pull_request.number }} --json body -q '.body')
echo "PR Description: $DESCRIPTION"
CUDA_BE_BRANCH=$(echo "$DESCRIPTION" | grep -oP 'cuda-backend-branch:\s*\K[^\s]+') || true
if [ -z "$CUDA_BE_BRANCH" ]; then
CUDA_BE_BRANCH="main" # Default branch if not specified
fi
echo "Extracted CUDA Backend Branch: $CUDA_BE_BRANCH"
echo "::set-output name=cuda-backend-branch::$CUDA_BE_BRANCH"

test-linux-curve:
name: Test on Linux
runs-on: [self-hosted, Linux, X64, icicle]
needs: [check-changed-files, check-format, extract-cuda-backend-branch]
strategy:
matrix:
curve:
- name: bn254
build_args: -DG2=ON -DECNTT=ON
- name: bls12_381
build_args: -DG2=ON -DECNTT=ON
- name: bls12_377
build_args: -DG2=ON -DECNTT=ON
- name: bw6_761
build_args: -DG2=ON -DECNTT=ON
- name: grumpkin
build_args:

steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Checkout CUDA Backend
uses: actions/checkout@v4
with:
repository: ingonyama-zk/icicle-cuda-backend
path: ./icicle_v3/backend/cuda
token: ${{ secrets.GITHUB_TOKEN }}
ssh-key: ${{ secrets.CUDA_PULL_KEY }}
ref: ${{ needs.extract-cuda-backend-branch.outputs.cuda-backend-branch }}
- name: Build curve
working-directory: ./icicle_v3
if: needs.check-changed-files.outputs.cpp_cuda == 'true'
run: |
mkdir -p build && rm -rf build/*
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DCURVE=${{ matrix.curve.name }} ${{ matrix.curve.build_args }} -DCUDA_BACKEND=local -S . -B build
cmake --build build -j
- name: Run C++ curve Tests
working-directory: ./icicle_v3/build/tests
if: needs.check-changed-files.outputs.cpp_cuda == 'true'
run: ctest

test-linux-field:
name: Test on Linux
runs-on: [self-hosted, Linux, X64, icicle]
needs: [check-changed-files, check-format, extract-cuda-backend-branch]
strategy:
matrix:
field:
- name: babybear
build_args: -DEXT_FIELD=ON
- name: stark252
build_args: -DEXT_FIELD=OFF
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Checkout CUDA Backend
uses: actions/checkout@v4
with:
repository: ingonyama-zk/icicle-cuda-backend
path: ./icicle_v3/backend/cuda
token: ${{ secrets.GITHUB_TOKEN }}
ssh-key: ${{ secrets.CUDA_PULL_KEY }}
ref: ${{ needs.extract-cuda-backend-branch.outputs.cuda-backend-branch }}
- name: Build field
working-directory: ./icicle_v3
if: needs.check-changed-files.outputs.cpp_cuda == 'true'
run: |
mkdir -p build && rm -rf build/*
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON -DFIELD=${{ matrix.field.name }} ${{ matrix.field.build_args }} -DCUDA_BACKEND=local -S . -B build
cmake --build build -j
- name: Run C++ field Tests
working-directory: ./icicle_v3/build/tests
if: needs.check-changed-files.outputs.cpp_cuda == 'true'
run: ctest
82 changes: 82 additions & 0 deletions .github/workflows/v3_rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Rust

on:
pull_request:
branches:
- V3
- yshekel/V3 # TODO remove when merged to V3
push:
branches:
- V3

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
check-changed-files:
uses: ./.github/workflows/check-changed-files.yml

check-format:
name: Check Code Format
runs-on: ubuntu-22.04
needs: check-changed-files
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check rustfmt
if: needs.check-changed-files.outputs.rust == 'true' || needs.check-changed-files.outputs.cpp_cuda == 'true'
working-directory: ./wrappers/rust
# "-name target -prune" removes searching in any directory named "target"
# Formatting by single file is necessary due to generated files not being present
# before building the project.
# e.g. icicle-cuda-runtime/src/bindings.rs is generated and icicle-cuda-runtime/src/lib.rs includes that module
# causing rustfmt to fail.
run: if [[ $(find . -path ./icicle-curves/icicle-curve-template -prune -o -name target -prune -o -iname *.rs -print | xargs cargo fmt --check --) ]]; then echo "Please run cargo fmt"; exit 1; fi

extract-cuda-backend-branch:
name: Extract cuda branch name
runs-on: ubuntu-22.04
outputs:
cuda-backend-branch: ${{ steps.extract.outputs.cuda-backend-branch }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Extract Private Branch from PR Description
id: extract
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
DESCRIPTION=$(gh pr view ${{ github.event.pull_request.number }} --json body -q '.body')
echo "PR Description: $DESCRIPTION"
CUDA_BE_BRANCH=$(echo "$DESCRIPTION" | grep -oP 'cuda-backend-branch:\s*\K[^\s]+') || true
if [ -z "$CUDA_BE_BRANCH" ]; then
CUDA_BE_BRANCH="main" # Default branch if not specified
fi
echo "Extracted CUDA Backend Branch: $CUDA_BE_BRANCH"
echo "::set-output name=cuda-backend-branch::$CUDA_BE_BRANCH"

test-linux:
name: Test on Linux
runs-on: [self-hosted, Linux, X64, icicle]
needs: [check-changed-files, check-format, extract-cuda-backend-branch]
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Checkout CUDA Backend
uses: actions/checkout@v4
with:
repository: ingonyama-zk/icicle-cuda-backend
path: ./icicle_v3/backend/cuda
token: ${{ secrets.GITHUB_TOKEN }}
ssh-key: ${{ secrets.CUDA_PULL_KEY }}
ref: ${{ needs.extract-cuda-backend-branch.outputs.cuda-backend-branch }}
- name: Run tests
working-directory: ./wrappers/rust_v3
if: needs.check-changed-files.outputs.rust == 'true' || needs.check-changed-files.outputs.cpp_cuda == 'true'
# tests are split to phases since NTT domain is global but tests have conflicting requirements
run: |
cargo build --workspace --release --features=cuda_backend
cargo test --workspace --release --verbose --features=cuda_backend -- --skip phase
cargo test phase2 --workspace --release --features=cuda_backend
cargo test phase3 --workspace --release --features=cuda_backend
Loading