1 #ifndef DASH__COARRAY_UTILS_H__ 2 #define DASH__COARRAY_UTILS_H__ 4 #include <dash/Types.h> 6 #define DART_TAG_SYNC_IMAGES 10016; 74 template<
typename Container>
76 using element =
typename Container::value_type;
82 static_cast<element
>(
myid)) == image_ids.end())
89 *(std::min(image_ids.begin(), image_ids.end()))};
90 auto tag = DART_TAG_SYNC_IMAGES;
96 std::for_each(image_ids.begin(), image_ids.end(), [&](
const element & el){
112 DASH_LOG_DEBUG(
"Begin second phase of sync_images");
114 std::for_each(image_ids.begin(), image_ids.end(), [&](
const element & el)
143 using value_type =
typename Coarray<T>::value_type;
150 coarr.team().dart_id()),
162 template<
typename T,
typename BinaryOp>
167 using value_type =
typename Coarray<T>::value_type;
168 using index_type =
typename Coarray<T>::index_type;
171 "Cannot reduce unknown type!");
174 const auto team_dart_id = coarr.team().dart_id();
175 bool broadcast_result = (master < 0);
179 const auto & global_coords = coarr.pattern().global(master,
180 std::array<index_type,ndim> {});
181 const auto & global_idx = coarr.pattern().at(global_coords);
183 const auto dart_gptr = (coarr.begin() + global_idx).dart_gptr();
188 if(coarr.team().myid() != master){
199 if(broadcast_result){
dart_ret_t dart_send(const void *sendbuf, size_t nelem, dart_datatype_t dtype, int tag, dart_global_unit_t unit)
DART Equivalent to MPI send.
void sync_images(const Container &image_ids)
Blocks until all selected units reach this statement.
global_unit_t myid()
Shortcut to query the global unit ID of the calling unit.
ssize_t num_images()
Return the number of units in the global team.
size_t size()
Return the number of units in the global team.
This class is a simple memory pool which holds allocates elements of size ValueType.
void sync_all()
blocks until all units reach this statement.
struct dash::unit_id< dash::global_unit, dart_global_unit_t > global_unit_t
Unit ID to use for global IDs.
dart_ret_t dart_bcast(void *buf, size_t nelem, dart_datatype_t dtype, dart_team_unit_t root, dart_team_t team)
DART Equivalent to MPI broadcast.
dash::global_unit_t this_image()
Shortcut to query the global unit ID of the calling unit.
dart_ret_t dart_accumulate(dart_gptr_t gptr, const void *values, size_t nelem, dart_datatype_t dtype, dart_operation_t op)
Perform an element-wise atomic update on the values pointed to by gptr by applying the operation op w...
#define DART_TYPE_BYTE
integral data types
constexpr dim_t ndim(const DimensionalType &d)
void cobroadcast(Coarray< T > &coarr, const team_unit_t &master)
Broadcasts the value on master to all other members of this co_array.
dart_ret_t dart_barrier(dart_team_t team)
DART Equivalent to MPI_Barrier.
Type trait for mapping to DART data types.
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
dart_ret_t dart_recv(void *recvbuf, size_t nelem, dart_datatype_t dtype, int tag, dart_global_unit_t unit)
DART Equivalent to MPI recv.
GlobIter find(GlobIter first, GlobIter last, const ElementType &value)
Returns an iterator to the first element in the range [first,last) that compares equal to val...
void barrier()
A global barrier involving all units.
Convencience wrapper to determine the DART type and number of elements required for the given templat...
void for_each(const GlobInputIt &first, const GlobInputIt &last, UnaryFunction func)
Invoke a function on every element in a range distributed by a pattern.
void coreduce(Coarray< T > &coarr, const BinaryOp &op, team_unit_t master=team_unit_t{-1})
Performes a broadside reduction of the Coarray images.
dart_ret_t dart_flush(dart_gptr_t gptr)
Guarantee completion of all outstanding operations involving a segment on a certain unit...