STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
Concurrency::details::_View_shape Class Reference

#include <amprt.h>

Inheritance diagram for Concurrency::details::_View_shape:
Concurrency::details::_Reference_counter

Public Member Functions

_AMPIMP _Ret_ _View_shape_Get_reduced_shape_for_copy ()
 
unsigned int _Get_rank () const
 
unsigned int _Get_linear_offset () const
 
const unsigned int_Get_base_extent () const
 
const unsigned int_Get_view_offset () const
 
const unsigned int_Get_view_extent () const
 
const bool_Get_projection_info () const
 
bool _Is_projection () const
 
bool _Is_valid (size_t _Buffer_size) const
 
unsigned int _Get_view_size () const
 
unsigned int _Get_view_linear_offset () const
 
bool _Is_view_linear (unsigned int &_Linear_offset, unsigned int &_Linear_size) const
 
bool _Overlaps (const _View_shape *_Other) const
 
bool _Subsumes (const _View_shape *_Other) const
 
- Public Member Functions inherited from Concurrency::details::_Reference_counter
 _Reference_counter ()
 
virtual ~_Reference_counter () noexcept(false)
 
size_t _Add_reference ()
 
size_t _Remove_reference ()
 
_AMPIMP void _Release ()
 
size_t _Get_reference_count ()
 

Static Public Member Functions

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)
 
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)
 
static bool _Compare_extent (unsigned int _Rank, const unsigned int *_Extent1, const unsigned int *_Extent2)
 

Private Member Functions

 _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)
 
virtual ~_View_shape ()
 
 _View_shape ()
 
 _View_shape (const _View_shape &_Other)
 
 _View_shape (_View_shape &&_Other)
 
_View_shapeoperator= (const _View_shape &_Other)
 
_View_shapeoperator= (_View_shape &&_Other)
 
bool _Is_valid () const
 
bool _Compare_base_shape (const _View_shape *_Other) const
 
bool _Contains (const unsigned int *_Element_index) const
 
unsigned int _Get_linear_offset (const unsigned int *_Element_index) const
 

Static Private Member Functions

static bool _Intervals_overlap (size_t _First_start, size_t _First_end, size_t _Second_start, size_t _Second_end)
 
static unsigned int _Get_extent_size (unsigned int _Rank, const unsigned int *_Extent)
 

Private Attributes

unsigned int _M_rank
 
unsigned int _M_linear_offset
 
unsigned int_M_base_extent
 
unsigned int_M_view_offset
 
unsigned int_M_view_extent
 
bool_M_projection_info
 

Constructor & Destructor Documentation

Concurrency::details::_View_shape::_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 
)
private
virtual Concurrency::details::_View_shape::~_View_shape ( )
privatevirtual
Concurrency::details::_View_shape::_View_shape ( )
private
Concurrency::details::_View_shape::_View_shape ( const _View_shape _Other)
private
Concurrency::details::_View_shape::_View_shape ( _View_shape &&  _Other)
private

Member Function Documentation

