Poplar and PopLibs
poputil::TensorUseTracker Class Reference

Class that tracks the usage of data on different tiles. More...

#include <TileMapping.hpp>

Public Types

enum class  MappingMethod { OptimizeHaloRegions , ConstrainMappingToUsedTiles , None }
 

Public Member Functions

 TensorUseTracker (unsigned numTiles, unsigned startTile=0, bool ascendingMappingOrder=true)
 Constructor for the TensorUseTracker class. More...
 
 TensorUseTracker (const TensorUseTracker &other)
 Constructor for the TensorUseTracker class.
 
 TensorUseTracker (TensorUseTracker &&other)
 Default constructor for the TensorUseTracker class.
 
TensorUseTrackeroperator= (const TensorUseTracker &other)
 Assignment operator for the TensorUseTracker class.
 
TensorUseTrackeroperator= (TensorUseTracker &&other)
 Default assignment operator for the TensorUseTracker class.
 
 ~TensorUseTracker ()
 Destructor for the TensorUserTracker class.
 
void add (const poplar::Graph &graph, unsigned tile, const poplar::Tensor &t)
 Add a case of data usage. More...
 
void add (TensorUseTracker other)
 Add cases of data usage from another tracker. More...
 
void resolve (const poplar::Graph &graph, unsigned grainSize, unsigned minElementsPerTile, bool extendPartialUsage=false, TensorUseTracker::MappingMethod mappingMethod=TensorUseTracker::MappingMethod::None)
 Resolve data usage for mapping. More...
 
void mapTensorsByUse (poplar::Graph &graph, unsigned grainSize, unsigned minElementsPerTile, bool extendPartialUsage=false, TensorUseTracker::MappingMethod mappingMethod=TensorUseTracker::MappingMethod::None)
 Map data according to use. More...
 
bool empty () const
 Check if any cases of data usage have been registered. More...
 

Detailed Description

Class that tracks the usage of data on different tiles.

If data is broadcast to many tiles, it is sometimes efficient to map the data so that it is spread evenly amongst the tiles that use it.

This class can collect information about the use of data and then calculate a suitable tile mapping.

Member Enumeration Documentation

◆ MappingMethod

Enumerator
OptimizeHaloRegions 

Map "halo regions" to single tiles.

These are regions that are used by multiple tiles but have neighbouring regions used by subsets of those tiles.

ConstrainMappingToUsedTiles 

Mapping of elements is constrained to be only on tiles that use them.

Otherwise, to meet grain size constraints, elements may be mapped to tiles which do not use them.

None 

No mapping method used.

Constructor & Destructor Documentation

◆ TensorUseTracker()

poputil::TensorUseTracker::TensorUseTracker ( unsigned  numTiles,
unsigned  startTile = 0,
bool  ascendingMappingOrder = true 
)

Constructor for the TensorUseTracker class.

Parameters
numTilesThe number of tiles to track data use of.
startTileThe tile to start tracking data use on.
ascendingMappingOrderIf true, the first tile used = startTile and tiles are allocated in increasing order. If false, the first tile used = (number of device tiles -1
  • startTile) and tiles are allocated in decreasing order.

Member Function Documentation

◆ add() [1/2]

void poputil::TensorUseTracker::add ( const poplar::Graph graph,
unsigned  tile,
const poplar::Tensor t 
)

Add a case of data usage.

Parameters
graphThe Poplar graph being tracked.
tileThe tile that the use occurs on.
tThe tensor representing the data being used.

◆ add() [2/2]

void poputil::TensorUseTracker::add ( TensorUseTracker  other)

Add cases of data usage from another tracker.

Parameters
otherThe TensorUseTracker to merge data usage information from.

◆ empty()

bool poputil::TensorUseTracker::empty ( ) const

Check if any cases of data usage have been registered.

Returns
If true, no cases have been registered. If false, cases have been registered.

◆ mapTensorsByUse()

void poputil::TensorUseTracker::mapTensorsByUse ( poplar::Graph graph,
unsigned  grainSize,
unsigned  minElementsPerTile,
bool  extendPartialUsage = false,
TensorUseTracker::MappingMethod  mappingMethod = TensorUseTracker::MappingMethod::None 
)

Map data according to use.

This function will set the tile mapping of variable regions based on tracked data use. Variable regions with usage on multiple tiles will have their elements spread across those tiles.

Parameters
graphThe Poplar graph being tracked.
grainSizeThe number of elements mapped to each tile will be an integer multiple of the grain size.
minElementsPerTileThe minimum number of elements that must be mapped to a tile.
extendPartialUsageWhen set, partial use of tensors will be extended to cover the entire tensor, based on the usage of neighbouring regions before mapping.
mappingMethodMethod used for mapping elements.

◆ resolve()

void poputil::TensorUseTracker::resolve ( const poplar::Graph graph,
unsigned  grainSize,
unsigned  minElementsPerTile,
bool  extendPartialUsage = false,
TensorUseTracker::MappingMethod  mappingMethod = TensorUseTracker::MappingMethod::None 
)

Resolve data usage for mapping.

Data used on multiple tiles will have their usage spread across those tiles.

Parameters
graphThe Poplar graph being tracked.
grainSizeThe number of elements mapped to each tile will be an integer multiple of the grain size.
minElementsPerTileThe minimum number of elements that must be mapped to a tile.
extendPartialUsageWhen set, partial usage of tensors will be extended to cover the entire tensor, based on the usage of neighbouring regions.
mappingMethodMethod used for mapping elements.

The documentation for this class was generated from the following file: