Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
PatchScheduler Class Reference

The MPI scheduler. More...

#include <shamrock/include/shamrock/scheduler/PatchScheduler.hpp>

Collaboration diagram for PatchScheduler:

Public Types

using PatchTree = shamrock::scheduler::PatchTree
using SchedulerPatchData = shamrock::scheduler::SchedulerPatchData
using SynchronizedData = shamrock::solvergraph::SolverGraphSerializable

Public Member Functions

shamrock::patch::PatchDataLayerLayoutpdl_old ()
std::shared_ptr< shamrock::patch::PatchDataLayerLayoutget_layout_ptr_old () const
void scheduler_step (bool do_split_merge, bool do_load_balancing)
 scheduler step
void init_mpi_required_types ()
void free_mpi_required_types ()
 PatchScheduler (const std::shared_ptr< shamrock::patch::PatchDataLayerLayout > &pdl_ptr, u64 crit_split, u64 crit_merge)
std::string dump_status ()
void update_local_load_value (std::function< u64(shamrock::patch::Patch)> load_function)
template<class vectype>
std::tuple< vectype, vectype > get_box_tranform ()
template<class vectype>
std::tuple< vectype, vectype > get_box_volume ()
bool should_resize_box (bool node_in)
template<class vectype>
void set_coord_domain_bound (vectype bmin, vectype bmax)
 modify the bounding box of the patch domain
void allpush_data (shamrock::patch::PatchDataLayer &pdat)
 push data in the scheduler The content of pdat as to be the same for each node
template<u32 dim>
void make_patch_base_grid (std::array< u32, dim > patch_count)
template<class vectype>
void set_coord_domain_bound (std::tuple< vectype, vectype > box)
 modify the bounding box of the patch domain
std::string format_patch_coord (shamrock::patch::Patch p)
void check_patchdata_locality_correctness ()
void dump_local_patches (std::string filename)
std::vector< std::unique_ptr< shamrock::patch::PatchDataLayer > > gather_data (u32 rank)
void add_root_patch ()
 add patch to the scheduler
void sync_build_LB (bool global_patch_sync, bool balance_load)
template<class vec>
shamrock::patch::PatchCoordTransform< vec > get_patch_transform ()
template<class Function>
void for_each_patch_data (Function &&fct)
 for each macro for patchadata example usage
template<class Function>
void for_each_patch (Function &&fct)
void for_each_global_patch (const std::function< void(const shamrock::patch::Patch &)> &fct)
void for_each_local_patch (const std::function< void(const shamrock::patch::Patch &)> &fct)
void for_each_local_patchdata (const std::function< void(const shamrock::patch::Patch &, shamrock::patch::PatchDataLayer &)> &fct)
void for_each_local_patch_nonempty (std::function< void(const shamrock::patch::Patch &)> fct)
u32 get_patch_rank_owner (u64 patch_id)
void for_each_patchdata_nonempty (std::function< void(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &)> fct)
template<class T>
shambase::DistributedData< T > map_owned_patchdata (std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct)
template<class T>
shambase::DistributedData< T > distrib_data_local_to_all_simple (shambase::DistributedData< T > &src)
template<class T>
shambase::DistributedData< T > distrib_data_local_to_all_load_store (shambase::DistributedData< T > &src)
template<class T>
shambase::DistributedData< T > map_owned_patchdata_fetch_simple (std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct)
template<class T>
shambase::DistributedData< T > map_owned_patchdata_fetch_load_store (std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct)
template<class T>
shamrock::patch::PatchField< T > map_owned_to_patch_field_simple (std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct)
template<class T>
shamrock::patch::PatchField< T > map_owned_to_patch_field_load_store (std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct)
u64 get_rank_count ()
u64 get_total_obj_count ()
template<class T>
std::unique_ptr< sycl::buffer< T > > rankgather_field (u32 field_idx)
template<class Function, class Pfield>
void compute_patch_field (Pfield &field, MPI_Datatype &dtype, Function &&lambda)
auto get_node_set_edge_patchdata_layer_refs ()
std::vector< u64add_root_patches (std::vector< shamrock::patch::PatchCoord< 3 > > coords)
 add a root patch to the scheduler
shamrock::patch::SimulationBoxInfoget_sim_box ()
nlohmann::json serialize_patch_metadata ()
template<>
std::tuple< f32_3, f32_3 > get_box_tranform ()
template<>
std::tuple< f64_3, f64_3 > get_box_tranform ()
template<>
std::tuple< f32_3, f32_3 > get_box_volume ()
template<>
std::tuple< f64_3, f64_3 > get_box_volume ()
template<>
std::tuple< i64_3, i64_3 > get_box_volume ()

Public Attributes

std::shared_ptr< shamrock::patch::PatchDataLayerLayoutpdl_ptr
u64 crit_patch_split
 splitting limit (if load value > crit_patch_split => patch split)
