Poplar and PopLibs
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Collectives.hpp File Reference
#include <poplar/DebugContext.hpp>
#include <poplar/Graph.hpp>
#include <poplar/OptionFlags.hpp>
#include <poplar/Program.hpp>
#include <poplar/Tensor.hpp>
#include <iosfwd>
#include <vector>

Go to the source code of this file.

Classes

struct  gcl::CommGroup
 Struct to specify sub-groups of replicas. More...
 
struct  gcl::Chunk
 Represents a section of a tensor mapped to an IPU. More...
 
struct  gcl::Chunks
 A vector of Chunk data. More...
 

Namespaces

namespace  gcl
 Graphcore Communications Library.
 

Macros

#define GCL_NO_DISCARD
 Produce compile time warning for unused return values.
 

Enumerations

enum class  gcl::CommGroupType { gcl::ALL , gcl::CONSECUTIVE , gcl::ORTHOGONAL }
 Enum to define communication group specification type. More...
 
enum class  gcl::CollectiveOperator { }
 Supported collective operators. More...
 

Functions

std::istream & gcl::operator>> (std::istream &is, CollectiveOperator &op)
 Parse token from input stream is to op. More...
 
std::ostream & gcl::operator<< (std::ostream &os, const CollectiveOperator &op)
 Write op to output stream os. More...
 
CrossReplica functions

Collective operations working across replicas.

poplar::Tensor gcl::allReduceCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, CollectiveOperator op, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Perform an all-reduce operation. More...
 
std::vector< poplar::Tensorgcl::allReduceCrossReplica (poplar::Graph &graph, const std::vector< poplar::Tensor > &datas, CollectiveOperator op, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Perform an all-reduce operation on multiple tensors. More...
 
poplar::Tensor gcl::allReduceCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, CollectiveOperator op, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allReduceCrossReplica() without the group arg (for all replicas). More...
 
std::vector< poplar::Tensorgcl::allReduceCrossReplica (poplar::Graph &graph, const std::vector< poplar::Tensor > &datas, CollectiveOperator op, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allReduceCrossReplica() with multiple input tensors and without the group arg. More...
 
void gcl::allReduceToDestinationCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, poplar::Tensor &destination, CollectiveOperator op, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allReduceCrossReplica() but writes the result to the destination tensor. More...
 
void gcl::allReduceToDestinationCrossReplica (poplar::Graph &graph, const std::vector< poplar::Tensor > &datas, const std::vector< poplar::Tensor > &destinations, CollectiveOperator op, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allReduceToDestinationCrossReplica() with multiple input and output tensors. More...
 
void gcl::allReduceToDestinationCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, poplar::Tensor &destination, CollectiveOperator op, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allReduceToDestinationCrossReplica() without group arg. More...
 
void gcl::allReduceInPlaceCrossReplica (poplar::Graph &graph, poplar::Tensor &data, CollectiveOperator op, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allReduceCrossReplica() but writes result back to the input data tensor. More...
 
void gcl::allReduceInPlaceCrossReplica (poplar::Graph &graph, std::vector< poplar::Tensor > &datas, CollectiveOperator op, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Perform an all-reduce operation on multiple tensors writing the results back to the input datas tensors. More...
 
void gcl::allReduceInPlaceCrossReplica (poplar::Graph &graph, poplar::Tensor &data, CollectiveOperator op, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allReduceInPlaceCrossReplica() without group arg. More...
 
void gcl::allReduceInPlaceCrossReplica (poplar::Graph &graph, std::vector< poplar::Tensor > &datas, CollectiveOperator op, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allReduceInPlaceCrossReplica() with multiple input tensors and without group arg. More...
 
poplar::Tensor gcl::reduceScatterCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, CollectiveOperator op, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Reduce the replicated rank-1 tensor data with the result scattered across the replicas. More...
 
std::vector< poplar::Tensorgcl::reduceScatterCrossReplica (poplar::Graph &graph, const std::vector< poplar::Tensor > &datas, CollectiveOperator op, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As reduceScatterCrossReplica() but with vector input argument and vector output as return value. More...
 
void gcl::reduceScatterToDestinationCrossReplica (poplar::Graph &graph, const std::vector< poplar::Tensor > &datas, const std::vector< poplar::Tensor > &destinations, CollectiveOperator op, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As reduceScatterCrossReplica() but with vector input/output arguments. More...
 
poplar::Tensor gcl::reduceScatterCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, CollectiveOperator op, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As reduceScatterCrossReplica() without group arg. More...
 
poplar::Tensor gcl::allGatherCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Gather the replicated tensor data. More...
 
std::vector< poplar::Tensorgcl::allGatherCrossReplica (poplar::Graph &graph, const std::vector< poplar::Tensor > &datas, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allGatherCrossReplica() but with vector input argument and vector output as return value. More...
 
void gcl::allGatherToDestinationCrossReplica (poplar::Graph &graph, const std::vector< poplar::Tensor > &datas, const std::vector< poplar::Tensor > &destinations, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allGatherCrossReplica() but with vector input/output arguments. More...
 
poplar::Tensor gcl::allGatherCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allGatherCrossReplica() without group arg. More...
 
poplar::Tensor gcl::allToAllCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, poplar::program::Sequence &prog, const CommGroup &group, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Perform an all-to-all exchange of the elements of the input tensor based on replica ID. More...
 
poplar::Tensor gcl::allToAllCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 As allToAllCrossReplica() without group arg. More...
 
poplar::Tensor gcl::broadcastCrossReplica (poplar::Graph &graph, const poplar::Tensor &data, poplar::program::Sequence &prog, const CommGroup &group={}, unsigned rootReplica=0, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Perform a broadcast from one replica to all other replicas. More...
 
WithinReplica functions

Collective operations working within replicas.

poplar::Tensor gcl::concatChunks (const Chunks &chunks)
 Concatenates chunks. More...
 
Chunks gcl::reduceScatterWithinReplica (poplar::Graph &graph, const poplar::Tensor &toReduce, CollectiveOperator op, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Reduce a rank 2 tensor. More...
 
poplar::Tensor gcl::allGatherWithinReplica (poplar::Graph &graph, const Chunks &toGather, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Broadcast data distributed over all IPUs. More...
 
poplar::Tensor gcl::allReduceWithinReplica (poplar::Graph &graph, const poplar::Tensor &toReduce, CollectiveOperator op, poplar::program::Sequence &prog, const poplar::DebugContext &debugContext={}, const poplar::OptionFlags &options={})
 Perform an all-reduce operation on the specified tensor. More...