array::array 建構函式
初始化 array 類別的新執行個體。 array<T,N> 沒有預設的建構函式。 所有建構函式都只能在 CPU 上執行。 它們無法在 Direct3D 目標上執行。
explicit array(
const Concurrency::extent<_Rank> & _Extent
) restrict(cpu);
explicit array(
int _E0
) restrict(cpu);
explicit array(
int _E0,
int _E1
) restrict(cpu);
explicit array(
int _E0,
int _E1,
int _E2
) restrict(cpu);
array(
const Concurrency::extent<_Rank>& _Extent,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
array(
int _E0,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
array(
int _E0,
int _E1,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
array(
int _E0,
int _E1,
int _E2,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
array(
const Concurrency::extent<_Rank>& _Extent,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
array(
int _E0,
accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
array(
int _E0,
int _E1,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
array(
int _E0,
int _E1,
int _E2,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
template <
typename _InputIterator
>
array(
const Concurrency::extent<_Rank>& _Extent,
_InputIterator _Src_first,
_InputIterator _Src_last
) restrict(cpu);
template <
typename _InputIterator
>
array(
const Concurrency::extent<_Rank>& _Extent,
_InputIterator _Src_first
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
_InputIterator _Src_first,
_InputIterator _Src_last
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
_InputIterator _Src_first
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
_InputIterator _Src_first,
_InputIterator _Src_last
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
_InputIterator _Src_first
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
int _E2,
_InputIterator _Src_first,
_InputIterator _Src_last
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
int _E2,
_InputIterator _Src_first
) restrict(cpu);
template <
typename _InputIterator
>
array(
const Concurrency::extent<_Rank>& _Extent,
_InputIterator _Src_first,
_InputIterator _Src_last,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
template <
typename _InputIterator
>
array(
const Concurrency::extent<_Rank>& _Extent,
_InputIterator _Src_first,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
_InputIterator _Src_first,
_InputIterator _Src_last,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
_InputIterator _Src_first,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
_InputIterator _Src_first,
_InputIterator _Src_last,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
_InputIterator _Src_first,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
int _E2,
_InputIterator _Src_first,
_InputIterator _Src_last,
Concurrency::accelerator_view _Av,
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
int _E2,
_InputIterator _Src_first,
Concurrency::accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
template <
typename _InputIterator
>
array(
const Concurrency::extent<_Rank>& _Extent,
_InputIterator _Src_first,
_InputIterator _Src_last,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
template <
typename _InputIterator
>
array(
const Concurrency::extent<_Rank>& _Extent,
_InputIterator _Src_first,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
_InputIterator _Src_first,
_InputIterator _Src_last,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
_InputIterator _Src_first,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
_InputIterator _Src_first,
_InputIterator _Src_last,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
_InputIterator _Src_first,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
int _E2,
_InputIterator _Src_first,
_InputIterator _Src_last,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
template <
typename _InputIterator
>
array(
int _E0,
int _E1,
int _E2,
_InputIterator _Src_first,
Concurrency::accelerator_view _Av,
Concurrency::accelerator_view _Associated_Av
) restrict(cpu);
explicit array(
const array_view<const _Value_type, _Rank>& _Src
) restrict(cpu);
array(
const array_view<const _Value_type, _Rank>& _Src,
accelerator_view _Av
access_type _Cpu_access_type = access_type_auto
) restrict(cpu);
array(
const array_view<const _Value_type, _Rank>& _Src,
accelerator_view _Av,
accelerator_view _Associated_Av
) restrict(cpu);
array(
const array& _Other
) restrict(cpu);
array(
array && _Other
) restrict(cpu);
參數
_Associated_Av
指定陣列慣用目標位置的 accelerator_view。_Av
指定陣列位置 accelerator_view 的物件。_Cpu_access_type
CPU 上的陣列所需的 access_type。 這個參數具有預設值 access_type_auto,將 CPU access_type 判斷保留給執行階段。 陣列的實際 CPU access_type 可以使用 get_cpu_access_type 方法來查詢。_Extent
陣列中每個維度的範圍。_E0
這個區段範圍的最重要元件。_E1
這個區段範圍的次重要元件。_E2
這個區段範圍的最不重要元件。_InputIterator
輸入迭代器的類型。_Src
給要複製的物件。_Src_first
來源容器中的開頭迭代器。_Src_last
來源容器中的結束迭代器。_Other
其他資料來源。_Rank
區段的順位。_Value_type
所複製項目的資料類型。
備註
預備環境建構函式有兩個 accelerator_view 物件,可做為建構函式參數。 預備環境陣列會做為最佳化兩個加速器之間 (CPU 和 Direct3D 加速器之間) 重複之複本的提示。 預備環境陣列會針對資料傳輸進行最佳化,且沒有穩定的使用者空間記憶體。 它們是由具有正確硬體對齊的 DirectX 暫存緩衝區所支援,可確保 CPU 與加速器之間擁有有效率的直接記憶體存取 (DMA) 傳輸。 預備環境陣列的 accelerator_view 屬性會傳回建構時所使用的第一個加速器引數的值。 當預備環境陣列參與傳輸作業時,您無法變更或檢查其內容,如下列程式碼所示。
class SimulationServer
{
array<float,2> acceleratorArray;
array<float,2> stagingArray;
public:
SimulationServer(const accelerator_view& av)
:acceleratorArray(extent<2>(1000,1000), av),
stagingArray(extent<2>(1000,1000), accelerator("cpu"),
accelerator("gpu"))
{
}
void OnCompute()
{
array<float,2> &a = acceleratorArray;
ApplyNetworkChanges(stagingArray.data());
// Starting here, you can't change or examine contents.
a = stagingArray;
parallel_for_each(a.extents, [&](index<2> idx)
{
// Update a[idx] according to simulation.
}
stagingArray = a;
// Starting here, you can change or examine contents.
SendToClient(stagingArray.data());
}
};
需求
**標頭:**amp.h
**命名空間:**並行