다음을 통해 공유


array_view 클래스

다른 컨테이너에 저장된 데이터에 대한 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
개체에 있는 요소의 데이터 형식입니다 array_view .

_Rank
개체의 순위입니다 array_view .

멤버

공용 생성자

속성 설명
array_view 생성자 array_view 클래스의 새 인스턴스를 초기화합니다. 에 대한 array<T,N>기본 생성자가 없습니다. 모든 생성자는 CPU에서만 실행되도록 제한되며 Direct3D 대상에서 실행할 수 없습니다.
~array_view 소멸자 개체를 array_view 삭제합니다.

공용 메서드

이름 설명
copy_to 를 호출copy(*this, dest)하여 개체의 array_view 내용을 지정된 대상에 복사합니다.
data 의 원시 데이터에 대한 포인터를 반환합니다 array_view.
dis카드_data 이 뷰의 기본이 되는 현재 데이터를 카드.
get_extent array_view 개체의 익스텐트 개체를 반환합니다.
get_ref 인덱싱된 요소에 대한 참조를 반환합니다.
get_source_accelerator_view 데이터 원본 array_view있는 accelerator_view 반환합니다.
refresh 바인딩된 메모리가 인터페이스 외부에서 수정되었음을 개체에 array_view 알립니다array_view. 이 메서드를 호출하면 캐시된 모든 정보가 부실하게 렌더링됩니다.
reinterpret_as 개체의 모든 요소를 포함하는 1차원 배열을 array_view 반환합니다.
section 지정된 원점 및 필요에 따라 지정된 익스텐트를 가진 개체의 array_view 하위 섹션을 반환합니다.
synchronize 개체에 대한 모든 수정 내용을 array_view 원본 데이터로 다시 동기화합니다.
synchronize_async 개체에 대한 모든 수정 내용을 array_view 원본 데이터로 비동기적으로 동기화합니다.
synchronize_to 개체에 대한 모든 수정 내용을 array_view 지정된 accelerator_view 동기화합니다.
synchronize_to_async 개체에 대한 모든 수정 내용을 array_view 지정된 accelerator_view 비동기적으로 동기화합니다.
view_as array_viewarray_view 개체의 데이터를 사용하여 다른 순위의 개체를 생성합니다.

Public 연산자

이름 설명
operator() 매개 변수 또는 매개 변수로 지정된 요소의 값을 반환합니다.
operator[] 매개 변수로 지정된 요소를 반환합니다.
operator= 지정된 array_view 개체의 콘텐츠를 이 항목으로 복사합니다.

공용 상수

이름 설명
rank 상수 array_view 개체의 차수를 저장합니다.

데이터 멤버

이름 설명
extent extent 개체의 모양을 정의하는 array_view 개체를 가져옵니다.
source_accelerator_view 데이터 원본 array_view 이 있는 accelerator_view 가져옵니다.
value_type 바인딩된 배열의 array_view 값 형식입니다.

설명

클래스는 array_view 배열 개체 또는 개체의 하위 섹션에 포함된 데이터에 대한 뷰를 array 나타냅니다.

원본 데이터가 있는 개체(로컬) 또는 다른 가속기 또는 일관성이 있는 개체에 액세스할 array_view 수 있습니다기본(원격으로). 개체에 원격으로 액세스하면 뷰가 필요에 따라 복사되고 캐시됩니다. 자동 캐싱 array_view 의 효과를 제외하고 개체에는 개체의 array 성능 프로필과 유사한 성능 프로필이 있습니다. 보기를 통해 데이터에 액세스할 때 성능 저하가 적습니다.

다음과 같은 세 가지 원격 사용 시나리오가 있습니다.

  • 시스템 메모리 포인터에 대한 뷰는 가속기를 parallel_for_each 호출하여 전달되고 가속기에서 액세스됩니다.

  • 액셀러레이터에 있는 배열에 대한 뷰는 다른 액셀러레이터에 대한 호출을 parallel_for_each 통해 전달되고 해당 위치에 액세스됩니다.

  • 액셀러레이터에 있는 배열에 대한 보기는 CPU에서 액세스됩니다.

이러한 시나리오 중 하나에서 참조된 뷰는 런타임에 의해 원격 위치로 복사되고 개체 호출에 array_view 의해 수정된 경우 로컬 위치로 다시 복사됩니다. 런타임은 변경 내용을 다시 복사하는 프로세스를 최적화하거나, 변경된 요소만 복사하거나, 변경되지 않은 부분도 복사할 수 있습니다. 한 데이터 원본에서 겹치는 array_view 개체는 원격 위치에서 참조 무결성을 기본 보장되지 않습니다.

동일한 데이터 원본에 대한 모든 다중 스레드 액세스를 동기화해야 합니다.

런타임은 개체의 데이터 array_view 캐싱과 관련하여 다음과 같은 보장을 수행합니다.

  • 잘 동기화된 모든 개체와 array_view 개체에 대한 액세스 array 는 프로그램 순서대로 직렬 관계 앞에 적용됩니다.

  • 단일 array 개체의 동일한 가속기에서 겹 array_view 치는 개체에 대한 모든 잘 동기화된 액세스는 개체를 array 통해 별칭이 지정됩니다. 그들은 프로그램 순서를 준수 하는 전체 발생-전에 관계를 유도 합니다. 캐싱이 없습니다. 개체가 array_view 다른 가속기에서 실행되는 경우 액세스 순서가 정의되지 않고 경합 상태가 생성됩니다.

시스템 메모리에서 포인터를 array_view 사용하여 개체를 만들 때는 포인터를 통해서만 뷰 array_view 개체를 array_view 변경해야 합니다. 또는 기본 네이티브 메모리가 개체를 통해 array_view 서가 아니라 직접 변경되는 경우 시스템 포인터에 연결된 개체 중 하나를 array_view 호출 refresh() 해야 합니다.

두 작업 중 하나는 기본 네이티브 메모리가 변경되고 액셀러레이터에 있는 모든 복사본이 오래되었다는 것을 개체에 알 array_view 깁니다. 이러한 지침을 따르는 경우 포인터 기반 뷰는 데이터 병렬 배열 보기에 제공된 뷰와 동일합니다.

상속 계층 구조

_Array_view_shape

_Array_view_base

array_view

요구 사항

헤더: amp.h

네임스페이스: 동시성

~Array_view

개체를 array_view 삭제합니다.

~array_view()restrict(amp,cpu);

Array_view

array_view 클래스의 새 인스턴스를 초기화합니다.

array_view(
    array<value_type, _Rank>& _Src)restrict(amp,cpu);

array_view(
    const array_view& _Other)restrict(amp,cpu);

explicit array_view(
    const Concurrency::extent<_Rank>& _Extent) restrict(cpu);

template <
    typename _Container
>
array_view(
    const Concurrency::extent<_Rank>& _Extent,
    _Container& _Src) restrict(cpu);

array_view(
    const Concurrency::extent<_Rank>& _Extent,
    value_type* _Src)restrict(amp,cpu);

explicit array_view(
    int _E0) restrict(cpu);

template <
    typename _Container
>
explicit array_view(
    _Container& _Src,
    typename std::enable_if<details::_Is_container<_Container>::type::value, void **>::type = 0) restrict(cpu);

template <
    typename _Container
>
explicit array_view(
    int _E0,
    _Container& _Src) restrict(cpu);

explicit array_view(
    int _E0,
    int _E1) __CPU_ONLY;

template <
    typename _Container
>
explicit array_view(
    int _E0,
    int _E1,
    _Container& _Src) restrict(cpu);

explicit array_view(
    int _E0,
    int _E1,
    int _E2) __CPU_ONLY;

template <
    typename _Container
>
explicit array_view(
    int _E0,
    int _E1,
    int _E2,
    _Container& _Src);

explicit array_view(
    int _E0,
    _In_ value_type* _Src)restrict(amp,cpu);

template <
    typename _Arr_type,
    int _Size
>
explicit array_view(
    _In_ _Arr_type (& _Src) [_Size]) restrict(amp,cpu);

explicit array_view(
    int _E0,
    int _E1,
    _In_ value_type* _Src)restrict(amp,cpu);

explicit array_view(
    int _E0,
    int _E1,
    int _E2,
    _In_ value_type* _Src)restrict(amp,cpu);

array_view(
    const array<value_type, _Rank>& _Src)restrict(amp,cpu);

array_view(
    const array_view<value_type, _Rank>& _Src)restrict(amp,cpu);

array_view(
    const array_view<const value_type, _Rank>& _Src)restrict(amp,cpu);

template <
    typename _Container
>
array_view(
    const Concurrency::extent<_Rank>& _Extent,
    const _Container& _Src) restrict(cpu);

template <
    typename _Container
>
explicit array_view(
    const _Container& _Src,
    typename std::enable_if<details::_Is_container<_Container>::type::value, void **>::type = 0) restrict(cpu);

array_view(
    const Concurrency::extent<_Rank>& _Extent,
    const value_type* _Src)restrict(amp,cpu);

template <
    typename _Arr_type,
    int _Size
>
explicit array_view(
    const _In_ _Arr_type (& _Src) [_Size]) restrict(amp,cpu);

template <
    typename _Container
>
array_view(
    int _E0,
    const _Container& _Src);

template <
    typename _Container
>
array_view(
    int _E0,
    int _E1,
    const _Container& _Src);

template <
    typename _Container
>
array_view(
    int _E0,
    int _E1,
    int _E2,
    const _Container& _Src);

array_view(
    int _E0,
    const value_type* _Src)restrict(amp,cpu);

array_view(
    int _E0,
    int _E1,
    const value_type* _Src) restrict(amp,cpu);

array_view(
    int _E0,
    int _E1,
    int _E2,
    const value_type* _Src) restrict(amp,cpu);

매개 변수

_Arr_type
데이터를 제공하는 C 스타일 배열의 요소 형식입니다.

_컨테이너
지원 및 size() 멤버를 지원하는 선형 컨테이너를 지정해야 하는 템플릿 인수입니다data().

_E0
이 섹션의 범위에서 가장 중요한 구성 요소입니다.

_E1
이 섹션의 범위에서 가장 중요한 다음 구성 요소입니다.

_E2
이 섹션의 익스텐트 중 가장 중요하지 않은 구성 요소입니다.

_범위
array_view차원의 익스텐트입니다.

_Other
array_view형식을 초기화할 형식 array_view<T,N> 의 개체입니다.

_크기
데이터를 제공하는 C 스타일 배열의 크기입니다.

_Src
새 배열에 복사될 원본 데이터에 대한 포인터입니다.

copy_to

를 호출copy(*this, dest)하여 개체의 array_view 내용을 지정된 대상 개체에 복사합니다.

void copy_to(
    array<value_type, _Rank>& _Dest) const;

void copy_to(
    array_view<value_type, _Rank>& _Dest) const;

매개 변수

_Dest
복사할 개체입니다.

데이터

의 원시 데이터에 대한 포인터를 반환합니다 array_view.

value_type* data() const restrict(amp,
    cpu);

const value_type* data() const restrict(amp,
    cpu);

Return Value

array_view의 원시 데이터에 대한 포인터입니다.

dis카드_data

이 뷰의 기본이 되는 현재 데이터를 카드. 이는 보기 accelerator_view 의 현재 콘텐츠를 액세스 대상에 복사하지 않도록 하는 데 사용되는 런타임에 대한 최적화 힌트이며, 기존 콘텐츠가 필요하지 않은 경우 사용하는 것이 좋습니다. 이 메서드는 restrict(amp) 컨텍스트에서 사용되는 경우 no-op입니다.

void discard_data() const restrict(cpu);

extent

extent 개체의 모양을 정의하는 array_view 개체를 가져옵니다.

__declspec(property(get= get_extent)) Concurrency::extent<_Rank> extent;

get_extent

개체의 익스텐트 개체를 array_view 반환합니다.

Concurrency::extent<_Rank> get_extent() const restrict(cpu, amp);

Return Value

extent 개체의 array_view 개체입니다.

get_ref

_Index 인덱싱된 요소에 대한 참조를 가져옵니다. CPU의 array_view 액세스하기 위한 다른 인덱싱 연산자와 달리 이 메서드는 이 array_view 콘텐츠를 CPU와 암시적으로 동기화하지 않습니다. 원격 위치에서 array_view 액세스하거나 이 array_view 관련된 복사 작업을 수행한 후 사용자는 이 메서드를 호출하기 전에 array_view CPU에 명시적으로 동기화해야 합니다. 이렇게 하지 않으면 정의되지 않은 동작이 발생합니다.

value_type& get_ref(
    const index<_Rank>& _Index) const restrict(amp, cpu);

매개 변수

_Index
인덱스입니다.

Return Value

_Index 인덱싱된 요소에 대한 참조

get_source_accelerator_view

array_view 데이터 원본이 있는 accelerator_view 반환합니다. array_view 데이터 원본이 없는 경우 이 API는 runtime_exception throw합니다.

accelerator_view get_source_accelerator_view() const;

Return Value

operator()

매개 변수 또는 매개 변수로 지정된 요소의 값을 반환합니다.

value_type& operator() (
    const index<_Rank>& _Index) const restrict(amp,cpu);

typename details::_Projection_result_type<value_type,_Rank>::_Result_type operator() (
    int _I) const restrict(amp,cpu);

value_type& operator() (
    int _I0,
    int _I1) const restrict(amp,cpu);

value_type& operator() (
    int _I0,
    int _I1,
    int _I2) const restrict(amp,cpu);

typename details::_Projection_result_type<value_type,_Rank>::_Const_result_type operator() (
    int _I) const restrict(amp,cpu);

매개 변수

_Index
요소의 위치입니다.

_I0
첫 번째 차원의 인덱스입니다.

_I1
두 번째 차원의 인덱스입니다.

_I2
세 번째 차원의 인덱스입니다.

_I
요소의 위치입니다.

Return Value

매개 변수 또는 매개 변수로 지정된 요소의 값입니다.

operator[]

매개 변수로 지정된 요소를 반환합니다.

typename details::_Projection_result_type<value_type,_Rank>::_Const_result_type operator[] (
    int _I) const restrict(amp,cpu);

value_type& operator[] (
    const index<_Rank>& _Index) const restrict(amp,cpu);

매개 변수

_Index
인덱스입니다.

_I
인덱스입니다.

Return Value

인덱스의 요소 값 또는 array_view 가장 중요한 차원에 프로젝트된 값입니다.

operator=

지정된 array_view 개체의 내용을 이 개체에 복사합니다.

array_view& operator= (
    const array_view& _Other) restrict(amp,cpu);

array_view& operator= (
    const array_view<value_type, _Rank>& _Other) restrict(amp,cpu);

매개 변수

_Other
array_view 복사할 개체입니다.

Return Value

array_view 개체에 대한 참조입니다.

rank

array_view 개체의 차수를 저장합니다.

static const int rank = _Rank;

refresh

바인딩된 메모리가 인터페이스 외부에서 수정되었음을 개체에 array_view 알립니다array_view. 이 메서드를 호출하면 캐시된 모든 정보가 부실하게 렌더링됩니다.

void refresh() const restrict(cpu);

reinterpret_as

옵션으로 원본 array_view 다른 값 형식을 가질 수 있는 1차원 array_view 통해 array_view 다시 해석합니다.

구문

template <
    typename _Value_type2
>
array_view< _Value_type2, _Rank> reinterpret_as() const restrict(amp,cpu);

template <
    typename _Value_type2
>
array_view<const _Value_type2, _Rank> reinterpret_as() const restrict(amp,cpu);

매개 변수

_Value_type2
array_view 개체의 데이터 형식입니다.

Return Value

array_view 요소 형식이 변환되고 순위가 N에서 _Value_type2T1로 감소하여 이를 array_view기반으로 하는 개체 또는 const array_view 개체입니다.

설명

경우에 따라 다차원 배열을 원본 배열과 다른 값 형식을 가질 수 있는 선형 1차원 배열로 보는 것이 편리합니다. 이 메서드를 array_view 사용하여 이 작업을 수행할 수 있습니다.

다른 값 형식을 사용하여 array_view 개체를 재해석하는 경고는 잠재적으로 안전하지 않은 작업입니다. 이 기능은 주의하여 사용해야 합니다.

예를 들면 다음과 같습니다.

struct RGB { float r; float g; float b; };

array<RGB,3>  a = ...;
array_view<float,1> v = a.reinterpret_as<float>();

assert(v.extent == 3*a.extent);

section

지정된 원점 및 필요에 따라 지정된 익스텐트를 가진 개체의 array_view 하위 섹션을 반환합니다.

array_view section(
    const Concurrency::index<_Rank>& _Section_origin,
    const Concurrency::extent<_Rank>& _Section_extent) const restrict(amp,cpu);

array_view section(
    const Concurrency::index<_Rank>& _Idx) const restrict(amp,cpu);

array_view section(
    const Concurrency::extent<_Rank>& _Ext) const restrict(amp,cpu);

array_view section(
    int _I0,
    int _E0) const restrict(amp,cpu);

array_view section(
    int _I0,
    int _I1,
    int _E0,
    int _E1) const restrict(amp,cpu);

array_view section(
    int _I0,
    int _I1,
    int _I2,
    int _E0,
    int _E1,
    int _E2) const restrict(amp,cpu);

매개 변수

