Skip to content

refactor: move distributed awareness to PGBL - #583

Open
Becheler wants to merge 1 commit into
boostorg:developfrom
Becheler:refactor/drop-mpi-pbgl-awareness
Open

refactor: move distributed awareness to PGBL#583
Becheler wants to merge 1 commit into
boostorg:developfrom
Becheler:refactor/drop-mpi-pbgl-awareness

Conversation

@Becheler

@Becheler Becheler commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

This is a cross-repo change and comes with a companion PR in PBGL : boostorg/graph_parallel#47

In short: When Boost was modularized, the PBGL part moved to the graph_parallel repository, but the forwarding hooks, use_mpi.hpp, and the MPI build wiring remained in graph. This PR closes the migration story.

Before submitting

  • This PR targets the develop branch.
  • I searched for an existing PR or issue covering the same change.
  • My contribution is licensed under the Boost Software License 1.0.

Type of change

  • Bug fix
  • New feature or API addition
  • Refactor (no behavior change)
  • Documentation
  • Build, CI, or tooling
  • Other (specify below)

Does this PR introduce a breaking change?

  • Yes (describe migration impact below)
  • No

What this PR does

  • Deleted use_mpi.hpp, detail/mpi_include.hpp, detail/empty_header.hpp
  • Stripped the forwarding hooks from all 11 algorithm headers:
    • top mpi_include.hpp include
    • trailing BOOST_GRAPH_MPI_INCLUDE(...)),
    • the BFS distributed/concepts.hpp forward
    • the #ifdef BOOST_GRAPH_USE_MPI bfs_helper declaration block.
  • Removed the three MPI regions from pending/property_serialize.hpp (kept the two generic serialize() overloads).
  • Removed import mpi from build/Jamfile.v2

Motivation

  • PBGL was historically developed inside libs/graph. To let one code path run sequentially or distributed, the sequential headers included their distributed counterparts when BOOST_GRAPH_USE_MPI. was defined. When Boost was modularized, PBGL moved to the graph_parallel repository, but the forwarding hooks, use_mpi.hpp, and the MPI build wiring remained in graph.
  • So the dependency was unfortunately inverted: BGL names and its build depends on its own downstream consumer, pulling MPI and Boost.Serialization into its dependency graph.
  • In 2018, commit 5f1edca5 (Peter Dimov) wrapped the includes in a BOOST_GRAPH_MPI_INCLUDE macro to hide them from boostdep: the reported dependency disappeared but the actual coupling did not (build/Jamfile.v2 still runs import mpi).
  • The forwarding feature itself was actually partially broken today with Fruchterman–Reingold: distributed/fruchterman_reingold.hpp uses point_traits but no header on any include path pulls in boost/graph/point_traits.hpp. So #define BOOST_GRAPH_USE_MPI + #include <boost/graph/fruchterman_reingold.hpp> has never compiled in any release. No distributed test covers this so it went unnoticed.

The user contract (remains unchanged with this PR):

"include <boost/graph/use_mpi.hpp> first, then the serial algorithm header, get the distributed version for free":

It allows to write code like:

#include <boost/graph/use_mpi.hpp> // first, always
#include <boost/graph/distributed/mpi_process_group.hpp>
#include <boost/graph/distributed/adjacency_list.hpp>
#include <boost/graph/breadth_first_search.hpp> // sequential header only

using namespace boost;

typedef adjacency_list<vecS,
    distributedS<graph::distributed::mpi_process_group, vecS>,
    undirectedS> Graph;

int main(int argc, char* argv[])
{
    mpi::environment env(argc, argv);
    Graph g(100);
    // runs the distributed BFS, its header never included by name
    breadth_first_search(g, vertex(0, g), visitor(default_bfs_visitor()));
}
  • The file keeps the same path <boost/graph/use_mpi.hpp> but it ships from graph_parallel instead of graph. Existing includes resolve unchanged.
  • the forwarding mechanism is preserved: the relocated use_mpi.hppincludes all the distributed algorithm headers, a user who includes only the sequential <boost/graph/breadth_first_search.hpp> and calls it on a distributed graph still gets the distributed overload.
  • Users who already include distributed/… headers explicitly are of course unaffected.

Testing

This was locally verified: 5 in-tree PBGL tests/examples that rely on this pattern compiled with zero edits.

Checklist

  • Existing tests pass (b2 in the test/ directory).
  • New behavior is covered by a test, or this is a docs / build / refactor change.
  • Documentation was updated if user-facing behavior changed.
  • No new compiler warnings on the platforms I built against.

@Becheler Becheler self-assigned this Sep 1, 2026
@Becheler Becheler added technical debt Code that works but needs refactoring, cleanup, or modernization. Not user-facing. dependencies Pull requests that update a dependency file labels Sep 1, 2026
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Boost dependency footprint vs develop (auto-generated).
PR run 33504971594 vs develop run 33494674376 (417011fa53).

Header-inclusion weights (graph files pulling each direct dependency in):

No header-inclusion-weight changes.

Transitive Boost modules: 66 → 66 (0)

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

Compiler-warning counts vs develop (auto-generated).
PR run 33504971560 vs develop run 33494674338 (417011fa53).

Job Baseline After Delta
macos (clang, 14) 648 648 0
macos (clang, 17) 611 611 0
macos (clang, 20) 611 611 0
ubuntu (clang-19, 14) 648 648 0
ubuntu (clang-19, 17) 611 611 0
ubuntu (clang-19, 20) 611 611 0
ubuntu (clang-19, 23) 611 611 0
ubuntu (gcc-14, 14) 801 801 0
ubuntu (gcc-14, 17) 937 937 0
ubuntu (gcc-14, 20) 937 937 0
ubuntu (gcc-14, 23) 937 937 0
windows_msvc_14_3 (msvc-14.3) 961 961 0

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Becheler Becheler changed the title refactor: move PBGL awareness to PGBL refactor: move distributed awareness to PGBL Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file technical debt Code that works but needs refactoring, cleanup, or modernization. Not user-facing.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant