This topic has not yet been rated - Rate this topic

array_view Class

Visual Studio 11

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Represents a view into the data in an array<T,N>.


          
template <
   typename _Value_type,
   int _Rank = 1
>
class array_view : public _Array_view_base<_Rank,sizeof(_Value_type)/sizeof(int)>;
template <
   typename _Value_type,
   int _Rank                     
>
class array_view<const _Value_type, _Rank> : public _Array_view_base<_Rank,sizeof(_Value_type)/sizeof(int)>;
        
_Value_type

The data type of the elements in the array_view object.

_Rank

The rank of the array_view object.

Public Constructors

Name

Description

array_view::array_view Constructor

Initializes a new instance of the array_view class. There is no default constructor for array<T,N>. All constructors are restricted to run on the CPU only and cannot be executed on a Direct3D target.

array_view::~array_view Destructor

Destroys the array_view object.

Public Methods

Name

Description

array_view::copy_to Method

Copies the contents of the array_view object to the specified destination by calling copy(*this, dest).

array_view::data Method

Returns a pointer to the raw data of the array_view.

array_view::discard_data Method

Discards the current data underlying this view.

array_view::get_extent Method

Returns the extent object of the array_view object.

array_view::project Method

Returns the grid that defines the shape of the array_view object.

array_view::refresh Method

Notifies the array_view object that its bound memory has been modified outside the array_view interface. A call to this method renders all cached information stale.

array_view::reinterpret_as Method

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

array_view::section Method

Returns a subsection of the array_view object that's at the specified origin and, optionally, that has the specified extent.

array_view::synchronize Method

Synchronizes any modifications made to the array_view object back to its source data.

array_view::view_as Method

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

Public Operators

Name

Description

array_view::operator() Operator

Returns the value of the element that is specified by the parameter or parameters.

array_view::operator[] Operator

Returns the element that is specified by the parameters.

array_view::operator= Operator

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

Public Constants

Name

Description

array_view::rank Constant

Stores the rank of the array_view object.

Data Members

Name

Description

array_view::extent Data Member

Gets the extent object that defines the shape of the array_view object.

The array_view class represents a possibly cached view into the data that is contained in an array object or a subsection of an array object.

You can access the array_view object where the source data is located (locally) or on a different accelerator or a coherence domain (remotely). When you access the object remotely, views are copied and cached as necessary. Except for the effects of automatic caching, array_view objects have a performance profile similar to that of array objects. There is a small to negligible access penalty when you access the data through views. There are three remote usage scenarios:

  • A view to a system memory pointer is passed by means of a parallel_for_each call to an accelerator and accessed on the accelerator.

  • A view to an array located on an accelerator is passed by means of a parallel_for_each call to another accelerator and is accessed there.

  • A view to an array located on an accelerator is accessed on the CPU. In any one of these scenarios, the referenced views are copied by the system to the remote location and, if modified by the array_view object, are copied back to the local location. The runtime might optimize the process of copying changes back, might copy only changed elements, or might copy unchanged portions also. Overlapping array_view objects on one data source are not guaranteed to maintain referential integrity in a remote location.

You must synchronize any multithreaded access to the same data source.

The runtime makes the following guarantees regarding the caching of data in array_view objects:

  • Let A be an array and V a view to the array. Then, all well synchronized accesses to A and V in program order obey a serial occurs-before relationship.

  • Let A be an array and V1 and V2 be overlapping views to the array.When executing on the accelerator where A has been allocated, all well-synchronized accesses through A, V1 and V2 are aliased through A and induce a total occurs-before relationship which obeys program order. (No caching.) Otherwise, if they are executing on different accelerators, the behavior of writing to V1 and V2 is undefined (a race).

When you create an array_view object using a pointer in system memory, you must change the view array_view object only through the array_view pointer. Alternatively, you must call refresh()on one of the array_view objects that are attached to the system pointer, if the underlying native memory is changed directly, instead of through the array_view object. Either action notifies the array_view object that the underlying native memory is changed and that any copies that are located on an accelerator are outdated. If you follow these guidelines, the pointer-based views are identical to those provided to views of data-parallel arrays.

_Array_view_shape

_Array_view_base

array_view

Header: amp.h

Namespace: Concurrency

Did you find this helpful?
(1500 characters remaining)