![]() |
Shamrock 2025.10.0
Astrophysical Code
|
Handle the patch list of the mpi scheduler. More...
#include <shamrock/include/shamrock/scheduler/scheduler_patch_list.hpp>
Collaboration diagram for SchedulerPatchList:Public Member Functions | |
| void | invalidate_load_values () |
| Invalidate current load values (To use after a change the patches is made) | |
| void | check_load_values_valid (SourceLocation loc=SourceLocation{}) |
| Check if the load values are valid, throw otherwise. | |
| void | build_global () |
| rebuild global from the local list of each tables | |
| std::unordered_set< u64 > | build_local () |
| select owned patches owned by the node to rebuild local | |
| void | build_local_differantial (std::unordered_set< u64 > &patch_id_lst, std::vector< u64 > &to_send_idx, std::vector< u64 > &to_recv_idx) |
| Build the local patch list and create a differential of patches to send / recv since last time. | |
| void | build_global_idx_map () |
| recompute id_patch_to_global_idx | |
| void | build_local_idx_map () |
| recompute id_patch_to_local_idx | |
| void | reset_local_pack_index () |
| reset Patch's pack index value | |
| std::tuple< u64, u64, u64, u64, u64, u64, u64, u64 > | split_patch (u64 id_patch) |
| split the Patch having id_patch as id and return the index of the 8 subpatches in the global vector | |
| void | merge_patch (u64 idx0, u64 idx1, u64 idx2, u64 idx3, u64 idx4, u64 idx5, u64 idx6, u64 idx7) |
| merge the 8 given patches index in the global vector | |
Public Attributes | |
| u64 | _next_patch_id = 0 |
| The next available patch id. | |
| std::vector< shamrock::patch::Patch > | global |
| contain the list of all patches in the simulation | |
| std::vector< shamrock::patch::Patch > | local |
| contain the list of patch owned by the current node | |
| bool | is_load_values_up_to_date = false |
| Are patch load values up to date. | |
| std::unordered_map< u64, u64 > | id_patch_to_global_idx |
| id_patch_to_global_idx[patch_id] = index in global patch list | |
| std::unordered_map< u64, u64 > | id_patch_to_local_idx |
| id_patch_to_local_idx[patch_id] = index in local patch list | |
Handle the patch list of the mpi scheduler.
Definition at line 34 of file scheduler_patch_list.hpp.
| void SchedulerPatchList::build_global | ( | ) |
rebuild global from the local list of each tables
similar to global = allgather(local)
Definition at line 25 of file scheduler_patch_list.cpp.
| void SchedulerPatchList::build_global_idx_map | ( | ) |
recompute id_patch_to_global_idx
Definition at line 80 of file scheduler_patch_list.cpp.
| std::unordered_set< u64 > SchedulerPatchList::build_local | ( | ) |
select owned patches owned by the node to rebuild local
Definition at line 34 of file scheduler_patch_list.cpp.
Here is the call graph for this function:| void SchedulerPatchList::build_local_differantial | ( | std::unordered_set< u64 > & | patch_id_lst, |
| std::vector< u64 > & | to_send_idx, | ||
| std::vector< u64 > & | to_recv_idx | ||
| ) |
Build the local patch list and create a differential of patches to send / recv since last time.
The method clears the local vector. It then iterates over the global vector of shamrock::patch::Patch objects. For each Patch object, it checks if the id_patch is in the patch_id_lst set. If it is, it means the patch was previously owned by the current node, so it does nothing. If it was not previously owned, it adds the id_patch to the patch_id_lst set and adds the index i to the to_recv_idx vector.
If the node_owner_id of the Patch object is not the same as the current node's rank (as determined by shamcomm::world_rank()), it checks if the id_patch was previously owned by the current node. If it was, it adds the index i to the to_send_idx vector and removes the id_patch from the patch_id_lst set.
In summary, this method builds the local patch list by comparing the global patch list with the current node's previously owned patches. It also identifies patches that need to be sent to or received from other nodes.
| patch_id_lst | The set of patch ids previously owned by the current node |
| to_send_idx | The vector of indices of patches that need to be sent to other nodes |
| to_recv_idx | The vector of indices of patches that need to be received from other nodes |
Definition at line 51 of file scheduler_patch_list.cpp.
Here is the call graph for this function:| void SchedulerPatchList::build_local_idx_map | ( | ) |
recompute id_patch_to_local_idx
Definition at line 91 of file scheduler_patch_list.cpp.
|
inline |
Check if the load values are valid, throw otherwise.
Definition at line 62 of file scheduler_patch_list.hpp.
|
inline |
Invalidate current load values (To use after a change the patches is made)
Definition at line 59 of file scheduler_patch_list.hpp.
| void SchedulerPatchList::merge_patch | ( | u64 | idx0, |
| u64 | idx1, | ||
| u64 | idx2, | ||
| u64 | idx3, | ||
| u64 | idx4, | ||
| u64 | idx5, | ||
| u64 | idx6, | ||
| u64 | idx7 | ||
| ) |
merge the 8 given patches index in the global vector
Note : the first one will contain the merge patch the 7 others will be set with node_owner_id = u32_max, and then be flushed out when doing build local / sync global
parameters idx... are the 8 patches index in the global patch metadata vector.
Definition at line 160 of file scheduler_patch_list.cpp.
| void SchedulerPatchList::reset_local_pack_index | ( | ) |
reset Patch's pack index value
Definition at line 102 of file scheduler_patch_list.cpp.
| std::tuple< u64, u64, u64, u64, u64, u64, u64, u64 > SchedulerPatchList::split_patch | ( | u64 | id_patch | ) |
split the Patch having id_patch as id and return the index of the 8 subpatches in the global vector
| id_patch | the id of the patch to split |
Definition at line 109 of file scheduler_patch_list.cpp.
| u64 SchedulerPatchList::_next_patch_id = 0 |
The next available patch id.
This variable is used to assign a unique id to each patch when adding, splitting or merging patches.
Definition at line 44 of file scheduler_patch_list.hpp.
| std::vector<shamrock::patch::Patch> SchedulerPatchList::global |
contain the list of all patches in the simulation
Definition at line 49 of file scheduler_patch_list.hpp.
id_patch_to_global_idx[patch_id] = index in global patch list
Definition at line 115 of file scheduler_patch_list.hpp.
id_patch_to_local_idx[patch_id] = index in local patch list
Definition at line 120 of file scheduler_patch_list.hpp.
| bool SchedulerPatchList::is_load_values_up_to_date = false |
Are patch load values up to date.
Definition at line 56 of file scheduler_patch_list.hpp.
| std::vector<shamrock::patch::Patch> SchedulerPatchList::local |
contain the list of patch owned by the current node
Definition at line 54 of file scheduler_patch_list.hpp.