bool Concurrency::details::_View_shape::_Compare_base_shape ( const _View_shape _Other) const
inlineprivate
1835  {
1836  return ((_M_rank == _Other->_M_rank) &&
1837  (_M_linear_offset == _Other->_M_linear_offset) &&
1839  }
unsigned int _M_linear_offset
Definition: amprt.h:1875
static bool _Compare_extent(unsigned int _Rank, const unsigned int *_Extent1, const unsigned int *_Extent2)
Definition: amprt.h:1668
unsigned int * _M_base_extent
Definition: amprt.h:1876
unsigned int _M_rank
Definition: amprt.h:1874
static bool Concurrency::details::_View_shape::_Compare_extent ( unsigned int  _Rank,
const unsigned int _Extent1,
const unsigned int _Extent2 
)
inlinestatic
1669  {
1670  for (size_t _I = 0; _I < _Rank; ++_I) {
1671  if (_Extent1[_I] != _Extent2[_I]) {
1672  return false;
1673  }
1674  }
1675 
1676  return true;
1677  }
static bool Concurrency::details::_View_shape::_Compare_extent_with_elem_size ( unsigned int  _Rank,
const unsigned int _Extent1,
size_t  _Elem_size1,
const unsigned int _Extent2,
size_t  _Elem_size2 
)
inlinestatic
1648  {
1649  _ASSERTE((_Rank >= 1) && (_Extent1 != NULL)&& (_Extent2 != NULL));
1650 
1651  // The extents should match accounting for the element sizes of the respective buffers
1652  if ((_Extent1[_Rank - 1] * _Elem_size1) != (_Extent2[_Rank - 1] * _Elem_size2))
1653  {
1654  return false;
1655  }
1656 
1657  // Now compare the extent in all but the least significant dimension
1658  if ((_Rank > 1) && !_Compare_extent(_Rank - 1, _Extent1, _Extent2))
1659  {
1660  return false;
1661  }
1662 
1663  return true;
1664  }
static bool _Compare_extent(unsigned int _Rank, const unsigned int *_Extent1, const unsigned int *_Extent2)
Definition: amprt.h:1668
#define _ASSERTE(expr)
Definition: crtdbg.h:707
#define NULL
Definition: corecrt.h:158
bool Concurrency::details::_View_shape::_Contains ( const unsigned int _Element_index) const
inlineprivate
1846  {
1847  for (size_t _I = 0; _I < _M_rank; ++_I)
1848  {
1849  if ((_Element_index[_I] < _M_view_offset[_I]) ||
1850  (_Element_index[_I] >= (_M_view_offset[_I] + _M_view_extent[_I])))
1851  {
1852  return false;
1853  }
1854  }
1855 
1856  return true;
1857  }
unsigned int * _M_view_extent
Definition: amprt.h:1878
unsigned int _M_rank
Definition: amprt.h:1874
unsigned int * _M_view_offset
Definition: amprt.h:1877
static _AMPIMP _Ret_ _View_shape* __cdecl Concurrency::details::_View_shape::_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 
)
static
const unsigned int* Concurrency::details::_View_shape::_Get_base_extent ( ) const
inline
1602  {
1603  return _M_base_extent;
1604  }
unsigned int * _M_base_extent
Definition: amprt.h:1876
static unsigned int Concurrency::details::_View_shape::_Get_extent_size ( unsigned int  _Rank,
const unsigned int _Extent 
)
inlinestaticprivate
1801  {
1802  unsigned int totalExtent = 1;
1803  for (size_t _I = 0; _I < _Rank; ++_I) {
1804  totalExtent *= _Extent[_I];
1805  }
1806 
1807  return totalExtent;
1808  }
Definition: type_traits:1021
unsigned int Concurrency::details::_View_shape::_Get_linear_offset ( ) const
inline
1597  {
1598  return _M_linear_offset;
1599  }
unsigned int _M_linear_offset
Definition: amprt.h:1875
unsigned int Concurrency::details::_View_shape::_Get_linear_offset ( const unsigned int _Element_index) const
inlineprivate
1860  {
1861  unsigned int currMultiplier = 1;
1862  unsigned int linearOffset = _M_linear_offset;
1863  for (int _I = static_cast<int>(_M_rank - 1); _I >= 0; _I--)
1864  {
1865  linearOffset += (currMultiplier * _Element_index[_I]);
1866  currMultiplier *= _M_base_extent[_I];
1867  }
1868 
1869  return linearOffset;
1870  }
unsigned int _M_linear_offset
Definition: amprt.h:1875
unsigned int * _M_base_extent
Definition: amprt.h:1876
unsigned int _M_rank
Definition: amprt.h:1874
const bool* Concurrency::details::_View_shape::_Get_projection_info ( ) const
inline
1616  {
1617  return _M_projection_info;
1618  }
bool * _M_projection_info
Definition: amprt.h:1879
unsigned int Concurrency::details::_View_shape::_Get_rank ( ) const
inline
1592  {
1593  return _M_rank;
1594  }
unsigned int _M_rank
Definition: amprt.h:1874
_AMPIMP _Ret_ _View_shape* Concurrency::details::_View_shape::_Get_reduced_shape_for_copy ( )
const unsigned int* Concurrency::details::_View_shape::_Get_view_extent ( ) const
inline
1611  {
1612  return _M_view_extent;
1613  }
unsigned int * _M_view_extent
Definition: amprt.h:1878
unsigned int Concurrency::details::_View_shape::_Get_view_linear_offset ( ) const
inline
1642  {
1644  }
unsigned int _Get_linear_offset() const
Definition: amprt.h:1596
unsigned int * _M_view_offset
Definition: amprt.h:1877
const unsigned int* Concurrency::details::_View_shape::_Get_view_offset ( ) const
inline
1607  {
1608  return _M_view_offset;
1609  }
unsigned int * _M_view_offset
Definition: amprt.h:1877
unsigned int Concurrency::details::_View_shape::_Get_view_size ( ) const
inline
1637  {
1639  }
unsigned int * _M_view_extent
Definition: amprt.h:1878
unsigned int _M_rank
Definition: amprt.h:1874
static unsigned int _Get_extent_size(unsigned int _Rank, const unsigned int *_Extent)
Definition: amprt.h:1800
static bool Concurrency::details::_View_shape::_Intervals_overlap ( size_t  _First_start,
size_t  _First_end,
size_t  _Second_start,
size_t  _Second_end 
)
inlinestaticprivate
1784  {
1785  // Order the intervals by their start points
1786  if (_First_start > _Second_start) {
1787  size_t temp = _First_start;
1788  _First_start = _Second_start;
1789  _Second_start = temp;
1790 
1791  temp = _First_end;
1792  _First_end = _Second_end;
1793  _Second_end = temp;
1794  }
1795 
1796  // The start of the second one must be within the bounds of the first one
1797  return (_Second_start <= _First_end);
1798  }
bool Concurrency::details::_View_shape::_Is_projection ( ) const
inline
1621  {
1622  return _M_projection_info[0];
1623  }
bool * _M_projection_info
Definition: amprt.h:1879
bool Concurrency::details::_View_shape::_Is_valid ( size_t  _Buffer_size) const
inline
1626  {
1627  // The end point of the base shape should not be greater than the size of the buffer
1628  size_t endLinearOffset = _M_linear_offset + _Get_extent_size(_M_rank, _M_base_extent);
1629  if (endLinearOffset > _Buffer_size) {
1630  return false;
1631  }
1632 
1633  return _Is_valid();
1634  }
unsigned int _M_linear_offset
Definition: amprt.h:1875
unsigned int * _M_base_extent
Definition: amprt.h:1876
unsigned int _M_rank
Definition: amprt.h:1874
bool _Is_valid() const
Definition: amprt.h:1810
static unsigned int _Get_extent_size(unsigned int _Rank, const unsigned int *_Extent)
Definition: amprt.h:1800
bool Concurrency::details::_View_shape::_Is_valid ( ) const
inlineprivate
1811  {
1812  if (_M_rank == 0) {
1813  return false;
1814  }
1815 
1816  // Ensure the _M_view_offset + _M_view_extent is within the bounds of _M_base_extent
1817  size_t viewSize = 1;
1818 
1819  for (size_t _I = 0; _I < _M_rank; ++_I)
1820  {
1821  viewSize *= _M_view_extent[_I];
1822  if ((_M_view_offset[_I] + _M_view_extent[_I]) > _M_base_extent[_I]) {
1823  return false;
1824  }
1825  }
1826 
1827  if (viewSize == 0) {
1828  return false;
1829  }
1830 
1831  return true;
1832  }
unsigned int * _M_view_extent
Definition: amprt.h:1878
unsigned int * _M_base_extent
Definition: amprt.h:1876
unsigned int _M_rank
Definition: amprt.h:1874
unsigned int * _M_view_offset
Definition: amprt.h:1877
bool Concurrency::details::_View_shape::_Is_view_linear ( unsigned int _Linear_offset,
unsigned int _Linear_size 
) const
inline
1680  {
1681  // The effective rank for the purpose of determining linearity
1682  // depends on the highest dimension in which the extent is not 1
1683  unsigned int _First_dim_with_non_unit_extent = 0;
1684  while ((_First_dim_with_non_unit_extent < _M_rank) && (_M_view_extent[_First_dim_with_non_unit_extent] == 1)) {
1685  _First_dim_with_non_unit_extent++;
1686  }
1687 
1688  unsigned int _Effective_rank = (_M_rank - _First_dim_with_non_unit_extent);
1689 
1690  // It is linear if the effective rank is <= 1 or the base extent
1691  // and view extent are same in all but the highest dimension with
1692  // non-unit extent
1693  if ((_Effective_rank <= 1) ||
1694  (_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])))
1695  {
1696  _Linear_offset = _Get_view_linear_offset();
1697  _Linear_size = _Get_view_size();
1698  return true;
1699  }
1700 
1701  return false;
1702  }
unsigned int * _M_view_extent
Definition: amprt.h:1878
static bool _Compare_extent(unsigned int _Rank, const unsigned int *_Extent1, const unsigned int *_Extent2)
Definition: amprt.h:1668
unsigned int * _M_base_extent
Definition: amprt.h:1876
unsigned int _Get_view_size() const
Definition: amprt.h:1636
unsigned int _M_rank
Definition: amprt.h:1874
unsigned int _Get_view_linear_offset() const
Definition: amprt.h:1641
bool Concurrency::details::_View_shape::_Overlaps ( const _View_shape _Other) const
inline
1705  {
1706  if (_Compare_base_shape(_Other))
1707  {
1708  // If the base shapes are identical we will do the N-dimensional
1709  // bounding box overlap test
1710 
1711  for (size_t _I = 0; _I < _M_rank; ++_I)
1712  {
1714  _Other->_M_view_offset[_I], _Other->_M_view_offset[_I] + _Other->_M_view_extent[_I] - 1))
1715  {
1716  return false;
1717  }
1718  }
1719 
1720  return true;
1721  }
1722  else
1723  {
1724  // The base shapes are different. Check based on linear intervals
1725  size_t firstStart = _Get_view_linear_offset();
1726  size_t firstEnd = firstStart + _Get_view_size() - 1;
1727 
1728  size_t secondStart = _Other->_Get_view_linear_offset();
1729  size_t secondEnd = secondStart + _Other->_Get_view_size() - 1;
1730 
1731  return _Intervals_overlap(firstStart, firstEnd, secondStart, secondEnd);
1732  }
1733  }
unsigned int * _M_view_extent
Definition: amprt.h:1878
bool _Compare_base_shape(const _View_shape *_Other) const
Definition: amprt.h:1834
unsigned int _Get_view_size() const
Definition: amprt.h:1636
unsigned int _M_rank
Definition: amprt.h:1874
unsigned int * _M_view_offset
Definition: amprt.h:1877
static bool _Intervals_overlap(size_t _First_start, size_t _First_end, size_t _Second_start, size_t _Second_end)
Definition: amprt.h:1782
unsigned int _Get_view_linear_offset() const
Definition: amprt.h:1641
bool Concurrency::details::_View_shape::_Subsumes ( const _View_shape _Other) const
inline
1736  {
1737  // Subsumption test can only be done for shapes that have the same base shape or
1738  // when both have a rank of 1
1739  if ((_M_rank == 1) && (_Other->_Get_rank() == 1))
1740  {
1741  size_t thisStart = _Get_view_linear_offset();
1742  size_t thisEnd = thisStart + _Get_view_size() - 1;
1743 
1744  size_t otherStart = _Other->_Get_view_linear_offset();
1745  size_t otherEnd = otherStart + _Other->_Get_view_size() - 1;
1746 
1747  return ((otherStart >= thisStart) && (otherEnd <= thisEnd));
1748  }
1749 
1750  if (!_Compare_base_shape(_Other)) {
1751  return false;
1752  }
1753 
1754  if (!_Contains(_Other->_Get_view_offset())) {
1755  return false;
1756  }
1757 
1758  std::vector<unsigned int> otherEndPointIndex(_M_rank);
1759  for (size_t _I = 0; _I < _M_rank; ++_I) {
1760  otherEndPointIndex[_I] = _Other->_Get_view_offset()[_I] + _Other->_Get_view_extent()[_I] - 1;
1761  }
1762 
1763  return _Contains(otherEndPointIndex.data());
1764  }
const unsigned int * _Get_view_offset() const
Definition: amprt.h:1606
bool _Compare_base_shape(const _View_shape *_Other) const
Definition: amprt.h:1834
const unsigned int * _Get_view_extent() const
Definition: amprt.h:1610
bool _Contains(const unsigned int *_Element_index) const
Definition: amprt.h:1845
unsigned int _Get_view_size() const
Definition: amprt.h:1636
unsigned int _M_rank
Definition: amprt.h:1874
unsigned int _Get_view_linear_offset() const
Definition: amprt.h:1641
unsigned int _Get_rank() const
Definition: amprt.h:1591
_View_shape& Concurrency::details::_View_shape::operator= ( const _View_shape _Other)
private
_View_shape& Concurrency::details::_View_shape::operator= ( _View_shape &&  _Other)
private

Member Data Documentation

unsigned int* Concurrency::details::_View_shape::_M_base_extent
private
unsigned int Concurrency::details::_View_shape::_M_linear_offset
private
bool* Concurrency::details::_View_shape::_M_projection_info
private
unsigned int Concurrency::details::_View_shape::_M_rank
private
unsigned int* Concurrency::details::_View_shape::_M_view_extent
private
unsigned int* Concurrency::details::_View_shape::_M_view_offset
private

The documentation for this class was generated from the following file: