Skip to content

Port shared-partner changestats to the C++ term API#655

Draft
krivit with Copilot wants to merge 4 commits into
masterfrom
copilot/convert-sp-code-to-cpp
Draft

Port shared-partner changestats to the C++ term API#655
krivit with Copilot wants to merge 4 commits into
masterfrom
copilot/convert-sp-code-to-cpp

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The shared-partner changestats were implemented as a dense C macro expansion over edgewise/dyadwise, six SP configurations, and three calculation modes. This change moves the public changestat entry points onto the C++ term API and updates the triadic proposal code to use the same shared-partner dispatch helpers.

  • C++ changestat entry points

    • Replaces src/changestats_dgw_sp.c with src/changestats_dgw_sp.cpp.
    • Ports the ddsp, dgwdsp, desp, dgwesp, dnsp, and dgwnsp entry points (plus distribution/bipartite wrappers) to C_CHANGESTAT_CPP(...).
    • Keeps the existing SP traversal semantics intact while expressing the top-level dispatch and stat updates in C++.
  • Shared helper dispatch

    • Adds C++ helper functions in src/changestats_dgw_sp.h to dispatch dsp* / esp* logic by L2Type.
    • Consolidates repeated per-type selection in one place, including the nonzero-dyad delta used by proposal code.
  • Triadic proposal update

    • Updates src/MHproposals_triadic.cpp to call the new shared-partner helper instead of expanding the legacy header macros directly.
    • Preserves the existing unsupported-RTP behavior in the proposal path.

Example of the new dispatch style:

C_CHANGESTAT_CPP(dgwdsp, {
    auto *spcache = get_spcache(mt);
    L2Type type = static_cast<L2Type>(mt.iinput[0]);

    double cumchange = dsp_path_multiplier(type) == 1
      ? dsp_gw_change<1>(type, tail, head, nwp, edgestate, spcache, alpha, loneexpa)
      : dsp_gw_change<2>(type, tail, head, nwp, edgestate, spcache, alpha, loneexpa);

    mt.stat[0] = edgestate ? -cumchange : cumchange;
  })

Copilot AI linked an issue Jul 1, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Convert sp code to C++ template with updated MHproposals Port shared-partner changestats to the C++ term API Jul 1, 2026
Copilot finished work on behalf of krivit July 1, 2026 08:12
Copilot AI requested a review from krivit July 1, 2026 08:12
@krivit

krivit commented Jul 1, 2026

Copy link
Copy Markdown
Member

@copilot Also modify the sp_change() functions to use the C++ network API and incorporate them as templates.

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Also modify the sp_change() functions to use the C++ network API and incorporate them as templates.

Addressed in a9a9b21.

Copilot finished work on behalf of krivit July 1, 2026 08:30
@krivit

krivit commented Jul 1, 2026

Copy link
Copy Markdown
Member

@copilot Assume that changestats_dgw_sp.h will only ever be invoked from C++, and remove no-longer-used macros.

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Assume that changestats_dgw_sp.h will only ever be invoked from C++, and remove no-longer-used macros.

Addressed in 122588c.

Copilot finished work on behalf of krivit July 1, 2026 08:39
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.

Convert the *sp code to C++?

2 participants