共用方式為


array Class

Represents a data container used to move data to an accelerator.

template <
   typename _Value_type,
   int _Rank
>
friend class array;

Parameters

  • _Value_type
    The element type of the data.

  • _Rank
    The rank of the array.

Members

Public Constructors

Name

Description

array::array Constructor

Initializes a new instance of the array class.

array::~array Destructor

Destroys the array object.

Public Methods

Name

Description

array::copy_to Method

Copies the contents of the array to another array.

array::data Method

Returns a pointer to the raw data of the array.

array::get_accelerator_view Method

Returns the accelerator_view object that represents the location where the array is allocated. This property can be accessed only on the CPU.

array::get_associated_accelerator_view Method

Gets the second accelerator_view object that is passed as a parameter when a staging constructor is called to instantiate the array object.

array::get_cpu_access_type Method

Returns the access_type of the array. This method can be accessed only on the CPU.

array::get_extent Method

Returns the extent object of the array.

array::reinterpret_as Method

Returns a one-dimensional array that contains all the elements in the array object.

array::section Method

Returns a subsection of the array object that is at the specified origin and, optionally, that has the specified extent.

array::view_as Method

Returns an array_view object that is constructed from the array object.

Public Operators

Name

Description

array::operator std::vector<_Value_type> Operator

Uses copy(*this, vector) to implicitly convert the array to a std::vector object.

array::operator() Operator

Returns the element value that is specified by the parameters.

array::operator[] Operator

Returns the element that is at the specified index.

array::operator= Operator

Copies the contents of the specified array object into this one.

Public Constants

Name

Description

array::rank Constant

Stores the rank of the array.

Public Data Members

Name

Description

array::accelerator_view Data Member

Gets the accelerator_view object that represents the location where the array is allocated. This property can be accessed only on the CPU.

array::associated_accelerator_view Data Member

Gets the second accelerator_view object that is passed as a parameter when a staging constructor is called to instantiate the array object.

array::cpu_access_type Data Member

Gets the access_type that represents how the CPU can access the storage of the array.

array::extent Data Member

Gets the extent that defines the shape of the array.

Remarks

The type array<T,N> represents a dense and regular (not jagged) N-dimensional array that is located in a specific location, such as an accelerator or the CPU. The data type of the elements in the array is T, which must be of a type that is compatible with the target accelerator. Although the rank, N, (of the array is determined statically and is part of the type, the extent of the array is determined by the runtime and is expressed by using class extent<N>.

An array can have any number of dimensions, although some functionality is specialized for array objects with rank one, two, and three. If you omit the dimension argument, the default is 1.

Array data is laid out contiguously in memory. Elements that differ by one in the least significant dimension are adjacent in memory.

Arrays are logically considered to be value types, because when an array is copied to another array, a deep copy is performed. Two arrays never point to the same data.

The array<T,N> type is used in several scenarios:

  • As a data container that can be used in computations on an accelerator.

  • As a data container to hold memory on the host CPU (that can be used to copy to and from other arrays).

  • As a staging object to act as a fast intermediary in host-to-device copies.

Inheritance Hierarchy

array

Requirements

Header: amp.h

Namespace: Concurrency

See Also

Reference

Concurrency Namespace (C++ AMP)