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<
static void allocate_array(
Parallel::CProxy_GlobalCache<Metavariables>& global_cache,
initialization_items) noexcept {
auto& local_cache = *(global_cache.ckLocalBranch());
auto& array_proxy =
// 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)
std::vector<CkArrayIndex> first_element{};
const EvenOrOddSection even_section{
EvenOrOdd::Even, EvenOrOddSection::cproxy_section::ckNew(
const EvenOrOddSection odd_section{
EvenOrOdd::Odd, EvenOrOddSection::cproxy_section::ckNew(
using IsFirstElementSection =
const IsFirstElementSection is_first_element_section{
true, IsFirstElementSection::cproxy_section::ckNew(
// 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;
global_cache, initialization_items,
static_cast<int>(i) % number_of_procs);
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

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:

◆ cookie() [2/2]

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

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:

The documentation for this struct was generated from the following file:
int number_of_procs(const DistribObject &distributed_object) noexcept
Number of processing elements.
Definition: Info.hpp:24
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
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
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.
A subset of chares in a parallel component.
Definition: Section.hpp:36
The array index used for indexing Chare Arrays, mostly an implementation detail.
Definition: ArrayIndex.hpp:28
The Parallel::Section<ParallelComponent, SectionIdTag> that this element belongs to.
Definition: Section.hpp:29