Skip to content

Mock external LibOME - #562

Open
AkshatRai07 wants to merge 7 commits into
masterfrom
extern-libome
Open

Mock external LibOME#562
AkshatRai07 wants to merge 7 commits into
masterfrom
extern-libome

Conversation

@AkshatRai07

Copy link
Copy Markdown
Collaborator

A step for #519.
In this PR we:

  • Add a C++ library in extras/gsoc/libome.
  • Compile it using build.rs.
  • Consume the library in as3.rs.
  • Update functions and tests across ekore, ekore_capi, and ekore_py.

This successfully demonstrates that it is possible to call an external library from the ekore crate without hindering performance. If the library uses cmake for build, we can simply change it in Cargo.toml.

Copilot AI lite review requested due to automatic review settings August 29, 2026 06:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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++ libome with a C ABI and compile/link it into crates/ekore via build.rs.
  • Introduce as3 OME implementation in ekore that calls libome and extend OME tower support up to N3LO.
  • Update C API + Python wrappers/tests to accept order < 4 and 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_ns still passes nf/eta as u32/i32 even though the C ABI uses unsigned int/int. To keep the ABI correct across platforms, cast to std::ffi::c_uint / std::ffi::c_int consistently 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.

Comment thread crates/ekore/build.rs
Comment thread crates/ekore/build.rs

fn main() {
let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let libome_dir = manifest_dir.join("../../extras/gsoc/libome");

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants