28 return std::make_unique<T>(*to_copy);
50 const std::unique_ptr<View>& prev_view,
View& curr_view);
58 const std::unique_ptr<View>& prev_view,
View& curr_view);
150 const std::string& profile =
"default");
175 const std::string& profile =
"default");
188 const std::string& profile =
"default");
204 const std::vector<int>& max_nodes_by_shard,
205 const std::vector<Mode>& delivery_modes_by_shard,
258 const std::map<std::type_index, std::variant<SubgroupAllocationPolicy, CrossProductPolicy>>
policies;
279 std::map<std::type_index, std::vector<std::vector<uint32_t>>> compute_standard_shard_sizes(
280 const std::vector<std::type_index>& subgroup_type_order,
281 const std::unique_ptr<View>& prev_view,
282 const View& curr_view)
const;
293 const std::type_index subgroup_type,
295 const std::map<std::type_index, std::vector<std::vector<uint32_t>>>& shard_sizes)
const;
309 const std::type_index subgroup_type,
311 const std::unique_ptr<View>& prev_view,
313 const std::map<std::type_index, std::vector<std::vector<uint32_t>>>& shard_sizes)
const;
325 void compute_standard_memberships(
const std::vector<std::type_index>& subgroup_type_order,
326 const std::unique_ptr<View>& prev_view,
341 void compute_cross_product_memberships(
const std::vector<std::type_index>& subgroup_type_order,
342 const std::unique_ptr<View>& prev_view,
348 std::variant<SubgroupAllocationPolicy, CrossProductPolicy>>&
349 policies_by_subgroup_type)
350 : policies(policies_by_subgroup_type) {}
352 : policies(to_copy.policies) {}
356 const std::unique_ptr<View>& prev_view,
357 View& curr_view)
const;
const std::map< std::type_index, std::variant< SubgroupAllocationPolicy, CrossProductPolicy > > policies
The entry for each type of subgroup is either a SubgroupAllocationPolicy if that type should use the ...
A data structure defining the parameters of the default subgroup allocation function for a single sub...
ShardAllocationPolicy fixed_even_shards(int num_shards, int nodes_per_shard, const std::string &profile="default")
Returns a ShardAllocationPolicy that specifies num_shards shards with the same fixed number of nodes ...
uint32_t subgroup_type_id_t
Type of the numeric ID used to refer to subgroup types within a Group; this is currently computed as ...
ShardAllocationPolicy raw_fixed_even_shards(int num_shards, int nodes_per_shard, const std::string &profile="default")
Returns a ShardAllocationPolicy that specifies num_shards shards with the same fixed number of nodes ...
constexpr char max_nodes_profile_field[]
DefaultSubgroupAllocator(const std::map< std::type_index, std::variant< SubgroupAllocationPolicy, CrossProductPolicy >> &policies_by_subgroup_type)
ShardAllocationPolicy custom_shards_policy(const std::vector< int > &min_nodes_by_shard, const std::vector< int > &max_nodes_by_shard, const std::vector< Mode > &delivery_modes_by_shard, const std::vector< std::string > &profiles_by_shard)
Returns a ShardAllocationPolicy for a subgroup that has a different number of members in each shard...
std::vector< std::vector< SubView > > subgroup_shard_layout_t
The data structure used to store a subgroups-and-shards layout for a single subgroup type (i...
std::vector< Mode > modes_by_shard
If even_shards is false, this will contain an entry for each shard indicating which delivery mode it ...
std::pair< std::type_index, uint32_t > source_subgroup
The (type, index) pair identifying the "source" subgroup of the cross-product.
subgroup_allocation_map_t one_subgroup_entire_view(const std::vector< std::type_index > &subgroup_type_order, const std::unique_ptr< View > &prev_view, View &curr_view)
A simple implementation of shard_view_generator_t that creates a single, un-sharded subgroup containi...
std::vector< int > min_num_nodes_by_shard
If even_shards is false, this will contain an entry for each shard indicating the minimum number of m...
int num_subgroups
The number of subgroups of the same Replicated type to create.
std::pair< std::type_index, uint32_t > target_subgroup
The (type, index) pair identifying the "target" subgroup of the cross-product.
SubgroupAllocationPolicy one_subgroup_policy(const ShardAllocationPolicy &policy)
Returns a SubgroupAllocationPolicy for a replicated type that only has a single subgroup.
std::unique_ptr< T > deep_pointer_copy(const std::unique_ptr< T > &to_copy)
A copy constructor for objects owned by unique_ptr.
int num_shards
The number of shards; set to 1 for a non-sharded subgroup.
constexpr char num_shards_profile_field[]
std::map< std::type_index, subgroup_shard_layout_t > subgroup_allocation_map_t
The data structure used to store the subgroups-and-shards layouts for all subgroup types in a Group (...
Functor of type shard_view_generator_t that implements the default subgroup allocation algorithm...
subgroup_allocation_map_t one_subgroup_entire_view_raw(const std::vector< std::type_index > &subgroup_type_order, const std::unique_ptr< View > &prev_view, View &curr_view)
A simple implementation of shard_view_generator_t that returns a single, un-sharded subgroup in Unord...
std::vector< std::string > profiles_by_shard
If even_shards is false, this will contain an entry for each shard indicating which profile it should...
bool even_shards
Whether all shards should contain the same number of members.
std::string shards_profile
If even_shards is true, this is the profile that will be used for every shard.
DefaultSubgroupAllocator(const DefaultSubgroupAllocator &to_copy)
An alternate type of subgroup allocation policy for subgroup types whose membership will be defined a...
ShardAllocationPolicy flexible_even_shards(int num_shards, int min_nodes_per_shard, int max_nodes_per_shard, const std::string &profile="default")
Returns a ShardAllocationPolicy that specifies num_shards "flexible" or fault-tolerant shards...
std::vector< ShardAllocationPolicy > shard_policy_by_subgroup
If identical_subgroups is true, contains a single entry with the allocation policy for all subgroups ...
A data structure defining the parameters of the default subgroup allocation function for a single sub...
SubgroupAllocationPolicy identical_subgroups_policy(int num_subgroups, const ShardAllocationPolicy &subgroup_policy)
Returns a SubgroupAllocationPolicy for a replicated type that needs n subgroups with identical shardi...
std::vector< int > max_num_nodes_by_shard
If even_shards is false, this will contain an entry for each shard indicating the maximum number of m...
int max_nodes_per_shard
If even_shards is true, this is the maximum number of nodes per shard.
ShardAllocationPolicy custom_shard_policy(const std::vector< Mode > &delivery_modes_by_shard, const std::vector< std::string > &profiles_by_shard)
Returns a ShardAllocationPolicy for a subgroup that has a different number of members in each shard...
constexpr char min_nodes_profile_field[]
bool identical_subgroups
Whether all subgroups of this type will have an identical shard layout.
int min_nodes_per_shard
If even_shards is true, this is the minimum number of nodes per shard.
Mode shards_mode
If even_shards is true, this is the delivery mode that will be used for every shard.