Tilings: Decomposing Data

group aml_tiling

Tiling Data Structure High-Level API.

Tiling is an array representation of data structures. AML tiling structure can be defined as 1D or 2D contiguous arrays. Tiles in tilings can be of custom size and AML provides iterators to easily access tiles element.

Defines

AML_TILING_TYPE_1D

Tiling types passed to some tiling routines. Regular, linear tiling with uniform tile sizes.

AML_TILING_TYPE_2D_ROWMAJOR

Tiling types passed to some tiling routines. 2-dimensional cartesian tiling with uniform tile sizes, stored in rowmajor order

AML_TILING_TYPE_2D_COLMAJOR

Tiling types passed to some tiling routines. 2-dimensional cartesian tiling with uniform tile sizes, stored in colmajor order

Functions

int aml_tiling_tileid(const struct aml_tiling *tiling, ...)

Provides the tile id of a tile.

Return

-1 in case of invalid coordinates, else the id of the tile (that is, its order in memory), to use with other functions.

Parameters
  • tiling: an initialized tiling structure.

  • coordinates: a list of size_t coordinates, one per dimension of the tiling.

size_t aml_tiling_tilesize(const struct aml_tiling *tiling, int tileid)

Provides the information on the size of a tile.

Return

the size of a tile.

Parameters
  • tiling: an initialized tiling structure.

  • tileid: an identifier of a tile (a value between 0 and the number of tiles minus 1).

void *aml_tiling_tilestart(const struct aml_tiling *tiling, const void *ptr, int tileid)

Provides the information on the location of a tile in memory.

Return

the address of the start of the tile identified by “tileid”, within the provided user data structure.

Parameters
  • tiling: an initialized tiling structure.

  • ptr: an address of the start of the complete user data structure that this tiling describes.

  • tileid: an identifier of a tile (a value between 0 and the number of tiles minus 1).

int aml_tiling_ndims(const struct aml_tiling *tiling, ...)

Provides the dimensions of the entire tiling in tiles.

Return

0 if successful, an error code otherwise.

Parameters
  • tiling: an initialized tiling structure.

  • sizes: a list of output (size_t *), one per dimension of the tiling. Will contain the size of each dimension in tiles upon return.

int aml_tiling_create_iterator(struct aml_tiling *tiling, struct aml_tiling_iterator **iterator, int flags)

Allocates and initializes a new tiling iterator.

Return

0 if successful; an error code otherwise.

Parameters
  • tiling: an initialized tiling structure.

  • iterator: an address where the pointer to the newly allocated iterator structure will be stored.

  • flags: reserved for future use; pass 0 for now.

int aml_tiling_init_iterator(struct aml_tiling *tiling, struct aml_tiling_iterator *iterator, int flags)

Initializes a tiling iterator.

Return

0 if successful; an error code otherwise.

Parameters
  • tiling: an initialized tiling structure.

  • iterator: an allocated tiling iterator structure.

  • flags: reserved for future use; pass 0 for now.

void aml_tiling_fini_iterator(struct aml_tiling *tiling, struct aml_tiling_iterator *iterator)

Finalize an initialized tiling iterator.

Parameters
  • tiling: an initialized tiling structure.

  • iterator: an initialized tiling iterator structure.

void aml_tiling_destroy_iterator(struct aml_tiling *tiling, struct aml_tiling_iterator **iterator)

Tears down an initialized tiling iterator.

Return

0 if successful; an error code otherwise.

Parameters
  • tiling: an initialized tiling structure.

  • iterator: an initialized tiling iterator structure.

int aml_tiling_iterator_reset(struct aml_tiling_iterator *iterator)

Resets a tiling iterator to the first tile.

Return

0 if successful; an error code otherwise.

Parameters
  • iterator: an initialized tiling iterator structure.

int aml_tiling_iterator_next(struct aml_tiling_iterator *iterator)

Advances a tiling iterator to the next tile.

Return

0 if successful; an error code otherwise.

Parameters
  • iterator: an initialized tiling iterator structure.

int aml_tiling_iterator_end(const struct aml_tiling_iterator *iterator)

Checks whether the iterator is past the last tile.

Return

0 if the iterator points at a valid tile; 1 if it’s past the last tile.

Parameters
  • iterator: an initialized tiling iterator structure.

int aml_tiling_iterator_get(const struct aml_tiling_iterator *iterator, ...)

Queries the iterator.

Return

0 if successful; an error code otherwise.

Parameters
  • iterator: an initialized tiling iterator structure.

  • x: an argument of type unsigned long*; on return gets filled with the identifier of the tile currently pointed to.

struct aml_tiling_ops
#include <aml.h>

aml_tiling_ops is a structure containing a set of operation over a tiling. These operation are the creation and destruction of iterators, access to tiles indexing, size and tiling dimension. Aware users may create or modify implementation by assembling appropriate operations in such a structure.

struct aml_tiling
#include <aml.h>

An aml_tiling is a multi-dimensional grid of data, e.g a matrix, a stencil etc… Tilings are used in AML as a description of a macro data structure that will be used by a library for doing its own work. This structure is exploitable by AML to perform optimized movement operations.

struct aml_tiling_iterator_ops
#include <aml.h>

struct aml_tiling_iterator
#include <aml.h>