Mock external LibOME - #562
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The new FFI/build integration has portability and distribution risks (C ABI integer types and C++ build inputs outside the crate) that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces a mock external C++ libome (C ABI) and wires it into ekore to provide N3LO (a_s^3) unpolarized, space-like OME entries, then propagates the new supported order and shapes through the C and Python bindings/tests.
Changes:
- Add mock C++
libomewith a C ABI and compile/link it intocrates/ekoreviabuild.rs. - Introduce
as3OME implementation inekorethat callslibomeand extend OME tower support up to N3LO. - Update C API + Python wrappers/tests to accept order
< 4and validate the new N3LO slot.
File summaries
| File | Description |
|---|---|
| extras/gsoc/libome/README.md | Documents the mock C++ library and its dummy-return behavior for FFI testing. |
| extras/gsoc/libome/ome.h | Declares the C ABI surface (complex struct + N3LO OME function prototypes). |
| extras/gsoc/libome/ome.cpp | Implements the mock ABI functions returning dummy complex zeros. |
| crates/ekore/src/operator_matrix_elements/unpolarized/spacelike/as3.rs | New N3LO OME implementation calling the external C ABI. |
| crates/ekore/src/operator_matrix_elements/unpolarized/spacelike.rs | Extends OME tower to include as3 (N3LO) and updates tests accordingly. |
| crates/ekore/Cargo.toml | Adds cc as a build-dependency for compiling the external C++ code. |
| crates/ekore/build.rs | Compiles and links the mock C++ library into ekore. |
| crates/ekore_py/tests/test_ome_us.py | Updates Python tests for new supported order and N3LO zeros. |
| crates/ekore_py/src/ome_us.rs | Updates Python wrapper guard/limits to support order < 4. |
| crates/ekore_capi/tests/c/test_ome_us.c | Updates C tests for new result lengths and N3LO zeros. |
| crates/ekore_capi/src/ome_us.rs | Updates C API guard/limits and result-length helpers for order < 4. |
| Cargo.toml | Adds cc to workspace dependencies. |
| Cargo.lock | Locks cc and related transitive dependencies. |
Review details
Suppressed comments (1)
crates/ekore/src/operator_matrix_elements/unpolarized/spacelike/as3.rs:62
A_nsstill passesnf/etaas u32/i32 even though the C ABI usesunsigned int/int. To keep the ABI correct across platforms, cast tostd::ffi::c_uint/std::ffi::c_intconsistently here as well.
pub(super) fn A_ns(c: &mut Cache, nf: u8, L: f64) -> [[Complex<f64>; 2]; 2] {
let n: OmeComplex = c.n().into();
let nf_u32 = u32::from(nf);
let a_qq_ns = unsafe { Complex::from(ome_as3_AqqNS(n, nf_u32, L, -1)) };
- Files reviewed: 12/13 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
|
||
| fn main() { | ||
| let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); | ||
| let libome_dir = manifest_dir.join("../../extras/gsoc/libome"); |
There was a problem hiding this comment.
This is just a mock library, there is no need to push this to crates.io. @felixhekhorn if it is required then do let me know I'll change the location of this lib. I don't think people will be doing cargo add ekore for a while, since it is incomplete and it is more convenient to use ekore_capi and ekore_py instead.
A step for #519.
In this PR we:
extras/gsoc/libome.build.rs.as3.rs.ekore,ekore_capi, andekore_py.This successfully demonstrates that it is possible to call an external library from the
ekorecrate without hindering performance. If the library usescmakefor build, we can simply change it inCargo.toml.