Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
SchedulerPatchList Class Reference

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< u64build_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, u64split_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::Patchglobal
 contain the list of all patches in the simulation
 
std::vector< shamrock::patch::Patchlocal
 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, u64id_patch_to_global_idx
 id_patch_to_global_idx[patch_id] = index in global patch list
 
std::unordered_map< u64, u64id_patch_to_local_idx
 id_patch_to_local_idx[patch_id] = index in local patch list
 

Detailed Description

Handle the patch list of the mpi scheduler.

Definition at line 34 of file scheduler_patch_list.hpp.

Member Function Documentation

◆ build_global()

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.

◆ build_global_idx_map()

void SchedulerPatchList::build_global_idx_map ( )

recompute id_patch_to_global_idx

Definition at line 80 of file scheduler_patch_list.cpp.

◆ build_local()

std::unordered_set< u64 > SchedulerPatchList::build_local ( )

select owned patches owned by the node to rebuild local

Returns
std::unordered_set<u64>

Definition at line 34 of file scheduler_patch_list.cpp.

+ Here is the call graph for this function:

◆ build_local_differantial()

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.

Parameters
patch_id_lstThe set of patch ids previously owned by the current node
to_send_idxThe vector of indices of patches that need to be sent to other nodes
to_recv_idxThe 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:

◆ build_local_idx_map()

void SchedulerPatchList::build_local_idx_map ( )

recompute id_patch_to_local_idx

Definition at line 91 of file scheduler_patch_list.cpp.

◆ check_load_values_valid()

void SchedulerPatchList::check_load_values_valid ( SourceLocation  loc = SourceLocation{})
inline

Check if the load values are valid, throw otherwise.

Definition at line 62 of file scheduler_patch_list.hpp.

◆ invalidate_load_values()

void SchedulerPatchList::invalidate_load_values ( )
inline

Invalidate current load values (To use after a change the patches is made)

Definition at line 59 of file scheduler_patch_list.hpp.

◆ merge_patch()

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.

◆ reset_local_pack_index()

void SchedulerPatchList::reset_local_pack_index ( )

reset Patch's pack index value

Definition at line 102 of file scheduler_patch_list.cpp.

◆ split_patch()

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

Parameters
id_patchthe id of the patch to split
Returns
std::tuple<u64,u64,u64,u64,u64,u64,u64,u64> the index of the 8 splitted in the global vector

Definition at line 109 of file scheduler_patch_list.cpp.

Member Data Documentation

◆ _next_patch_id

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.

Todo:
make this variable to private

Definition at line 44 of file scheduler_patch_list.hpp.

◆ global

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

std::unordered_map<u64, u64> SchedulerPatchList::id_patch_to_global_idx

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

std::unordered_map<u64, u64> SchedulerPatchList::id_patch_to_local_idx

id_patch_to_local_idx[patch_id] = index in local patch list

Definition at line 120 of file scheduler_patch_list.hpp.

◆ is_load_values_up_to_date

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.

◆ local

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.


The documentation for this class was generated from the following files: