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 ()
 
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
1911  {
1912  return ((_M_rank == _Other->_M_rank) &&
1913  (_M_linear_offset == _Other->_M_linear_offset) &&
1915  }
unsigned int _M_linear_offset
Definition: amprt.h:1951
static bool _Compare_extent(unsigned int _Rank, const unsigned int *_Extent1, const unsigned int *_Extent2)
Definition: amprt.h:1744
unsigned int * _M_base_extent
Definition: amprt.h:1952
unsigned int _M_rank
Definition: amprt.h:1950
static bool Concurrency::details::_View_shape::_Compare_extent ( unsigned int  _Rank,
const unsigned int _Extent1,
const unsigned int _Extent2 
)
inlinestatic
1745  {
1746  for (size_t _I = 0; _I < _Rank; ++_I) {
1747  if (_Extent1[_I] != _Extent2[_I]) {
1748  return false;
1749  }
1750  }
1751 
1752  return true;
1753  }
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
1724  {
1725  _ASSERTE((_Rank >= 1) && (_Extent1 != NULL)&& (_Extent2 != NULL));
1726 
1727  // The extents should match accounting for the element sizes of the respective buffers
1728  if ((_Extent1[_Rank - 1] * _Elem_size1) != (_Extent2[_Rank - 1] * _Elem_size2))
1729  {
1730  return false;
1731  }
1732 
1733  // Now compare the extent in all but the least significant dimension
1734  if ((_Rank > 1) && !_Compare_extent(_Rank - 1, _Extent1, _Extent2))
1735  {
1736  return false;
1737  }
1738 
1739  return true;
1740  }
static bool _Compare_extent(unsigned int _Rank, const unsigned int *_Extent1, const unsigned int *_Extent2)
Definition: amprt.h:1744
#define NULL
Definition: crtdbg.h:30
#define _ASSERTE(expr)
Definition: crtdbg.h:216
bool Concurrency::details::_View_shape::_Contains ( const unsigned int _Element_index) const
inlineprivate
1922  {
1923  for (size_t _I = 0; _I < _M_rank; ++_I)
1924  {
1925  if ((_Element_index[_I] < _M_view_offset[_I]) ||
1926  (_Element_index[_I] >= (_M_view_offset[_I] + _M_view_extent[_I])))
1927  {
1928  return false;
1929  }
1930  }
1931 
1932  return true;
1933  }
unsigned int * _M_view_extent
Definition: amprt.h:1954
unsigned int _M_rank
Definition: amprt.h:1950
unsigned int * _M_view_offset
Definition: amprt.h:1953
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
1678  {
1679  return _M_base_extent;
1680  }
unsigned int * _M_base_extent
Definition: amprt.h:1952
static unsigned int Concurrency::details::_View_shape::_Get_extent_size ( unsigned int  _Rank,
const unsigned int _Extent 
)
inlinestaticprivate
1877  {
1878  unsigned int totalExtent = 1;
1879  for (size_t _I = 0; _I < _Rank; ++_I) {
1880  totalExtent *= _Extent[_I];
1881  }
1882 
1883  return totalExtent;
1884  }
unsigned int Concurrency::details::_View_shape::_Get_linear_offset ( ) const
inline
1673  {
1674  return _M_linear_offset;
1675  }
unsigned int _M_linear_offset
Definition: amprt.h:1951
unsigned int Concurrency::details::_View_shape::_Get_linear_offset ( const unsigned int _Element_index) const
inlineprivate
1936  {
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--)
1940  {
1941  linearOffset += (currMultiplier * _Element_index[_I]);
1942  currMultiplier *= _M_base_extent[_I];
1943  }
1944 
1945  return linearOffset;
1946  }
unsigned int _M_linear_offset
Definition: amprt.h:1951
unsigned int * _M_base_extent
Definition: amprt.h:1952
unsigned int _M_rank
Definition: amprt.h:1950
const bool* Concurrency::details::_View_shape::_Get_projection_info ( ) const
inline
1692  {
1693  return _M_projection_info;
1694  }
bool * _M_projection_info
Definition: amprt.h:1955
unsigned int Concurrency::details::_View_shape::_Get_rank ( ) const
inline
1668  {
1669  return _M_rank;
1670  }
unsigned int _M_rank
Definition: amprt.h:1950
_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
1687  {
1688  return _M_view_extent;
1689  }
unsigned int * _M_view_extent
Definition: amprt.h:1954
unsigned int Concurrency::details::_View_shape::_Get_view_linear_offset ( ) const
inline
1718  {
1720  }
unsigned int _Get_linear_offset() const
Definition: amprt.h:1672
unsigned int * _M_view_offset
Definition: amprt.h:1953
const unsigned int* Concurrency::details::_View_shape::_Get_view_offset ( ) const
inline
1683  {
1684  return _M_view_offset;
1685  }
unsigned int * _M_view_offset
Definition: amprt.h:1953
unsigned int Concurrency::details::_View_shape::_Get_view_size ( ) const
inline
1713  {
1715  }
unsigned int * _M_view_extent
Definition: amprt.h:1954
unsigned int _M_rank
Definition: amprt.h:1950
static unsigned int _Get_extent_size(unsigned int _Rank, const unsigned int *_Extent)
Definition: amprt.h:1876
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
1860  {
1861  // Order the intervals by their start points
1862  if (_First_start > _Second_start) {
1863  size_t temp = _First_start;
1864  _First_start = _Second_start;
1865  _Second_start = temp;
1866 
1867  temp = _First_end;
1868  _First_end = _Second_end;
1869  _Second_end = temp;
1870  }
1871 
1872  // The start of the second one must be within the bounds of the first one
1873  return (_Second_start <= _First_end);
1874  }
bool Concurrency::details::_View_shape::_Is_projection ( ) const
inline
1697  {
1698  return _M_projection_info[0];
1699  }
bool * _M_projection_info
Definition: amprt.h:1955
bool Concurrency::details::_View_shape::_Is_valid ( size_t  _Buffer_size) const
inline
1702  {
1703  // The end point of the base shape should not be greater than the size of the buffer
1704  size_t endLinearOffset = _M_linear_offset + _Get_extent_size(_M_rank, _M_base_extent);
1705  if (endLinearOffset > _Buffer_size) {
1706  return false;
1707  }
1708 
1709  return _Is_valid();
1710  }
unsigned int _M_linear_offset
Definition: amprt.h:1951
unsigned int * _M_base_extent
Definition: amprt.h:1952
unsigned int _M_rank
Definition: amprt.h:1950
bool _Is_valid() const
Definition: amprt.h:1886
static unsigned int _Get_extent_size(unsigned int _Rank, const unsigned int *_Extent)
Definition: amprt.h:1876
bool Concurrency::details::_View_shape::_Is_valid ( ) const
inlineprivate
1887  {
1888  if (_M_rank == 0) {
1889  return false;
1890  }
1891 
1892  // Ensure the _M_view_offset + _M_view_extent is within the bounds of _M_base_extent
1893  size_t viewSize = 1;
1894 
1895  for (size_t _I = 0; _I < _M_rank; ++_I)
1896  {
1897  viewSize *= _M_view_extent[_I];
1898  if ((_M_view_offset[_I] + _M_view_extent[_I]) > _M_base_extent[_I]) {
1899  return false;
1900  }
1901  }
1902 
1903  if (viewSize == 0) {
1904  return false;
1905  }
1906 
1907  return true;
1908  }
unsigned int * _M_view_extent
Definition: amprt.h:1954
unsigned int * _M_base_extent
Definition: amprt.h:1952
unsigned int _M_rank
Definition: amprt.h:1950
unsigned int * _M_view_offset
Definition: amprt.h:1953
bool Concurrency::details::_View_shape::_Is_view_linear ( unsigned int _Linear_offset,
unsigned int _Linear_size 
) const
inline
1756  {
1757  // The effective rank for the purpose of determining linearity
1758  // depends on the highest dimension in which the extent is not 1
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++;
1762  }
1763 
1764  unsigned int _Effective_rank = (_M_rank - _First_dim_with_non_unit_extent);
1765 
1766  // It is linear if the effective rank is <= 1 or the base extent
1767  // and view extent are same in all but the highest dimension with
1768  // 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])))
1771  {
1772  _Linear_offset = _Get_view_linear_offset();
1773  _Linear_size = _Get_view_size();
1774  return true;
1775  }
1776 
1777  return false;
1778  }
unsigned int * _M_view_extent
Definition: amprt.h:1954
static bool _Compare_extent(unsigned int _Rank, const unsigned int *_Extent1, const unsigned int *_Extent2)
Definition: amprt.h:1744
unsigned int * _M_base_extent
Definition: amprt.h:1952
unsigned int _Get_view_size() const
Definition: amprt.h:1712
unsigned int _M_rank
Definition: amprt.h:1950
unsigned int _Get_view_linear_offset() const
Definition: amprt.h:1717
bool Concurrency::details::_View_shape::_Overlaps ( const _View_shape _Other) const
inline
1781  {
1782  if (_Compare_base_shape(_Other))
1783  {
1784  // If the base shapes are identical we will do the N-dimensional
1785  // bounding box overlap test
1786 
1787  for (size_t _I = 0; _I < _M_rank; ++_I)
1788  {
1790  _Other->_M_view_offset[_I], _Other->_M_view_offset[_I] + _Other->_M_view_extent[_I] - 1))
1791  {
1792  return false;
1793  }
1794  }
1795 
1796  return true;
1797  }
1798  else
1799  {
1800  // The base shapes are different. Check based on linear intervals
1801  size_t firstStart = _Get_view_linear_offset();
1802  size_t firstEnd = firstStart + _Get_view_size() - 1;
1803 
1804  size_t secondStart = _Other->_Get_view_linear_offset();
1805  size_t secondEnd = secondStart + _Other->_Get_view_size() - 1;
1806 
1807  return _Intervals_overlap(firstStart, firstEnd, secondStart, secondEnd);
1808  }
1809  }
unsigned int * _M_view_extent
Definition: amprt.h:1954
bool _Compare_base_shape(const _View_shape *_Other) const
Definition: amprt.h:1910
unsigned int _Get_view_size() const
Definition: amprt.h:1712
unsigned int _M_rank
Definition: amprt.h:1950
unsigned int * _M_view_offset
Definition: amprt.h:1953
static bool _Intervals_overlap(size_t _First_start, size_t _First_end, size_t _Second_start, size_t _Second_end)
Definition: amprt.h:1858
unsigned int _Get_view_linear_offset() const
Definition: amprt.h:1717
bool Concurrency::details::_View_shape::_Subsumes ( const _View_shape _Other) const
inline
1812  {
1813  // Subsumption test can only be done for shapes that have the same base shape or
1814  // when both have a rank of 1
1815  if ((_M_rank == 1) && (_Other->_Get_rank() == 1))
1816  {
1817  size_t thisStart = _Get_view_linear_offset();
1818  size_t thisEnd = thisStart + _Get_view_size() - 1;
1819 
1820  size_t otherStart = _Other->_Get_view_linear_offset();
1821  size_t otherEnd = otherStart + _Other->_Get_view_size() - 1;
1822 
1823  return ((otherStart >= thisStart) && (otherEnd <= thisEnd));
1824  }
1825 
1826  if (!_Compare_base_shape(_Other)) {
1827  return false;
1828  }
1829 
1830  if (!_Contains(_Other->_Get_view_offset())) {
1831  return false;
1832  }
1833 
1834  std::vector<unsigned int> otherEndPointIndex(_M_rank);
1835  for (size_t _I = 0; _I < _M_rank; ++_I) {
1836  otherEndPointIndex[_I] = _Other->_Get_view_offset()[_I] + _Other->_Get_view_extent()[_I] - 1;
1837  }
1838 
1839  return _Contains(otherEndPointIndex.data());
1840  }
const unsigned int * _Get_view_offset() const
Definition: amprt.h:1682
bool _Compare_base_shape(const _View_shape *_Other) const
Definition: amprt.h:1910
const unsigned int * _Get_view_extent() const
Definition: amprt.h:1686
bool _Contains(const unsigned int *_Element_index) const
Definition: amprt.h:1921
unsigned int _Get_view_size() const
Definition: amprt.h:1712
unsigned int _M_rank
Definition: amprt.h:1950
unsigned int _Get_view_linear_offset() const
Definition: amprt.h:1717
unsigned int _Get_rank() const
Definition: amprt.h:1667
_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: