STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
amp.h
Go to the documentation of this file.
1 /***
2 * ==++==
3 *
4 * Copyright (c) Microsoft Corporation. All rights reserved.
5 *
6 * ==--==
7 * =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
8 *
9 * amp.h
10 *
11 * C++ AMP Library
12 *
13 * =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
14 ****/
15 
16 #pragma once
17 
18 #include <crtdbg.h>
19 #include <vector>
20 #include <iterator>
21 #include <future>
22 
23 #include <amprt.h>
24 #include <xxamp.h>
25 #include <type_traits>
26 
27 #define _AMP_H
28 
29 #pragma pack(push,8)
30 
31 
32 namespace Concurrency
33 {
34 
53 template <int _Rank> class index
54 {
55 public:
57 
58  template <typename _Value_type, int _Rank>
59  friend class array;
60 
61  template <int _Rank, int _Element_size>
63 
64  template <int _Rank, int _Element_size>
66 
67  static const int rank = _Rank;
68  typedef int value_type;
69 
74  {
76  }
77 
84  index(const index<_Rank>& _Other) __GPU
85  {
87  }
88 
95  explicit index(int _I) __GPU
96  {
97  static_assert(_Rank == 1, "This constructor can only be used to construct an index<1> object.");
99  }
100 
110  index(int _I0, int _I1) __GPU
111  {
112  static_assert(_Rank == 2, "This constructor can only be used to construct an index<2> object.");
113  _M_base[0] = _I0;
114  _M_base[1] = _I1;
115  }
116 
129  index(int _I0, int _I1, int _I2) __GPU
130  {
131  static_assert(_Rank == 3, "This constructor can only be used to construct an index<3> object.");
132  _M_base[0] = _I0;
133  _M_base[1] = _I1;
134  _M_base[2] = _I2;
135  }
136 
145  explicit index(const int _Array[_Rank]) __GPU
146  {
148  }
149 
154  {
156  return *this;
157  }
158 
168  int operator[] (unsigned _Index) const __GPU
169  {
170  return _M_base[_Index];
171  }
172 
182  int& operator[] (unsigned _Index) __GPU
183  {
184  return _M_base[_Index];
185  }
186 
187  // Operations
188 
199  {
201  return *this;
202  }
203 
214  {
216  return *this;
217  }
218 
229  {
231  return *this;
232  }
233 
244  {
246  return *this;
247  }
248 
259  {
261  return *this;
262  }
263 
274  {
276  return *this;
277  }
278 
289  {
291  return *this;
292  }
293 
301  {
303  return *this;
304  }
305 
313  {
314  index<_Rank> old_Index(*this);
316  return old_Index;
317  }
318 
326  {
328  return *this;
329  }
330 
338  {
339  index<_Rank> old_Index(*this);
341  return old_Index;
342  }
343 
344 private:
345  template<class _Tuple_type>
346  friend
348 
356  //
357  // implementation details - end
358 
359  int _M_base[_Rank];
360 };
361 
362 
383 template <int _Rank> class extent
384 {
385 public:
387 
388  template <typename _Value_type, int _Rank>
389  friend class array;
390 
391  template <int _Rank, int _Element_size>
393 
394  template <int _Rank, int _Element_size>
396 
397  static const int rank = _Rank;
398  typedef int value_type;
399 
400 
405  {
407  }
408 
415  extent(const extent<_Rank>& _Other) __GPU
416  {
418  }
419 
426  explicit extent(int _I) __GPU
427  {
428  static_assert(_Rank == 1, "This constructor can only be used to construct an extent<1> object.");
429  _M_base[0] = _I;
430  }
431 
441  extent(int _I0, int _I1) __GPU
442  {
443  static_assert(_Rank == 2, "This constructor can only be used to construct an extent<2> object.");
444  _M_base[0] = _I0;
445  _M_base[1] = _I1;
446  }
447 
460  extent(int _I0, int _I1, int _I2) __GPU
461  {
462  static_assert(_Rank == 3, "This constructor can only be used to construct an extent<3> object.");
463  _M_base[0] = _I0;
464  _M_base[1] = _I1;
465  _M_base[2] = _I2;
466  }
467 
476  explicit extent(const int _Array[_Rank]) __GPU
477  {
479  }
480 
485  {
487  return *this;
488  }
489 
499  int operator[] (unsigned int _Index) const __GPU
500  {
501  return _M_base[_Index];
502  }
503 
513  int& operator[] (unsigned int _Index) __GPU
514  {
515  return _M_base[_Index];
516  }
517 
521  unsigned int size() const __GPU
522  {
523  return static_cast<unsigned int>(_product_helper<extent<_Rank>>::func(_M_base));
524  }
525 
529  bool contains(const index<rank>& _Index) const __GPU
530  {
531  return details::_contains<extent<rank>, index<rank>, rank>::func(*this, _Index);
532  }
533 
537  template <int _Dim0> tiled_extent<_Dim0> tile() const __GPU
538  {
539  static_assert(rank == 1, "One-dimensional tile() method only available on extent<1>");
540  static_assert(_Dim0>0, "All tile dimensions must be positive");
541 
542  return tiled_extent<_Dim0>(*this);
543  }
544 
548  template <int _Dim0, int _Dim1> tiled_extent<_Dim0, _Dim1> tile() const __GPU
549  {
550  static_assert(rank == 2, "Two-dimensional tile() method only available on extent<2>");
551  static_assert(_Dim0>0 && _Dim1>0, "All tile dimensions must be positive");
552 
553  return tiled_extent<_Dim0, _Dim1>(*this);
554  }
555 
559  template <int _Dim0, int _Dim1, int _Dim2> tiled_extent<_Dim0, _Dim1, _Dim2> tile() const __GPU
560  {
561  static_assert(rank == 3, "Three-dimensional tile() method only available on extent<3>");
562  static_assert(_Dim0>0 && _Dim1>0 && _Dim2>0, "All tile dimensions must be positive");
563 
564  return tiled_extent<_Dim0, _Dim1, _Dim2>(*this);
565  }
566 
567  // Operations
568 
579  {
581  details::_arithmetic_op_loop_helper<extent<_Rank>, details::opAdd>::func(new_extent, *this, _Rhs);
582  return new_extent;
583  }
584 
595  {
597  details::_arithmetic_op_loop_helper<extent<_Rank>, details::opSub>::func(new_extent, *this, _Rhs);
598  return new_extent;
599  }
600 
611  {
613  return *this;
614  }
615 
626  {
628  return *this;
629  }
630 
641  {
643  return *this;
644  }
645 
656  {
658  return *this;
659  }
660 
671  {
673  return *this;
674  }
675 
686  {
688  return *this;
689  }
690 
701  {
703  return *this;
704  }
705 
716  {
718  return *this;
719  }
720 
731  {
733  return *this;
734  }
735 
743  {
745  return *this;
746  }
747 
755  {
756  extent<_Rank> old_extent(*this);
758  return old_extent;
759  }
760 
768  {
770  return *this;
771  }
772 
780  {
781  extent<_Rank> old_extent(*this);
783  return old_extent;
784  }
785 
786  // implementation details (compiler helpers) - begin
787 
788  // Index mapping for simple zero-based extent domain.
789  index<_Rank> _map_index(const index<_Rank>& _Index) const __GPU {
790  return _Index;
791  }
792 
793 private:
794  template<class _Tuple_type>
795  friend
804 
805  // the store
806  int _M_base[_Rank];
807 };
808 
809 namespace details
810 {
811  template <typename T> struct _Is_extent_or_index : std::false_type { };
812 
813  template <int N>
815 
816  template <int N>
818 }
819 
820 template <int _Rank, template <int> class _Tuple_type>
821 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, bool>::type
822 operator==(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
823 {
825 }
826 
827 template <int _Rank, template <int> class _Tuple_type>
828 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, bool>::type
829 operator!=(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
830 {
832 }
833 
834 template <int _Rank, template <int> class _Tuple_type>
835 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
836 operator+(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
837 {
838  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
839  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opAdd>::func(new_Tuple, _Lhs, _Rhs);
840  return new_Tuple;
841 }
842 
843 template <int _Rank, template <int> class _Tuple_type>
844 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
845 operator-(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
846 {
847  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
848  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opSub>::func(new_Tuple, _Lhs, _Rhs);
849  return new_Tuple;
850 }
851 
852 template <int _Rank, template <int> class _Tuple_type>
853 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
854 operator+(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU
855 {
856  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
857  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opAdd>::func(new_Tuple, _Lhs, _Rhs);
858  return new_Tuple;
859 }
860 
861 template <int _Rank, template <int> class _Tuple_type>
862 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
863 operator+(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
864 {
865  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
866  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opAdd>::func(new_Tuple, _Lhs, _Rhs);
867  return new_Tuple;
868 }
869 
870 template <int _Rank, template <int> class _Tuple_type>
871 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
872 operator-(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU
873 {
874  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
875  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opSub>::func(new_Tuple, _Lhs, _Rhs);
876  return new_Tuple;
877 }
878 
879 template <int _Rank, template <int> class _Tuple_type>
880 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
881 operator-(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
882 {
883  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
884  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opSub>::func(new_Tuple, _Lhs, _Rhs);
885  return new_Tuple;
886 }
887 
888 template <int _Rank, template <int> class _Tuple_type>
889 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
890 operator*(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU
891 {
892  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
893  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMul>::func(new_Tuple, _Lhs, _Rhs);
894  return new_Tuple;
895 }
896 
897 template <int _Rank, template <int> class _Tuple_type>
898 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
899 operator*(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
900 {
901  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
902  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMul>::func(new_Tuple, _Lhs, _Rhs);
903  return new_Tuple;
904 }
905 
906 template <int _Rank, template <int> class _Tuple_type>
907 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
908 operator/(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU
909 {
910  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
911  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opDiv>::func(new_Tuple, _Lhs, _Rhs);
912  return new_Tuple;
913 }
914 
915 template <int _Rank, template <int> class _Tuple_type>
916 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
917 operator/(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
918 {
919  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
920  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opDiv>::func(new_Tuple, _Lhs, _Rhs);
921  return new_Tuple;
922 }
923 
924 template <int _Rank, template <int> class _Tuple_type>
925 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
926 operator%(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU
927 {
928  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
929  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMod>::func(new_Tuple, _Lhs, _Rhs);
930  return new_Tuple;
931 }
932 
933 template <int _Rank, template <int> class _Tuple_type>
934 typename std::enable_if<details::_Is_extent_or_index<_Tuple_type<_Rank>>::value, _Tuple_type<_Rank>>::type
935 operator%(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
936 {
937  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
938  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMod>::func(new_Tuple, _Lhs, _Rhs);
939  return new_Tuple;
940 }
949 {
950 public:
958 #pragma warning( suppress : 4100 ) // unreferenced formal parameter
959  tile_barrier(const tile_barrier& _Other) __GPU {}
960 
965  void wait() const __GPU_ONLY
966  {
968  }
969 
975  {
977  }
978 
984  {
986  }
987 
993  {
995  }
996 };
997 
1002 template <int _Rank> class _Tiled_index_base
1003 {
1004 public:
1005 
1007 
1008  static const int rank = _Rank;
1009 
1014 
1019 
1024 
1029 
1034 
1054  const index<rank>& _Local,
1055  const index<rank>& _Tile,
1056  const index<rank>& _Tile_origin,
1057  const tile_barrier& _Barrier) __GPU
1058  : global(_Global), local(_Local), tile(_Tile), tile_origin(_Tile_origin), barrier(_Barrier)
1059  {}
1060 
1068  : global(_Other.global),
1069  local(_Other.local),
1070  tile(_Other.tile),
1071  tile_origin(_Other.tile_origin),
1072  barrier(_Other.barrier)
1073  {}
1074 
1079  operator const index<rank>() const __GPU
1080  {
1081  return global;
1082  }
1083 
1084 private:
1086 };
1087 
1096 template <int _Dim0, int _Dim1 = 0, int _Dim2 = 0> class tiled_index : public _Tiled_index_base<3>
1097 {
1098 public:
1117  tiled_index(const index<rank>& _Global,
1118  const index<rank>& _Local,
1119  const index<rank>& _Tile,
1120  const index<rank>& _Tile_origin,
1121  const tile_barrier& _Barrier) __GPU
1122  : _Tiled_index_base(_Global, _Local, _Tile, _Tile_origin, _Barrier)
1123  {}
1124 
1131  tiled_index(const tiled_index& _Other) __GPU
1132  : _Tiled_index_base(_Other)
1133  {}
1134 
1139  __declspec(property(get=get_tile_extent)) extent<rank> tile_extent;
1140  extent<rank> get_tile_extent() const __GPU { return extent<rank>(_Dim0, _Dim1, _Dim2); }
1141 
1145  static const int tile_dim0 = _Dim0;
1146  static const int tile_dim1 = _Dim1;
1147  static const int tile_dim2 = _Dim2;
1148 
1149 private:
1150  tiled_index& operator=(const tiled_index&) __GPU;
1151 };
1152 
1153 template <int _Dim0, int _Dim1>
1154 class tiled_index<_Dim0, _Dim1, 0> : public _Tiled_index_base<2>
1155 {
1156 public:
1175  tiled_index(const index<rank>& _Global,
1176  const index<rank>& _Local,
1177  const index<rank>& _Tile,
1178  const index<rank>& _Tile_origin,
1179  const tile_barrier& _Barrier) __GPU
1180  : _Tiled_index_base(_Global, _Local, _Tile, _Tile_origin, _Barrier)
1181  {}
1182 
1189  tiled_index(const tiled_index& _Other) __GPU
1190  : _Tiled_index_base(_Other)
1191  {}
1192 
1197  __declspec(property(get=get_tile_extent)) extent<rank> tile_extent;
1198  extent<rank> get_tile_extent() const __GPU { return extent<rank>(_Dim0, _Dim1); }
1199 
1203  static const int tile_dim0 = _Dim0;
1204  static const int tile_dim1 = _Dim1;
1205 
1206 private:
1207  tiled_index& operator=(const tiled_index&) __GPU;
1208 };
1209 
1210 template <int _Dim0>
1211 class tiled_index<_Dim0, 0, 0> : public _Tiled_index_base<1>
1212 {
1213 public:
1232  tiled_index(const index<rank>& _Global,
1233  const index<rank>& _Local,
1234  const index<rank>& _Tile,
1235  const index<rank>& _Tile_origin,
1236  const tile_barrier& _Barrier) __GPU
1237  : _Tiled_index_base(_Global, _Local, _Tile, _Tile_origin, _Barrier)
1238  {}
1239 
1246  tiled_index(const tiled_index& _Other) __GPU
1247  : _Tiled_index_base(_Other)
1248  {}
1249 
1254  __declspec(property(get=get_tile_extent)) extent<rank> tile_extent;
1255  extent<rank> get_tile_extent() const __GPU { return extent<rank>(_Dim0); }
1256 
1260  static const int tile_dim0 = _Dim0;
1261 
1262 private:
1263  tiled_index& operator=(const tiled_index&) __GPU;
1264 };
1265 
1266 
1274 template <int _Dim0, int _Dim1 /*=0*/, int _Dim2 /*=0*/> class tiled_extent : public Concurrency::extent<3>
1275 {
1276 public:
1277 
1278  static_assert(_Dim0>0, "_Dim0 must be positive");
1279  static_assert(_Dim1>0, "_Dim1 must be positive");
1280  static_assert(_Dim2>0, "_Dim2 must be positive");
1281 
1285  tiled_extent() __GPU {}
1286 
1291  {}
1292 
1296  tiled_extent(const tiled_extent& _Other) __GPU : Concurrency::extent<rank>(_Other)
1297  {}
1298 
1302  tiled_extent& operator=(const tiled_extent& _Other) __GPU
1303  {
1305  return *this;
1306  }
1307 
1312  __declspec(property(get=get_tile_extent)) Concurrency::extent<rank> tile_extent;
1313  Concurrency::extent<rank> get_tile_extent() const __GPU
1314  {
1315  return Concurrency::extent<rank>(_Dim0, _Dim1, _Dim2);
1316  }
1317 
1321  tiled_extent pad() const __GPU
1322  {
1323  Concurrency::extent<rank> _New_extent(((static_cast<unsigned int>((*this)[0]) + _Dim0 - 1)/_Dim0) * _Dim0,
1324  ((static_cast<unsigned int>((*this)[1]) + _Dim1 - 1)/_Dim1) * _Dim1,
1325  ((static_cast<unsigned int>((*this)[2]) + _Dim2 - 1)/_Dim2) * _Dim2);
1326 
1327  return tiled_extent<_Dim0,_Dim1,_Dim2>(_New_extent);
1328  }
1329 
1333  tiled_extent truncate() const __GPU
1334  {
1335  Concurrency::extent<rank> _New_extent(((*this)[0]/_Dim0) * _Dim0, ((*this)[1]/_Dim1) * _Dim1, ((*this)[2]/_Dim2) * _Dim2);
1336  return tiled_extent<_Dim0,_Dim1,_Dim2>(_New_extent);
1337  }
1338 
1342  static const int tile_dim0 = _Dim0;
1343  static const int tile_dim1 = _Dim1;
1344  static const int tile_dim2 = _Dim2;
1345 
1346  // implementation details (compiler helpers) - begin
1347 
1348  // Given the local index, the tile index, the global index, in the 0-based domain that
1349  // has same extents as 'this', and a barrier object, return a tiled_index<_Dim0, _Dim1, _Dim2> into
1350  // the 'this' tiled_extent domain.
1351  tiled_index<_Dim0, _Dim1, _Dim2> _map_index(const index<rank>& _Local, const index<rank>& _Tile, const index<rank>& _Global, tile_barrier& _Barrier) const __GPU
1352  {
1353  index<rank> _Tile_origin = details::_Create_uninitialized_tuple<index<rank>>();
1354  details::_arithmetic_op_loop_helper<index<rank>, details::opMul>::func(_Tile_origin, _Tile, tile_extent);
1355  return tiled_index<_Dim0, _Dim1, _Dim2>(_Global, _Local, _Tile, _Tile_origin, _Barrier);
1356  }
1357  // implementation details (compiler helpers) - end
1358 };
1359 
1360 
1361 template <int _Dim0, int _Dim1>
1362 class tiled_extent<_Dim0, _Dim1, 0> : public Concurrency::extent<2>
1363 {
1364 public:
1365 
1366  static_assert(_Dim0>0, "_Dim0 must be positive");
1367  static_assert(_Dim1>0, "_Dim1 must be positive");
1368 
1372  tiled_extent() __GPU {}
1373 
1378  {}
1379 
1383  tiled_extent(const tiled_extent& _Other) __GPU : Concurrency::extent<rank>(_Other)
1384  {}
1385 
1389  tiled_extent& operator=(const tiled_extent& _Other) __GPU
1390  {
1392  return *this;
1393  }
1394 
1399  __declspec(property(get=get_tile_extent)) Concurrency::extent<rank> tile_extent;
1400  Concurrency::extent<rank> get_tile_extent() const __GPU
1401  {
1402  return Concurrency::extent<rank>(_Dim0, _Dim1);
1403  }
1404 
1408  tiled_extent pad() const __GPU
1409  {
1410  Concurrency::extent<rank> _New_extent(((static_cast<unsigned int>((*this)[0]) + _Dim0 - 1)/_Dim0) * _Dim0,
1411  ((static_cast<unsigned int>((*this)[1]) + _Dim1 - 1)/_Dim1) * _Dim1);
1412  return tiled_extent<_Dim0,_Dim1>(_New_extent);
1413  }
1414 
1418  tiled_extent truncate() const __GPU
1419  {
1420  Concurrency::extent<rank> _New_extent(((*this)[0]/_Dim0) * _Dim0, ((*this)[1]/_Dim1) * _Dim1);
1421  return tiled_extent<_Dim0,_Dim1>(_New_extent);
1422  }
1423 
1427  static const int tile_dim0 = _Dim0;
1428  static const int tile_dim1 = _Dim1;
1429 
1430  // implementation details (compiler helpers) - begin
1431 
1432  // Given the local index, the tile index, the global index, in the 0-based domain that
1433  // has same extents as 'this', and a barrier object, return a tiled_index<_Dim0, _Dim1> into
1434  // the 'this' tiled_extent domain.
1435  tiled_index<_Dim0, _Dim1> _map_index(const index<rank>& _Local, const index<rank>& _Tile, const index<rank>& _Global, tile_barrier& _Barrier) const __GPU
1436  {
1437  index<rank> _Tile_origin = details::_Create_uninitialized_tuple<index<rank>>();
1438  details::_arithmetic_op_loop_helper<index<rank>, details::opMul>::func(_Tile_origin, _Tile, tile_extent);
1439  return tiled_index<_Dim0, _Dim1>(_Global, _Local, _Tile, _Tile_origin, _Barrier);
1440  }
1441  // implementation details (compiler helpers) - end
1442 };
1443 
1444 template <int _Dim0>
1445 class tiled_extent<_Dim0, 0, 0> : public Concurrency::extent<1>
1446 {
1447 public:
1448 
1449  static_assert(_Dim0>0, "_Dim0 must be positive");
1450 
1454  tiled_extent() __GPU {}
1455 
1460  {}
1461 
1465  tiled_extent(const tiled_extent& _Other) __GPU : Concurrency::extent<rank>(_Other)
1466  {}
1467 
1471  tiled_extent& operator=(const tiled_extent& _Other) __GPU
1472  {
1474  return *this;
1475  }
1476 
1481  __declspec(property(get=get_tile_extent)) Concurrency::extent<rank> tile_extent;
1482  Concurrency::extent<rank> get_tile_extent() const __GPU
1483  {
1484  return Concurrency::extent<rank>(_Dim0);
1485  }
1486 
1490  tiled_extent pad() const __GPU
1491  {
1492  Concurrency::extent<rank> _New_extent(((static_cast<unsigned int>((*this)[0]) + _Dim0 - 1)/_Dim0) * _Dim0);
1493  return tiled_extent<_Dim0>(_New_extent);
1494  }
1495 
1499  tiled_extent truncate() const __GPU
1500  {
1501  Concurrency::extent<rank> _New_extent(((*this)[0]/_Dim0) * _Dim0);
1502  return tiled_extent<_Dim0>(_New_extent);
1503  }
1504 
1508  static const int tile_dim0 = _Dim0;
1509 
1510  // implementation details (compiler helpers) - begin
1511 
1512  // Given the local index, the tile index, the global index, in the 0-based domain that
1513  // has same extents as 'this', and a barrier object, return a tiled_index<_Dim0> into
1514  // the 'this' tiled_extent domain.
1515  tiled_index<_Dim0> _map_index(const index<rank>& _Local, const index<rank>& _Tile, const index<rank>& _Global, tile_barrier& _Barrier) const __GPU
1516  {
1517  index<rank> _Tile_origin = details::_Create_uninitialized_tuple<index<rank>>();
1518  details::_arithmetic_op_loop_helper<index<rank>, details::opMul>::func(_Tile_origin, _Tile, tile_extent);
1519  return tiled_index<_Dim0>(_Global, _Local, _Tile, _Tile_origin, _Barrier);
1520  }
1521 };
1522 
1523 namespace details
1524 {
1525 
1526 template <int _Old_element_size, int _New_element_size>
1528 {
1529  int _Total_size = _Old_element_size * _Old_size;
1530  int _New_size = (_Total_size + _New_element_size - 1)/ _New_element_size;
1531 
1532  return _New_size;
1533 }
1534 
1535 
1536 template <int _Old_element_size, int _New_element_size>
1537 int _Calculate_reinterpreted_size(int _Old_size) __CPU_ONLY
1538 {
1539  int _Total_size = _Old_element_size * _Old_size;
1540  int _New_size = (_Total_size + _New_element_size - 1)/ _New_element_size;
1541 
1542  if (_New_size * _New_element_size > _Total_size)
1543  throw runtime_exception("Element type of reinterpret_as does not evenly divide into extent", E_INVALIDARG);
1544 
1545  return _New_size;
1546 }
1547 
1548 
1549 // This class defines the shape of an array view and provides
1550 // the functionality of translating dimensional indices into
1551 // flat offsets into the underlying buffer
1552 template <int _Rank, int _Element_size /* in number of ints */>
1554 {
1556  friend class _Array_view_shape<_Rank+1, _Element_size>;
1557 
1558 public:
1562  __declspec(property(get=get_extent)) Concurrency::extent<_Rank> extent;
1563  Concurrency::extent<_Rank> get_extent() const __GPU
1564  {
1565  return _M_view_extent;
1566  }
1567 
1569 
1570 protected:
1571  int _Base_linear_offset() const __GPU
1572  {
1573  return (_M_total_linear_offset - (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _M_view_offset._M_base)));
1574  }
1575 
1577  :
1578  _M_array_extent(_Other._M_array_extent),
1579  _M_array_multiplier(_Other._M_array_multiplier),
1580  _M_view_offset(_Other._M_view_offset),
1581  _M_total_linear_offset(_Other._M_total_linear_offset),
1582  _M_view_extent(_Other._M_view_extent)
1583  {
1584  }
1585 
1586  // For "section"
1587  _Array_view_shape(const _Array_view_shape& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
1588  :
1589  _M_array_extent(_Other._M_array_extent),
1590  _M_array_multiplier(_Other._M_array_multiplier),
1591  _M_view_offset(_Other._M_view_offset + _Section_origin),
1592  _M_view_extent(_Section_extent)
1593  {
1594  _Is_valid_section(_Other._M_view_extent, _Section_origin, _Section_extent);
1595 
1596  _M_total_linear_offset = _Other._Base_linear_offset() + (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _M_view_offset._M_base));
1597  }
1598 
1599  _Array_view_shape(int _Base_linear_offset, const Concurrency::extent<_Rank>& _Array_extent) __GPU
1600  :
1601  _M_array_extent(_Array_extent),
1602  _M_view_offset(index<_Rank>()),
1603  _M_total_linear_offset(_Base_linear_offset),
1604  _M_view_extent(_Array_extent)
1605  {
1606  _Initialize_multiplier();
1607  }
1608 
1609  _Array_view_shape(int _Base_linear_offset, const Concurrency::extent<_Rank>& _Array_extent,
1610  const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
1611  :
1612  _M_array_extent(_Array_extent),
1613  _M_view_offset(_Section_origin),
1614  _M_total_linear_offset(_Base_linear_offset),
1615  _M_view_extent(_Section_extent)
1616  {
1617  _Is_valid_section(_Array_extent, _Section_origin, _Section_extent);
1618 
1619  _Initialize_multiplier();
1620  _M_total_linear_offset += (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _M_view_offset._M_base));
1621  }
1622 
1624  {
1625  _M_array_extent = _Other._M_array_extent;
1626  _M_array_multiplier = _Other._M_array_multiplier;
1627  _M_view_offset = _Other._M_view_offset;
1628  _M_total_linear_offset = _Other._M_total_linear_offset;
1629  _M_view_extent = _Other._M_view_extent;
1630  return *this;
1631  }
1632 
1633  void _Project0(int _I, _Array_view_shape<_Rank-1,_Element_size>& _Projected_shape) const __GPU
1634  {
1635  static_assert(_Rank > 1, "Projection is only supported on array_views with a rank of 2 or higher");
1636 
1637  _Is_valid_projection(_I, this->_M_view_extent);
1638 
1639  typedef Concurrency::extent<_Rank-1> _RES_EXT;
1640  typedef Concurrency::extent<_Rank> _SRC_EXT;
1641  typedef Concurrency::index<_Rank-1> _RES_IDX;
1642  typedef Concurrency::index<_Rank> _SRC_IDX;
1644  _Projected_shape._M_array_extent, this->_M_array_extent,
1645  _Projected_shape._M_array_multiplier, this->_M_array_multiplier,
1646  _Projected_shape._M_view_offset, this->_M_view_offset,
1647  _Projected_shape._M_view_extent, this->_M_view_extent);
1648 
1649  _Projected_shape._M_total_linear_offset = _M_total_linear_offset + (_Element_size * _I * _M_array_multiplier[0]);
1650  }
1651 
1653  : _M_array_extent(details::_do_not_initialize), _M_array_multiplier(details::_do_not_initialize),
1654  _M_view_offset(details::_do_not_initialize), _M_view_extent(details::_do_not_initialize)
1655  {
1656  }
1657 
1658 private:
1659 
1661  {
1662  details::_Is_valid_extent(_M_array_extent);
1663  unsigned int _Ext = _M_array_extent[_Rank-1];
1664  details::_Array_init_helper<Concurrency::extent<_Rank>, Concurrency::extent<_Rank>>::func(_Ext, _M_array_multiplier, _M_array_extent);
1665  }
1666 
1667 protected:
1671  int _M_total_linear_offset; // in number of units
1673 };
1674 
1675 template <int _Rank, int _Element_size>
1676 class _Array_view_base : public _Array_view_shape<_Rank,_Element_size /* in number of ints */>
1677 {
1678  typedef _Array_flatten_helper<_Rank, typename Concurrency::extent<_Rank>::value_type, typename Concurrency::index<_Rank>::value_type> _Flatten_helper;
1679 
1680  template <int _R, int _S>
1681  friend class _Array_view_base;
1682 
1683 public:
1684 
1686 
1688  {
1689  // Unregister the view; Do not throw exception
1690  _Unregister(false);
1691  }
1692 
1693 protected:
1694 
1695  _Array_view_base() __GPU {}
1696 
1697  _Array_view_base(const _Buffer_descriptor& _Buffer_desc, const _Array_view_shape<_Rank, _Element_size>& _Shape) __GPU
1698  :
1699  _M_buffer_descriptor(_Buffer_desc),
1701  {
1702  // Register the view
1703  _Register();
1704  }
1705 
1706  _Array_view_base(const _Array_view_base& _Other) __GPU
1707  :
1708  _M_buffer_descriptor(_Other._M_buffer_descriptor),
1710  {
1711  // Register the view
1712  _Register_copy(_Other);
1713 
1714  // update this buffer descriptor in case _Register_copy was late and missed the update opportunity.
1715  _M_buffer_descriptor = _Other._M_buffer_descriptor;
1716  }
1717 
1718  _Array_view_base(const _Array_view_base& _Other, const Concurrency::extent<_Rank>& _Array_extent) __GPU
1719  :
1720  _M_buffer_descriptor(_Other._M_buffer_descriptor),
1721  _Array_view_shape<_Rank, _Element_size>(_Other._Base_linear_offset(), _Array_extent)
1722  {
1723  // Register the view
1724  _Register();
1725  }
1726 
1727  _Array_view_base(const _Array_view_base& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
1728  :
1729  _M_buffer_descriptor(_Other._M_buffer_descriptor),
1730  _Array_view_shape<_Rank, _Element_size>(_Other, _Section_origin, _Section_extent)
1731  {
1732  // Register the view
1733  _Register();
1734  }
1735 
1736  _Array_view_base(const _Buffer_descriptor& _Buffer_desc, const Concurrency::extent<_Rank>& _Array_extent) __GPU
1737  :
1738  _M_buffer_descriptor(_Buffer_desc),
1740  {
1741  // Register the view
1742  _Register();
1743  }
1744 
1745  _Array_view_base(const _Buffer_descriptor& _Buffer_desc, int _Base_linear_offset, const Concurrency::extent<_Rank>& _Array_extent) __GPU
1746  :
1747  _M_buffer_descriptor(_Buffer_desc),
1748  _Array_view_shape<_Rank, _Element_size>(_Base_linear_offset,_Array_extent)
1749  {
1750  // Register the view
1751  _Register();
1752  }
1753 
1755  const _Buffer_descriptor& _Buffer_desc,
1756  int _Base_linear_offset,
1757  const Concurrency::extent<_Rank>& _Array_extent,
1758  const Concurrency::index<_Rank>& _View_offset,
1759  const Concurrency::extent<_Rank>& _View_extent
1760  ) __CPU_ONLY
1761  :
1762  _M_buffer_descriptor(_Buffer_desc),
1763  _Array_view_shape<_Rank, _Element_size>(_Base_linear_offset,_Array_extent,_View_offset,_View_extent)
1764  {
1765  // Register the view
1766  _Register(_Buffer_desc._Get_view_key());
1767  }
1768 
1770  const _Buffer_descriptor& _Buffer_desc,
1771  int _Base_linear_offset,
1772  const Concurrency::extent<_Rank>& _Array_extent,
1773  const Concurrency::index<_Rank>& _View_offset,
1774  const Concurrency::extent<_Rank>& _View_extent
1775  ) __GPU_ONLY
1776  :
1777  _M_buffer_descriptor(_Buffer_desc),
1778  _Array_view_shape<_Rank, _Element_size>(_Base_linear_offset,_Array_extent,_View_offset,_View_extent)
1779  {
1780  // Register the view
1781  _Register();
1782  }
1783 
1784  _Array_view_base(const _Buffer_descriptor& _Buffer_desc, const Concurrency::extent<_Rank>& _Array_extent,
1785  const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
1786  :
1787  _M_buffer_descriptor(_Buffer_desc),
1788  _Array_view_shape<_Rank, _Element_size>(0,_Array_extent,_Section_origin,_Section_extent)
1789  {
1790  // Register the view
1791  _Register();
1792  }
1793 
1795  :
1797  {
1798  _Ubiquitous_buffer_ptr _PUBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_Array_extent.size(), _Element_size * sizeof(int));
1799  _M_buffer_descriptor = _Buffer_descriptor(NULL, _PUBuf, _No_access, _No_access);
1800 
1801  // Register the view
1802  _Register();
1803  }
1804 
1805  _Array_view_base(_In_ void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __CPU_ONLY
1806  :
1808  {
1809  if (_Data == NULL) {
1810  throw runtime_exception("Invalid pointer argument (NULL) to array_view constructor", E_INVALIDARG);
1811  }
1812 
1813  _Buffer_ptr _PBuf = _Buffer::_Create_buffer(_Data, accelerator(accelerator::cpu_accelerator).default_view, _Array_extent.size(), _Element_size * sizeof(int));
1814  _Ubiquitous_buffer_ptr _PUBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf);
1815  _M_buffer_descriptor = _Buffer_descriptor(_Data, _PUBuf, _Read_write_access, _Read_write_access);
1816 
1817  // Register the view
1818  _Register();
1819  }
1820 
1821  _Array_view_base(_In_ void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __GPU_ONLY
1822  :
1823  _Array_view_shape<_Rank, _Element_size>(0,_Array_extent), _M_buffer_descriptor(_Data, NULL, _Read_write_access, _Read_write_access)
1824  {
1825  }
1826 
1827  _Array_view_base(const void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __CPU_ONLY
1828  :
1830  {
1831  if (_Data == NULL) {
1832  throw runtime_exception("Invalid pointer argument (NULL) to array_view constructor", E_INVALIDARG);
1833  }
1834 
1835  _Buffer_ptr _PBuf = _Buffer::_Create_buffer(const_cast<void*>(_Data), accelerator(accelerator::cpu_accelerator).default_view, _Array_extent.size(), _Element_size * sizeof(int));
1836  _Ubiquitous_buffer_ptr _PUBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf);
1837  _M_buffer_descriptor = _Buffer_descriptor(const_cast<void*>(_Data), _PUBuf, _Read_access, _Read_access);
1838 
1839  // Register the view
1840  _Register();
1841  }
1842 
1843  _Array_view_base(const void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __GPU_ONLY
1844  :
1845 #pragma warning( push )
1846 #pragma warning( disable : 4880 )
1847  // Casting away constness in amp restricted scope might result in
1848  // undefined behavior, therefore, the compiler will report a level 1 warning
1849  // for it. But the following const_cast is harmless thus we are suppressing
1850  // this warning just for this line.
1851  _Array_view_shape<_Rank, _Element_size>(0,_Array_extent), _M_buffer_descriptor(const_cast<void*>(_Data), NULL, _Read_access, _Read_access)
1852 #pragma warning( pop )
1853  {
1854  }
1855 
1857  {
1858  if (this != &_Other)
1859  {
1860  // Unregister the current view
1861  _Unregister();
1862 
1863  _M_buffer_descriptor = _Other._M_buffer_descriptor;
1865 
1866  // Register the new view
1867  _Register_copy(_Other);
1868 
1869  // update this buffer descriptor in case _Register_copy was late and missed the update opportunity.
1870  _M_buffer_descriptor = _Other._M_buffer_descriptor;
1871  }
1872 
1873  return *this;
1874  }
1875 
1876  _Ret_ void * _Access(const index<_Rank>& _Index) const __GPU
1877  {
1878  int * _Ptr = reinterpret_cast<int *>(_M_buffer_descriptor._M_data_ptr);
1879  return &_Ptr[this->_M_total_linear_offset + (_Element_size * _Flatten_helper::func(this->_M_array_multiplier._M_base, _Index._M_base))];
1880  }
1881 
1882  _Ret_ void * _Access(_Access_mode _Requested_mode, const index<_Rank>& _Index) const __CPU_ONLY
1883  {
1884  // Refresh the data ptr if we do not have requested access
1885  if ((_M_buffer_descriptor._M_curr_cpu_access_mode & _Requested_mode) != _Requested_mode) {
1886  _M_buffer_descriptor._Get_CPU_access(_Requested_mode);
1887  }
1888 
1889  return _Access(_Index);
1890  }
1891 
1892  _Ret_ void * _Access(_Access_mode /*_Requested_mode*/, const index<_Rank>& _Index) const __GPU_ONLY
1893  {
1894  return _Access(_Index);
1895  }
1896 
1897  _Array_view_base _Section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU
1898  {
1899  auto _View = _Array_view_base(*this, _Section_origin, _Section_extent);
1900 
1901  // Register the constructed view with the section buffer view shape
1902  _View._Register(_Array_view_base::_Create_section_buffer_shape(this->_M_buffer_descriptor, _Section_origin, _Section_extent));
1903 
1904  return _View;
1905  }
1906 
1907  _Array_view_base _Section(const index<_Rank>& _Idx) const __GPU
1908  {
1909  return _Section(_Idx, this->extent - _Idx);
1910  }
1911 
1912  void _Project0(int _I, _Array_view_base<_Rank-1,_Element_size>& _Projected_view) const __GPU
1913  {
1914  _Projected_view._M_buffer_descriptor = this->_M_buffer_descriptor;
1916 
1917  // Register the constructed view with the projection buffer view shape
1918  _Projected_view._Register(_Array_view_base::_Create_projection_buffer_shape(this->_M_buffer_descriptor, 0, _I));
1919  }
1920 
1921  template <int _New_element_size>
1923  {
1924  static_assert(_Rank==1, "reinterpret_as is only permissible on array views of rank 1");
1925  int _New_size = _Calculate_reinterpreted_size<_Element_size,_New_element_size>(this->_M_view_extent.size());
1926  return _Array_view_base<_Rank,_New_element_size>(this->_M_buffer_descriptor,
1927  this->_M_total_linear_offset,
1928  Concurrency::extent<_Rank>(_New_size));
1929  }
1930 
1931  template <int _New_rank>
1933  {
1934  static_assert(_Rank==1, "view_as is only permissible on array views of rank 1");
1935  return _Array_view_base<_New_rank, _Element_size>(this->_M_buffer_descriptor,
1936  this->_M_total_linear_offset,
1937  _View_extent,
1938  index<_New_rank>(),
1939  _View_extent);
1940  }
1941 
1943  {
1944  unsigned int bufElemSize = static_cast<unsigned int>(_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_buffer_elem_size());
1945  unsigned int elemSize = _Element_size * sizeof(int);
1946 
1947  size_t linearOffsetInBytes = this->_Base_linear_offset() * sizeof(int);
1948 
1949  size_t baseLSDExtentInBytes = this->_M_array_extent[_Rank - 1];
1950  baseLSDExtentInBytes *= elemSize;
1951 
1952  size_t viewLSDOffsetInBytes = this->_M_view_offset[_Rank - 1];
1953  viewLSDOffsetInBytes *= elemSize;
1954 
1955  size_t viewLSDExtentInBytes = this->_M_view_extent[_Rank - 1];
1956  viewLSDExtentInBytes *= elemSize;
1957 
1958  // The base array extent, view extent, and view offset must be compatible with the underlying
1959  // buffer's element size
1960  if (((linearOffsetInBytes % bufElemSize) != 0) ||
1961  ((baseLSDExtentInBytes % bufElemSize) != 0) ||
1962  ((viewLSDOffsetInBytes % bufElemSize) != 0) ||
1963  ((viewLSDExtentInBytes % bufElemSize) != 0))
1964  {
1965  throw runtime_exception("The array_view base extent, view offset and/or view extent is incompatible with the underlying buffer", E_FAIL);
1966  }
1967 
1968  // The shape to be passed to the underlying buffer for registration must be in terms of
1969  // the element size of the buffer
1970  _ASSERTE((linearOffsetInBytes / bufElemSize) <= UINT_MAX);
1971  unsigned int linearOffset = static_cast<unsigned int>(linearOffsetInBytes / bufElemSize);
1972 
1973  unsigned int baseExtent[_Rank];
1974  unsigned int viewOffset[_Rank];
1975  unsigned int viewExtent[_Rank];
1976 #pragma warning( push )
1977 #pragma warning( disable : 6294 )
1978 #pragma warning( disable : 6201 ) // Index '-1' is out of valid index range '0' to '0' for possibly stack allocated buffer 'baseExtent'.
1979  for (int i = 0; i < _Rank - 1; ++i) {
1980  baseExtent[i] = this->_M_array_extent[i];
1981  viewOffset[i] = this->_M_view_offset[i];
1982  viewExtent[i] = this->_M_view_extent[i];
1983  }
1984 #pragma warning( pop )
1985 
1986  // The extent in the least significant dimension needs to be adjusted for
1987  // difference in element size between the buffer and ourselves
1988  _ASSERTE((baseLSDExtentInBytes / bufElemSize) <= UINT_MAX);
1989  baseExtent[_Rank - 1] = static_cast<unsigned int>(baseLSDExtentInBytes / bufElemSize);
1990 
1991  _ASSERTE((viewLSDOffsetInBytes / bufElemSize) <= UINT_MAX);
1992  viewOffset[_Rank - 1] = static_cast<unsigned int>(viewLSDOffsetInBytes / bufElemSize);
1993 
1994  _ASSERTE((viewLSDExtentInBytes / bufElemSize) <= UINT_MAX);
1995  viewExtent[_Rank - 1] = static_cast<unsigned int>(viewLSDExtentInBytes / bufElemSize);
1996 
1997  return _View_shape::_Create_view_shape(_Rank, linearOffset, baseExtent, viewOffset, viewExtent);
1998  }
1999 
2000 protected:
2001 
2002  // Underlying storage
2003  _Buffer_descriptor _M_buffer_descriptor;
2004 
2005 private:
2006 
2007  void _Register(_In_opt_ const _View_key _Source_view_key = nullptr) __CPU_ONLY
2008  {
2009  _M_buffer_descriptor._Get_buffer_ptr()->_Register_view(_M_buffer_descriptor._Get_view_key(),
2011  _Create_buffer_view_shape(),
2012  _Source_view_key);
2013 
2014  if (_M_buffer_descriptor._M_curr_cpu_access_mode != _No_access)
2015  {
2016  _Buffer_ptr _PBuf;
2017  _Get_access_async(_M_buffer_descriptor._Get_view_key(),
2019  _M_buffer_descriptor._M_curr_cpu_access_mode,
2020  _PBuf)._Get();
2021 
2022  _M_buffer_descriptor._M_data_ptr = _PBuf->_Get_host_ptr();
2023  }
2024  }
2025 
2027  {
2028  _M_buffer_descriptor._Get_buffer_ptr()->_Register_view_copy(_M_buffer_descriptor._Get_view_key(), _Other._M_buffer_descriptor._Get_view_key());
2029  }
2030 
2031  void _Register(_In_ void* _Shape) __CPU_ONLY
2032  {
2033  if (_Shape == NULL) {
2034  return;
2035  }
2036 
2037  // Unregister and register with the right shape
2038  _Unregister();
2039 
2040  _M_buffer_descriptor._Get_buffer_ptr()->_Register_view(_M_buffer_descriptor._Get_view_key(),
2042  reinterpret_cast<_View_shape*>(_Shape));
2043 
2044  if (_M_buffer_descriptor._M_curr_cpu_access_mode != _No_access)
2045  {
2046  _Buffer_ptr _PBuf;
2047  _Get_access_async(_M_buffer_descriptor._Get_view_key(),
2049  _M_buffer_descriptor._M_curr_cpu_access_mode,
2050  _PBuf)._Get();
2051 
2052  _M_buffer_descriptor._M_data_ptr = _PBuf->_Get_host_ptr();
2053  }
2054  }
2055 
2056  void _Unregister(bool _Throw_exception = true) __CPU_ONLY
2057  {
2058  if (!_Throw_exception && (std::current_exception() == nullptr)) {
2059  _Throw_exception = true;
2060  }
2061 
2062  try
2063  {
2064  _M_buffer_descriptor._Get_buffer_ptr()->_Unregister_view(_M_buffer_descriptor._Get_view_key());
2065  }
2066  catch(...)
2067  {
2068  if (_Throw_exception) {
2069  throw;
2070  }
2071  }
2072  }
2073 
2074  static _Ret_ void* _Create_projection_buffer_shape(const _Buffer_descriptor& _Descriptor, unsigned int _Dim, int _Dim_offset) __CPU_ONLY
2075  {
2076  _View_shape* _Base_shape = _Get_buffer_view_shape(_Descriptor);
2077 
2078  std::vector<unsigned int> _New_view_extent(_Base_shape->_Get_rank());
2079  std::vector<unsigned int> _New_view_offset(_Base_shape->_Get_rank());
2080  bool *_New_projection_info = new bool[_Base_shape->_Get_rank()];
2081  for (unsigned int _I = 0; _I < _Base_shape->_Get_rank(); ++_I)
2082  {
2083  _New_view_extent[_I] = _Base_shape->_Get_view_extent()[_I];
2084  _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I];
2085  _New_projection_info[_I] = _Base_shape->_Get_projection_info()[_I];
2086  }
2087 
2088  // The _Dim'th non-projected dimension needs to be found
2089  unsigned int _UnProjectedDimCount = 0;
2090  for (unsigned int _I = 0; _I < _Base_shape->_Get_rank(); ++_I)
2091  {
2092  if (_Base_shape->_Get_projection_info()[_I]) {
2093  continue;
2094  }
2095 
2096  if (_UnProjectedDimCount == _Dim) {
2097  _New_view_extent[_I] = 1;
2098  _New_view_offset[_I] += _Dim_offset;
2099  _New_projection_info[_I] = true;
2100  break;
2101  }
2102  else {
2103  _UnProjectedDimCount++;
2104  }
2105  }
2106 
2107  auto _PView_shape = _View_shape::_Create_view_shape(_Base_shape->_Get_rank(),
2108  _Base_shape->_Get_linear_offset(),
2109  _Base_shape->_Get_base_extent(),
2110  _New_view_offset.data(),
2111  _New_view_extent.data(),
2112  _New_projection_info);
2113 
2114  delete [] _New_projection_info;
2115 
2116  return _PView_shape;
2117  }
2118 
2119  static _Ret_ void* _Create_section_buffer_shape(const _Buffer_descriptor& _Descriptor,
2120  const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __CPU_ONLY
2121  {
2122  _View_shape* _Base_shape = _Get_buffer_view_shape(_Descriptor);
2123  if (_Base_shape->_Get_rank() == _Rank) {
2124  return NULL;
2125  }
2126 
2127  std::vector<unsigned int> _New_view_extent(_Base_shape->_Get_rank());
2128  std::vector<unsigned int> _New_view_offset(_Base_shape->_Get_rank());
2129  unsigned int _I = 0, _J = 0;
2130  while (_I < _Base_shape->_Get_rank())
2131  {
2132  if (_Base_shape->_Get_projection_info()[_I])
2133  {
2134  _New_view_extent[_I] = _Base_shape->_Get_view_extent()[_I];
2135  _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I];
2136  }
2137  else
2138  {
2139  // If _J is the least significant dimension, then we need to adjust the
2140  // offset and extent for the underlying buffer's element size
2141  if (_J == (_Rank - 1))
2142  {
2143  unsigned int bufElemSize = static_cast<unsigned int>(_Descriptor._Get_buffer_ptr()->_Get_master_buffer_elem_size());
2144  unsigned int elemSize = _Element_size * sizeof(int);
2145 
2146  size_t sectionLSDOriginInBytes = _Section_origin[_J];
2147  sectionLSDOriginInBytes *= elemSize;
2148 
2149  size_t sectionLSDExtentInBytes = _Section_extent[_J];
2150  sectionLSDExtentInBytes *= elemSize;
2151 
2152  // The section offset and extent must be compatible with the underlying
2153  // buffer's element size
2154  if (((sectionLSDOriginInBytes % bufElemSize) != 0) ||
2155  ((sectionLSDExtentInBytes % bufElemSize) != 0))
2156  {
2157  throw runtime_exception("The array_view section origin and/or extent is incompatible with the underlying buffer", E_FAIL);
2158  }
2159 
2160  // The extent in the least significant dimension needs to be adjusted for
2161  // difference in element size between the buffer and ourselves
2162  _ASSERTE((sectionLSDOriginInBytes / bufElemSize) <= UINT_MAX);
2163  _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I] + static_cast<unsigned int>(sectionLSDOriginInBytes / bufElemSize);
2164 
2165  _ASSERTE((sectionLSDExtentInBytes / bufElemSize) <= UINT_MAX);
2166  _New_view_extent[_I] = static_cast<unsigned int>(sectionLSDExtentInBytes / bufElemSize);
2167  }
2168  else
2169  {
2170  _New_view_extent[_I] = _Section_extent[_J];
2171  _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I] + _Section_origin[_J];
2172  }
2173 
2174  _J++;
2175  }
2176 
2177  _I++;
2178  }
2179 
2180  _ASSERTE(_J == _Rank);
2181 
2182  return _View_shape::_Create_view_shape(_Base_shape->_Get_rank(),
2183  _Base_shape->_Get_linear_offset(),
2184  _Base_shape->_Get_base_extent(),
2185  _New_view_offset.data(),
2186  _New_view_extent.data(),
2187  _Base_shape->_Get_projection_info());
2188  }
2189 
2191 
2192  void _Register_copy(const _Array_view_base &/*_Other*/) __GPU_ONLY
2193  {
2194  }
2195 
2196  void _Register(_In_ void* /*_Shape*/) __GPU_ONLY
2197  {
2198  }
2199 
2200  void _Unregister(bool /*_Throw_exception*/ = true) __GPU_ONLY
2201  {
2202  }
2203 
2204  static _Ret_ void* _Create_projection_buffer_shape(const _Buffer_descriptor& /*_Descriptor*/, int /*_Dim*/, int /*_I*/) __GPU_ONLY
2205  {
2206  return NULL;
2207  }
2208 
2209  static _Ret_ void* _Create_section_buffer_shape(const _Buffer_descriptor& /*_Descriptor*/, const Concurrency::index<_Rank>& /*_Section_origin*/, const Concurrency::extent<_Rank>& /*_Section_extent*/) __GPU_ONLY
2210  {
2211  return NULL;
2212  }
2213 };
2214 
2215 template<typename _Container>
2217 {
2218  template<class _Uty> static auto _Fn(_Uty _Val, decltype(_Val.size(), _Val.data(), 0)) -> std::true_type;
2219  template<class _Uty> static auto _Fn(_Uty _Val, ...) -> std::false_type;
2220  typedef decltype(_Fn(std::declval<_Container>(),0)) type;
2221 };
2222 
2223 } // namespace details
2224 
2225 
2236 template <typename _Value_type, int _Rank = 1> class array_view : public _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)>
2237 {
2238  typedef _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)> _Base;
2239 
2241  static_assert(0 == (sizeof(_Value_type) % sizeof(int)), "only value types whose size is a multiple of the size of an integer are allowed in array views");
2242 
2243  friend class details::_Array_view_projection_helper<_Value_type,_Rank>;
2244  friend class details::_Array_view_projection_helper<_Value_type,_Rank+1>;
2245 
2246  friend class array_view<_Value_type, _Rank>;
2247  friend class array_view<const _Value_type, _Rank>;
2248 
2249  friend class array_view<_Value_type, _Rank+1>;
2250  friend class array_view<const _Value_type, _Rank+1>;
2251 
2252  template <typename _T, int _R>
2253  friend class array;
2254 
2255  friend const _Buffer_descriptor& details::_Get_buffer_descriptor<array_view<_Value_type, _Rank>>(const array_view<_Value_type, _Rank>& _Array) __GPU;
2256 
2257 public:
2258  static const int rank = _Rank;
2259  typedef typename _Value_type value_type;
2260 
2261 
2265  ~array_view() __GPU {}
2266 
2275  : _Base(_Get_buffer_descriptor(_Src), _Src.extent)
2276  {
2277  _Initialize();
2278  }
2279 
2283  array_view(const array_view& _Other) __GPU
2284  : _Base(_Other)
2285  {
2286  _Initialize();
2287  }
2288 
2296  :_Base(_Extent)
2297  {
2298  _Initialize(_Extent.size(), true);
2299  }
2300 
2310  template <typename _Container> array_view(const Concurrency::extent<_Rank>& _Extent, _Container& _Src) __CPU_ONLY
2311  :_Base(_Src.data(),_Extent)
2312  {
2313  static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match");
2314  _Initialize(_Src.size());
2315  }
2316 
2327  array_view(const Concurrency::extent<_Rank>& _Extent, _Value_type * _Src) __GPU
2328  :_Base(_Src,_Extent)
2329  {
2330  _Initialize();
2331  }
2332 
2339  explicit array_view(int _E0) __CPU_ONLY
2340  :_Base(Concurrency::extent<1>(_E0))
2341  {
2342  static_assert(_Rank == 1, "rank must be 1");
2343  _Initialize(this->get_extent().size(), true);
2344  }
2345 
2353  template <typename _Container> explicit array_view(_Container& _Src, typename std::enable_if<details::_Is_container<_Container>::type::value,void **>::type = 0) __CPU_ONLY
2354  :_Base(_Src.data(), Concurrency::extent<1>(static_cast<int>(_Src.size())))
2355  {
2356  if (_Src.size() > INT_MAX) {
2357  throw runtime_exception("Invalid _Src container argument - _Src size is greater than INT_MAX", E_INVALIDARG);
2358  }
2359  static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match");
2360  static_assert(_Rank == 1, "rank must be 1");
2361  _Initialize(_Src.size());
2362  }
2363 
2373  template <typename _Container> explicit array_view(int _E0, _Container& _Src) __CPU_ONLY
2374  :_Base(_Src.data(), Concurrency::extent<1>(_E0))
2375  {
2376  static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match");
2377  static_assert(_Rank == 1, "rank must be 1");
2378  _Initialize(_Src.size());
2379  }
2380 
2390  explicit array_view(int _E0, int _E1) __CPU_ONLY
2391  :_Base(Concurrency::extent<2>(_E0,_E1))
2392  {
2393  static_assert(_Rank == 2, "rank must be 2");
2394  _Initialize(this->get_extent().size(), true);
2395  }
2396 
2409  template <typename _Container> explicit array_view(int _E0, int _E1, _Container& _Src) __CPU_ONLY
2410  :_Base(_Src.data(), Concurrency::extent<2>(_E0,_E1))
2411  {
2412  static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match");
2413  static_assert(_Rank == 2, "rank must be 2");
2414  _Initialize(_Src.size());
2415  }
2416 
2429  explicit array_view(int _E0, int _E1, int _E2) __CPU_ONLY
2430  :_Base(Concurrency::extent<3>(_E0,_E1,_E2))
2431  {
2432  static_assert(_Rank == 3, "rank must be 3");
2433  _Initialize(this->get_extent().size(), true);
2434  }
2435 
2451  template <typename _Container> explicit array_view(int _E0, int _E1, int _E2, _Container& _Src) __CPU_ONLY
2452  :_Base(_Src.data(), Concurrency::extent<3>(_E0,_E1,_E2))
2453  {
2454  static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match");
2455  static_assert(_Rank == 3, "rank must be 3");
2456  _Initialize(_Src.size());
2457  }
2458 
2469  explicit array_view(int _E0, _In_ _Value_type * _Src) __GPU
2470  :_Base(_Src, Concurrency::extent<1>(_E0))
2471  {
2472  static_assert(_Rank == 1, "rank must be 1");
2473  _Initialize();
2474  }
2475 
2482  template <int _Size> explicit array_view(_In_ _Value_type (&_Src) [_Size]) __GPU
2483  :_Base(_Src, Concurrency::extent<1>(_Size))
2484  {
2485  static_assert(_Rank == 1, "rank must be 1");
2486  _Initialize();
2487  }
2488 
2502  explicit array_view(int _E0, int _E1, _In_ _Value_type * _Src) __GPU
2503  :_Base(_Src, Concurrency::extent<2>(_E0,_E1))
2504  {
2505  static_assert(_Rank == 2, "rank must be 2");
2506  _Initialize();
2507  }
2508 
2525  explicit array_view(int _E0, int _E1, int _E2, _In_ _Value_type * _Src) __GPU
2526  :_Base(_Src, Concurrency::extent<3>(_E0,_E1,_E2))
2527  {
2528  static_assert(_Rank == 3, "rank must be 3");
2529  _Initialize();
2530  }
2531 
2535  array_view& operator=(const array_view& _Other) __GPU
2536  {
2537  _Base::operator=(_Other);
2538  return *this;
2539  }
2540 
2545  {
2546  copy(*this,_Dest);
2547  }
2548 
2553  {
2554  copy(*this,_Dest);
2555  }
2556 
2568  {
2570  }
2571 
2585  _Value_type& get_ref(const index<_Rank>& _Index) const __GPU
2586  {
2587  void *_Ptr = _Access(_Index);
2588  return *reinterpret_cast<value_type*>(_Ptr);
2589  }
2590 
2600  _Value_type& operator[] (const index<_Rank>& _Index) const __GPU
2601  {
2602  return this->operator()(_Index);
2603  }
2604 
2614  _Value_type& operator() (const index<_Rank>& _Index) const __GPU
2615  {
2616  void * _Ptr = _Access(_Read_write_access, _Index);
2617  return *reinterpret_cast<_Value_type*>(_Ptr);
2618  }
2619 
2631  {
2633  }
2634 
2647  _Value_type& operator() (int _I0, int _I1) const __GPU
2648  {
2649  static_assert(_Rank == 2, "value_type& array_view::operator()(int,int) is only permissible on array_view<T, 2>");
2650  return this->operator()(index<2>(_I0,_I1));
2651  }
2652 
2668  _Value_type& operator() (int _I0, int _I1, int _I2) const __GPU
2669  {
2670  static_assert(_Rank == 3, "value_type& array_view::operator()(int,int,int) is only permissible on array_view<T, 3>");
2671  return this->operator()(index<3>(_I0,_I1,_I2));
2672  }
2673 
2686  array_view section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU
2687  {
2688  return _Convert<_Value_type>(_Section(_Section_origin, _Section_extent));
2689  }
2690 
2702  {
2703  return section(_Idx, this->extent - _Idx);
2704  }
2705 
2717  {
2718  return section(Concurrency::index<_Rank>(), _Ext);
2719  }
2720 
2734  array_view section(int _I0, int _E0) const __GPU
2735  {
2736  static_assert(_Rank == 1, "rank must be 1");
2737  return section(Concurrency::index<1>(_I0), Concurrency::extent<1>(_E0));
2738  }
2739 
2759  array_view section(int _I0, int _I1, int _E0, int _E1) const __GPU
2760  {
2761  static_assert(_Rank == 2, "rank must be 2");
2762  return section(Concurrency::index<2>(_I0,_I1), Concurrency::extent<2>(_E0,_E1));
2763  }
2764 
2790  array_view section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU
2791  {
2792  static_assert(_Rank == 3, "rank must be 3");
2793  return section(Concurrency::index<3>(_I0,_I1,_I2), Concurrency::extent<3>(_E0,_E1,_E2));
2794  }
2795 
2804  template <typename _Value_type2> array_view<_Value_type2, _Rank> reinterpret_as() const __GPU
2805  {
2806  return _Convert<_Value_type2>(this->template _Reinterpret_as<sizeof(_Value_type2)/sizeof(int)>());
2807  }
2808 
2818  template <int _New_rank> array_view<_Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) const __GPU
2819  {
2820  return _Convert<_Value_type>(_View_as(_View_extent));
2821  }
2822 
2826  _Ret_ _Value_type* data() const __GPU
2827  {
2828  static_assert(_Rank == 1, "array_view::data() is only permissible on array_view<T, 1>");
2829  return &this->operator[](index<_Rank>());
2830  }
2831 
2836  void refresh() const __CPU_ONLY
2837  {
2838  // If the array_view corresponds to a ubiquitous buffer with no data source,
2839  // then refresh is a no-op
2840  if (!this->_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) {
2841  return;
2842  }
2843 
2844  _Buffer_ptr _PBuf;
2845  _Get_access_async(this->_M_buffer_descriptor._Get_view_key(), this->_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Write_access, _PBuf)._Get();
2846  }
2847 
2862  {
2863  auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(this->_M_buffer_descriptor);
2864 
2865  _Buffer_ptr _PBuf;
2866  _Event _Ev;
2867 
2868  if (_Access_type != access_type_none) {
2869  _Ev = _Get_access_async(this->_M_buffer_descriptor._Get_view_key(), _Accl_view, _Get_synchronize_access_mode(_Access_type), _PBuf);
2870  }
2871 
2872  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
2873  }
2874 
2886  {
2887  auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(this->_M_buffer_descriptor);
2888 
2889  _Buffer_ptr _PBuf;
2890  _Event _Ev;
2891 
2892  // If the array_view corresponds to a ubiquitous buffer with no data source, then synchronize is a no-op
2893  if ((_Access_type != access_type_none) && this->_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source())
2894  {
2895  _Ev = _Get_access_async(this->_M_buffer_descriptor._Get_view_key(),
2896  this->_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(),
2897  _Get_synchronize_access_mode(_Access_type),
2898  _PBuf);
2899  }
2900 
2901  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
2902  }
2903 
2914  void synchronize_to(const accelerator_view& _Accl_view, access_type _Access_type = access_type_read) const __CPU_ONLY
2915  {
2916  auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(this->_M_buffer_descriptor);
2917 
2918  _Buffer_ptr _PBuf;
2919 
2920  if (_Access_type != access_type_none) {
2921  _Get_access_async(this->_M_buffer_descriptor._Get_view_key(), _Accl_view, _Get_synchronize_access_mode(_Access_type), _PBuf)._Get();
2922  }
2923 
2925  }
2926 
2935  {
2936  auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(this->_M_buffer_descriptor);
2937 
2938  _Buffer_ptr _PBuf;
2939 
2940  // If the array_view corresponds to a ubiquitous buffer with no data source, then synchronize is a no-op
2941  if ((_Access_type != access_type_none) && this->_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source())
2942  {
2943  _Get_access_async(this->_M_buffer_descriptor._Get_view_key(),
2944  this->_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(),
2945  _Get_synchronize_access_mode(_Access_type),
2946  _PBuf)._Get();
2947  }
2948 
2950  }
2951 
2960  {
2961  this->_M_buffer_descriptor._Get_buffer_ptr()->_Discard(this->_M_buffer_descriptor._Get_view_key());
2962  }
2963 
2969  {
2970  if (this->_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) {
2971  return this->_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view();
2972  }
2973  else {
2974  throw runtime_exception("Cannot query source accelerator_view for an array_view without a data source.", E_INVALIDARG);
2975  }
2976  }
2977 
2978  __declspec(property(get=get_source_accelerator_view)) accelerator_view source_accelerator_view;
2979 
2980 private:
2981  template <typename _T, int _R>
2982  static array_view<_T,_R> _Convert(const _Array_view_base<_R,sizeof(_T)/sizeof(int)>& _Other) __GPU
2983  {
2984  static_assert(sizeof(array_view<_T,_R>) == sizeof(_Array_view_base<_R,sizeof(_T)/sizeof(int)>), "ASSERT FAILURE: implementation relies on binary conversion between the two");
2985  return (*reinterpret_cast<const array_view<_T,_R>*>(&_Other));
2986  }
2987 
2988  void _Project0(int _I, array_view<_Value_type, _Rank-1> &_Projected_view) const __GPU
2989  {
2990  _Base::_Project0(_I, _Projected_view);
2991  _Projected_view._Initialize();
2992  }
2993 
2994  array_view() __GPU {}
2995 
2996  array_view(const array_view& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
2997  :_Base(_Other, _Section_origin, _Section_extent)
2998  {
2999  _Initialize();
3000  }
3001 
3002  array_view(_Buffer_descriptor& _Src_buffer, const Concurrency::extent<_Rank>& _Extent) __GPU
3003  :_Base(_Src_buffer,_Extent)
3004  {
3005  _Initialize();
3006  }
3007 
3008  void _Initialize() __GPU
3009  {
3010  // Set the type access mode
3011  this->_M_buffer_descriptor._M_type_access_mode = _Read_write_access;
3012  }
3013 
3014  void _Initialize(size_t _Src_data_size, bool _Discard_data = false) __CPU_ONLY
3015  {
3016  // Ensure that the _Src_data_size is at least as big as the size
3017  // of the array_view
3018  if (_Src_data_size < this->extent.size()) {
3019  throw runtime_exception("Invalid _Src container argument - _Src size is less than the size of the array_view.", E_INVALIDARG);
3020  }
3021 
3022  _Initialize();
3023 
3024  if (_Discard_data) {
3025  discard_data();
3026  }
3027  }
3028 
3029 }; // class array_view<T,R>
3030 
3031 // array_view<const T,R>
3032 template <typename _Value_type, int _Rank>
3033 class array_view<const _Value_type, _Rank> : public _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)>
3034 {
3036  static_assert(0 == (sizeof(_Value_type) % sizeof(int)), "only value types whose size is a multiple of the size of an integer are allowed in array views");
3037 
3038  typedef _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)> _Base;
3039 
3040  friend class details::_Const_array_view_projection_helper<_Value_type,_Rank>;
3041  friend class details::_Const_array_view_projection_helper<_Value_type,_Rank+1>;
3042 
3043  friend class array_view<_Value_type, _Rank>;
3044  friend class array_view<const _Value_type, _Rank>;
3045 
3046  friend class array_view<_Value_type, _Rank+1>;
3047  friend class array_view<const _Value_type, _Rank+1>;
3048 
3049  friend const _Buffer_descriptor& details::_Get_buffer_descriptor<array_view<const _Value_type, _Rank>>(const array_view<const _Value_type, _Rank>& _Array) __GPU;
3050 
3051 public:
3052  static const int rank = _Rank;
3053  typedef typename const _Value_type value_type;
3054 
3058  ~array_view() __GPU {}
3059 
3068  :_Base(_Get_buffer_descriptor(_Src), _Src.extent)
3069  {
3070  _Initialize();
3071  }
3072 
3077  :_Base(_Src)
3078  {
3079  _Initialize();
3080  }
3081 
3086  :_Base(_Src)
3087  {
3088  }
3089 
3099  template <typename _Container> array_view(const Concurrency::extent<_Rank>& _Extent, const _Container& _Src) __CPU_ONLY
3100  :_Base(_Src.data(),_Extent)
3101  {
3102  static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src.data())>::type>::type, _Value_type>::value, "container element type and array view element type must match");
3103  _Initialize(_Src.size());
3104  }
3105 
3116  template <typename _Container> explicit array_view(const _Container& _Src, typename std::enable_if<details::_Is_container<_Container>::type::value,void **>::type = 0) __CPU_ONLY
3117  :_Base(_Src.data(), Concurrency::extent<1>(static_cast<int>(_Src.size())))
3118  {
3119  if (_Src.size() > INT_MAX) {
3120  throw runtime_exception("Invalid _Src container argument - _Src size is greater than INT_MAX", E_INVALIDARG);
3121  }
3122  static_assert( std::is_same<decltype(_Src.data()), const _Value_type*>::value, "container element type and array view element type must match");
3123  static_assert(_Rank == 1, "rank must be 1");
3124  _Initialize(_Src.size());
3125  }
3126 
3136  template <typename _Container> array_view(const Concurrency::extent<_Rank>& _Extent, _Container& _Src) __CPU_ONLY
3137  :_Base(_Src.data(),_Extent)
3138  {
3139  static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src.data())>::type>::type, _Value_type>::value, "container element type and array view element type must match");
3140  _Initialize(_Src.size());
3141  }
3142 
3153  array_view(const Concurrency::extent<_Rank>& _Extent, const _Value_type * _Src) __GPU
3154  :_Base(_Src,_Extent)
3155  {
3156  _Initialize();
3157  }
3158 
3169  array_view(const Concurrency::extent<_Rank>& _Extent, _In_ _Value_type * _Src) __GPU
3170  :_Base(_Src,_Extent)
3171  {
3172  _Initialize();
3173  }
3174 
3184  template <typename _Container> array_view(int _E0, const _Container& _Src) __CPU_ONLY
3185  :_Base(_Src.data(), Concurrency::extent<1>(_E0))
3186  {
3187  static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src.data())>::type>::type, _Value_type>::value, "container element type and array view element type must match");
3188  static_assert(_Rank == 1, "rank must be 1");
3189  _Initialize(_Src.size());
3190  }
3191 
3199  template <int _Size> explicit array_view(const _In_ _Value_type (&_Src) [_Size]) __GPU
3200  :_Base(_Src, Concurrency::extent<1>(_Size))
3201  {
3202  static_assert(_Rank == 1, "rank must be 1");
3203  _Initialize();
3204  }
3205 
3218  template <typename _Container> array_view(int _E0, int _E1, const _Container& _Src) __CPU_ONLY
3219  :_Base(_Src.data(), Concurrency::extent<2>(_E0,_E1))
3220  {
3221  static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src.data())>::type>::type, _Value_type>::value, "container element type and array view element type must match");
3222  static_assert(_Rank == 2, "rank must be 2");
3223  _Initialize(_Src.size());
3224  }
3225 
3241  template <typename _Container> array_view(int _E0, int _E1, int _E2, const _Container& _Src) __CPU_ONLY
3242  :_Base(_Src.data(), Concurrency::extent<3>(_E0,_E1,_E2))
3243  {
3244  static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src.data())>::type>::type, _Value_type>::value, "container element type and array view element type must match");
3245  static_assert(_Rank == 3, "rank must be 3");
3246  _Initialize(_Src.size());
3247  }
3248 
3259  array_view(int _E0, const _Value_type * _Src) __GPU
3260  :_Base(_Src, Concurrency::extent<1>(_E0))
3261  {
3262  static_assert(_Rank == 1, "rank must be 1");
3263  _Initialize();
3264  }
3265 
3279  array_view(int _E0, int _E1, const _Value_type * _Src) __GPU
3280  :_Base(_Src, Concurrency::extent<2>(_E0,_E1))
3281  {
3282  static_assert(_Rank == 2, "rank must be 2");
3283  _Initialize();
3284  }
3285 
3302  array_view(int _E0, int _E1, int _E2, const _Value_type * _Src) __GPU
3303  :_Base(_Src, Concurrency::extent<3>(_E0,_E1,_E2))
3304  {
3305  static_assert(_Rank == 3, "rank must be 3");
3306  _Initialize();
3307  }
3308 
3319  array_view(int _E0, _In_ _Value_type * _Src) __GPU
3320  :_Base(_Src, Concurrency::extent<1>(_E0))
3321  {
3322  static_assert(_Rank == 1, "rank must be 1");
3323  _Initialize();
3324  }
3325 
3339  array_view(int _E0, int _E1, _In_ _Value_type * _Src) __GPU
3340  :_Base(_Src, Concurrency::extent<2>(_E0,_E1))
3341  {
3342  static_assert(_Rank == 2, "rank must be 2");
3343  _Initialize();
3344  }
3345 
3362  array_view(int _E0, int _E1, int _E2, _In_ _Value_type * _Src) __GPU
3363  :_Base(_Src, Concurrency::extent<3>(_E0,_E1,_E2))
3364  {
3365  static_assert(_Rank == 3, "rank must be 3");
3366  _Initialize();
3367  }
3368 
3372  array_view& operator=(const array_view& _Other) __GPU
3373  {
3374  _Base::operator=(_Other);
3375  return *this;
3376  }
3377 
3382  {
3383  _Base::operator=(_Other);
3384  return *this;
3385  }
3386 
3391  {
3392  copy(*this,_Dest);
3393  }
3394 
3399  {
3400  copy(*this,_Dest);
3401  }
3402 
3414  {
3416  }
3417 
3431  const _Value_type& get_ref(const index<_Rank>& _Index) const __GPU
3432  {
3433  void *_Ptr = _Access(_Index);
3434  return *reinterpret_cast<value_type*>(_Ptr);
3435  }
3436 
3446  const _Value_type& operator[] (const index<_Rank>& _Index) const __GPU
3447  {
3448  return this->operator()(_Index);
3449  }
3450 
3460  const _Value_type& operator() (const index<_Rank>& _Index) const __GPU
3461  {
3462  void * _Ptr = _Access(_Read_access, _Index);
3463  return *reinterpret_cast<value_type*>(_Ptr);
3464  }
3465 
3477  {
3479  }
3480 
3493  const _Value_type& operator() (int _I0, int _I1) const __GPU
3494  {
3495  static_assert(_Rank == 2, "value_type& array_view::operator()(int,int) is only permissible on array_view<T, 2>");
3496  return this->operator()(index<2>(_I0,_I1));
3497  }
3498 
3514  const _Value_type& operator() (int _I0, int _I1, int _I2) const __GPU
3515  {
3516  static_assert(_Rank == 3, "value_type& array_view::operator()(int,int,int) is only permissible on array_view<T, 3>");
3517  return this->operator()(index<3>(_I0,_I1,_I2));
3518  }
3519 
3532  array_view section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU
3533  {
3534  return _Convert<_Value_type>(_Section(_Section_origin, _Section_extent));
3535  }
3536 
3548  {
3549  return section(Concurrency::index<_Rank>(), _Ext);
3550  }
3551 
3563  {
3564  return section(_Idx, this->extent - _Idx);
3565  }
3566 
3580  array_view section(int _I0, int _E0) const __GPU
3581  {
3582  static_assert(_Rank == 1, "rank must be 1");
3583  return section(Concurrency::index<1>(_I0), Concurrency::extent<1>(_E0));
3584  }
3585 
3605  array_view section(int _I0, int _I1, int _E0, int _E1) const __GPU
3606  {
3607  static_assert(_Rank == 2, "rank must be 2");
3608  return section(Concurrency::index<2>(_I0,_I1), Concurrency::extent<2>(_E0,_E1));
3609  }
3610 
3636  array_view section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU
3637  {
3638  static_assert(_Rank == 3, "rank must be 3");
3639  return section(Concurrency::index<3>(_I0,_I1,_I2), Concurrency::extent<3>(_E0,_E1,_E2));
3640  }
3641 
3650  template <typename _Value_type2> array_view<const _Value_type2, _Rank> reinterpret_as() const __GPU
3651  {
3652  return _Convert<_Value_type2>(this->template _Reinterpret_as<sizeof(_Value_type2)/sizeof(int)>());
3653  }
3654 
3664  template <int _New_rank> array_view<const _Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) const __GPU
3665  {
3666  return _Convert<_Value_type>(_View_as(_View_extent));
3667  }
3668 
3672  const _Value_type* data() const __GPU
3673  {
3674  static_assert(_Rank == 1, "array_view::data() is only permissible on array_view<T, 1>");
3675  return &this->operator[](index<_Rank>());
3676  }
3677 
3682  void refresh() const __CPU_ONLY
3683  {
3684  _Buffer_ptr _PBuf;
3685  _Get_access_async(this->_M_buffer_descriptor._Get_view_key(), this->_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Write_access, _PBuf)._Get();
3686  }
3687 
3698  {
3699  auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(this->_M_buffer_descriptor);
3700 
3701  _Buffer_ptr _PBuf;
3702  _Event _Ev;
3703 
3704  _Ev = _Get_access_async(this->_M_buffer_descriptor._Get_view_key(), _Accl_view, _Read_access, _PBuf);
3705 
3706  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
3707  }
3708 
3716  {
3717  auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(this->_M_buffer_descriptor);
3718 
3719  _Buffer_ptr _PBuf;
3720  _Event _Ev;
3721 
3722  // If the array_view corresponds to a ubiquitous buffer with no data source,
3723  // then synchronize is a no-op
3724  if (this->_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) {
3725  _Ev = _Get_access_async(this->_M_buffer_descriptor._Get_view_key(), this->_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Read_access, _PBuf);
3726  }
3727 
3728  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
3729  }
3730 
3737  void synchronize_to(const accelerator_view& _Accl_view) const __CPU_ONLY
3738  {
3739  auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(this->_M_buffer_descriptor);
3740 
3741  _Buffer_ptr _PBuf;
3742 
3743  _Get_access_async(this->_M_buffer_descriptor._Get_view_key(), _Accl_view, _Read_access, _PBuf)._Get();
3744 
3746  }
3747 
3752  {
3753  auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(this->_M_buffer_descriptor);
3754 
3755  _Buffer_ptr _PBuf;
3756 
3757  // If the array_view corresponds to a ubiquitous buffer with no data source,
3758  // then synchronize is a no-op
3759  if (this->_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) {
3760  _Get_access_async(this->_M_buffer_descriptor._Get_view_key(), this->_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Read_access, _PBuf)._Get();
3761  }
3762 
3764  }
3765 
3771  {
3772  if (this->_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) {
3773  return this->_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view();
3774  }
3775  else {
3776  throw runtime_exception("Cannot query source accelerator_view for an array_view without a data source.", E_INVALIDARG);
3777  }
3778  }
3779 
3780  __declspec(property(get=get_source_accelerator_view)) accelerator_view source_accelerator_view;
3781 
3782 private:
3783  template <typename _T, int _R>
3784  static array_view<const _T,_R> _Convert(const _Array_view_base<_R,sizeof(_T)/sizeof(int)>& _Other) __GPU
3785  {
3786  static_assert(sizeof(array_view<const _T,_R>) == sizeof(_Array_view_base<_R,sizeof(_T)/sizeof(int)>), "ASSERT FAILURE: implementation relies on binary conversion between the two");
3787  return (*reinterpret_cast<const array_view<const _T,_R>*>(&_Other));
3788  }
3789 
3790  void _Project0(int _I, array_view<const _Value_type, _Rank-1> &_Projected_view) const __GPU
3791  {
3792  _Base::_Project0(_I, _Projected_view);
3793  _Projected_view._Initialize();
3794  }
3795 
3796  array_view() __GPU {}
3797 
3798  array_view(const array_view& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
3799  :
3800  _Base(_Other, _Section_origin, _Section_extent)
3801  {
3802  _Initialize();
3803  }
3804 
3805  void _Initialize() __GPU
3806  {
3807  // Set the type access mode
3808  this->_M_buffer_descriptor._M_type_access_mode = _Read_access;
3809  }
3810 
3811  void _Initialize(size_t _Src_data_size) __CPU_ONLY
3812  {
3813  // Ensure that the _Src_data_size is at least as big as the size
3814  // of the array_view
3815  if (_Src_data_size < this->extent.size()) {
3816  throw runtime_exception("Invalid _Src container argument - _Src size is less than the size of the array_view.", E_INVALIDARG);
3817  }
3818 
3819  _Initialize();
3820  }
3821 
3822 }; // class array_view<const T,R>
3823 
3824 // Forward declarations for copy functions
3825 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest);
3826 template <typename _Value_type, int _Rank> void copy(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest);
3827 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest);
3828 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest);
3829 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest);
3830 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest);
3831 template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter);
3832 template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter);
3833 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest);
3834 template <typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest);
3835 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest);
3836 template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest);
3837 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest);
3838 template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest);
3839 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest);
3840 template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest);
3841 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest);
3842 template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest);
3843 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest);
3844 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest);
3845 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest);
3846 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest);
3847 template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter);
3848 template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter);
3849 
3850 namespace direct3d
3851 {
3852  template<typename _Value_type, int _Rank>
3854 }
3855 
3865 template <typename _Value_type, int _Rank = 1> class array
3866 {
3867  // internal storage abstraction
3869  typedef _Array_flatten_helper<_Rank, typename Concurrency::extent<_Rank>::value_type, typename Concurrency::index<_Rank>::value_type> _Flatten_helper;
3870 
3871  _CPP_AMP_VERIFY_RANK(_Rank, array);
3872  static_assert(!std::is_const<_Value_type>::value, "array<const _Value_type> is not supported");
3873  static_assert(0 == (sizeof(_Value_type) % sizeof(int)), "only value types whose size is a multiple of the size of an integer are allowed in array");
3874 
3875  // Friends
3876  template<typename _Value_type, int _Rank>
3878  friend const _Buffer_descriptor& details::_Get_buffer_descriptor<array<_Value_type,_Rank>>(const array<_Value_type,_Rank>& _Array) __GPU;
3879  friend _Ret_ _Ubiquitous_buffer* details::_Get_buffer<array<_Value_type,_Rank>>(const array<_Value_type,_Rank>& _Array) __CPU_ONLY;
3880  friend _Event details::_Get_access_async<array<_Value_type,_Rank>>(const array<_Value_type,_Rank>& _Array, _Access_mode _Mode, _Buffer_ptr &_Buf_ptr) __CPU_ONLY;
3881 
3882  public:
3883  static const int rank = _Rank;
3884  typedef typename _Value_type value_type;
3885 
3892  explicit array(const Concurrency::extent<_Rank> & _Extent) __CPU_ONLY
3893  : _M_extent(_Extent)
3894  {
3895  _Initialize(details::_Select_default_accelerator().default_view, access_type_auto);
3896  }
3897 
3904  explicit array(int _E0) __CPU_ONLY
3905  : _M_extent(Concurrency::extent<_Rank>(_E0))
3906  {
3907  static_assert(_Rank == 1, "array(int) is only permissible on array<T, 1>");
3908  _Initialize(details::_Select_default_accelerator().default_view, access_type_auto);
3909  }
3910 
3920  explicit array(int _E0, int _E1) __CPU_ONLY
3921  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
3922  {
3923  static_assert(_Rank == 2, "array(int, int) is only permissible on array<T, 2>");
3924  _Initialize(details::_Select_default_accelerator().default_view, access_type_auto);
3925  }
3926 
3939  explicit array(int _E0, int _E1, int _E2) __CPU_ONLY
3940  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
3941  {
3942  static_assert(_Rank == 3, "array(int, int, int) is only permissible on array<T, 3>");
3943  _Initialize(details::_Select_default_accelerator().default_view, access_type_auto);
3944  }
3945 
3963  : _M_extent(_Extent)
3964  {
3965  _Initialize(_Av, _Cpu_access_type);
3966  }
3967 
3984  array(int _E0, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
3985  : _M_extent(Concurrency::extent<_Rank>(_E0))
3986  {
3987  static_assert(_Rank == 1, "array(int, accelerator_view) is only permissible on array<T, 1>");
3988  _Initialize(_Av, _Cpu_access_type);
3989  }
3990 
4010  array(int _E0, int _E1, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
4011  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4012  {
4013  static_assert(_Rank == 2, "array(int, int, accelerator_view) is only permissible on array<T, 2>");
4014  _Initialize(_Av, _Cpu_access_type);
4015  }
4016 
4039  array(int _E0, int _E1, int _E2, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
4040  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4041  {
4042  static_assert(_Rank == 3, "array(int, int, int, accelerator_view) is only permissible on array<T, 3>");
4043  _Initialize(_Av, _Cpu_access_type);
4044  }
4045 
4059  : _M_extent(_Extent)
4060  {
4061  _Initialize(_Av, _Associated_Av);
4062  }
4063 
4076  array(int _E0, accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4077  : _M_extent(Concurrency::extent<_Rank>(_E0))
4078  {
4079  static_assert(_Rank == 1, "array(int, accelerator_view, accelerator_view) is only permissible on array<T, 1>");
4080  _Initialize(_Av, _Associated_Av);
4081  }
4082 
4098  array(int _E0, int _E1, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4099  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4100  {
4101  static_assert(_Rank == 2, "array(int, int, accelerator_view, accelerator_view) is only permissible on array<T, 2>");
4102  _Initialize(_Av, _Associated_Av);
4103  }
4104 
4123  array(int _E0, int _E1, int _E2, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4124  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4125  {
4126  static_assert(_Rank == 3, "array(int, int, int, accelerator_view, accelerator_view) is only permissible on array<T, 3>");
4127  _Initialize(_Av, _Associated_Av);
4128  }
4129 
4142  template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
4143  : _M_extent(_Extent)
4144  {
4145  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4146  }
4147 
4158  template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first) __CPU_ONLY
4159  : _M_extent(_Extent)
4160  {
4161  _InputIterator _Src_last = _Src_first;
4162  std::advance(_Src_last, this->extent.size());
4163 
4164  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4165  }
4166 
4179  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
4180  : _M_extent(Concurrency::extent<_Rank>(_E0))
4181  {
4182  static_assert(_Rank == 1, "array(int, iterator, iterator) is only permissible on array<T, 1>");
4183  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4184  }
4185 
4196  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first) __CPU_ONLY
4197  : _M_extent(Concurrency::extent<_Rank>(_E0))
4198  {
4199  static_assert(_Rank == 1, "array(int, iterator) is only permissible on array<T, 1>");
4200 
4201  _InputIterator _Src_last = _Src_first;
4202  std::advance(_Src_last, this->extent.size());
4203 
4204  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4205  }
4206 
4222  template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
4223  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4224  {
4225  static_assert(_Rank == 2, "array(int, int, iterator, iterator) is only permissible on array<T, 2>");
4226  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4227  }
4228 
4242  template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first) __CPU_ONLY
4243  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4244  {
4245  static_assert(_Rank == 2, "array(int, int, iterator) is only permissible on array<T, 2>");
4246 
4247  _InputIterator _Src_last = _Src_first;
4248  std::advance(_Src_last, this->extent.size());
4249 
4250  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4251  }
4252 
4269  template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
4270  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4271  {
4272  static_assert(_Rank == 3, "array(int, int, int, iterator, iterator) is only permissible on array<T, 3>");
4273  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4274  }
4275 
4292  template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first) __CPU_ONLY
4293  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4294  {
4295  static_assert(_Rank == 3, "array(int, int, int, iterator) is only permissible on array<T, 3>");
4296 
4297  _InputIterator _Src_last = _Src_first;
4298  std::advance(_Src_last, this->extent.size());
4299 
4300  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4301  }
4302 
4325  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) __CPU_ONLY
4326  : _M_extent(_Extent)
4327  {
4328  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4329  }
4330 
4351  template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
4352  : _M_extent(_Extent)
4353  {
4354  _InputIterator _Src_last = _Src_first;
4355  std::advance(_Src_last, this->extent.size());
4356 
4357  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4358  }
4359 
4382  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
4383  : _M_extent(Concurrency::extent<_Rank>(_E0))
4384  {
4385  static_assert(_Rank == 1, "array(int, iterator, iterator) is only permissible on array<T, 1>");
4386  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4387  }
4388 
4409  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
4410  : _M_extent(Concurrency::extent<_Rank>(_E0))
4411  {
4412  static_assert(_Rank == 1, "array(int, iterator) is only permissible on array<T, 1>");
4413 
4414  _InputIterator _Src_last = _Src_first;
4415  std::advance(_Src_last, this->extent.size());
4416 
4417  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4418  }
4419 
4445  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) __CPU_ONLY
4446  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4447  {
4448  static_assert(_Rank == 2, "array(int, int, iterator, iterator) is only permissible on array<T, 2>");
4449  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4450  }
4451 
4475  template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
4476  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4477  {
4478  static_assert(_Rank == 2, "array(int, int, iterator) is only permissible on array<T, 2>");
4479 
4480  _InputIterator _Src_last = _Src_first;
4481  std::advance(_Src_last, this->extent.size());
4482 
4483  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4484  }
4485 
4514  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) __CPU_ONLY
4515  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4516  {
4517  static_assert(_Rank == 3, "array(int, int, int, iterator, iterator) is only permissible on array<T, 3>");
4518  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4519  }
4520 
4547  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) __CPU_ONLY
4548  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4549  {
4550  static_assert(_Rank == 3, "array(int, int, int, iterator) is only permissible on array<T, 3>");
4551 
4552  _InputIterator _Src_last = _Src_first;
4553  std::advance(_Src_last, this->extent.size());
4554 
4555  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4556  }
4557 
4576  template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4577  : _M_extent(_Extent)
4578  {
4579  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4580  }
4581 
4598  template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4599  : _M_extent(_Extent)
4600  {
4601  _InputIterator _Src_last = _Src_first;
4602  std::advance(_Src_last, this->extent.size());
4603 
4604  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4605  }
4606 
4625  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4626  : _M_extent(Concurrency::extent<_Rank>(_E0))
4627  {
4628  static_assert(_Rank == 1, "array(int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 1>");
4629  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4630  }
4631 
4648  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av)
4649  : _M_extent(Concurrency::extent<_Rank>(_E0))
4650  {
4651  static_assert(_Rank == 1, "array(int, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 1>");
4652 
4653  _InputIterator _Src_last = _Src_first;
4654  std::advance(_Src_last, this->extent.size());
4655 
4656  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4657  }
4658 
4680  template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4681  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4682  {
4683  static_assert(_Rank == 2, "array(int, int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 2>");
4684  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4685  }
4686 
4706  template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4707  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4708  {
4709  static_assert(_Rank == 2, "array(int, int, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 2>");
4710 
4711  _InputIterator _Src_last = _Src_first;
4712  std::advance(_Src_last, this->extent.size());
4713 
4714  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4715  }
4716 
4741  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) __CPU_ONLY
4742  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4743  {
4744  static_assert(_Rank == 3, "array(int, int, int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 3>");
4745  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4746  }
4747 
4770  template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4771  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4772  {
4773  static_assert(_Rank == 3, "array(int, int, int, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 3>");
4774 
4775  _InputIterator _Src_last = _Src_first;
4776  std::advance(_Src_last, this->extent.size());
4777 
4778  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4779  }
4780 
4787  explicit array(const array_view<const _Value_type,_Rank>& _Src) __CPU_ONLY
4788  :_M_extent(_Src.extent)
4789  {
4790  _Initialize(details::_Select_default_accelerator().default_view, access_type_auto);
4791  Concurrency::copy(_Src,*this);
4792  }
4793 
4811  :_M_extent(_Src.extent)
4812  {
4813  _Initialize(_Av, _Cpu_access_type);
4814  Concurrency::copy(_Src,*this);
4815  }
4816 
4830  :_M_extent(_Src.extent)
4831  {
4832  _Initialize(_Av, _Associated_Av);
4833  Concurrency::copy(_Src,*this);
4834  }
4835 
4839  array(const array& _Other) __CPU_ONLY
4840  : _M_extent(_Other._M_extent)
4841  {
4842  _Initialize(_Other.accelerator_view, _Other.associated_accelerator_view);
4843  Concurrency::copy(_Other, *this);
4844  }
4845 
4849  array(array && _Other) __CPU_ONLY
4850  : _M_extent(_Other._M_extent), _M_multiplier(_Other._M_multiplier)
4851  , _M_buffer_descriptor(_Other._M_buffer_descriptor)
4852  {
4853  // Register this
4854  this->_Register_copy(_Other);
4855 
4856  // Release the _Other array
4857  _Other._Unregister();
4858  _Other._M_buffer_descriptor._M_data_ptr = NULL;
4859  _Other._M_buffer_descriptor._Set_buffer_ptr(NULL);
4860  }
4861 
4865  array & operator= (const array & _Other) __CPU_ONLY
4866  {
4867  if (this != &_Other)
4868  {
4869  // First unregister myself from the current buffer
4870  _Unregister();
4871 
4872  _M_extent = _Other._M_extent;
4873  _Initialize(_Other.accelerator_view, _Other.associated_accelerator_view);
4874  Concurrency::copy(_Other, *this);
4875  }
4876  return *this;
4877  }
4878 
4882  array & operator= (array && _Other) __CPU_ONLY
4883  {
4884  if (this != &_Other)
4885  {
4886  // First unregister myself from the current buffer
4887  _Unregister();
4888 
4889  _M_extent = _Other._M_extent;
4890  _M_multiplier = _Other._M_multiplier;
4891  _M_buffer_descriptor = _Other._M_buffer_descriptor;
4892  this->_Register_copy(_Other);
4893 
4894  // Release the _Other array
4895  _Other._Unregister();
4896  _Other._M_buffer_descriptor._M_data_ptr = NULL;
4897  _Other._M_buffer_descriptor._Set_buffer_ptr(NULL);
4898  }
4899  return *this;
4900  }
4901 
4906  {
4907  Concurrency::copy(_Src,*this);
4908  return *this;
4909  }
4910 
4914  void copy_to(array<_Value_type,_Rank>& _Dest) const __CPU_ONLY
4915  {
4916  Concurrency::copy(*this, _Dest);
4917  }
4918 
4922  void copy_to(const array_view<_Value_type,_Rank>& _Dest) const __CPU_ONLY
4923  {
4924  Concurrency::copy(*this,_Dest);
4925  }
4926 
4930  __declspec(property(get=get_extent)) Concurrency::extent<_Rank> extent;
4931  Concurrency::extent<_Rank> get_extent() const __GPU
4932  {
4933  return _M_extent;
4934  }
4935 
4939  __declspec(property(get=get_accelerator_view)) Concurrency::accelerator_view accelerator_view;
4940  Concurrency::accelerator_view get_accelerator_view() const __CPU_ONLY
4941  {
4942  return _Get_buffer()->_Get_master_buffer()->_Get_access_on_accelerator_view();
4943  }
4944 
4948  __declspec(property(get=get_associated_accelerator_view)) Concurrency::accelerator_view associated_accelerator_view;
4949  Concurrency::accelerator_view get_associated_accelerator_view() const __CPU_ONLY
4950  {
4951  return _Get_buffer()->_Get_master_buffer()->_Get_accelerator_view();
4952  }
4953 
4957  __declspec(property(get=get_cpu_access_type)) access_type cpu_access_type;
4958  access_type get_cpu_access_type() const __CPU_ONLY
4959  {
4960  return _Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_type();
4961  }
4962 
4972  _Value_type& operator[] (const index<_Rank>& _Index) __GPU
4973  {
4974  // Refresh the data ptr if needed
4975  _Refresh_data_ptr(_Read_write_access);
4976 
4977  _Value_type * _Ptr = reinterpret_cast<_Value_type *>(_M_buffer_descriptor._M_data_ptr);
4978  return _Ptr[_Flatten_helper::func(_M_multiplier._M_base, _Index._M_base)];
4979  }
4980 
4990  const _Value_type& operator[] (const index<_Rank>& _Index) const __GPU
4991  {
4992  // Refresh the data ptr if needed
4993 #pragma warning( push )
4994 #pragma warning( disable : 4880 )
4995  // Casting away constness in amp restricted scope might result in
4996  // undefined behavior, therefore, the compiler will report a level 1 warning
4997  // for it. But the following const_cast is harmless thus we are suppressing
4998  // this warning just for this line.
4999  const_cast<array*>(this)->_Refresh_data_ptr(_Read_access);
5000 #pragma warning( pop )
5001 
5002  _Value_type * _Ptr = reinterpret_cast<_Value_type *>(_M_buffer_descriptor._M_data_ptr);
5003  return _Ptr[_Flatten_helper::func(_M_multiplier._M_base, _Index._M_base)];
5004  }
5005 
5017  {
5019  }
5020 
5032  {
5034  }
5035 
5045  _Value_type& operator() (const index<_Rank>& _Index) __GPU
5046  {
5047  return this->operator[](_Index);
5048  }
5049 
5059  const _Value_type& operator() (const index<_Rank>& _Index) const __GPU
5060  {
5061  return this->operator[](_Index);
5062  }
5063 
5076  _Value_type& operator() (int _I0, int _I1) __GPU
5077  {
5078  static_assert(_Rank == 2, "value_type& array::operator()(int, int) is only permissible on array<T, 2>");
5079  return this->operator[](index<2>(_I0, _I1));
5080  }
5081 
5094  const _Value_type& operator() (int _I0, int _I1) const __GPU
5095  {
5096  static_assert(_Rank == 2, "const value_type& array::operator()(int, int) is only permissible on array<T, 2>");
5097  return this->operator[](index<2>(_I0, _I1));
5098  }
5099 
5115  _Value_type& operator() (int _I0, int _I1, int _I2) __GPU
5116  {
5117  static_assert(_Rank == 3, "value_type& array::operator()(int, int, int) is only permissible on array<T, 3>");
5118  return this->operator[](index<3>(_I0, _I1, _I2));
5119  }
5120 
5136  const _Value_type& operator() (int _I0, int _I1, int _I2) const __GPU
5137  {
5138  static_assert(_Rank == 3, "const value_type& array::operator()(int, int, int) const is only permissible on array<T, 3>");
5139  return this->operator[](index<3>(_I0, _I1, _I2));
5140  }
5141 
5153  {
5155  }
5156 
5168  {
5170  }
5171 
5185  {
5186  array_view<_Value_type,_Rank> _T1(*this);
5187  return _T1.section(_Section_origin, _Section_extent);
5188  }
5189 
5202  array_view<const _Value_type,_Rank> section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU
5203  {
5205  return _T1.section(_Section_origin, _Section_extent);
5206  }
5207 
5219  {
5220  return section(Concurrency::index<_Rank>(), _Ext);
5221  }
5222 
5234  {
5235  return section(Concurrency::index<_Rank>(), _Ext);
5236  }
5237 
5249  {
5250  array_view<_Value_type,_Rank> _T1(*this);
5251  return _T1.section(_Idx);
5252  }
5253 
5265  {
5267  return _T1.section(_Idx);
5268  }
5269 
5283  array_view<_Value_type,1> section(int _I0, int _E0) __GPU
5284  {
5285  array_view<_Value_type,_Rank> _T1(*this);
5286  return _T1.section(_I0,_E0);
5287  }
5288 
5302  array_view<const _Value_type,1> section(int _I0, int _E0) const __GPU
5303  {
5305  return _T1.section(_I0,_E0);
5306  }
5307 
5327  array_view<_Value_type,2> section(int _I0, int _I1, int _E0, int _E1) __GPU
5328  {
5329  array_view<_Value_type,_Rank> _T1(*this);
5330  return _T1.section(_I0,_I1,_E0,_E1);
5331  }
5332 
5352  array_view<const _Value_type,2> section(int _I0, int _I1, int _E0, int _E1) const __GPU
5353  {
5355  return _T1.section(_I0,_I1,_E0,_E1);
5356  }
5357 
5383  array_view<_Value_type,3> section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) __GPU
5384  {
5385  array_view<_Value_type,_Rank> _T1(*this);
5386  return _T1.section(_I0,_I1,_I2,_E0,_E1,_E2);
5387  }
5388 
5414  array_view<const _Value_type,3> section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU
5415  {
5417  return _T1.section(_I0,_I1,_I2,_E0,_E1,_E2);
5418  }
5419 
5427  template <typename _Value_type2> array_view<_Value_type2,1> reinterpret_as() __GPU
5428  {
5429  return array_view<_Value_type,1>(_M_buffer_descriptor, Concurrency::extent<1>(extent.size())).template reinterpret_as<_Value_type2>();
5430  }
5431 
5439  template <typename _Value_type2> array_view<const _Value_type2,1> reinterpret_as() const __GPU
5440  {
5441 #pragma warning( push )
5442 #pragma warning( disable : 4880 )
5443  // Casting away constness in amp restricted scope might result in
5444  // undefined behavior, therefore, the compiler will report a level 1 warning
5445  // for it. But the following const_cast is harmless thus we are suppressing
5446  // this warning just for this line.
5447  return const_cast<array*>(this)->reinterpret_as<_Value_type2>();
5448 #pragma warning( pop )
5449  }
5450 
5460  template <int _New_rank> array_view<_Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) __GPU
5461  {
5462  return array_view<_Value_type,_New_rank>(_M_buffer_descriptor, _View_extent);
5463  }
5464 
5474  template <int _New_rank> array_view<const _Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) const __GPU
5475  {
5476 #pragma warning( push )
5477 #pragma warning( disable : 4880 )
5478  // Casting away constness in amp restricted scope might result in
5479  // undefined behavior, therefore, the compiler will report a level 1 warning
5480  // for it. But the following const_cast is harmless thus we are suppressing
5481  // this warning just for this line.
5482  return const_cast<array*>(this)->view_as<_New_rank>(_View_extent);
5483 #pragma warning( pop )
5484  }
5485 
5489  operator std::vector<_Value_type>() const __CPU_ONLY
5490  {
5491  std::vector<_Value_type> _return_vector(extent.size());
5492  Concurrency::copy(*this, _return_vector.begin());
5493 
5494  return _return_vector;
5495  }
5496 
5500  _Ret_ _Value_type* data() __GPU
5501  {
5502  _Refresh_data_ptr(_Read_write_access, false /* _Exception */);
5503  return reinterpret_cast<_Value_type*>(_M_buffer_descriptor._M_data_ptr);
5504  }
5505 
5509  const _Value_type* data() const __GPU
5510  {
5511 #pragma warning( push )
5512 #pragma warning( disable : 4880 )
5513  // Casting away constness in amp restricted scope might result in
5514  // undefined behavior, therefore, the compiler will report a level 1 warning
5515  // for it. But the following const_cast is harmless thus we are suppressing
5516  // this warning just for this line.
5517  const_cast<array*>(this)->_Refresh_data_ptr(_Read_access, false /* _Exception */);
5518 #pragma warning( pop )
5519  return reinterpret_cast<const _Value_type*>(_M_buffer_descriptor._M_data_ptr);
5520  }
5521 
5525  ~array() __CPU_ONLY noexcept(false)
5526  {
5527  bool _Can_throw = (std::current_exception() == nullptr);
5528 
5529  // Destructor should not throw if we are already processing
5530  // an exception and another exception will result in termination
5531  try {
5532  _Unregister();
5533  }
5534  catch(...)
5535  {
5536  if (_Can_throw) {
5537  throw;
5538  }
5539  }
5540  }
5541 
5542 private:
5543 
5544  // No default constructor
5545  array() __CPU_ONLY;
5546 
5547  // Private constructor used by direct3d::make_array
5548  array(const Concurrency::extent<_Rank>& _Extent, _Buffer_descriptor _Buffer_descriptor)
5549  : _M_extent(_Extent), _M_buffer_descriptor(_Buffer_descriptor)
5550  {
5551  _Initialize();
5552 
5553  // Register this
5554  this->_Register();
5555  }
5556 
5557  // Initialize
5558  unsigned int _Initialize() __CPU_ONLY
5559  {
5560  details::_Is_valid_extent(_M_extent);
5561 
5562  // Arrays always have a type access mode of '_Is_array_mode'
5563  // This is the mechanism for differentiating between arrays and array_views by the runtime
5564  _M_buffer_descriptor._M_type_access_mode = _Is_array_mode;
5565  unsigned int totalExtent = _M_extent[_Rank-1];
5566  details::_Array_init_helper<Concurrency::extent<_Rank>, Concurrency::extent<_Rank>>::func(totalExtent, _M_multiplier, _M_extent);
5567 
5568  return totalExtent;
5569  }
5570 
5571  // Initialize and allocate on specified accelerator_view
5572  void _Initialize(Concurrency::accelerator_view _Av, access_type _Cpu_access_type) __CPU_ONLY
5573  {
5574  unsigned int totalExtent = _Initialize();
5575  // release the existing buffer if any before allocation new one
5576  _M_buffer_descriptor._Set_buffer_ptr(NULL);
5577 
5578  _Buffer_ptr _PBuf = _Buffer::_Create_buffer(_Av, _Av, totalExtent, sizeof(_Value_type), false /* _Is_temp */, _Cpu_access_type);
5579 
5580  _M_buffer_descriptor._Set_buffer_ptr(_Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf));
5581  _Register();
5582  }
5583 
5584  // Initialize and allocate on specified accelerator_view and copy specified data
5585  template <typename _InputIterator>
5586  void _Initialize(Concurrency::accelerator_view _Av, _InputIterator _Src_first, _InputIterator _Src_last, access_type _Cpu_access_type) __CPU_ONLY
5587  {
5588  _Initialize(_Av, _Cpu_access_type);
5589  copy(_Src_first, _Src_last, *this);
5590  }
5591 
5592  // Initialize and allocate on specified accelerator_views
5594  {
5595  unsigned int totalExtent = _Initialize();
5596 
5597  // Staging arrays can only be created if the accelerator_view is on the cpu_accelerator
5598  _Buffer_ptr _PBuf = NULL;
5599 
5600  // release the existing buffer if any before allocation new one
5601  _M_buffer_descriptor._Set_buffer_ptr(NULL);
5602 
5603  if (_Is_cpu_accelerator(_Av.accelerator))
5604  {
5605  // If the accelerator _Associated_Av supports zero-copy and the default cpu access type
5606  // for the accelerator is access_type_read_write, create a zero-copy buffer instead of a
5607  // staging buffer
5608  if (_Associated_Av.accelerator.supports_cpu_shared_memory && (_Get_recommended_buffer_host_access_mode(_Associated_Av) == _Read_write_access)) {
5609  _PBuf = _Buffer::_Create_buffer(_Associated_Av, _Av, totalExtent, sizeof(_Value_type), false /* _Is_temp */, access_type_read_write);
5610  }
5611  else {
5612  _PBuf = _Buffer::_Create_stage_buffer(_Associated_Av, _Av, totalExtent, sizeof(_Value_type));
5613  }
5614 
5615  _PBuf->_Map_buffer(_Read_write_access, true /* _Wait */);
5616  }
5617  else
5618  {
5619  _PBuf = _Buffer::_Create_buffer(_Av, _Av, totalExtent, sizeof(_Value_type), false /* _Is_temp */, access_type_auto);
5620  }
5621 
5622  _M_buffer_descriptor._Set_buffer_ptr(_Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf));
5623  _Register();
5624  }
5625 
5626  // Initialize and allocate on specified accelerator_views
5627  template <typename _InputIterator>
5628  void _Initialize(Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
5629  {
5630  _Initialize(_Av, _Associated_Av);
5631  copy(_Src_first, _Src_last, *this);
5632  }
5633 
5634  void _Register() __CPU_ONLY
5635  {
5638  _M_buffer_descriptor._Get_buffer_ptr()->_Register_view(_M_buffer_descriptor._Get_view_key(), cpuAv, _Create_buffer_view_shape());
5639 
5640  _M_buffer_descriptor._Get_buffer_ptr()->_Discard(_M_buffer_descriptor._Get_view_key());
5641 
5642  // If the array is on the CPU accelerator then we will ensure that the descriptor
5643  // indicates CPU access
5645  {
5646  _Buffer_ptr _PBuf = NULL;
5647  this->_Get_access_async(_Read_write_access, _PBuf, false)._Get();
5648  }
5649  }
5650 
5651  void _Register_copy(const array &_Other) __CPU_ONLY
5652  {
5653  _M_buffer_descriptor._Get_buffer_ptr()->_Register_view_copy(_M_buffer_descriptor._Get_view_key(), _Other._M_buffer_descriptor._Get_view_key());
5654  }
5655 
5656  void _Unregister() __CPU_ONLY
5657  {
5658  // No need to unregister if the array was moved causing the buffer ptr to be set to NULL
5659  if (_M_buffer_descriptor._Get_buffer_ptr() != NULL) {
5660  _M_buffer_descriptor._Get_buffer_ptr()->_Unregister_view(_M_buffer_descriptor._Get_view_key());
5661  }
5662  }
5663 
5665  {
5666  return _M_buffer_descriptor._Get_buffer_ptr();
5667  }
5668 
5669  _Event _Get_access_async(_Access_mode _Mode, _Buffer_ptr &_Buf_ptr, bool _Zero_copy_cpu_access = false) const __CPU_ONLY
5670  {
5671  _ASSERTE(!_Zero_copy_cpu_access || (_Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_mode() != _No_access));
5672 
5673  _Buffer_ptr _PBuf;
5674  Concurrency::accelerator_view _Access_av = _Zero_copy_cpu_access ? accelerator(accelerator::cpu_accelerator).default_view : this->accelerator_view;
5675  _Event _Ev = details::_Get_access_async(_M_buffer_descriptor._Get_view_key(),
5676  _Access_av,
5677  _Mode, _PBuf);
5678  _Buf_ptr = _PBuf;
5679 
5680  if (_Is_cpu_accelerator(_Access_av.accelerator)) {
5681  _Ev = _Ev._Add_continuation(std::function<_Event()>([_PBuf, this]() mutable -> _Event {
5682  const_cast<array*>(this)->_M_buffer_descriptor._M_data_ptr = _PBuf->_Get_host_ptr();
5683  return _Event();
5684  }));
5685  }
5686 
5687  return _Ev;
5688  }
5689 
5691  {
5692  _ASSERTE(_Get_buffer()->_Get_master_buffer_elem_size() == sizeof(_Value_type));
5693 
5694  unsigned int _ZeroOffset[_Rank] = {0};
5695  unsigned int _View_extent[_Rank];
5696  for(int i=0; i<_Rank; ++i)
5697  {
5698  _View_extent[i] = static_cast<unsigned int>(this->_M_extent[i]);
5699  }
5700  return _View_shape::_Create_view_shape(static_cast<unsigned int>(_Rank), 0, &_View_extent[0], &_ZeroOffset[0], &_View_extent[0]);
5701  }
5702 
5703  bool _Has_cpu_access() const __CPU_ONLY
5704  {
5705  return (_Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_mode() != _No_access);
5706  }
5707 
5708  void _Refresh_data_ptr(_Access_mode _Requested_mode, bool _Exception = true) __CPU_ONLY
5709  {
5710  _ASSERTE(_Is_valid_access_mode(_Requested_mode));
5711 
5712  // For an array that has CPU access, the maximum CPU access allowed is that allowed by
5713  // the underlying _Buffer allocation
5714  _Requested_mode = static_cast<_Access_mode>(_Requested_mode & _Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_mode());
5715 
5716  // Refresh the data ptr if we do not have requested access
5717  if ((_Requested_mode == _No_access) || ((_M_buffer_descriptor._M_curr_cpu_access_mode & _Requested_mode) != _Requested_mode))
5718  {
5719  if (_Has_cpu_access() && (_Requested_mode != _No_access))
5720  {
5721  auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor);
5722  _Buffer_ptr _PBuf;
5723  bool _Zero_copy_cpu_access = !_Is_cpu_accelerator(this->accelerator_view.accelerator);
5724  this->_Get_access_async(_Requested_mode, _PBuf, _Zero_copy_cpu_access)._Get();
5726  }
5727  else
5728  {
5729  if (_Exception)
5730  {
5731  if (!_Has_cpu_access()) {
5732  throw runtime_exception("The array is not accessible on CPU.", E_FAIL);
5733  }
5734  else {
5735  throw runtime_exception("The array is not accessible for reading on CPU.", E_FAIL);
5736  }
5737  }
5738  }
5739  }
5740  }
5741 
5742  void _Refresh_data_ptr(_Access_mode /*_Requested_mode*/, bool /*_Exception*/ = true) __GPU_ONLY
5743  {
5744  }
5745 
5746 private:
5747  // Data members
5748 
5750 
5751  // Descriptor of the buffer underlying the array
5752  _Buffer_descriptor _M_buffer_descriptor;
5753 
5754  // The vector used for index calculation.
5756 };
5757 
5758 namespace details
5759 {
5760 template <typename _Value_type, int _Rank>
5762 {
5763  if (_Src.extent.size() > _Dest.extent.size())
5764  {
5765  throw runtime_exception("Invalid _Src argument. _Src size exceeds total size of the _Dest.", E_INVALIDARG);
5766  }
5767 
5768  // We can obliterate the exisiting content of dest if it is about to be totally overwritten
5769  _Access_mode _Dest_access_mode = (_Src.extent.size() == _Dest.extent.size()) ? _Write_access : _Read_write_access;
5770 
5771  _Buffer_ptr _PBufSrc, _PBufDest;
5772  _Event _Ev = _Get_access_async(_Src, _Read_access, _PBufSrc);
5773  _Ev = _Ev._Add_event(_Get_access_async(_Dest, _Dest_access_mode, _PBufDest));
5774  size_t _NumElemsToCopy = (_Src.extent.size() * sizeof(_Value_type)) / _PBufSrc->_Get_elem_size();
5775  return _Ev._Add_continuation(std::function<_Event()>([_PBufSrc, _PBufDest, _NumElemsToCopy]() mutable -> _Event {
5776  return details::_Copy_impl(_PBufSrc, 0, _PBufDest, 0, _NumElemsToCopy);
5777  }));
5778 }
5779 
5780 template <typename InputIterator, typename _Value_type, int _Rank>
5781 _Event _Copy_async_impl(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest)
5782 {
5783  size_t _NumElemsToCopy = std::distance(_SrcFirst, _SrcLast);
5784  // We can obliterate the exisiting content of dest if it is about to be totally overwritten
5785  _Access_mode _Dest_access_mode = (_NumElemsToCopy == _Dest.extent.size()) ? _Write_access : _Read_write_access;
5786  _Buffer_ptr _PDestBuf;
5787  _Event _Ev = _Get_access_async(_Dest, _Dest_access_mode, _PDestBuf);
5788 
5789  return _Ev._Add_continuation(std::function<_Event()>([_SrcFirst, _SrcLast, _PDestBuf, _NumElemsToCopy]() mutable -> _Event {
5790  return details::_Copy_impl<InputIterator, _Value_type>(_SrcFirst, _SrcLast, _NumElemsToCopy, _PDestBuf, 0);
5791  }));
5792 }
5793 
5794 template <typename OutputIterator, typename _Value_type, int _Rank>
5795 _Event _Copy_async_impl(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
5796 {
5797  _Buffer_ptr _PSrcBuf;
5798  _Event _Ev = _Get_access_async(_Src, _Read_access, _PSrcBuf);
5799  size_t _NumElemsToCopy = (_Src.extent.size() * sizeof(_Value_type)) / _PSrcBuf->_Get_elem_size();
5800  return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _NumElemsToCopy, _DestIter]() mutable -> _Event {
5801  return details::_Copy_impl<OutputIterator, _Value_type>(_PSrcBuf, 0, _NumElemsToCopy, _DestIter);
5802  }));
5803 }
5804 
5805 template <typename _Value_type, int _Rank>
5807 {
5808  const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src);
5809  const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest);
5810  if (_SrcBufDesc._Get_buffer_ptr() == _DestBufDesc._Get_buffer_ptr()) {
5811  throw runtime_exception("Cannot copy between overlapping regions of the same buffer.", E_INVALIDARG);
5812  }
5813 
5814  _Buffer_ptr _PSrcBuf, _PDestBuf;
5815  _Event _Ev = _Get_access_async(_Src, _Read_access, _PSrcBuf);
5816 
5817  // The source accelerator_view is driven by array's master location,
5818  // therefore we can pass nullptr to avoid unnecessary computation
5819  auto _AccelInfo = _Get_src_dest_accelerator_view(nullptr, &_DestBufDesc);
5820 
5821  _Ev = _Ev._Add_event(_Get_access_async(_DestBufDesc._Get_view_key(), _AccelInfo.second, _Write_access, _PDestBuf));
5822  _View_shape_ptr _PSrcShape = _Get_buffer_view_shape(_SrcBufDesc);
5823  _View_shape_ptr _PDestShape = _Get_buffer_view_shape(_DestBufDesc);
5824  return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape]() mutable -> _Event {
5825  return details::_Copy_impl(_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape);
5826  }));
5827 }
5828 
5829 template <typename _Value_type, int _Rank>
5831 {
5832  const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src);
5833  const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest);
5834  if (_SrcBufDesc._Get_buffer_ptr() == _DestBufDesc._Get_buffer_ptr()) {
5835  throw runtime_exception("Cannot copy between overlapping regions of the same buffer.", E_INVALIDARG);
5836  }
5837 
5838  auto _AccelInfo = _Get_src_dest_accelerator_view(&_SrcBufDesc, &_DestBufDesc);
5839 
5840  _Buffer_ptr _PSrcBuf, _PDestBuf;
5841  _Event _Ev = _Get_access_async(_SrcBufDesc._Get_view_key(), _AccelInfo.first, _Read_access, _PSrcBuf);
5842  _Ev = _Ev._Add_event(_Get_access_async(_Dest, _Write_access, _PDestBuf));
5843  _View_shape_ptr _PSrcShape = _Get_buffer_view_shape(_SrcBufDesc);
5844  _View_shape_ptr _PDestShape = _Get_buffer_view_shape(_DestBufDesc);
5845  return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape]() mutable -> _Event {
5846  return details::_Copy_impl(_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape);
5847  }));
5848 }
5849 
5850 template <typename _Value_type, int _Rank>
5852 {
5853  const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src);
5854  const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest);
5855  _View_shape_ptr _PSrcShape = _Get_buffer_view_shape(_SrcBufDesc);
5856  _View_shape_ptr _PDestShape = _Get_buffer_view_shape(_DestBufDesc);
5857  if ((_SrcBufDesc._Get_buffer_ptr() == _DestBufDesc._Get_buffer_ptr()) && _PSrcShape->_Overlaps(_PDestShape)) {
5858  throw runtime_exception("Cannot copy between overlapping regions of the same buffer.", E_INVALIDARG);
5859  }
5860 
5861  auto _AccelInfo = _Get_src_dest_accelerator_view(&_SrcBufDesc, &_DestBufDesc);
5862 
5863  _Buffer_ptr _PSrcBuf, _PDestBuf;
5864  _Event _Ev = _Get_access_async(_SrcBufDesc._Get_view_key(), _AccelInfo.first, _Read_access, _PSrcBuf);
5865  _Ev = _Ev._Add_event(_Get_access_async(_DestBufDesc._Get_view_key(), _AccelInfo.second, _Write_access, _PDestBuf));
5866  return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape]() mutable -> _Event {
5867  return details::_Copy_impl(_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape);
5868  }));
5869 }
5870 
5871 template <typename InputIterator, typename _Value_type, int _Rank>
5872 _Event _Copy_async_impl(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest)
5873 {
5874  static_assert(!std::is_const<_Value_type>::value, "Cannot copy to array_view<const _Value_type, _Rank>.");
5875 
5876  size_t _Src_size = std::distance(_SrcFirst, _SrcLast);
5877 
5878  // Source cannot be greater than destination
5879  if (_Src_size > _Dest.extent.size())
5880  {
5881  throw runtime_exception("Number of elements in range between [_SrcFirst, _SrcLast) exceeds total size of the _Dest.", E_INVALIDARG);
5882  }
5883 
5884 #pragma warning( push )
5885 #pragma warning( disable : 4127 ) // Disable warning about constant conditional expression
5886  // Higher ranks need to have as many elements as in _Dest array_view
5887  if ((_Rank > 1) && (_Src_size != _Dest.extent.size()))
5888  {
5889  throw runtime_exception("For _Rank > 1 the number of elements in range between [_SrcFirst, _SrcLast) has to be equal to total size of the _Dest.", E_INVALIDARG);
5890  }
5891 #pragma warning( pop )
5892 
5893  // We can obliterate the exisiting content of dest if it is about to be totally overwritten
5894  _Access_mode _Dest_access_mode = (_Src_size == _Dest.extent.size()) ? _Write_access : _Read_write_access;
5895 
5896  // Get read-write access for array_view on cpu_accelerator and take underlying pointer to data
5897  const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest);
5898 
5899  auto _AccelInfo = _Get_src_dest_accelerator_view(nullptr, &_DestBufDesc);
5900 
5901  _Buffer_ptr _PDestBuf;
5902  _Event _Ev = _Get_access_async(_DestBufDesc._Get_view_key(), _AccelInfo.second, _Dest_access_mode, _PDestBuf);
5903 
5904  _View_shape_ptr _Dst_shape = _Get_buffer_view_shape(_DestBufDesc);
5905 
5906  // If the _Dst shape is linear then perform a linear copy
5907  unsigned int _Dst_linear_offset, _Dst_linear_size;
5908  if (_Dst_shape->_Is_view_linear(_Dst_linear_offset, _Dst_linear_size))
5909  {
5910  _Ev = _Ev._Add_continuation(std::function<_Event()>([_PDestBuf, _SrcFirst, _SrcLast, _Src_size, _Dst_linear_offset]() mutable -> _Event {
5911  return details::_Copy_impl<InputIterator, _Value_type>(_SrcFirst, _SrcLast, _Src_size, _PDestBuf, _Dst_linear_offset);
5912  }));
5913  }
5914  else
5915  {
5916  _View_shape_ptr _Reinterpreted_dst_shape = _Create_reinterpreted_shape(_Dst_shape, _PDestBuf->_Get_elem_size(), sizeof(_Value_type));
5917 
5918  // Source has as many elements as in destination, reshape source to match destination shape
5919  std::vector<unsigned int> _Src_offset(_Reinterpreted_dst_shape->_Get_rank(), 0);
5920  _View_shape_ptr _Src_shape = details::_View_shape::_Create_view_shape(_Reinterpreted_dst_shape->_Get_rank(), 0 /* linear offset*/,
5921  _Reinterpreted_dst_shape->_Get_view_extent(), _Src_offset.data(),
5922  _Reinterpreted_dst_shape->_Get_view_extent());
5923 
5924  _Ev = _Ev._Add_continuation(std::function<_Event()>([_PDestBuf, _SrcFirst, _Src_shape, _Dst_shape]() mutable -> _Event {
5925  return details::_Copy_impl<InputIterator, _Value_type>(_SrcFirst, _Src_shape, _PDestBuf, _Dst_shape);
5926  }));
5927  }
5928 
5929  return _Ev;
5930 }
5931 
5932 template <typename OutputIterator, typename _Value_type, int _Rank>
5933 _Event _Copy_async_impl(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
5934 {
5935  // Caller is responsible for passing valid _DestIter
5936 
5937  // Get read access for array_view on cpu_accelerator and take underlying pointer to data
5938  const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src);
5939 
5940  auto _AccelInfo = _Get_src_dest_accelerator_view(&_SrcBufDesc, nullptr);
5941 
5942  _Buffer_ptr _PSrcBuf;
5943  _Event _Ev = _Get_access_async(_SrcBufDesc._Get_view_key(), _AccelInfo.first, _Read_access, _PSrcBuf);
5944 
5945  // Get source shape
5946  _View_shape_ptr _Src_shape = _Get_buffer_view_shape(_SrcBufDesc);
5947 
5948  // If the _Src_shape is linear then perform a linear copy
5949  unsigned int _Src_linear_offset, _Src_linear_size;
5950  if (_Src_shape->_Is_view_linear(_Src_linear_offset, _Src_linear_size))
5951  {
5952  _Ev = _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _Src_linear_offset, _Src_linear_size, _DestIter]() mutable -> _Event {
5953  return details::_Copy_impl<OutputIterator, _Value_type>(_PSrcBuf, _Src_linear_offset, _Src_linear_size, _DestIter);
5954  }));
5955  }
5956  else
5957  {
5958  _View_shape_ptr _Reinterpreted_src_shape = _Create_reinterpreted_shape(_Src_shape, _PSrcBuf->_Get_elem_size(), sizeof(_Value_type));
5959 
5960  // Valid destination should have space for as many elements as in source array_view, reshape to match source view shape
5961  std::vector<unsigned int> _Dst_offset(_Reinterpreted_src_shape->_Get_rank(), 0);
5962  _View_shape_ptr _Dst_shape = details::_View_shape::_Create_view_shape(_Reinterpreted_src_shape->_Get_rank(), 0 /* linear offset*/,
5963  _Reinterpreted_src_shape->_Get_view_extent(), _Dst_offset.data(),
5964  _Reinterpreted_src_shape->_Get_view_extent());
5965 
5966  _Ev = _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _Src_shape, _DestIter, _Dst_shape]() mutable -> _Event {
5967  return details::_Copy_impl<OutputIterator, _Value_type>(_PSrcBuf, _Src_shape, _DestIter, _Dst_shape);
5968  }));
5969  }
5970 
5971  return _Ev;
5972 }
5973 
5974 }
5975 
5988 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest)
5989 {
5992  sizeof(_Value_type) * _Src.extent.size());
5993 
5994  auto _Ev = _Copy_async_impl(_Src, _Dest);
5995 
5996  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
5997 }
5998 
6008 template <typename _Value_type, int _Rank> void copy(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest)
6009 {
6012  sizeof(_Value_type) * _Src.extent.size());
6013 
6014  _Copy_async_impl(_Src, _Dest)._Get();
6015 
6017 }
6018 
6034 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest)
6035 {
6036  auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(nullptr,
6038  sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast));
6039 
6040  _Event _Ev = _Copy_async_impl(_SrcFirst, _SrcLast, _Dest);
6041 
6042  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6043 }
6044 
6057 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest)
6058 {
6059  auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(nullptr,
6061  sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast));
6062 
6063  _Copy_async_impl(_SrcFirst, _SrcLast, _Dest)._Get();
6064 
6066 }
6067 
6081 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest)
6082 {
6083  InputIterator _SrcLast = _SrcFirst;
6084  std::advance(_SrcLast, _Dest.extent.size());
6085  return copy_async(_SrcFirst, _SrcLast, _Dest);
6086 }
6087 
6098 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest)
6099 {
6100  InputIterator _SrcLast = _SrcFirst;
6101  std::advance(_SrcLast, _Dest.extent.size());
6102  copy(_SrcFirst, _SrcLast, _Dest);
6103 }
6104 
6117 template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
6118 {
6119  _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator);
6120 
6122  nullptr,
6123  sizeof(_Value_type) * _Src.extent.size());
6124  _Event _Ev = _Copy_async_impl(_Src, _DestIter);
6125 
6126  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6127 }
6128 
6138 template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
6139 {
6140  _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator);
6141 
6143  nullptr,
6144  sizeof(_Value_type) * _Src.extent.size());
6145 
6146  _Copy_async_impl(_Src, _DestIter)._Get();
6147 
6149 }
6150 
6163 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest)
6164 {
6167  sizeof(_Value_type) * _Src.extent.size());
6168 
6169  _Event _Ev = _Copy_async_impl(_Src, _Dest);
6170 
6171  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6172 }
6173 
6183 template <typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest)
6184 {
6187  sizeof(_Value_type) * _Src.extent.size());
6188 
6189  _Copy_async_impl(_Src, _Dest)._Get();
6190 
6192 }
6193 
6207 {
6210  sizeof(_Value_type) * _Src.extent.size());
6211 
6212  _Event _Ev = _Copy_async_impl(_Src, _Dest);
6213 
6214  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6215 }
6216 
6226 template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest)
6227 {
6230  sizeof(_Value_type) * _Src.extent.size());
6231 
6232  _Copy_async_impl(_Src, _Dest)._Get();
6233 
6235 }
6236 
6249 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest)
6250 {
6251  return copy_async<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest);
6252 }
6253 
6263 template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest)
6264 {
6265  copy<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest);
6266 }
6267 
6280 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest)
6281 {
6284  sizeof(_Value_type) * _Src.extent.size());
6285 
6286  _Event _Ev = _Copy_async_impl(_Src, _Dest);
6287 
6288  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6289 }
6290 
6300 template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest)
6301 {
6304  sizeof(_Value_type) * _Src.extent.size());
6305 
6306  _Copy_async_impl(_Src, _Dest)._Get();
6307 
6309 }
6310 
6323 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest)
6324 {
6325  return copy_async<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest);
6326 }
6327 
6337 template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest)
6338 {
6339  copy<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest);
6340 }
6341 
6357 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest)
6358 {
6359  auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(nullptr,
6361  sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast));
6362 
6363  _Event _Ev = _Copy_async_impl(_SrcFirst, _SrcLast, _Dest);
6364 
6365  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6366 }
6367 
6381 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest)
6382 {
6383  InputIterator _SrcLast = _SrcFirst;
6384  std::advance(_SrcLast, _Dest.extent.size());
6385  return copy_async(_SrcFirst, _SrcLast, _Dest);
6386 }
6387 
6400 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest)
6401 {
6402  auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(nullptr,
6404  sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast));
6405 
6406  _Copy_async_impl(_SrcFirst, _SrcLast, _Dest)._Get();
6407 
6409 }
6410 
6421 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest)
6422 {
6423  InputIterator _SrcLast = _SrcFirst;
6424  std::advance(_SrcLast, _Dest.extent.size());
6425  copy(_SrcFirst, _SrcLast, _Dest);
6426 }
6427 
6440 template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
6441 {
6442  _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator);
6443 
6444  // Caller is responsible for passing valid _DestIter
6446  nullptr,
6447  sizeof(_Value_type) * _Src.extent.size());
6448 
6449  _Event _Ev = _Copy_async_impl(_Src, _DestIter);
6450 
6451  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6452 }
6453 
6463 template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
6464 {
6465  _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator);
6466 
6468  nullptr,
6469  sizeof(_Value_type) * _Src.extent.size());
6470 
6471  _Copy_async_impl(_Src, _DestIter)._Get();
6472 
6474 }
6475 
6476 // Namespace for Direct3D specific functionality
6477 namespace direct3d
6478 {
6494  template<typename _Value_type, int _Rank> _Ret_ IUnknown *get_buffer(const array<_Value_type, _Rank> &_Array) __CPU_ONLY
6495  {
6496  _Buffer_ptr _PBuf;
6497  _Get_access_async(_Array, _Read_write_access, _PBuf)._Get();
6499  }
6500 
6522  template<typename _Value_type, int _Rank> array<_Value_type, _Rank> make_array(const Concurrency::extent<_Rank> &_Extent, const Concurrency::accelerator_view &_Av, _In_ IUnknown *_D3D_buffer) __CPU_ONLY
6523  {
6525 
6526  if (_D3D_buffer == NULL)
6527  {
6528  throw runtime_exception("NULL D3D buffer pointer.", E_INVALIDARG);
6529  }
6530 
6532  {
6533  throw runtime_exception("Cannot create D3D buffer on a non-D3D accelerator_view.", E_INVALIDARG);
6534  }
6535 
6536  _Ubiquitous_buffer_ptr _PBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_Buffer::_Create_buffer(_D3D_buffer, _Av, _Extent.size(), sizeof(_Value_type)));
6537  return array<_Value_type, _Rank>(_Extent, _Buffer_descriptor(_PBuf->_Get_master_buffer()->_Get_host_ptr(), _PBuf, _Is_array_mode, _Read_write_access));
6538  }
6539 
6540 } // namespace Concurrency::direct3d
6541 
6542 //=============================================================================
6543 // Atomic Operation Library
6544 //=============================================================================
6545 
6546 #define AS_UINT_PTR(p) reinterpret_cast<unsigned int *>(p)
6547 #define AS_UINT(v) *(reinterpret_cast<unsigned int *>(&(v)))
6548 #define AS_INT(v) *(reinterpret_cast<int *>(&(v)))
6549 #define AS_FLOAT(v) *(reinterpret_cast<float *>(&(v)))
6550 
6563 inline int atomic_fetch_add(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6564 {
6565  unsigned int _Ret;
6567  return AS_INT(_Ret);
6568 }
6569 
6582 inline unsigned int atomic_fetch_add(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6583 {
6584  return __dp_d3d_interlocked_add(_Dest, _Value);
6585 }
6586 
6599 inline int atomic_fetch_sub(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6600 {
6601  unsigned int _Ret;
6602  int _Neg = -_Value;
6603  _Ret = __dp_d3d_interlocked_add(AS_UINT_PTR(_Dest), AS_UINT(_Neg));
6604  return AS_INT(_Ret);
6605 }
6606 
6619 
6620 inline unsigned int atomic_fetch_sub(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6621 {
6622 #pragma warning( push )
6623 #pragma warning( disable : 4146 )
6624  // Warning 4146: unary minus operator applied to unsigned type, result
6625  // still unsigned.
6626  //
6627  // This is what we want here. The resulted unsigned value have the
6628  // right binary representation for achieving subtraction
6629  return __dp_d3d_interlocked_add(_Dest, (-_Value));
6630 #pragma warning( pop )
6631 }
6632 
6633 
6643 inline int atomic_fetch_inc(_Inout_ int * _Dest) __GPU_ONLY
6644 {
6645  unsigned int _Ret;
6646  _Ret = __dp_d3d_interlocked_add(AS_UINT_PTR(_Dest), 1U);
6647  return AS_INT(_Ret);
6648 }
6649 
6659 inline unsigned int atomic_fetch_inc(_Inout_ unsigned int * _Dest) __GPU_ONLY
6660 {
6661  return __dp_d3d_interlocked_add(_Dest, 1U);
6662 }
6663 
6673 inline int atomic_fetch_dec(_Inout_ int * _Dest) __GPU_ONLY
6674 {
6675 #pragma warning( push )
6676 #pragma warning( disable : 4146 )
6677  // Warning 4146: unary minus operator applied to unsigned type, result
6678  // still unsigned.
6679  unsigned int _Ret;
6680  _Ret = __dp_d3d_interlocked_add(AS_UINT_PTR(_Dest), (-(1U)));
6681  return AS_INT(_Ret);
6682 #pragma warning( pop )
6683 }
6684 
6694 inline unsigned int atomic_fetch_dec(_Inout_ unsigned int * _Dest) __GPU_ONLY
6695 {
6696 #pragma warning( push )
6697 #pragma warning( disable : 4146 )
6698  // Warning 4146: unary minus operator applied to unsigned type, result
6699  // still unsigned.
6700  return __dp_d3d_interlocked_add(_Dest, (-(1U)));
6701 #pragma warning( pop )
6702 }
6703 
6716 inline int atomic_exchange(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6717 {
6718  unsigned int _Ret = __dp_d3d_interlocked_exchange(AS_UINT_PTR(_Dest), AS_UINT(_Value));
6719  return AS_INT(_Ret);
6720 }
6721 
6734 inline unsigned int atomic_exchange(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6735 {
6736  return __dp_d3d_interlocked_exchange(_Dest, _Value);
6737 }
6738 
6751 inline float atomic_exchange(_Inout_ float * _Dest, float _Value) __GPU_ONLY
6752 {
6753  unsigned int _Ret = __dp_d3d_interlocked_exchange(AS_UINT_PTR(_Dest), AS_UINT(_Value));
6754  return AS_FLOAT(_Ret);
6755 }
6756 
6775 inline bool atomic_compare_exchange(_Inout_ int * _Dest, _Inout_ int * _Expected_value, int _Value) __GPU_ONLY
6776 {
6777  int _Old = *_Expected_value;
6778  unsigned int _Ret = __dp_d3d_interlocked_compare_exchange(AS_UINT_PTR(_Dest), AS_UINT(_Value), AS_UINT(_Old));
6779  if (_Ret == AS_UINT(_Old))
6780  {
6781  return true;
6782  }
6783  else
6784  {
6785  *_Expected_value = AS_INT(_Ret);
6786  return false;
6787  }
6788 }
6789 
6808 inline bool atomic_compare_exchange(_Inout_ unsigned int * _Dest, _Inout_ unsigned int * _Expected_value, unsigned int _Value) __GPU_ONLY
6809 {
6810  unsigned int _Old = *_Expected_value;
6811  unsigned int _Ret = __dp_d3d_interlocked_compare_exchange(_Dest, _Value, _Old);
6812  if (_Ret == _Old)
6813  {
6814  return true;
6815  }
6816  else
6817  {
6818  *_Expected_value = _Ret;
6819  return false;
6820  }
6821 }
6822 
6836 inline int atomic_fetch_max(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6837 {
6838  return __dp_d3d_interlocked_max_int(_Dest, _Value);
6839 }
6840 
6854 inline unsigned int atomic_fetch_max(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6855 {
6856  return __dp_d3d_interlocked_max_uint(_Dest, _Value);
6857 }
6858 
6859 
6873 inline int atomic_fetch_min(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6874 {
6875  return __dp_d3d_interlocked_min_int(_Dest, _Value);
6876 }
6877 
6891 inline unsigned int atomic_fetch_min(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6892 {
6893  return __dp_d3d_interlocked_min_uint(_Dest, _Value);
6894 }
6895 
6908 inline int atomic_fetch_and(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6909 {
6910  unsigned int _Ret;
6912  return AS_INT(_Ret);
6913 }
6914 
6927 inline unsigned int atomic_fetch_and(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6928 {
6929  return __dp_d3d_interlocked_and(_Dest, _Value);
6930 }
6931 
6932 
6945 inline int atomic_fetch_or(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6946 {
6947  unsigned int _Ret;
6949  return AS_INT(_Ret);
6950 }
6951 
6964 inline unsigned int atomic_fetch_or(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6965 {
6966  return __dp_d3d_interlocked_or(_Dest, _Value);
6967 }
6968 
6981 inline int atomic_fetch_xor(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6982 {
6983  unsigned int _Ret;
6985  return AS_INT(_Ret);
6986 }
6987 
7000 inline unsigned int atomic_fetch_xor(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
7001 {
7002  return __dp_d3d_interlocked_xor(_Dest, _Value);
7003 }
7004 
7005 //=============================================================================
7006 // parallel_for_each
7007 //=============================================================================
7008 
7020 template <int _Rank, typename _Kernel_type> void parallel_for_each(const extent<_Rank>& _Compute_domain, const _Kernel_type &_Kernel)
7021 {
7023  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7024 }
7025 
7037 template <int _Dim0, int _Dim1, int _Dim2, typename _Kernel_type> void parallel_for_each(const tiled_extent<_Dim0, _Dim1, _Dim2>& _Compute_domain, const _Kernel_type& _Kernel)
7038 {
7040  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7041 }
7042 
7054 template <int _Dim0, int _Dim1, typename _Kernel_type> void parallel_for_each(const tiled_extent<_Dim0, _Dim1>& _Compute_domain, const _Kernel_type& _Kernel)
7055 {
7057  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7058 }
7059 
7071 template <int _Dim0, typename _Kernel_type> void parallel_for_each(const tiled_extent<_Dim0>& _Compute_domain, const _Kernel_type& _Kernel)
7072 {
7074  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7075 }
7076 
7089 template <int _Rank, typename _Kernel_type> void parallel_for_each(const accelerator_view& _Accl_view, const extent<_Rank>& _Compute_domain, const _Kernel_type& _Kernel)
7090 {
7091  _Host_Scheduling_info _SchedulingInfo = {_Accl_view};
7092  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7093 }
7094 
7108 template <int _Dim0, int _Dim1, int _Dim2, typename _Kernel_type> void parallel_for_each(const accelerator_view& _Accl_view, const tiled_extent<_Dim0, _Dim1, _Dim2>& _Compute_domain, const _Kernel_type& _Kernel)
7109 {
7110  _Host_Scheduling_info _SchedulingInfo = {_Accl_view};
7111  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7112 }
7113 
7127 template <int _Dim0, int _Dim1, typename _Kernel_type> void parallel_for_each(const accelerator_view& _Accl_view, const tiled_extent<_Dim0, _Dim1>& _Compute_domain, const _Kernel_type& _Kernel)
7128 {
7129  _Host_Scheduling_info _SchedulingInfo = {_Accl_view};
7130  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7131 }
7132 
7146 template <int _Dim0, typename _Kernel_type> void parallel_for_each(const accelerator_view& _Accl_view, const tiled_extent<_Dim0>& _Compute_domain, const _Kernel_type& _Kernel)
7147 {
7148  _Host_Scheduling_info _SchedulingInfo = {_Accl_view};
7149  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7150 }
7151 
7152 
7153 
7154 //=============================================================================
7155 
7156 extern "C"
7157 {
7158 
7159 // Debugging intrinsics
7160 void direct3d_abort() __GPU_ONLY;
7161 void direct3d_errorf(const char *, ...) __GPU_ONLY;
7162 void direct3d_printf(const char *, ...) __GPU_ONLY;
7163 
7164 }
7165 
7168 
7169 #pragma warning( push )
7170 #pragma warning( disable : 4100 ) // unreferenced formal parameter
7171 
7178 inline void all_memory_fence(const tile_barrier & _Barrier) __GPU_ONLY
7179 {
7181 }
7182 
7189 inline void global_memory_fence(const tile_barrier & _Barrier) __GPU_ONLY
7190 {
7192 }
7193 
7200 inline void tile_static_memory_fence(const tile_barrier & _Barrier) __GPU_ONLY
7201 {
7203 }
7204 
7205 #pragma warning( pop )
7206 
7207 
7208 
7209 namespace direct3d
7210 {
7211 
7221 inline int abs(int _X) __GPU_ONLY
7222 {
7223  return __dp_d3d_absi(_X);
7224 }
7225 
7241 inline float clamp(float _X, float _Min, float _Max) __GPU_ONLY
7242 {
7243  return __dp_d3d_clampf(_X, _Min, _Max);
7244 }
7245 
7261 inline int clamp(int _X, int _Min, int _Max) __GPU_ONLY
7262 {
7263  return __dp_d3d_clampi(_X, _Min, _Max);
7264 }
7265 
7275 inline unsigned int countbits(unsigned int _X) __GPU_ONLY
7276 {
7277  return __dp_d3d_countbitsu(_X);
7278 }
7279 
7289 inline int firstbithigh(int _X) __GPU_ONLY
7290 {
7291  return __dp_d3d_firstbithighi(_X);
7292 }
7293 
7303 inline int firstbitlow(int _X) __GPU_ONLY
7304 {
7305  return __dp_d3d_firstbitlowi(_X);
7306 }
7307 
7320 inline int imax(int _X, int _Y) __GPU_ONLY
7321 {
7322  return __dp_d3d_maxi(_X, _Y);
7323 }
7324 
7337 inline int imin(int _X, int _Y) __GPU_ONLY
7338 {
7339  return __dp_d3d_mini(_X, _Y);
7340 }
7341 
7354 inline unsigned int umax(unsigned int _X, unsigned int _Y) __GPU_ONLY
7355 {
7356  return __dp_d3d_maxu(_X, _Y);
7357 }
7358 
7371 inline unsigned int umin(unsigned int _X, unsigned int _Y) __GPU_ONLY
7372 {
7373  return __dp_d3d_minu(_X, _Y);
7374 }
7375 
7391 inline float mad(float _X, float _Y, float _Z) __GPU_ONLY
7392 {
7393  return __dp_d3d_madf(_X, _Y, _Z);
7394 }
7395 
7411 inline double mad(double _X, double _Y, double _Z) __GPU_ONLY
7412 {
7413  return __dp_d3d_madd(_X, _Y, _Z);
7414 }
7415 
7431 inline int mad(int _X, int _Y, int _Z) __GPU_ONLY
7432 {
7433  return __dp_d3d_madi(_X, _Y, _Z);
7434 }
7435 
7451 inline unsigned int mad(unsigned int _X, unsigned int _Y, unsigned int _Z) __GPU_ONLY
7452 {
7453  return __dp_d3d_madu(_X, _Y, _Z);
7454 }
7455 
7465 inline float noise(float _X) __GPU_ONLY
7466 {
7467  return __dp_d3d_noisef(_X);
7468 }
7469 
7479 inline float radians(float _X) __GPU_ONLY
7480 {
7481  return __dp_d3d_radiansf(_X);
7482 }
7483 
7493 inline float rcp(float _X) __GPU_ONLY
7494 {
7495  return __dp_d3d_rcpf(_X);
7496 }
7497 
7507 inline unsigned int reversebits(unsigned int _X) __GPU_ONLY
7508 {
7509  return __dp_d3d_reversebitsu(_X);
7510 }
7511 
7521 inline float saturate(float _X) __GPU_ONLY
7522 {
7523  return __dp_d3d_saturatef(_X);
7524 }
7525 
7535 inline int sign(int _X) __GPU_ONLY
7536 {
7537  return __dp_d3d_signi(_X);
7538 }
7539 
7555 inline float smoothstep(float _Min, float _Max, float _X) __GPU_ONLY
7556 {
7557  return __dp_d3d_smoothstepf(_Min, _Max, _X);
7558 }
7559 
7572 inline float step(float _Y, float _X) __GPU_ONLY
7573 {
7574  return __dp_d3d_stepf(_Y, _X);
7575 }
7576 
7577 } // namespace Concurrency::direct3d
7578 
7579 } // namespace Concurrency
7580 
7581 #include <xxamp_inl.h>
7582 
7583 namespace concurrency = Concurrency;
7584 
7585 #pragma pack(pop)
7586 // End of file
int __dp_d3d_interlocked_min_int(_Inout_ int *, int) __GPU_ONLY
array(int _E0, int _E1, int _E2) __CPU_ONLY
Construct an array from three integer extents.
Definition: amp.h:3939
tiled_extent(const tiled_extent &_Other) __GPU
Copy constructor. Constructs a new tiled_extent from the supplied argument "_Other".
Definition: amp.h:1296
_Array_view_base(_In_ void *_Data, const Concurrency::extent< _Rank > &_Array_extent) __GPU_ONLY
Definition: amp.h:1821
void synchronize() const __CPU_ONLY
Synchronizes any modifications made to "this" array_view to its source data.
Definition: amp.h:3751
friend class accelerator
Definition: amprt.h:1444
static _Projection_result_type< _T, _R >::_Result_type _Project0(const array_view< _T, _R > *_Arr_view, int _I) __GPU
Definition: xxamp_inl.h:42
tiled_extent truncate() const __GPU
Returns a new tiled_extent with extents adjusted down to be evenly divisible by the tile dimensions...
Definition: amp.h:1499
array_view(const array< _Value_type, _Rank > &_Src) __GPU
Construct an array_view which is bound to the data contained in the _Src array. The extent of the arr...
Definition: amp.h:3067
_Buffer_descriptor _M_buffer_descriptor
Definition: amp.h:5752
accelerator_view get_source_accelerator_view() const
Returns the accelerator_view where the data source of the array_view is located. If the array_view do...
Definition: amp.h:2968
int __dp_d3d_firstbitlowi(int) __GPU_ONLY
array_view section(const Concurrency::index< _Rank > &_Idx) const __GPU
Produces a subsection of the source array_view with origin specified by an index, with an extent of (...
Definition: amp.h:3562
int atomic_fetch_or(_Inout_ int *_Dest, int _Value) __GPU_ONLY
Performs an atomic bitwise or operation of _Value to the memory location pointed to by _Dest ...
Definition: amp.h:6945
void refresh() const __CPU_ONLY
Informs the array_view that its bound memory has been modified outside the array_view interface...
Definition: amp.h:2836
array(int _E0, int _E1, int _E2, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array from three integer extents, bound to a specific accelerator_view.
Definition: amp.h:4039
_CPP_AMP_VERIFY_RANK(_Rank, index)
array_view section(int _I0, int _E0) const __GPU
Produces a one-dimensional subsection of the source array_view with origin specified by the index com...
Definition: amp.h:2734
index< _Rank > & operator-=(int _Rhs) __GPU
Subtracts an integer value from each element of this index.
Definition: amp.h:243
reference operator[](size_type _Pos)
Definition: array:140
Concurrency::extent< _Rank > _M_array_multiplier
Definition: amp.h:1669
void _Initialize(Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Definition: amp.h:5593
#define NULL
Definition: vcruntime.h:236
array(int _E0, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array initialized from an iterator into a container, bound to a specific accelerator_vie...
Definition: amp.h:4409
array_view< _Value_type, 3 > section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) __GPU
Produces a three-dimensional subsection of the source array with origin specified by the index compon...
Definition: amp.h:5383
array_view(int _E0, _Container &_Src) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container.
Definition: amp.h:2373
array(array &&_Other) __CPU_ONLY
Move constructor.
Definition: amp.h:4849
details::_Buffer_descriptor _Buffer_descriptor
Definition: amp.h:1685
float __dp_d3d_radiansf(float) __GPU_ONLY
unsigned int __dp_d3d_interlocked_add(_Inout_ unsigned int *, unsigned int) __GPU_ONLY
index operator--(int) __GPU
Post-decrements each element of this index.
Definition: amp.h:337
const unsigned int * _Get_base_extent() const
Definition: amprt.h:1601
int atomic_exchange(_Inout_ int *_Dest, int _Value) __GPU_ONLY
Sets the value of location pointed to by _Dest to _Value as an atomic operation
Definition: amp.h:6716
std::enable_if< details::_Is_extent_or_index< _Tuple_type< _Rank > >::value, bool >::type operator==(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:822
_Tuple_type _Create_uninitialized_tuple() __GPU
Definition: xxamp.h:214
index< _Rank > & operator++() __GPU
Pre-increments each element of this index.
Definition: amp.h:300
array_view() __GPU
Definition: amp.h:2994
details::_Projection_result_type< _Value_type, _Rank >::_Result_type operator[](int _I) __GPU
Projects the most-significant dimension of this array. If the array rank is 1, this produces a single...
Definition: amp.h:5016
void all_memory_fence(const tile_barrier &_Barrier) __GPU_ONLY
Memory fences and tile barriers.
Definition: amp.h:7178
array_view(int _E0, int _E1, int _E2, const _Container &_Src) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container.
Definition: amp.h:3241
const index< rank > global
An index that represents the global index within an extent.
Definition: amp.h:1013
constexpr auto size(const _Container &_Cont) -> decltype(_Cont.size())
Definition: xutility:1478
tiled_index< _Dim0, _Dim1 > _map_index(const index< rank > &_Local, const index< rank > &_Tile, const index< rank > &_Global, tile_barrier &_Barrier) const __GPU
Definition: amp.h:1435
_AMPIMP _Event _Add_continuation(const std::function< _Event __cdecl()> &_Continuation_task)
Creates an event which is an ordered collection of this and a continuation task
_AMPIMP _Access_mode __cdecl _Get_recommended_buffer_host_access_mode(const accelerator_view &_Av)
const _Value_type * data() const __GPU
Returns a pointer to the raw data of this array.
Definition: amp.h:5509
array_view section(int _I0, int _I1, int _E0, int _E1) const __GPU
Produces a two-dimensional subsection of the source array_view with origin specified by the index com...
Definition: amp.h:2759
array_view(const array_view &_Other) __GPU
Copy constructor. Shallow copy.
Definition: amp.h:2283
float __dp_d3d_madf(float, float, float) __GPU_ONLY
~_Array_view_shape() __GPU
Definition: amp.h:1568
const unsigned int * _Get_view_offset() const
Definition: amprt.h:1606
_Event _Get_access_async(const _View_key _Key, accelerator_view _Av, _Access_mode _Mode, _Buffer_ptr &_Buf_ptr)
Definition: amprt.h:3389
array_view< _Value_type, _Rank > section(const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Produces a subsection of the source array at the given origin and extent.
Definition: amp.h:5184
details::_Buffer_descriptor _Buffer_descriptor
Definition: amp.h:3868
void _Register_copy(const _Array_view_base &_Other) __CPU_ONLY
Definition: amp.h:2026
void _Register_copy(const _Array_view_base &) __GPU_ONLY
Definition: amp.h:2192
~array_view() __GPU
Destroys this array_view and reclaims resources.
Definition: amp.h:2265
Definition: amprt.h:91
index< _Rank > & operator+=(int _Rhs) __GPU
Adds an integer value to each element of this index.
Definition: amp.h:228
Definition: xxamp.h:242
extent< _Rank > & operator+=(int _Rhs) __GPU
Adds an integer value to each element of this extent.
Definition: amp.h:670
Definition: xxamp.h:236
unsigned int __dp_d3d_interlocked_xor(_Inout_ unsigned int *, unsigned int) __GPU_ONLY
array_view(int _E0) __CPU_ONLY
Construct an array_view which is not bound to a data source.
Definition: amp.h:2339
index< _Rank > & operator/=(int _Rhs) __GPU
Divides each element of this index by an integer value.
Definition: amp.h:273
index< _Rank > operator++(int) __GPU
Post-increments each element of this index.
Definition: amp.h:312
tiled_extent & operator=(const tiled_extent &_Other) __GPU
copy-assignment operator
Definition: amp.h:1471
array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array initialized from a pair of iterators into a container, bound to a specific acceler...
Definition: amp.h:4382
array_view(const _In_ _Value_type(&_Src)[_Size]) __GPU
Construct an array_view which is bound to the data contained in the _Src container; ...
Definition: amp.h:3199
_Array_view_base< _Rank, _New_element_size > _Reinterpret_as() const __GPU
Definition: amp.h:1922
int __dp_d3d_clampi(int, int, int) __GPU_ONLY
array_view< _Value_type2, _Rank > reinterpret_as() const __GPU
Produces a (possibly unsafe) reinterpretation of this array_view that is linear and with a different ...
Definition: amp.h:2804
unsigned int __dp_d3d_madu(unsigned int, unsigned int, unsigned int) __GPU_ONLY
_Value_type value_type
Definition: amp.h:2259
void _Register() __GPU_ONLY
Definition: amp.h:2190
array_view(const Concurrency::extent< _Rank > &_Extent) __CPU_ONLY
Construct an array_view which is not bound to a data source.
Definition: amp.h:2295
_eInitializeState
Definition: xxamp.h:208
_Array_view_base(const void *_Data, const Concurrency::extent< _Rank > &_Array_extent) __CPU_ONLY
Definition: amp.h:1827
extent< _Rank > operator-(const index< _Rank > &_Rhs) const __GPU
Element-wise subtraction of this extent with an index.
Definition: amp.h:594
static _Ret_ void * _Create_section_buffer_shape(const _Buffer_descriptor &_Descriptor, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __CPU_ONLY
Definition: amp.h:2119
const index< rank > tile
An index that represents the coordinates of the current tile of a tiled_extent.
Definition: amp.h:1023
void refresh() const __CPU_ONLY
Informs the array_view that its bound memory has been modified outside the array_view interface...
Definition: amp.h:3682
Definition: array:21
array_view< const _Value_type, _New_rank > view_as(const Concurrency::extent< _New_rank > &_View_extent) const __GPU
Produces an array_view of a different rank over this array_view's data.
Definition: amp.h:3664
void _Project0(int _I, _Array_view_base< _Rank-1, _Element_size > &_Projected_view) const __GPU
Definition: amp.h:1912
void _Refresh_data_ptr(_Access_mode, bool=true) __GPU_ONLY
Definition: amp.h:5742
array_view(const array_view &_Other, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Definition: amp.h:3798
tiled_extent & operator=(const tiled_extent &_Other) __GPU
copy-assignment operator
Definition: amp.h:1389
float noise(float _X) __GPU_ONLY
Generates a random value using the Perlin noise algorithm
Definition: amp.h:7465
array_view< _Value_type, 1 > section(int _I0, int _E0) __GPU
Produces a one-dimensional subsection of the source array with origin specified by the index componen...
Definition: amp.h:5283
unsigned int __dp_d3d_interlocked_or(_Inout_ unsigned int *, unsigned int) __GPU_ONLY
#define __GPU
Definition: amprt.h:45
std::enable_if< details::_Is_extent_or_index< _Tuple_type< _Rank > >::value, _Tuple_type< _Rank > >::type operator*(const _Tuple_type< _Rank > &_Lhs, typename _Tuple_type< _Rank >::value_type _Rhs) __GPU
Definition: amp.h:890
_Array_view_base< _New_rank, _Element_size > _View_as(const Concurrency::extent< _New_rank > &_View_extent) const __GPU
Definition: amp.h:1932
Concurrency::extent< _Rank > _M_multiplier
Definition: amp.h:5755
Definition: xxamp.h:238
index< _Rank > & operator--() __GPU
Pre-decrements each element of this index.
Definition: amp.h:325
array_view< const _Value_type, _Rank > section(const Concurrency::extent< _Rank > &_Ext) const __GPU
Produces a subsection of the source array_view with origin of zero, with an extent of _Ext...
Definition: amp.h:5233
array(const array &_Other) __CPU_ONLY
Copy constructor. Deep copy.
Definition: amp.h:4839
tiled_extent() __GPU
Default constructor.
Definition: amp.h:1285
tiled_extent pad() const __GPU
Returns a new tiled_extent with extents adjusted up to be evenly divisible by the tile dimensions...
Definition: amp.h:1408
_In_ int _Val
Definition: vcruntime_string.h:62
int __dp_d3d_maxi(int, int) __GPU_ONLY
Class represents a virtual device abstraction on a C++ AMP data-parallel accelerator ...
Definition: amprt.h:1442
index< _Rank > & operator-=(const index< _Rank > &_Rhs) __GPU
Element-wise subtraction of this index with another index.
Definition: amp.h:213
_Array_view_shape(const _Array_view_shape &_Other) __GPU
Definition: amp.h:1576
_AMPIMP std::pair< accelerator_view, accelerator_view > __cdecl _Get_src_dest_accelerator_view(_In_opt_ const _Buffer_descriptor *_SrcBuffDescPtr, _In_opt_ const _Buffer_descriptor *_DestBuffDescPtr)
extent< _Rank > & operator++() __GPU
Pre-increments each element of this extent.
Definition: amp.h:742
bool _Local() const _NOEXCEPT
Definition: functional:419
static _AMPIMP _Ret_ IUnknown *__cdecl _Get_D3D_buffer(_In_ _Buffer *_Buffer_ptr)
void _Project0(int _I, array_view< const _Value_type, _Rank-1 > &_Projected_view) const __GPU
Definition: amp.h:3790
int firstbitlow(int _X) __GPU_ONLY
Gets the location of the first set bit in _X, starting from the lowest order bit and working upward ...
Definition: amp.h:7303
_Array_view_base(const _Buffer_descriptor &_Buffer_desc, int _Base_linear_offset, const Concurrency::extent< _Rank > &_Array_extent, const Concurrency::index< _Rank > &_View_offset, const Concurrency::extent< _Rank > &_View_extent) __GPU_ONLY
Definition: amp.h:1769
static _AMPIMP _Ret_ _View_shape *__cdecl _Create_view_shape(unsigned int _Rank, unsigned int _Linear_offset, const unsigned int *_Base_extent, const unsigned int *_View_offset, const unsigned int *_View_extent, const bool *_Projection_info=NULL)
array_view< _Value_type2, 1 > reinterpret_as() __GPU
Produces a (possibly unsafe) reinterpretation of this array that is linear and with a different eleme...
Definition: amp.h:5427
The Concurrency namespace provides classes and functions that provide access to the Concurrency Runti...
Definition: agents.h:43
Class represents a future corresponding to a C++ AMP asynchronous operation
Definition: amprt.h:1266
array_view< const _Value_type, 3 > section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU
Produces a three-dimensional subsection of the source array with origin specified by the index compon...
Definition: amp.h:5414
static void _Is_valid_extent(const _T< _Rank > &_Tuple) __CPU_ONLY
Definition: xxamp.h:1195
bool _Is_valid_access_mode(_Access_mode _Mode)
Definition: amprt.h:417
unsigned int size() const __GPU
Returns the total linear size of this extent (in units of elements).
Definition: amp.h:521
unsigned int __dp_d3d_maxu(unsigned int, unsigned int) __GPU_ONLY
float __dp_d3d_smoothstepf(float, float, float) __GPU_ONLY
void _Project0(int _I, array_view< _Value_type, _Rank-1 > &_Projected_view) const __GPU
Definition: amp.h:2988
extent< _Rank > & operator--() __GPU
Pre-decrements each element of this extent.
Definition: amp.h:767
array_view(const Concurrency::extent< _Rank > &_Extent, _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:2327
unsigned int umax(unsigned int _X, unsigned int _Y) __GPU_ONLY
Determine the maximum numeric value of the arguments
Definition: amp.h:7354
concurrency::completion_future synchronize_to_async(const accelerator_view &_Accl_view) const __CPU_ONLY
Asynchronously synchronizes any modifications made to "this" array_view to the specified accelerator_...
Definition: amp.h:3697
A _Tiled_index_base is the base class of all three kinds of tiled_index to share the common code...
Definition: amp.h:1002
array< _Value_type, _Rank > make_array(const Concurrency::extent< _Rank > &_Extent, const Concurrency::accelerator_view &_Av, _In_ IUnknown *_D3D_buffer) __CPU_ONLY
Create an array from a D3D buffer interface pointer.
Definition: amp.h:6522
float __dp_d3d_clampf(float, float, float) __GPU_ONLY
array_view(int _E0, int _E1, int _E2) __CPU_ONLY
Construct an array_view which is not bound to a data source.
Definition: amp.h:2429
array_view section(int _I0, int _I1, int _E0, int _E1) const __GPU
Produces a two-dimensional subsection of the source array_view with origin specified by the index com...
Definition: amp.h:3605
static _Ret_ void * _Create_section_buffer_shape(const _Buffer_descriptor &, const Concurrency::index< _Rank > &, const Concurrency::extent< _Rank > &) __GPU_ONLY
Definition: amp.h:2209
array(const Concurrency::extent< _Rank > &_Extent, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array initialized from an iterator into a container, bound to a specific accelerator_vie...
Definition: amp.h:4351
tiled_extent(const Concurrency::extent< rank > &_Other) __GPU
Constructs a new tiled_extent from the supplied extent.
Definition: amp.h:1459
double __dp_d3d_madd(double, double, double) __GPU_ONLY
const bool * _Get_projection_info() const
Definition: amprt.h:1615
void __dp_d3d_tile_static_memory_fence_with_tile_barrier() __GPU_ONLY
_Array_flatten_helper< _Rank, typename Concurrency::extent< _Rank >::value_type, typename Concurrency::index< _Rank >::value_type > _Flatten_helper
Definition: amp.h:3869
array(int _E0) __CPU_ONLY
Construct array with the extent _E0
Definition: amp.h:3904
_Buffer_descriptor _M_buffer_descriptor
Definition: amp.h:2003
float rcp(float _X) __GPU_ONLY
Calculates a fast, approximate reciprocal of the argument
Definition: amp.h:7493
_Ret_ _View_shape * _Create_buffer_view_shape() const __CPU_ONLY
Definition: amp.h:1942
_Ret_ _View_shape * _Create_buffer_view_shape() const
Definition: amp.h:5690
integral_constant< bool, false > false_type
Definition: xtr1common:41
array_view(array< _Value_type, _Rank > &_Src) __GPU
Construct an array_view which is bound to the data contained in the _Src array. The extent of the arr...
Definition: amp.h:2274
_Array_view_base(const _Array_view_base &_Other, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Definition: amp.h:1727
array_view(const array_view< _Value_type, _Rank > &_Src) __GPU
Copy constructor. Shallow copy.
Definition: amp.h:3076
Definition: xxamp.h:240
_AMPIMP void _Register_view(_In_ _View_key _Key, accelerator_view _Cpu_av, _View_shape_ptr _Shape, _In_opt_ const _View_key _Source_view_key=nullptr)
array(int _E0, accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view.
Definition: amp.h:4076
_Tiled_index_base & operator=(const _Tiled_index_base &) __GPU
array(const array_view< const _Value_type, _Rank > &_Src, accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array initialized from an array_view, bound to a specific accelerator_view.
Definition: amp.h:4810
A tiled_index is a set of indices of 1 to 3 dimensions which have been subdivided into 1-...
Definition: amp.h:1096
_AMPIMP bool __cdecl _Is_D3D_accelerator_view(const accelerator_view &_Av)
_AMPIMP void _Get()
Wait until the _Event completes and throw any exceptions that occur.
array(const Concurrency::extent< _Rank > &_Extent, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array initialized from a pair of iterators into a container, bound to a specific acceler...
Definition: amp.h:4325
unsigned int
Definition: vccorlib.h:2468
extent(const int _Array[_Rank]) __GPU
Constructs an extent with the coordinate values provided the array of int component values...
Definition: amp.h:476
_AMPIMP _Ret_ _Amp_runtime_trace *__cdecl _Get_amp_trace()
int atomic_fetch_dec(_Inout_ int *_Dest) __GPU_ONLY
Performs an atomic decrement to the memory location pointed to by _Dest
Definition: amp.h:6673
concurrency::completion_future synchronize_async(access_type _Access_type=access_type_read) const __CPU_ONLY
Asynchronously synchronizes any modifications made to "this" array_view to its source data...
Definition: amp.h:2885
array(const Concurrency::extent< _Rank > &_Extent) __CPU_ONLY
Construct an array from extents
Definition: amp.h:3892
_Array_view_base(const _Buffer_descriptor &_Buffer_desc, const Concurrency::extent< _Rank > &_Array_extent) __GPU
Definition: amp.h:1736
tiled_index(const tiled_index &_Other) __GPU
Copy Constructor.
Definition: amp.h:1131
Definition: amprt.h:93
unsigned int reversebits(unsigned int _X) __GPU_ONLY
Reverses the order of the bits in _X
Definition: amp.h:7507
void wait_with_all_memory_fence() const __GPU_ONLY
Blocks execution of all threads in a tile until all all threads in the tile have reached this call...
Definition: amp.h:974
#define UINT_MAX
Definition: limits.h:36
extent() __GPU
Default constructor. The value at each dimension is initialized to zero.
Definition: amp.h:404
const unsigned int * _Get_view_extent() const
Definition: amprt.h:1610
static _AMPIMP const wchar_t cpu_accelerator[]
String constant for cpu accelerator
Definition: amprt.h:1035
extent< _Rank > & operator%=(int _Rhs) __GPU
Modulus an integer value from each element of this extent.
Definition: amp.h:730
_Array_view_shape(int _Base_linear_offset, const Concurrency::extent< _Rank > &_Array_extent) __GPU
Definition: amp.h:1599
array_view & operator=(const array_view< _Value_type, _Rank > &_Other) __GPU
Copy Assignment operator. Shallow copy.
Definition: amp.h:3381
void _Initialize(Concurrency::accelerator_view _Av, access_type _Cpu_access_type) __CPU_ONLY
Definition: amp.h:5572
static void _Is_valid_section(const _T2< _Rank > &_Base_extent, const _T1< _Rank > &_Section_origin, const _T2< _Rank > &_Section_extent) __CPU_ONLY
Definition: xxamp.h:1106
int atomic_fetch_max(_Inout_ int *_Dest, int _Value) __GPU_ONLY
Atomically computes the maximum of _Value and the value of the memory location pointed to by _Dest...
Definition: amp.h:6836
void _Initialize(size_t _Src_data_size, bool _Discard_data=false) __CPU_ONLY
Definition: amp.h:3014
_Array_view_base< _Rank, sizeof(_Value_type)/sizeof(int)> _Base
Definition: amp.h:3036
_Iter_diff_t< _InIt > distance(_InIt _First, _InIt _Last)
Definition: xutility:1124
The tile_barrier class is a capability class that is only creatable by the system, and passed to a tiled parallel_for_each lambda as part of the tiled_index parameter. It provides wait methods whose purpose is to synchronize execution of threads running within the thread group (tile).
Definition: amp.h:948
array(int _E0, int _E1, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view, initialized from an iterator into ...
Definition: amp.h:4706
_AMPIMP _Event _Add_event(_Event _Ev)
Creates an event which is an ordered collection of this and _Ev
#define AS_UINT(v)
Definition: amp.h:6547
index< _Rank > & operator*=(int _Rhs) __GPU
Multiplies each element of this index with an integer value.
Definition: amp.h:258
_Ret_ _Value_type * data() __GPU
Returns a pointer to the raw data of this array.
Definition: amp.h:5500
index(int _I0, int _I1) __GPU
Constructor for index<2>
Definition: amp.h:110
void __dp_d3d_tile_static_memory_fence() __GPU_ONLY
extent< _Rank > & operator/=(int _Rhs) __GPU
Divides an integer value into each element of this extent.
Definition: amp.h:715
void _Initialize(Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
Definition: amp.h:5628
array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
Construct an array initialized from a pair of iterators into a container.
Definition: amp.h:4179
int i[4]
Definition: dvec.h:68
std::enable_if< details::_Is_extent_or_index< _Tuple_type< _Rank > >::value, _Tuple_type< _Rank > >::type operator-(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:845
array_view(const Concurrency::extent< _Rank > &_Extent, _In_ _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:3169
array_view< _Value_type, _Rank > section(const index< _Rank > &_Idx) __GPU
Produces a subsection of the source array with origin specified by an index, with an extent of (this-...
Definition: amp.h:5248
array(int _E0, int _E1, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array from two integer extents, bound to a specific accelerator_view.
Definition: amp.h:4010
_Array_view_base() __GPU
Definition: amp.h:1695
index() __GPU
Default constructor, initializes all elements with 0.
Definition: amp.h:73
concurrency::completion_future synchronize_to_async(const accelerator_view &_Accl_view, access_type _Access_type=access_type_read) const __CPU_ONLY
Asynchronously synchronizes any modifications made to "this" array_view to the specified accelerator_...
Definition: amp.h:2861
array_view(const Concurrency::extent< _Rank > &_Extent, _Container &_Src) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container.
Definition: amp.h:2310
void copy_to(const array_view< _Value_type, _Rank > &_Dest) const __CPU_ONLY
Copies elements from this array_view to the destination array_view.
Definition: amp.h:3398
tiled_extent & operator=(const tiled_extent &_Other) __GPU
copy-assignment operator
Definition: amp.h:1302
int sign(int _X) __GPU_ONLY
Returns the sign of the argument
Definition: amp.h:7535
void direct3d_printf(const char *,...) __GPU_ONLY
_Access_mode _M_curr_cpu_access_mode
Definition: amprt.h:450
_Array_view_base(const Concurrency::extent< _Rank > &_Array_extent) __CPU_ONLY
Definition: amp.h:1794
#define _In_
Definition: sal.h:305
Definition: xxamp.h:243
index< _Rank > & operator+=(const index< _Rank > &_Rhs) __GPU
Element-wise addition of this index with another index.
Definition: amp.h:198
void _Refresh_data_ptr(_Access_mode _Requested_mode, bool _Exception=true) __CPU_ONLY
Definition: amp.h:5708
index< _Rank > & operator%=(int _Rhs) __GPU
Modulus an integer value into each element of this index.
Definition: amp.h:288
int _Base_linear_offset() const __GPU
Definition: amp.h:1571
std::enable_if< details::_Is_extent_or_index< _Tuple_type< _Rank > >::value, _Tuple_type< _Rank > >::type operator+(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:836
unsigned int __dp_d3d_reversebitsu(unsigned int) __GPU_ONLY
array(const array_view< const _Value_type, _Rank > &_Src) __CPU_ONLY
Construct an array initialized from an array_view.
Definition: amp.h:4787
Concurrency::extent< _Rank > _M_view_extent
Definition: amp.h:1672
tiled_extent(const Concurrency::extent< rank > &_Other) __GPU
Constructs a new tiled_extent from the supplied extent.
Definition: amp.h:1290
void _Initialize() __GPU
Definition: amp.h:3805
int __dp_d3d_mini(int, int) __GPU_ONLY
float __dp_d3d_rcpf(float) __GPU_ONLY
#define _In_opt_
Definition: sal.h:306
static _Ret_ void * _Create_projection_buffer_shape(const _Buffer_descriptor &, int, int) __GPU_ONLY
Definition: amp.h:2204
unsigned int _Initialize() __CPU_ONLY
Definition: amp.h:5558
array_view< const _Value_type, _New_rank > view_as(const Concurrency::extent< _New_rank > &_View_extent) const __GPU
Produces an array_view of a different rank over this array's data.
Definition: amp.h:5474
tiled_extent(const tiled_extent &_Other) __GPU
Copy constructor. Constructs a new tiled_extent from the supplied argument "_Other".
Definition: amp.h:1383
void synchronize(access_type _Access_type=access_type_read) const __CPU_ONLY
Synchronizes any modifications made to "this" array_view to its source data.
Definition: amp.h:2934
tiled_extent< _Dim0 > tile() const __GPU
Produces a tiled_extent object with the tile extents given by _Dim0.
Definition: amp.h:537
bool _Has_cpu_access() const __CPU_ONLY
Definition: amp.h:5703
#define __CPU_ONLY
Definition: amprt.h:47
void _Unregister(bool _Throw_exception=true) __CPU_ONLY
Definition: amp.h:2056
void synchronize_to(const accelerator_view &_Accl_view, access_type _Access_type=access_type_read) const __CPU_ONLY
Synchronizes any modifications made to "this" array_view to the specified accelerator_view.
Definition: amp.h:2914
void _Initialize_multiplier() __GPU
Definition: amp.h:1660
void _Register() __CPU_ONLY
Definition: amp.h:5634
_Ret_ _Ubiquitous_buffer * _Get_buffer() const __CPU_ONLY
Definition: amp.h:5664
tiled_extent(const tiled_extent &_Other) __GPU
Copy constructor. Constructs a new tiled_extent from the supplied argument "_Other".
Definition: amp.h:1465
array(int _E0, _InputIterator _Src_first) __CPU_ONLY
Construct an array initialized from an iterator.
Definition: amp.h:4196
int value_type
Definition: amp.h:68
__declspec(deprecated("Concurrency::EnableTracing is a deprecated function.")) _CONCRTIMP HRESULT __cdecl EnableTracing()
Enables tracing in the Concurrency Runtime. This function is deprecated because ETW tracing is now on...
array_view< _Value_type, _Rank > section(const Concurrency::extent< _Rank > &_Ext) __GPU
Produces a subsection of the source array_view with origin of zero, with an extent of _Ext...
Definition: amp.h:5218
tiled_index< _Dim0, _Dim1, _Dim2 > _map_index(const index< rank > &_Local, const index< rank > &_Tile, const index< rank > &_Global, tile_barrier &_Barrier) const __GPU
Definition: amp.h:1351
Exception thrown due to a C++ AMP runtime_exception. This is the base type for all C++ AMP exception ...
Definition: amprt_exceptions.h:29
array_view section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU
Produces a three-dimensional subsection of the source array_view with origin specified by the index c...
Definition: amp.h:2790
_CPP_AMP_VERIFY_RANK(_Rank, extent)
Concurrency::extent< _Rank > _M_extent
Definition: amp.h:5749
extent< _Rank > operator+(const index< _Rank > &_Rhs) const __GPU
Element-wise addition of this extent with an index.
Definition: amp.h:578
static void _Is_valid_projection(int _I, const _T1< _Rank > &_Base_extent) __CPU_ONLY
Definition: xxamp.h:1131
array(const Concurrency::extent< _Rank > &_Extent, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array from extents, bound to a specific accelerator_view.
Definition: amp.h:3962
_Event _Get_access_async(_Access_mode _Mode, _Buffer_ptr &_Buf_ptr, bool _Zero_copy_cpu_access=false) const __CPU_ONLY
Definition: amp.h:5669
struct Concurrency::details::_Buffer_descriptor _Buffer_descriptor
extent< _Rank > & operator+=(const extent< _Rank > &_Rhs) __GPU
Element-wise addition of this extent with another extent.
Definition: amp.h:610
float saturate(float _X) __GPU_ONLY
Clamps _X within the range of 0 to 1
Definition: amp.h:7521
_AMPIMP accelerator __cdecl _Select_default_accelerator()
void parallel_for_each(const extent< _Rank > &_Compute_domain, const _Kernel_type &_Kernel)
Invokes a parallel computation of a kernel function over a compute domain on an accelerator_view. The accelerator_view is determined from the arrays and/or array_views captured by the kernel function, or if no accelerator_view can be derived, the default is chosen.
Definition: amp.h:7020
unsigned int _Get_linear_offset() const
Definition: amprt.h:1596
_Ret_ void * _Access(_Access_mode _Requested_mode, const index< _Rank > &_Index) const __CPU_ONLY
Definition: amp.h:1882
array(int _E0, int _E1, int _E2, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
Construct an array initialized from an iterator.
Definition: amp.h:4269
_Array_view_base(const _Buffer_descriptor &_Buffer_desc, int _Base_linear_offset, const Concurrency::extent< _Rank > &_Array_extent) __GPU
Definition: amp.h:1745
_Array_flatten_helper< _Rank, typename Concurrency::extent< _Rank >::value_type, typename Concurrency::index< _Rank >::value_type > _Flatten_helper
Definition: amp.h:1555
_Ret_ IUnknown * get_buffer(const array< _Value_type, _Rank > &_Array) __CPU_ONLY
Get the D3D buffer interface underlying an array.
Definition: amp.h:6494
tiled_extent() __GPU
Default constructor.
Definition: amp.h:1372
static void func(_RES_EXT &_ResArrayExtent, const _SRC_EXT &_SrcArrayExtent, _RES_EXT &_ResArrayMultiplier, const _SRC_EXT &_SrcArrayMultiplier, _RES_IDX &_ResViewOffset, const _SRC_IDX &_SrcViewOffset, _RES_EXT &_ResViewExtent, const _SRC_EXT &_SrcViewExtent) __GPU
Definition: xxamp.h:768
array_view< const _Value_type, 1 > section(int _I0, int _E0) const __GPU
Produces a one-dimensional subsection of the source array with origin specified by the index componen...
Definition: amp.h:5302
void synchronize_to(const accelerator_view &_Accl_view) const __CPU_ONLY
Synchronizes any modifications made to "this" array_view to the specified accelerator_view.
Definition: amp.h:3737
_AMPIMP _Buffer_ptr _Get_master_buffer() const
extent< _Rank > & operator+=(const index< _Rank > &_Rhs) __GPU
Element-wise addition of this extent with an index.
Definition: amp.h:640
const _Value_type * data() const __GPU
Returns a pointer to the raw data of this array_view.
Definition: amp.h:3672
array_view< const _Value_type, _Rank > section(const index< _Rank > &_Idx) const __GPU
Produces a subsection of the source array with origin specified by an index, with an extent of (this-...
Definition: amp.h:5264
tiled_index(const tiled_index &_Other) __GPU
Copy Constructor.
Definition: amp.h:1246
int atomic_fetch_xor(_Inout_ int *_Dest, int _Value) __GPU_ONLY
Performs an atomic bitwise xor operation of _Value to the memory location pointed to by _Dest ...
Definition: amp.h:6981
tiled_extent(const Concurrency::extent< rank > &_Other) __GPU
Constructs a new tiled_extent from the supplied extent.
Definition: amp.h:1377
array_view(int _E0, int _E1, int _E2, _In_ _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:2525
array_view section(const Concurrency::extent< _Rank > &_Ext) const __GPU
Produces a subsection of the source array_view with origin of zero, with an extent of _Ext...
Definition: amp.h:2716
_Tiled_index_base(const _Tiled_index_base &_Other) __GPU
Copy Constructor.
Definition: amp.h:1067
array(int _E0, int _E1, int _E2, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view, initialized from a pair of iterato...
Definition: amp.h:4741
void copy_to(const array_view< _Value_type, _Rank > &_Dest) const __CPU_ONLY
Copies elements from this array to the destination array_view.
Definition: amp.h:4922
_Ret_ _Ubiquitous_buffer * _Get_buffer(const _Array_type &_Array) __CPU_ONLY
Definition: xxamp.h:1069
unsigned int umin(unsigned int _X, unsigned int _Y) __GPU_ONLY
Determine the minimum numeric value of the arguments
Definition: amp.h:7371
array(const Concurrency::extent< _Rank > &_Extent, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view, initialized from a pair of iterato...
Definition: amp.h:4576
_AMPIMP void _Register_view_copy(_In_ _View_key _New_view_key, _In_ _View_key _Existing_view_key)
_Tiled_index_base(const index< rank > &_Global, const index< rank > &_Local, const index< rank > &_Tile, const index< rank > &_Tile_origin, const tile_barrier &_Barrier) __GPU
A Constructor that initializes data members using the given values.
Definition: amp.h:1053
unsigned int countbits(unsigned int _X) __GPU_ONLY
Counts the number of set bits in _X
Definition: amp.h:7275
void copy_to(array< _Value_type, _Rank > &_Dest) const __CPU_ONLY
Copies elements from this array_view to the destination array.
Definition: amp.h:2544
array(const Concurrency::extent< _Rank > &_Extent, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
Construct an array initialized from a pair of iterators into a container.
Definition: amp.h:4142
_Array_view_base(const _Buffer_descriptor &_Buffer_desc, int _Base_linear_offset, const Concurrency::extent< _Rank > &_Array_extent, const Concurrency::index< _Rank > &_View_offset, const Concurrency::extent< _Rank > &_View_extent) __CPU_ONLY
Definition: amp.h:1754
unsigned int mad(unsigned int _X, unsigned int _Y, unsigned int _Z) __GPU_ONLY
Performs an arithmetic multiply/add operation on three arguments: _X * _Y + _Z
Definition: amp.h:7451
tiled_extent< _Dim0, _Dim1, _Dim2 > tile() const __GPU
Produces a tiled_extent object with the tile extents given by _Dim0, _Dim1, _Dim2.
Definition: amp.h:559
~array_view() __GPU
Destroys this array_view and reclaims resources.
Definition: amp.h:3058
int __dp_d3d_absi(int) __GPU_ONLY
#define false
Definition: stdbool.h:16
array_view< const _Value_type2, _Rank > reinterpret_as() const __GPU
Produces a (possibly unsafe) reinterpretation of this array_view that is linear and with a different ...
Definition: amp.h:3650
void direct3d_abort() __GPU_ONLY
void __dp_d3d_all_memory_fence() __GPU_ONLY
extent(int _I) __GPU
Constructor for extent<1>.
Definition: amp.h:426
unsigned int __dp_d3d_interlocked_and(_Inout_ unsigned int *, unsigned int) __GPU_ONLY
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) __CPU_ONLY
Construct an array initialized from a pair of iterators into a container, bound to a specific acceler...
Definition: amp.h:4514
array_view(_In_ _Value_type(&_Src)[_Size]) __GPU
Construct an array_view which is bound to the array _Src.
Definition: amp.h:2482
array_view(const Concurrency::extent< _Rank > &_Extent, _Container &_Src) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container.
Definition: amp.h:3136
void copy_to(array< _Value_type, _Rank > &_Dest) const __CPU_ONLY
Copies elements from this array to the destination array.
Definition: amp.h:4914
_AMPIMP void _Unregister_view(_In_ _View_key _Key)
void __dp_d3d_all_memory_fence_with_tile_barrier() __GPU_ONLY
array_view(int _E0, int _E1, const _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:3279
const tile_barrier barrier
An object which represents a barrier within the current tile of threads.
Definition: amp.h:1033
_Ret_ _View_key _Get_view_key()
Definition: amprt.h:537
const index< rank > tile_origin
An index that represents the global coordinates of the origin of the current tile within a tiled_exte...
Definition: amp.h:1028
array_view section(const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) const __GPU
Produces a subsection of the source array_view at the given origin and extent.
Definition: amp.h:3532
array_view section(const Concurrency::extent< _Rank > &_Ext) const __GPU
Produces a subsection of the source array_view with origin of zero, with an extent of _Ext...
Definition: amp.h:3547
Concurrency::extent< _Rank > _M_array_extent
Definition: amp.h:1668
accelerator_view get_source_accelerator_view() const
Returns the accelerator_view where the data source of the array_view is located. If the array_view do...
Definition: amp.h:3770
The extent type represents an N-dimensional vector of int which specifies the bounds of an N-dimen...
Definition: amp.h:383
void _Register(_In_opt_ const _View_key _Source_view_key=nullptr) __CPU_ONLY
Definition: amp.h:2007
~_Array_view_base() __GPU
Definition: amp.h:1687
_Array_view_base< _Rank, sizeof(_Value_type)/sizeof(int)> _Base
Definition: amp.h:2238
An array is a multi-dimensional data aggregate on a accelerator_view.
Definition: amp.h:3865
_Array_flatten_helper< _Rank, typename Concurrency::extent< _Rank >::value_type, typename Concurrency::index< _Rank >::value_type > _Flatten_helper
Definition: amp.h:1678
void direct3d_errorf(const char *,...) __GPU_ONLY
void discard_data() const __CPU_ONLY
Discards the current data underlying this view. This is an optimization hint to the runtime used to a...
Definition: amp.h:2959
#define AS_INT(v)
Definition: amp.h:6548
extent(int _I0, int _I1, int _I2) __GPU
Constructor for extent<3>
Definition: amp.h:460
int abs(int _X) __GPU_ONLY
Returns the absolute value of the argument
Definition: amp.h:7221
index(const int _Array[_Rank]) __GPU
Constructs an index with the coordinate values provided the array of int component values...
Definition: amp.h:145
void _Unregister(bool=true) __GPU_ONLY
Definition: amp.h:2200
array_view(const _Container &_Src, typename std::enable_if< details::_Is_container< _Container >::type::value, void ** >::type=0) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container; ...
Definition: amp.h:3116
int __dp_d3d_madi(int, int, int) __GPU_ONLY
_AMPIMP ULONG _Launch_async_copy_event_helper(const _Buffer_descriptor &_Src, const _Buffer_descriptor &_Dest, ULONGLONG _Num_bytes_for_copy)
void _Register_copy(const array &_Other) __CPU_ONLY
Definition: amp.h:5651
int value_type
Definition: amp.h:398
unsigned int __dp_d3d_interlocked_min_uint(_Inout_ unsigned int *, unsigned int) __GPU_ONLY
index(const index< _Rank > &_Other) __GPU
Copy Constructor.
Definition: amp.h:84
array(int _E0, int _E1, int _E2, _InputIterator _Src_first) __CPU_ONLY
Construct an array initialized from an iterator.
Definition: amp.h:4292
void * _M_data_ptr
Definition: amprt.h:438
array(const Concurrency::extent< _Rank > &_Extent, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view.
Definition: amp.h:4058
_Array_view_shape(int _Base_linear_offset, const Concurrency::extent< _Rank > &_Array_extent, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Definition: amp.h:1609
unsigned int __dp_d3d_interlocked_exchange(_Inout_ unsigned int *, unsigned int) __GPU_ONLY
Definition: amprt.h:94
_Ret_ _View_shape * _Get_buffer_view_shape(const _Buffer_descriptor &_Descriptor)
Definition: amprt.h:3395
array_view & operator=(const array_view &_Other) __GPU
Copy Assignment operator. Shallow copy.
Definition: amp.h:3372
int imin(int _X, int _Y) __GPU_ONLY
Determine the minimum numeric value of the arguments
Definition: amp.h:7337
array(int _E0, int _E1, int _E2, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view.
Definition: amp.h:4123
_Access_mode
Definition: amprt.h:88
array(int _E0, int _E1, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
Construct an array initialized from a pair of iterators into a container.
Definition: amp.h:4222
tiled_extent() __GPU
Default constructor.
Definition: amp.h:1454
array(int _E0, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av)
Construct a staging array between two associated accelerator_view, initialized from an iterator into ...
Definition: amp.h:4648
const _Buffer_descriptor & _Get_buffer_descriptor(const _Array_type &_Array) __GPU
Definition: xxamp.h:1063
array_view(const array_view &_Other, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Definition: amp.h:2996
const index< rank > local
An index that represents the relative index within the current tile of a tiled_extent.
Definition: amp.h:1018
array(int _E0, int _E1, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view, initialized from a pair of iterato...
Definition: amp.h:4680
constexpr auto data(_Container &_Cont) -> decltype(_Cont.data())
Definition: xutility:1513
Definition: xxamp.h:710
float radians(float _X) __GPU_ONLY
Converts _X from degrees to radians
Definition: amp.h:7479
_AMPIMP ULONG _Launch_array_view_synchronize_event_helper(const _Buffer_descriptor &_Buff_desc)
extent< _Rank > operator++(int) __GPU
Post-increments each element of this extent.
Definition: amp.h:754
_AMPIMP ULONG _Start_copy_event_helper(const _Buffer_descriptor &_Src, const _Buffer_descriptor &_Dest, ULONGLONG _Num_bytes_for_copy)
float smoothstep(float _Min, float _Max, float _X) __GPU_ONLY
Returns a smooth Hermite interpolation between 0 and 1, if _X is in the range [_Min, _Max].
Definition: amp.h:7555
tiled_extent pad() const __GPU
Returns a new tiled_extent with extents adjusted up to be evenly divisible by the tile dimensions...
Definition: amp.h:1490
_Array_view_base(_In_ void *_Data, const Concurrency::extent< _Rank > &_Array_extent) __CPU_ONLY
Definition: amp.h:1805
tiled_index(const index< rank > &_Global, const index< rank > &_Local, const index< rank > &_Tile, const index< rank > &_Tile_origin, const tile_barrier &_Barrier) __GPU
A Constructor that initializes data members using the given values.
Definition: amp.h:1117
int clamp(int _X, int _Min, int _Max) __GPU_ONLY
Clamps _X to the specified _Min and _Max range
Definition: amp.h:7261
array_view(int _E0, _In_ _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:2469
tiled_extent< _Dim0, _Dim1 > tile() const __GPU
Produces a tiled_extent object with the tile extents given by _Dim0, _Dim1
Definition: amp.h:548
_Array_view_shape & operator=(const _Array_view_shape &_Other) __GPU
Definition: amp.h:1623
_Ret_ _Value_type * data() const __GPU
Returns a pointer to the raw data of this array_view.
Definition: amp.h:2826
extent< _Rank > & operator-=(int _Rhs) __GPU
Subtracts an integer value from each element of this extent.
Definition: amp.h:685
int operator[](unsigned int _Index) const __GPU
Index operator.
Definition: amp.h:499
_Array_view_base(const _Buffer_descriptor &_Buffer_desc, const Concurrency::extent< _Rank > &_Array_extent, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Definition: amp.h:1784
#define _CPP_AMP_VERIFY_MUTABLE_ITERATOR(_Type_name)
Definition: xxamp.h:27
void copy(const array< _Value_type, _Rank > &_Src, array< _Value_type, _Rank > &_Dest)
Copies the contents of the source array into the destination array.
Definition: amp.h:6008
Definition: xxamp.h:228
int _M_total_linear_offset
Definition: amp.h:1671
array_view(int _E0, const _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:3259
array_view(int _E0, const _Container &_Src) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container.
Definition: amp.h:3184
float __dp_d3d_saturatef(float) __GPU_ONLY
Definition: amprt.h:109
~array() __CPU_ONLY noexcept(false)
Destroys this array and reclaims resources.
Definition: amp.h:5525
A tiled_extent is an extent of 1 to 3 dimensions which also subdivides the extent space into 1-...
Definition: amp.h:1274
int _M_base[_Rank]
Definition: amp.h:359
Definition: xxamp.h:244
int atomic_fetch_and(_Inout_ int *_Dest, int _Value) __GPU_ONLY
Performs an atomic bitwise and operation of _Value to the memory location pointed to by _Dest ...
Definition: amp.h:6908
void advance(_InIt &_Where, _Diff _Off)
Definition: xutility:1089
array_view< const _Value_type, _Rank > section(const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) const __GPU
Produces a subsection of the source array at the given origin and extent.
Definition: amp.h:5202
array_view(int _E0, int _E1, const _Container &_Src) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container.
Definition: amp.h:3218
extent(int _I0, int _I1) __GPU
Constructor for extent<2>
Definition: amp.h:441
array(int _E0, int _E1, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array initialized from an iterator into a container, bound to a specific accelerator_vie...
Definition: amp.h:4475
_AMPIMP ULONG _Start_array_view_synchronize_event_helper(const _Buffer_descriptor &_Buff_desc)
array_view(int _E0, int _E1, int _E2, const _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:3302
array_view< const _Value_type2, 1 > reinterpret_as() const __GPU
Produces a (possibly unsafe) reinterpretation of this array that is linear and with a different eleme...
Definition: amp.h:5439
int _Calculate_reinterpreted_size(int _Old_size) __GPU_ONLY
Definition: amp.h:1527
array_view(_Buffer_descriptor &_Src_buffer, const Concurrency::extent< _Rank > &_Extent) __GPU
Definition: amp.h:3002
void _Unregister() __CPU_ONLY
Definition: amp.h:5656
array(int _E0, int _E1, int _E2, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array initialized from an iterator into a container, bound to a specific accelerator_vie...
Definition: amp.h:4547
array_view section(int _I0, int _E0) const __GPU
Produces a one-dimensional subsection of the source array_view with origin specified by the index com...
Definition: amp.h:3580
Definition: amprt.h:105
Definition: amprt.h:90
std::enable_if< details::_Is_extent_or_index< _Tuple_type< _Rank > >::value, bool >::type operator!=(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:829
int atomic_fetch_sub(_Inout_ int *_Dest, int _Value) __GPU_ONLY
Performs an atomic subtraction of _Value from the memory location pointed to by _Dest ...
Definition: amp.h:6599
array(const Concurrency::extent< _Rank > &_Extent, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view, initialized from an iterator into ...
Definition: amp.h:4598
details::_Projection_result_type< _Value_type, _Rank >::_Const_result_type operator()(int _I) const __GPU
Projects the most-significant dimension of this array. If the array rank is 1, this produces a single...
Definition: amp.h:5167
_Event _Copy_async_impl(const array_view< _Value_type, _Rank > &_Src, OutputIterator _DestIter)
Definition: amp.h:5933
void copy_to(const array_view< _Value_type, _Rank > &_Dest) const __CPU_ONLY
Copies elements from this array_view to the destination array_view.
Definition: amp.h:2552
int __dp_d3d_firstbithighi(int) __GPU_ONLY
details::_Projection_result_type< _Value_type, _Rank >::_Result_type operator()(int _I) __GPU
Projects the most-significant dimension of this array. If the array rank is 1, this produces a single...
Definition: amp.h:5152
_Ret_ void * _Access(const index< _Rank > &_Index) const __GPU
Definition: amp.h:1876
#define AS_UINT_PTR(p)
Definition: amp.h:6546
Definition: xxamp.h:237
Definition: xxamp.h:233
bool atomic_compare_exchange(_Inout_ int *_Dest, _Inout_ int *_Expected_value, int _Value) __GPU_ONLY
Atomically, compares the value pointed to by _Dest for equality with that pointed to by _Expected_val...
Definition: amp.h:6775
array_view(int _E0, int _E1, _In_ _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:3339
_Ret_ _View_shape * _Create_reinterpreted_shape(const _View_shape *_Source_shape, size_t _Curr_elem_size, size_t _New_elem_size)
Definition: amprt.h:1885
extent(const extent< _Rank > &_Other) __GPU
Copy constructor. Constructs a new extent from the supplied argument _Other.
Definition: amp.h:415
unsigned int __dp_d3d_interlocked_compare_exchange(_Inout_ unsigned int *, unsigned int, unsigned int) __GPU_ONLY
int atomic_fetch_inc(_Inout_ int *_Dest) __GPU_ONLY
Performs an atomic increment to the memory location pointed to by _Dest
Definition: amp.h:6643
void global_memory_fence(const tile_barrier &_Barrier) __GPU_ONLY
Ensures that global memory accesses are visible to other threads in the thread tile, and are executed according to program order
Definition: amp.h:7189
_Array_view_base(const _Buffer_descriptor &_Buffer_desc, const _Array_view_shape< _Rank, _Element_size > &_Shape) __GPU
Definition: amp.h:1697
void copy_to(array< _Value_type, _Rank > &_Dest) const __CPU_ONLY
Copies elements from this array_view to the destination array.
Definition: amp.h:3390
array_view section(const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) const __GPU
Produces a subsection of the source array_view at the given origin and extent.
Definition: amp.h:2686
array(int _E0, int _E1) __CPU_ONLY
Construct an array from two integer extents.
Definition: amp.h:3920
_Array_view_base _Section(const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) const __GPU
Definition: amp.h:1897
void _Initialize(Concurrency::accelerator_view _Av, _InputIterator _Src_first, _InputIterator _Src_last, access_type _Cpu_access_type) __CPU_ONLY
Definition: amp.h:5586
array(int _E0, int _E1, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view.
Definition: amp.h:4098
void _Parallel_for_each(_In_ _Host_Scheduling_info *_Sch_info, extent< _Rank > _Compute_domain, const _Kernel_type &_F)
static _Projection_result_type< _T, _R >::_Result_type _Project0(_In_ array< _T, _R > *_Array, int _I) __GPU
Definition: xxamp_inl.h:73
array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view, initialized from a pair of iterato...
Definition: amp.h:4625
_Ret_ void * _Access(_Access_mode, const index< _Rank > &_Index) const __GPU_ONLY
Definition: amp.h:1892
#define AS_FLOAT(v)
Definition: amp.h:6549
array_view(int _E0, _In_ _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:3319
int _M_base[_Rank]
Definition: amp.h:806
_AMPIMP _Event __cdecl _Copy_impl(_In_ _Buffer *_Src, size_t _Src_offset, _Out_ _Buffer *_Dst, size_t _Dest_offset, size_t _Num_elems, size_t _Preferred_copy_chunk_num_elems=0)
integral_constant< bool, true > true_type
Definition: xtr1common:40
index< _Rank > & operator=(const index< _Rank > &_Other) __GPU
copy-assignment operators
Definition: amp.h:153
Definition: type_traits:931
extent< _Rank > & operator=(const extent< _Rank > &_Other) __GPU
copy-assignment operator
Definition: amp.h:484
index(int _I) __GPU
Constructor for index<1>
Definition: amp.h:95
Define an N-dimensional index point; which may also be viewed as a vector based at the origin in N-sp...
Definition: amp.h:53
array_view(int _E0, int _E1, int _E2, _In_ _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:3362
Definition: xxamp.h:241
#define _Inout_
Definition: sal.h:375
void _Register(_In_ void *_Shape) __CPU_ONLY
Definition: amp.h:2031
_Array_view_base(const _Array_view_base &_Other) __GPU
Definition: amp.h:1706
exception_ptr current_exception() _NOEXCEPT
Definition: exception:359
array(const Concurrency::extent< _Rank > &_Extent, _InputIterator _Src_first) __CPU_ONLY
Construct an array initialized from an iterator.
Definition: amp.h:4158
tiled_index(const index< rank > &_Global, const index< rank > &_Local, const index< rank > &_Tile, const index< rank > &_Tile_origin, const tile_barrier &_Barrier) __GPU
A Constructor that initializes data members using the given values.
Definition: amp.h:1232
void _Register(_In_ void *) __GPU_ONLY
Definition: amp.h:2196
array & operator=(const array_view< const _Value_type, _Rank > &_Src) __CPU_ONLY
Assignment operator from an array_view
Definition: amp.h:4905
static _AMPIMP accelerator_view __cdecl get_auto_selection_view()
Returns the auto selection accelerator_view which when specified as the parallel_for_each target resu...
concurrency::completion_future synchronize_async() const __CPU_ONLY
Asynchronously synchronizes any modifications made to "this" array_view to its source data...
Definition: amp.h:3715
tiled_extent truncate() const __GPU
Returns a new tiled_extent with extents adjusted down to be evenly divisible by the tile dimensions...
Definition: amp.h:1333
array(int _E0, int _E1, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct an array initialized from a pair of iterators into a container, bound to a specific acceler...
Definition: amp.h:4445
_Ret_ _Ubiquitous_buffer * _Get_buffer_ptr() const __CPU_ONLY
Definition: amprt.h:503
int operator[](unsigned _Index) const __GPU
Index operator.
Definition: amp.h:168
static _Projection_result_type< _T, _R >::_Const_result_type _Project0(const array_view< const _T, _R > *_Arr_view, int _I) __GPU
Definition: xxamp_inl.h:33
Definition: amprt.h:318
void _Initialize(size_t _Src_data_size) __CPU_ONLY
Definition: amp.h:3811
void __dp_d3d_device_memory_fence_with_tile_barrier() __GPU_ONLY
_Access_mode _Get_synchronize_access_mode(access_type cpu_access_type)
Definition: amprt.h:1927
extent< _Rank > & operator-=(const extent< _Rank > &_Rhs) __GPU
Element-wise subtraction of this extent with another extent.
Definition: amp.h:625
_Array_view_base(const void *_Data, const Concurrency::extent< _Rank > &_Array_extent) __GPU_ONLY
Definition: amp.h:1843
extent< _Rank > & operator-=(const index< _Rank > &_Rhs) __GPU
Element-wise subtraction of this extent with an index.
Definition: amp.h:655
void wait_with_global_memory_fence() const __GPU_ONLY
Blocks execution of all threads in a tile until all all threads in the tile have reached this call...
Definition: amp.h:983
Definition: type_traits:950
_Value_type value_type
Definition: amp.h:3884
Concurrency::index< _Rank > _M_view_offset
Definition: amp.h:1670
Class represents a accelerator abstraction for C++ AMP data-parallel devices
Definition: amprt.h:1013
std::enable_if< details::_Is_extent_or_index< _Tuple_type< _Rank > >::value, _Tuple_type< _Rank > >::type operator%(const _Tuple_type< _Rank > &_Lhs, typename _Tuple_type< _Rank >::value_type _Rhs) __GPU
Definition: amp.h:926
Definition: amprt.h:106
Definition: xxamp.h:235
unsigned int __dp_d3d_interlocked_max_uint(_Inout_ unsigned int *, unsigned int) __GPU_ONLY
const _Value_type value_type
Definition: amp.h:3053
void __dp_d3d_device_memory_fence() __GPU_ONLY
_Array_view_base & operator=(const _Array_view_base &_Other) __GPU
Definition: amp.h:1856
Definition: amprt.h:92
tiled_index< _Dim0 > _map_index(const index< rank > &_Local, const index< rank > &_Tile, const index< rank > &_Global, tile_barrier &_Barrier) const __GPU
Definition: amp.h:1515
#define INT_MAX
Definition: limits.h:35
An array_view is an N-dimensional view over data held in another container (such as array
Definition: amp.h:2236
array_view(int _E0, int _E1) __CPU_ONLY
Construct an array_view which is not bound to a data source.
Definition: amp.h:2390
void wait_with_tile_static_memory_fence() const __GPU_ONLY
Blocks execution of all threads in a tile until all all threads in the tile have reached this call...
Definition: amp.h:992
array(int _E0, int _E1, _InputIterator _Src_first) __CPU_ONLY
Construct an array initialized from an iterator.
Definition: amp.h:4242
array_view(_Container &_Src, typename std::enable_if< details::_Is_container< _Container >::type::value, void ** >::type=0) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container.
Definition: amp.h:2353
array_view< _Value_type, 2 > section(int _I0, int _I1, int _E0, int _E1) __GPU
Produces a two-dimensional subsection of the source array with origin specified by the index componen...
Definition: amp.h:5327
#define __GPU_ONLY
Definition: amprt.h:46
_Array_view_base _Section(const index< _Rank > &_Idx) const __GPU
Definition: amp.h:1907
void _Project0(int _I, _Array_view_shape< _Rank-1, _Element_size > &_Projected_shape) const __GPU
Definition: amp.h:1633
Definition: xxamp.h:234
array_view< _Value_type, _New_rank > view_as(const Concurrency::extent< _New_rank > &_View_extent) const __GPU
Produces an array_view of a different rank over this array_view's data.
Definition: amp.h:2818
int imax(int _X, int _Y) __GPU_ONLY
Determine the maximum numeric value of the arguments
Definition: amp.h:7320
bool _Is_cpu_accelerator(const accelerator &_Accl)
Definition: amprt.h:3401
array_view(int _E0, int _E1, _In_ _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:2502
int __dp_d3d_signi(int) __GPU_ONLY
void wait() const __GPU_ONLY
Blocks execution of all threads in a tile until all all threads in the tile have reached this call...
Definition: amp.h:965
array_view(int _E0, int _E1, int _E2, _Container &_Src) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container.
Definition: amp.h:2451
unsigned int __dp_d3d_countbitsu(unsigned int) __GPU_ONLY
array_view(const Concurrency::extent< _Rank > &_Extent, const _Container &_Src) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container.
Definition: amp.h:3099
tiled_index(const tiled_index &_Other) __GPU
Copy Constructor.
Definition: amp.h:1189
Definition: amprt.h:1581
array_view & operator=(const array_view &_Other) __GPU
Copy Assignment operator. Shallow copy.
Definition: amp.h:2535
_In_ int _Value
Definition: setjmp.h:173
int atomic_fetch_add(_Inout_ int *_Dest, int _Value) __GPU_ONLY
Performs an atomic addition of _Value to the memory location pointed to by _Dest
Definition: amp.h:6563
_Array_view_shape() __GPU
Definition: amp.h:1652
array_view section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU
Produces a three-dimensional subsection of the source array_view with origin specified by the index c...
Definition: amp.h:3636
array_view section(const Concurrency::index< _Rank > &_Idx) const __GPU
Produces a subsection of the source array_view with origin specified by an index, with an extent of (...
Definition: amp.h:2701
extent< _Rank > operator--(int) __GPU
Post-decrements each element of this extent.
Definition: amp.h:779
index< _Rank > _map_index(const index< _Rank > &_Index) const __GPU
Definition: amp.h:789
tile_barrier(const tile_barrier &_Other) __GPU
Copy Constructor. The tile_barrier class does not have a public default constructor or assignment ope...
Definition: amp.h:959
_Array_view_shape(const _Array_view_shape &_Other, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Definition: amp.h:1587
void _Initialize() __GPU
Definition: amp.h:3008
_Value_type & get_ref(const index< _Rank > &_Index) const __GPU
Get a reference to the element indexed by _Index. Unlike the other indexing operators for accessing t...
Definition: amp.h:2585
float __dp_d3d_noisef(float) __GPU_ONLY
array_view< const _Value_type, 2 > section(int _I0, int _I1, int _E0, int _E1) const __GPU
Produces a two-dimensional subsection of the source array with origin specified by the index componen...
Definition: amp.h:5352
_CPP_AMP_VERIFY_RANK(_Rank, tiled_index)
details::_Projection_result_type< _Value_type, _Rank >::_Const_result_type operator[](int _I) const __GPU
Projects the most-significant dimension of this array. If the array rank is 1, this produces a single...
Definition: amp.h:5031
_Size
Definition: vcruntime_string.h:36
static _Ret_ void * _Create_projection_buffer_shape(const _Buffer_descriptor &_Descriptor, unsigned int _Dim, int _Dim_offset) __CPU_ONLY
Definition: amp.h:2074
unsigned int __dp_d3d_minu(unsigned int, unsigned int) __GPU_ONLY
_AMPIMP void _Write_end_event(ULONG _Span_id)
unsigned int _Get_rank() const
Definition: amprt.h:1591
tiled_extent pad() const __GPU
Returns a new tiled_extent with extents adjusted up to be evenly divisible by the tile dimensions...
Definition: amp.h:1321
#define _Ret_
Definition: sal.h:996
concurrency::completion_future copy_async(const array< _Value_type, _Rank > &_Src, array< _Value_type, _Rank > &_Dest)
Asynchronously copies the contents of the source array into the destination array.
Definition: amp.h:5988
extent< _Rank > & operator*=(int _Rhs) __GPU
Multiplies an integer value to each element of this extent.
Definition: amp.h:700
concurrency::completion_future _Start_async_op_wait_event_helper(ULONG _Async_op_id, _Event _Ev)
Definition: amprt.h:3753
int __dp_d3d_interlocked_max_int(_Inout_ int *, int) __GPU_ONLY
int firstbithigh(int _X) __GPU_ONLY
Gets the location of the first set bit in _X, starting from the highest order bit and working downwar...
Definition: amp.h:7289
std::enable_if< details::_Is_extent_or_index< _Tuple_type< _Rank > >::value, _Tuple_type< _Rank > >::type operator/(const _Tuple_type< _Rank > &_Lhs, typename _Tuple_type< _Rank >::value_type _Rhs) __GPU
Definition: amp.h:908
float __dp_d3d_stepf(float, float) __GPU_ONLY
access_type
Enumeration type used to denote the various types of access to data.
Definition: amprt.h:103
_Array_view_base(const _Array_view_base &_Other, const Concurrency::extent< _Rank > &_Array_extent) __GPU
Definition: amp.h:1718
bool contains(const index< rank > &_Index) const __GPU
Tests whether the index "_Index" is properly contained within this extent.
Definition: amp.h:529
array(const array_view< const _Value_type, _Rank > &_Src, accelerator_view _Av, accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_views, initialized from an array_view...
Definition: amp.h:4829
tiled_extent truncate() const __GPU
Returns a new tiled_extent with extents adjusted down to be evenly divisible by the tile dimensions...
Definition: amp.h:1418
tiled_index(const index< rank > &_Global, const index< rank > &_Local, const index< rank > &_Tile, const index< rank > &_Tile_origin, const tile_barrier &_Barrier) __GPU
A Constructor that initializes data members using the given values.
Definition: amp.h:1175
array(int _E0, Concurrency::accelerator_view _Av, access_type _Cpu_access_type=access_type_auto) __CPU_ONLY
Construct array with the extent _E0, bound to a specific accelerator_view.
Definition: amp.h:3984
float step(float _Y, float _X) __GPU_ONLY
Compares two values, returning 0 or 1 based on which value is greater
Definition: amp.h:7572
array_view< _Value_type, _New_rank > view_as(const Concurrency::extent< _New_rank > &_View_extent) __GPU
Produces an array_view of a different rank over this array's data.
Definition: amp.h:5460
static _Projection_result_type< _T, _R >::_Const_result_type _Project0(const array< _T, _R > *_Array, int _I) __GPU
Definition: xxamp_inl.h:65
index(int _I0, int _I1, int _I2) __GPU
Constructor for index<3>
Definition: amp.h:129
int atomic_fetch_min(_Inout_ int *_Dest, int _Value) __GPU_ONLY
Atomically computes the minimum of _Value and the value of the memory location pointed to by _Dest...
Definition: amp.h:6873
array(int _E0, int _E1, int _E2, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Construct a staging array between two associated accelerator_view, initialized from an iterator into ...
Definition: amp.h:4770
array_view(const array_view< const _Value_type, _Rank > &_Src) __GPU
Copy constructor. Shallow copy.
Definition: amp.h:3085
array_view(int _E0, int _E1, _Container &_Src) __CPU_ONLY
Construct an array_view which is bound to the data contained in the _Src container.
Definition: amp.h:2409
void tile_static_memory_fence(const tile_barrier &_Barrier) __GPU_ONLY
Ensures that tile_static memory accesses are visible to other threads in the thread tile...
Definition: amp.h:7200
const _Value_type & get_ref(const index< _Rank > &_Index) const __GPU
Get a reference to the element indexed by _Index. Unlike the other indexing operators for accessing t...
Definition: amp.h:3431
array_view(const Concurrency::extent< _Rank > &_Extent, const _Value_type *_Src) __GPU
Construct an array_view which is bound to the data pointed to by _Src.
Definition: amp.h:3153