# mopro-21 milestone_3 report :::info Latest Updated: Feb. 21st, 2024 ::: [TOC] ## Things we have done ### Implement reusable testing interface on iOS app We build the testing inferface that can easily integrate with more MSM algorithms. This resuable feature allow us to move faster in further works about benchmarking other MSM algorithms and find the suitable one with mobile GPU. <u>**reproducing steps (from root directory):**</u> 1. Modify the `mopro-ffi/Cargo.toml` ```toml [features] default = [] --> comment this line # default = ["gpu-benchmarks"] --> Uncomment this line ``` 2. Build the UniFFI bindings by `cd mopro-ffi && make` 3. Update bindings by `cd .. && ./scripts/update_bindings.sh config-example.toml` 4. Open the `mopro-ios/MoproKit/Example/MoproKit.xcworkspace` in Xcode 5. Build the project and open the iOS simulator to check the interface #### Result Screenshots | [iOS Simulator Demo](https://youtu.be/c0FrjWPrqxY) ![Simulator Screenshot - iPhone 15 Pro - Mopro Examples](https://hackmd.io/_uploads/B1ICFBGhT.png =45%x) ![Simulator Screenshot - iPhone 15 Pro - MSM Benchmark >](https://hackmd.io/_uploads/rJCsKrGnT.png =45%x) ### Run benchmarking on real-device <u>**reproducing steps (from root directory):**</u> 1. Modify the `mopro-ffi/Cargo.toml` ```toml [features] default = [] --> comment this line # default = ["gpu-benchmarks"] --> Uncomment this line ``` 2. Build the UniFFI bindings by `cd mopro-ffi && make` 3. Open `config-example.toml` in the root dir and change `device_type` from `simulator` to `device` 4. Update bindings by `cd .. && ./scripts/update_bindings.sh config-example.toml` 5. Open the `mopro-ios/MoproKit/Example/MoproKit.xcworkspace` in Xcode 6. Plug in you iOS device and connect to your Mac 7. Select your device and build the project (using `cmd + R`) 8. Check on your iOS device. #### Result Screenshot | [iPhone Demo](https://youtu.be/l-8MvycDTHY) (Run on iPhone 14 Pro) <img src="https://hackmd.io/_uploads/B1pgIUf3p.png" alt ="Real device screen shot on iphone 14 pro" width="45%x"/> *Real device screen shot conducted on iphone 14 pro* ### Docs about enabling benchmarking of msm algorithms - Guidance of generating MSM benchmark report on `mopro/mopro-ios/README.md` - Performance update on `mopro/README.md` ## Summary of the proposal 1. Benchmark Arkwork MSM across laptops, iOS simulators, and iPhones. | | laptop<br>(Rust test) | laptop<br>(Swift test) | iOS Simulator<br>[Demo Video](https://youtu.be/c0FrjWPrqxY) | iPhone<br>[Demo Video](https://youtu.be/l-8MvycDTHY) | |:---------------------------------:|:------------------------------------------------------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------:| | Timing<br>(Single Arkworks MSM) | 0.33 ms | 0.37 ms | 0.31 ms | 0.27 ms | | Device Spec | M2 chip | M2 chip | M2 chip | iPhone 14 Pro<br>(A16 Bionic) | | Screenshots<br>(Click to enlarge) | [<img src="https://hackmd.io/_uploads/Sy1l9Mmh6.png" alt ="MSM Rust test" width="1000px"/>](https://hackmd.io/_uploads/Sy1l9Mmh6.png) | [<img src="https://hackmd.io/_uploads/rkEl5G736.png" alt ="MSM Swift test" width="1009px"/>](https://hackmd.io/_uploads/rkEl5G736.png) | [<img src="https://hackmd.io/_uploads/HJttqMQha.png" alt ="MSM iOS Simulator" width="30%x"/>](https://hackmd.io/_uploads/HJttqMQha.png) | [<img src="https://hackmd.io/_uploads/B1pgIUf3p.png" alt ="MSM iPhone 14 pro" width="30%x"/>](https://hackmd.io/_uploads/B1pgIUf3p.png) | 2. Integrate the Arkworks MSM algorithm as the baseline in Rust and make it executable in Swift with UniFFI. 3. Launch a testing interface on mobile for further MSM algorithm benchmarking. ## TODO Log ### iOS - [x] Design the way to illustrate the benchmark of this - [x] A swift file that maps all algorithm from uniffi to swift. <u>Make it the only file we need to change if added a new algorithm.</u> - [x] A swift file for UI - [x] A component to show the integrated algorithm - [x] Rendering the mapped algorithm and wrapped it into components - [x] A button component for "Generating Benchmarks" - [x] A swift file for report generating logic - [x] show a table for (`num_msm`) | Algorithm | Avg Timing | Compare to baseline <br>(arkwork-msm)</br> | | ----------- | --------------- |:------------------------------------------:| | arkworks-msm | in ms | - | | Algo. A | in ms | in % | | Algo. B | in ms | in % | - [x] [Backlog] show a figure ## Future Work ### improve MSM performance on mobile GPU - [Mopro 22 proposal](https://github.com/privacy-scaling-explorations/acceleration-program/issues/34) ### Backlog items - Benchmarking on memory usage - Generate figure and show them on iOS device ## Reference - [morpo#21](https://github.com/oskarth/mopro/issues/21#issue-1966426073)