Intel® oneAPI DPC++/C++ Compiler Developer Guide and Reference

ID 767253
Date 9/08/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Shape

Variadic template class n_extent_t describes the shape of the n_dimensional container. Specifically, the number of dimensions the size of each.

Syntax
template<typename... TypeListT>
class n_extent_t
Description

n_extent_t represents the shape of a container as a sequence of sizes for each dimension. The size of each dimension can be represented by different types. This flexibility allows the same interface to be used to declare n_extents_t whose dimensions are fully known at compile time with fixed<int NumberT>, or to be only known at runtime with int, or only known at runtime but with a guarantee will be a multiple of an alignment with aligned<int Alignment>. For details, see the Number representation section.

The following table provides information on the template arguments for n_extent_t.

Template Argument

Description

typename... TypeListT

Comma separated list of types, where the number of types provided controls how many dimensions there are. Each type in the list identifies how the size of the corresponding dimension is to be represented. The order of the dimensions is the same order as C++ subscripts declaring a multi-dimensional array, from leftmost to rightmost.

Type must be int, fixed<NumberT>, or aligned<AlignmentT> for each value describing corresponding dimensions size (extent) in regular order of C++ subscripts - from outer to inner.

The following table provides information on the members of n_extent_t

Member

Description

static constexpr int rank;

Number of dimensions.

static constexpr int row_dimension = rank-1;
Index of last dimension, row.
n_extent_t()

Requirements: Every type in TypeListT is default constructible.

Effects: Construct n_extent_t, uses default values of each type in TypeListT for the dimesnion sizes. In general, only correctly initialized when every type is a fixed<NumberT>

n_extent_t(const n_extent_t &a_other)

Effects: Construct n_exent_t, copying size of each dimension from a_other.

explicit n_extent_t(const TypeListT & … a_values)

Effects: Construct n_exent_t, initializing each dimension with the corresponding value from the list of a_values passed as an argument. In use, a_values is a comma separate list of values whose length and types are defined by TypeListT.

template<int DimensionT> auto get() const

Requirements: DimenstionT >=0 and DimensiontT < rank.

Effects: Determine the exent of DimensionT.

Returns: In the type declared by the DimensionT position of 0-based TypeListT, the extent of the specified DimensionT

template<int DimensionT> 
auto rightmost_dimensions() const

Requirements: DimenstionT >=0 and DimensiontT <= rank.

Effects: Construct a n_extent_t with a lower rank by copying the righmost DimensionT values from this instance.

Returns: n_exent[get<rank - DimensionT>()]

[get<rank + 1 - DimensionT>()]

[get<…>()]

[get<row_dimension>()]

template<class... OtherTypeListT>
bool operator == (const n_extent_t<OtherTypeListT...> a_other) const

Requirements: rank of a_other is the same as this instance's.

Effects: Compare size of each dimension for equality. Only compares numeric values, not the types of each dimension.

Returns:true if all dimensions are numerically equal, false otherwise.

template<class... OtherTypeListT>
bool operator != (const n_extent_t<OtherTypeListT...> a_other) const

Requirements: rank of a_other is the same as this instance's.

Effects: Compare size of each dimension for inequality. Only compares numeric values, not the types of each dimension.

Returns:true if any dimensions are numerically different, false otherwise.

size_t size() const

Returns: Number of elements specified by extent

Effects: Calculates the number of cells represented by the current extent values of each dimension by multiplying them all together.

Returns: get<0>()*get<1>()*get<…>()*get<rank-1>()

The following table provides information on the friend functions of n_extent_t.

Friend function

Description

std::ostream& operator << (std::ostream& output_stream, const n_extent_t & a_extents)

Effects: Append string representation of a_extents' values to a_output_stream

Returns: Reference to a_output_stream for chained calls.