u64 crit_patch_merge
 merging limit (if load value < crit_patch_merge => patch merge)
SchedulerPatchList patch_list
 handle the list of the patches of the scheduler
SchedulerPatchData patch_data
 handle the data of the patches of the scheduler
PatchTree patch_tree
 handle the tree structure of the patches
SynchronizedData synchronized_data
 data that is synchroneous across all ranks
std::unordered_set< u64owned_patch_id
 (owned_patch_id = patch_list.build_local())

Static Public Attributes

static constexpr u64 max_axis_patch_coord = LoadBalancer::max_box_sz
static constexpr u64 max_axis_patch_coord_length = LoadBalancer::max_box_sz + 1

Detailed Description

The MPI scheduler.

Definition at line 86 of file PatchScheduler.hpp.

Member Typedef Documentation

◆ PatchTree

using PatchScheduler::PatchTree = shamrock::scheduler::PatchTree

Definition at line 94 of file PatchScheduler.hpp.

◆ SchedulerPatchData

using PatchScheduler::SchedulerPatchData = shamrock::scheduler::SchedulerPatchData

Definition at line 95 of file PatchScheduler.hpp.

◆ SynchronizedData

using PatchScheduler::SynchronizedData = shamrock::solvergraph::SolverGraphSerializable

Definition at line 96 of file PatchScheduler.hpp.

Constructor & Destructor Documentation

◆ PatchScheduler()

PatchScheduler::PatchScheduler ( const std::shared_ptr< shamrock::patch::PatchDataLayerLayout > & pdl_ptr,
u64 crit_split,
u64 crit_merge )

Definition at line 209 of file PatchScheduler.cpp.

◆ ~PatchScheduler()

PatchScheduler::~PatchScheduler ( )

Definition at line 222 of file PatchScheduler.cpp.

Member Function Documentation

◆ add_root_patch()

void PatchScheduler::add_root_patch ( )

add patch to the scheduler

//TODO find a better way to do this it is too error prone

Parameters
p
pdat

Definition at line 193 of file PatchScheduler.cpp.

Here is the call graph for this function:

◆ add_root_patches()

std::vector< u64 > PatchScheduler::add_root_patches ( std::vector< shamrock::patch::PatchCoord< 3 > > coords)

add a root patch to the scheduler

Parameters
coordscoordinates of the patch
Returns
u64 the id of the made patch

Definition at line 101 of file PatchScheduler.cpp.

Here is the call graph for this function:

◆ allpush_data()

void PatchScheduler::allpush_data ( shamrock::patch::PatchDataLayer & pdat)

push data in the scheduler The content of pdat as to be the same for each node

Parameters
pdatthe data to push

Definition at line 167 of file PatchScheduler.cpp.

Here is the call graph for this function:

◆ check_patchdata_locality_correctness()

void PatchScheduler::check_patchdata_locality_correctness ( )

Definition at line 682 of file PatchScheduler.cpp.

◆ compute_patch_field()

template<class Function, class Pfield>
void PatchScheduler::compute_patch_field ( Pfield & field,
MPI_Datatype & dtype,
Function && lambda )
inline

Definition at line 496 of file PatchScheduler.hpp.

◆ distrib_data_local_to_all_load_store()

template<class T>
shambase::DistributedData< T > PatchScheduler::distrib_data_local_to_all_load_store ( shambase::DistributedData< T > & src)
inline

Definition at line 372 of file PatchScheduler.hpp.

◆ distrib_data_local_to_all_simple()

template<class T>
shambase::DistributedData< T > PatchScheduler::distrib_data_local_to_all_simple ( shambase::DistributedData< T > & src)
inline

Definition at line 359 of file PatchScheduler.hpp.

◆ dump_local_patches()

void PatchScheduler::dump_local_patches ( std::string filename)

Definition at line 837 of file PatchScheduler.cpp.

◆ dump_status()

std::string PatchScheduler::dump_status ( )

Definition at line 569 of file PatchScheduler.cpp.

◆ for_each_global_patch()

void PatchScheduler::for_each_global_patch ( const std::function< void(const shamrock::patch::Patch &)> & fct)
inline

Definition at line 287 of file PatchScheduler.hpp.

◆ for_each_local_patch()

void PatchScheduler::for_each_local_patch ( const std::function< void(const shamrock::patch::Patch &)> & fct)
inline

Definition at line 296 of file PatchScheduler.hpp.

◆ for_each_local_patch_nonempty()

void PatchScheduler::for_each_local_patch_nonempty ( std::function< void(const shamrock::patch::Patch &)> fct)
inline

Definition at line 315 of file PatchScheduler.hpp.

◆ for_each_local_patchdata()

