17 #if !(defined (_M_X64) || defined (_M_IX86) || defined (_M_ARM) || defined (_M_ARM64) )
18 #error ERROR: C++ AMP runtime is supported only on X64, X86, ARM, and ARM64 architectures.
22 #error ERROR: C++ AMP runtime is not supported when compiling /clr.
26 #error ERROR: C++ AMP runtime is supported only for C++.
32 #pragma comment(lib, "vcampd")
34 #pragma comment(lib, "vcamp")
41 #define __GPU restrict(amp,cpu)
42 #define __GPU_ONLY restrict(amp)
73 #define _AMPIMP __declspec(dllimport)
129 return InterlockedIncrement(reinterpret_cast<LONG volatile*>(&
_M_rc));
138 size_t refCount = InterlockedDecrement(reinterpret_cast<LONG volatile*>(&
_M_rc));
181 _Other._M_obj_ptr =
nullptr;
202 if (oldPtr !=
NULL) {
216 _Other._M_obj_ptr =
nullptr;
219 if (oldPtr !=
nullptr)
252 if (_M_obj_ptr ==
NULL)
272 class _Accelerator_view_impl;
273 class _CPU_accelerator_view_impl;
274 class _D3D_accelerator_view_impl;
275 class _Accelerator_impl;
277 class _DPC_runtime_factory;
281 struct _DPC_shader_blob;
456 : _M_data_ptr(
NULL), _M_buffer_ptr(NULL),
488 _M_data_ptr = _Other._M_data_ptr;
489 _M_curr_cpu_access_mode = _Other._M_curr_cpu_access_mode;
490 _M_type_access_mode = _Other._M_type_access_mode;
504 if (_M_buffer_ptr != _Buffer_ptr)
506 if (_M_buffer_ptr !=
NULL) {
512 if (_M_buffer_ptr !=
NULL) {
518 #if !defined(_CXXAMP)
522 UNREFERENCED_PARAMETER(_Buffer_ptr);
523 _M_buffer_ptr =
NULL;
539 return ((
const _View_key)(
this));
577 : _M_data_ptr(
NULL), _M_texture_ptr(NULL), _M_most_detailed_mipmap_level(0), _M_view_mipmap_levels(0)
624 _M_data_ptr = _Other._M_data_ptr;
626 _M_most_detailed_mipmap_level = _Other._M_most_detailed_mipmap_level;
627 _M_view_mipmap_levels = _Other._M_view_mipmap_levels;
641 return _M_texture_ptr == _Other._M_texture_ptr
643 && _M_most_detailed_mipmap_level == _Other._M_most_detailed_mipmap_level
644 && _M_view_mipmap_levels == _Other._M_view_mipmap_levels;
665 _M_view_mipmap_levels = _View_mipmap_levels;
670 if (_M_texture_ptr != _Texture_ptr)
672 if (_M_texture_ptr !=
NULL) {
678 if (_M_texture_ptr !=
NULL) {
684 #if !defined(_CXXAMP)
688 UNREFERENCED_PARAMETER(_Texture_ptr);
689 _M_texture_ptr =
NULL;
703 return !((_M_most_detailed_mipmap_level < _Other->_M_most_detailed_mipmap_level) ? ((_M_most_detailed_mipmap_level + _M_view_mipmap_levels - 1) < _Other->_M_most_detailed_mipmap_level)
729 : _M_data_ptr(
NULL), _M_sampler_ptr(NULL)
757 _M_data_ptr = _Other._M_data_ptr;
772 return _M_sampler_ptr == _Other._M_sampler_ptr && _M_data_ptr == _Other.
_M_data_ptr;
782 if (_M_sampler_ptr != _Sampler_ptr)
784 if (_M_sampler_ptr !=
NULL) {
790 if (_M_sampler_ptr !=
NULL) {
796 #if !defined(_CXXAMP)
800 UNREFERENCED_PARAMETER(_Sampler_ptr);
801 _M_sampler_ptr =
NULL;
1073 _AMPIMP scoped_d3d_access_lock&
operator=(scoped_d3d_access_lock &&_Other);
1080 scoped_d3d_access_lock &
operator=(
const scoped_d3d_access_lock &_Other);
1134 _Init(_Device_path.c_str());
1160 std::vector<accelerator> _AcceleratorVector;
1162 for (
size_t _I = 0; (_I < _NumDevices); ++_I)
1167 return _AcceleratorVector;
1358 : _M_shared_future(_Other._M_shared_future),
1359 _M_task(_Other._M_task)
1367 : _M_shared_future(
std::
move(_Other._M_shared_future)),
1368 _M_task(
std::
move(_Other._M_task))
1382 completion_future&
operator=(
const completion_future& _Other)
1384 if (
this != &_Other) {
1397 if (
this != &_Other) {
1398 _M_shared_future =
std::move(_Other._M_shared_future);
1412 _M_shared_future.get();
1425 return _M_shared_future.valid();
1433 _M_shared_future.wait();
1445 template <
class _Rep,
class _Period>
1448 return _M_shared_future.wait_for(_Rel_time);
1460 template <
class _Clock,
class _Duration>
1463 return _M_shared_future.wait_until(_Abs_time);
1474 operator std::shared_future<void>()
const
1476 return _M_shared_future;
1483 template <
typename _Functor>
1484 void then(
const _Functor &_Func)
const
1486 this->to_task().then(_Func);
1507 : _M_shared_future(_Shared_future), _M_task(_Task)
1526 friend class details::_D3D_accelerator_view_impl;
1527 friend class details::_CPU_accelerator_view_impl;
1587 _AMPIMP bool get_is_auto_selection() const;
1588 __declspec(property(
get=get_is_auto_selection))
bool is_auto_selection;
1622 _AMPIMP accelerator_view(_Accelerator_view_impl_ptr _Impl,
bool _Auto_selection =
false);
1627 bool _M_auto_selection;
1649 std::hash<_Accelerator_view_impl*> _HashFunctor;
1662 const unsigned int *_Base_extent,
const unsigned int *_View_offset,
1663 const unsigned int *_View_extent,
const bool *_Projection_info =
NULL);
1674 return _M_linear_offset;
1679 return _M_base_extent;
1684 return _M_view_offset;
1688 return _M_view_extent;
1693 return _M_projection_info;
1698 return _M_projection_info[0];
1704 size_t endLinearOffset = _M_linear_offset + _Get_extent_size(_M_rank, _M_base_extent);
1705 if (endLinearOffset > _Buffer_size) {
1714 return _Get_extent_size(_M_rank, _M_view_extent);
1719 return _Get_linear_offset(_M_view_offset);
1728 if ((_Extent1[_Rank - 1] * _Elem_size1) != (_Extent2[_Rank - 1] * _Elem_size2))
1734 if ((_Rank > 1) && !_Compare_extent(_Rank - 1, _Extent1, _Extent2))
1744 _Compare_extent(
unsigned int _Rank,
const unsigned int *_Extent1,
const unsigned int *_Extent2)
1746 for (
size_t _I = 0; _I < _Rank; ++_I) {
1747 if (_Extent1[_I] != _Extent2[_I]) {
1755 inline bool _Is_view_linear(
unsigned int &_Linear_offset,
unsigned int &_Linear_size)
const
1759 unsigned int _First_dim_with_non_unit_extent = 0;
1760 while ((_First_dim_with_non_unit_extent < _M_rank) && (_M_view_extent[_First_dim_with_non_unit_extent] == 1)) {
1761 _First_dim_with_non_unit_extent++;
1764 unsigned int _Effective_rank = (_M_rank - _First_dim_with_non_unit_extent);
1769 if ((_Effective_rank <= 1) ||
1770 (_Compare_extent(_Effective_rank - 1, &_M_base_extent[_First_dim_with_non_unit_extent + 1], &_M_view_extent[_First_dim_with_non_unit_extent + 1])))
1772 _Linear_offset = _Get_view_linear_offset();
1773 _Linear_size = _Get_view_size();
1782 if (_Compare_base_shape(_Other))
1787 for (
size_t _I = 0; _I < _M_rank; ++_I)
1789 if (!_Intervals_overlap(_M_view_offset[_I], _M_view_offset[_I] + _M_view_extent[_I] - 1,
1801 size_t firstStart = _Get_view_linear_offset();
1802 size_t firstEnd = firstStart + _Get_view_size() - 1;
1807 return _Intervals_overlap(firstStart, firstEnd, secondStart, secondEnd);
1815 if ((_M_rank == 1) && (_Other->
_Get_rank() == 1))
1817 size_t thisStart = _Get_view_linear_offset();
1818 size_t thisEnd = thisStart + _Get_view_size() - 1;
1823 return ((otherStart >= thisStart) && (otherEnd <= thisEnd));
1826 if (!_Compare_base_shape(_Other)) {
1834 std::vector<unsigned int> otherEndPointIndex(_M_rank);
1835 for (
size_t _I = 0; _I < _M_rank; ++_I) {
1839 return _Contains(otherEndPointIndex.data());
1844 _View_shape(
unsigned int _Rank,
unsigned int _Linear_offset,
1845 const unsigned int *_Base_extent,
const unsigned int *_View_offset,
1846 const unsigned int *_View_extent,
const bool *_Projection_info);
1859 size_t _Second_start,
size_t _Second_end)
1862 if (_First_start > _Second_start) {
1863 size_t temp = _First_start;
1864 _First_start = _Second_start;
1865 _Second_start = temp;
1868 _First_end = _Second_end;
1873 return (_Second_start <= _First_end);
1878 unsigned int totalExtent = 1;
1879 for (
size_t _I = 0; _I < _Rank; ++_I) {
1880 totalExtent *= _Extent[_I];
1893 size_t viewSize = 1;
1895 for (
size_t _I = 0; _I < _M_rank; ++_I)
1897 viewSize *= _M_view_extent[_I];
1898 if ((_M_view_offset[_I] + _M_view_extent[_I]) > _M_base_extent[_I]) {
1903 if (viewSize == 0) {
1912 return ((_M_rank == _Other->
_M_rank) &&
1914 _Compare_extent(_M_rank, _M_base_extent, _Other->
_M_base_extent));
1921 inline bool _Contains(
const unsigned int* _Element_index)
const
1923 for (
size_t _I = 0; _I < _M_rank; ++_I)
1925 if ((_Element_index[_I] < _M_view_offset[_I]) ||
1926 (_Element_index[_I] >= (_M_view_offset[_I] + _M_view_extent[_I])))
1937 unsigned int currMultiplier = 1;
1938 unsigned int linearOffset = _M_linear_offset;
1939 for (
int _I = static_cast<int>(_M_rank - 1); _I >= 0; _I--)
1941 linearOffset += (currMultiplier * _Element_index[_I]);
1942 currMultiplier *= _M_base_extent[_I];
1945 return linearOffset;
1963 unsigned int _Rank = _Source_shape->
_Get_rank();
1965 size_t _BaseLSDExtentInBytes = (_Source_shape->
_Get_base_extent())[_Rank - 1] * _Curr_elem_size;
1966 size_t _ViewLSDOffsetInBytes = (_Source_shape->
_Get_view_offset())[_Rank - 1] * _Curr_elem_size;
1967 size_t _ViewLSDExtentInBytes = (_Source_shape->
_Get_view_extent())[_Rank - 1] * _Curr_elem_size;
1969 _ASSERTE((_LinearOffsetInBytes % _New_elem_size) == 0);
1970 _ASSERTE((_BaseLSDExtentInBytes % _New_elem_size) == 0);
1971 _ASSERTE((_ViewLSDOffsetInBytes % _New_elem_size) == 0);
1972 _ASSERTE((_ViewLSDExtentInBytes % _New_elem_size) == 0);
1974 size_t _Temp_val = _LinearOffsetInBytes / _New_elem_size;
1976 unsigned int _New_linear_offset =
static_cast<unsigned int>(_Temp_val);
1978 std::vector<unsigned int> _New_base_extent(_Rank);
1979 std::vector<unsigned int> _New_view_offset(_Rank);
1980 std::vector<unsigned int> _New_view_extent(_Rank);
1981 for (
unsigned int i = 0;
i < _Rank - 1; ++
i) {
1988 _Temp_val = _BaseLSDExtentInBytes / _New_elem_size;
1990 _New_base_extent[_Rank - 1] =
static_cast<unsigned int>(_Temp_val);
1992 _Temp_val = _ViewLSDOffsetInBytes / _New_elem_size;
1994 _New_view_offset[_Rank - 1] =
static_cast<unsigned int>(_Temp_val);
1996 _Temp_val = _ViewLSDExtentInBytes / _New_elem_size;
1998 _New_view_extent[_Rank - 1] =
static_cast<unsigned int>(_Temp_val);
2000 return _View_shape::_Create_view_shape(_Rank, _New_linear_offset, _New_base_extent.data(), _New_view_offset.data(), _New_view_extent.data());
2005 switch(cpu_access_type)
2032 return _Cpu_access_type;
2038 friend class _CPU_accelerator_view_impl;
2039 friend class _D3D_accelerator_view_impl;
2040 friend class _D3D_temp_staging_cache;
2048 _AMPIMP static _Ret_ _Buffer * __cdecl _Create_buffer(accelerator_view _Accelerator_view, accelerator_view _Access_on_accelerator_view,
size_t _Num_elems,
2053 _AMPIMP static _Ret_ _Buffer * __cdecl _Create_buffer(
_In_ void *_Data_ptr, accelerator_view _Accelerator_view,
size_t _Num_elems,
2057 _AMPIMP static _Ret_ _Buffer * __cdecl _Create_stage_buffer(accelerator_view _Accelerator_view, accelerator_view _Access_on_accelerator_view,
2058 size_t _Num_elems,
size_t _Elem_size,
bool _Is_temp =
false);
2062 _AMPIMP static _Ret_ _Buffer * __cdecl _Get_temp_staging_buffer(accelerator_view _Av,
size_t _Requested_num_elems,
size_t _Elem_size);
2074 _AMPIMP _Event _Copy_to_async(
_Out_ _Buffer * _Dest,
size_t _Num_elems,
size_t _Src_offset = 0,
size_t _Dest_offset = 0);
2079 _AMPIMP accelerator_view _Get_accelerator_view()
const;
2080 _AMPIMP accelerator_view _Get_access_on_accelerator_view()
const;
2102 return _M_elem_size;
2107 return _M_num_elems;
2112 return _M_accelerator_view;
2117 return _M_access_on_accelerator_view;
2122 return _M_owns_data;
2125 _AMPIMP bool _Exclusively_owns_data();
2129 return _M_is_staging;
2134 return _M_allowed_host_access_mode;
2144 return ((_Get_allowed_host_access_mode() & _Requested_access_mode) == _Requested_access_mode);
2149 return _M_current_host_access_mode;
2160 return _M_is_adopted;
2165 return _M_is_buffer;
2168 _AMPIMP bool _Is_mappable()
const;
2174 _Buffer(
_In_ _Accelerator_view_impl* _Av,
_In_ void *_Buffer_data_ptr,
_In_ void * _Host_ptr,
2176 size_t _Elem_size,
bool _Owns_data,
bool _Is_staging,
bool _Is_temp,
bool _Is_adopted);
2190 _M_host_ptr = _Host_ptr;
2191 if (_Host_ptr ==
NULL) {
2195 _M_current_host_access_mode = _Host_access_mode;
2201 _M_data_ptr = _Data_ptr;
2230 friend class _CPU_accelerator_view_impl;
2231 friend class _D3D_accelerator_view_impl;
2232 friend class _D3D_temp_staging_cache;
2239 size_t _Width,
size_t _Height,
size_t _Depth,
2240 unsigned int _Mip_levels,
2242 unsigned int _Num_channels,
2243 unsigned int _Bits_per_channel,
2244 bool _Is_temp =
false);
2249 _In_ IUnknown *_Data_ptr, accelerator_view _Accelerator_view,
2250 unsigned int _View_format);
2253 _AMPIMP static _Ret_ _Texture * __cdecl _Create_stage_texture(accelerator_view _Accelerator_view, accelerator_view _Access_on_accelerator_view,
2255 size_t _Width,
size_t _Height,
size_t _Depth,
2256 unsigned int _Mip_levels,
2258 bool _Is_temp =
false);
2261 _AMPIMP static _Ret_ _Texture * __cdecl _Create_stage_texture(accelerator_view _Accelerator_view, accelerator_view _Access_on_accelerator_view,
2263 size_t _Width,
size_t _Height,
size_t _Depth,
2264 unsigned int _Mip_levels,
2266 unsigned int _Num_channels,
2267 unsigned int _Bits_per_channel);
2271 _AMPIMP static _Ret_ _Texture * __cdecl _Get_temp_staging_texture(accelerator_view _Accelerator_view,
2273 size_t _Width,
size_t _Height,
size_t _Depth,
2274 unsigned int _Mip_levels,
2278 _AMPIMP static _Ret_ _Texture * __cdecl _Clone_texture(
const _Texture *
_Src,
const accelerator_view &_Accelerator_view,
const accelerator_view &_Associated_av);
2283 const size_t *_Src_offset,
const size_t *_Dst_offset,
2284 unsigned int _Src_mipmap_level,
unsigned int _Dst_mipmap_level);
2288 return (_M_width >> _Mip_offset) ? (_M_width >> _Mip_offset) : 1U;
2293 return (_M_height >> _Mip_offset) ? (_M_height >> _Mip_offset) : 1U;
2298 return (_M_depth >> _Mip_offset) ? (_M_depth >> _Mip_offset) : 1U;
2308 return _M_texture_format;
2313 return _M_view_format;
2318 return _M_num_channels;
2324 return _Is_adopted() ? 0 : _M_bits_per_channel;
2329 return _M_bits_per_channel * _M_num_channels;
2332 unsigned int _Get_data_length(
unsigned int _Most_detailed_mipmap_level,
unsigned int _View_mipmap_levels,
const size_t *_Extents =
nullptr) const
2336 unsigned long long _Bits_per_byte = 8ULL;
2337 unsigned long long _Total_bytes = 0ULL;
2339 unsigned int _Mip_level = _Most_detailed_mipmap_level;
2342 for (
unsigned int _Mip_offset=0; _Mip_offset < _View_mipmap_levels; ++_Mip_offset)
2344 unsigned long long _Width = 1ULL;
2345 unsigned long long _Height = 1ULL;
2346 unsigned long long _Depth = 1ULL;
2353 _Depth = (_Extents[2] >> _Mip_level) ? (_Extents[2] >> _Mip_level) : 1U;
2356 _Height = (_Extents[1] >> _Mip_level) ? (_Extents[1] >> _Mip_level) : 1U;
2359 _Width = (_Extents[0] >> _Mip_level) ? (_Extents[0] >> _Mip_level) : 1U;
2367 _Width = _Get_width(_Mip_level);
2368 _Height = _Get_height(_Mip_level);
2369 _Depth = _Get_depth(_Mip_level);
2374 _Total_bytes += ((_Width * _Height * _Depth *
static_cast<unsigned long long>(_Get_bits_per_element())) + _Bits_per_byte - 1) / _Bits_per_byte;
2379 return static_cast<unsigned int>(_Total_bytes);
2384 return _M_mip_levels;
2389 return _M_row_pitch;
2394 _M_row_pitch =
_Val;
2399 return _M_depth_pitch;
2404 _M_depth_pitch =
_Val;
2411 _Texture(
_In_ _Accelerator_view_impl* _Av,
_In_ void *_Texture_data_ptr,
_In_ void * _Host_ptr,
2414 size_t _Width,
size_t _Height,
size_t _Depth,
2415 unsigned int _Mip_levels,
2416 unsigned int _Texture_format,
2417 unsigned int _View_format,
2418 unsigned int _Num_channels,
2419 unsigned int _Bits_per_channel,
2420 bool _Owns_data,
bool _Is_staging,
bool _Is_temp,
bool _Is_adopted);
2450 unsigned int _Filter_mode,
2451 unsigned int _Address_mode,
2470 return _M_is_adopted;
2475 return _M_filter_mode;
2480 return _M_address_mode;
2485 return &_M_border_color[0];
2491 _Sampler(
unsigned int _Filter_mode,
unsigned int _Address_mode,
float _Border_r,
float _Border_g,
float _Border_b,
float _Border_a);
2507 float _M_border_color[4];
2513 size_t _Num_elems,
size_t _Preferred_copy_chunk_num_elems = 0);
2516 _Out_ _Texture *_Dst_tex,
const size_t *_Dst_offset,
unsigned int _Dst_mipmap_level,
2517 const size_t *_Copy_extent,
const size_t *_Preferred_copy_chunk_extent =
NULL);
2521 bool _Truncated_copy =
false;
2522 size_t _Allocation_extent[3] = { _Copy_chunk_extent[0], _Copy_chunk_extent[1], _Copy_chunk_extent[2] };
2524 unsigned int _Most_sig_idx = _Tex->_Get_rank() - 1;
2526 if (_Allocation_extent[_Most_sig_idx] > _Remaining_copy_extent[_Most_sig_idx]) {
2527 _Allocation_extent[_Most_sig_idx] = _Remaining_copy_extent[_Most_sig_idx];
2530 _Texture_ptr _Stage = _Texture::_Get_temp_staging_texture(_Tex->_Get_accelerator_view(), _Tex->_Get_rank(),
2531 _Allocation_extent[0], _Allocation_extent[1], _Allocation_extent[2],
2532 1, _Tex->_Get_texture_format());
2535 size_t _Staging_tex_extent[3] = {_Stage->_Get_width(), _Stage->_Get_height(), _Stage->_Get_depth()};
2536 if (_Curr_copy_extent[_Most_sig_idx] > _Staging_tex_extent[_Most_sig_idx]) {
2537 _Curr_copy_extent[_Most_sig_idx] = _Staging_tex_extent[_Most_sig_idx];
2542 if (_Curr_copy_extent[_Most_sig_idx] < _Remaining_copy_extent[_Most_sig_idx])
2544 _Remaining_copy_extent[_Most_sig_idx] -= _Curr_copy_extent[_Most_sig_idx];
2545 _Truncated_copy =
true;
2548 for (
unsigned int _I = 0; _I < _Most_sig_idx; _I++)
2550 _ASSERTE(_Curr_copy_extent[_I] == _Remaining_copy_extent[_I]);
2553 *_Staging_texture = _Stage;
2554 return _Truncated_copy;
2557 #pragma warning ( push )
2558 #pragma warning ( disable : 6101 )
2563 template <
typename _Input_iterator,
typename _Value_type>
2565 size_t _Width,
size_t _Height,
size_t _Depth,
2566 size_t _Dst_row_pitch_in_bytes,
size_t _Dst_depth_pitch_in_bytes,
2567 size_t _Src_row_pitch,
size_t _Src_depth_pitch)
2573 _Input_iterator _End =
_Src;
2580 unsigned char *_Dst_ptr =
reinterpret_cast<unsigned char *
>(_Dst);
2581 _Input_iterator _Src_start =
_Src;
2582 for (
size_t _I = 0; _I < _Height; _I++)
2584 _Input_iterator _Src_end = _Src_start;
2589 _Dst_ptr += _Dst_row_pitch_in_bytes;
2596 unsigned char *_Dst_ptr_slice_start =
reinterpret_cast<unsigned char *
>(_Dst);
2597 _Input_iterator _Src_depth_slice_start =
_Src;
2598 for (
size_t _I = 0; _I < _Depth; _I++)
2600 _Input_iterator _Src_start = _Src_depth_slice_start;
2601 unsigned char *_Dst_ptr = _Dst_ptr_slice_start;
2603 for (
size_t _J = 0; _J < _Height; _J++)
2605 _Input_iterator _Src_end = _Src_start;
2610 _Dst_ptr += _Dst_row_pitch_in_bytes;
2614 _Dst_ptr_slice_start += _Dst_depth_pitch_in_bytes;
2615 std::advance(_Src_depth_slice_start, _Src_depth_pitch);
2624 #pragma warning ( pop ) // disable : 6101
2626 template <
typename _Output_iterator,
typename _Value_type>
2628 size_t _Width,
size_t _Height,
size_t _Depth,
2629 size_t _Src_row_pitch_in_bytes,
size_t _Src_depth_pitch_in_bytes,
2630 size_t _Dst_row_pitch,
size_t _Dst_depth_pitch)
2636 const _Value_type * _End = _Src + _Width;
2642 const unsigned char *_Src_ptr =
reinterpret_cast<const unsigned char *
>(
_Src);
2643 _Output_iterator _Dst_iter = _Dst;
2644 for (
size_t _I = 0; _I < _Height; _I++)
2646 const _Value_type * _Src_end =
reinterpret_cast<const _Value_type*
>(_Src_ptr) + _Width;
2650 _Src_ptr += _Src_row_pitch_in_bytes;
2656 const unsigned char *_Src_ptr_slice_start =
reinterpret_cast<const unsigned char *
>(
_Src);
2657 _Output_iterator _Dst_depth_slice_start = _Dst;
2658 for (
size_t _I = 0; _I < _Depth; _I++)
2660 _Output_iterator _Dst_iter = _Dst_depth_slice_start;
2661 const unsigned char *_Src_ptr = _Src_ptr_slice_start;
2663 for (
size_t _J = 0; _J < _Height; _J++)
2665 const _Value_type * _Src_end =
reinterpret_cast<const _Value_type *
>(_Src_ptr) + _Width;
2670 _Src_ptr += _Src_row_pitch_in_bytes;
2673 _Src_ptr_slice_start += _Src_depth_pitch_in_bytes;
2674 std::advance(_Dst_depth_slice_start, _Dst_depth_pitch);
2690 return (preferredChunkSize / _Elem_size);
2694 size_t _Depth,
size_t _Bits_per_element,
_Out_writes_(3)
size_t *_Preferred_copy_chunk_extent)
2696 _ASSERTE(_Preferred_copy_chunk_extent !=
nullptr);
2698 size_t requestedByteSize =
static_cast<size_t>((
static_cast<unsigned long long>(_Width) *
2699 static_cast<unsigned long long>(_Height) *
2700 static_cast<unsigned long long>(_Depth) *
2701 static_cast<unsigned long long>(_Bits_per_element)) >> 3);
2706 size_t preferredCopyChunkNumElems =
static_cast<size_t>((
static_cast<unsigned long long>(preferredChunkSize) * 8U) / _Bits_per_element);
2713 _Width = preferredCopyChunkNumElems;
2716 _Height = (preferredCopyChunkNumElems + _Width - 1) / _Width;
2719 _Depth = (preferredCopyChunkNumElems + (_Height * _Width) - 1) / (_Height * _Width);
2725 _Preferred_copy_chunk_extent[0] = _Width;
2726 _Preferred_copy_chunk_extent[1] = _Height;
2727 _Preferred_copy_chunk_extent[2] = _Depth;
2731 template <
typename _T>
2734 static_assert(std::is_unsigned<_T>::value,
"This GCD function only supports unsigned integral types");
2754 template <
typename _T>
2757 static_assert(std::is_unsigned<_T>::value,
"This LCM function only supports unsigned integral types");
2762 return ((_M / _Gcd) * _N);
2765 template <
typename InputIterator,
typename _Value_type>
2766 inline _Event _Copy_impl(InputIterator _SrcFirst, InputIterator _SrcLast,
size_t _NumElemsToCopy,
2767 _Out_ _Buffer * _Dst,
size_t _Dest_offset,
size_t _Preferred_copy_chunk_num_elems = 0)
2769 if (_NumElemsToCopy == 0) {
2777 #pragma warning ( push )
2778 #pragma warning ( disable : 6001 ) // Using uninitialized memory '*_Dst'
2779 if (((_NumElemsToCopy *
sizeof(_Value_type)) + (_Dest_offset * _Dst->_Get_elem_size())) > (_Dst->_Get_num_elems() * _Dst->_Get_elem_size()))
2781 throw runtime_exception(
"Invalid _Src argument(s). _Src size exceeds total size of the _Dest.", E_INVALIDARG);
2783 #pragma warning ( pop )
2795 _Buffer_ptr _PDestBuf = _Dst;
2798 _Value_type *_DestPtr =
reinterpret_cast<_Value_type*
>(
reinterpret_cast<char*
>(_PDestBuf->_Get_host_ptr()) + (_Dest_offset * _PDestBuf->_Get_elem_size()));
2811 _Buffer_ptr _PDestBuf = _Dst;
2812 size_t _NumElemsToCopyRemaining = _NumElemsToCopy;
2813 size_t _PreferredNumElemsToCopyPerChunk = _Preferred_copy_chunk_num_elems;
2814 if (_PreferredNumElemsToCopyPerChunk == 0) {
2819 size_t _CurrDstOffset = _Dest_offset;
2820 InputIterator _CurrStartIter = _SrcFirst;
2824 size_t _AdjustmentRatio = _Lcm /
sizeof(_Value_type);
2828 size_t _AllocationNumElems = _PreferredNumElemsToCopyPerChunk;
2829 if (_NumElemsToCopyRemaining < _AllocationNumElems) {
2830 _AllocationNumElems = _NumElemsToCopyRemaining;
2833 _Buffer_ptr _PDestStagingBuf = _Buffer::_Get_temp_staging_buffer(_Dst->_Get_accelerator_view(),
2834 _AllocationNumElems,
sizeof(_Value_type));
2837 _ASSERTE(_PDestStagingBuf->_Get_elem_size() ==
sizeof(_Value_type));
2839 InputIterator _CurrEndIter = _CurrStartIter;
2840 size_t _CurrNumElemsToCopy = _AllocationNumElems;
2841 if (_CurrNumElemsToCopy > _PDestStagingBuf->_Get_num_elems()) {
2842 _CurrNumElemsToCopy = _PDestStagingBuf->_Get_num_elems();
2845 if (_NumElemsToCopyRemaining <= _CurrNumElemsToCopy) {
2846 _CurrNumElemsToCopy = _NumElemsToCopyRemaining;
2847 _CurrEndIter = _SrcLast;
2853 _CurrNumElemsToCopy = (_CurrNumElemsToCopy / _AdjustmentRatio) * _AdjustmentRatio;
2857 _ASSERTE((_CurrNumElemsToCopy % _AdjustmentRatio) == 0);
2866 _Ev = _Ev.
_Add_event(_PDestStagingBuf->_Copy_to_async(_PDestBuf, _CurrNumElemsToCopy, 0, _CurrDstOffset));
2869 _NumElemsToCopyRemaining -= _CurrNumElemsToCopy;
2870 _CurrDstOffset += (_CurrNumElemsToCopy *
sizeof(_Value_type)) / _Dst->_Get_elem_size();
2871 _CurrStartIter = _CurrEndIter;
2873 }
while (_NumElemsToCopyRemaining != 0);
2882 template<
typename _InputIterator,
typename _Distance>
2883 typename std::enable_if<std::is_base_of<std::input_iterator_tag, typename std::iterator_traits<_InputIterator>::iterator_category>::value>::type
2889 template<
typename _OutputIterator,
typename _Distance>
2890 typename std::enable_if<!std::is_base_of<std::input_iterator_tag, typename std::iterator_traits<_OutputIterator>::iterator_category>::value>::type
2893 for (
size_t i = 0;
i <
_N; ++
i)
2899 template <
typename OutputIterator,
typename _Value_type>
2901 OutputIterator _DestIter,
size_t _Preferred_copy_chunk_num_elems = 0)
2903 if ((_Src ==
NULL) || ((_Src_offset + _Num_elems) > _Src->_Get_num_elems())) {
2907 if (_Num_elems == 0) {
2911 size_t _NumElemsToCopy = (_Num_elems * _Src->_Get_elem_size()) /
sizeof(_Value_type);
2921 _Buffer_ptr _PSrcBuf =
_Src;
2925 const _Value_type *_PFirst =
reinterpret_cast<const _Value_type*
>(
reinterpret_cast<char*
>(_PSrcBuf->_Get_host_ptr()) + (_Src_offset * _PSrcBuf->_Get_elem_size()));
2926 std::copy(_PFirst, _PFirst + _NumElemsToCopy, _DestIter);
2941 _Buffer_ptr _PSrcBuf =
_Src;
2942 size_t _PreferredNumElemsToCopyPerChunk = _Preferred_copy_chunk_num_elems;
2943 if (_PreferredNumElemsToCopyPerChunk == 0) {
2949 size_t _AllocationNumElems = _PreferredNumElemsToCopyPerChunk;
2950 if (_NumElemsToCopy < _AllocationNumElems) {
2951 _AllocationNumElems = _NumElemsToCopy;
2954 _Buffer_ptr _PSrcStagingBuf = _Buffer::_Get_temp_staging_buffer(_Src->_Get_accelerator_view(),
2955 _AllocationNumElems,
sizeof(_Value_type));
2958 _ASSERTE(_PSrcStagingBuf->_Get_elem_size() ==
sizeof(_Value_type));
2963 size_t _AdjustmentRatio = _Lcm /
sizeof(_Value_type);
2965 size_t _CurrNumElemsToCopy = _AllocationNumElems;
2966 if (_CurrNumElemsToCopy > _PSrcStagingBuf->_Get_num_elems()) {
2967 _CurrNumElemsToCopy = _PSrcStagingBuf->_Get_num_elems();
2969 if (_NumElemsToCopy <= _CurrNumElemsToCopy)
2971 _CurrNumElemsToCopy = _NumElemsToCopy;
2977 _CurrNumElemsToCopy = (_CurrNumElemsToCopy / _AdjustmentRatio) * _AdjustmentRatio;
2980 _ASSERTE((_CurrNumElemsToCopy % _AdjustmentRatio) == 0);
2982 size_t _NumElemsToCopyRemaining = _NumElemsToCopy - _CurrNumElemsToCopy;
2984 _Ev = _PSrcBuf->_Copy_to_async(_PSrcStagingBuf, (_CurrNumElemsToCopy *
sizeof(_Value_type)) / _PSrcBuf->_Get_elem_size(), _Src_offset, 0);
2986 if (_NumElemsToCopyRemaining != 0)
2989 _CurrNumElemsToCopy, _NumElemsToCopyRemaining,
2990 _Src_offset, _PreferredNumElemsToCopyPerChunk]()
mutable ->
_Event
2994 size_t _CurrSrcOffset = _Src_offset + ((_CurrNumElemsToCopy *
sizeof(_Value_type)) / _PSrcBuf->_Get_elem_size());
2995 OutputIterator _CurrDestIter = _DestIter;
2996 _Advance_output_iterator<decltype(_CurrDestIter), size_t>(_CurrDestIter, _CurrNumElemsToCopy);
2997 _Event _Ret_ev = _Copy_impl<OutputIterator, _Value_type>(_PSrcBuf.
_Get_ptr(), _CurrSrcOffset,
2998 (_NumElemsToCopyRemaining *
sizeof(_Value_type)) / _PSrcBuf->_Get_elem_size(),
2999 _CurrDestIter, _PreferredNumElemsToCopyPerChunk);
3002 _Value_type *_PFirst =
reinterpret_cast<_Value_type*
>(_PSrcStagingBuf->_Get_host_ptr());
3003 std::copy(_PFirst, _PFirst + _CurrNumElemsToCopy, _DestIter);
3011 _Value_type *_PFirst =
reinterpret_cast<_Value_type*
>(_PSrcStagingBuf->_Get_host_ptr());
3012 std::copy(_PFirst, _PFirst + _CurrNumElemsToCopy, _DestIter);
3027 const unsigned int _Rank,
3028 const unsigned int _Src_linear_offset,
3029 const unsigned int * _Src_extents,
3030 const unsigned int * _Src_copy_offset,
3031 const unsigned int _Dst_linear_offset,
3032 const unsigned int * _Dst_extents,
3033 const unsigned int * _Dst_copy_offset,
3034 const unsigned int * _Copy_extents)
3036 this->_Rank = _Rank;
3038 this->_Src_linear_offset = _Src_linear_offset;
3039 this->_Src_extents.assign( _Src_extents, _Src_extents + _Rank);
3040 this->_Src_copy_offset.assign( _Src_copy_offset, _Src_copy_offset + _Rank);
3042 this->_Dst_linear_offset = _Dst_linear_offset;
3043 this->_Dst_extents.assign( _Dst_extents, _Dst_extents + _Rank);
3044 this->_Dst_copy_offset.assign( _Dst_copy_offset, _Dst_copy_offset + _Rank);
3046 this->_Copy_extents.assign( _Copy_extents, _Copy_extents + _Rank);
3069 unsigned int _Native_copy_rank,
3070 std::function<HRESULT(
const _Array_copy_desc &_Reduced)> _Native_copy_func);
3076 template<
typename _InputInterator,
typename _OutputIterator>
3079 std::copy(_SrcFirst, _SrcLast, _DstFirst);
3084 template <
typename InputIterator,
typename _Value_type>
3091 if (_Src_shape->_Is_projection()) {
3092 _Src_shape = _Src_shape->_Get_reduced_shape_for_copy();
3095 if (_Dst_shape->_Is_projection()) {
3096 _Dst_shape = _Dst_shape->_Get_reduced_shape_for_copy();
3099 _ASSERTE(_Src_shape->_Get_rank() == _Dst_shape->_Get_rank());
3101 _ASSERTE(_View_shape::_Compare_extent_with_elem_size(_Src_shape->_Get_rank(), _Src_shape->_Get_view_extent(),
3102 sizeof(_Value_type), _Dst_shape->_Get_view_extent(), _Dst->_Get_elem_size()));
3108 _Buffer_ptr _PDestBuf = _Dst;
3119 _Src_shape->_Get_view_size(),
sizeof(_Value_type),
true );
3122 _Value_type *_Dst_ptr =
reinterpret_cast<_Value_type*
>(_PTempStagingBuf->_Get_host_ptr());
3126 _Buffer_ptr _PDestBuf = _Dst;
3128 return _Copy_impl(_PTempStagingBuf, _Src_shape, _PDestBuf, _Dst_shape);
3133 template <
typename OutputIterator,
typename _Value_type>
3140 if (_Src_shape->_Is_projection()) {
3141 _Src_shape = _Src_shape->_Get_reduced_shape_for_copy();
3144 if (_Dst_shape->_Is_projection()) {
3145 _Dst_shape = _Dst_shape->_Get_reduced_shape_for_copy();
3148 _ASSERTE(_Src_shape->_Get_rank() == _Dst_shape->_Get_rank());
3150 _ASSERTE(_View_shape::_Compare_extent_with_elem_size(_Src_shape->_Get_rank(), _Src_shape->_Get_view_extent(),
3151 _Src->_Get_elem_size(), _Dst_shape->_Get_view_extent(),
sizeof(_Value_type)));
3158 _Buffer_ptr _PSrcBuf =
_Src;
3160 return _Copy_impl_iter(reinterpret_cast<_Value_type*>(_PSrcBuf->_Get_host_ptr()),
3162 _DestIter, _Dst_shape);
3171 _Dst_shape->_Get_view_size(),
sizeof(_Value_type),
true);
3173 _Event _Ev = _Src->_Copy_to_async(_PTempStagingBuf, _Src_shape, _Dst_shape);
3175 return _Copy_impl_iter(reinterpret_cast<_Value_type*>(_PTempStagingBuf->_Get_host_ptr()),
3176 _Dst_shape, _DestIter, _Dst_shape);
3182 template<
typename _InputInterator,
typename _OutputIterator>
3184 _OutputIterator _DstIter, _View_shape_ptr _Dst_shape)
3186 if (_Src_shape->_Is_projection()) {
3187 _Src_shape = _Src_shape->_Get_reduced_shape_for_copy();
3190 if (_Dst_shape->_Is_projection()) {
3191 _Dst_shape = _Dst_shape->_Get_reduced_shape_for_copy();
3194 _ASSERTE(_Src_shape->_Get_rank() == _Dst_shape->_Get_rank());
3195 _ASSERTE(_View_shape::_Compare_extent(_Src_shape->_Get_rank(), _Src_shape->_Get_view_extent(), _Dst_shape->_Get_view_extent()));
3198 unsigned int _Src_linear_offset, _Src_linear_size, _Dst_linear_offset, _Dst_linear_size;
3199 if (_Src_shape->_Is_view_linear(_Src_linear_offset, _Src_linear_size) &&
3200 _Dst_shape->_Is_view_linear(_Dst_linear_offset, _Dst_linear_size))
3202 _ASSERTE(_Src_linear_size == _Dst_linear_size);
3206 auto _SrcLast = _SrcIter;
3213 std::vector<unsigned int> _Src_extent(_Src_shape->_Get_rank());
3214 std::vector<unsigned int> _Src_offset(_Src_shape->_Get_rank());
3215 std::vector<unsigned int> _Dst_extent(_Dst_shape->_Get_rank());
3216 std::vector<unsigned int> _Dst_offset(_Dst_shape->_Get_rank());
3217 std::vector<unsigned int> _Copy_extent(_Src_shape->_Get_rank());
3219 for (
size_t i = 0;
i < _Src_shape->_Get_rank(); ++
i) {
3220 _Src_extent[
i] = _Src_shape->_Get_base_extent()[
i];
3221 _Src_offset[
i] = _Src_shape->_Get_view_offset()[
i];
3222 _Dst_extent[
i] = _Dst_shape->_Get_base_extent()[
i];
3223 _Dst_offset[
i] = _Dst_shape->_Get_view_offset()[
i];
3224 _Copy_extent[
i] = _Src_shape->_Get_view_extent()[
i];
3228 _Src_shape->_Get_rank(),
3229 _Src_shape->_Get_linear_offset(),
3232 _Dst_shape->_Get_linear_offset(),
3235 _Copy_extent.data());
3241 auto _SrcFirst = _SrcIter;
3242 auto _DstFirst = _DstIter;
3246 auto _SrcLast = _SrcFirst;
3249 std::copy(_SrcFirst, _SrcLast, _DstFirst);
3266 friend _AMPIMP accelerator_view __cdecl _Select_copy_src_accelerator_view(
_In_ _View_key _Src_view_key,
const accelerator_view &_Dest_accelerator_view);
3276 _AMPIMP void _Register_view(
_In_ _View_key _Key, accelerator_view _Cpu_av, _View_shape_ptr _Shape);
3299 _AMPIMP _Buffer_ptr _Get_master_buffer()
const;
3301 _AMPIMP accelerator_view _Get_master_accelerator_view()
const;
3307 return _M_master_av;
3312 return _M_master_buffer_elem_size;
3317 return _M_master_buffer_num_elems;
3322 return _M_has_data_source;
3351 _Event _Commit_view_async(
_In_ _View_info *_Info,
_Inout_ ULONGLONG *_Sync_size =
nullptr);
3363 void _Unset_discard_flag(
_Inout_ _View_info *_Info);
3367 bool _Should_discard(
const _View_info *_Info)
const;
3372 bool _Has_exclusive_data(
const _View_info *_Info)
const;
3377 bool _Requires_update_on_target_accelerator_view(
const _View_info *_Info,
3379 _In_ _Accelerator_view_impl* _Target_acclerator_view)
const;
3384 static void _Flag_redundant_commits(std::vector<std::pair<_View_info*, bool>> &_Commit_list);
3396 _Accelerator_view_unordered_set _Get_caching_info_impl(
_In_ _View_key _Key,
_Out_opt_ bool *_Can_access_anywhere);
3398 _Ret_ _Accelerator_view_impl* _Determine_alternate_target_accelerator_view(
_In_ _View_key _Key,
3399 _In_ _Accelerator_view_impl* _Original_av,
3451 _AMPIMP static _Ret_ void * __cdecl _Get_D3D_sampler_data_ptr(
_In_ IUnknown *_D3D_sampler);
3452 _AMPIMP static void __cdecl _Release_D3D_sampler_data_ptr(
_In_ void *_Sampler_data_ptr);
3509 _AMPIMP HRESULT get_view_removed_reason()
const throw();
3565 #define HELPERAPI __cdecl
3631 return reinterpret_cast<void *
>(_Tmp);
3633 else if (_Is_texture())
3635 _Texture * _Tmp = _Get_texture_desc()->_Get_texture_ptr();
3636 return reinterpret_cast<void *
>(_Tmp);
3641 _Sampler * _Tmp = _Get_sampler_desc()->_Get_sampler_ptr();
3642 return reinterpret_cast<void *
>(_Tmp);
3708 if (!_Accelerator_view.is_auto_selection) {
3715 _M_is_explicit_target_acclview =
false;
3716 if (_M_rv !=
NULL) {
3717 _M_is_explicit_target_acclview =
true;
3720 _M_device_resource_info =
NULL;
3721 _M_num_resources = 0;
3722 _M_num_writable_buffers = 0;
3723 _M_num_samplers = 0;
3725 _M_const_buffer_info =
NULL;
3726 _M_num_const_buffers = 0;
3728 _M_RW_aliasing =
false;
3732 _M_shader_blobs[_I] =
NULL;
3735 _M_is_flat_model = 0;
3736 _M_compute_rank = 0;
3737 _M_grid_extents =
NULL;
3743 _M_groupExtentX = 0;
3744 _M_groupExtentY = 0;
3745 _M_groupExtentZ = 0;
3750 if (_M_grid_extents) {
3751 delete [] _M_grid_extents;
3757 return ((_M_aliased_buffer_set !=
nullptr) && (_M_aliased_buffer_set->find(_Buffer_ptr) != _M_aliased_buffer_set->end()));
3762 return ((_M_is_device_buffer_unaccessed !=
nullptr) && _M_is_device_buffer_unaccessed->operator[](_Buffer_idx));
3767 if (_M_is_device_buffer_unaccessed ==
nullptr) {
3768 _M_is_device_buffer_unaccessed = std::unique_ptr<std::vector<bool>>(
new std::vector<bool>(_M_num_resources,
false));
3771 _M_is_device_buffer_unaccessed->operator[](_Buffer_idx) =
true;
3776 if (!_M_RW_aliasing) {
3780 _ASSERTE(_M_Redirect_indices !=
nullptr);
3782 return _M_Redirect_indices->data();
3785 void _Check_buffer_aliasing();
3786 void _Update_buffer_rw_property();
3787 void _Setup_aliasing_redirection_indices();
3788 void _Select_accelerator_view();
3789 void _Verify_buffers_against_accelerator_view();
3839 _Inout_ void ** _ShaderBlobs)
throw(...);
3842 unsigned int _ComputeRank,
3843 _In_ int * _Extents,
3844 unsigned int _GroupRank,
3845 const unsigned int * _GroupExtents,
3846 unsigned int & _GroupCountX,
3847 unsigned int & _GroupCountY,
3848 unsigned int & _GroupCountZ)
throw(...);
3879 friend BOOL CALLBACK _Init_amp_runtime_trace(PINIT_ONCE _Init_once, PVOID _Param,
_Inout_ PVOID *
_Context);
3886 _AMPIMP void _Write_end_event(ULONG _Span_id);
3890 void _Add_accelerator_config_event(PVOID _Accelerator_id, LPCWSTR _Device_path, LPCWSTR _Device_description);
3894 void _Write_all_accelerator_config_events();
3898 ULONG _Start_accelerator_view_wait_event(PVOID _Accelerator_id, PVOID _Accelerator_view_id);
3902 void _Launch_flush_event(PVOID _Accelerator_id, PVOID _Accelerator_view_id);
3906 ULONG _Launch_marker(PVOID _Accelerator_id, PVOID _Accelerator_view_id);
3914 std::shared_future<void> retFuture;
3919 retFuture =
std::async(std::launch::sync, [=]()
mutable {
3922 if (_Async_op_id == _Amp_runtime_trace::_M_event_disabled)
3942 retTaskCompletionEvent.
set();
3971 _AMPIMP ULONG _Launch_async_copy_event_helper(nullptr_t,
const _Buffer_descriptor &_Dest, ULONGLONG _Num_bytes_for_copy);
3982 void _Enable_provider(
bool _Enable =
true);
3995 void _Write_accelerator_config_event(
const std::tuple<PVOID, LPCWSTR, LPCWSTR> &_ConfigTuple);
3998 ULONG _Start_parallel_for_each_event(
3999 PVOID _Accelerator_id,
4000 PVOID _Accelerator_view_id,
4001 BOOL _Is_tiled_explicitly,
4002 ULONGLONG _Num_of_tiles,
4003 ULONG _Num_of_threads_per_tile,
4005 ULONG _Num_read_only_resources,
4006 ULONG _Num_read_write_resources,
4007 ULONGLONG _Size_of_all_resouces,
4008 ULONG _Size_of_const_data,
4009 ULONGLONG _Size_of_data_for_copy);
4012 ULONG _Start_copy_event(
4013 PVOID _Src_accelerator_id,
4014 PVOID _Src_accelerator_view_id,
4015 PVOID _Dst_accelerator_id,
4016 PVOID _Dst_accelerator_view_id,
4017 ULONGLONG _Num_bytes_for_copy,
4018 BOOL _Is_src_staging,
4019 BOOL _Is_dst_staging);
4022 ULONG _Launch_async_copy_event(
4023 PVOID _Src_accelerator_id,
4024 PVOID _Src_accelerator_view_id,
4025 PVOID _Dst_accelerator_id,
4026 PVOID _Dst_accelerator_view_id,
4027 ULONGLONG _Num_bytes_for_copy,
4028 BOOL _Is_src_staging,
4029 BOOL _Is_dst_staging);
4032 _AMPIMP ULONG _Start_async_op_wait_event(ULONG _Async_op_id);
4035 ULONG _Start_array_view_synchronize_event(ULONGLONG _Num_bytes_to_synchronize);
4038 ULONG _Launch_array_view_synchronize_event(ULONGLONG _Num_bytes_to_synchronize);
4041 std::tuple<PVOID, PVOID, BOOL> _Get_resource_diagnostic_info(
const _Buffer_descriptor &_Buff_desc, accelerator_view _Accl_view)
const;
4044 std::tuple<PVOID, PVOID, BOOL> _Get_resource_diagnostic_info(
const _Texture_descriptor &_Tex_desc)
const;
4047 ULONG _Get_unique_identifier();
4064 static const ULONG _M_event_disabled = 0;
unsigned int * _M_view_extent
Definition: amprt.h:1954
#define _Out_
Definition: sal.h:351
unsigned int _M_linear_offset
Definition: amprt.h:1951
_AMPIMP bool __cdecl is_timeout_disabled(const accelerator_view &_Accelerator_view)
Returns a boolean flag indicating if timeout is disabled for the specified accelerator_view. This corresponds to the D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT flag for Direct3D device creation.
_Event _Copy_impl(_In_ _Buffer *_Src, _View_shape_ptr _Src_shape, OutputIterator _DestIter, _View_shape_ptr _Dst_shape)
Definition: amprt.h:3134
unsigned int _M_view_mipmap_levels
Definition: amprt.h:570
static bool _Compare_extent(unsigned int _Rank, const unsigned int *_Extent1, const unsigned int *_Extent2)
Definition: amprt.h:1744
_AMPIMP scoped_d3d_access_lock & operator=(scoped_d3d_access_lock &&_Other)
Move assignment operator for scoped_d3d_access_lock: Take ownership of a lock from another scoped_d3d...
completion_future & operator=(const completion_future &_Other)
Copy assignment operator
Definition: amprt.h:1382
HRESULT _M_error_code
Definition: amprt.h:887
_Sampler_descriptor & operator=(const _Sampler_descriptor &_Other) __GPU
Definition: amprt.h:753
size_t _Get_elem_size() const
Definition: amprt.h:2100
size_t _Get_master_buffer_elem_size() const
Definition: amprt.h:3310
size_t _M_num_writable_buffers
Definition: amprt.h:3679
unsigned int _Get_bits_per_element() const
Definition: amprt.h:2327
details::_Reference_counted_obj_ptr< details::_Buffer > _Buffer_ptr
Definition: amprt.h:302
std::vector< unsigned int > _Copy_extents
Definition: amprt.h:3064
_Ty & get(array< _Ty, _Size > &_Arr) _NOEXCEPT
Definition: array:506
size_t _M_rc
Definition: amprt.h:156
_OutIt copy(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2072
size_t _M_depth
Definition: amprt.h:2434
_Reference_counted_obj_ptr(const _Reference_counted_obj_ptr &_Other)
Definition: amprt.h:173
virtual _AMPIMP ~runtime_exception()
Destruct a runtime_exception exception object instance
T * _M_obj_ptr
Definition: amprt.h:248
friend class _D3D_accelerator_view_impl
Definition: amprt.h:317
_Ret_ void * _Get_data_ptr() const
Definition: amprt.h:2088
void get() const
Returns the result this task produced. If the task is not in a terminal state, a call to get will wai...
Definition: ppltasks.h:4387
_Accelerator_view_impl_ptr _M_master_av
Definition: amprt.h:3408
size_t operator()(const accelerator_view &_Accl_view) const
Definition: amprt.h:1647
_Short_vector_base_type_id
Definition: amprt.h:285
static _AMPIMP const wchar_t direct3d_ref[]
String constant for direct3d reference accelerator
Definition: amprt.h:1121
_AMPIMP ~_Event()
Destructor of the _Event.
completion_future()
Default constructor
Definition: amprt.h:1350
exception_ptr current_exception()
Definition: exception:527
const unsigned int * _Get_base_extent() const
Definition: amprt.h:1677
std::unique_ptr< std::vector< bool > > _M_is_device_buffer_unaccessed
Definition: amprt.h:3793
#define _Out_opt_
Definition: sal.h:352
void _Get_preferred_copy_chunk_extent(unsigned int _Rank, size_t _Width, size_t _Height, size_t _Depth, size_t _Bits_per_element, _Out_writes_(3) size_t *_Preferred_copy_chunk_extent)
Definition: amprt.h:2693
#define S_OK
Definition: comutil.h:62
_AMPIMP runtime_exception(const char *_Message, HRESULT _Hresult)
Construct a runtime_exception exception with a message and an error code
unchecked_array_iterator< _Iterator > make_unchecked_array_iterator(_Iterator _Ptr)
Definition: iterator:729
std::future_status wait_for(const std::chrono::duration< _Rep, _Period > &_Rel_time) const
Blocks until the associated asynchronous operation completes or _Rel_time has elapsed ...
Definition: amprt.h:1446
~_DPC_call_handle()
Definition: amprt.h:3748
void * _M_data
Definition: amprt.h:3650
unsigned int _Get_texture_format() const
Definition: amprt.h:2306
_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 size_t ERROR_MSG_BUFFER_SIZE
Definition: amprt.h:112
std::shared_future< void > _M_shared_future
Definition: amprt.h:1511
__declspec(property(get=get_version)) unsigned int version
_Check_return_ _In_ int _Mode
Definition: io.h:338
unsigned int _Get_mip_levels() const
Definition: amprt.h:2382
size_t _M_master_buffer_num_elems
Definition: amprt.h:3418
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
unsigned int _Rank
Definition: amprt.h:3051
unsigned int _M_groupExtentY
Definition: amprt.h:3703
accelerator_view _M_accelerator_view
Definition: amprt.h:3804
bool _M_RW_aliasing
Definition: amprt.h:3686
unsigned int _Get_view_format() const
Definition: amprt.h:2311
bool _Subsumes(const _View_shape *_Other) const
Definition: amprt.h:1811
_AMPIMP accelerator()
Construct a accelerator representing the default accelerator
size_t _M_row_pitch
Definition: amprt.h:2441
void _Distance(_InIt _First, _InIt _Last, _Diff &_Off)
Definition: xutility:764
details::_Reference_counted_obj_ptr< details::_Texture > _Texture_ptr
Definition: amprt.h:303
_AMPIMP const wchar_t * _Get_description() const
bool _Is_buffer_aliased(_In_ void *_Buffer_ptr)
Definition: amprt.h:3755
unsigned int * _M_base_extent
Definition: amprt.h:1952
bool _Is_buffer_unaccessed(size_t _Buffer_idx)
Definition: amprt.h:3760
bool _Get_chunked_staging_texture(_In_ _Texture *_Tex, const size_t *_Copy_chunk_extent, _Inout_ size_t *_Remaining_copy_extent, _Out_ size_t *_Curr_copy_extent, _Out_ _Texture_ptr *_Staging_texture)
Definition: amprt.h:2519
std::wstring get_description() const
Returns the device description as a std::wstring
Definition: amprt.h:1216
_AMPIMP out_of_memory()
Construct an out_of_memory exception
_Ret_ _Accelerator_view_impl * _Get_accelerator_view_impl() const
Definition: amprt.h:2110
_AMPIMP _Ret_ IUnknown *__cdecl get_device(const accelerator_view &_Av)
Get the D3D device interface underlying a accelerator_view.
unsigned int _Get_address_mode() const
Definition: amprt.h:2478
_Buffer_descriptor & operator=(const _Buffer_descriptor &_Other) __GPU
Definition: amprt.h:484
std::vector< unsigned int > _Dst_copy_offset
Definition: amprt.h:3061
unsigned int _M_groupExtentZ
Definition: amprt.h:3704
static _AMPIMP const wchar_t direct3d_warp[]
String constant for direct3d WARP accelerator
Definition: amprt.h:1116
Exception thrown when an underlying OS/DirectX call fails due to lack of system or device memory ...
Definition: amprt.h:894
#define __GPU
Definition: amprt.h:41
_AMPIMP accelerator_view __cdecl create_accelerator_view(_In_ IUnknown *_D3D_device, queuing_mode _Qmode=queuing_mode_automatic)
Create a accelerator_view from a D3D device interface pointer.
_N
Definition: wchar.h:1269
size_t _Get_row_pitch() const
Definition: amprt.h:2387
_Reference_counted_obj_ptr & operator=(const _Reference_counted_obj_ptr &_Other)
Definition: amprt.h:194
_Buffer_descriptor(_In_ void *_Data_ptr, _In_ _Ubiquitous_buffer *_Buffer_ptr, _Access_mode _Curr_cpu_access_mode, _Access_mode _Type_mode) __GPU
Definition: amprt.h:461
void * _M_data_ptr
Definition: amprt.h:2503
std::future_status wait_until(const std::chrono::time_point< _Clock, _Duration > &_Abs_time) const
Blocks until the associated asynchronous operation completes or until the current time exceeds _Abs_t...
Definition: amprt.h:1461
_Ret_ void * _Get_resource_ptr() const
Definition: amprt.h:3626
_OutIt move(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2447
Class represents a virtual device abstraction on a C++ AMP data-parallel accelerator ...
Definition: amprt.h:1518
_AMPIMP bool _Is_finished()
Poll whether the _Event has completed or not and throws any exceptions that occur ...
RAII wrapper for a D3D access lock on an accelerator_view.
Definition: amprt.h:1021
_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)
_AMPIMP bool __cdecl d3d_access_try_lock(accelerator_view &_Av)
Attempt to acquire the D3D access lock on an accelerator_view without blocking.
void _Init()
Definition: amprt.h:250
_Ret_ _Accelerator_view_impl * _Get_accelerator_view_impl_ptr(const accelerator_view &_Accl_view)
Definition: amprt.h:1632
std::vector< unsigned int > _Src_extents
Definition: amprt.h:3055
_Ubiquitous_buffer * _M_buffer_ptr
Definition: amprt.h:439
bool _M_owns_data
Definition: amprt.h:2213
details::_Reference_counted_obj_ptr< details::_View_shape > _View_shape_ptr
Definition: amprt.h:307
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
_Ret_ _Texture_descriptor * _Get_texture_desc() const
Definition: amprt.h:3614
std::wstring get_device_path() const
Returns the system-wide unique device instance path as a std::wstring
Definition: amprt.h:1200
bool _Is_valid_access_mode(_Access_mode _Mode)
Definition: amprt.h:411
size_t _Get_depth(unsigned int _Mip_offset=0) const
Definition: amprt.h:2296
void _Set_texture_ptr(_In_opt_ _Texture *_Texture_ptr) __GPU_ONLY
Definition: amprt.h:685
std::unordered_set< _View_info * > _M_view_info_set
Definition: amprt.h:3439
_Texture_descriptor(_Texture_descriptor &&_Other) __CPU_ONLY
Definition: amprt.h:634
_AMPIMP _Event __cdecl _Copy_async_impl(_In_ _Texture *_Src_tex, const size_t *_Src_offset, unsigned int _Src_mipmap_level, _Out_ _Texture *_Dst_tex, const size_t *_Dst_offset, unsigned int _Dst_mipmap_level, const size_t *_Copy_extent, const size_t *_Preferred_copy_chunk_extent=NULL)
_AMPIMP bool operator==(const _Event &_Other) const
Return true if the other _Event is same as this _Event; false otherwise
accelerator(const std::wstring &_Device_path)
Construct a accelerator representing the accelerator with the specified device instance path ...
Definition: amprt.h:1132
Tag type to indicate the D3D access lock should be adopted rather than acquired.
Definition: amprt.h:1016
const bool * _Get_projection_info() const
Definition: amprt.h:1691
void _Set_depth_pitch(size_t _Val)
Definition: amprt.h:2402
unsigned int _M_is_debug_data
Definition: amprt.h:3655
_AMPIMP scoped_d3d_access_lock(accelerator_view &_Av)
Acquire a D3D access lock on the given accelerator_view. The lock is released when this object goes o...
details::_Reference_counted_obj_ptr< details::_Accelerator_impl > _Accelerator_impl_ptr
Definition: amprt.h:301
_AMPIMP bool get_supports_limited_double_precision() const
Returns a boolean value indicating whether the accelerator has limited double precision support (excl...
_AMPIMP bool _Is_empty() const
Tells if this is an empty event
#define NULL
Definition: crtdbg.h:30
_Ret_ T * operator->() const
Definition: amprt.h:227
bool _M_has_data_source
Definition: amprt.h:3421
unsigned int _Get_num_channels() const
Definition: amprt.h:2316
bool _Owns_data() const
Definition: amprt.h:2120
_AMPIMP bool __cdecl _Set_default_accelerator(_Accelerator_impl_ptr _Accl)
_AMPIMP _Ret_ _DPC_call_handle *HELPERAPI __dpc_create_call_handle(_In_ _Host_Scheduling_info *_Sch_info)
_AMPIMP HRESULT get_error_code() const
Get the error code that caused this exception
access_type _Get_cpu_access_type(_Access_mode _Cpu_access_mode)
Definition: amprt.h:2021
iterator_traits< _InIt >::difference_type distance(_InIt _First, _InIt _Last)
Definition: xutility:755
bool operator==(const _Sampler_descriptor &_Other) const __GPU
Definition: amprt.h:770
void _Set_sampler_ptr(_In_opt_ _Sampler *_Sampler_ptr) __GPU_ONLY
Definition: amprt.h:797
_AMPIMP bool __cdecl _Is_D3D_accelerator_view(const accelerator_view &_Av)
_AMPIMP bool get_supports_cpu_shared_memory() const
Returns a boolean value indicating whether the accelerator supports memory accessible both by the acc...
_AMPIMP void _Get()
Wait until the _Event completes and throw any exceptions that occur.
details::_Reference_counted_obj_ptr< details::_Accelerator_view_impl > _Accelerator_view_impl_ptr
Definition: amprt.h:300
unsigned int _M_rank
Definition: amprt.h:2431
_AMPIMP _Ret_ _Amp_runtime_trace *__cdecl _Get_amp_trace()
BOOL _Is_sampler() const
Definition: amprt.h:3603
bool _Is_adopted() const
Definition: amprt.h:2157
enum _Short_vector_base_type_id _Texture_base_type_id
Definition: amprt.h:296
basic_ostream< _Elem, _Traits > &__CLRCALL_OR_CDECL flush(basic_ostream< _Elem, _Traits > &_Ostr)
Definition: ostream:1016
The task_completion_event class allows you to delay the execution of a task until a condition is sati...
Definition: ppltasks.h:2883
_AMPIMP bool get_has_display() const
Returns a boolean value indicating whether the accelerator is attached to a display ...
_Sampler_descriptor(const _Sampler_descriptor &_Other) __GPU
Definition: amprt.h:746
size_t _Get_reference_count()
Definition: amprt.h:150
void _Set_buffer_ptr(_In_opt_ _Ubiquitous_buffer *_Buffer_ptr) __CPU_ONLY
Definition: amprt.h:502
size_t _M_num_resources
Definition: amprt.h:3678
_AMPIMP accelerator & operator=(const accelerator &_Other)
Assignment operator
bool _Compare_base_shape(const _View_shape *_Other) const
Definition: amprt.h:1910
bool _Is_host_accessible(_Access_mode _Requested_access_mode) const
Definition: amprt.h:2142
unsigned int _Get_most_detailed_mipmap_level() const __GPU
Definition: amprt.h:653
#define UINT_MAX
Definition: limits.h:41
A non-reentrant mutex which is explicitly aware of the Concurrency Runtime.
Definition: concrt.h:3548
unsigned int _M_groupCountZ
Definition: amprt.h:3699
const unsigned int * _Get_view_extent() const
Definition: amprt.h:1686
_T _Greatest_common_divisor(_T _M, _T _N)
Definition: amprt.h:2732
_AMPIMP bool get_is_emulated() const
Returns a boolean value indicating whether the accelerator is emulated. This is true, for example, with the direct3d reference and WARP accelerators.
_Accelerator_view_impl_ptr _M_access_on_accelerator_view
Definition: amprt.h:2206
static _AMPIMP const wchar_t cpu_accelerator[]
String constant for cpu accelerator
Definition: amprt.h:1111
_Trace * _M_trace_ptr
Definition: amprt.h:4061
_Event _Copy_impl_iter(_InputInterator _SrcIter, _View_shape_ptr _Src_shape, _OutputIterator _DstIter, _View_shape_ptr _Dst_shape)
Definition: amprt.h:3183
_AMPIMP _Event _Add_event(_Event _Ev)
Creates an event which is an ordered collection of this and _Ev
unsigned int _M_bits_per_channel
Definition: amprt.h:2437
void then(const _Functor &_Func) const
Chains a callback Functor to the completion_future to be executed when the associated asynchronous op...
Definition: amprt.h:1484
unsigned int _M_filter_mode
Definition: amprt.h:2505
_Ret_ T * _Get_ptr() const
Definition: amprt.h:242
_AMPIMP ~scoped_d3d_access_lock()
Destructor for scoped_d3d_access_lock: unlock the accelerator_view.
unsigned int _M_mip_levels
Definition: amprt.h:2439
int i[4]
Definition: dvec.h:70
_Buffer_descriptor() __GPU
Definition: amprt.h:455
void _Set_row_pitch(size_t _Val)
Definition: amprt.h:2392
details::_Reference_counted_obj_ptr< details::_Ubiquitous_buffer > _Ubiquitous_buffer_ptr
Definition: amprt.h:305
static std::vector< accelerator > get_all()
Returns the vector of accelerator objects representing all available accelerators ...
Definition: amprt.h:1158
bool _Contains(const unsigned int *_Element_index) const
Definition: amprt.h:1921
_Texture_descriptor(const _Texture_descriptor &_Other) __GPU
Definition: amprt.h:604
completion_future(completion_future &&_Other)
Move constructor
Definition: amprt.h:1366
_AMPIMP _Ret_ _Accelerator_impl_ptr *__cdecl _Get_devices()
#define _ASSERTE(expr)
Definition: crtdbg.h:216
void _Set_buffer_ptr(_In_opt_ _Ubiquitous_buffer *_Buffer_ptr) __GPU_ONLY
Definition: amprt.h:519
_Access_mode _M_curr_cpu_access_mode
Definition: amprt.h:444
_In_ size_t _In_z_ const unsigned char * _Src
Definition: mbstring.h:95
unsigned int _Get_view_mipmap_levels() const __GPU
Definition: amprt.h:658
#define _In_
Definition: sal.h:314
_AMPIMP void __cdecl amp_uninitialize()
Uninitializes the C++ AMP runtime. It is legal to call this function multiple times during an applica...
volatile ULONG _M_counter
Definition: amprt.h:4058
#define _Inout_opt_
Definition: sal.h:385
_DPC_kernel_func_kind
Definition: amprt.h:3664
size_t _Get_num_elems() const
Definition: amprt.h:2105
std::unique_ptr< std::unordered_set< _View_key > > _M_view_keys
Definition: amprt.h:2223
bool _M_is_temp
Definition: amprt.h:2217
_Accelerator_view_impl_ptr _M_accelerator_view
Definition: amprt.h:2205
#define _In_opt_
Definition: sal.h:315
_Event_impl_ptr _M_ptr_event_impl
Definition: amprt.h:401
_Sampler_descriptor(_Sampler_descriptor &&_Other) __CPU_ONLY
Definition: amprt.h:765
#define FAILED(hr)
Definition: comutil.h:71
_Ret_ void * _Get_data_ptr() const
Definition: amprt.h:2462
bool _Overlaps(const _View_shape *_Other) const
Definition: amprt.h:1780
std::vector< unsigned int > _Src_copy_offset
Definition: amprt.h:3056
unsigned int _Get_view_size() const
Definition: amprt.h:1712
unsigned int _Dst_linear_offset
Definition: amprt.h:3059
struct Concurrency::details::_Sampler_descriptor _Sampler_descriptor
_AMPIMP _View_shape_ptr _Get_view_shape(_In_ _View_key _Key)
_Reference_counted_obj_ptr & operator=(_Reference_counted_obj_ptr &&_Other)
Definition: amprt.h:210
_Ret_ _Accelerator_view_impl * _Get_access_on_accelerator_view_impl() const
Definition: amprt.h:2115
#define __CPU_ONLY
Definition: amprt.h:43
IUnknown * _M_data_ptr
Definition: amprt.h:553
BOOL _Is_buffer() const
Definition: amprt.h:3593
_Accelerator_view_impl_ptr _M_impl
Definition: amprt.h:1626
const float * _Get_border_color() const
Definition: amprt.h:2483
static _AMPIMP const wchar_t default_accelerator[]
String constant for default accelerator
Definition: amprt.h:1106
bool _M_is_adopted
Definition: amprt.h:2504
bool _M_is_staging
Definition: amprt.h:2214
_Ret_ _Buffer_descriptor * _Get_buffer_desc() const
Definition: amprt.h:3608
size_t _M_height
Definition: amprt.h:2433
_Array_copy_desc(const unsigned int _Rank, const unsigned int _Src_linear_offset, const unsigned int *_Src_extents, const unsigned int *_Src_copy_offset, const unsigned int _Dst_linear_offset, const unsigned int *_Dst_extents, const unsigned int *_Dst_copy_offset, const unsigned int *_Copy_extents)
Definition: amprt.h:3026
~_Reference_counted_obj_ptr()
Definition: amprt.h:186
void _Copy_data_on_host(int _Rank, const _Value_type *_Src, _Output_iterator _Dst, size_t _Width, size_t _Height, size_t _Depth, size_t _Src_row_pitch_in_bytes, size_t _Src_depth_pitch_in_bytes, size_t _Dst_row_pitch, size_t _Dst_depth_pitch)
Definition: amprt.h:2627
Exception thrown due to a C++ AMP runtime_exception. This is the base type for all C++ AMP exception ...
Definition: amprt.h:835
std::unordered_map< _View_key, _View_info * > _M_view_map
Definition: amprt.h:3430
_AMPIMP void HELPERAPI __dpc_set_kernel_shader_info(_In_ _DPC_call_handle *_Handle, _Inout_ void **_ShaderBlobs)
bool _Is_buffer() const
Definition: amprt.h:2163
_Buffer_descriptor * _View_key
Definition: amprt.h:404
void wait() const
Blocks until the associated asynchronous operation completes
Definition: amprt.h:1431
_AMPIMP size_t get_dedicated_memory() const
Get the dedicated memory for this accelerator in KB
struct Concurrency::details::_Buffer_descriptor _Buffer_descriptor
_AMPIMP accelerator_view get_default_view() const
Return the default accelerator view associated with this accelerator
_Ret_ void * _Get_host_ptr() const
Definition: amprt.h:2095
_AMPIMP accelerator __cdecl _Select_default_accelerator()
unsigned int _Get_linear_offset() const
Definition: amprt.h:1672
_AMPIMP void __cdecl d3d_access_lock(accelerator_view &_Av)
Acquire a lock on an accelerator_view for the purpose of safely performing D3D operations on resource...
unsigned int _M_compute_rank
Definition: amprt.h:3693
The Parallel Patterns Library (PPL) task class. A task object represents work that can be executed as...
Definition: ppltasks.h:4120
std::unordered_set< accelerator_view, _Accelerator_view_hasher > _Accelerator_view_unordered_set
Definition: amprt.h:1654
#define HELPERAPI
Definition: amprt.h:3565
bool _Are_mipmap_levels_overlapping(const _Texture_descriptor *_Other) const __CPU_ONLY
Definition: amprt.h:694
size_t _Get_master_buffer_num_elems() const
Definition: amprt.h:3315
_AMPIMP bool set_default_cpu_access_type(access_type _Default_cpu_access_type)
Set the default cpu access_type for arrays created on this accelerator or for implicit memory allocat...
std::map< _Accelerator_view_impl_ptr, _Buffer_ptr > _M_buffer_map
Definition: amprt.h:3426
_AMPIMP void _Get_CPU_access(_Access_mode _Requested_mode) const
_Access_mode _M_current_host_access_mode
Definition: amprt.h:2210
_Accelerator_impl_ptr _M_impl
Definition: amprt.h:1336
details::_Reference_counted_obj_ptr< details::_Event_impl > _Event_impl_ptr
Definition: amprt.h:306
unsigned int _Get_data_length(unsigned int _Most_detailed_mipmap_level, unsigned int _View_mipmap_levels, const size_t *_Extents=nullptr) const
Definition: amprt.h:2332
size_t _M_actual_arg_num
Definition: amprt.h:3591
_Ret_ _Ubiquitous_buffer * _Get_buffer(const _Array_type &_Array) __CPU_ONLY
Definition: xxamp.h:1070
size_t _M_width
Definition: amprt.h:2432
unsigned int _M_groupCountX
Definition: amprt.h:3697
_Reference_counted_obj_ptr(_Reference_counted_obj_ptr &&_Other)
Definition: amprt.h:179
_Sampler_descriptor() __GPU
Definition: amprt.h:728
_Ret_ _Sampler * _Get_sampler_ptr() const __CPU_ONLY
Definition: amprt.h:775
_Reference_counter()
Definition: amprt.h:120
unsigned int _Get_mipmap_levels(const _Texture *_Tex)
Definition: amprt.h:4068
_Sampler_descriptor(_In_ _Sampler *_Sampler_ptr) __GPU
Definition: amprt.h:733
#define false
Definition: stdbool.h:11
_AMPIMP ULONG _Start_async_op_wait_event(ULONG _Async_op_id)
_Ret_ _View_key _Get_view_key()
Definition: amprt.h:532
_Access_mode _M_type_access_mode
Definition: amprt.h:449
void _Set_data_ptr(_In_ IUnknown *_Data_ptr)
Definition: amprt.h:2199
_AMPIMP access_type get_default_cpu_access_type() const
Get the default cpu access_type for buffers created on this accelerator
unsigned int _M_rank
Definition: amprt.h:1950
_AMPIMP void __cdecl d3d_access_unlock(accelerator_view &_Av)
Release the D3D access lock on the given accelerator_view. If the calling thread does not hold the lo...
bool _Is_valid() const
Definition: amprt.h:1886
unsigned int _M_groupExtentX
Definition: amprt.h:3702
void * _M_data_ptr
Definition: amprt.h:715
Concurrency::critical_section _M_critical_section
Definition: amprt.h:2224
friend _Event _Get_access_async(const _View_key _Key, accelerator_view _Av, _Access_mode _Mode, _Buffer_ptr &_Buf_ptr)
Definition: amprt.h:3457
_AMPIMP void _Init(const wchar_t *_Path)
unsigned int _Get_rank() const
Definition: amprt.h:2301
size_t _Get_depth_pitch() const
Definition: amprt.h:2397
~_Texture_descriptor() __GPU
Definition: amprt.h:598
_CRTIMP void __cdecl wait(unsigned int _Milliseconds)
Pauses the current context for a specified amount of time.
completion_future & operator=(completion_future &&_Other)
Move assignment operator
Definition: amprt.h:1395
unsigned int * _M_view_offset
Definition: amprt.h:1953
~_Buffer_descriptor() __GPU
Definition: amprt.h:470
_Device_resource_info * _M_device_resource_info
Definition: amprt.h:3677
_AMPIMP size_t __cdecl _Get_preferred_copy_chunk_size(size_t _Total_copy_size_in_bytes)
void * _M_data_ptr
Definition: amprt.h:432
bool _Is_projection() const
Definition: amprt.h:1696
_Ret_ _View_shape * _Get_buffer_view_shape(const _Buffer_descriptor &_Descriptor)
Definition: amprt.h:3463
unsigned int _Get_linear_offset(const unsigned int *_Element_index) const
Definition: amprt.h:1935
std::vector< std::tuple< PVOID, LPCWSTR, LPCWSTR > > _M_accelerator_configs
Definition: amprt.h:4055
_AMPIMP void HELPERAPI __dpc_dispatch_kernel(_In_ _DPC_call_handle *_Handle)
_Access_mode
Definition: amprt.h:82
_AMPIMP _Event & operator=(const _Event &_Other)
Assignment operator
static bool set_default(const std::wstring &_Path)
Sets the default accelerator to be used for any operation that implicitly uses the default accelerato...
Definition: amprt.h:1181
basic_string< wchar_t, char_traits< wchar_t >, allocator< wchar_t > > wstring
Definition: xstring:2645
bool operator==(const _Texture_descriptor &_Other) const __GPU
Definition: amprt.h:639
_AMPIMP void HELPERAPI __dpc_set_const_buffer_info(_In_ _DPC_call_handle *_Handle, _In_ _Device_const_buffer_info *_DeviceConstBufferInfo, size_t _NumConstBuffers)
bool _Is_adopted() const
Definition: amprt.h:2467
std::vector< unsigned int > _Dst_extents
Definition: amprt.h:3060
size_t _Get_height(unsigned int _Mip_offset=0) const
Definition: amprt.h:2291
void _Set_view_mipmap_levels(unsigned int _View_mipmap_levels) __CPU_ONLY
Definition: amprt.h:663
unsigned int _M_texture_format
Definition: amprt.h:2435
_AMPIMP void HELPERAPI __dpc_set_device_resource_info(_In_ _DPC_call_handle *_Handle, _In_ _Device_resource_info *_DeviceResourceInfo, size_t _NumResources)
_Array_copy_desc()
Definition: amprt.h:3049
_Device_const_buffer_info * _M_const_buffer_info
Definition: amprt.h:3683
_DPC_call_handle(const accelerator_view &_Accelerator_view)
Definition: amprt.h:3706
void _Set_texture_ptr(_In_opt_ _Texture *_Texture_ptr) __CPU_ONLY
Definition: amprt.h:668
#define _AMPIMP
Definition: amprt.h:73
__declspec(property(get=get_device_path)) std _AMPIMP unsigned int get_version() const
Get the version for this accelerator
concurrency::task< void > to_task() const
Returns a concurrency::task object corresponding to the associated asynchronous operation ...
Definition: amprt.h:1497
void swap(array< _Ty, _Size > &_Left, array< _Ty, _Size > &_Right) _NOEXCEPT_OP(_NOEXCEPT_OP(_Left.swap(_Right)))
Definition: array:429
void advance(_InIt &_Where, _Diff _Off)
Definition: xutility:695
future_status
Definition: future:97
static unsigned int _Get_extent_size(unsigned int _Rank, const unsigned int *_Extent)
Definition: amprt.h:1876
T & operator*() const
Definition: amprt.h:232
#define _Out_writes_(size)
Definition: sal.h:354
static bool _Intervals_overlap(size_t _First_start, size_t _First_end, size_t _Second_start, size_t _Second_end)
Definition: amprt.h:1858
#define _T(x)
Definition: tchar.h:2498
Exception thrown when an underlying DirectX call fails due to the Windows timeout detection and recov...
Definition: amprt.h:3480
virtual ~_Reference_counter()
Definition: amprt.h:123
unsigned int _Get_view_linear_offset() const
Definition: amprt.h:1717
access_type _Get_allowed_host_access_type() const
Definition: amprt.h:2137
_AMPIMP _Event()
Constructor of the _Event.
int _M_is_flat_model
Definition: amprt.h:3692
unsigned int _M_groupCountY
Definition: amprt.h:3698
_AMPIMP void HELPERAPI __dpc_release_call_handle(_In_ _DPC_call_handle *_Handle)
unsigned int _M_num_channels
Definition: amprt.h:2438
queuing_mode
Queuing modes supported for accelerator views
Definition: amprt.h:826
_Ret_ _Sampler_descriptor * _Get_sampler_desc() const
Definition: amprt.h:3620
unsigned int _Src_linear_offset
Definition: amprt.h:3054
_Resource_kind
Definition: amprt.h:3572
_Buffer_descriptor(const _Buffer_descriptor &_Other) __GPU
Definition: amprt.h:476
unsigned int _M_most_detailed_mipmap_level
Definition: amprt.h:564
bool _Is_array() const
Definition: amprt.h:527
details::_Reference_counted_obj_ptr< details::_Sampler > _Sampler_ptr
Definition: amprt.h:304
_Check_return_ _In_z_ _Scanf_format_string_ const char * _Format
Definition: stdio.h:230
size_t _M_const_buf_size
Definition: amprt.h:3653
_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
size_t _M_num_samplers
Definition: amprt.h:3680
_Accelerator_view_impl * _M_rv
Definition: amprt.h:3673
bool valid() const
Returns true if the object is associated with an asynchronous operation
Definition: amprt.h:1423
~_Sampler_descriptor() __GPU
Definition: amprt.h:740
_Accelerator_view_impl_ptr _M_impl
Definition: amprt.h:1082
_Ret_ _Accelerator_impl * _Get_accelerator_impl_ptr(const accelerator &_Accl)
Definition: amprt.h:1637
friend class accelerator_view
Definition: amprt.h:1091
_AMPIMP const wchar_t * _Get_device_path() const
_AMPIMP void HELPERAPI __dpc_set_kernel_dispatch_info(_In_ _DPC_call_handle *_Handle, unsigned int _ComputeRank, _In_ int *_Extents, unsigned int _GroupRank, const unsigned int *_GroupExtents, unsigned int &_GroupCountX, unsigned int &_GroupCountY, unsigned int &_GroupCountZ)
#define _Inout_
Definition: sal.h:384
Concurrency::critical_section _M_critical_section
Definition: amprt.h:3442
_AMPIMP bool get_supports_double_precision() const
Returns a boolean value indicating whether the accelerator supports full double precision (including ...
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...
size_t _M_depth_pitch
Definition: amprt.h:2442
_Ret_ _Texture * _Get_texture_ptr() const __CPU_ONLY
Definition: amprt.h:647
_Ret_ _Ubiquitous_buffer * _Get_buffer_ptr() const __CPU_ONLY
Definition: amprt.h:497
std::enable_if<!std::is_base_of< std::input_iterator_tag, typename std::iterator_traits< _OutputIterator >::iterator_category >::value >::type _Advance_output_iterator(_OutputIterator &_Iter, size_t _N)
Definition: amprt.h:2891
static void _UnInitialize(_In_ T *_Obj_ptr)
Definition: amprt.h:258
bool _M_is_explicit_target_acclview
Definition: amprt.h:3674
_Access_mode _Get_synchronize_access_mode(access_type cpu_access_type)
Definition: amprt.h:2003
const _View_key _Get_view_key() const
Definition: amprt.h:537
_Resource_kind _M_resource_kind
Definition: amprt.h:3581
_Texture_descriptor(unsigned int _Most_detailed_mipmap_level, unsigned int _View_mipmap_levels) __GPU
Definition: amprt.h:583
completion_future(const completion_future &_Other)
Copy constructor
Definition: amprt.h:1357
bool _Is_temp() const
Definition: amprt.h:2152
size_t _M_num_const_buffers
Definition: amprt.h:3684
size_t _M_num_elems
Definition: amprt.h:2212
bool _M_is_adopted
Definition: amprt.h:2219
~completion_future()
Destructor
Definition: amprt.h:1375
Class represents a accelerator abstraction for C++ AMP data-parallel devices
Definition: amprt.h:1089
_Access_mode _Get_current_host_access_mode() const
Definition: amprt.h:2147
_Texture_descriptor() __GPU
Definition: amprt.h:576
BOOL _Is_texture() const
Definition: amprt.h:3598
_Buffer * _M_master_buffer
Definition: amprt.h:3412
size_t _Remove_reference()
Definition: amprt.h:134
_Texture * _M_texture_ptr
Definition: amprt.h:560
void _Set_host_ptr(_In_ void *_Host_ptr, _Access_mode _Host_access_mode=_No_access)
Definition: amprt.h:2186
future< typename result_of< typename enable_if<!_Is_launch_type< typename decay< _Fty >::type >::value, _Fty >::type(_ArgTypes...)>::type > async(_Fty &&_Fnarg, _ArgTypes &&..._Args)
Definition: future:1893
std::unique_ptr< std::vector< int > > _M_Redirect_indices
Definition: amprt.h:3795
_AMPIMP size_t __cdecl _Get_num_devices()
size_t _Add_reference()
Definition: amprt.h:127
std::unique_ptr< std::unordered_set< void * > > _M_aliased_buffer_set
Definition: amprt.h:3792
_Texture_descriptor & operator=(const _Texture_descriptor &_Other) __GPU
Definition: amprt.h:620
Concurrency::critical_section _M_critical_section
Definition: amprt.h:4052
Exception thrown when an unsupported feature is used
Definition: amprt.h:3540
size_t _M_elem_size
Definition: amprt.h:2211
bool _Has_data_source() const
Definition: amprt.h:3320
void _Set_sampler_ptr(_In_opt_ _Sampler *_Sampler_ptr) __CPU_ONLY
Definition: amprt.h:780
_AMPIMP accelerator_view create_view(queuing_mode qmode=queuing_mode_automatic)
Create and return a new accelerator view on this accelerator with the specified queuing mode...
#define __GPU_ONLY
Definition: amprt.h:42
bool _M_is_buffer
Definition: amprt.h:2220
_AMPIMP HRESULT __cdecl _Recursive_array_copy(const _Array_copy_desc &_Desc, unsigned int _Native_copy_rank, std::function< HRESULT(const _Array_copy_desc &_Reduced)> _Native_copy_func)
size_t _Get_width(unsigned int _Mip_offset=0) const
Definition: amprt.h:2286
bool _Is_staging() const
Definition: amprt.h:2127
_FwdIt const _Ty _Val
Definition: algorithm:1938
bool set() const
Sets the task completion event.
Definition: ppltasks.h:2899
bool _Is_view_linear(unsigned int &_Linear_offset, unsigned int &_Linear_size) const
Definition: amprt.h:1755
_Sampler * _M_sampler_ptr
Definition: amprt.h:722
concurrency::task< void > _M_task
Definition: amprt.h:1512
bool _Is_cpu_accelerator(const accelerator &_Accl)
Definition: amprt.h:3469
bool _Is_valid(size_t _Buffer_size) const
Definition: amprt.h:1701
struct Concurrency::details::_Texture_descriptor _Texture_descriptor
void * _M_host_ptr
Definition: amprt.h:2208
unsigned int _Get_filter_mode() const
Definition: amprt.h:2473
unsigned int _M_address_mode
Definition: amprt.h:2506
_Access_mode _M_formal_access_mode
Definition: amprt.h:3586
_Reference_counted_obj_ptr(T *_Ptr=NULL)
Definition: amprt.h:167
unsigned int _Get_bits_per_channel() const
Definition: amprt.h:2321
static bool _Compare_extent_with_elem_size(unsigned int _Rank, const unsigned int *_Extent1, size_t _Elem_size1, const unsigned int *_Extent2, size_t _Elem_size2)
Definition: amprt.h:1723
void * _M_desc
Definition: amprt.h:3583
unsigned int _M_view_format
Definition: amprt.h:2436
const int * _Get_redirect_indices() const
Definition: amprt.h:3774
_Access_mode _M_allowed_host_access_mode
Definition: amprt.h:2209
_AMPIMP ~accelerator()
Destructor
__declspec(property(get=get_description)) std _AMPIMP bool get_is_debug() const
Returns a boolean value indicating whether the accelerator was created with DEBUG layer enabled for e...
_AMPIMP bool operator!=(const _Event &_Other) const
Return false if the other _Event is same as this _Event; true otherwise
unsigned int * _M_grid_extents
Definition: amprt.h:3694
_T _Least_common_multiple(_T _M, _T _N)
Definition: amprt.h:2755
friend _Event _Get_access_async(const _View_key _Key, accelerator_view _Av, _Access_mode _Mode, _Buffer_ptr &_Buf_ptr)
Definition: amprt.h:3457
void _Set_buffer_unaccessed(size_t _Buffer_idx)
Definition: amprt.h:3765
size_t _Get_preferred_copy_chunk_num_elems(size_t _Total_num_elems, size_t _Elem_size)
Definition: amprt.h:2686
_AMPIMP void _Write_end_event(ULONG _Span_id)
unsigned int _Get_rank() const
Definition: amprt.h:1667
#define _Ret_
Definition: sal.h:1005
_Texture_descriptor(const _Texture_descriptor &_Other, unsigned int _Most_detailed_mipmap_level, unsigned int _View_mipmap_levels) __GPU
Definition: amprt.h:612
_Access_mode _Get_allowed_host_access_mode() const
Definition: amprt.h:2132
concurrency::completion_future _Start_async_op_wait_event_helper(ULONG _Async_op_id, _Event _Ev)
Definition: amprt.h:3912
bool * _M_projection_info
Definition: amprt.h:1955
access_type
Enumeration type used to denote the various types of access to data.
Definition: amprt.h:97
void * _M_data_ptr
Definition: amprt.h:2207
Exception thrown when the runtime fails to launch a kernel using the compute domain specified at the ...
Definition: amprt.h:3520
size_t _M_master_buffer_elem_size
Definition: amprt.h:3415
_AMPIMP runtime_exception & operator=(const runtime_exception &_Other)
Assignment operator
HRESULT _M_view_removed_reason_code
Definition: amprt.h:3513
_AMPIMP void __cdecl _Register_async_event(const _Event &_Ev, const std::shared_future< void > &_Shared_future)
_AMPIMP bool _Is_finished_nothrow()
Poll whether the _Event has completed or not. Swallows any exceptions
_Ret_ _Accelerator_view_impl * _Get_master_accelerator_view_impl() const
Definition: amprt.h:3305
completion_future(const std::shared_future< void > &_Shared_future, const concurrency::task< void > &_Task)
Definition: amprt.h:1505