array_view Class
[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)>;
Public Constructors
|
Name |
Description |
|---|---|
|
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. |
|
|
Destroys the array_view object. |
Public Methods
|
Name |
Description |
|---|---|
|
Copies the contents of the array_view object to the specified destination by calling copy(*this, dest). |
|
|
Returns a pointer to the raw data of the array_view. |
|
|
Discards the current data underlying this view. |
|
|
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. |
|
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. |
|
|
Returns a one-dimensional array that contains all the elements in the array_view object. |
|
|
Returns a subsection of the array_view object that's at the specified origin and, optionally, that has the specified extent. |
|
|
Synchronizes any modifications made to the array_view object back to its source data. |
|
|
Returns an array_view object that is constructed from the array_view object. |
Public Operators
|
Name |
Description |
|---|---|
|
Returns the value of the element that is specified by the parameter or parameters. |
|
|
Returns the element that is specified by the parameters. |
|
|
Copies the contents of the specified array_view object into this one. |
Public Constants
|
Name |
Description |
|---|---|
|
Stores the rank of the array_view object. |
Data Members
|
Name |
Description |
|---|---|
|
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.