void PatchScheduler::for_each_local_patchdata ( const std::function< void(const shamrock::patch::Patch &, shamrock::patch::PatchDataLayer &)> & fct)
inline

Definition at line 305 of file PatchScheduler.hpp.

◆ for_each_patch()

template<class Function>
void PatchScheduler::for_each_patch ( Function && fct)
inline

Definition at line 274 of file PatchScheduler.hpp.

◆ for_each_patch_data()

template<class Function>
void PatchScheduler::for_each_patch_data ( Function && fct)
inline

for each macro for patchadata example usage

sched.for_each_patch_data(
[&](u64 id_patch, Patch cur_p, PatchData &pdat) {
....
}
);
std::uint64_t u64
64 bit unsigned integer
Template Parameters
FunctionThe functor that will be used
Parameters
fct

Definition at line 261 of file PatchScheduler.hpp.

Here is the call graph for this function:

◆ for_each_patchdata_nonempty()

void PatchScheduler::for_each_patchdata_nonempty ( std::function< void(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &)> fct)
inline

Definition at line 333 of file PatchScheduler.hpp.

◆ format_patch_coord()

std::string PatchScheduler::format_patch_coord ( shamrock::patch::Patch p)

Definition at line 641 of file PatchScheduler.cpp.

◆ free_mpi_required_types()

void PatchScheduler::free_mpi_required_types ( )

Definition at line 47 of file PatchScheduler.cpp.

◆ gather_data()

std::vector< std::unique_ptr< shamrock::patch::PatchDataLayer > > PatchScheduler::gather_data ( u32 rank)

Definition at line 944 of file PatchScheduler.cpp.

◆ get_box_tranform() [1/2]

template<>
std::tuple< f64_3, f64_3 > PatchScheduler::get_box_tranform ( )

Definition at line 267 of file PatchScheduler.cpp.

◆ get_box_tranform() [2/2]

template<>
std::tuple< f32_3, f32_3 > PatchScheduler::get_box_tranform ( )

Definition at line 253 of file PatchScheduler.cpp.

◆ get_box_volume() [1/3]

template<>
std::tuple< i64_3, i64_3 > PatchScheduler::get_box_volume ( )

Definition at line 299 of file PatchScheduler.cpp.

◆ get_box_volume() [2/3]

template<>
std::tuple< f64_3, f64_3 > PatchScheduler::get_box_volume ( )

Definition at line 290 of file PatchScheduler.cpp.

◆ get_box_volume() [3/3]

template<>
std::tuple< f32_3, f32_3 > PatchScheduler::get_box_volume ( )

Definition at line 281 of file PatchScheduler.cpp.

◆ get_layout_ptr_old()

std::shared_ptr< shamrock::patch::PatchDataLayerLayout > PatchScheduler::get_layout_ptr_old ( ) const
inline

Definition at line 116 of file PatchScheduler.hpp.

◆ get_node_set_edge_patchdata_layer_refs()

auto PatchScheduler::get_node_set_edge_patchdata_layer_refs ( )
inline

Definition at line 514 of file PatchScheduler.hpp.

◆ get_patch_rank_owner()

u32 PatchScheduler::get_patch_rank_owner ( u64 patch_id)
inline

Definition at line 327 of file PatchScheduler.hpp.

◆ get_patch_transform()

template<class vec>
shamrock::patch::PatchCoordTransform< vec > PatchScheduler::get_patch_transform ( )
inline

Definition at line 237 of file PatchScheduler.hpp.

◆ get_rank_count()

u64 PatchScheduler::get_rank_count ( )
inline

Definition at line 420 of file PatchScheduler.hpp.

◆ get_sim_box()

shamrock::patch::SimulationBoxInfo & PatchScheduler::get_sim_box ( )
inline

Definition at line 535 of file PatchScheduler.hpp.

◆ get_total_obj_count()

u64 PatchScheduler::get_total_obj_count ( )
inline

Definition at line 431 of file PatchScheduler.hpp.

◆ init_mpi_required_types()

void PatchScheduler::init_mpi_required_types ( )

Definition at line 40 of file PatchScheduler.cpp.

◆ make_patch_base_grid()

template<u32 dim>
template void PatchScheduler::make_patch_base_grid< 3 > ( std::array< u32, dim > patch_count)

Definition at line 55 of file PatchScheduler.cpp.

◆ map_owned_patchdata()

template<class T>
shambase::DistributedData< T > PatchScheduler::map_owned_patchdata ( std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct)
inline

Definition at line 346 of file PatchScheduler.hpp.

◆ map_owned_patchdata_fetch_load_store()

template<class T>
shambase::DistributedData< T > PatchScheduler::map_owned_patchdata_fetch_load_store ( std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct)
inline

Definition at line 396 of file PatchScheduler.hpp.

◆ map_owned_patchdata_fetch_simple()

