Reduce#

event CCL_API reduce (const void *send_buf, void *recv_buf, size_t count, datatype dtype, reduction rtype, int root, const communicator &comm, const stream &stream, const reduce_attr &attr=default_reduce_attr, const vector_class< event > &deps={})

Reduce is a collective communication operation that performs the global reduction operation on values from all ranks of the communicator and returns the result to the root rank.

Parameters
  • send_buf – the buffer with count elements of dtype that stores local data to be reduced

  • recv_buf – [out] the buffer to store reduced result, must have the same dimension as send_buf. Used by the root rank only, ignored by other ranks.

  • count – the number of elements of type dtype in send_buf and recv_buf

  • dtype – the datatype of elements in send_buf and recv_buf

  • rtype – the type of the reduction operation to be applied

  • root – the rank that gets the result of reduction

  • comm – the communicator for which the operation will be performed

  • stream – abstraction over a device queue constructed via ccl::create_stream

  • attr – optional attributes to customize operation

  • deps – an optional vector of the events that the operation should depend on

Returns

ccl::event an object to track the progress of the operation

event CCL_API reduce (const void *send_buf, void *recv_buf, size_t count, datatype dtype, reduction rtype, int root, const communicator &comm, const reduce_attr &attr=default_reduce_attr, const vector_class< event > &deps={})

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

template<class BufferType, class = typename std::enable_if<is_native_type_supported<BufferType>(), event>::type> event CCL_API reduce (const BufferType *send_buf, BufferType *recv_buf, size_t count, reduction rtype, int root, const communicator &comm, const stream &stream, const reduce_attr &attr=default_reduce_attr, const vector_class< event > &deps={})

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Type-safe version.

template<class BufferType, class = typename std::enable_if<is_native_type_supported<BufferType>(), event>::type> event CCL_API reduce (const BufferType *send_buf, BufferType *recv_buf, size_t count, reduction rtype, int root, const communicator &comm, const reduce_attr &attr=default_reduce_attr, const vector_class< event > &deps={})

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Type-safe version.

template<class BufferObjectType, class = typename std::enable_if<is_class_supported<BufferObjectType>(), event>::type> event CCL_API reduce (const BufferObjectType &send_buf, BufferObjectType &recv_buf, size_t count, reduction rtype, int root, const communicator &comm, const stream &stream, const reduce_attr &attr=default_reduce_attr, const vector_class< event > &deps={})

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Type-safe version.

template<class BufferObjectType, class = typename std::enable_if<is_class_supported<BufferObjectType>(), event>::type> event CCL_API reduce (const BufferObjectType &send_buf, BufferObjectType &recv_buf, size_t count, reduction rtype, int root, const communicator &comm, const reduce_attr &attr=default_reduce_attr, const vector_class< event > &deps={})

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Type-safe version.