Skip to content

Conversation

@HaoZeke
Copy link
Contributor

@HaoZeke HaoZeke commented Oct 8, 2024

The design is still being threshed out.

meson setup bbdir -Dwith_rpc=True
meson compile -C bbdir
./bbdir/CppCore/rgpot/rpc/potserv 125697
python CppCore/rgpot/rpc/pyclient.py localhost:125697

@HaoZeke
Copy link
Contributor Author

HaoZeke commented Oct 8, 2024

Note that, thankfully, there is no real difference between working with this "simpler interface":

@0xbd1f89fa17369103;

# Design kanged from eOn v4 C-style structs
# TODO(rg): Should be more object oriented

struct ForceInput {
 natm   @0 :Int32; # TODO(rg): Do we really need this..
 pos    @1 :List(Float64);
 atmnrs @2 :List(Int32);
 box    @3 :List(Float64);
}

struct PotentialResult {
  energy @0: Float64;
  forces @1: List(Float64);
}

interface CuH2Pot {
  calculate @0 (fip :ForceInput)
    -> (result :PotentialResult);
}

Or this redundant one:

struct Position {
  x @0 :Float64;
  y @1 :Float64;
  z @2 :Float64;
}

struct AtomMatrixRPC {
  positions @0 :List(Position);
}

struct BoxMatrix {
  box @0: List(Vector);
}

struct Vector {
  x @0: Float64;
  y @1: Float64;
  z @2: Float64;
}

struct AtomTypes {
  atomTypes @0: List(Int32);
}

struct PotentialResult {
  energy @0: Float64;
  forces @1: List(ForceVector);
}

struct ForceVector {
  x @0: Float64;
  y @1: Float64;
  z @2: Float64;
}

interface CuH2Pot {
  calculate @0 (positions :AtomMatrixRPC, atomTypes :AtomTypes, boxMatrix :BoxMatrix)
    -> (result :PotentialResult);
}

Which is essentially the design in 0e3d99c and 1dd36ad.

Basically there is no time difference for running two servers.

Command Mean [ms] Min [ms] Max [ms] Relative
python oclient.py localhost:12345 108.8 ± 12.7 98.9 143.3 1.00
python pyclient.py localhost:12346 109.4 ± 18.3 99.0 182.8 1.01 ± 0.21

Where oclient is the ForceInput variant, and pyclient is the redundant form.

Essentially this seems to suggest that more nested structures are OK, which is better (needs testing of course for buffer size)

@HaoZeke HaoZeke requested a review from Copilot August 13, 2025 13:30

This comment was marked as outdated.

HaoZeke and others added 3 commits August 13, 2025 15:38
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@HaoZeke HaoZeke requested a review from Copilot August 13, 2025 13:44
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces RPC (Remote Procedure Call) support to the project using Cap'n Proto. The implementation allows for remote calculation of potential energies and forces for the CuH2 potential through a client-server architecture.

  • Adds Cap'n Proto RPC server and Python client implementation for remote potential calculations
  • Updates C++ standard to C++20 and adds necessary dependencies (capnproto, pycapnp, etc.)
  • Includes build system integration with conditional RPC compilation

Reviewed Changes

Copilot reviewed 12 out of 14 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pixi.toml Adds Cap'n Proto and Python dependencies for RPC support
meson_options.txt Adds with_rpc build option to conditionally enable RPC features
meson.build Updates C++ standard from C++17 to C++20 for RPC compatibility
CppCore/rgpot/rpc/server.cpp Implements Cap'n Proto RPC server for CuH2 potential calculations
CppCore/rgpot/rpc/pyclient.py Python client for connecting to and using the RPC server
CppCore/rgpot/rpc/meson.build Build configuration for RPC server and library
CppCore/rgpot/rpc/Potentials.capnp Cap'n Proto schema definition for potential calculation interface
CppCore/rgpot/LennardJones/meson.build Code formatting improvements
CppCore/rgpot/CuH2/meson.build Code formatting improvements
CppCore/meson.build Integrates RPC subdirectory when option is enabled
.pre-commit-config.yaml Adds meson formatting to pre-commit hooks
.github/workflows/build_test.yml Renames job from buildmamba to buildpixi

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

1 participant