-
Notifications
You must be signed in to change notification settings - Fork 1
Overview
All chares in CharmLite are members of collections, where collections are specializations of the collection<T, Mapper>
class. Here, T
is a user-defined chare-type, and a Mapper
maps chare-indices to PEs. All chares must be descendants of the chare<T, Index>
class where Index
defines their index-type (e.g., std::tuple<int, int>
for 2D chares). Chare indices may use up to 128-bits of storage (on most machines), and must have equality and additive operators and an index_view
specialization.
In CharmLite, there are two types of collection proxies:
-
collection_proxy<T>
-- A generic collection ofT
-type chares with no inherent size restrictions. -
group_proxy<T, bool Node>
-- A collection ofT
-type chares with, either, one member per worker or per process.
Collections can be constructed with the static-method collection<T>::construct<(Message|void), Mapper?>((Message|void), collection_options?)
. A default mapper is used when one is not specified. Options may be used to indicate an initial set of elements; when they are provided, each element is constructed with a copy of the message indicated by Message
(if void
is provided, the default constructor is assumed).
Important: A collection without any initial elements is assumed as in an "inserting" state, see below.
Node/group collections may be constructed via: group_proxy<T, Node?>::construct<(Message|void)>(Message|void)
. Note, groups are not user-configurable since they imply a default set of elements to construct.
The members of collections are accessible via the []
operator, which returns a corresponding element_proxy<T>
.
Outside of phases of "static" insertion, only chares within a collective can insert new elements. Within "static" insertion phases, however, any entity can call insert
on an element-proxy to insert an element. To start a phase of static insertion, call begin_inserting
on one PE. Then, when it is complete, call done_inserting
(likewise on one PE). Collective operations (i.e., broadcasts and reductions) are buffered during static insertion phases, and will not complete until they conclude. An example flow may resemble:
auto col = collective_proxy<T>::construct();
for (auto i = 0; i < n; i++) {
col[i].insert<(Message|void)>(Message|void);
}
col.done_inserting();
One may call an entry method on all members of a collection using the broadcast<Message|void, Entry>(Message|void)
routine. The Entry
parameter is a member-function of the class that accepts (Message|void)
as its parameter.
One may construct a callback that corresponds to a broadcast over all members using the: callback<Message|void, Entry>(Message|void)
.
As with the collection_proxy<...>::broadcast
method, one can send a message to a single chare element using their send
method.
Element proxies also implement the callback
method, which functions identically to its collection-counterpart, albeit constructing a callback that sends a message to a single element.
Chares can contribute to reductions over a collection through their element proxy.