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 template <int _Rank, template <int> class _Tuple_type>
810 bool operator==(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
811 {
813 }
814 
815 template <int _Rank, template <int> class _Tuple_type>
816 bool operator!=(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
817 {
819 }
820 
821 template <int _Rank, template <int> class _Tuple_type>
822 _Tuple_type<_Rank> operator+(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
823 {
824  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
825  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opAdd>::func(new_Tuple, _Lhs, _Rhs);
826  return new_Tuple;
827 }
828 
829 template <int _Rank, template <int> class _Tuple_type>
830 _Tuple_type<_Rank> operator-(const _Tuple_type<_Rank>& _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
831 {
832  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
833  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opSub>::func(new_Tuple, _Lhs, _Rhs);
834  return new_Tuple;
835 }
836 
837 template <int _Rank, template <int> class _Tuple_type>
838 _Tuple_type<_Rank> operator+(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU
839 {
840  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
841  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opAdd>::func(new_Tuple, _Lhs, _Rhs);
842  return new_Tuple;
843 }
844 
845 template <int _Rank, template <int> class _Tuple_type>
846 _Tuple_type<_Rank> operator+(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
847 {
848  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
849  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opAdd>::func(new_Tuple, _Lhs, _Rhs);
850  return new_Tuple;
851 }
852 
853 template <int _Rank, template <int> class _Tuple_type>
854 _Tuple_type<_Rank> 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>, opSub>::func(new_Tuple, _Lhs, _Rhs);
858  return new_Tuple;
859 }
860 
861 template <int _Rank, template <int> class _Tuple_type>
862 _Tuple_type<_Rank> operator-(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
863 {
864  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
865  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opSub>::func(new_Tuple, _Lhs, _Rhs);
866  return new_Tuple;
867 }
868 
869 template <int _Rank, template <int> class _Tuple_type>
870 _Tuple_type<_Rank> operator*(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU
871 {
872  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
873  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMul>::func(new_Tuple, _Lhs, _Rhs);
874  return new_Tuple;
875 }
876 
877 template <int _Rank, template <int> class _Tuple_type>
878 _Tuple_type<_Rank> operator*(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
879 {
880  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
881  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMul>::func(new_Tuple, _Lhs, _Rhs);
882  return new_Tuple;
883 }
884 
885 template <int _Rank, template <int> class _Tuple_type>
886 _Tuple_type<_Rank> operator/(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU
887 {
888  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
889  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opDiv>::func(new_Tuple, _Lhs, _Rhs);
890  return new_Tuple;
891 }
892 
893 template <int _Rank, template <int> class _Tuple_type>
894 _Tuple_type<_Rank> operator/(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
895 {
896  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
897  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opDiv>::func(new_Tuple, _Lhs, _Rhs);
898  return new_Tuple;
899 }
900 
901 template <int _Rank, template <int> class _Tuple_type>
902 _Tuple_type<_Rank> operator%(const _Tuple_type<_Rank>& _Lhs, typename _Tuple_type<_Rank>::value_type _Rhs) __GPU
903 {
904  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
905  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMod>::func(new_Tuple, _Lhs, _Rhs);
906  return new_Tuple;
907 }
908 
909 template <int _Rank, template <int> class _Tuple_type>
910 _Tuple_type<_Rank> operator%(typename _Tuple_type<_Rank>::value_type _Lhs, const _Tuple_type<_Rank>& _Rhs) __GPU
911 {
912  _Tuple_type<_Rank> new_Tuple = details::_Create_uninitialized_tuple<_Tuple_type<_Rank>>();
913  details::_arithmetic_op_loop_helper<_Tuple_type<_Rank>, opMod>::func(new_Tuple, _Lhs, _Rhs);
914  return new_Tuple;
915 }
924 {
925 public:
933 #pragma warning( suppress : 4100 ) // unreferenced formal parameter
934  tile_barrier(const tile_barrier& _Other) __GPU {}
935 
940  void wait() const __GPU_ONLY
941  {
943  }
944 
950  {
952  }
953 
959  {
961  }
962 
968  {
970  }
971 };
972 
977 template <int _Rank> class _Tiled_index_base
978 {
979 public:
980 
982 
983  static const int rank = _Rank;
984 
989 
994 
999 
1004 
1009 
1029  const index<rank>& _Local,
1030  const index<rank>& _Tile,
1031  const index<rank>& _Tile_origin,
1032  const tile_barrier& _Barrier) __GPU
1033  : global(_Global), local(_Local), tile(_Tile), tile_origin(_Tile_origin), barrier(_Barrier)
1034  {}
1035 
1043  : global(_Other.global),
1044  local(_Other.local),
1045  tile(_Other.tile),
1046  tile_origin(_Other.tile_origin),
1047  barrier(_Other.barrier)
1048  {}
1049 
1054  operator const index<rank>() const __GPU
1055  {
1056  return global;
1057  }
1058 
1059 private:
1061 };
1062 
1071 template <int _Dim0, int _Dim1 = 0, int _Dim2 = 0> class tiled_index : public _Tiled_index_base<3>
1072 {
1073 public:
1092  tiled_index(const index<rank>& _Global,
1093  const index<rank>& _Local,
1094  const index<rank>& _Tile,
1095  const index<rank>& _Tile_origin,
1096  const tile_barrier& _Barrier) __GPU
1097  : _Tiled_index_base(_Global, _Local, _Tile, _Tile_origin, _Barrier)
1098  {}
1099 
1106  tiled_index(const tiled_index& _Other) __GPU
1107  : _Tiled_index_base(_Other)
1108  {}
1109 
1114  __declspec(property(get=get_tile_extent)) extent<rank> tile_extent;
1115  extent<rank> get_tile_extent() __GPU { return extent<rank>(_Dim0, _Dim1, _Dim2); }
1116 
1120  static const int tile_dim0 = _Dim0;
1121  static const int tile_dim1 = _Dim1;
1122  static const int tile_dim2 = _Dim2;
1123 
1124 private:
1125  tiled_index& operator=(const tiled_index&) __GPU;
1126 };
1127 
1128 template <int _Dim0, int _Dim1>
1129 class tiled_index<_Dim0, _Dim1, 0> : public _Tiled_index_base<2>
1130 {
1131 public:
1150  tiled_index(const index<rank>& _Global,
1151  const index<rank>& _Local,
1152  const index<rank>& _Tile,
1153  const index<rank>& _Tile_origin,
1154  const tile_barrier& _Barrier) __GPU
1155  : _Tiled_index_base(_Global, _Local, _Tile, _Tile_origin, _Barrier)
1156  {}
1157 
1164  tiled_index(const tiled_index& _Other) __GPU
1165  : _Tiled_index_base(_Other)
1166  {}
1167 
1172  __declspec(property(get=get_tile_extent)) extent<rank> tile_extent;
1173  extent<rank> get_tile_extent() __GPU { return extent<rank>(_Dim0, _Dim1); }
1174 
1178  static const int tile_dim0 = _Dim0;
1179  static const int tile_dim1 = _Dim1;
1180 
1181 private:
1182  tiled_index& operator=(const tiled_index&) __GPU;
1183 };
1184 
1185 template <int _Dim0>
1186 class tiled_index<_Dim0, 0, 0> : public _Tiled_index_base<1>
1187 {
1188 public:
1207  tiled_index(const index<rank>& _Global,
1208  const index<rank>& _Local,
1209  const index<rank>& _Tile,
1210  const index<rank>& _Tile_origin,
1211  const tile_barrier& _Barrier) __GPU
1212  : _Tiled_index_base(_Global, _Local, _Tile, _Tile_origin, _Barrier)
1213  {}
1214 
1221  tiled_index(const tiled_index& _Other) __GPU
1222  : _Tiled_index_base(_Other)
1223  {}
1224 
1229  __declspec(property(get=get_tile_extent)) extent<rank> tile_extent;
1230  extent<rank> get_tile_extent() __GPU { return extent<rank>(_Dim0); }
1231 
1235  static const int tile_dim0 = _Dim0;
1236 
1237 private:
1238  tiled_index& operator=(const tiled_index&) __GPU;
1239 };
1240 
1241 
1249 template <int _Dim0, int _Dim1 /*=0*/, int _Dim2 /*=0*/> class tiled_extent : public Concurrency::extent<3>
1250 {
1251 public:
1252 
1253  static_assert(_Dim0>0, "_Dim0 must be positive");
1254  static_assert(_Dim1>0, "_Dim1 must be positive");
1255  static_assert(_Dim2>0, "_Dim2 must be positive");
1256 
1260  tiled_extent() __GPU {}
1261 
1266  {}
1267 
1271  tiled_extent(const tiled_extent& _Other) __GPU : Concurrency::extent<rank>(_Other)
1272  {}
1273 
1277  tiled_extent& operator=(const tiled_extent& _Other) __GPU
1278  {
1280  return *this;
1281  }
1282 
1287  __declspec(property(get=get_tile_extent)) Concurrency::extent<rank> tile_extent;
1288  Concurrency::extent<rank> get_tile_extent() const __GPU
1289  {
1290  return Concurrency::extent<rank>(_Dim0, _Dim1, _Dim2);
1291  }
1292 
1296  tiled_extent pad() const __GPU
1297  {
1298  Concurrency::extent<rank> _New_extent(((static_cast<unsigned int>((*this)[0]) + _Dim0 - 1)/_Dim0) * _Dim0,
1299  ((static_cast<unsigned int>((*this)[1]) + _Dim1 - 1)/_Dim1) * _Dim1,
1300  ((static_cast<unsigned int>((*this)[2]) + _Dim2 - 1)/_Dim2) * _Dim2);
1301 
1302  return tiled_extent<_Dim0,_Dim1,_Dim2>(_New_extent);
1303  }
1304 
1308  tiled_extent truncate() const __GPU
1309  {
1310  Concurrency::extent<rank> _New_extent(((*this)[0]/_Dim0) * _Dim0, ((*this)[1]/_Dim1) * _Dim1, ((*this)[2]/_Dim2) * _Dim2);
1311  return tiled_extent<_Dim0,_Dim1,_Dim2>(_New_extent);
1312  }
1313 
1317  static const int tile_dim0 = _Dim0;
1318  static const int tile_dim1 = _Dim1;
1319  static const int tile_dim2 = _Dim2;
1320 
1321  // implementation details (compiler helpers) - begin
1322 
1323  // Given the local index, the tile index, the global index, in the 0-based domain that
1324  // has same extents as 'this', and a barrier object, return a tiled_index<_Dim0, _Dim1, _Dim2> into
1325  // the 'this' tiled_extent domain.
1326  tiled_index<_Dim0, _Dim1, _Dim2> _map_index(const index<rank>& _Local, const index<rank>& _Tile, const index<rank>& _Global, tile_barrier& _Barrier) const __GPU
1327  {
1328  index<rank> _Tile_origin = details::_Create_uninitialized_tuple<index<rank>>();
1329  details::_arithmetic_op_loop_helper<index<rank>, details::opMul>::func(_Tile_origin, _Tile, tile_extent);
1330  return tiled_index<_Dim0, _Dim1, _Dim2>(_Global, _Local, _Tile, _Tile_origin, _Barrier);
1331  }
1332  // implementation details (compiler helpers) - end
1333 };
1334 
1335 
1336 template <int _Dim0, int _Dim1>
1337 class tiled_extent<_Dim0, _Dim1, 0> : public Concurrency::extent<2>
1338 {
1339 public:
1340 
1341  static_assert(_Dim0>0, "_Dim0 must be positive");
1342  static_assert(_Dim1>0, "_Dim1 must be positive");
1343 
1347  tiled_extent() __GPU {}
1348 
1353  {}
1354 
1358  tiled_extent(const tiled_extent& _Other) __GPU : Concurrency::extent<rank>(_Other)
1359  {}
1360 
1364  tiled_extent& operator=(const tiled_extent& _Other) __GPU
1365  {
1367  return *this;
1368  }
1369 
1374  __declspec(property(get=get_tile_extent)) Concurrency::extent<rank> tile_extent;
1375  Concurrency::extent<rank> get_tile_extent() const __GPU
1376  {
1377  return Concurrency::extent<rank>(_Dim0, _Dim1);
1378  }
1379 
1383  tiled_extent pad() const __GPU
1384  {
1385  Concurrency::extent<rank> _New_extent(((static_cast<unsigned int>((*this)[0]) + _Dim0 - 1)/_Dim0) * _Dim0,
1386  ((static_cast<unsigned int>((*this)[1]) + _Dim1 - 1)/_Dim1) * _Dim1);
1387  return tiled_extent<_Dim0,_Dim1>(_New_extent);
1388  }
1389 
1393  tiled_extent truncate() const __GPU
1394  {
1395  Concurrency::extent<rank> _New_extent(((*this)[0]/_Dim0) * _Dim0, ((*this)[1]/_Dim1) * _Dim1);
1396  return tiled_extent<_Dim0,_Dim1>(_New_extent);
1397  }
1398 
1402  static const int tile_dim0 = _Dim0;
1403  static const int tile_dim1 = _Dim1;
1404 
1405  // implementation details (compiler helpers) - begin
1406 
1407  // Given the local index, the tile index, the global index, in the 0-based domain that
1408  // has same extents as 'this', and a barrier object, return a tiled_index<_Dim0, _Dim1> into
1409  // the 'this' tiled_extent domain.
1410  tiled_index<_Dim0, _Dim1> _map_index(const index<rank>& _Local, const index<rank>& _Tile, const index<rank>& _Global, tile_barrier& _Barrier) const __GPU
1411  {
1412  index<rank> _Tile_origin = details::_Create_uninitialized_tuple<index<rank>>();
1413  details::_arithmetic_op_loop_helper<index<rank>, details::opMul>::func(_Tile_origin, _Tile, tile_extent);
1414  return tiled_index<_Dim0, _Dim1>(_Global, _Local, _Tile, _Tile_origin, _Barrier);
1415  }
1416  // implementation details (compiler helpers) - end
1417 };
1418 
1419 template <int _Dim0>
1420 class tiled_extent<_Dim0, 0, 0> : public Concurrency::extent<1>
1421 {
1422 public:
1423 
1424  static_assert(_Dim0>0, "_Dim0 must be positive");
1425 
1429  tiled_extent() __GPU {}
1430 
1435  {}
1436 
1440  tiled_extent(const tiled_extent& _Other) __GPU : Concurrency::extent<rank>(_Other)
1441  {}
1442 
1446  tiled_extent& operator=(const tiled_extent& _Other) __GPU
1447  {
1449  return *this;
1450  }
1451 
1456  __declspec(property(get=get_tile_extent)) Concurrency::extent<rank> tile_extent;
1457  Concurrency::extent<rank> get_tile_extent() const __GPU
1458  {
1459  return Concurrency::extent<rank>(_Dim0);
1460  }
1461 
1465  tiled_extent pad() const __GPU
1466  {
1467  Concurrency::extent<rank> _New_extent(((static_cast<unsigned int>((*this)[0]) + _Dim0 - 1)/_Dim0) * _Dim0);
1468  return tiled_extent<_Dim0>(_New_extent);
1469  }
1470 
1474  tiled_extent truncate() const __GPU
1475  {
1476  Concurrency::extent<rank> _New_extent(((*this)[0]/_Dim0) * _Dim0);
1477  return tiled_extent<_Dim0>(_New_extent);
1478  }
1479 
1483  static const int tile_dim0 = _Dim0;
1484 
1485  // implementation details (compiler helpers) - begin
1486 
1487  // Given the local index, the tile index, the global index, in the 0-based domain that
1488  // has same extents as 'this', and a barrier object, return a tiled_index<_Dim0> into
1489  // the 'this' tiled_extent domain.
1490  tiled_index<_Dim0> _map_index(const index<rank>& _Local, const index<rank>& _Tile, const index<rank>& _Global, tile_barrier& _Barrier) const __GPU
1491  {
1492  index<rank> _Tile_origin = details::_Create_uninitialized_tuple<index<rank>>();
1493  details::_arithmetic_op_loop_helper<index<rank>, details::opMul>::func(_Tile_origin, _Tile, tile_extent);
1494  return tiled_index<_Dim0>(_Global, _Local, _Tile, _Tile_origin, _Barrier);
1495  }
1496 };
1497 
1498 namespace details
1499 {
1500 
1501 template <int _Old_element_size, int _New_element_size>
1503 {
1504  int _Total_size = _Old_element_size * _Old_size;
1505  int _New_size = (_Total_size + _New_element_size - 1)/ _New_element_size;
1506 
1507  return _New_size;
1508 }
1509 
1510 
1511 template <int _Old_element_size, int _New_element_size>
1512 int _Calculate_reinterpreted_size(int _Old_size) __CPU_ONLY
1513 {
1514  int _Total_size = _Old_element_size * _Old_size;
1515  int _New_size = (_Total_size + _New_element_size - 1)/ _New_element_size;
1516 
1517  if (_New_size * _New_element_size > _Total_size)
1518  throw runtime_exception("Element type of reinterpret_as does not evenly divide into extent", E_INVALIDARG);
1519 
1520  return _New_size;
1521 }
1522 
1523 
1524 // This class defines the shape of an array view and provides
1525 // the functionality of translating dimensional indices into
1526 // flat offsets into the underlying buffer
1527 template <int _Rank, int _Element_size /* in number of ints */>
1529 {
1531  friend class _Array_view_shape<_Rank+1, _Element_size>;
1532 
1533 public:
1537  __declspec(property(get=get_extent)) Concurrency::extent<_Rank> extent;
1538  Concurrency::extent<_Rank> get_extent() const __GPU
1539  {
1540  return _M_view_extent;
1541  }
1542 
1544 
1545 protected:
1546  int _Base_linear_offset() const __GPU
1547  {
1548  return (_M_total_linear_offset - (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _M_view_offset._M_base)));
1549  }
1550 
1552  :
1553  _M_array_extent(_Other._M_array_extent),
1554  _M_array_multiplier(_Other._M_array_multiplier),
1555  _M_view_offset(_Other._M_view_offset),
1556  _M_total_linear_offset(_Other._M_total_linear_offset),
1557  _M_view_extent(_Other._M_view_extent)
1558  {
1559  }
1560 
1561  // For "section"
1562  _Array_view_shape(const _Array_view_shape& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
1563  :
1564  _M_array_extent(_Other._M_array_extent),
1565  _M_array_multiplier(_Other._M_array_multiplier),
1566  _M_view_offset(_Other._M_view_offset + _Section_origin),
1567  _M_view_extent(_Section_extent)
1568  {
1569  _Is_valid_section(_Other._M_view_extent, _Section_origin, _Section_extent);
1570 
1571  _M_total_linear_offset = _Other._Base_linear_offset() + (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _M_view_offset._M_base));
1572  }
1573 
1574  _Array_view_shape(int _Base_linear_offset, const Concurrency::extent<_Rank>& _Array_extent) __GPU
1575  :
1576  _M_array_extent(_Array_extent),
1577  _M_view_offset(index<_Rank>()),
1578  _M_total_linear_offset(_Base_linear_offset),
1579  _M_view_extent(_Array_extent)
1580  {
1581  _Initialize_multiplier();
1582  }
1583 
1584  _Array_view_shape(int _Base_linear_offset, const Concurrency::extent<_Rank>& _Array_extent,
1585  const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
1586  :
1587  _M_array_extent(_Array_extent),
1588  _M_view_offset(_Section_origin),
1589  _M_total_linear_offset(_Base_linear_offset),
1590  _M_view_extent(_Section_extent)
1591  {
1592  _Is_valid_section(_Array_extent, _Section_origin, _Section_extent);
1593 
1594  _Initialize_multiplier();
1595  _M_total_linear_offset += (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _M_view_offset._M_base));
1596  }
1597 
1599  {
1600  _M_array_extent = _Other._M_array_extent;
1601  _M_array_multiplier = _Other._M_array_multiplier;
1602  _M_view_offset = _Other._M_view_offset;
1603  _M_total_linear_offset = _Other._M_total_linear_offset;
1604  _M_view_extent = _Other._M_view_extent;
1605  return *this;
1606  }
1607 
1608  void _Project0(int _I, _Array_view_shape<_Rank-1,_Element_size>& _Projected_shape) const __GPU
1609  {
1610  static_assert(_Rank > 1, "Projection is only supported on array_views with a rank of 2 or higher");
1611 
1612  _Is_valid_projection(_I, this->_M_view_extent);
1613 
1614  typedef Concurrency::extent<_Rank-1> _RES_EXT;
1615  typedef Concurrency::extent<_Rank> _SRC_EXT;
1616  typedef Concurrency::index<_Rank-1> _RES_IDX;
1617  typedef Concurrency::index<_Rank> _SRC_IDX;
1619  _Projected_shape._M_array_extent, this->_M_array_extent,
1620  _Projected_shape._M_array_multiplier, this->_M_array_multiplier,
1621  _Projected_shape._M_view_offset, this->_M_view_offset,
1622  _Projected_shape._M_view_extent, this->_M_view_extent);
1623 
1624  _Projected_shape._M_total_linear_offset = _M_total_linear_offset + (_Element_size * _I * _M_array_multiplier[0]);
1625  }
1626 
1628  : _M_array_extent(details::_do_not_initialize), _M_array_multiplier(details::_do_not_initialize),
1629  _M_view_offset(details::_do_not_initialize), _M_view_extent(details::_do_not_initialize)
1630  {
1631  }
1632 
1633 private:
1634 
1636  {
1637  details::_Is_valid_extent(_M_array_extent);
1638  unsigned int _Ext = _M_array_extent[_Rank-1];
1639  details::_Array_init_helper<Concurrency::extent<_Rank>, Concurrency::extent<_Rank>>::func(_Ext, _M_array_multiplier, _M_array_extent);
1640  }
1641 
1642 protected:
1646  int _M_total_linear_offset; // in number of units
1648 };
1649 
1650 template <int _Rank, int _Element_size>
1651 class _Array_view_base : public _Array_view_shape<_Rank,_Element_size /* in number of ints */>
1652 {
1653  template <int _R, int _S>
1654  friend class _Array_view_base;
1655 
1656 public:
1657 
1659 
1661  {
1662  // Unregister the view; Do not throw exception
1663  _Unregister(false);
1664  }
1665 
1666 protected:
1667 
1668  _Array_view_base() __GPU {}
1669 
1670  _Array_view_base(const _Buffer_descriptor& _Buffer_desc, const _Array_view_shape& _Shape) __GPU
1671  :
1672  _M_buffer_descriptor(_Buffer_desc),
1674  {
1675  // Register the view
1676  _Register();
1677  }
1678 
1679  _Array_view_base(const _Array_view_base& _Other) __GPU
1680  :
1681  _M_buffer_descriptor(_Other._M_buffer_descriptor),
1683  {
1684  // Register the view
1685  _Register_copy(_Other);
1686  }
1687 
1688  _Array_view_base(const _Array_view_base& _Other, const Concurrency::extent<_Rank>& _Array_extent) __GPU
1689  :
1690  _M_buffer_descriptor(_Other._M_buffer_descriptor),
1691  _Array_view_shape<_Rank, _Element_size>(_Other._Base_linear_offset(), _Array_extent)
1692  {
1693  // Register the view
1694  _Register();
1695  }
1696 
1697  _Array_view_base(const _Array_view_base& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
1698  :
1699  _M_buffer_descriptor(_Other._M_buffer_descriptor),
1700  _Array_view_shape<_Rank, _Element_size>(_Other, _Section_origin, _Section_extent)
1701  {
1702  // Register the view
1703  _Register();
1704  }
1705 
1706  _Array_view_base(const _Buffer_descriptor& _Buffer_desc, const Concurrency::extent<_Rank>& _Array_extent) __GPU
1707  :
1708  _M_buffer_descriptor(_Buffer_desc),
1710  {
1711  // Register the view
1712  _Register();
1713  }
1714 
1715  _Array_view_base(const _Buffer_descriptor& _Buffer_desc, int _Base_linear_offset, const Concurrency::extent<_Rank>& _Array_extent) __GPU
1716  :
1717  _M_buffer_descriptor(_Buffer_desc),
1718  _Array_view_shape<_Rank, _Element_size>(_Base_linear_offset,_Array_extent)
1719  {
1720  // Register the view
1721  _Register();
1722  }
1723 
1725  const _Buffer_descriptor& _Buffer_desc,
1726  int _Base_linear_offset,
1727  const Concurrency::extent<_Rank>& _Array_extent,
1728  const Concurrency::index<_Rank>& _View_offset,
1729  const Concurrency::extent<_Rank>& _View_extent
1730  ) __GPU
1731  :
1732  _M_buffer_descriptor(_Buffer_desc),
1733  _Array_view_shape<_Rank, _Element_size>(_Base_linear_offset,_Array_extent,_View_offset,_View_extent)
1734  {
1735  // Register the view
1736  _Register();
1737  }
1738 
1739  _Array_view_base(const _Buffer_descriptor& _Buffer_desc, const Concurrency::extent<_Rank>& _Array_extent,
1740  const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
1741  :
1742  _M_buffer_descriptor(_Buffer_desc),
1743  _Array_view_shape<_Rank, _Element_size>(0,_Array_extent,_Section_origin,_Section_extent)
1744  {
1745  // Register the view
1746  _Register();
1747  }
1748 
1750  :
1752  {
1753  _Ubiquitous_buffer_ptr _PUBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_Array_extent.size(), _Element_size * sizeof(int));
1754  _M_buffer_descriptor = _Buffer_descriptor(NULL, _PUBuf, _No_access, _No_access);
1755 
1756  // Register the view
1757  _Register();
1758  }
1759 
1760  _Array_view_base(_In_ void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __CPU_ONLY
1761  :
1763  {
1764  if (_Data == NULL) {
1765  throw runtime_exception("Invalid pointer argument (NULL) to array_view constructor", E_INVALIDARG);
1766  }
1767 
1768  _Buffer_ptr _PBuf = _Buffer::_Create_buffer(_Data, accelerator(accelerator::cpu_accelerator).default_view, _Array_extent.size(), _Element_size * sizeof(int));
1769  _Ubiquitous_buffer_ptr _PUBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf);
1770  _M_buffer_descriptor = _Buffer_descriptor(_Data, _PUBuf, _Read_write_access, _Read_write_access);
1771 
1772  // Register the view
1773  _Register();
1774  }
1775 
1776  _Array_view_base(_In_ void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __GPU_ONLY
1777  :
1778  _Array_view_shape<_Rank, _Element_size>(0,_Array_extent), _M_buffer_descriptor(_Data, NULL, _Read_write_access, _Read_write_access)
1779  {
1780  }
1781 
1782  _Array_view_base(const void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __CPU_ONLY
1783  :
1785  {
1786  if (_Data == NULL) {
1787  throw runtime_exception("Invalid pointer argument (NULL) to array_view constructor", E_INVALIDARG);
1788  }
1789 
1790  _Buffer_ptr _PBuf = _Buffer::_Create_buffer(const_cast<void*>(_Data), accelerator(accelerator::cpu_accelerator).default_view, _Array_extent.size(), _Element_size * sizeof(int));
1791  _Ubiquitous_buffer_ptr _PUBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf);
1792  _M_buffer_descriptor = _Buffer_descriptor(const_cast<void*>(_Data), _PUBuf, _Read_access, _Read_access);
1793 
1794  // Register the view
1795  _Register();
1796  }
1797 
1798  _Array_view_base(const void * _Data, const Concurrency::extent<_Rank>& _Array_extent) __GPU_ONLY
1799  :
1800 #pragma warning( push )
1801 #pragma warning( disable : 4880 )
1802  // Casting away constness in amp restricted scope might result in
1803  // undefined behavior, therefore, the compiler will report a level 1 warning
1804  // for it. But the following const_cast is harmless thus we are suppressing
1805  // this warning just for this line.
1806  _Array_view_shape<_Rank, _Element_size>(0,_Array_extent), _M_buffer_descriptor(const_cast<void*>(_Data), NULL, _Read_access, _Read_access)
1807 #pragma warning( pop )
1808  {
1809  }
1810 
1812  {
1813  if (this != &_Other)
1814  {
1815  // Unregister the current view
1816  _Unregister();
1817 
1818  _M_buffer_descriptor = _Other._M_buffer_descriptor;
1820 
1821  // Register the new view
1822  _Register_copy(_Other);
1823  }
1824 
1825  return *this;
1826  }
1827 
1828  _Ret_ void * _Access(const index<_Rank>& _Index) const __GPU
1829  {
1830  int * _Ptr = reinterpret_cast<int *>(_M_buffer_descriptor._M_data_ptr);
1831  return &_Ptr[_M_total_linear_offset + (_Element_size * _Flatten_helper::func(_M_array_multiplier._M_base, _Index._M_base))];
1832  }
1833 
1834  _Ret_ void * _Access(_Access_mode _Requested_mode, const index<_Rank>& _Index) const __CPU_ONLY
1835  {
1836  // Refresh the data ptr if we do not have requested access
1837  if ((_M_buffer_descriptor._M_curr_cpu_access_mode & _Requested_mode) != _Requested_mode) {
1838  _M_buffer_descriptor._Get_CPU_access(_Requested_mode);
1839  }
1840 
1841  return _Access(_Index);
1842  }
1843 
1844  _Ret_ void * _Access(_Access_mode _Requested_mode, const index<_Rank>& _Index) const __GPU_ONLY
1845  {
1846  UNREFERENCED_PARAMETER(_Requested_mode);
1847 
1848  return _Access(_Index);
1849  }
1850 
1851  _Array_view_base _Section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU
1852  {
1853  auto _View = _Array_view_base(*this, _Section_origin, _Section_extent);
1854 
1855  // Register the constructed view with the section buffer view shape
1856  _View._Register(_Array_view_base::_Create_section_buffer_shape(this->_M_buffer_descriptor, _Section_origin, _Section_extent));
1857 
1858  return _View;
1859  }
1860 
1861  _Array_view_base _Section(const index<_Rank>& _Idx) const __GPU
1862  {
1863  return _Section(_Idx, this->extent - _Idx);
1864  }
1865 
1866  void _Project0(int _I, _Array_view_base<_Rank-1,_Element_size>& _Projected_view) const __GPU
1867  {
1868  _Projected_view._M_buffer_descriptor = this->_M_buffer_descriptor;
1870 
1871  // Register the constructed view with the projection buffer view shape
1872  _Projected_view._Register(_Array_view_base::_Create_projection_buffer_shape(this->_M_buffer_descriptor, 0, _I));
1873  }
1874 
1875  template <int _New_element_size>
1877  {
1878  static_assert(_Rank==1, "reinterpret_as is only permissible on array views of rank 1");
1879  int _New_size = _Calculate_reinterpreted_size<_Element_size,_New_element_size>(_M_view_extent.size());
1880  return _Array_view_base<_Rank,_New_element_size>(this->_M_buffer_descriptor,
1881  _M_total_linear_offset,
1882  Concurrency::extent<_Rank>(_New_size));
1883  }
1884 
1885  template <int _New_rank>
1887  {
1888  static_assert(_Rank==1, "view_as is only permissible on array views of rank 1");
1889  return _Array_view_base<_New_rank, _Element_size>(this->_M_buffer_descriptor,
1890  _M_total_linear_offset,
1891  _View_extent,
1892  index<_New_rank>(),
1893  _View_extent);
1894  }
1895 
1897  {
1898  unsigned int bufElemSize = static_cast<unsigned int>(_M_buffer_descriptor._Get_buffer_ptr()->_Get_master_buffer_elem_size());
1899  unsigned int elemSize = _Element_size * sizeof(int);
1900 
1901  size_t linearOffsetInBytes = _Base_linear_offset() * sizeof(int);
1902 
1903  size_t baseLSDExtentInBytes = _M_array_extent[_Rank - 1];
1904  baseLSDExtentInBytes *= elemSize;
1905 
1906  size_t viewLSDOffsetInBytes = _M_view_offset[_Rank - 1];
1907  viewLSDOffsetInBytes *= elemSize;
1908 
1909  size_t viewLSDExtentInBytes = _M_view_extent[_Rank - 1];
1910  viewLSDExtentInBytes *= elemSize;
1911 
1912  // The base array extent, view extent, and view offset must be compatible with the underlying
1913  // buffer's element size
1914  if (((linearOffsetInBytes % bufElemSize) != 0) ||
1915  ((baseLSDExtentInBytes % bufElemSize) != 0) ||
1916  ((viewLSDOffsetInBytes % bufElemSize) != 0) ||
1917  ((viewLSDExtentInBytes % bufElemSize) != 0))
1918  {
1919  throw runtime_exception("The array_view base extent, view offset and/or view extent is incompatible with the underlying buffer", E_FAIL);
1920  }
1921 
1922  // The shape to be passed to the underlying buffer for registration must be in terms of
1923  // the element size of the buffer
1924  _ASSERTE((linearOffsetInBytes / bufElemSize) <= UINT_MAX);
1925  unsigned int linearOffset = static_cast<unsigned int>(linearOffsetInBytes / bufElemSize);
1926 
1927  unsigned int baseExtent[_Rank];
1928  unsigned int viewOffset[_Rank];
1929  unsigned int viewExtent[_Rank];
1930 #pragma warning( push )
1931 #pragma warning( disable : 6294 )
1932 #pragma warning( disable : 6201 ) // Index '-1' is out of valid index range '0' to '0' for possibly stack allocated buffer 'baseExtent'.
1933  for (int i = 0; i < _Rank - 1; ++i) {
1934  baseExtent[i] = _M_array_extent[i];
1935  viewOffset[i] = _M_view_offset[i];
1936  viewExtent[i] = _M_view_extent[i];
1937  }
1938 #pragma warning( pop )
1939 
1940  // The extent in the least significant dimension needs to be adjusted for
1941  // difference in element size between the buffer and ourselves
1942  _ASSERTE((baseLSDExtentInBytes / bufElemSize) <= UINT_MAX);
1943  baseExtent[_Rank - 1] = static_cast<unsigned int>(baseLSDExtentInBytes / bufElemSize);
1944 
1945  _ASSERTE((viewLSDOffsetInBytes / bufElemSize) <= UINT_MAX);
1946  viewOffset[_Rank - 1] = static_cast<unsigned int>(viewLSDOffsetInBytes / bufElemSize);
1947 
1948  _ASSERTE((viewLSDExtentInBytes / bufElemSize) <= UINT_MAX);
1949  viewExtent[_Rank - 1] = static_cast<unsigned int>(viewLSDExtentInBytes / bufElemSize);
1950 
1951  return _View_shape::_Create_view_shape(_Rank, linearOffset, baseExtent, viewOffset, viewExtent);
1952  }
1953 
1954 protected:
1955 
1956  // Underlying storage
1957  _Buffer_descriptor _M_buffer_descriptor;
1958 
1959 private:
1960 
1962  {
1963  _M_buffer_descriptor._Get_buffer_ptr()->_Register_view(_M_buffer_descriptor._Get_view_key(),
1965  _Create_buffer_view_shape());
1966 
1967  if (_M_buffer_descriptor._M_curr_cpu_access_mode != _No_access)
1968  {
1969  _Buffer_ptr _PBuf;
1970  _Get_access_async(_M_buffer_descriptor._Get_view_key(),
1972  _M_buffer_descriptor._M_curr_cpu_access_mode,
1973  _PBuf)._Get();
1974 
1975  _M_buffer_descriptor._M_data_ptr = _PBuf->_Get_host_ptr();
1976  }
1977  }
1978 
1980  {
1981  _M_buffer_descriptor._Get_buffer_ptr()->_Register_view_copy(_M_buffer_descriptor._Get_view_key(), _Other._M_buffer_descriptor._Get_view_key());
1982  }
1983 
1984  void _Register(_In_ void* _Shape) __CPU_ONLY
1985  {
1986  if (_Shape == NULL) {
1987  return;
1988  }
1989 
1990  // Unregister and register with the right shape
1991  _Unregister();
1992 
1993  _M_buffer_descriptor._Get_buffer_ptr()->_Register_view(_M_buffer_descriptor._Get_view_key(),
1995  reinterpret_cast<_View_shape*>(_Shape));
1996 
1997  if (_M_buffer_descriptor._M_curr_cpu_access_mode != _No_access)
1998  {
1999  _Buffer_ptr _PBuf;
2000  _Get_access_async(_M_buffer_descriptor._Get_view_key(),
2002  _M_buffer_descriptor._M_curr_cpu_access_mode,
2003  _PBuf)._Get();
2004 
2005  _M_buffer_descriptor._M_data_ptr = _PBuf->_Get_host_ptr();
2006  }
2007  }
2008 
2009  void _Unregister(bool _Throw_exception = true) __CPU_ONLY
2010  {
2011  if (!_Throw_exception && (std::current_exception() == nullptr)) {
2012  _Throw_exception = true;
2013  }
2014 
2015  try
2016  {
2017  _M_buffer_descriptor._Get_buffer_ptr()->_Unregister_view(_M_buffer_descriptor._Get_view_key());
2018  }
2019  catch(...)
2020  {
2021  if (_Throw_exception) {
2022  throw;
2023  }
2024  }
2025  }
2026 
2027  static _Ret_ void* _Create_projection_buffer_shape(const _Buffer_descriptor& _Descriptor, unsigned int _Dim, int _Dim_offset) __CPU_ONLY
2028  {
2029  _View_shape* _Base_shape = _Get_buffer_view_shape(_Descriptor);
2030 
2031  std::vector<unsigned int> _New_view_extent(_Base_shape->_Get_rank());
2032  std::vector<unsigned int> _New_view_offset(_Base_shape->_Get_rank());
2033  bool *_New_projection_info = new bool[_Base_shape->_Get_rank()];
2034  for (unsigned int _I = 0; _I < _Base_shape->_Get_rank(); ++_I)
2035  {
2036  _New_view_extent[_I] = _Base_shape->_Get_view_extent()[_I];
2037  _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I];
2038  _New_projection_info[_I] = _Base_shape->_Get_projection_info()[_I];
2039  }
2040 
2041  // The _Dim'th non-projected dimension needs to be found
2042  unsigned int _UnProjectedDimCount = 0;
2043  for (unsigned int _I = 0; _I < _Base_shape->_Get_rank(); ++_I)
2044  {
2045  if (_Base_shape->_Get_projection_info()[_I]) {
2046  continue;
2047  }
2048 
2049  if (_UnProjectedDimCount == _Dim) {
2050  _New_view_extent[_I] = 1;
2051  _New_view_offset[_I] += _Dim_offset;
2052  _New_projection_info[_I] = true;
2053  break;
2054  }
2055  else {
2056  _UnProjectedDimCount++;
2057  }
2058  }
2059 
2060  auto _PView_shape = _View_shape::_Create_view_shape(_Base_shape->_Get_rank(),
2061  _Base_shape->_Get_linear_offset(),
2062  _Base_shape->_Get_base_extent(),
2063  _New_view_offset.data(),
2064  _New_view_extent.data(),
2065  _New_projection_info);
2066 
2067  delete [] _New_projection_info;
2068 
2069  return _PView_shape;
2070  }
2071 
2072  static _Ret_ void* _Create_section_buffer_shape(const _Buffer_descriptor& _Descriptor,
2073  const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __CPU_ONLY
2074  {
2075  _View_shape* _Base_shape = _Get_buffer_view_shape(_Descriptor);
2076  if (_Base_shape->_Get_rank() == _Rank) {
2077  return NULL;
2078  }
2079 
2080  std::vector<unsigned int> _New_view_extent(_Base_shape->_Get_rank());
2081  std::vector<unsigned int> _New_view_offset(_Base_shape->_Get_rank());
2082  unsigned int _I = 0, _J = 0;
2083  while (_I < _Base_shape->_Get_rank())
2084  {
2085  if (_Base_shape->_Get_projection_info()[_I])
2086  {
2087  _New_view_extent[_I] = _Base_shape->_Get_view_extent()[_I];
2088  _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I];
2089  }
2090  else
2091  {
2092  // If _J is the least significant dimension, then we need to adjust the
2093  // offset and extent for the underlying buffer's element size
2094  if (_J == (_Rank - 1))
2095  {
2096  unsigned int bufElemSize = static_cast<unsigned int>(_Descriptor._Get_buffer_ptr()->_Get_master_buffer_elem_size());
2097  unsigned int elemSize = _Element_size * sizeof(int);
2098 
2099  size_t sectionLSDOriginInBytes = _Section_origin[_J];
2100  sectionLSDOriginInBytes *= elemSize;
2101 
2102  size_t sectionLSDExtentInBytes = _Section_extent[_J];
2103  sectionLSDExtentInBytes *= elemSize;
2104 
2105  // The section offset and extent must be compatible with the underlying
2106  // buffer's element size
2107  if (((sectionLSDOriginInBytes % bufElemSize) != 0) ||
2108  ((sectionLSDExtentInBytes % bufElemSize) != 0))
2109  {
2110  throw runtime_exception("The array_view section origin and/or extent is incompatible with the underlying buffer", E_FAIL);
2111  }
2112 
2113  // The extent in the least significant dimension needs to be adjusted for
2114  // difference in element size between the buffer and ourselves
2115  _ASSERTE((sectionLSDOriginInBytes / bufElemSize) <= UINT_MAX);
2116  _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I] + static_cast<unsigned int>(sectionLSDOriginInBytes / bufElemSize);
2117 
2118  _ASSERTE((sectionLSDExtentInBytes / bufElemSize) <= UINT_MAX);
2119  _New_view_extent[_I] = static_cast<unsigned int>(sectionLSDExtentInBytes / bufElemSize);
2120  }
2121  else
2122  {
2123  _New_view_extent[_I] = _Section_extent[_J];
2124  _New_view_offset[_I] = _Base_shape->_Get_view_offset()[_I] + _Section_origin[_J];
2125  }
2126 
2127  _J++;
2128  }
2129 
2130  _I++;
2131  }
2132 
2133  _ASSERTE(_J == _Rank);
2134 
2135  return _View_shape::_Create_view_shape(_Base_shape->_Get_rank(),
2136  _Base_shape->_Get_linear_offset(),
2137  _Base_shape->_Get_base_extent(),
2138  _New_view_offset.data(),
2139  _New_view_extent.data(),
2140  _Base_shape->_Get_projection_info());
2141  }
2142 
2144 
2146  {
2147  UNREFERENCED_PARAMETER(_Other);
2148  }
2149 
2150  void _Register(_In_ void* _Shape) __GPU_ONLY
2151  {
2152  UNREFERENCED_PARAMETER(_Shape);
2153  }
2154 
2155  void _Unregister(bool _Throw_exception = true) __GPU_ONLY
2156  {
2157  UNREFERENCED_PARAMETER(_Throw_exception);
2158  }
2159 
2160  static _Ret_ void* _Create_projection_buffer_shape(const _Buffer_descriptor& _Descriptor, int _Dim, int _I) __GPU_ONLY
2161  {
2162  UNREFERENCED_PARAMETER(_Descriptor);
2163  UNREFERENCED_PARAMETER(_Dim);
2164  UNREFERENCED_PARAMETER(_I);
2165 
2166  return NULL;
2167  }
2168 
2169  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
2170  {
2171  UNREFERENCED_PARAMETER(_Descriptor);
2172  UNREFERENCED_PARAMETER(_Section_origin);
2173  UNREFERENCED_PARAMETER(_Section_extent);
2174 
2175  return NULL;
2176  }
2177 };
2178 
2179 template<typename _Container>
2181 {
2182  template<class _Uty> static auto _Fn(_Uty _Val, decltype(_Val.size(), _Val.data(), 0)) -> std::true_type;
2183  template<class _Uty> static auto _Fn(_Uty _Val, ...) -> std::false_type;
2184  typedef decltype(_Fn(std::declval<_Container>(),0)) type;
2185 };
2186 
2187 } // namespace details
2188 
2189 
2200 template <typename _Value_type, int _Rank = 1> class array_view : public _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)>
2201 {
2202  typedef _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)> _Base;
2203 
2205  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");
2206 
2207  friend class details::_Array_view_projection_helper<_Value_type,_Rank>;
2208  friend class details::_Array_view_projection_helper<_Value_type,_Rank+1>;
2209 
2210  friend class array_view<_Value_type, _Rank>;
2211  friend class array_view<const _Value_type, _Rank>;
2212 
2213  friend class array_view<_Value_type, _Rank+1>;
2214  friend class array_view<const _Value_type, _Rank+1>;
2215 
2216  template <typename _T, int _R>
2217  friend class array;
2218 
2219  friend const _Buffer_descriptor& details::_Get_buffer_descriptor<array_view<_Value_type, _Rank>>(const array_view<_Value_type, _Rank>& _Array) __GPU;
2220 
2221 public:
2222  static const int rank = _Rank;
2223  typedef typename _Value_type value_type;
2224 
2225 
2229  ~array_view() __GPU {}
2230 
2239  : _Base(_Get_buffer_descriptor(_Src), _Src.extent)
2240  {
2241  _Initialize();
2242  }
2243 
2247  array_view(const array_view& _Other) __GPU
2248  : _Base(_Other)
2249  {
2250  _Initialize();
2251  }
2252 
2260  :_Base(_Extent)
2261  {
2262  _Initialize(_Extent.size(), true);
2263  }
2264 
2274  template <typename _Container> array_view(const Concurrency::extent<_Rank>& _Extent, _Container& _Src) __CPU_ONLY
2275  :_Base(_Src.data(),_Extent)
2276  {
2277  static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match");
2278  _Initialize(_Src.size());
2279  }
2280 
2291  array_view(const Concurrency::extent<_Rank>& _Extent, _Value_type * _Src) __GPU
2292  :_Base(_Src,_Extent)
2293  {
2294  _Initialize();
2295  }
2296 
2303  explicit array_view(int _E0) __CPU_ONLY
2304  :_Base(Concurrency::extent<1>(_E0))
2305  {
2306  static_assert(_Rank == 1, "rank must be 1");
2307  _Initialize(get_extent().size(), true);
2308  }
2309 
2317  template <typename _Container> explicit array_view(_Container& _Src, typename std::enable_if<details::_Is_container<_Container>::type::value,void **>::type = 0) __CPU_ONLY
2318  :_Base(_Src.data(), Concurrency::extent<1>(static_cast<int>(_Src.size())))
2319  {
2320  if (_Src.size() > INT_MAX) {
2321  throw runtime_exception("Invalid _Src container argument - _Src size is greater than INT_MAX", E_INVALIDARG);
2322  }
2323  static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match");
2324  static_assert(_Rank == 1, "rank must be 1");
2325  _Initialize(_Src.size());
2326  }
2327 
2337  template <typename _Container> explicit array_view(int _E0, _Container& _Src) __CPU_ONLY
2338  :_Base(_Src.data(), Concurrency::extent<1>(_E0))
2339  {
2340  static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match");
2341  static_assert(_Rank == 1, "rank must be 1");
2342  _Initialize(_Src.size());
2343  }
2344 
2354  explicit array_view(int _E0, int _E1) __CPU_ONLY
2355  :_Base(Concurrency::extent<2>(_E0,_E1))
2356  {
2357  static_assert(_Rank == 2, "rank must be 2");
2358  _Initialize(get_extent().size(), true);
2359  }
2360 
2373  template <typename _Container> explicit array_view(int _E0, int _E1, _Container& _Src) __CPU_ONLY
2374  :_Base(_Src.data(), Concurrency::extent<2>(_E0,_E1))
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 == 2, "rank must be 2");
2378  _Initialize(_Src.size());
2379  }
2380 
2393  explicit array_view(int _E0, int _E1, int _E2) __CPU_ONLY
2394  :_Base(Concurrency::extent<3>(_E0,_E1,_E2))
2395  {
2396  static_assert(_Rank == 3, "rank must be 3");
2397  _Initialize(get_extent().size(), true);
2398  }
2399 
2415  template <typename _Container> explicit array_view(int _E0, int _E1, int _E2, _Container& _Src) __CPU_ONLY
2416  :_Base(_Src.data(), Concurrency::extent<3>(_E0,_E1,_E2))
2417  {
2418  static_assert( std::is_same<decltype(_Src.data()), _Value_type*>::value, "container element type and array view element type must match");
2419  static_assert(_Rank == 3, "rank must be 3");
2420  _Initialize(_Src.size());
2421  }
2422 
2433  explicit array_view(int _E0, _In_ _Value_type * _Src) __GPU
2434  :_Base(_Src, Concurrency::extent<1>(_E0))
2435  {
2436  static_assert(_Rank == 1, "rank must be 1");
2437  _Initialize();
2438  }
2439 
2446  template <typename _Arr_type, int _Size> explicit array_view(_In_ _Arr_type (&_Src) [_Size]) __GPU
2448  {
2449  static_assert( std::is_same<typename std::remove_reference<decltype(*_Src)>::type, _Value_type>::value, "container element type and array view element type must match");
2450  static_assert(_Rank == 1, "rank must be 1");
2451  _Initialize();
2452  }
2453 
2467  explicit array_view(int _E0, int _E1, _In_ _Value_type * _Src) __GPU
2468  :_Base(_Src, Concurrency::extent<2>(_E0,_E1))
2469  {
2470  static_assert(_Rank == 2, "rank must be 2");
2471  _Initialize();
2472  }
2473 
2490  explicit array_view(int _E0, int _E1, int _E2, _In_ _Value_type * _Src) __GPU
2491  :_Base(_Src, Concurrency::extent<3>(_E0,_E1,_E2))
2492  {
2493  static_assert(_Rank == 3, "rank must be 3");
2494  _Initialize();
2495  }
2496 
2500  array_view& operator=(const array_view& _Other) __GPU
2501  {
2502  _Base::operator=(_Other);
2503  return *this;
2504  }
2505 
2510  {
2511  copy(*this,_Dest);
2512  }
2513 
2518  {
2519  copy(*this,_Dest);
2520  }
2521 
2533  {
2535  }
2536 
2550  value_type& get_ref(const index<_Rank>& _Index) const __GPU
2551  {
2552  void *_Ptr = _Access(_Index);
2553  return *reinterpret_cast<value_type*>(_Ptr);
2554  }
2555 
2565  value_type& operator[] (const index<_Rank>& _Index) const __GPU
2566  {
2567  return this->operator()(_Index);
2568  }
2569 
2579  value_type& operator() (const index<_Rank>& _Index) const __GPU
2580  {
2581  void * _Ptr = _Access(_Read_write_access, _Index);
2582  return *reinterpret_cast<value_type*>(_Ptr);
2583  }
2584 
2596  {
2598  }
2599 
2612  value_type& operator() (int _I0, int _I1) const __GPU
2613  {
2614  static_assert(_Rank == 2, "value_type& array_view::operator()(int,int) is only permissible on array_view<T, 2>");
2615  return this->operator()(index<2>(_I0,_I1));
2616  }
2617 
2633  value_type& operator() (int _I0, int _I1, int _I2) const __GPU
2634  {
2635  static_assert(_Rank == 3, "value_type& array_view::operator()(int,int,int) is only permissible on array_view<T, 3>");
2636  return this->operator()(index<3>(_I0,_I1,_I2));
2637  }
2638 
2651  array_view section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU
2652  {
2653  return _Convert<_Value_type>(_Section(_Section_origin, _Section_extent));
2654  }
2655 
2667  {
2668  return section(_Idx, this->extent - _Idx);
2669  }
2670 
2682  {
2683  return section(Concurrency::index<_Rank>(), _Ext);
2684  }
2685 
2699  array_view section(int _I0, int _E0) const __GPU
2700  {
2701  static_assert(_Rank == 1, "rank must be 1");
2702  return section(Concurrency::index<1>(_I0), Concurrency::extent<1>(_E0));
2703  }
2704 
2724  array_view section(int _I0, int _I1, int _E0, int _E1) const __GPU
2725  {
2726  static_assert(_Rank == 2, "rank must be 2");
2727  return section(Concurrency::index<2>(_I0,_I1), Concurrency::extent<2>(_E0,_E1));
2728  }
2729 
2755  array_view section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU
2756  {
2757  static_assert(_Rank == 3, "rank must be 3");
2758  return section(Concurrency::index<3>(_I0,_I1,_I2), Concurrency::extent<3>(_E0,_E1,_E2));
2759  }
2760 
2769  template <typename _Value_type2> array_view<_Value_type2, _Rank> reinterpret_as() const __GPU
2770  {
2771  return _Convert<_Value_type2>(this->template _Reinterpret_as<sizeof(_Value_type2)/sizeof(int)>());
2772  }
2773 
2783  template <int _New_rank> array_view<_Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) const __GPU
2784  {
2785  return _Convert<_Value_type>(_View_as(_View_extent));
2786  }
2787 
2791  _Ret_ _Value_type* data() const __GPU
2792  {
2793  static_assert(_Rank == 1, "array_view::data() is only permissible on array_view<T, 1>");
2794  return &this->operator[](index<_Rank>());
2795  }
2796 
2801  void refresh() const __CPU_ONLY
2802  {
2803  // If the array_view corresponds to a ubiquitous buffer with no data source,
2804  // then refresh is a no-op
2805  if (!_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) {
2806  return;
2807  }
2808 
2809  _Buffer_ptr _PBuf;
2810  _Get_access_async(_M_buffer_descriptor._Get_view_key(), _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Write_access, _PBuf)._Get();
2811  }
2812 
2827  {
2828  auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(_M_buffer_descriptor);
2829 
2830  _Buffer_ptr _PBuf;
2831  _Event _Ev;
2832 
2833  if (_Access_type != access_type_none) {
2834  _Ev = _Get_access_async(_M_buffer_descriptor._Get_view_key(), _Accl_view, _Get_synchronize_access_mode(_Access_type), _PBuf);
2835  }
2836 
2837  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
2838  }
2839 
2851  {
2852  auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(_M_buffer_descriptor);
2853 
2854  _Buffer_ptr _PBuf;
2855  _Event _Ev;
2856 
2857  // If the array_view corresponds to a ubiquitous buffer with no data source, then synchronize is a no-op
2858  if ((_Access_type != access_type_none) && _M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source())
2859  {
2860  _Ev = _Get_access_async(_M_buffer_descriptor._Get_view_key(),
2861  _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(),
2862  _Get_synchronize_access_mode(_Access_type),
2863  _PBuf);
2864  }
2865 
2866  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
2867  }
2868 
2879  void synchronize_to(const accelerator_view& _Accl_view, access_type _Access_type = access_type_read) const __CPU_ONLY
2880  {
2881  auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor);
2882 
2883  _Buffer_ptr _PBuf;
2884 
2885  if (_Access_type != access_type_none) {
2886  _Get_access_async(_M_buffer_descriptor._Get_view_key(), _Accl_view, _Get_synchronize_access_mode(_Access_type), _PBuf)._Get();
2887  }
2888 
2890  }
2891 
2900  {
2901  auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor);
2902 
2903  _Buffer_ptr _PBuf;
2904 
2905  // If the array_view corresponds to a ubiquitous buffer with no data source, then synchronize is a no-op
2906  if ((_Access_type != access_type_none) && _M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source())
2907  {
2908  _Get_access_async(_M_buffer_descriptor._Get_view_key(),
2909  _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(),
2910  _Get_synchronize_access_mode(_Access_type),
2911  _PBuf)._Get();
2912  }
2913 
2915  }
2916 
2925  {
2926  _M_buffer_descriptor._Get_buffer_ptr()->_Discard(_M_buffer_descriptor._Get_view_key());
2927  }
2928 
2934  {
2935  if (_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) {
2936  return _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view();
2937  }
2938  else {
2939  throw runtime_exception("Cannot query source accelerator_view for an array_view without a data source.", E_INVALIDARG);
2940  }
2941  }
2942 
2943  __declspec(property(get=get_source_accelerator_view)) accelerator_view source_accelerator_view;
2944 
2945 private:
2946  template <typename _T, int _R>
2947  static array_view<_T,_R> _Convert(const _Array_view_base<_R,sizeof(_T)/sizeof(int)>& _Other) __GPU
2948  {
2949  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");
2950  return (*reinterpret_cast<const array_view<_T,_R>*>(&_Other));
2951  }
2952 
2953  void _Project0(int _I, array_view<_Value_type, _Rank-1> &_Projected_view) const __GPU
2954  {
2955  _Base::_Project0(_I, _Projected_view);
2956  _Projected_view._Initialize();
2957  }
2958 
2959  array_view() __GPU {}
2960 
2961  array_view(const array_view& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
2962  :_Base(_Other, _Section_origin, _Section_extent)
2963  {
2964  _Initialize();
2965  }
2966 
2967  array_view(_Buffer_descriptor& _Src_buffer, const Concurrency::extent<_Rank>& _Extent) __GPU
2968  :_Base(_Src_buffer,_Extent)
2969  {
2970  _Initialize();
2971  }
2972 
2973  void _Initialize() __GPU
2974  {
2975  // Set the type access mode
2976  _M_buffer_descriptor._M_type_access_mode = _Read_write_access;
2977  }
2978 
2979  void _Initialize(size_t _Src_data_size, bool _Discard_data = false) __CPU_ONLY
2980  {
2981  // Ensure that the _Src_data_size is at least as big as the size
2982  // of the array_view
2983  if (_Src_data_size < this->extent.size()) {
2984  throw runtime_exception("Invalid _Src container argument - _Src size is less than the size of the array_view.", E_INVALIDARG);
2985  }
2986 
2987  _Initialize();
2988 
2989  if (_Discard_data) {
2990  discard_data();
2991  }
2992  }
2993 
2994 }; // class array_view<T,R>
2995 
2996 // array_view<const T,R>
2997 template <typename _Value_type, int _Rank>
2998 class array_view<const _Value_type, _Rank> : public _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)>
2999 {
3001  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");
3002 
3003  typedef _Array_view_base<_Rank, sizeof(_Value_type)/sizeof(int)> _Base;
3004 
3005  friend class details::_Const_array_view_projection_helper<_Value_type,_Rank>;
3006  friend class details::_Const_array_view_projection_helper<_Value_type,_Rank+1>;
3007 
3008  friend class array_view<_Value_type, _Rank>;
3009  friend class array_view<const _Value_type, _Rank>;
3010 
3011  friend class array_view<_Value_type, _Rank+1>;
3012  friend class array_view<const _Value_type, _Rank+1>;
3013 
3014  friend const _Buffer_descriptor& details::_Get_buffer_descriptor<array_view<const _Value_type, _Rank>>(const array_view<const _Value_type, _Rank>& _Array) __GPU;
3015 
3016 public:
3017  static const int rank = _Rank;
3018  typedef typename const _Value_type value_type;
3019 
3023  ~array_view() __GPU {}
3024 
3033  :_Base(_Get_buffer_descriptor(_Src), _Src.extent)
3034  {
3035  _Initialize();
3036  }
3037 
3042  :_Base(_Src)
3043  {
3044  _Initialize();
3045  }
3046 
3051  :_Base(_Src)
3052  {
3053  }
3054 
3064  template <typename _Container> array_view(const Concurrency::extent<_Rank>& _Extent, const _Container& _Src) __CPU_ONLY
3065  :_Base(_Src.data(),_Extent)
3066  {
3067  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");
3068  _Initialize(_Src.size());
3069  }
3070 
3081  template <typename _Container> explicit array_view(const _Container& _Src, typename std::enable_if<details::_Is_container<_Container>::type::value,void **>::type = 0) __CPU_ONLY
3082  :_Base(_Src.data(), Concurrency::extent<1>(static_cast<int>(_Src.size())))
3083  {
3084  if (_Src.size() > INT_MAX) {
3085  throw runtime_exception("Invalid _Src container argument - _Src size is greater than INT_MAX", E_INVALIDARG);
3086  }
3087  static_assert( std::is_same<decltype(_Src.data()), const _Value_type*>::value, "container element type and array view element type must match");
3088  static_assert(_Rank == 1, "rank must be 1");
3089  _Initialize(_Src.size());
3090  }
3091 
3101  template <typename _Container> array_view(const Concurrency::extent<_Rank>& _Extent, _Container& _Src) __CPU_ONLY
3102  :_Base(_Src.data(),_Extent)
3103  {
3104  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");
3105  _Initialize(_Src.size());
3106  }
3107 
3118  array_view(const Concurrency::extent<_Rank>& _Extent, const _Value_type * _Src) __GPU
3119  :_Base(_Src,_Extent)
3120  {
3121  _Initialize();
3122  }
3123 
3134  array_view(const Concurrency::extent<_Rank>& _Extent, _In_ _Value_type * _Src) __GPU
3135  :_Base(_Src,_Extent)
3136  {
3137  _Initialize();
3138  }
3139 
3149  template <typename _Container> array_view(int _E0, const _Container& _Src) __CPU_ONLY
3150  :_Base(_Src.data(), Concurrency::extent<1>(_E0))
3151  {
3152  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");
3153  static_assert(_Rank == 1, "rank must be 1");
3154  _Initialize(_Src.size());
3155  }
3156 
3164  template <typename _Arr_type, int _Size> explicit array_view(const _In_ _Arr_type (&_Src) [_Size]) __GPU
3166  {
3167  static_assert( std::is_same<typename std::remove_const<typename std::remove_reference<decltype(*_Src)>::type>::type, _Value_type>::value, "container element type and array view element type must match");
3168  static_assert(_Rank == 1, "rank must be 1");
3169  _Initialize();
3170  }
3171 
3184  template <typename _Container> array_view(int _E0, int _E1, const _Container& _Src) __CPU_ONLY
3185  :_Base(_Src.data(), Concurrency::extent<2>(_E0,_E1))
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 == 2, "rank must be 2");
3189  _Initialize(_Src.size());
3190  }
3191 
3207  template <typename _Container> array_view(int _E0, int _E1, int _E2, const _Container& _Src) __CPU_ONLY
3208  :_Base(_Src.data(), Concurrency::extent<3>(_E0,_E1,_E2))
3209  {
3210  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");
3211  static_assert(_Rank == 3, "rank must be 3");
3212  _Initialize(_Src.size());
3213  }
3214 
3225  array_view(int _E0, const _Value_type * _Src) __GPU
3226  :_Base(_Src, Concurrency::extent<1>(_E0))
3227  {
3228  static_assert(_Rank == 1, "rank must be 1");
3229  _Initialize();
3230  }
3231 
3245  array_view(int _E0, int _E1, const _Value_type * _Src) __GPU
3246  :_Base(_Src, Concurrency::extent<2>(_E0,_E1))
3247  {
3248  static_assert(_Rank == 2, "rank must be 2");
3249  _Initialize();
3250  }
3251 
3268  array_view(int _E0, int _E1, int _E2, const _Value_type * _Src) __GPU
3269  :_Base(_Src, Concurrency::extent<3>(_E0,_E1,_E2))
3270  {
3271  static_assert(_Rank == 3, "rank must be 3");
3272  _Initialize();
3273  }
3274 
3285  array_view(int _E0, _In_ _Value_type * _Src) __GPU
3286  :_Base(_Src, Concurrency::extent<1>(_E0))
3287  {
3288  static_assert(_Rank == 1, "rank must be 1");
3289  _Initialize();
3290  }
3291 
3305  array_view(int _E0, int _E1, _In_ _Value_type * _Src) __GPU
3306  :_Base(_Src, Concurrency::extent<2>(_E0,_E1))
3307  {
3308  static_assert(_Rank == 2, "rank must be 2");
3309  _Initialize();
3310  }
3311 
3328  array_view(int _E0, int _E1, int _E2, _In_ _Value_type * _Src) __GPU
3329  :_Base(_Src, Concurrency::extent<3>(_E0,_E1,_E2))
3330  {
3331  static_assert(_Rank == 3, "rank must be 3");
3332  _Initialize();
3333  }
3334 
3338  array_view& operator=(const array_view& _Other) __GPU
3339  {
3340  _Base::operator=(_Other);
3341  return *this;
3342  }
3343 
3348  {
3349  _Base::operator=(_Other);
3350  return *this;
3351  }
3352 
3357  {
3358  copy(*this,_Dest);
3359  }
3360 
3365  {
3366  copy(*this,_Dest);
3367  }
3368 
3380  {
3382  }
3383 
3397  value_type& get_ref(const index<_Rank>& _Index) const __GPU
3398  {
3399  void *_Ptr = _Access(_Index);
3400  return *reinterpret_cast<value_type*>(_Ptr);
3401  }
3402 
3412  value_type& operator[] (const index<_Rank>& _Index) const __GPU
3413  {
3414  return this->operator()(_Index);
3415  }
3416 
3426  value_type& operator() (const index<_Rank>& _Index) const __GPU
3427  {
3428  void * _Ptr = _Access(_Read_access, _Index);
3429  return *reinterpret_cast<value_type*>(_Ptr);
3430  }
3431 
3443  {
3445  }
3446 
3459  value_type& operator() (int _I0, int _I1) const __GPU
3460  {
3461  static_assert(_Rank == 2, "value_type& array_view::operator()(int,int) is only permissible on array_view<T, 2>");
3462  return this->operator()(index<2>(_I0,_I1));
3463  }
3464 
3480  value_type& operator() (int _I0, int _I1, int _I2) const __GPU
3481  {
3482  static_assert(_Rank == 3, "value_type& array_view::operator()(int,int,int) is only permissible on array_view<T, 3>");
3483  return this->operator()(index<3>(_I0,_I1,_I2));
3484  }
3485 
3498  array_view section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU
3499  {
3500  return _Convert<_Value_type>(_Section(_Section_origin, _Section_extent));
3501  }
3502 
3514  {
3515  return section(Concurrency::index<_Rank>(), _Ext);
3516  }
3517 
3529  {
3530  return section(_Idx, this->extent - _Idx);
3531  }
3532 
3546  array_view section(int _I0, int _E0) const __GPU
3547  {
3548  static_assert(_Rank == 1, "rank must be 1");
3549  return section(Concurrency::index<1>(_I0), Concurrency::extent<1>(_E0));
3550  }
3551 
3571  array_view section(int _I0, int _I1, int _E0, int _E1) const __GPU
3572  {
3573  static_assert(_Rank == 2, "rank must be 2");
3574  return section(Concurrency::index<2>(_I0,_I1), Concurrency::extent<2>(_E0,_E1));
3575  }
3576 
3602  array_view section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU
3603  {
3604  static_assert(_Rank == 3, "rank must be 3");
3605  return section(Concurrency::index<3>(_I0,_I1,_I2), Concurrency::extent<3>(_E0,_E1,_E2));
3606  }
3607 
3616  template <typename _Value_type2> array_view<const _Value_type2, _Rank> reinterpret_as() const __GPU
3617  {
3618  return _Convert<_Value_type2>(this->template _Reinterpret_as<sizeof(_Value_type2)/sizeof(int)>());
3619  }
3620 
3630  template <int _New_rank> array_view<const _Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) const __GPU
3631  {
3632  return _Convert<_Value_type>(_View_as(_View_extent));
3633  }
3634 
3638  const _Value_type* data() const __GPU
3639  {
3640  static_assert(_Rank == 1, "array_view::data() is only permissible on array_view<T, 1>");
3641  return &this->operator[](index<_Rank>());
3642  }
3643 
3648  void refresh() const __CPU_ONLY
3649  {
3650  _Buffer_ptr _PBuf;
3651  _Get_access_async(_M_buffer_descriptor._Get_view_key(), _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Write_access, _PBuf)._Get();
3652  }
3653 
3664  {
3665  auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(_M_buffer_descriptor);
3666 
3667  _Buffer_ptr _PBuf;
3668  _Event _Ev;
3669 
3670  _Ev = _Get_access_async(_M_buffer_descriptor._Get_view_key(), _Accl_view, _Read_access, _PBuf);
3671 
3672  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
3673  }
3674 
3682  {
3683  auto _Async_op_id = details::_Get_amp_trace()->_Launch_array_view_synchronize_event_helper(_M_buffer_descriptor);
3684 
3685  _Buffer_ptr _PBuf;
3686  _Event _Ev;
3687 
3688  // If the array_view corresponds to a ubiquitous buffer with no data source,
3689  // then synchronize is a no-op
3690  if (_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) {
3691  _Ev = _Get_access_async(_M_buffer_descriptor._Get_view_key(), _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Read_access, _PBuf);
3692  }
3693 
3694  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
3695  }
3696 
3703  void synchronize_to(const accelerator_view& _Accl_view) const __CPU_ONLY
3704  {
3705  auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor);
3706 
3707  _Buffer_ptr _PBuf;
3708 
3709  _Get_access_async(_M_buffer_descriptor._Get_view_key(), _Accl_view, _Read_access, _PBuf)._Get();
3710 
3712  }
3713 
3718  {
3719  auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor);
3720 
3721  _Buffer_ptr _PBuf;
3722 
3723  // If the array_view corresponds to a ubiquitous buffer with no data source,
3724  // then synchronize is a no-op
3725  if (_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) {
3726  _Get_access_async(_M_buffer_descriptor._Get_view_key(), _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view(), _Read_access, _PBuf)._Get();
3727  }
3728 
3730  }
3731 
3737  {
3738  if (_M_buffer_descriptor._Get_buffer_ptr()->_Has_data_source()) {
3739  return _M_buffer_descriptor._Get_buffer_ptr()->_Get_master_accelerator_view();
3740  }
3741  else {
3742  throw runtime_exception("Cannot query source accelerator_view for an array_view without a data source.", E_INVALIDARG);
3743  }
3744  }
3745 
3746  __declspec(property(get=get_source_accelerator_view)) accelerator_view source_accelerator_view;
3747 
3748 private:
3749  template <typename _T, int _R>
3750  static array_view<const _T,_R> _Convert(const _Array_view_base<_R,sizeof(_T)/sizeof(int)>& _Other) __GPU
3751  {
3752  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");
3753  return (*reinterpret_cast<const array_view<const _T,_R>*>(&_Other));
3754  }
3755 
3756  void _Project0(int _I, array_view<const _Value_type, _Rank-1> &_Projected_view) const __GPU
3757  {
3758  _Base::_Project0(_I, _Projected_view);
3759  _Projected_view._Initialize();
3760  }
3761 
3762  array_view() __GPU {}
3763 
3764  array_view(const array_view& _Other, const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) __GPU
3765  :
3766  _Base(_Other, _Section_origin, _Section_extent)
3767  {
3768  _Initialize();
3769  }
3770 
3771  void _Initialize() __GPU
3772  {
3773  // Set the type access mode
3774  _M_buffer_descriptor._M_type_access_mode = _Read_access;
3775  }
3776 
3777  void _Initialize(size_t _Src_data_size) __CPU_ONLY
3778  {
3779  // Ensure that the _Src_data_size is at least as big as the size
3780  // of the array_view
3781  if (_Src_data_size < this->extent.size()) {
3782  throw runtime_exception("Invalid _Src container argument - _Src size is less than the size of the array_view.", E_INVALIDARG);
3783  }
3784 
3785  _Initialize();
3786  }
3787 
3788 }; // class array_view<const T,R>
3789 
3790 // Forward declarations for copy functions
3791 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest);
3792 template <typename _Value_type, int _Rank> void copy(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest);
3793 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest);
3794 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest);
3795 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest);
3796 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest);
3797 template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter);
3798 template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter);
3799 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest);
3800 template <typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest);
3801 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest);
3802 template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest);
3803 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest);
3804 template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest);
3805 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);
3806 template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest);
3807 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);
3808 template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest);
3809 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest);
3810 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest);
3811 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest);
3812 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest);
3813 template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter);
3814 template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter);
3815 
3816 namespace direct3d
3817 {
3818  template<typename _Value_type, int _Rank>
3820 }
3821 
3831 template <typename _Value_type, int _Rank = 1> class array
3832 {
3833  // internal storage abstraction
3835  typedef _Array_flatten_helper<_Rank, typename Concurrency::extent<_Rank>::value_type, typename Concurrency::index<_Rank>::value_type> _Flatten_helper;
3836 
3837  _CPP_AMP_VERIFY_RANK(_Rank, array);
3838  static_assert(!std::is_const<_Value_type>::value, "array<const _Value_type> is not supported");
3839  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");
3840 
3841  // Friends
3842  template<typename _Value_type, int _Rank>
3844  friend const _Buffer_descriptor& details::_Get_buffer_descriptor<array<_Value_type,_Rank>>(const array<_Value_type,_Rank>& _Array) __GPU;
3845  friend _Ret_ _Ubiquitous_buffer* details::_Get_buffer<array<_Value_type,_Rank>>(const array<_Value_type,_Rank>& _Array) __CPU_ONLY;
3846  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;
3847 
3848  public:
3849  static const int rank = _Rank;
3850  typedef typename _Value_type value_type;
3851 
3858  explicit array(const Concurrency::extent<_Rank> & _Extent) __CPU_ONLY
3859  : _M_extent(_Extent)
3860  {
3861  _Initialize(details::_Select_default_accelerator().default_view, access_type_auto);
3862  }
3863 
3870  explicit array(int _E0) __CPU_ONLY
3871  : _M_extent(Concurrency::extent<_Rank>(_E0))
3872  {
3873  static_assert(_Rank == 1, "array(int) is only permissible on array<T, 1>");
3874  _Initialize(details::_Select_default_accelerator().default_view, access_type_auto);
3875  }
3876 
3886  explicit array(int _E0, int _E1) __CPU_ONLY
3887  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
3888  {
3889  static_assert(_Rank == 2, "array(int, int) is only permissible on array<T, 2>");
3890  _Initialize(details::_Select_default_accelerator().default_view, access_type_auto);
3891  }
3892 
3905  explicit array(int _E0, int _E1, int _E2) __CPU_ONLY
3906  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
3907  {
3908  static_assert(_Rank == 3, "array(int, int, int) is only permissible on array<T, 3>");
3909  _Initialize(details::_Select_default_accelerator().default_view, access_type_auto);
3910  }
3911 
3929  : _M_extent(_Extent)
3930  {
3931  _Initialize(_Av, _Cpu_access_type);
3932  }
3933 
3950  array(int _E0, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
3951  : _M_extent(Concurrency::extent<_Rank>(_E0))
3952  {
3953  static_assert(_Rank == 1, "array(int, accelerator_view) is only permissible on array<T, 1>");
3954  _Initialize(_Av, _Cpu_access_type);
3955  }
3956 
3976  array(int _E0, int _E1, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
3977  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
3978  {
3979  static_assert(_Rank == 2, "array(int, int, accelerator_view) is only permissible on array<T, 2>");
3980  _Initialize(_Av, _Cpu_access_type);
3981  }
3982 
4005  array(int _E0, int _E1, int _E2, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
4006  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4007  {
4008  static_assert(_Rank == 3, "array(int, int, int, accelerator_view) is only permissible on array<T, 3>");
4009  _Initialize(_Av, _Cpu_access_type);
4010  }
4011 
4025  : _M_extent(_Extent)
4026  {
4027  _Initialize(_Av, _Associated_Av);
4028  }
4029 
4042  array(int _E0, accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4043  : _M_extent(Concurrency::extent<_Rank>(_E0))
4044  {
4045  static_assert(_Rank == 1, "array(int, accelerator_view, accelerator_view) is only permissible on array<T, 1>");
4046  _Initialize(_Av, _Associated_Av);
4047  }
4048 
4064  array(int _E0, int _E1, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4065  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4066  {
4067  static_assert(_Rank == 2, "array(int, int, accelerator_view, accelerator_view) is only permissible on array<T, 2>");
4068  _Initialize(_Av, _Associated_Av);
4069  }
4070 
4089  array(int _E0, int _E1, int _E2, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4090  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4091  {
4092  static_assert(_Rank == 3, "array(int, int, int, accelerator_view, accelerator_view) is only permissible on array<T, 3>");
4093  _Initialize(_Av, _Associated_Av);
4094  }
4095 
4108  template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
4109  : _M_extent(_Extent)
4110  {
4111  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4112  }
4113 
4124  template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first) __CPU_ONLY
4125  : _M_extent(_Extent)
4126  {
4127  _InputIterator _Src_last = _Src_first;
4128  std::advance(_Src_last, this->extent.size());
4129 
4130  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4131  }
4132 
4145  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
4146  : _M_extent(Concurrency::extent<_Rank>(_E0))
4147  {
4148  static_assert(_Rank == 1, "array(int, iterator, iterator) is only permissible on array<T, 1>");
4149  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4150  }
4151 
4162  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first) __CPU_ONLY
4163  : _M_extent(Concurrency::extent<_Rank>(_E0))
4164  {
4165  static_assert(_Rank == 1, "array(int, iterator) is only permissible on array<T, 1>");
4166 
4167  _InputIterator _Src_last = _Src_first;
4168  std::advance(_Src_last, this->extent.size());
4169 
4170  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4171  }
4172 
4188  template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
4189  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4190  {
4191  static_assert(_Rank == 2, "array(int, int, iterator, iterator) is only permissible on array<T, 2>");
4192  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4193  }
4194 
4208  template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first) __CPU_ONLY
4209  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4210  {
4211  static_assert(_Rank == 2, "array(int, int, iterator) is only permissible on array<T, 2>");
4212 
4213  _InputIterator _Src_last = _Src_first;
4214  std::advance(_Src_last, this->extent.size());
4215 
4216  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4217  }
4218 
4235  template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
4236  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4237  {
4238  static_assert(_Rank == 3, "array(int, int, int, iterator, iterator) is only permissible on array<T, 3>");
4239  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4240  }
4241 
4258  template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first) __CPU_ONLY
4259  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4260  {
4261  static_assert(_Rank == 3, "array(int, int, int, iterator) is only permissible on array<T, 3>");
4262 
4263  _InputIterator _Src_last = _Src_first;
4264  std::advance(_Src_last, this->extent.size());
4265 
4266  _Initialize(details::_Select_default_accelerator().default_view, _Src_first, _Src_last, access_type_auto);
4267  }
4268 
4291  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
4292  : _M_extent(_Extent)
4293  {
4294  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4295  }
4296 
4317  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
4318  : _M_extent(_Extent)
4319  {
4320  _InputIterator _Src_last = _Src_first;
4321  std::advance(_Src_last, this->extent.size());
4322 
4323  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4324  }
4325 
4348  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
4349  : _M_extent(Concurrency::extent<_Rank>(_E0))
4350  {
4351  static_assert(_Rank == 1, "array(int, iterator, iterator) is only permissible on array<T, 1>");
4352  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4353  }
4354 
4375  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, Concurrency::accelerator_view _Av, access_type _Cpu_access_type = access_type_auto) __CPU_ONLY
4376  : _M_extent(Concurrency::extent<_Rank>(_E0))
4377  {
4378  static_assert(_Rank == 1, "array(int, iterator) is only permissible on array<T, 1>");
4379 
4380  _InputIterator _Src_last = _Src_first;
4381  std::advance(_Src_last, this->extent.size());
4382 
4383  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4384  }
4385 
4411  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
4412  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4413  {
4414  static_assert(_Rank == 2, "array(int, int, iterator, iterator) is only permissible on array<T, 2>");
4415  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4416  }
4417 
4441  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
4442  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4443  {
4444  static_assert(_Rank == 2, "array(int, int, iterator) is only permissible on array<T, 2>");
4445 
4446  _InputIterator _Src_last = _Src_first;
4447  std::advance(_Src_last, this->extent.size());
4448 
4449  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4450  }
4451 
4480  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
4481  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4482  {
4483  static_assert(_Rank == 3, "array(int, int, int, iterator, iterator) is only permissible on array<T, 3>");
4484  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4485  }
4486 
4513  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
4514  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4515  {
4516  static_assert(_Rank == 3, "array(int, int, int, iterator) is only permissible on array<T, 3>");
4517 
4518  _InputIterator _Src_last = _Src_first;
4519  std::advance(_Src_last, this->extent.size());
4520 
4521  _Initialize(_Av, _Src_first, _Src_last, _Cpu_access_type);
4522  }
4523 
4542  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
4543  : _M_extent(_Extent)
4544  {
4545  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4546  }
4547 
4564  template <typename _InputIterator> array(const Concurrency::extent<_Rank>& _Extent, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4565  : _M_extent(_Extent)
4566  {
4567  _InputIterator _Src_last = _Src_first;
4568  std::advance(_Src_last, this->extent.size());
4569 
4570  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4571  }
4572 
4591  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, _InputIterator _Src_last, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4592  : _M_extent(Concurrency::extent<_Rank>(_E0))
4593  {
4594  static_assert(_Rank == 1, "array(int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 1>");
4595  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4596  }
4597 
4614  template <typename _InputIterator> array(int _E0, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av)
4615  : _M_extent(Concurrency::extent<_Rank>(_E0))
4616  {
4617  static_assert(_Rank == 1, "array(int, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 1>");
4618 
4619  _InputIterator _Src_last = _Src_first;
4620  std::advance(_Src_last, this->extent.size());
4621 
4622  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4623  }
4624 
4646  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
4647  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4648  {
4649  static_assert(_Rank == 2, "array(int, int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 2>");
4650  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4651  }
4652 
4672  template <typename _InputIterator> array(int _E0, int _E1, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4673  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1))
4674  {
4675  static_assert(_Rank == 2, "array(int, int, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 2>");
4676 
4677  _InputIterator _Src_last = _Src_first;
4678  std::advance(_Src_last, this->extent.size());
4679 
4680  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4681  }
4682 
4707  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
4708  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4709  {
4710  static_assert(_Rank == 3, "array(int, int, int, iterator, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 3>");
4711  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4712  }
4713 
4736  template <typename _InputIterator> array(int _E0, int _E1, int _E2, _InputIterator _Src_first, Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
4737  : _M_extent(Concurrency::extent<_Rank>(_E0, _E1, _E2))
4738  {
4739  static_assert(_Rank == 3, "array(int, int, int, iterator, accelerator_view, accelerator_view) is only permissible on array<T, 3>");
4740 
4741  _InputIterator _Src_last = _Src_first;
4742  std::advance(_Src_last, this->extent.size());
4743 
4744  _Initialize(_Av, _Associated_Av, _Src_first, _Src_last);
4745  }
4746 
4753  explicit array(const array_view<const _Value_type,_Rank>& _Src) __CPU_ONLY
4754  :_M_extent(_Src.extent)
4755  {
4756  _Initialize(details::_Select_default_accelerator().default_view, access_type_auto);
4757  Concurrency::copy(_Src,*this);
4758  }
4759 
4777  :_M_extent(_Src.extent)
4778  {
4779  _Initialize(_Av, _Cpu_access_type);
4780  Concurrency::copy(_Src,*this);
4781  }
4782 
4796  :_M_extent(_Src.extent)
4797  {
4798  _Initialize(_Av, _Associated_Av);
4799  Concurrency::copy(_Src,*this);
4800  }
4801 
4805  array(const array& _Other) __CPU_ONLY
4806  : _M_extent(_Other._M_extent)
4807  {
4808  _Initialize(_Other.accelerator_view, _Other.associated_accelerator_view);
4809  Concurrency::copy(_Other, *this);
4810  }
4811 
4815  array(array && _Other) __CPU_ONLY
4816  : _M_extent(_Other._M_extent), _M_multiplier(_Other._M_multiplier)
4817  , _M_buffer_descriptor(_Other._M_buffer_descriptor)
4818  {
4819  // Register this
4820  this->_Register_copy(_Other);
4821 
4822  // Release the _Other array
4823  _Other._Unregister();
4824  _Other._M_buffer_descriptor._M_data_ptr = NULL;
4825  _Other._M_buffer_descriptor._Set_buffer_ptr(NULL);
4826  }
4827 
4831  array & operator= (const array & _Other) __CPU_ONLY
4832  {
4833  if (this != &_Other)
4834  {
4835  // First unregister myself from the current buffer
4836  _Unregister();
4837 
4838  _M_extent = _Other._M_extent;
4839  _Initialize(_Other.accelerator_view, _Other.associated_accelerator_view);
4840  Concurrency::copy(_Other, *this);
4841  }
4842  return *this;
4843  }
4844 
4848  array & operator= (array && _Other) __CPU_ONLY
4849  {
4850  if (this != &_Other)
4851  {
4852  // First unregister myself from the current buffer
4853  _Unregister();
4854 
4855  _M_extent = _Other._M_extent;
4856  _M_multiplier = _Other._M_multiplier;
4857  _M_buffer_descriptor = _Other._M_buffer_descriptor;
4858  this->_Register_copy(_Other);
4859 
4860  // Release the _Other array
4861  _Other._Unregister();
4862  _Other._M_buffer_descriptor._M_data_ptr = NULL;
4863  _Other._M_buffer_descriptor._Set_buffer_ptr(NULL);
4864  }
4865  return *this;
4866  }
4867 
4872  {
4873  Concurrency::copy(_Src,*this);
4874  return *this;
4875  }
4876 
4880  void copy_to(array<_Value_type,_Rank>& _Dest) const __CPU_ONLY
4881  {
4882  Concurrency::copy(*this, _Dest);
4883  }
4884 
4888  void copy_to(const array_view<_Value_type,_Rank>& _Dest) const __CPU_ONLY
4889  {
4890  Concurrency::copy(*this,_Dest);
4891  }
4892 
4896  __declspec(property(get=get_extent)) Concurrency::extent<_Rank> extent;
4897  Concurrency::extent<_Rank> get_extent() const __GPU
4898  {
4899  return _M_extent;
4900  }
4901 
4905  __declspec(property(get=get_accelerator_view)) Concurrency::accelerator_view accelerator_view;
4906  Concurrency::accelerator_view get_accelerator_view() const __CPU_ONLY
4907  {
4908  return _Get_buffer()->_Get_master_buffer()->_Get_access_on_accelerator_view();
4909  }
4910 
4914  __declspec(property(get=get_associated_accelerator_view)) Concurrency::accelerator_view associated_accelerator_view;
4915  Concurrency::accelerator_view get_associated_accelerator_view() const __CPU_ONLY
4916  {
4917  return _Get_buffer()->_Get_master_buffer()->_Get_accelerator_view();
4918  }
4919 
4923  __declspec(property(get=get_cpu_access_type)) access_type cpu_access_type;
4924  access_type get_cpu_access_type() const __CPU_ONLY
4925  {
4926  return _Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_type();
4927  }
4928 
4938  value_type& operator[] (const index<_Rank>& _Index) __GPU
4939  {
4940  // Refresh the data ptr if needed
4941  _Refresh_data_ptr(_Read_write_access);
4942 
4943  _Value_type * _Ptr = reinterpret_cast<_Value_type *>(_M_buffer_descriptor._M_data_ptr);
4944  return _Ptr[_Flatten_helper::func(_M_multiplier._M_base, _Index._M_base)];
4945  }
4946 
4956  const value_type& operator[] (const index<_Rank>& _Index) const __GPU
4957  {
4958  // Refresh the data ptr if needed
4959 #pragma warning( push )
4960 #pragma warning( disable : 4880 )
4961  // Casting away constness in amp restricted scope might result in
4962  // undefined behavior, therefore, the compiler will report a level 1 warning
4963  // for it. But the following const_cast is harmless thus we are suppressing
4964  // this warning just for this line.
4965  const_cast<array*>(this)->_Refresh_data_ptr(_Read_access);
4966 #pragma warning( pop )
4967 
4968  _Value_type * _Ptr = reinterpret_cast<_Value_type *>(_M_buffer_descriptor._M_data_ptr);
4969  return _Ptr[_Flatten_helper::func(_M_multiplier._M_base, _Index._M_base)];
4970  }
4971 
4983  {
4985  }
4986 
4998  {
5000  }
5001 
5011  value_type& operator() (const index<_Rank>& _Index) __GPU
5012  {
5013  return this->operator[](_Index);
5014  }
5015 
5025  const value_type& operator() (const index<_Rank>& _Index) const __GPU
5026  {
5027  return this->operator[](_Index);
5028  }
5029 
5042  value_type& operator() (int _I0, int _I1) __GPU
5043  {
5044  static_assert(_Rank == 2, "value_type& array::operator()(int, int) is only permissible on array<T, 2>");
5045  return this->operator[](index<2>(_I0, _I1));
5046  }
5047 
5060  const value_type& operator() (int _I0, int _I1) const __GPU
5061  {
5062  static_assert(_Rank == 2, "const value_type& array::operator()(int, int) is only permissible on array<T, 2>");
5063  return this->operator[](index<2>(_I0, _I1));
5064  }
5065 
5081  value_type& operator() (int _I0, int _I1, int _I2) __GPU
5082  {
5083  static_assert(_Rank == 3, "value_type& array::operator()(int, int, int) is only permissible on array<T, 3>");
5084  return this->operator[](index<3>(_I0, _I1, _I2));
5085  }
5086 
5102  const value_type& operator() (int _I0, int _I1, int _I2) const __GPU
5103  {
5104  static_assert(_Rank == 3, "const value_type& array::operator()(int, int, int) const is only permissible on array<T, 3>");
5105  return this->operator[](index<3>(_I0, _I1, _I2));
5106  }
5107 
5119  {
5121  }
5122 
5134  {
5136  }
5137 
5151  {
5152  array_view<_Value_type,_Rank> _T1(*this);
5153  return _T1.section(_Section_origin, _Section_extent);
5154  }
5155 
5168  array_view<const _Value_type,_Rank> section(const Concurrency::index<_Rank>& _Section_origin, const Concurrency::extent<_Rank>& _Section_extent) const __GPU
5169  {
5171  return _T1.section(_Section_origin, _Section_extent);
5172  }
5173 
5185  {
5186  return section(Concurrency::index<_Rank>(), _Ext);
5187  }
5188 
5200  {
5201  return section(Concurrency::index<_Rank>(), _Ext);
5202  }
5203 
5215  {
5216  array_view<_Value_type,_Rank> _T1(*this);
5217  return _T1.section(_Idx);
5218  }
5219 
5231  {
5233  return _T1.section(_Idx);
5234  }
5235 
5249  array_view<_Value_type,1> section(int _I0, int _E0) __GPU
5250  {
5251  array_view<_Value_type,_Rank> _T1(*this);
5252  return _T1.section(_I0,_E0);
5253  }
5254 
5268  array_view<const _Value_type,1> section(int _I0, int _E0) const __GPU
5269  {
5271  return _T1.section(_I0,_E0);
5272  }
5273 
5293  array_view<_Value_type,2> section(int _I0, int _I1, int _E0, int _E1) __GPU
5294  {
5295  array_view<_Value_type,_Rank> _T1(*this);
5296  return _T1.section(_I0,_I1,_E0,_E1);
5297  }
5298 
5318  array_view<const _Value_type,2> section(int _I0, int _I1, int _E0, int _E1) const __GPU
5319  {
5321  return _T1.section(_I0,_I1,_E0,_E1);
5322  }
5323 
5349  array_view<_Value_type,3> section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) __GPU
5350  {
5351  array_view<_Value_type,_Rank> _T1(*this);
5352  return _T1.section(_I0,_I1,_I2,_E0,_E1,_E2);
5353  }
5354 
5380  array_view<const _Value_type,3> section(int _I0, int _I1, int _I2, int _E0, int _E1, int _E2) const __GPU
5381  {
5383  return _T1.section(_I0,_I1,_I2,_E0,_E1,_E2);
5384  }
5385 
5393  template <typename _Value_type2> array_view<_Value_type2,1> reinterpret_as() __GPU
5394  {
5395  return array_view<_Value_type,1>(_M_buffer_descriptor, Concurrency::extent<1>(extent.size())).template reinterpret_as<_Value_type2>();
5396  }
5397 
5405  template <typename _Value_type2> array_view<const _Value_type2,1> reinterpret_as() const __GPU
5406  {
5407 #pragma warning( push )
5408 #pragma warning( disable : 4880 )
5409  // Casting away constness in amp restricted scope might result in
5410  // undefined behavior, therefore, the compiler will report a level 1 warning
5411  // for it. But the following const_cast is harmless thus we are suppressing
5412  // this warning just for this line.
5413  return const_cast<array*>(this)->reinterpret_as<_Value_type2>();
5414 #pragma warning( pop )
5415  }
5416 
5426  template <int _New_rank> array_view<_Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) __GPU
5427  {
5428  return array_view<_Value_type,_New_rank>(_M_buffer_descriptor, _View_extent);
5429  }
5430 
5440  template <int _New_rank> array_view<const _Value_type,_New_rank> view_as(const Concurrency::extent<_New_rank>& _View_extent) const __GPU
5441  {
5442 #pragma warning( push )
5443 #pragma warning( disable : 4880 )
5444  // Casting away constness in amp restricted scope might result in
5445  // undefined behavior, therefore, the compiler will report a level 1 warning
5446  // for it. But the following const_cast is harmless thus we are suppressing
5447  // this warning just for this line.
5448  return const_cast<array*>(this)->view_as<_New_rank>(_View_extent);
5449 #pragma warning( pop )
5450  }
5451 
5455  operator std::vector<_Value_type>() const __CPU_ONLY
5456  {
5457  std::vector<_Value_type> _return_vector(extent.size());
5458  Concurrency::copy(*this, _return_vector.begin());
5459 
5460  return _return_vector;
5461  }
5462 
5466  _Ret_ _Value_type* data() __GPU
5467  {
5468  _Refresh_data_ptr(_Read_write_access, false /* _Exception */);
5469  return reinterpret_cast<_Value_type*>(_M_buffer_descriptor._M_data_ptr);
5470  }
5471 
5475  const _Value_type* data() const __GPU
5476  {
5477 #pragma warning( push )
5478 #pragma warning( disable : 4880 )
5479  // Casting away constness in amp restricted scope might result in
5480  // undefined behavior, therefore, the compiler will report a level 1 warning
5481  // for it. But the following const_cast is harmless thus we are suppressing
5482  // this warning just for this line.
5483  const_cast<array*>(this)->_Refresh_data_ptr(_Read_access, false /* _Exception */);
5484 #pragma warning( pop )
5485  return reinterpret_cast<const _Value_type*>(_M_buffer_descriptor._M_data_ptr);
5486  }
5487 
5491  ~array() __CPU_ONLY
5492  {
5493  bool _Can_throw = (std::current_exception() == nullptr);
5494 
5495  // Destructor should not throw if we are already processing
5496  // an exception and another exception will result in termination
5497  try {
5498  _Unregister();
5499  }
5500  catch(...)
5501  {
5502  if (_Can_throw) {
5503  throw;
5504  }
5505  }
5506  }
5507 
5508 private:
5509 
5510  // No default constructor
5511  array() __CPU_ONLY;
5512 
5513  // Private constructor used by direct3d::make_array
5514  array(const Concurrency::extent<_Rank>& _Extent, _Buffer_descriptor _Buffer_descriptor)
5515  : _M_extent(_Extent), _M_buffer_descriptor(_Buffer_descriptor)
5516  {
5517  _Initialize();
5518 
5519  // Register this
5520  this->_Register();
5521  }
5522 
5523  // Initialize
5524  unsigned int _Initialize() __CPU_ONLY
5525  {
5526  details::_Is_valid_extent(_M_extent);
5527 
5528  // Arrays always have a type access mode of '_Is_array_mode'
5529  // This is the mechanism for differentiating between arrays and array_views by the runtime
5530  _M_buffer_descriptor._M_type_access_mode = _Is_array_mode;
5531  unsigned int totalExtent = _M_extent[_Rank-1];
5532  details::_Array_init_helper<Concurrency::extent<_Rank>, Concurrency::extent<_Rank>>::func(totalExtent, _M_multiplier, _M_extent);
5533 
5534  return totalExtent;
5535  }
5536 
5537  // Initialize and allocate on specified accelerator_view
5538  void _Initialize(Concurrency::accelerator_view _Av, access_type _Cpu_access_type) __CPU_ONLY
5539  {
5540  unsigned int totalExtent = _Initialize();
5541  // release the existing buffer if any before allocation new one
5542  _M_buffer_descriptor._Set_buffer_ptr(NULL);
5543 
5544  _Buffer_ptr _PBuf = _Buffer::_Create_buffer(_Av, _Av, totalExtent, sizeof(_Value_type), false /* _Is_temp */, _Cpu_access_type);
5545 
5546  _M_buffer_descriptor._Set_buffer_ptr(_Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf));
5547  _Register();
5548  }
5549 
5550  // Initialize and allocate on specified accelerator_view and copy specified data
5551  template <typename _InputIterator>
5552  void _Initialize(Concurrency::accelerator_view _Av, _InputIterator _Src_first, _InputIterator _Src_last, access_type _Cpu_access_type) __CPU_ONLY
5553  {
5554  _Initialize(_Av, _Cpu_access_type);
5555  copy(_Src_first, _Src_last, *this);
5556  }
5557 
5558  // Initialize and allocate on specified accelerator_views
5560  {
5561  unsigned int totalExtent = _Initialize();
5562 
5563  // Staging arrays can only be created if the accelerator_view is on the cpu_accelerator
5564  _Buffer_ptr _PBuf = NULL;
5565 
5566  // release the existing buffer if any before allocation new one
5567  _M_buffer_descriptor._Set_buffer_ptr(NULL);
5568 
5569  if (_Is_cpu_accelerator(_Av.accelerator))
5570  {
5571  // If the accelerator _Associated_Av supports zero-copy and the default cpu access type
5572  // for the accelerator is access_type_read_write, create a zero-copy buffer instead of a
5573  // staging buffer
5574  if (_Associated_Av.accelerator.supports_cpu_shared_memory && (_Get_recommended_buffer_host_access_mode(_Associated_Av) == _Read_write_access)) {
5575  _PBuf = _Buffer::_Create_buffer(_Associated_Av, _Av, totalExtent, sizeof(_Value_type), false /* _Is_temp */, access_type_read_write);
5576  }
5577  else {
5578  _PBuf = _Buffer::_Create_stage_buffer(_Associated_Av, _Av, totalExtent, sizeof(_Value_type));
5579  }
5580 
5581  _PBuf->_Map_buffer(_Read_write_access, true /* _Wait */);
5582  }
5583  else
5584  {
5585  _PBuf = _Buffer::_Create_buffer(_Av, _Av, totalExtent, sizeof(_Value_type), false /* _Is_temp */, access_type_auto);
5586  }
5587 
5588  _M_buffer_descriptor._Set_buffer_ptr(_Ubiquitous_buffer::_Create_ubiquitous_buffer(_PBuf));
5589  _Register();
5590  }
5591 
5592  // Initialize and allocate on specified accelerator_views
5593  template <typename _InputIterator>
5594  void _Initialize(Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av, _InputIterator _Src_first, _InputIterator _Src_last) __CPU_ONLY
5595  {
5596  _Initialize(_Av, _Associated_Av);
5597  copy(_Src_first, _Src_last, *this);
5598  }
5599 
5600  void _Register() __CPU_ONLY
5601  {
5604  _M_buffer_descriptor._Get_buffer_ptr()->_Register_view(_M_buffer_descriptor._Get_view_key(), cpuAv, _Create_buffer_view_shape());
5605 
5606  _M_buffer_descriptor._Get_buffer_ptr()->_Discard(_M_buffer_descriptor._Get_view_key());
5607 
5608  // If the array is on the CPU accelerator then we will ensure that the descriptor
5609  // indicates CPU access
5611  {
5612  _Buffer_ptr _PBuf = NULL;
5613  this->_Get_access_async(_Read_write_access, _PBuf, false)._Get();
5614  }
5615  }
5616 
5617  void _Register_copy(const array &_Other) __CPU_ONLY
5618  {
5619  _M_buffer_descriptor._Get_buffer_ptr()->_Register_view_copy(_M_buffer_descriptor._Get_view_key(), _Other._M_buffer_descriptor._Get_view_key());
5620  }
5621 
5622  void _Unregister() __CPU_ONLY
5623  {
5624  // No need to unregister if the array was moved causing the buffer ptr to be set to NULL
5625  if (_M_buffer_descriptor._Get_buffer_ptr() != NULL) {
5626  _M_buffer_descriptor._Get_buffer_ptr()->_Unregister_view(_M_buffer_descriptor._Get_view_key());
5627  }
5628  }
5629 
5631  {
5632  return _M_buffer_descriptor._Get_buffer_ptr();
5633  }
5634 
5635  _Event _Get_access_async(_Access_mode _Mode, _Buffer_ptr &_Buf_ptr, bool _Zero_copy_cpu_access = false) __CPU_ONLY const
5636  {
5637  _ASSERTE(!_Zero_copy_cpu_access || (_Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_mode() != _No_access));
5638 
5639  _Buffer_ptr _PBuf;
5640  Concurrency::accelerator_view _Access_av = _Zero_copy_cpu_access ? accelerator(accelerator::cpu_accelerator).default_view : this->accelerator_view;
5641  _Event _Ev = details::_Get_access_async(_M_buffer_descriptor._Get_view_key(),
5642  _Access_av,
5643  _Mode, _PBuf);
5644  _Buf_ptr = _PBuf;
5645 
5646  if (_Is_cpu_accelerator(_Access_av.accelerator)) {
5647  _Ev = _Ev._Add_continuation(std::function<_Event()>([_PBuf, this]() mutable -> _Event {
5648  const_cast<array*>(this)->_M_buffer_descriptor._M_data_ptr = _PBuf->_Get_host_ptr();
5649  return _Event();
5650  }));
5651  }
5652 
5653  return _Ev;
5654  }
5655 
5657  {
5658  _ASSERTE(_Get_buffer()->_Get_master_buffer_elem_size() == sizeof(_Value_type));
5659 
5660  unsigned int _ZeroOffset[_Rank] = {0};
5661  unsigned int _View_extent[_Rank];
5662  for(int i=0; i<_Rank; ++i)
5663  {
5664  _View_extent[i] = static_cast<unsigned int>(this->_M_extent[i]);
5665  }
5666  return _View_shape::_Create_view_shape(static_cast<unsigned int>(_Rank), 0, &_View_extent[0], &_ZeroOffset[0], &_View_extent[0]);
5667  }
5668 
5669  bool _Has_cpu_access() const __CPU_ONLY
5670  {
5671  return (_Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_mode() != _No_access);
5672  }
5673 
5674  void _Refresh_data_ptr(_Access_mode _Requested_mode, bool _Exception = true) __CPU_ONLY
5675  {
5676  _ASSERTE(_Is_valid_access_mode(_Requested_mode));
5677 
5678  // For an array that has CPU access, the maximum CPU access allowed is that allowed by
5679  // the underlying _Buffer allocation
5680  _Requested_mode = static_cast<_Access_mode>(_Requested_mode & _Get_buffer()->_Get_master_buffer()->_Get_allowed_host_access_mode());
5681 
5682  // Refresh the data ptr if we do not have requested access
5683  if ((_Requested_mode == _No_access) || ((_M_buffer_descriptor._M_curr_cpu_access_mode & _Requested_mode) != _Requested_mode))
5684  {
5685  if (_Has_cpu_access() && (_Requested_mode != _No_access))
5686  {
5687  auto _Span_id = details::_Get_amp_trace()->_Start_array_view_synchronize_event_helper(_M_buffer_descriptor);
5688  _Buffer_ptr _PBuf;
5689  bool _Zero_copy_cpu_access = !_Is_cpu_accelerator(this->accelerator_view.accelerator);
5690  this->_Get_access_async(_Requested_mode, _PBuf, _Zero_copy_cpu_access)._Get();
5692  }
5693  else
5694  {
5695  if (_Exception)
5696  {
5697  if (!_Has_cpu_access()) {
5698  throw runtime_exception("The array is not accessible on CPU.", E_FAIL);
5699  }
5700  else {
5701  throw runtime_exception("The array is not accessible for reading on CPU.", E_FAIL);
5702  }
5703  }
5704  }
5705  }
5706  }
5707 
5708  void _Refresh_data_ptr(_Access_mode _Requested_mode, bool _Exception = true) __GPU_ONLY
5709  {
5710  UNREFERENCED_PARAMETER(_Requested_mode);
5711  UNREFERENCED_PARAMETER(_Exception);
5712  }
5713 
5714 private:
5715  // Data members
5716 
5718 
5719  // Descriptor of the buffer underlying the array
5720  _Buffer_descriptor _M_buffer_descriptor;
5721 
5722  // The vector used for index calculation.
5724 };
5725 
5726 namespace details
5727 {
5728 template <typename _Value_type, int _Rank>
5730 {
5731  if (_Src.extent.size() > _Dest.extent.size())
5732  {
5733  throw runtime_exception("Invalid _Src argument. _Src size exceeds total size of the _Dest.", E_INVALIDARG);
5734  }
5735 
5736  // We can obliterate the exisiting content of dest if it is about to be totally overwritten
5737  _Access_mode _Dest_access_mode = (_Src.extent.size() == _Dest.extent.size()) ? _Write_access : _Read_write_access;
5738 
5739  _Buffer_ptr _PBufSrc, _PBufDest;
5740  _Event _Ev = _Get_access_async(_Src, _Read_access, _PBufSrc);
5741  _Ev = _Ev._Add_event(_Get_access_async(_Dest, _Dest_access_mode, _PBufDest));
5742  size_t _NumElemsToCopy = (_Src.extent.size() * sizeof(_Value_type)) / _PBufSrc->_Get_elem_size();
5743  return _Ev._Add_continuation(std::function<_Event()>([_PBufSrc, _PBufDest, _NumElemsToCopy]() mutable -> _Event {
5744  return details::_Copy_impl(_PBufSrc, 0, _PBufDest, 0, _NumElemsToCopy);
5745  }));
5746 }
5747 
5748 template <typename InputIterator, typename _Value_type, int _Rank>
5749 _Event _Copy_async_impl(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest)
5750 {
5751  size_t _NumElemsToCopy = std::distance(_SrcFirst, _SrcLast);
5752  // We can obliterate the exisiting content of dest if it is about to be totally overwritten
5753  _Access_mode _Dest_access_mode = (_NumElemsToCopy == _Dest.extent.size()) ? _Write_access : _Read_write_access;
5754  _Buffer_ptr _PDestBuf;
5755  _Event _Ev = _Get_access_async(_Dest, _Dest_access_mode, _PDestBuf);
5756 
5757  return _Ev._Add_continuation(std::function<_Event()>([_SrcFirst, _SrcLast, _PDestBuf, _NumElemsToCopy]() mutable -> _Event {
5758  return details::_Copy_impl<InputIterator, _Value_type>(_SrcFirst, _SrcLast, _NumElemsToCopy, _PDestBuf, 0);
5759  }));
5760 }
5761 
5762 template <typename OutputIterator, typename _Value_type, int _Rank>
5763 _Event _Copy_async_impl(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
5764 {
5765  _Buffer_ptr _PSrcBuf;
5766  _Event _Ev = _Get_access_async(_Src, _Read_access, _PSrcBuf);
5767  size_t _NumElemsToCopy = (_Src.extent.size() * sizeof(_Value_type)) / _PSrcBuf->_Get_elem_size();
5768  return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _NumElemsToCopy, _DestIter]() mutable -> _Event {
5769  return details::_Copy_impl<OutputIterator, _Value_type>(_PSrcBuf, 0, _NumElemsToCopy, _DestIter);
5770  }));
5771 }
5772 
5773 template <typename _Value_type, int _Rank>
5775 {
5776  const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src);
5777  const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest);
5778  if (_SrcBufDesc._Get_buffer_ptr() == _DestBufDesc._Get_buffer_ptr()) {
5779  throw runtime_exception("Cannot copy between overlapping regions of the same buffer.", E_INVALIDARG);
5780  }
5781 
5782  _Buffer_ptr _PSrcBuf, _PDestBuf;
5783  _Event _Ev = _Get_access_async(_Src, _Read_access, _PSrcBuf);
5784 
5785  // The source accelerator_view is driven by array's master location,
5786  // therefore we can pass nullptr to avoid unnecessary computation
5787  auto _AccelInfo = _Get_src_dest_accelerator_view(nullptr, &_DestBufDesc);
5788 
5789  _Ev = _Ev._Add_event(_Get_access_async(_DestBufDesc._Get_view_key(), _AccelInfo.second, _Write_access, _PDestBuf));
5790  _View_shape_ptr _PSrcShape = _Get_buffer_view_shape(_SrcBufDesc);
5791  _View_shape_ptr _PDestShape = _Get_buffer_view_shape(_DestBufDesc);
5792  return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape]() mutable -> _Event {
5793  return details::_Copy_impl(_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape);
5794  }));
5795 }
5796 
5797 template <typename _Value_type, int _Rank>
5799 {
5800  const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src);
5801  const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest);
5802  if (_SrcBufDesc._Get_buffer_ptr() == _DestBufDesc._Get_buffer_ptr()) {
5803  throw runtime_exception("Cannot copy between overlapping regions of the same buffer.", E_INVALIDARG);
5804  }
5805 
5806  auto _AccelInfo = _Get_src_dest_accelerator_view(&_SrcBufDesc, &_DestBufDesc);
5807 
5808  _Buffer_ptr _PSrcBuf, _PDestBuf;
5809  _Event _Ev = _Get_access_async(_SrcBufDesc._Get_view_key(), _AccelInfo.first, _Read_access, _PSrcBuf);
5810  _Ev = _Ev._Add_event(_Get_access_async(_Dest, _Write_access, _PDestBuf));
5811  _View_shape_ptr _PSrcShape = _Get_buffer_view_shape(_SrcBufDesc);
5812  _View_shape_ptr _PDestShape = _Get_buffer_view_shape(_DestBufDesc);
5813  return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape]() mutable -> _Event {
5814  return details::_Copy_impl(_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape);
5815  }));
5816 }
5817 
5818 template <typename _Value_type, int _Rank>
5820 {
5821  const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src);
5822  const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest);
5823  _View_shape_ptr _PSrcShape = _Get_buffer_view_shape(_SrcBufDesc);
5824  _View_shape_ptr _PDestShape = _Get_buffer_view_shape(_DestBufDesc);
5825  if ((_SrcBufDesc._Get_buffer_ptr() == _DestBufDesc._Get_buffer_ptr()) && _PSrcShape->_Overlaps(_PDestShape)) {
5826  throw runtime_exception("Cannot copy between overlapping regions of the same buffer.", E_INVALIDARG);
5827  }
5828 
5829  auto _AccelInfo = _Get_src_dest_accelerator_view(&_SrcBufDesc, &_DestBufDesc);
5830 
5831  _Buffer_ptr _PSrcBuf, _PDestBuf;
5832  _Event _Ev = _Get_access_async(_SrcBufDesc._Get_view_key(), _AccelInfo.first, _Read_access, _PSrcBuf);
5833  _Ev = _Ev._Add_event(_Get_access_async(_DestBufDesc._Get_view_key(), _AccelInfo.second, _Write_access, _PDestBuf));
5834  return _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape]() mutable -> _Event {
5835  return details::_Copy_impl(_PSrcBuf, _PSrcShape, _PDestBuf, _PDestShape);
5836  }));
5837 }
5838 
5839 template <typename InputIterator, typename _Value_type, int _Rank>
5840 _Event _Copy_async_impl(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest)
5841 {
5842  static_assert(!std::is_const<_Value_type>::value, "Cannot copy to array_view<const _Value_type, _Rank>.");
5843 
5844  size_t _Src_size = std::distance(_SrcFirst, _SrcLast);
5845 
5846  // Source cannot be greater than destination
5847  if (_Src_size > _Dest.extent.size())
5848  {
5849  throw runtime_exception("Number of elements in range between [_SrcFirst, _SrcLast) exceeds total size of the _Dest.", E_INVALIDARG);
5850  }
5851 
5852 #pragma warning( push )
5853 #pragma warning( disable : 4127 ) // Disable warning about constant conditional expression
5854  // Higher ranks need to have as many elements as in _Dest array_view
5855  if ((_Rank > 1) && (_Src_size != _Dest.extent.size()))
5856  {
5857  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);
5858  }
5859 #pragma warning( pop )
5860 
5861  // We can obliterate the exisiting content of dest if it is about to be totally overwritten
5862  _Access_mode _Dest_access_mode = (_Src_size == _Dest.extent.size()) ? _Write_access : _Read_write_access;
5863 
5864  // Get read-write access for array_view on cpu_accelerator and take underlying pointer to data
5865  const _Buffer_descriptor &_DestBufDesc = _Get_buffer_descriptor(_Dest);
5866 
5867  auto _AccelInfo = _Get_src_dest_accelerator_view(nullptr, &_DestBufDesc);
5868 
5869  _Buffer_ptr _PDestBuf;
5870  _Event _Ev = _Get_access_async(_DestBufDesc._Get_view_key(), _AccelInfo.second, _Dest_access_mode, _PDestBuf);
5871 
5872  _View_shape_ptr _Dst_shape = _Get_buffer_view_shape(_DestBufDesc);
5873 
5874  // If the _Dst shape is linear then perform a linear copy
5875  unsigned int _Dst_linear_offset, _Dst_linear_size;
5876  if (_Dst_shape->_Is_view_linear(_Dst_linear_offset, _Dst_linear_size))
5877  {
5878  _Ev = _Ev._Add_continuation(std::function<_Event()>([_PDestBuf, _SrcFirst, _SrcLast, _Src_size, _Dst_linear_offset]() mutable -> _Event {
5879  return details::_Copy_impl<InputIterator, _Value_type>(_SrcFirst, _SrcLast, _Src_size, _PDestBuf, _Dst_linear_offset);
5880  }));
5881  }
5882  else
5883  {
5884  _View_shape_ptr _Reinterpreted_dst_shape = _Create_reinterpreted_shape(_Dst_shape, _PDestBuf->_Get_elem_size(), sizeof(_Value_type));
5885 
5886  // Source has as many elements as in destination, reshape source to match destination shape
5887  std::vector<unsigned int> _Src_offset(_Reinterpreted_dst_shape->_Get_rank(), 0);
5888  _View_shape_ptr _Src_shape = details::_View_shape::_Create_view_shape(_Reinterpreted_dst_shape->_Get_rank(), 0 /* linear offset*/,
5889  _Reinterpreted_dst_shape->_Get_view_extent(), _Src_offset.data(),
5890  _Reinterpreted_dst_shape->_Get_view_extent());
5891 
5892  _Ev = _Ev._Add_continuation(std::function<_Event()>([_PDestBuf, _SrcFirst, _Src_shape, _Dst_shape]() mutable -> _Event {
5893  return details::_Copy_impl<InputIterator, _Value_type>(_SrcFirst, _Src_shape, _PDestBuf, _Dst_shape);
5894  }));
5895  }
5896 
5897  return _Ev;
5898 }
5899 
5900 template <typename OutputIterator, typename _Value_type, int _Rank>
5902 {
5903  // Caller is responsible for passing valid _DestIter
5904 
5905  // Get read access for array_view on cpu_accelerator and take underlying pointer to data
5906  const _Buffer_descriptor &_SrcBufDesc = _Get_buffer_descriptor(_Src);
5907 
5908  auto _AccelInfo = _Get_src_dest_accelerator_view(&_SrcBufDesc, nullptr);
5909 
5910  _Buffer_ptr _PSrcBuf;
5911  _Event _Ev = _Get_access_async(_SrcBufDesc._Get_view_key(), _AccelInfo.first, _Read_access, _PSrcBuf);
5912 
5913  // Get source shape
5914  _View_shape_ptr _Src_shape = _Get_buffer_view_shape(_SrcBufDesc);
5915 
5916  // If the _Src_shape is linear then perform a linear copy
5917  unsigned int _Src_linear_offset, _Src_linear_size;
5918  if (_Src_shape->_Is_view_linear(_Src_linear_offset, _Src_linear_size))
5919  {
5920  _Ev = _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _Src_linear_offset, _Src_linear_size, _DestIter]() mutable -> _Event {
5921  return details::_Copy_impl<OutputIterator, _Value_type>(_PSrcBuf, _Src_linear_offset, _Src_linear_size, _DestIter);
5922  }));
5923  }
5924  else
5925  {
5926  _View_shape_ptr _Reinterpreted_src_shape = _Create_reinterpreted_shape(_Src_shape, _PSrcBuf->_Get_elem_size(), sizeof(_Value_type));
5927 
5928  // Valid destination should have space for as many elements as in source array_view, reshape to match source view shape
5929  std::vector<unsigned int> _Dst_offset(_Reinterpreted_src_shape->_Get_rank(), 0);
5930  _View_shape_ptr _Dst_shape = details::_View_shape::_Create_view_shape(_Reinterpreted_src_shape->_Get_rank(), 0 /* linear offset*/,
5931  _Reinterpreted_src_shape->_Get_view_extent(), _Dst_offset.data(),
5932  _Reinterpreted_src_shape->_Get_view_extent());
5933 
5934  _Ev = _Ev._Add_continuation(std::function<_Event()>([_PSrcBuf, _Src_shape, _DestIter, _Dst_shape]() mutable -> _Event {
5935  return details::_Copy_impl<OutputIterator, _Value_type>(_PSrcBuf, _Src_shape, _DestIter, _Dst_shape);
5936  }));
5937  }
5938 
5939  return _Ev;
5940 }
5941 
5942 }
5943 
5956 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest)
5957 {
5960  sizeof(_Value_type) * _Src.extent.size());
5961 
5962  auto _Ev = _Copy_async_impl(_Src, _Dest);
5963 
5964  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
5965 }
5966 
5976 template <typename _Value_type, int _Rank> void copy(const array<_Value_type,_Rank>& _Src, array<_Value_type,_Rank>& _Dest)
5977 {
5980  sizeof(_Value_type) * _Src.extent.size());
5981 
5982  _Copy_async_impl(_Src, _Dest)._Get();
5983 
5985 }
5986 
6002 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest)
6003 {
6004  auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(nullptr,
6006  sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast));
6007 
6008  _Event _Ev = _Copy_async_impl(_SrcFirst, _SrcLast, _Dest);
6009 
6010  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6011 }
6012 
6025 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, array<_Value_type, _Rank> &_Dest)
6026 {
6027  auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(nullptr,
6029  sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast));
6030 
6031  _Copy_async_impl(_SrcFirst, _SrcLast, _Dest)._Get();
6032 
6034 }
6035 
6049 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest)
6050 {
6051  InputIterator _SrcLast = _SrcFirst;
6052  std::advance(_SrcLast, _Dest.extent.size());
6053  return copy_async(_SrcFirst, _SrcLast, _Dest);
6054 }
6055 
6066 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, array<_Value_type, _Rank> &_Dest)
6067 {
6068  InputIterator _SrcLast = _SrcFirst;
6069  std::advance(_SrcLast, _Dest.extent.size());
6070  copy(_SrcFirst, _SrcLast, _Dest);
6071 }
6072 
6085 template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
6086 {
6087  _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator);
6088 
6090  nullptr,
6091  sizeof(_Value_type) * _Src.extent.size());
6092  _Event _Ev = _Copy_async_impl(_Src, _DestIter);
6093 
6094  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6095 }
6096 
6106 template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
6107 {
6108  _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator);
6109 
6111  nullptr,
6112  sizeof(_Value_type) * _Src.extent.size());
6113 
6114  _Copy_async_impl(_Src, _DestIter)._Get();
6115 
6117 }
6118 
6131 template <typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest)
6132 {
6135  sizeof(_Value_type) * _Src.extent.size());
6136 
6137  _Event _Ev = _Copy_async_impl(_Src, _Dest);
6138 
6139  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6140 }
6141 
6151 template <typename _Value_type, int _Rank> void copy(const array<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest)
6152 {
6155  sizeof(_Value_type) * _Src.extent.size());
6156 
6157  _Copy_async_impl(_Src, _Dest)._Get();
6158 
6160 }
6161 
6175 {
6178  sizeof(_Value_type) * _Src.extent.size());
6179 
6180  _Event _Ev = _Copy_async_impl(_Src, _Dest);
6181 
6182  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6183 }
6184 
6194 template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest)
6195 {
6198  sizeof(_Value_type) * _Src.extent.size());
6199 
6200  _Copy_async_impl(_Src, _Dest)._Get();
6201 
6203 }
6204 
6218 {
6219  return copy_async<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest);
6220 }
6221 
6231 template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, array<_Value_type, _Rank>& _Dest)
6232 {
6233  copy<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest);
6234 }
6235 
6249 {
6252  sizeof(_Value_type) * _Src.extent.size());
6253 
6254  _Event _Ev = _Copy_async_impl(_Src, _Dest);
6255 
6256  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6257 }
6258 
6268 template <typename _Value_type, int _Rank> void copy(const array_view<const _Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest)
6269 {
6272  sizeof(_Value_type) * _Src.extent.size());
6273 
6274  _Copy_async_impl(_Src, _Dest)._Get();
6275 
6277 }
6278 
6292 {
6293  return copy_async<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest);
6294 }
6295 
6305 template <typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank>& _Src, const array_view<_Value_type, _Rank>& _Dest)
6306 {
6307  copy<_Value_type, _Rank>(array_view<const _Value_type, _Rank>(_Src), _Dest);
6308 }
6309 
6325 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest)
6326 {
6327  auto _Async_op_id = details::_Get_amp_trace()->_Launch_async_copy_event_helper(nullptr,
6329  sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast));
6330 
6331  _Event _Ev = _Copy_async_impl(_SrcFirst, _SrcLast, _Dest);
6332 
6333  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6334 }
6335 
6349 template <typename InputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest)
6350 {
6351  InputIterator _SrcLast = _SrcFirst;
6352  std::advance(_SrcLast, _Dest.extent.size());
6353  return copy_async(_SrcFirst, _SrcLast, _Dest);
6354 }
6355 
6368 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, InputIterator _SrcLast, const array_view<_Value_type, _Rank> &_Dest)
6369 {
6370  auto _Span_id = details::_Get_amp_trace()->_Start_copy_event_helper(nullptr,
6372  sizeof(_Value_type) * std::distance(_SrcFirst, _SrcLast));
6373 
6374  _Copy_async_impl(_SrcFirst, _SrcLast, _Dest)._Get();
6375 
6377 }
6378 
6389 template <typename InputIterator, typename _Value_type, int _Rank> void copy(InputIterator _SrcFirst, const array_view<_Value_type, _Rank> &_Dest)
6390 {
6391  InputIterator _SrcLast = _SrcFirst;
6392  std::advance(_SrcLast, _Dest.extent.size());
6393  copy(_SrcFirst, _SrcLast, _Dest);
6394 }
6395 
6408 template <typename OutputIterator, typename _Value_type, int _Rank> concurrency::completion_future copy_async(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
6409 {
6410  _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator);
6411 
6412  // Caller is responsible for passing valid _DestIter
6414  nullptr,
6415  sizeof(_Value_type) * _Src.extent.size());
6416 
6417  _Event _Ev = _Copy_async_impl(_Src, _DestIter);
6418 
6419  return details::_Get_amp_trace()->_Start_async_op_wait_event_helper(_Async_op_id, _Ev);
6420 }
6421 
6431 template <typename OutputIterator, typename _Value_type, int _Rank> void copy(const array_view<_Value_type, _Rank> &_Src, OutputIterator _DestIter)
6432 {
6433  _CPP_AMP_VERIFY_MUTABLE_ITERATOR(OutputIterator);
6434 
6436  nullptr,
6437  sizeof(_Value_type) * _Src.extent.size());
6438 
6439  _Copy_async_impl(_Src, _DestIter)._Get();
6440 
6442 }
6443 
6444 // Namespace for Direct3D specific functionality
6445 namespace direct3d
6446 {
6462  template<typename _Value_type, int _Rank> _Ret_ IUnknown *get_buffer(const array<_Value_type, _Rank> &_Array) __CPU_ONLY
6463  {
6464  _Buffer_ptr _PBuf;
6465  _Get_access_async(_Array, _Read_write_access, _PBuf)._Get();
6467  }
6468 
6490  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
6491  {
6492  details::_Is_valid_extent(_Extent);
6493 
6494  if (_D3D_buffer == NULL)
6495  {
6496  throw runtime_exception("NULL D3D buffer pointer.", E_INVALIDARG);
6497  }
6498 
6500  {
6501  throw runtime_exception("Cannot create D3D buffer on a non-D3D accelerator_view.", E_INVALIDARG);
6502  }
6503 
6504  _Ubiquitous_buffer_ptr _PBuf = _Ubiquitous_buffer::_Create_ubiquitous_buffer(_Buffer::_Create_buffer(_D3D_buffer, _Av, _Extent.size(), sizeof(_Value_type)));
6505  return array<_Value_type, _Rank>(_Extent, _Buffer_descriptor(_PBuf->_Get_master_buffer()->_Get_host_ptr(), _PBuf, _Is_array_mode, _Read_write_access));
6506  }
6507 
6508 } // namespace Concurrency::direct3d
6509 
6510 //=============================================================================
6511 // Atomic Operation Library
6512 //=============================================================================
6513 
6514 #define AS_UINT_PTR(p) reinterpret_cast<unsigned int *>(p)
6515 #define AS_UINT(v) *(reinterpret_cast<unsigned int *>(&(v)))
6516 #define AS_INT(v) *(reinterpret_cast<int *>(&(v)))
6517 #define AS_FLOAT(v) *(reinterpret_cast<float *>(&(v)))
6518 
6531 inline int atomic_fetch_add(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6532 {
6533  unsigned int _Ret;
6535  return AS_INT(_Ret);
6536 }
6537 
6550 inline unsigned int atomic_fetch_add(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6551 {
6552  return __dp_d3d_interlocked_add(_Dest, _Value);
6553 }
6554 
6567 inline int atomic_fetch_sub(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6568 {
6569  unsigned int _Ret;
6570  int _Neg = -_Value;
6571  _Ret = __dp_d3d_interlocked_add(AS_UINT_PTR(_Dest), AS_UINT(_Neg));
6572  return AS_INT(_Ret);
6573 }
6574 
6587 
6588 inline unsigned int atomic_fetch_sub(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6589 {
6590 #pragma warning( push )
6591 #pragma warning( disable : 4146 )
6592  // Warning 4146: unary minus operator applied to unsigned type, result
6593  // still unsigned.
6594  //
6595  // This is what we want here. The resulted unsigned value have the
6596  // right binary representation for achieving subtraction
6597  return __dp_d3d_interlocked_add(_Dest, (-_Value));
6598 #pragma warning( pop )
6599 }
6600 
6601 
6611 inline int atomic_fetch_inc(_Inout_ int * _Dest) __GPU_ONLY
6612 {
6613  unsigned int _Ret;
6614  _Ret = __dp_d3d_interlocked_add(AS_UINT_PTR(_Dest), 1U);
6615  return AS_INT(_Ret);
6616 }
6617 
6627 inline unsigned int atomic_fetch_inc(_Inout_ unsigned int * _Dest) __GPU_ONLY
6628 {
6629  return __dp_d3d_interlocked_add(_Dest, 1U);
6630 }
6631 
6641 inline int atomic_fetch_dec(_Inout_ int * _Dest) __GPU_ONLY
6642 {
6643 #pragma warning( push )
6644 #pragma warning( disable : 4146 )
6645  // Warning 4146: unary minus operator applied to unsigned type, result
6646  // still unsigned.
6647  unsigned int _Ret;
6648  _Ret = __dp_d3d_interlocked_add(AS_UINT_PTR(_Dest), (-(1U)));
6649  return AS_INT(_Ret);
6650 #pragma warning( pop )
6651 }
6652 
6662 inline unsigned int atomic_fetch_dec(_Inout_ unsigned int * _Dest) __GPU_ONLY
6663 {
6664 #pragma warning( push )
6665 #pragma warning( disable : 4146 )
6666  // Warning 4146: unary minus operator applied to unsigned type, result
6667  // still unsigned.
6668  return __dp_d3d_interlocked_add(_Dest, (-(1U)));
6669 #pragma warning( pop )
6670 }
6671 
6684 inline int atomic_exchange(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6685 {
6686  unsigned int _Ret = __dp_d3d_interlocked_exchange(AS_UINT_PTR(_Dest), AS_UINT(_Value));
6687  return AS_INT(_Ret);
6688 }
6689 
6702 inline unsigned int atomic_exchange(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6703 {
6704  return __dp_d3d_interlocked_exchange(_Dest, _Value);
6705 }
6706 
6719 inline float atomic_exchange(_Inout_ float * _Dest, float _Value) __GPU_ONLY
6720 {
6721  unsigned int _Ret = __dp_d3d_interlocked_exchange(AS_UINT_PTR(_Dest), AS_UINT(_Value));
6722  return AS_FLOAT(_Ret);
6723 }
6724 
6743 inline bool atomic_compare_exchange(_Inout_ int * _Dest, _Inout_ int * _Expected_value, int _Value) __GPU_ONLY
6744 {
6745  int _Old = *_Expected_value;
6746  unsigned int _Ret = __dp_d3d_interlocked_compare_exchange(AS_UINT_PTR(_Dest), AS_UINT(_Value), AS_UINT(_Old));
6747  if (_Ret == AS_UINT(_Old))
6748  {
6749  return true;
6750  }
6751  else
6752  {
6753  *_Expected_value = AS_INT(_Ret);
6754  return false;
6755  }
6756 }
6757 
6776 inline bool atomic_compare_exchange(_Inout_ unsigned int * _Dest, _Inout_ unsigned int * _Expected_value, unsigned int _Value) __GPU_ONLY
6777 {
6778  unsigned int _Old = *_Expected_value;
6779  unsigned int _Ret = __dp_d3d_interlocked_compare_exchange(_Dest, _Value, _Old);
6780  if (_Ret == _Old)
6781  {
6782  return true;
6783  }
6784  else
6785  {
6786  *_Expected_value = _Ret;
6787  return false;
6788  }
6789 }
6790 
6804 inline int atomic_fetch_max(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6805 {
6806  return __dp_d3d_interlocked_max_int(_Dest, _Value);
6807 }
6808 
6822 inline unsigned int atomic_fetch_max(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6823 {
6824  return __dp_d3d_interlocked_max_uint(_Dest, _Value);
6825 }
6826 
6827 
6841 inline int atomic_fetch_min(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6842 {
6843  return __dp_d3d_interlocked_min_int(_Dest, _Value);
6844 }
6845 
6859 inline unsigned int atomic_fetch_min(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6860 {
6861  return __dp_d3d_interlocked_min_uint(_Dest, _Value);
6862 }
6863 
6876 inline int atomic_fetch_and(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6877 {
6878  unsigned int _Ret;
6880  return AS_INT(_Ret);
6881 }
6882 
6895 inline unsigned int atomic_fetch_and(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6896 {
6897  return __dp_d3d_interlocked_and(_Dest, _Value);
6898 }
6899 
6900 
6913 inline int atomic_fetch_or(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6914 {
6915  unsigned int _Ret;
6917  return AS_INT(_Ret);
6918 }
6919 
6932 inline unsigned int atomic_fetch_or(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6933 {
6934  return __dp_d3d_interlocked_or(_Dest, _Value);
6935 }
6936 
6949 inline int atomic_fetch_xor(_Inout_ int * _Dest, int _Value) __GPU_ONLY
6950 {
6951  unsigned int _Ret;
6953  return AS_INT(_Ret);
6954 }
6955 
6968 inline unsigned int atomic_fetch_xor(_Inout_ unsigned int * _Dest, unsigned int _Value) __GPU_ONLY
6969 {
6970  return __dp_d3d_interlocked_xor(_Dest, _Value);
6971 }
6972 
6973 //=============================================================================
6974 // parallel_for_each
6975 //=============================================================================
6976 
6988 template <int _Rank, typename _Kernel_type> void parallel_for_each(const extent<_Rank>& _Compute_domain, const _Kernel_type &_Kernel)
6989 {
6991  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
6992 }
6993 
7005 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)
7006 {
7008  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7009 }
7010 
7022 template <int _Dim0, int _Dim1, typename _Kernel_type> void parallel_for_each(const tiled_extent<_Dim0, _Dim1>& _Compute_domain, const _Kernel_type& _Kernel)
7023 {
7025  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7026 }
7027 
7039 template <int _Dim0, typename _Kernel_type> void parallel_for_each(const tiled_extent<_Dim0>& _Compute_domain, const _Kernel_type& _Kernel)
7040 {
7042  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7043 }
7044 
7057 template <int _Rank, typename _Kernel_type> void parallel_for_each(const accelerator_view& _Accl_view, const extent<_Rank>& _Compute_domain, const _Kernel_type& _Kernel)
7058 {
7059  _Host_Scheduling_info _SchedulingInfo = {_Accl_view};
7060  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7061 }
7062 
7076 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)
7077 {
7078  _Host_Scheduling_info _SchedulingInfo = {_Accl_view};
7079  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7080 }
7081 
7095 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)
7096 {
7097  _Host_Scheduling_info _SchedulingInfo = {_Accl_view};
7098  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7099 }
7100 
7114 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)
7115 {
7116  _Host_Scheduling_info _SchedulingInfo = {_Accl_view};
7117  details::_Parallel_for_each(&_SchedulingInfo, _Compute_domain, _Kernel);
7118 }
7119 
7120 
7121 
7122 //=============================================================================
7123 
7124 extern "C"
7125 {
7126 
7127 // Debugging intrinsics
7128 void direct3d_abort() __GPU_ONLY;
7129 void direct3d_errorf(const char *, ...) __GPU_ONLY;
7130 void direct3d_printf(const char *, ...) __GPU_ONLY;
7131 
7132 }
7133 
7136 
7137 #pragma warning( push )
7138 #pragma warning( disable : 4100 ) // unreferenced formal parameter
7139 
7146 inline void all_memory_fence(const tile_barrier & _Barrier) __GPU_ONLY
7147 {
7149 }
7150 
7157 inline void global_memory_fence(const tile_barrier & _Barrier) __GPU_ONLY
7158 {
7160 }
7161 
7168 inline void tile_static_memory_fence(const tile_barrier & _Barrier) __GPU_ONLY
7169 {
7171 }
7172 
7173 #pragma warning( pop )
7174 
7175 
7176 
7177 namespace direct3d
7178 {
7179 
7189 inline int abs(int _X) __GPU_ONLY
7190 {
7191  return __dp_d3d_absi(_X);
7192 }
7193 
7209 inline float clamp(float _X, float _Min, float _Max) __GPU_ONLY
7210 {
7211  return __dp_d3d_clampf(_X, _Min, _Max);
7212 }
7213 
7229 inline int clamp(int _X, int _Min, int _Max) __GPU_ONLY
7230 {
7231  return __dp_d3d_clampi(_X, _Min, _Max);
7232 }
7233 
7243 inline unsigned int countbits(unsigned int _X) __GPU_ONLY
7244 {
7245  return __dp_d3d_countbitsu(_X);
7246 }
7247 
7257 inline int firstbithigh(int _X) __GPU_ONLY
7258 {
7259  return __dp_d3d_firstbithighi(_X);
7260 }
7261 
7271 inline int firstbitlow(int _X) __GPU_ONLY
7272 {
7273  return __dp_d3d_firstbitlowi(_X);
7274 }
7275 
7288 inline int imax(int _X, int _Y) __GPU_ONLY
7289 {
7290  return __dp_d3d_maxi(_X, _Y);
7291 }
7292 
7305 inline int imin(int _X, int _Y) __GPU_ONLY
7306 {
7307  return __dp_d3d_mini(_X, _Y);
7308 }
7309 
7322 inline unsigned int umax(unsigned int _X, unsigned int _Y) __GPU_ONLY
7323 {
7324  return __dp_d3d_maxu(_X, _Y);
7325 }
7326 
7339 inline unsigned int umin(unsigned int _X, unsigned int _Y) __GPU_ONLY
7340 {
7341  return __dp_d3d_minu(_X, _Y);
7342 }
7343 
7359 inline float mad(float _X, float _Y, float _Z) __GPU_ONLY
7360 {
7361  return __dp_d3d_madf(_X, _Y, _Z);
7362 }
7363 
7379 inline double mad(double _X, double _Y, double _Z) __GPU_ONLY
7380 {
7381  return __dp_d3d_madd(_X, _Y, _Z);
7382 }
7383 
7399 inline int mad(int _X, int _Y, int _Z) __GPU_ONLY
7400 {
7401  return __dp_d3d_madi(_X, _Y, _Z);
7402 }
7403 
7419 inline unsigned int mad(unsigned int _X, unsigned int _Y, unsigned int _Z) __GPU_ONLY
7420 {
7421  return __dp_d3d_madu(_X, _Y, _Z);
7422 }
7423 
7433 inline float noise(float _X) __GPU_ONLY
7434 {
7435  return __dp_d3d_noisef(_X);
7436 }
7437 
7447 inline float radians(float _X) __GPU_ONLY
7448 {
7449  return __dp_d3d_radiansf(_X);
7450 }
7451 
7461 inline float rcp(float _X) __GPU_ONLY
7462 {
7463  return __dp_d3d_rcpf(_X);
7464 }
7465 
7475 inline unsigned int reversebits(unsigned int _X) __GPU_ONLY
7476 {
7477  return __dp_d3d_reversebitsu(_X);
7478 }
7479 
7489 inline float saturate(float _X) __GPU_ONLY
7490 {
7491  return __dp_d3d_saturatef(_X);
7492 }
7493 
7503 inline int sign(int _X) __GPU_ONLY
7504 {
7505  return __dp_d3d_signi(_X);
7506 }
7507 
7523 inline float smoothstep(float _Min, float _Max, float _X) __GPU_ONLY
7524 {
7525  return __dp_d3d_smoothstepf(_Min, _Max, _X);
7526 }
7527 
7540 inline float step(float _Y, float _X) __GPU_ONLY
7541 {
7542  return __dp_d3d_stepf(_Y, _X);
7543 }
7544 
7545 } // namespace Concurrency::direct3d
7546 
7547 } // namespace Concurrency
7548 
7549 #include <xxamp_inl.h>
7550 
7551 namespace concurrency = Concurrency;
7552 
7553 #pragma pack(pop)
7554 // 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:3905
tiled_extent(const tiled_extent &_Other) __GPU
Copy constructor. Constructs a new tiled_extent from the supplied argument "_Other".
Definition: amp.h:1271
_Array_view_base(_In_ void *_Data, const Concurrency::extent< _Rank > &_Array_extent) __GPU_ONLY
Definition: amp.h:1776
void synchronize() const __CPU_ONLY
Synchronizes any modifications made to "this" array_view to its source data.
Definition: amp.h:3717
friend class accelerator
Definition: amprt.h:1520
static _Projection_result_type< _T, _R >::_Result_type _Project0(const array_view< _T, _R > *_Arr_view, int _I) __GPU
Definition: xxamp_inl.h:42
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:2550
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:1474
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:3032
_Buffer_descriptor _M_buffer_descriptor
Definition: amp.h:5720
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:2933
int __dp_d3d_firstbitlowi(int) __GPU_ONLY
_Tuple_type< _Rank > operator*(const _Tuple_type< _Rank > &_Lhs, typename _Tuple_type< _Rank >::value_type _Rhs) __GPU
Definition: amp.h:870
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:3528
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:6913
void refresh() const __CPU_ONLY
Informs the array_view that its bound memory has been modified outside the array_view interface...
Definition: amp.h:2801
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:4005
_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:2699
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:145
Concurrency::extent< _Rank > _M_array_multiplier
Definition: amp.h:1644
void _Initialize(Concurrency::accelerator_view _Av, Concurrency::accelerator_view _Associated_Av) __CPU_ONLY
Definition: amp.h:5559
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:4375
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:5349
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:2337
array(array &&_Other) __CPU_ONLY
Move constructor.
Definition: amp.h:4815
details::_Buffer_descriptor _Buffer_descriptor
Definition: amp.h:1658
_CRTIMP _In_ int _Value
Definition: setjmp.h:190
float __dp_d3d_radiansf(float) __GPU_ONLY
unsigned int __dp_d3d_interlocked_add(_Inout_ unsigned int *, unsigned int) __GPU_ONLY
exception_ptr current_exception()
Definition: exception:527
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:1677
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:6684
void _Register() __CPU_ONLY
Definition: amp.h:1961
_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:2959
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:4982
void all_memory_fence(const tile_barrier &_Barrier) __GPU_ONLY
Memory fences and tile barriers.
Definition: amp.h:7146
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:3207
const index< rank > global
An index that represents the global index within an extent.
Definition: amp.h:988
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:1410
_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:5475
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:2724
_Check_return_ _In_ int _Mode
Definition: io.h:338
array_view(const array_view &_Other) __GPU
Copy constructor. Shallow copy.
Definition: amp.h:2247
float __dp_d3d_madf(float, float, float) __GPU_ONLY
~_Array_view_shape() __GPU
Definition: amp.h:1543
const unsigned int * _Get_view_offset() const
Definition: amprt.h:1682
_Event _Get_access_async(const _View_key _Key, accelerator_view _Av, _Access_mode _Mode, _Buffer_ptr &_Buf_ptr)
Definition: amprt.h:3457
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:5150
details::_Buffer_descriptor _Buffer_descriptor
Definition: amp.h:3834
void _Register_copy(const _Array_view_base &_Other) __CPU_ONLY
Definition: amp.h:1979
extent< _Rank > operator+(const index< _Rank > &_Rhs) __GPU
Element-wise addition of this extent with an index.
Definition: amp.h:578
~array_view() __GPU
Destroys this array_view and reclaims resources.
Definition: amp.h:2229
Definition: amprt.h:85
size_type size() const _NOEXCEPT
Definition: array:116
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:2303
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
void _Unregister(bool _Throw_exception=true) __GPU_ONLY
Definition: amp.h:2155
tiled_extent & operator=(const tiled_extent &_Other) __GPU
copy-assignment operator
Definition: amp.h:1446
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:4348
_Array_view_base< _Rank, _New_element_size > _Reinterpret_as() const __GPU
Definition: amp.h:1876
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:2769
unsigned int __dp_d3d_madu(unsigned int, unsigned int, unsigned int) __GPU_ONLY
_Value_type value_type
Definition: amp.h:2223
void _Register() __GPU_ONLY
Definition: amp.h:2143
array_view(const Concurrency::extent< _Rank > &_Extent) __CPU_ONLY
Construct an array_view which is not bound to a data source.
Definition: amp.h:2259
_eInitializeState
Definition: xxamp.h:208
_Array_view_base(const void *_Data, const Concurrency::extent< _Rank > &_Array_extent) __CPU_ONLY
Definition: amp.h:1782
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:2072
const index< rank > tile
An index that represents the coordinates of the current tile of a tiled_extent.
Definition: amp.h:998
void refresh() const __CPU_ONLY
Informs the array_view that its bound memory has been modified outside the array_view interface...
Definition: amp.h:3648
Definition: array:19
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:3630
void _Project0(int _I, _Array_view_base< _Rank-1, _Element_size > &_Projected_view) const __GPU
Definition: amp.h:1866
array_view(const array_view &_Other, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Definition: amp.h:3764
tiled_extent & operator=(const tiled_extent &_Other) __GPU
copy-assignment operator
Definition: amp.h:1364
float noise(float _X) __GPU_ONLY
Generates a random value using the Perlin noise algorithm
Definition: amp.h:7433
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:5249
_Tuple_type< _Rank > operator/(const _Tuple_type< _Rank > &_Lhs, typename _Tuple_type< _Rank >::value_type _Rhs) __GPU
Definition: amp.h:886
unsigned int __dp_d3d_interlocked_or(_Inout_ unsigned int *, unsigned int) __GPU_ONLY
_CRTIMP _In_opt_z_ const wchar_t _In_opt_z_ const wchar_t unsigned int
Definition: crtdefs.h:642
#define __GPU
Definition: amprt.h:41
_Array_view_base< _New_rank, _Element_size > _View_as(const Concurrency::extent< _New_rank > &_View_extent) const __GPU
Definition: amp.h:1886
Concurrency::extent< _Rank > _M_multiplier
Definition: amp.h:5723
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:5199
array(const array &_Other) __CPU_ONLY
Copy constructor. Deep copy.
Definition: amp.h:4805
tiled_extent() __GPU
Default constructor.
Definition: amp.h:1260
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:1383
int __dp_d3d_maxi(int, int) __GPU_ONLY
Class represents a virtual device abstraction on a C++ AMP data-parallel accelerator ...
Definition: amprt.h:1518
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:1551
_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
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:3756
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:7271
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:5393
The Concurrency namespace provides classes and functions that provide access to the Concurrency Runti...
Definition: agents.h:42
Class represents a future corresponding to a C++ AMP asynchronous operation
Definition: amprt.h:1342
bool operator!=(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:816
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:5380
static void _Is_valid_extent(const _T< _Rank > &_Tuple) __CPU_ONLY
Definition: xxamp.h:1203
bool _Is_valid_access_mode(_Access_mode _Mode)
Definition: amprt.h:411
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:2953
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:2291
unsigned int umax(unsigned int _X, unsigned int _Y) __GPU_ONLY
Determine the maximum numeric value of the arguments
Definition: amp.h:7322
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:3663
A _Tiled_index_base is the base class of all three kinds of tiled_index to share the common code...
Definition: amp.h:977
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:6490
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:2393
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:3571
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:4317
tiled_extent(const Concurrency::extent< rank > &_Other) __GPU
Constructs a new tiled_extent from the supplied extent.
Definition: amp.h:1434
_AMPIMP void _Register_view(_In_ _View_key _Key, accelerator_view _Cpu_av, _View_shape_ptr _Shape)
double __dp_d3d_madd(double, double, double) __GPU_ONLY
const bool * _Get_projection_info() const
Definition: amprt.h:1691
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:3835
array(int _E0) __CPU_ONLY
Construct array with the extent _E0
Definition: amp.h:3870
_Buffer_descriptor _M_buffer_descriptor
Definition: amp.h:1957
float rcp(float _X) __GPU_ONLY
Calculates a fast, approximate reciprocal of the argument
Definition: amp.h:7461
#define NULL
Definition: crtdbg.h:30
_Ret_ _View_shape * _Create_buffer_view_shape() const __CPU_ONLY
Definition: amp.h:1896
_Ret_ _View_shape * _Create_buffer_view_shape() const
Definition: amp.h:5656
integral_constant< bool, false > false_type
Definition: xtr1common:48
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:2238
_Array_view_base(const _Array_view_base &_Other, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Definition: amp.h:1697
array_view(const array_view< _Value_type, _Rank > &_Src) __GPU
Copy constructor. Shallow copy.
Definition: amp.h:3041
Definition: xxamp.h:240
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:4042
void _Register(_In_ void *_Shape) __GPU_ONLY
Definition: amp.h:2150
_Tiled_index_base & operator=(const _Tiled_index_base &) __GPU
iterator_traits< _InIt >::difference_type distance(_InIt _First, _InIt _Last)
Definition: xutility:755
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:4776
A tiled_index is a set of indices of 1 to 3 dimensions which have been subdivided into 1-...
Definition: amp.h:1071
_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:4291
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:6641
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:2850
array(const Concurrency::extent< _Rank > &_Extent) __CPU_ONLY
Construct an array from extents
Definition: amp.h:3858
_Array_view_base(const _Buffer_descriptor &_Buffer_desc, const Concurrency::extent< _Rank > &_Array_extent) __GPU
Definition: amp.h:1706
tiled_index(const tiled_index &_Other) __GPU
Copy Constructor.
Definition: amp.h:1106
static const int rank
Definition: amp.h:67
Definition: amprt.h:87
unsigned int reversebits(unsigned int _X) __GPU_ONLY
Reverses the order of the bits in _X
Definition: amp.h:7475
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:949
#define UINT_MAX
Definition: limits.h:41
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:1686
_Event _Get_access_async(_Access_mode _Mode, _Buffer_ptr &_Buf_ptr, bool _Zero_copy_cpu_access=false) __CPU_ONLY const
Definition: amp.h:5635
static _AMPIMP const wchar_t cpu_accelerator[]
String constant for cpu accelerator
Definition: amprt.h:1111
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:1574
array_view & operator=(const array_view< _Value_type, _Rank > &_Other) __GPU
Copy Assignment operator. Shallow copy.
Definition: amp.h:3347
void _Initialize(Concurrency::accelerator_view _Av, access_type _Cpu_access_type) __CPU_ONLY
Definition: amp.h:5538
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:1107
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:6804
void _Initialize(size_t _Src_data_size, bool _Discard_data=false) __CPU_ONLY
Definition: amp.h:2979
_Array_view_base< _Rank, sizeof(_Value_type)/sizeof(int)> _Base
Definition: amp.h:3001
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:923
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:4672
_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:6515
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:5466
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:5594
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:4145
int i[4]
Definition: dvec.h:70
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:3134
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:5214
void _Refresh_data_ptr(_Access_mode _Requested_mode, bool _Exception=true) __GPU_ONLY
Definition: amp.h:5708
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:3976
_Array_view_base() __GPU
Definition: amp.h:1668
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:2826
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:2274
#define _ASSERTE(expr)
Definition: crtdbg.h:216
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:3364
tiled_extent & operator=(const tiled_extent &_Other) __GPU
copy-assignment operator
Definition: amp.h:1277
int sign(int _X) __GPU_ONLY
Returns the sign of the argument
Definition: amp.h:7503
void direct3d_printf(const char *,...) __GPU_ONLY
_Access_mode _M_curr_cpu_access_mode
Definition: amprt.h:444
_In_ size_t _In_z_ const unsigned char * _Src
Definition: mbstring.h:95
_Array_view_base(const Concurrency::extent< _Rank > &_Array_extent) __CPU_ONLY
Definition: amp.h:1749
#define _In_
Definition: sal.h:314
Definition: xxamp.h:243
~array() __CPU_ONLY
Destroys this array and reclaims resources.
Definition: amp.h:5491
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:5674
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:1546
unsigned int __dp_d3d_reversebitsu(unsigned int) __GPU_ONLY
_Ret_ _Ubiquitous_buffer * _Get_buffer() __CPU_ONLY const
Definition: amp.h:5630
array(const array_view< const _Value_type, _Rank > &_Src) __CPU_ONLY
Construct an array initialized from an array_view.
Definition: amp.h:4753
static const int rank
Definition: amp.h:397
Concurrency::extent< _Rank > _M_view_extent
Definition: amp.h:1647
tiled_extent(const Concurrency::extent< rank > &_Other) __GPU
Constructs a new tiled_extent from the supplied extent.
Definition: amp.h:1265
void _Initialize() __GPU
Definition: amp.h:3771
int __dp_d3d_mini(int, int) __GPU_ONLY
float __dp_d3d_rcpf(float) __GPU_ONLY
unsigned int _Initialize() __CPU_ONLY
Definition: amp.h:5524
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:5440
tiled_extent(const tiled_extent &_Other) __GPU
Copy constructor. Constructs a new tiled_extent from the supplied argument "_Other".
Definition: amp.h:1358
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:2899
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:5669
#define __CPU_ONLY
Definition: amprt.h:43
void _Unregister(bool _Throw_exception=true) __CPU_ONLY
Definition: amp.h:2009
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:2879
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:3397
void _Initialize_multiplier() __GPU
Definition: amp.h:1635
void _Register() __CPU_ONLY
Definition: amp.h:5600
tiled_extent(const tiled_extent &_Other) __GPU
Copy constructor. Constructs a new tiled_extent from the supplied argument "_Other".
Definition: amp.h:1440
array(int _E0, _InputIterator _Src_first) __CPU_ONLY
Construct an array initialized from an iterator.
Definition: amp.h:4162
int value_type
Definition: amp.h:68
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:5184
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:1326
Exception thrown due to a C++ AMP runtime_exception. This is the base type for all C++ AMP exception ...
Definition: amprt.h:835
_In_ double _Y
Definition: math.h:999
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:2755
_CPP_AMP_VERIFY_RANK(_Rank, extent)
Concurrency::extent< _Rank > _M_extent
Definition: amp.h:5717
_Ty * data() _NOEXCEPT
Definition: array:195
static void _Is_valid_projection(int _I, const _T1< _Rank > &_Base_extent) __CPU_ONLY
Definition: xxamp.h:1135
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:3928
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:7489
_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:6988
unsigned int _Get_linear_offset() const
Definition: amprt.h:1672
_Ret_ void * _Access(_Access_mode _Requested_mode, const index< _Rank > &_Index) const __CPU_ONLY
Definition: amp.h:1834
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:4235
_Array_view_base(const _Buffer_descriptor &_Buffer_desc, int _Base_linear_offset, const Concurrency::extent< _Rank > &_Array_extent) __GPU
Definition: amp.h:1715
_Array_flatten_helper< _Rank, typename Concurrency::extent< _Rank >::value_type, typename Concurrency::index< _Rank >::value_type > _Flatten_helper
Definition: amp.h:1530
_Ret_ IUnknown * get_buffer(const array< _Value_type, _Rank > &_Array) __CPU_ONLY
Get the D3D buffer interface underlying an array.
Definition: amp.h:6462
tiled_extent() __GPU
Default constructor.
Definition: amp.h:1347
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:5268
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:3703
_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:3638
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:5230
tiled_index(const tiled_index &_Other) __GPU
Copy Constructor.
Definition: amp.h:1221
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:6949
tiled_extent(const Concurrency::extent< rank > &_Other) __GPU
Constructs a new tiled_extent from the supplied extent.
Definition: amp.h:1352
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:2490
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:2681
_Tiled_index_base(const _Tiled_index_base &_Other) __GPU
Copy Constructor.
Definition: amp.h:1042
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:4707
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:4888
_Ret_ _Ubiquitous_buffer * _Get_buffer(const _Array_type &_Array) __CPU_ONLY
Definition: xxamp.h:1070
unsigned int umin(unsigned int _X, unsigned int _Y) __GPU_ONLY
Determine the minimum numeric value of the arguments
Definition: amp.h:7339
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:4542
_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:1028
unsigned int countbits(unsigned int _X) __GPU_ONLY
Counts the number of set bits in _X
Definition: amp.h:7243
void copy_to(array< _Value_type, _Rank > &_Dest) const __CPU_ONLY
Copies elements from this array_view to the destination array.
Definition: amp.h:2509
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:4108
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:7419
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:3023
int __dp_d3d_absi(int) __GPU_ONLY
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:3616
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:4480
void _Register_copy(const _Array_view_base &_Other) __GPU_ONLY
Definition: amp.h:2145
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:3101
void copy_to(array< _Value_type, _Rank > &_Dest) const __CPU_ONLY
Copies elements from this array to the destination array.
Definition: amp.h:4880
_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:3245
const tile_barrier barrier
An object which represents a barrier within the current tile of threads.
Definition: amp.h:1008
_Ret_ _View_key _Get_view_key()
Definition: amprt.h:532
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:1003
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:3498
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:3513
Concurrency::extent< _Rank > _M_array_extent
Definition: amp.h:1643
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:3736
The extent type represents an N-dimensional vector of int which specifies the bounds of an N-dimen...
Definition: amp.h:383
~_Array_view_base() __GPU
Definition: amp.h:1660
_Array_view_base< _Rank, sizeof(_Value_type)/sizeof(int)> _Base
Definition: amp.h:2202
An array is a multi-dimensional data aggregate on a accelerator_view.
Definition: amp.h:3831
_Tuple_type< _Rank > operator+(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:822
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:2924
#define AS_INT(v)
Definition: amp.h:6516
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:7189
index(const int _Array[_Rank]) __GPU
Constructs an index with the coordinate values provided the array of int component values...
Definition: amp.h:145
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:3081
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:5617
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:4258
void * _M_data_ptr
Definition: amprt.h:432
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:4024
_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:1584
unsigned int __dp_d3d_interlocked_exchange(_Inout_ unsigned int *, unsigned int) __GPU_ONLY
Definition: amprt.h:88
_Ret_ _View_shape * _Get_buffer_view_shape(const _Buffer_descriptor &_Descriptor)
Definition: amprt.h:3463
array_view & operator=(const array_view &_Other) __GPU
Copy Assignment operator. Shallow copy.
Definition: amp.h:3338
int imin(int _X, int _Y) __GPU_ONLY
Determine the minimum numeric value of the arguments
Definition: amp.h:7305
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:4089
_Access_mode
Definition: amprt.h:82
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:4188
tiled_extent() __GPU
Default constructor.
Definition: amp.h:1429
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:4614
const _Buffer_descriptor & _Get_buffer_descriptor(const _Array_type &_Array) __GPU
Definition: xxamp.h:1064
array_view(const array_view &_Other, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Definition: amp.h:2961
const index< rank > local
An index that represents the relative index within the current tile of a tiled_extent.
Definition: amp.h:993
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:4646
Definition: xxamp.h:710
float radians(float _X) __GPU_ONLY
Converts _X from degrees to radians
Definition: amp.h:7447
_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:7523
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:1465
_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
Definition: amp.h:1724
_Array_view_base(_In_ void *_Data, const Concurrency::extent< _Rank > &_Array_extent) __CPU_ONLY
Definition: amp.h:1760
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:1092
int clamp(int _X, int _Min, int _Max) __GPU_ONLY
Clamps _X to the specified _Min and _Max range
Definition: amp.h:7229
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:2433
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:1598
_Ret_ _Value_type * data() const __GPU
Returns a pointer to the raw data of this array_view.
Definition: amp.h:2791
extent< _Rank > operator-(const index< _Rank > &_Rhs) __GPU
Element-wise subtraction of this extent with an index.
Definition: amp.h:594
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:1739
#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:5976
Definition: xxamp.h:228
int _M_total_linear_offset
Definition: amp.h:1646
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:3225
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:3149
float __dp_d3d_saturatef(float) __GPU_ONLY
Definition: amprt.h:103
A tiled_extent is an extent of 1 to 3 dimensions which also subdivides the extent space into 1-...
Definition: amp.h:1249
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:6876
void advance(_InIt &_Where, _Diff _Off)
Definition: xutility:695
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:5168
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:3184
array_view(const _In_ _Arr_type(&_Src)[_Size]) __GPU
Construct an array_view which is bound to the data contained in the _Src container; ...
Definition: amp.h:3164
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:4441
#define _T(x)
Definition: tchar.h:2498
_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:3268
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:5405
int _Calculate_reinterpreted_size(int _Old_size) __GPU_ONLY
Definition: amp.h:1502
array_view(_Buffer_descriptor &_Src_buffer, const Concurrency::extent< _Rank > &_Extent) __GPU
Definition: amp.h:2967
void _Unregister() __CPU_ONLY
Definition: amp.h:5622
_Array_view_base(const _Buffer_descriptor &_Buffer_desc, const _Array_view_shape &_Shape) __GPU
Definition: amp.h:1670
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:4513
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:3546
static _Ret_ void * _Create_projection_buffer_shape(const _Buffer_descriptor &_Descriptor, int _Dim, int _I) __GPU_ONLY
Definition: amp.h:2160
static const int rank
Definition: amp.h:983
Definition: amprt.h:99
Definition: amprt.h:84
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:6567
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:4564
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:5133
_Event _Copy_async_impl(const array_view< _Value_type, _Rank > &_Src, OutputIterator _DestIter)
Definition: amp.h:5901
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:2517
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:5118
_Ret_ void * _Access(const index< _Rank > &_Index) const __GPU
Definition: amp.h:1828
#define AS_UINT_PTR(p)
Definition: amp.h:6514
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:6743
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:3305
_Ret_ _View_shape * _Create_reinterpreted_shape(const _View_shape *_Source_shape, size_t _Curr_elem_size, size_t _New_elem_size)
Definition: amprt.h:1961
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:6611
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:7157
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
Definition: amp.h:2169
void copy_to(array< _Value_type, _Rank > &_Dest) const __CPU_ONLY
Copies elements from this array_view to the destination array.
Definition: amp.h:3356
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:2651
array(int _E0, int _E1) __CPU_ONLY
Construct an array from two integer extents.
Definition: amp.h:3886
_Array_view_base _Section(const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) const __GPU
Definition: amp.h:1851
void _Initialize(Concurrency::accelerator_view _Av, _InputIterator _Src_first, _InputIterator _Src_last, access_type _Cpu_access_type) __CPU_ONLY
Definition: amp.h:5552
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:4064
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:4591
#define AS_FLOAT(v)
Definition: amp.h:6517
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:3285
_Tuple_type< _Rank > operator-(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:830
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:47
index< _Rank > & operator=(const index< _Rank > &_Other) __GPU
copy-assignment operators
Definition: amp.h:153
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:3328
Definition: xxamp.h:241
#define _Inout_
Definition: sal.h:384
void _Register(_In_ void *_Shape) __CPU_ONLY
Definition: amp.h:1984
_Array_view_base(const _Array_view_base &_Other) __GPU
Definition: amp.h:1679
array(const Concurrency::extent< _Rank > &_Extent, _InputIterator _Src_first) __CPU_ONLY
Construct an array initialized from an iterator.
Definition: amp.h:4124
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:1207
_Tuple_type< _Rank > operator%(const _Tuple_type< _Rank > &_Lhs, typename _Tuple_type< _Rank >::value_type _Rhs) __GPU
Definition: amp.h:902
array & operator=(const array_view< const _Value_type, _Rank > &_Src) __CPU_ONLY
Assignment operator from an array_view
Definition: amp.h:4871
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...
__declspec(deprecated("Concurrency::EnableTracing is a deprecated function.")) _CRTIMP HRESULT __cdecl EnableTracing()
Enables tracing in the Concurrency Runtime. This function is deprecated because ETW tracing is now on...
concurrency::completion_future synchronize_async() const __CPU_ONLY
Asynchronously synchronizes any modifications made to "this" array_view to its source data...
Definition: amp.h:3681
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:1308
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:4411
_Ret_ _Ubiquitous_buffer * _Get_buffer_ptr() const __CPU_ONLY
Definition: amprt.h:497
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:312
void _Initialize(size_t _Src_data_size) __CPU_ONLY
Definition: amp.h:3777
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:2003
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:1798
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:958
_Value_type value_type
Definition: amp.h:3850
Concurrency::index< _Rank > _M_view_offset
Definition: amp.h:1645
Class represents a accelerator abstraction for C++ AMP data-parallel devices
Definition: amprt.h:1089
Definition: amprt.h:100
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:3018
void __dp_d3d_device_memory_fence() __GPU_ONLY
_Array_view_base & operator=(const _Array_view_base &_Other) __GPU
Definition: amp.h:1811
Definition: amprt.h:86
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:1490
#define INT_MAX
Definition: limits.h:40
An array_view is an N-dimensional view over data held in another container (such as array
Definition: amp.h:2200
array_view(int _E0, int _E1) __CPU_ONLY
Construct an array_view which is not bound to a data source.
Definition: amp.h:2354
array_view(_In_ _Arr_type(&_Src)[_Size]) __GPU
Construct an array_view which is bound to the array _Src.
Definition: amp.h:2446
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:967
array(int _E0, int _E1, _InputIterator _Src_first) __CPU_ONLY
Construct an array initialized from an iterator.
Definition: amp.h:4208
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:2317
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:5293
#define __GPU_ONLY
Definition: amprt.h:42
_Array_view_base _Section(const index< _Rank > &_Idx) const __GPU
Definition: amp.h:1861
_FwdIt const _Ty _Val
Definition: algorithm:1938
void _Project0(int _I, _Array_view_shape< _Rank-1, _Element_size > &_Projected_shape) const __GPU
Definition: amp.h:1608
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:2783
int imax(int _X, int _Y) __GPU_ONLY
Determine the maximum numeric value of the arguments
Definition: amp.h:7288
bool _Is_cpu_accelerator(const accelerator &_Accl)
Definition: amprt.h:3469
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:2467
int __dp_d3d_signi(int) __GPU_ONLY
_Check_return_ _In_ long _Size
Definition: io.h:325
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:940
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:2415
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:3064
tiled_index(const tiled_index &_Other) __GPU
Copy Constructor.
Definition: amp.h:1164
Definition: amprt.h:1657
array_view & operator=(const array_view &_Other) __GPU
Copy Assignment operator. Shallow copy.
Definition: amp.h:2500
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:6531
_Array_view_shape() __GPU
Definition: amp.h:1627
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:3602
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:2666
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:934
_Array_view_shape(const _Array_view_shape &_Other, const Concurrency::index< _Rank > &_Section_origin, const Concurrency::extent< _Rank > &_Section_extent) __GPU
Definition: amp.h:1562
void _Initialize() __GPU
Definition: amp.h:2973
_Ret_ void * _Access(_Access_mode _Requested_mode, const index< _Rank > &_Index) const __GPU_ONLY
Definition: amp.h:1844
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:5318
_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:4997
bool operator==(const _Tuple_type< _Rank > &_Lhs, const _Tuple_type< _Rank > &_Rhs) __GPU
Definition: amp.h:810
static _Ret_ void * _Create_projection_buffer_shape(const _Buffer_descriptor &_Descriptor, unsigned int _Dim, int _Dim_offset) __CPU_ONLY
Definition: amp.h:2027
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:1667
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:1296
#define _Ret_
Definition: sal.h:1005
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:5956
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:3912
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:7257
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:97
_Array_view_base(const _Array_view_base &_Other, const Concurrency::extent< _Rank > &_Array_extent) __GPU
Definition: amp.h:1688
_Pre_maybenull_ _Post_z_ char _Pre_maybenull_ _Post_z_ char _Pre_maybenull_ _Post_z_ char _Pre_maybenull_ _Post_z_ char * _Ext
Definition: stdlib.h:854
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:4795
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:1393
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:1150
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:3950
float step(float _Y, float _X) __GPU_ONLY
Compares two values, returning 0 or 1 based on which value is greater
Definition: amp.h:7540
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:5426
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:6841
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:4736
array_view(const array_view< const _Value_type, _Rank > &_Src) __GPU
Copy constructor. Shallow copy.
Definition: amp.h:3050
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:2373
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:7168
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:3118