Skip to content

Commit

Permalink
Merge pull request #5 from zkmopro/feat/adapt-mopro-refactor
Browse files Browse the repository at this point in the history
Feat/adapt mopro refactor
  • Loading branch information
moven0831 authored Sep 29, 2024
2 parents bef26a6 + 43323db commit 5d9611b
Show file tree
Hide file tree
Showing 69 changed files with 2,967 additions and 2,903 deletions.
158 changes: 79 additions & 79 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[workspace]
members = ["mopro-msm"]
resolver = "2"
exclude = ["mopro-example-app"]
exclude = ["gpu-acceleration-app"]
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,36 @@ We are researching the methods and implement the methods that can accelerate mul

## mopro-msm

This is the crate that possess various of implementation of MSM functions, which are integrated in `mopro-core`.
This is the crate that possess various of implementation of MSM functions, which are integrated in `mopro-core`.

### Run benchmark on the laptop
Currently we support these MSM algorithms on BN254
- arkworks_pippenger
- bucket_wise_msm
- precompute_msm
- metal::msm (GPU)

Replace `MSM_ALGO` with the algorithm name below to get the benchmarks

Benchmarking for <u>single instance size</u>
```sh
cargo test --release --package mopro-msm --lib -- msm::MSM_ALGO::tests::test_run_benchmark --exact --nocapture
```

Benchmarking for <u>multiple instance size</u>
```sh
cargo test --release --package mopro-msm --lib -- msm::MSM_ALGO::tests::test_run_multi_benchmarks --exact --nocapture
```

## gpu-exploration-app

This is a benchmark app to compare the performance of different algorithm on IOS device.

Run this command on the project root directory to compile metal library for OS
```sh
# for macOS
bash mopro-msm/src/msm/metal/compile_metal.sh

# for iphoneOS
bash mopro-msm/src/msm/metal/compile_metal_iphone.sh
```
134 changes: 134 additions & 0 deletions gpu-acceleration-app/.github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
name: Build and Test

on:
push:
pull_request:
types:
- opened
- synchronize
- reopened
- ready_for_review

env:
CARGO_TERM_COLOR: always

jobs:
# TODO: Add a job to run clippy
lint:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Check formatting
run: cargo fmt --all -- --check

test-circom-custom:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Run circom tests
# TODO: Fix this custom jar thing
run: |
curl -L https://repo1.maven.org/maven2/net/java/dev/jna/jna/5.13.0/jna-5.13.0.jar -o jna-5.13.0.jar
CLASSPATH=jna-5.13.0.jar cargo test -- --nocapture
build-xcframework:
runs-on: macos-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Build xcframework
run: cargo run --bin ios
- name: Cache xcframework
id: cache-xcframework
uses: actions/cache/save@v4
with:
path: MoproiOSBindings
key: ${{ github.sha }}-xcframework
build-ios-app-device:
runs-on: macos-latest
needs: build-xcframework
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore cached xcframework
id: cache-restore-xcframework
uses: actions/cache/restore@v4
with:
path: MoproiOSBindings
key: ${{ github.sha }}-xcframework
- name: Build app for device
run: xcodebuild -project ./ios/mopro-test.xcodeproj -scheme mopro-test -destination generic/platform=iOS build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
build-ios-app-simulator:
runs-on: macos-latest
needs: build-xcframework
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore cached xcframework
id: cache-restore-xcframework
uses: actions/cache/restore@v4
with:
path: MoproiOSBindings
key: ${{ github.sha }}-xcframework
- name: Build app for device
run: xcodebuild -project ./ios/mopro-test.xcodeproj -scheme mopro-test -destination generic/platform=iOS\ Simulator build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
test-ios-app-simulator:
runs-on: macos-14
needs: build-xcframework
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Restore cached xcframework
id: cache-restore-xcframework
uses: actions/cache/restore@v4
with:
path: MoproiOSBindings
key: ${{ github.sha }}-xcframework
# to list available simulators: xcrun simctl list devices
- name: Test app in simulator
run: xcodebuild -project ./ios/mopro-test.xcodeproj -scheme mopro-test -destination 'platform=iOS Simulator,name=iPhone 15' test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
build-android-app:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Setup Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17

- name: Setup Android SDK
uses: android-actions/setup-android@v2.0.10
- name: Build android library
run: cargo run --bin android
- name: Build android app
run: cd android && ./gradlew build
9 changes: 9 additions & 0 deletions gpu-acceleration-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/target
*.udl
.DS_Store

MoproBindings.xcframework/
build/
jniLibs/
MoproAndroidBindings/
MoproiOSBindings/
Loading

0 comments on commit 5d9611b

Please sign in to comment.