template<class T>
shambase::DistributedData< T > PatchScheduler::map_owned_patchdata_fetch_simple ( std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct)
inline

Definition at line 383 of file PatchScheduler.hpp.

◆ map_owned_to_patch_field_load_store()

template<class T>
shamrock::patch::PatchField< T > PatchScheduler::map_owned_to_patch_field_load_store ( std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct)
inline

Definition at line 415 of file PatchScheduler.hpp.

◆ map_owned_to_patch_field_simple()

template<class T>
shamrock::patch::PatchField< T > PatchScheduler::map_owned_to_patch_field_simple ( std::function< T(const shamrock::patch::Patch, shamrock::patch::PatchDataLayer &pdat)> fct)
inline

Definition at line 409 of file PatchScheduler.hpp.

◆ pdl_old()

shamrock::patch::PatchDataLayerLayout & PatchScheduler::pdl_old ( )
inline

Definition at line 112 of file PatchScheduler.hpp.

◆ rankgather_field()

template<class T>
std::unique_ptr< sycl::buffer< T > > PatchScheduler::rankgather_field ( u32 field_idx)
inline

Definition at line 438 of file PatchScheduler.hpp.

◆ scheduler_step()

void PatchScheduler::scheduler_step ( bool do_split_merge,
bool do_load_balancing )

scheduler step

Parameters
do_split_merge
do_load_balancing

Definition at line 308 of file PatchScheduler.cpp.

Here is the call graph for this function:

◆ serialize_patch_metadata()

nlohmann::json PatchScheduler::serialize_patch_metadata ( )

Definition at line 1019 of file PatchScheduler.cpp.

◆ set_coord_domain_bound() [1/2]

template<class vectype>
void PatchScheduler::set_coord_domain_bound ( std::tuple< vectype, vectype > box)
inline

modify the bounding box of the patch domain

Template Parameters
vectype
Parameters
box

Definition at line 197 of file PatchScheduler.hpp.

Here is the call graph for this function:

◆ set_coord_domain_bound() [2/2]

template<class vectype>
void PatchScheduler::set_coord_domain_bound ( vectype bmin,
vectype bmax )
inline

modify the bounding box of the patch domain

Template Parameters
vectype
Parameters
bmin
bmax

Definition at line 165 of file PatchScheduler.hpp.

◆ should_resize_box()

bool PatchScheduler::should_resize_box ( bool node_in)

Definition at line 224 of file PatchScheduler.cpp.

◆ sync_build_LB()

void PatchScheduler::sync_build_LB ( bool global_patch_sync,
bool balance_load )

Definition at line 232 of file PatchScheduler.cpp.

◆ update_local_load_value()

void PatchScheduler::update_local_load_value ( std::function< u64(shamrock::patch::Patch)> load_function)
inline

Definition at line 141 of file PatchScheduler.hpp.

Member Data Documentation

◆ crit_patch_merge

u64 PatchScheduler::crit_patch_merge

merging limit (if load value < crit_patch_merge => patch merge)

Definition at line 101 of file PatchScheduler.hpp.

◆ crit_patch_split

u64 PatchScheduler::crit_patch_split

splitting limit (if load value > crit_patch_split => patch split)

Definition at line 100 of file PatchScheduler.hpp.

◆ max_axis_patch_coord

u64 PatchScheduler::max_axis_patch_coord = LoadBalancer::max_box_sz
staticconstexpr

Definition at line 91 of file PatchScheduler.hpp.

◆ max_axis_patch_coord_length

u64 PatchScheduler::max_axis_patch_coord_length = LoadBalancer::max_box_sz + 1
staticconstexpr

Definition at line 92 of file PatchScheduler.hpp.

◆ owned_patch_id

std::unordered_set<u64> PatchScheduler::owned_patch_id

(owned_patch_id = patch_list.build_local())

list of owned patch ids updated with

Definition at line 109 of file PatchScheduler.hpp.

◆ patch_data

SchedulerPatchData PatchScheduler::patch_data

handle the data of the patches of the scheduler

Definition at line 104 of file PatchScheduler.hpp.

◆ patch_list

SchedulerPatchList PatchScheduler::patch_list

handle the list of the patches of the scheduler

Definition at line 103 of file PatchScheduler.hpp.

◆ patch_tree

PatchTree PatchScheduler::patch_tree

handle the tree structure of the patches

Definition at line 105 of file PatchScheduler.hpp.

◆ pdl_ptr

std::shared_ptr<shamrock::patch::PatchDataLayerLayout> PatchScheduler::pdl_ptr

Definition at line 98 of file PatchScheduler.hpp.

◆ synchronized_data

SynchronizedData PatchScheduler::synchronized_data

data that is synchroneous across all ranks

Definition at line 106 of file PatchScheduler.hpp.


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