_E0
이 섹션의 범위에서 가장 중요한 구성 요소입니다.

_E1
이 섹션의 범위에서 가장 중요한 다음 구성 요소입니다.

_E2
이 섹션의 익스텐트 중 가장 중요하지 않은 구성 요소입니다.

_내선
구역의 익스텐트 범위를 지정하는 익스텐트 개체입니다. 원본은 0입니다.

_Idx
원본의 위치를 지정하는 인덱스 개체입니다. 하위 섹션은 나머지 범위입니다.

_I0
이 섹션의 원점에서 가장 중요한 구성 요소입니다.

_I1
이 섹션의 원점에서 가장 중요한 다음 구성 요소입니다.

_I2
이 섹션의 원점 중 가장 중요하지 않은 구성 요소입니다.

_Rank
섹션의 순위입니다.

_Section_extent
구역의 익스텐트 범위를 지정하는 익스텐트 개체입니다.

_Section_origin
원본의 위치를 지정하는 인덱스 개체입니다.

Return Value

지정된 원점 및 필요에 따라 지정된 익스텐트를 갖는 개체의 하위 섹션 array_view 입니다. 개체만 index 지정하면 하위 섹션에는 개체의 요소 인덱스보다 큰 인덱스가 있는 연결된 익스텐트 내의 모든 요소가 index 포함됩니다.

source_accelerator_view

이 array_view 연결된 원본 accelerator_view 가져옵니다.

__declspec(property(get= get_source_accelerator_view)) accelerator_view source_accelerator_view;

synchronize

개체에 대한 모든 수정 내용을 array_view 원본 데이터로 다시 동기화합니다.

void synchronize(access_type _Access_type = access_type_read) const restrict(cpu);

void synchronize() const restrict(cpu);

매개 변수

_Access_type
대상 accelerator_view 의도한 access_type. 이 매개 변수의 기본값은 .입니다 access_type_read.

synchronize_async

개체에 대한 모든 수정 내용을 array_view 원본 데이터로 비동기적으로 동기화합니다.

concurrency::completion_future synchronize_async(access_type _Access_type = access_type_read) const restrict(cpu);

concurrency::completion_future synchronize_async() const restrict(cpu);

매개 변수

_Access_type
대상 accelerator_view 의도한 access_type. 이 매개 변수의 기본값은 .입니다 access_type_read.

Return Value

작업이 완료될 때까지 대기할 미래입니다.

synchronize_to

이 array_view 수정한 내용을 지정된 accelerator_view 동기화합니다.

void synchronize_to(
    const accelerator_view& _Accl_view,
    access_type _Access_type = access_type_read) const restrict(cpu);

void synchronize_to(
    const accelerator_view& _Accl_view) const restrict(cpu);

매개 변수

_Accl_view
동기화할 대상 accelerator_view.

_Access_type
대상 accelerator_view 원하는 access_type. 이 매개 변수의 기본값은 access_type_read.

synchronize_to_async

이 array_view 수정한 내용을 지정된 accelerator_view 비동기적으로 동기화합니다.

concurrency::completion_future synchronize_to_async(
    const accelerator_view& _Accl_view,
    access_type _Access_type = access_type_read) const restrict(cpu);

concurrency::completion_future synchronize_to_async(
    const accelerator_view& _Accl_view) const restrict(cpu);

매개 변수

_Accl_view
동기화할 대상 accelerator_view.

_Access_type
대상 accelerator_view 원하는 access_type. 이 매개 변수의 기본값은 access_type_read.

Return Value

작업이 완료될 때까지 대기할 미래입니다.

value_type

array_view 값 형식 및 바인딩된 배열입니다.

typedef typenamevalue_type value_type;

view_as

이를 array_view 다른 순위로 array_view 재해석합니다.

template <
    int _New_rank
>
array_view<value_type,_New_rank> view_as(
    const Concurrency::extent<_New_rank>& _View_extent) const restrict(amp,cpu);

template <
    int _New_rank
>
array_view<const value_type,_New_rank> view_as(
    const Concurrency::extent<_New_rank> _View_extent) const restrict(amp,cpu);

매개 변수

_New_rank
array_view 개체의 순위입니다.

_View_extent
변형입니다.extent

value_type
원래 배열 개체와 반환 array_view 된 개체 모두에 있는 요소의 데이터 형식입니다.

Return Value

array_view 생성되는 개체입니다.

참고 항목

Concurrency 네임스페이스(C++ AMP)