-
-
Notifications
You must be signed in to change notification settings - Fork 259
Create parallel communication graph and support NetworkX analysis and visualiation #3803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 71 commits
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
7be4888
Work on more detailed IndexMap stats
chrisrichardson 62461ba
more stats
chrisrichardson 465d86f
More stats
chrisrichardson fa563e1
Compile more data
chrisrichardson 7f2cfe3
Remove imbalance
chrisrichardson 2922087
Remove imbalance from Python
chrisrichardson 516cf1c
Provide more detail
chrisrichardson f1a8c83
Index map split
garth-wells 50c95c3
Work on docs and tests
garth-wells a05d33c
Add placeholder
garth-wells 8c11c05
Implement function
garth-wells f7e1846
Remove OpenMPI-specific test
garth-wells 1377838
Updates
garth-wells 5fada56
Merge remote-tracking branch 'origin/main' into chris/index-map-stats
garth-wells 008b4b9
Work on edge weights
garth-wells 6c6879b
Add simple test
garth-wells 061ed7c
Merge remote-tracking branch 'origin/main' into chris/index-map-stats
garth-wells 5e2214a
Work on stats
garth-wells 54d5cee
Work on stats
garth-wells 63d392a
Use ranges
garth-wells 85879d0
Updates
garth-wells 3ca32e8
Updates
garth-wells f5c74a9
Simplify
garth-wells a74ff21
Type fix
garth-wells 69b2fde
Enable init
garth-wells 2ea25ea
Improve error message
garth-wells 869fecd
Test
garth-wells 9ae999b
Fix test
garth-wells 2791a4b
Format
garth-wells 4995a25
Enable
garth-wells 2db4690
Testing
garth-wells 64fef27
Fix
garth-wells c7ffb23
lint
garth-wells b2c1618
Enable
garth-wells 358a75b
Re-enable
garth-wells 37282e1
Work on stats
garth-wells ef9e2d8
Simplify
garth-wells 42bab4f
Merge remote-tracking branch 'origin/main' into chris/index-map-stats
garth-wells 4f2b340
Updates
garth-wells cb0371a
Add networkx demo
garth-wells fcf0d5e
mypy fix
garth-wells 7eb3e18
lint
garth-wells 1db0433
lint
garth-wells 134b384
Fix type hints
garth-wells a602d35
Fix
garth-wells a45a734
Type fixes
garth-wells cf429c9
Update test
garth-wells 6135182
Merge remote-tracking branch 'origin/main' into garth/indexmap-stats
garth-wells 54abf24
Simplify
garth-wells fd70271
Work on comm plotting
garth-wells 80245ba
Improve demo
garth-wells a6e7af1
Tidy up
garth-wells 2431574
Test update
garth-wells 4039396
Misc fixes
garth-wells 459a49d
Doc fixes
garth-wells 0ee3e28
Fixes
garth-wells 5d8ae26
Fixes
garth-wells ac67278
Include fixes
garth-wells b89e810
Add networkx for conda
garth-wells 3ba1b58
Demo name fixes
garth-wells 1277f87
Update names
garth-wells 3e9ed9b
Fix extension
garth-wells 61f1405
Add demo plot options
garth-wells c0877f2
Merge remote-tracking branch 'origin/main' into garth/indexmap-stats
garth-wells 925b744
Doc fix
garth-wells 0d62a47
Add bar chart plots
garth-wells 42ba28e
Remove C++ IndexMap stats code
garth-wells 9c95749
Update python/dolfinx/wrappers/graph.cpp
garth-wells c91512f
Merge branch 'main' into garth/indexmap-stats
garth-wells b78c449
Update test
garth-wells 44c71bf
Merge branch 'garth/indexmap-stats' of github.com:FEniCS/dolfinx into…
garth-wells 35437cb
Update cpp/dolfinx/common/IndexMap.h
garth-wells aade8a0
Update python/demo/demo_comm-pattern.py
garth-wells ead6823
Update cpp/dolfinx/common/IndexMap.h
garth-wells d6f3255
Update node weights
garth-wells 71956db
Merge branch 'garth/indexmap-stats' of github.com:FEniCS/dolfinx into…
garth-wells 2a9c464
Doc fixes
garth-wells dd28a96
Comment fixes
garth-wells 21e5837
More fixes
garth-wells d7b3d39
Lint
garth-wells 70caf90
Use free function
garth-wells e2ebcc5
Simplify
garth-wells 9db7f81
Merge remote-tracking branch 'origin/main' into garth/indexmap-stats
garth-wells b4a8fda
Fix merge
garth-wells 7fcd0b6
Merge branch 'main' into garth/indexmap-stats
garth-wells de31e39
Merge branch 'main' into garth/indexmap-stats
garth-wells 156e26b
Merge remote-tracking branch 'origin/main' into garth/indexmap-stats
garth-wells 6367f6f
Small updates
garth-wells e317647
Small formatting updates
garth-wells 6e8d444
Move code to avoid (possible) circular dependencies.
garth-wells f9b294a
Tidy
garth-wells 9916c7d
Add files
garth-wells 8e89c16
Wrap funtionality
garth-wells b706609
Work in docs
garth-wells db31949
Fix imports
garth-wells 70ddda1
Work in docs
garth-wells 4d0a5ef
Update cpp tests
garth-wells d004f99
Doc fix
garth-wells f838ee4
Doc fix
garth-wells File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ dependencies: | |
| - mpi4py | ||
| - mpich | ||
| - nanobind | ||
| - networkx | ||
| - ninja | ||
| - numba | ||
| - numpy | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,10 +7,13 @@ | |||||
| #pragma once | ||||||
|
|
||||||
| #include "IndexMap.h" | ||||||
| #include "MPI.h" | ||||||
| #include <cstdint> | ||||||
| #include <dolfinx/common/MPI.h> | ||||||
| #include <dolfinx/graph/AdjacencyList.h> | ||||||
| #include <memory> | ||||||
| #include <span> | ||||||
| #include <string> | ||||||
| #include <tuple> | ||||||
| #include <utility> | ||||||
| #include <vector> | ||||||
|
|
||||||
|
|
@@ -255,22 +258,101 @@ class IndexMap | |||||
| /// and sorted. | ||||||
| std::span<const int> dest() const noexcept; | ||||||
|
|
||||||
| /// @brief Returns the imbalance of the current IndexMap. | ||||||
| /// @brief Compute the number of ghost indices owned by each rank in | ||||||
| /// IndexMap::src. | ||||||
| /// | ||||||
| /// The imbalance is a measure of load balancing across all processes, | ||||||
| /// defined as the maximum number of indices on any process divided by | ||||||
| /// the average number of indices per process. This function | ||||||
| /// calculates the imbalance separately for owned indices and ghost | ||||||
| /// indices and returns them as a std::array<double, 2>. If the total | ||||||
| /// number of owned or ghost indices is zero, the respective entry in | ||||||
| /// the array is set to -1. | ||||||
| /// This is a measure of the amount of data: | ||||||
| /// | ||||||
| /// @note This is a collective operation and must be called by all | ||||||
| /// processes in the communicator associated with the IndexMap. | ||||||
| /// 1. Sent from this rank to other ranks when performing a reverse | ||||||
| /// (owner <- ghost) scatter. | ||||||
| /// | ||||||
| /// @return An array containing the imbalance in owned indices (first | ||||||
| /// element) and the imbalance in ghost indices (second element). | ||||||
| std::array<double, 2> imbalance() const; | ||||||
| /// 2. Received by this rank from other ranks when performing a | ||||||
| /// forward (owner -> ghost) scatter. | ||||||
| /// | ||||||
| /// @return A weight vector, where `weight[i]` the the number of | ||||||
| /// ghost indices owned by rank IndexMap::src()`[i]`. | ||||||
| std::vector<std::int32_t> weights_src() const; | ||||||
|
|
||||||
| /// @brief Compute the number of ghost indices owned by each rank in | ||||||
| /// IndexMap::dest. | ||||||
| /// | ||||||
| /// This is a measure of the amount of data: | ||||||
| /// | ||||||
| /// 1. Sent from this rank to other ranks when performing a forward | ||||||
| /// (owner -> ghost) scatter. | ||||||
| /// | ||||||
| /// 2. Received by this rank from other ranks when performing a | ||||||
| /// reverse forward (owner <- ghost) scatter. | ||||||
| /// | ||||||
| /// @return A weight vector, where `weight[i]` the the number of ghost | ||||||
| /// indices owned by rank IndexMap::dest()`[i]`. | ||||||
| std::vector<std::int32_t> weights_dest() const; | ||||||
|
|
||||||
| /// @brief Destination and source ranks by type, e.g, ranks that are | ||||||
| /// destination/source ranks for the caller and are in an common | ||||||
| /// shared memory region. | ||||||
| /// | ||||||
| /// This function is used to group destination and source ranks by | ||||||
| /// 'type'. The type is defined by the MPI `split_type`. Split types | ||||||
| /// include ranks from a common shared memory region | ||||||
| /// (`MPI_COMM_TYPE_SHARED`) or a common NUMA region. Splits types are | ||||||
| /// listed at See | ||||||
|
garth-wells marked this conversation as resolved.
Outdated
|
||||||
| /// https://docs.open-mpi.org/en/main/man-openmpi/man3/MPI_Comm_split_type.3.html#split-types. | ||||||
| /// | ||||||
| /// @note Collective operation on comm(); | ||||||
|
garth-wells marked this conversation as resolved.
Outdated
|
||||||
| /// | ||||||
| /// @param[in] split_type MPI split type, as used in the function | ||||||
| /// `MPI_Comm_split_type`. See | ||||||
| /// https://docs.open-mpi.org/en/main/man-openmpi/man3/MPI_Comm_split_type.3.html#split-types. | ||||||
| /// @return (0) Intersection of ranks in `split_type` and in dest(), | ||||||
| /// and (1) intersection of ranks in `split_type` and in src(). | ||||||
|
garth-wells marked this conversation as resolved.
|
||||||
| /// Returned ranks are on the comm() communicator. | ||||||
|
garth-wells marked this conversation as resolved.
|
||||||
| std::array<std::vector<int>, 2> rank_type(int split_type) const; | ||||||
|
|
||||||
| /// @brief Compute an directed graph that describes the parallel | ||||||
| /// communication patterns. | ||||||
| /// | ||||||
| /// The graph describes the communication pattern for a 'forward | ||||||
| /// scatter', i.e. sending owned data to ranks that ghost the data | ||||||
| /// (owner->ghost operation). | ||||||
| /// | ||||||
| /// Each node in the graph corresponds to an MPI rank. A graph edge is | ||||||
| /// a forward (owner->ghost) communication path. The edge weight is | ||||||
| /// the number 'values' communicated along the edge. Each edge also | ||||||
| /// has a marker that indicates if the edge is sending data to: | ||||||
| /// | ||||||
| /// 1. A node (rank) that shares memory with the sender (`true`), or | ||||||
| /// | ||||||
| /// 2. A remote node that does not share memory with the sender | ||||||
| /// (`false`). | ||||||
| /// | ||||||
| /// The graph data can be visualised using a tool like | ||||||
| /// [NetworkX](https://networkx.org/), | ||||||
| /// | ||||||
| /// @note Collective. | ||||||
| /// | ||||||
| /// @param[in] root MPI rank on which the build the communication | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| /// graph data. | ||||||
| /// @return Adjacency list representing the communication pattern, | ||||||
| /// where edges data is (0) the edge, (1) edge weight and (2) | ||||||
| /// local/remote memory indicator, and node weights (number of owned | ||||||
| /// indices). | ||||||
| graph::AdjacencyList<std::tuple<int, std::size_t, std::int8_t>, std::int32_t> | ||||||
| comm_graph(int root = 0) const; | ||||||
|
|
||||||
| /// @brief Build communication graph data as JSON string. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| /// | ||||||
| /// The data string can be decoded (loaded) to create a Python object | ||||||
| /// from which a [NetworkX](https://networkx.org/) graph can be | ||||||
| /// constructed. | ||||||
| /// | ||||||
| /// See ::comm_graph for a description of the data. | ||||||
| /// | ||||||
| /// @param[in] g Communication graph. | ||||||
| /// @return JSON string representing the communication graph. | ||||||
| static std::string comm_to_json( | ||||||
| const graph::AdjacencyList<std::tuple<int, std::size_t, std::int8_t>, | ||||||
| std::int32_t>& g); | ||||||
|
|
||||||
| private: | ||||||
| // Range of indices (global) owned by this process | ||||||
|
|
@@ -294,4 +376,5 @@ class IndexMap | |||||
| // Set of ranks ghost owned indices | ||||||
| std::vector<int> _dest; | ||||||
| }; | ||||||
|
|
||||||
| } // namespace dolfinx::common | ||||||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.