-
Notifications
You must be signed in to change notification settings - Fork 44
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
aot library load #354
Closed
aot library load #354
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edg-l
force-pushed
the
to_object_llvm
branch
from
November 28, 2023 11:40
ac64529
to
3f5549f
Compare
Benchmarking resultsBenchmark for program
|
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
20.858 ± 0.095 | 20.635 | 20.957 | 44.17 ± 0.22 |
cairo-native (JIT MLIR ORC Engine) |
1.588 ± 0.047 | 1.533 | 1.662 | 3.36 ± 0.10 |
cairo-native (AOT Native binary) |
0.661 ± 0.003 | 0.659 | 0.669 | 1.40 ± 0.01 |
cairo-native (AOT Native binary with host CPU features, march=native) |
0.472 ± 0.001 | 0.471 | 0.475 | 1.00 |
Benchmark for program fib_2M
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
20.415 ± 0.093 | 20.272 | 20.545 | 651.21 ± 9.90 |
cairo-native (JIT MLIR ORC Engine) |
1.172 ± 0.026 | 1.136 | 1.223 | 37.39 ± 0.99 |
cairo-native (AOT Native binary) |
0.031 ± 0.000 | 0.031 | 0.033 | 1.00 |
cairo-native (AOT Native binary with host CPU features, march=native) |
0.032 ± 0.001 | 0.031 | 0.037 | 1.02 ± 0.04 |
Benchmark for program logistic_map
Open benchmarks
Command | Mean [s] | Min [s] | Max [s] | Relative |
---|---|---|---|---|
Cairo-vm (Rust, Cairo 1) |
2.016 ± 0.031 | 1.966 | 2.068 | 28.62 ± 0.63 |
cairo-native (JIT MLIR ORC Engine) |
1.509 ± 0.011 | 1.493 | 1.526 | 21.42 ± 0.37 |
cairo-native (AOT Native binary) |
0.109 ± 0.001 | 0.109 | 0.113 | 1.55 ± 0.03 |
cairo-native (AOT Native binary with host CPU features, march=native) |
0.070 ± 0.001 | 0.070 | 0.074 | 1.00 |
Closing as #363 supersedes this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does
Using the libloading crate, we load the compiled library and call the entrypoint using the
_mlir_cifafe_
wrapper that gives us aextern "C"
function callable from Rust side.The problem
The problem is figuring out the correct signature and how to pass the correct arguments.
For now I reduced the scope to just calling contract function wrappers, which are produced by cairo->sierra when compiling a starknet contract, they always have the same signature:
I still havent figured out how to give the arguments correctly, right now i re-use the JIT value to construct the values:
But doesn't seem to work out well, because the later code calls a pop_front on the calldata we pass, and somehow when loading the first element, it SEGFAULTS, the part creating the segfault is here:cairo_native/src/libfuncs/array.rs
Lines 694 to 704 in 7a5a006
Edit: the segfault is no longer there after providing with 1 more argument, it seems the calldata pointer is picked up correctly, but there is a memmove involved in the pop_front that causes a segfault, probably due to misalignment (?) or it could also be because the pointer is not from libc, although i think the array is allocated using rust libc crate, but there may be issued if both libc versions arent exactly the same?.
macOS
On macOS i didn't get the segfault and i got to print some values returned, but they didn't make much sense, i think its also because the arguments are passed wrongly but somehow the execution went through. I also did not see any prints from the syscall handler which means something went wrong there too.
Reproducing
Testing is done using the aot.rs example.
You will need to change some lines because right now to use the cairo_runtime library from this same repo i use hardcoded paths, you can change them here:
cairo_native/src/ffi.rs
Lines 154 to 187 in 7a5a006
To run:
cargo b --all-features --all-targets --examples # Then to debug i use rust-gdb on linux and rust-lldb on macos: rust-gdb ./target/debug/examples/aot