Public Types | Public Member Functions | List of all members
Parallel::Section< ParallelComponent, SectionIdTag > Struct Template Reference

A subset of chares in a parallel component. More...

#include <Section.hpp>

Public Types

using parallel_component = ParallelComponent
 
using cproxy_section = typename charm_type::cproxy_section
 
using section_id_tag = SectionIdTag
 

Public Member Functions

 Section (IdType id, cproxy_section proxy) noexcept
 
 Section (Section &&rhs)=default
 
Sectionoperator= (Section &&rhs)=default
 
 Section (const Section &)=default
 
Sectionoperator= (const Section &)=default
 
const IdType & id () const noexcept
 The section ID corresponding to the SectionIdTag
 
void pup (PUP::er &p) noexcept
 
const cproxy_section & proxy () const noexcept
 The Charm++ section proxy.
 
cproxy_section & proxy () noexcept
 The Charm++ section proxy.
 
const CkSectionInfo & cookie () const noexcept
 The Charm++ section cookie that keeps track of reductions. More...
 
CkSectionInfo & cookie () noexcept
 The Charm++ section cookie that keeps track of reductions. More...
 

Detailed Description

template<typename ParallelComponent, typename SectionIdTag>
struct Parallel::Section< ParallelComponent, SectionIdTag >

A subset of chares in a parallel component.

The section is identified at compile time by the parallel component and a SectionIdTag. The SectionIdTag describes the quantity that partitions the chares into one or more sections. For example, the SectionIdTag could be the block ID in the computational domain, so elements are partitioned per block. Chares can be a member of multiple sections.

Here's an example how to work with sections in an array parallel component:

using array_allocation_tags = tmpl::list<
// The section proxy will be stored in each element's DataBox in this tag
// for convenient access
using initialization_tags = Parallel::get_initialization_tags<
array_allocation_tags>;
static void allocate_array(
Parallel::CProxy_GlobalCache<Metavariables>& global_cache,
tuples::tagged_tuple_from_typelist<initialization_tags>
initialization_items) noexcept {
auto& local_cache = *(global_cache.ckLocalBranch());
auto& array_proxy =
Parallel::get_parallel_component<ArrayComponent>(local_cache);
// Create sections from element IDs (the corresponding elements will be
// created below)
const size_t num_elements = 5;
std::vector<CkArrayIndex> even_elements{};
std::vector<CkArrayIndex> odd_elements{};
for (size_t i = 0; i < num_elements; ++i) {
(i % 2 == 0 ? even_elements : odd_elements)
.push_back(Parallel::ArrayIndex<int>(static_cast<int>(i)));
}
std::vector<CkArrayIndex> first_element{};
first_element.push_back(Parallel::ArrayIndex<int>(0));
const EvenOrOddSection even_section{
EvenOrOdd::Even, EvenOrOddSection::cproxy_section::ckNew(
array_proxy.ckGetArrayID(), even_elements.data(),
even_elements.size())};
const EvenOrOddSection odd_section{
EvenOrOdd::Odd, EvenOrOddSection::cproxy_section::ckNew(
array_proxy.ckGetArrayID(), odd_elements.data(),
odd_elements.size())};
using IsFirstElementSection =
const IsFirstElementSection is_first_element_section{
true, IsFirstElementSection::cproxy_section::ckNew(
array_proxy.ckGetArrayID(), first_element.data(),
first_element.size())};
// Create array elements, copying the appropriate section proxy into their
// DataBox
for (size_t i = 0; i < 5; ++i) {
tuples::get<Parallel::Tags::Section<ArrayComponent, EvenOrOddTag>>(
initialization_items) = i % 2 == 0 ? even_section : odd_section;
tuples::get<Parallel::Tags::Section<ArrayComponent, IsFirstElementTag>>(
initialization_items) =
i == 0 ? std::make_optional(is_first_element_section) : std::nullopt;
array_proxy[static_cast<int>(i)].insert(
global_cache, initialization_items,
static_cast<int>(i) % number_of_procs);
}
array_proxy.doneInserting();
}
Warning
The Charm++ documentation indicates some creation order restrictions for sections that may become relevant if we encounter issues with race conditions in the future.

Member Function Documentation

◆ cookie() [1/2]

template<typename ParallelComponent , typename SectionIdTag >
const CkSectionInfo& Parallel::Section< ParallelComponent, SectionIdTag >::cookie ( ) const
inlinenoexcept

The Charm++ section cookie that keeps track of reductions.

The section cookie must be stored on each element and updated when performing reductions. For details on Charm++ sections and section reductions see: https://charm.readthedocs.io/en/latest/charm++/manual.html?#sections-subsets-of-a-chare-array-group

◆ cookie() [2/2]

template<typename ParallelComponent , typename SectionIdTag >
CkSectionInfo& Parallel::Section< ParallelComponent, SectionIdTag >::cookie ( )
inlinenoexcept

The Charm++ section cookie that keeps track of reductions.

The section cookie must be stored on each element and updated when performing reductions. For details on Charm++ sections and section reductions see: https://charm.readthedocs.io/en/latest/charm++/manual.html?#sections-subsets-of-a-chare-array-group


The documentation for this struct was generated from the following file:
std::vector
Parallel::number_of_procs
int number_of_procs(const DistribObject &distributed_object) noexcept
Number of processing elements.
Definition: Info.hpp:24
Parallel::get_initialization_tags
tmpl::remove_duplicates< tmpl::flatten< tmpl::list< AllocationTagsList, tmpl::transform< InitializationActionsList, detail::get_initialization_tags_from_action< tmpl::_1 > >> >> get_initialization_tags
Given a list of initialization actions, and possibly a list of tags needed for allocation of an array...
Definition: ParallelComponentHelpers.hpp:254
Parallel::get_initialization_actions_list
tmpl::flatten< tmpl::transform< PhaseDepActionList, detail::get_initialization_actions_list< tmpl::_1 > >> get_initialization_actions_list
Given the phase dependent action list, return the list of actions in the Initialization phase (or an ...
Definition: ParallelComponentHelpers.hpp:218
domain::push_back
CoordinateMap< SourceFrame, TargetFrame, Maps..., NewMap > push_back(CoordinateMap< SourceFrame, TargetFrame, Maps... > old_map, NewMap new_map) noexcept
Creates a CoordinateMap by appending the new map to the end of the old maps.
Parallel::Section
A subset of chares in a parallel component.
Definition: Section.hpp:36
Parallel::ArrayIndex
The array index used for indexing Chare Arrays, mostly an implementation detail.
Definition: ArrayIndex.hpp:28
Parallel::Tags::Section
The Parallel::Section<ParallelComponent, SectionIdTag> that this element belongs to.
Definition: Section.hpp:29