AML Dense Layouts

group aml_layout_dense

Default aml layout.

Dense layouts describe how a multi-dimensional dense data structure is collapsed into a linear (and contiguous) virtual address range. Dimensions of a layout may contain a stride (space between elements) on the virtual address space, and a pitch (distance between contiguous elements of the same dimension).

#include <aml/layout/dense.h>

See also

aml_layout

Functions

int aml_layout_dense_create(struct aml_layout **layout, void *ptr, const int order, const size_t element_size, const size_t ndims, const size_t *dims, const size_t *stride, const size_t *pitch)

Dense layout constructor.

See also

aml_layout_dense

Parameters:
  • layout[out] A pointer where to store a newly allocated layout.

  • ptr[in] The pointer to the data structure described by this layout.

  • order[in] The order in which dimensions are organized. Can be AML_LAYOUT_ORDER_COLUMN_MAJOR or AML_LAYOUT_ORDER_ROW_MAJOR.

  • element_size[in] The size of each element in layout.

  • ndims[in] The number of dimensions of the layout.

  • dims[in] The number of elements along each dimension of the layout.

  • stride[in] The space between elements (in number of elements), along each dimension. If NULL then the stride is set to one for each dimension.

  • pitch[in] The space between consecutive elements of the same dimension. If NULL, pitch is set to the number of elements in each dimension.

Returns:

-AML_ENOMEM if layout allocation failed.

Returns:

-AML_EINVAL if layout is NULL.

Returns:

AML_SUCCESS if creation succeeded.

void *aml_layout_column_deref(const struct aml_layout_data *data, const size_t *coords)

Deref operator for dense layout in AML_ORDER_COLUMN_MAJOR. Also used as the deref operator for this type of layout. Does not check its argument. If data is NULL, or coords are out of bounds, the behaviour of aml_layout_column_deref() is undefined.

int aml_layout_column_order(const struct aml_layout_data *data)

Layout operator for retrieving order of dimension storage. This function shall not fail.

size_t aml_layout_dense_ndims(const struct aml_layout_data *data)

Operator for retrieving the number of dimensions in the layout. Does not check data is not NULL. If data is NULL or not the good pointer type, the behaviour is undefined.

size_t aml_layout_dense_element_size(const struct aml_layout_data *data)

Layout operator for retrieving layout elements size. Does not check data is not NULL. If data is NULL or not the good

int aml_layout_column_reshape(const struct aml_layout_data *data, struct aml_layout **output, size_t ndims, const size_t *dims)

Operator for reshaping dense layouts with column major order. Does not check if the number of elements match. This should be done in aml_layout_reshape().

Returns:

-AML_EINVAL if merge then split of dimensions cannot be done appropriatly.

Returns:

-AML_ENOMEM if the resulting layout cannot be allocated.

Returns:

AML_SUCCESS on successful reshape.

int aml_layout_column_slice(const struct aml_layout_data *data, struct aml_layout **output, const size_t *offsets, const size_t *dims, const size_t *strides)

Operator for slicing dense layouts with column major order. Does not check if slice elements are out of bound. This should be done in aml_layout_slice().

Returns:

-AML_ENOMEM if the resulting layout cannot be allocated.

Returns:

AML_SUCCESS on successful slicing.

void *aml_layout_row_deref(const struct aml_layout_data *data, const size_t *coords)

Operator for slicing dense layouts with column major order. Does not check if slice elements are out of bound. This should be done in aml_layout_slice().

Returns:

-AML_ENOMEM if the resulting layout cannot be allocated.

Returns:

AML_SUCCESS on successful slicing.

int aml_layout_row_order(const struct aml_layout_data *data)

Operator for retrieving layout order of a row major layout. This function shall not fail.

int aml_layout_row_dims(const struct aml_layout_data *data, size_t *dims)

Operator for retrieving dimensions size of a layout with row major order. Does not check data is not NULL. If data is NULL or not the good pointer type, the behaviour is undefined. Arguments are supposed to be checked in aml_layout_dims().

int aml_layout_row_reshape(const struct aml_layout_data *data, struct aml_layout **output, const size_t ndims, const size_t *dims)

Operator for reshaping dense layouts with row major order. Does not check if the number of elements match. This should be done in aml_layout_reshape().

Returns:

-AML_EINVAL if merge then split of dimensions cannot be done appropriatly.

Returns:

-AML_ENOMEM if the resulting layout cannot be allocated.

Returns:

AML_SUCCESS on successful reshape.

int aml_layout_row_slice(const struct aml_layout_data *data, struct aml_layout **output, const size_t *offsets, const size_t *dims, const size_t *strides)

Operator for slicing dense layouts with row major order. Does not check if slice elements are out of bound. This should be done in aml_layout_slice().

Returns:

-AML_ENOMEM if the resulting layout cannot be allocated.

Returns:

AML_SUCCESS on successful slicing.

int aml_layout_row_slice_native(const struct aml_layout_data *data, struct aml_layout **output, const size_t *offsets, const size_t *dims, const size_t *strides)

Operator for slicing dense layouts with row major order, without the overhead of user defined order, i.e using the internal library order. Does not check if slice elements are out of bound. This should be done in aml_layout_slice().

Returns:

-AML_ENOMEM if the resulting layout cannot be allocated.

Returns:

AML_SUCCESS on successful slicing.

Variables

struct aml_layout_ops aml_layout_column_ops

Pre-existing operators for dense layout with AML_LAYOUT_ORDER_COLUMN_MAJOR order.

struct aml_layout_ops aml_layout_row_ops

Pre-existing operators for dense layout with AML_LAYOUT_ORDER_ROW_MAJOR order.

struct aml_layout_dense
#include <dense.h>

Structure of a dense layout.