1 #ifndef DASH__SHARED_COUNTER_H_ 2 #define DASH__SHARED_COUNTER_H_ 4 #include <dash/Array.h> 14 template<
typename ValueType =
int>
26 _local_counts(_num_units)
28 _local_counts.
local[0] = 0;
33 : _num_units(team.
size()),
35 _local_counts(_num_units, team)
37 _local_counts.
local[0] = 0;
48 _local_counts[_myid] += increment;
58 _local_counts[_myid] -= increment;
74 ? _local_counts.
local[0]
91 #endif // DASH__SHARED_COUNTER_H_ global_unit_t myid()
Shortcut to query the global unit ID of the calling unit.
size_t size()
Return the number of units in the global team.
A simple shared counter that allows atomic increment- and decrement operations.
This class is a simple memory pool which holds allocates elements of size ValueType.
SharedCounter()
Constructor.
size_t size() const
The number of units in this team.
A Team instance specifies a subset of all available units.
void inc(ValueType increment)
Increment the shared counter value, atomic operation.
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...
struct dash::dart_operation ValueType
Reduce operands to their minimum value.
void dec(ValueType increment)
Decrement the shared counter value, atomic operation.
local_type local
Local proxy object, allows use in range-based for loops.