1 #ifndef DASH__COEVENT_H__INCLUDED 2 #define DASH__COEVENT_H__INCLUDED 6 #include <dash/Array.h> 7 #include <dash/Atomic.h> 8 #include <dash/GlobPtr.h> 9 #include <dash/Exception.h> 10 #include <dash/Team.h> 11 #include <dash/Types.h> 13 #include <dash/algorithm/Fill.h> 15 #include <dash/coarray/CoEventIter.h> 16 #include <dash/coarray/CoEventRef.h> 18 #include <dash/memory/MemorySpace.h> 49 using pointer =
typename array::pointer;
50 using const_pointer =
typename pointer::const_type;
57 using size_type = int;
82 auto dart_ptr = _event_counts.
begin().dart_gptr();
83 pointer nonconst_ptr{dart_ptr};
89 return iterator(static_cast<pointer>(_event_counts.
end()));
98 auto dart_ptr = _event_counts.
end().dart_gptr();
99 pointer nonconst_ptr{dart_ptr};
103 size_type size()
const {
105 return _team->
size();
112 inline void wait(
int count = 1) {
113 auto gref = _event_counts.
at(_team->myid().id);
118 DASH_LOG_DEBUG(
"waiting for event at gptr",
119 static_cast<pointer>(_event_counts.
begin()
121 std::this_thread::sleep_for(std::chrono::milliseconds(100));
123 current = gref.get();
124 }
while (current < count);
130 DASH_LOG_DEBUG(
"test for events on this unit");
131 return _event_counts.
at(static_cast<int>(_team->myid())).load();
139 if(!_is_initialized){
144 _is_initialized =
true;
148 inline Team & team() {
157 auto ptr =
static_cast<pointer
>(_event_counts.
begin() + unit);
165 return this->
operator()(static_cast<int>(unit));
170 bool _is_initialized =
false;
This class is a simple memory pool which holds allocates elements of size ValueType.
void wait(int count=1)
wait for a given number of incoming events.
iterator end() noexcept
Global pointer to the end of the array.
Type wrapper to mark any trivial type atomic.
bool is_initialized()
Check whether DASH has been initialized already.
void fill(GlobIterType first, GlobIterType last, const typename GlobIterType::value_type &value)
Assigns the given value to the elements in the range [first, last)
size_t size() const
The number of units in this team.
Coevent(Team &team=dash::Team::All())
Constructor to setup and initialize an Coevent.
A Team instance specifies a subset of all available units.
reference at(size_type global_pos)
Random access assignment operator, range-checked.
reference operator()(const int &unit)
Operator to select event at given unit.
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
void barrier() const
Establish a barrier for all units operating on the array, publishing all changes to all units...
reference operator()(const team_unit_t &unit)
Operator to select event at given unit.
static Team & All()
The invariant Team instance containing all available units.
void initialize(Team &team=dash::Team::All())
initializes the Coevent.
iterator begin() noexcept
Global pointer to the beginning of the array.
bool allocate(size_type nelem, dash::DistributionSpec< 1 > distribution, dash::Team &team=dash::Team::All())
Delayed allocation of global memory using a one-dimensional distribution spec.