diff --git a/dash/include/dash/pattern/BlockPattern.h b/dash/include/dash/pattern/BlockPattern.h index 74f792279..f6b4cdf1d 100644 --- a/dash/include/dash/pattern/BlockPattern.h +++ b/dash/include/dash/pattern/BlockPattern.h @@ -83,12 +83,6 @@ class BlockPattern BlockSpec_t; typedef CartesianIndexSpace BlockSizeSpec_t; - typedef DistributionSpec - DistributionSpec_t; - typedef TeamSpec - TeamSpec_t; - typedef SizeSpec - SizeSpec_t; typedef ViewSpec ViewSpec_t; typedef internal::PatternArguments @@ -107,15 +101,19 @@ class BlockPattern std::array coords; } local_coords_t; + typedef DistributionSpec distribution_spec; + typedef TeamSpec team_spec; + typedef SizeSpec size_spec; + private: /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. Defaults to BLOCKED in first, and NONE in higher /// dimensions - DistributionSpec_t _distspec; + distribution_spec _distspec; /// Team containing the units to which the patterns element are mapped dash::Team * _team = nullptr; /// Cartesian arrangement of units within the team - TeamSpec_t _teamspec; + team_spec _teamspec; /// Total amount of units to which this pattern's elements are mapped SizeType _nunits = 0; /// The global layout of the pattern's elements in memory respective to @@ -223,12 +221,12 @@ class BlockPattern */ BlockPattern( /// Pattern size (extent, number of elements) in every dimension - const SizeSpec_t &sizespec, + const size_spec &sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. - DistributionSpec_t dist, + distribution_spec dist, /// Cartesian arrangement of units within the team - const TeamSpec_t &teamspec, + const team_spec &teamspec, /// Team containing units to which this pattern maps its elements dash::Team &team = dash::Team::All()) : _distspec(std::move(dist)) @@ -285,11 +283,11 @@ class BlockPattern */ BlockPattern( /// Pattern size (extent, number of elements) in every dimension - const SizeSpec_t &sizespec, + const size_spec &sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. Defaults to BLOCKED in first, and NONE in higher /// dimensions - DistributionSpec_t dist = DistributionSpec_t(), + distribution_spec dist = distribution_spec(), /// Team containing units to which this pattern maps its elements Team &team = dash::Team::All()) : _distspec(std::move(dist)) @@ -1251,7 +1249,7 @@ class BlockPattern /** * Distribution specification of this pattern. */ - constexpr const DistributionSpec_t & distspec() const noexcept + constexpr const distribution_spec & distspec() const noexcept { return _distspec; } @@ -1261,9 +1259,9 @@ class BlockPattern * * \see DashPatternConcept */ - constexpr SizeSpec_t sizespec() const noexcept + constexpr size_spec sizespec() const noexcept { - return SizeSpec_t(_memory_layout.extents()); + return size_spec(_memory_layout.extents()); } /** @@ -1283,7 +1281,7 @@ class BlockPattern * * \see DashPatternConcept */ - constexpr const TeamSpec_t & teamspec() const noexcept + constexpr const team_spec & teamspec() const noexcept { return _teamspec; } @@ -1379,9 +1377,9 @@ class BlockPattern * distribution spec. */ BlockSizeSpec_t initialize_blocksizespec( - const SizeSpec_t & sizespec, - const DistributionSpec_t & distspec, - const TeamSpec_t & teamspec) const + const size_spec & sizespec, + const distribution_spec & distspec, + const team_spec & teamspec) const { DASH_LOG_TRACE_VAR("BlockPattern.init_blocksizespec", teamspec.size()); if (teamspec.size() == 0) { @@ -1404,8 +1402,8 @@ class BlockPattern * spec. */ BlockSpec_t initialize_blockspec( - const SizeSpec_t & sizespec, - const DistributionSpec_t & distspec, + const size_spec & sizespec, + const distribution_spec & distspec, const BlockSizeSpec_t & blocksizespec) const { if (blocksizespec.size() == 0) { diff --git a/dash/include/dash/pattern/BlockPattern1D.h b/dash/include/dash/pattern/BlockPattern1D.h index 3d69b8ef8..826fa4e4b 100644 --- a/dash/include/dash/pattern/BlockPattern1D.h +++ b/dash/include/dash/pattern/BlockPattern1D.h @@ -77,12 +77,6 @@ class BlockPattern<1, Arrangement, IndexType> LocalMemoryLayout_t; typedef CartesianSpace BlockSpec_t; - typedef DistributionSpec - DistributionSpec_t; - typedef TeamSpec - TeamSpec_t; - typedef SizeSpec - SizeSpec_t; typedef ViewSpec ViewSpec_t; typedef internal::PatternArguments @@ -101,6 +95,10 @@ class BlockPattern<1, Arrangement, IndexType> std::array coords; } local_coords_t; + typedef DistributionSpec distribution_spec; + typedef TeamSpec team_spec; + typedef SizeSpec size_spec; + private: /// Extent of the linear pattern. SizeType _size = 0; @@ -108,11 +106,11 @@ class BlockPattern<1, Arrangement, IndexType> MemoryLayout_t _memory_layout; /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC or NONE) of /// all dimensions. Defaults to BLOCKED. - DistributionSpec_t _distspec; + distribution_spec _distspec; /// Team containing the units to which the patterns element are mapped dash::Team * _team = nullptr; /// Cartesian arrangement of units within the team - TeamSpec_t _teamspec; + team_spec _teamspec; /// Total amount of units to which this pattern's elements are mapped SizeType _nunits = 0; /// Maximum extents of a block in this pattern @@ -194,11 +192,11 @@ class BlockPattern<1, Arrangement, IndexType> */ BlockPattern( /// Pattern size (extent, number of elements) in every dimension - const SizeSpec_t sizespec, + const size_spec sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC or NONE). - const DistributionSpec_t dist, + const distribution_spec dist, /// Cartesian arrangement of units within the team - const TeamSpec_t teamspec, + const team_spec teamspec, /// Team containing units to which this pattern maps its elements dash::Team & team = dash::Team::All()) : _size(sizespec.size()), @@ -255,10 +253,10 @@ class BlockPattern<1, Arrangement, IndexType> */ BlockPattern( /// Pattern size (extent, number of elements) in every dimension - const SizeSpec_t sizespec, + const size_spec sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE). /// Defaults to BLOCKED. - const DistributionSpec_t dist = DistributionSpec_t(), + const distribution_spec dist = distribution_spec(), /// Team containing units to which this pattern maps its elements Team & team = dash::Team::All()) : _size(sizespec.size()), @@ -1025,7 +1023,7 @@ class BlockPattern<1, Arrangement, IndexType> /** * Distribution specification of this pattern. */ - constexpr const DistributionSpec_t & distspec() const noexcept { + constexpr const distribution_spec & distspec() const noexcept { return _distspec; } @@ -1034,8 +1032,8 @@ class BlockPattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - constexpr SizeSpec_t sizespec() const { - return SizeSpec_t(std::array {{ _size }}); + constexpr size_spec sizespec() const { + return size_spec(std::array {{ _size }}); } /** @@ -1053,7 +1051,7 @@ class BlockPattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - constexpr const TeamSpec_t & teamspec() const { + constexpr const team_spec & teamspec() const { return _teamspec; } @@ -1141,7 +1139,7 @@ class BlockPattern<1, Arrangement, IndexType> */ SizeType initialize_blocksize( SizeType size, - const DistributionSpec_t & distspec, + const distribution_spec & distspec, SizeType nunits) const { DASH_LOG_TRACE_VAR("BlockPattern<1>.init_blocksize", nunits); if (nunits == 0) { diff --git a/dash/include/dash/pattern/CSRPattern.h b/dash/include/dash/pattern/CSRPattern.h index 71a83f70f..2578797e3 100644 --- a/dash/include/dash/pattern/CSRPattern.h +++ b/dash/include/dash/pattern/CSRPattern.h @@ -97,12 +97,6 @@ class CSRPattern<1, Arrangement, IndexType> LocalMemoryLayout_t; typedef CartesianSpace BlockSpec_t; - typedef DistributionSpec - DistributionSpec_t; - typedef TeamSpec - TeamSpec_t; - typedef SizeSpec - SizeSpec_t; typedef ViewSpec ViewSpec_t; typedef internal::PatternArguments @@ -121,6 +115,10 @@ class CSRPattern<1, Arrangement, IndexType> std::array coords; } local_coords_t; + typedef DistributionSpec distribution_spec; + typedef TeamSpec team_spec; + typedef SizeSpec size_spec; + private: /// Extent of the linear pattern. SizeType _size = 0; @@ -134,11 +132,11 @@ class CSRPattern<1, Arrangement, IndexType> BlockSpec_t _blockspec; /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC or NONE) of /// all dimensions. Defaults to BLOCKED. - DistributionSpec_t _distspec; + distribution_spec _distspec; /// Team containing the units to which the patterns element are mapped dash::Team * _team = nullptr; /// Cartesian arrangement of units within the team - TeamSpec_t _teamspec; + team_spec _teamspec; /// Total amount of units to which this pattern's elements are mapped SizeType _nunits = 0; /// Actual number of local elements of the active unit. @@ -187,11 +185,11 @@ class CSRPattern<1, Arrangement, IndexType> */ CSRPattern( /// Size spec of the pattern. - const SizeSpec_t & sizespec, + const size_spec & sizespec, /// Distribution spec. - const DistributionSpec_t & distspec, + const distribution_spec & distspec, /// Cartesian arrangement of units within the team - const TeamSpec_t & teamspec, + const team_spec & teamspec, /// Team containing units to which this pattern maps its elements. Team & team = dash::Team::All()) : _size(sizespec.size()), @@ -204,7 +202,7 @@ class CSRPattern<1, Arrangement, IndexType> _memory_layout(std::array {{ _size }}), _blockspec(initialize_blockspec( _local_sizes)), - _distspec(DistributionSpec_t()), + _distspec(distribution_spec()), _team(&team), _teamspec( teamspec, @@ -234,9 +232,9 @@ class CSRPattern<1, Arrangement, IndexType> */ CSRPattern( /// Size spec of the pattern. - const SizeSpec_t & sizespec, + const size_spec & sizespec, /// Distribution spec. - const DistributionSpec_t & distspec, + const distribution_spec & distspec, /// Team containing units to which this pattern maps its elements. Team & team = dash::Team::All()) : _size(sizespec.size()), @@ -249,7 +247,7 @@ class CSRPattern<1, Arrangement, IndexType> _memory_layout(std::array {{ _size }}), _blockspec(initialize_blockspec( _local_sizes)), - _distspec(DistributionSpec_t()), + _distspec(distribution_spec()), _team(&team), _teamspec(_distspec, *_team), _nunits(_team->size()), @@ -307,7 +305,7 @@ class CSRPattern<1, Arrangement, IndexType> /// Number of local elements for every unit in the active team. const std::vector & local_sizes, /// Cartesian arrangement of units within the team - const TeamSpec_t & teamspec, + const team_spec & teamspec, /// Team containing units to which this pattern maps its elements dash::Team & team = dash::Team::All()) : _size(initialize_size( @@ -318,7 +316,7 @@ class CSRPattern<1, Arrangement, IndexType> _memory_layout(std::array {{ _size }}), _blockspec(initialize_blockspec( _local_sizes)), - _distspec(DistributionSpec_t()), + _distspec(distribution_spec()), _team(&team), _teamspec( teamspec, @@ -362,7 +360,7 @@ class CSRPattern<1, Arrangement, IndexType> _blockspec( initialize_blockspec( _local_sizes)), - _distspec(DistributionSpec_t()), + _distspec(distribution_spec()), _team(&team), _teamspec(_distspec, *_team), _nunits(_team->size()), @@ -1052,7 +1050,7 @@ class CSRPattern<1, Arrangement, IndexType> /** * Distribution specification of this pattern. */ - constexpr const DistributionSpec_t & distspec() const noexcept + constexpr const distribution_spec & distspec() const noexcept { return _distspec; } @@ -1062,9 +1060,9 @@ class CSRPattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - constexpr SizeSpec_t sizespec() const noexcept + constexpr size_spec sizespec() const noexcept { - return SizeSpec_t(std::array {{ _size }}); + return size_spec(std::array {{ _size }}); } /** @@ -1084,7 +1082,7 @@ class CSRPattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - constexpr const TeamSpec_t & teamspec() const noexcept + constexpr const team_spec & teamspec() const noexcept { return _teamspec; } @@ -1181,7 +1179,7 @@ class CSRPattern<1, Arrangement, IndexType> */ std::vector initialize_local_sizes( size_type total_size, - const DistributionSpec_t & distspec, + const distribution_spec & distspec, const dash::Team & team) const { DASH_LOG_TRACE_VAR("CSRPattern.init_local_sizes()", total_size); diff --git a/dash/include/dash/pattern/DynamicPattern.h b/dash/include/dash/pattern/DynamicPattern.h index a467cbff5..cf4151458 100644 --- a/dash/include/dash/pattern/DynamicPattern.h +++ b/dash/include/dash/pattern/DynamicPattern.h @@ -93,12 +93,6 @@ class DynamicPattern<1, Arrangement, IndexType> LocalMemoryLayout_t; typedef CartesianSpace BlockSpec_t; - typedef DistributionSpec - DistributionSpec_t; - typedef TeamSpec - TeamSpec_t; - typedef SizeSpec - SizeSpec_t; typedef ViewSpec ViewSpec_t; typedef internal::PatternArguments @@ -117,6 +111,10 @@ class DynamicPattern<1, Arrangement, IndexType> std::array coords; } local_coords_t; + typedef DistributionSpec distribution_spec; + typedef TeamSpec team_spec; + typedef SizeSpec size_spec; + public: /** * Constructor, initializes a pattern from an argument list consisting @@ -153,11 +151,11 @@ class DynamicPattern<1, Arrangement, IndexType> */ DynamicPattern( /// Size spec of the pattern. - const SizeSpec_t & sizespec, + const size_spec & sizespec, /// Distribution spec. - const DistributionSpec_t & distspec, + const distribution_spec & distspec, /// Cartesian arrangement of units within the team - const TeamSpec_t & teamspec, + const team_spec & teamspec, /// Team containing units to which this pattern maps its elements. Team & team = dash::Team::All()) : _size(sizespec.size()), @@ -171,7 +169,7 @@ class DynamicPattern<1, Arrangement, IndexType> _blockspec(initialize_blockspec( _size, _local_sizes)), - _distspec(DistributionSpec_t()), + _distspec(distribution_spec()), _team(&team), _myid(_team->myid()), _teamspec( @@ -205,9 +203,9 @@ class DynamicPattern<1, Arrangement, IndexType> */ DynamicPattern( /// Size spec of the pattern. - const SizeSpec_t & sizespec, + const size_spec & sizespec, /// Distribution spec. - const DistributionSpec_t & distspec, + const distribution_spec & distspec, /// Team containing units to which this pattern maps its elements. Team & team = dash::Team::All()) : _size(sizespec.size()), @@ -221,7 +219,7 @@ class DynamicPattern<1, Arrangement, IndexType> _blockspec(initialize_blockspec( _size, _local_sizes)), - _distspec(DistributionSpec_t()), + _distspec(distribution_spec()), _team(&team), _myid(_team->myid()), _teamspec(_distspec, *_team), @@ -283,7 +281,7 @@ class DynamicPattern<1, Arrangement, IndexType> /// Number of local elements for every unit in the active team. const std::vector & local_sizes, /// Cartesian arrangement of units within the team - const TeamSpec_t & teamspec, + const team_spec & teamspec, /// Team containing units to which this pattern maps its elements dash::Team & team = dash::Team::All()) : _size(initialize_size( @@ -295,7 +293,7 @@ class DynamicPattern<1, Arrangement, IndexType> _blockspec(initialize_blockspec( _size, _local_sizes)), - _distspec(DistributionSpec_t()), + _distspec(distribution_spec()), _team(&team), _myid(_team->myid()), _teamspec( @@ -341,7 +339,7 @@ class DynamicPattern<1, Arrangement, IndexType> _blockspec(initialize_blockspec( _size, _local_sizes)), - _distspec(DistributionSpec_t()), + _distspec(distribution_spec()), _team(&team), _myid(_team->myid()), _teamspec(_distspec, *_team), @@ -1172,7 +1170,7 @@ class DynamicPattern<1, Arrangement, IndexType> /** * Distribution specification of this pattern. */ - const DistributionSpec_t & distspec() const + const distribution_spec & distspec() const { return _distspec; } @@ -1182,9 +1180,9 @@ class DynamicPattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - SizeSpec_t sizespec() const + size_spec sizespec() const { - return SizeSpec_t(std::array { _size }); + return size_spec(std::array { _size }); } /** @@ -1203,7 +1201,7 @@ class DynamicPattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - const TeamSpec_t & teamspec() const + const team_spec & teamspec() const { return _teamspec; } @@ -1310,7 +1308,7 @@ class DynamicPattern<1, Arrangement, IndexType> */ std::vector initialize_local_sizes( size_type total_size, - const DistributionSpec_t & distspec, + const distribution_spec & distspec, const dash::Team & team) const { DASH_LOG_TRACE_VAR("DynamicPattern.init_local_sizes()", total_size); @@ -1396,7 +1394,7 @@ class DynamicPattern<1, Arrangement, IndexType> */ SizeType initialize_blocksize( SizeType size, - const DistributionSpec_t & distspec, + const distribution_spec & distspec, SizeType nunits) const { DASH_LOG_TRACE_VAR("DynamicPattern.init_blocksize", nunits); @@ -1413,7 +1411,7 @@ class DynamicPattern<1, Arrangement, IndexType> SizeType initialize_num_local_blocks( SizeType num_blocks, SizeType blocksize, - const DistributionSpec_t & distspec, + const distribution_spec & distspec, SizeType nunits, SizeType local_size) const { @@ -1500,13 +1498,13 @@ class DynamicPattern<1, Arrangement, IndexType> BlockSpec_t _blockspec; /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC or NONE) of /// all dimensions. Defaults to BLOCKED. - DistributionSpec_t _distspec; + distribution_spec _distspec; /// Team containing the units to which the patterns element are mapped dash::Team * _team = nullptr; /// The active unit's id. team_unit_t _myid; /// Cartesian arrangement of units within the team - TeamSpec_t _teamspec; + team_spec _teamspec; /// Total amount of units to which this pattern's elements are mapped SizeType _nunits = 0; /// Maximum extents of a block in this pattern diff --git a/dash/include/dash/pattern/LoadBalancePattern.h b/dash/include/dash/pattern/LoadBalancePattern.h index 9654ebb9e..fc2722604 100644 --- a/dash/include/dash/pattern/LoadBalancePattern.h +++ b/dash/include/dash/pattern/LoadBalancePattern.h @@ -258,12 +258,6 @@ class LoadBalancePattern< LocalMemoryLayout_t; typedef CartesianSpace BlockSpec_t; - typedef DistributionSpec - DistributionSpec_t; - typedef TeamSpec - TeamSpec_t; - typedef SizeSpec - SizeSpec_t; typedef ViewSpec ViewSpec_t; typedef internal::PatternArguments @@ -286,13 +280,17 @@ class LoadBalancePattern< std::array coords; } local_coords_t; + typedef DistributionSpec distribution_spec; + typedef TeamSpec team_spec; + typedef SizeSpec size_spec; + public: /** * Constructor. */ LoadBalancePattern( /// Size spec of the pattern. - const SizeSpec_t & sizespec, + const size_spec & sizespec, /// Locality hierarchy of the team. TeamLocality_t & team_loc) : _size(sizespec.size()), @@ -345,7 +343,7 @@ class LoadBalancePattern< */ LoadBalancePattern( /// Size spec of the pattern. - const SizeSpec_t & sizespec, + const size_spec & sizespec, /// Team containing units to which this pattern maps its elements. dash::Team & team = dash::Team::All()) : LoadBalancePattern(sizespec, TeamLocality_t(team)) @@ -1005,7 +1003,7 @@ class LoadBalancePattern< /** * Distribution specification of this pattern. */ - const DistributionSpec_t & distspec() const + const distribution_spec & distspec() const { return _distspec; } @@ -1015,9 +1013,9 @@ class LoadBalancePattern< * * \see DashPatternConcept */ - SizeSpec_t sizespec() const + size_spec sizespec() const { - return SizeSpec_t(std::array {{ _size }}); + return size_spec(std::array {{ _size }}); } /** @@ -1036,7 +1034,7 @@ class LoadBalancePattern< * * \see DashPatternConcept */ - const TeamSpec_t & teamspec() const + const team_spec & teamspec() const { return _teamspec; } @@ -1290,13 +1288,13 @@ class LoadBalancePattern< /// Number of blocks in all dimensions BlockSpec_t _blockspec; /// Distribution types of all dimensions. - DistributionSpec_t _distspec; + distribution_spec _distspec; /// Team containing the units to which the patterns element are mapped dash::Team * _team = nullptr; /// The active unit's id. team_unit_t _myid; /// Cartesian arrangement of units within the team - TeamSpec_t _teamspec; + team_spec _teamspec; /// Total amount of units to which this pattern's elements are mapped SizeType _nunits = 0; /// Actual number of local elements of the active unit. diff --git a/dash/include/dash/pattern/SeqTilePattern.h b/dash/include/dash/pattern/SeqTilePattern.h index a188e0661..a8c28654a 100644 --- a/dash/include/dash/pattern/SeqTilePattern.h +++ b/dash/include/dash/pattern/SeqTilePattern.h @@ -95,12 +95,6 @@ class SeqTilePattern BlockSpec_t; typedef CartesianIndexSpace BlockSizeSpec_t; - typedef DistributionSpec - DistributionSpec_t; - typedef TeamSpec - TeamSpec_t; - typedef SizeSpec - SizeSpec_t; typedef ViewSpec ViewSpec_t; typedef internal::PatternArguments @@ -119,17 +113,21 @@ class SeqTilePattern std::array coords; } local_coords_t; + typedef DistributionSpec distribution_spec; + typedef TeamSpec team_spec; + typedef SizeSpec size_spec; + private: /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. Defaults to BLOCKED in first, and NONE in higher /// dimensions - DistributionSpec_t _distspec; + distribution_spec _distspec; /// Team containing the units to which the patterns element are mapped dash::Team * _team = nullptr; /// The active unit's id. team_unit_t _myid; /// Cartesian arrangement of units within the team - TeamSpec_t _teamspec; + team_spec _teamspec; /// The global layout of the pattern's elements in memory respective to /// memory order. Also specifies the extents of the pattern space. MemoryLayout_t _memory_layout; @@ -238,13 +236,13 @@ class SeqTilePattern */ SeqTilePattern( /// SeqTilePattern size (extent, number of elements) in every dimension - const SizeSpec_t &sizespec, + const size_spec &sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. Defaults to BLOCKED in first, and NONE in higher /// dimensions - DistributionSpec_t dist, + distribution_spec dist, /// Cartesian arrangement of units within the team - const TeamSpec_t &teamspec, + const team_spec &teamspec, /// Team containing units to which this pattern maps its elements dash::Team &team = dash::Team::All()) : _distspec(std::move(dist)) @@ -299,11 +297,11 @@ class SeqTilePattern */ SeqTilePattern( /// SeqTilePattern size (extent, number of elements) in every dimension - const SizeSpec_t & sizespec, + const size_spec & sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. Defaults to BLOCKED in first, and NONE in higher /// dimensions - const DistributionSpec_t & dist = DistributionSpec_t(), + const distribution_spec & dist = distribution_spec(), /// Team containing units to which this pattern maps its elements Team & team = dash::Team::All()) : _distspec(dist), @@ -1375,7 +1373,7 @@ class SeqTilePattern /** * Distribution specification of this pattern. */ - const DistributionSpec_t & distspec() const { + const distribution_spec & distspec() const { return _distspec; } @@ -1384,8 +1382,8 @@ class SeqTilePattern * * \see DashPatternConcept */ - SizeSpec_t sizespec() const { - return SizeSpec_t(_memory_layout.extents()); + size_spec sizespec() const { + return size_spec(_memory_layout.extents()); } /** @@ -1403,7 +1401,7 @@ class SeqTilePattern * * \see DashPatternConcept */ - const TeamSpec_t & teamspec() const { + const team_spec & teamspec() const { return _teamspec; } @@ -1475,9 +1473,9 @@ class SeqTilePattern * distribution spec. */ BlockSizeSpec_t initialize_blocksizespec( - const SizeSpec_t & sizespec, - const DistributionSpec_t & distspec, - const TeamSpec_t & teamspec) const { + const size_spec & sizespec, + const distribution_spec & distspec, + const team_spec & teamspec) const { DASH_LOG_TRACE("SeqTilePattern.init_blocksizespec()"); // Extents of a single block: std::array s_blocks{}; @@ -1500,9 +1498,9 @@ class SeqTilePattern * spec. */ BlockSpec_t initialize_blockspec( - const SizeSpec_t & sizespec, + const size_spec & sizespec, const BlockSizeSpec_t & blocksizespec, - const TeamSpec_t & teamspec) const + const team_spec & teamspec) const { DASH_LOG_TRACE("SeqTilePattern.init_blockspec()", "pattern size:", sizespec.extents(), diff --git a/dash/include/dash/pattern/ShiftTilePattern.h b/dash/include/dash/pattern/ShiftTilePattern.h index 17ae0424c..d9834f2e8 100644 --- a/dash/include/dash/pattern/ShiftTilePattern.h +++ b/dash/include/dash/pattern/ShiftTilePattern.h @@ -89,12 +89,6 @@ class ShiftTilePattern BlockSpec_t; typedef CartesianIndexSpace BlockSizeSpec_t; - typedef DistributionSpec - DistributionSpec_t; - typedef TeamSpec - TeamSpec_t; - typedef SizeSpec - SizeSpec_t; typedef ViewSpec ViewSpec_t; typedef internal::PatternArguments @@ -113,15 +107,19 @@ class ShiftTilePattern std::array coords; } local_coords_t; + typedef DistributionSpec distribution_spec; + typedef TeamSpec team_spec; + typedef SizeSpec size_spec; + private: /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. Defaults to BLOCKED in first, and NONE in higher /// dimensions - DistributionSpec_t _distspec; + distribution_spec _distspec; /// Team containing the units to which the patterns element are mapped dash::Team * _team = nullptr; /// Cartesian arrangement of units within the team - TeamSpec_t _teamspec; + team_spec _teamspec; /// The global layout of the pattern's elements in memory respective to /// memory order. Also specifies the extents of the pattern space. MemoryLayout_t _memory_layout; @@ -236,12 +234,12 @@ class ShiftTilePattern ShiftTilePattern( /// ShiftTilePattern size (extent, number of elements) in every /// dimension - const SizeSpec_t &sizespec, + const size_spec &sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. - DistributionSpec_t dist, + distribution_spec dist, /// Cartesian arrangement of units within the team - TeamSpec_t teamspec, + team_spec teamspec, /// Team containing units to which this pattern maps its elements dash::Team &team = dash::Team::All()) : _distspec(std::move(dist)) @@ -306,11 +304,11 @@ class ShiftTilePattern ShiftTilePattern( /// ShiftTilePattern size (extent, number of elements) in every /// dimension - const SizeSpec_t &sizespec, + const size_spec &sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. Defaults to BLOCKED in first, and NONE in higher /// dimensions - DistributionSpec_t dist = DistributionSpec_t(), + distribution_spec dist = distribution_spec(), /// Team containing units to which this pattern maps its elements Team &team = dash::Team::All()) : _distspec(std::move(dist)) @@ -1353,7 +1351,7 @@ class ShiftTilePattern /** * Distribution specification of this pattern. */ - inline const DistributionSpec_t & distspec() const { + inline const distribution_spec & distspec() const { return _distspec; } @@ -1362,8 +1360,8 @@ class ShiftTilePattern * * \see DashPatternConcept */ - SizeSpec_t sizespec() const { - return SizeSpec_t(_memory_layout.extents()); + size_spec sizespec() const { + return size_spec(_memory_layout.extents()); } /** @@ -1381,7 +1379,7 @@ class ShiftTilePattern * * \see DashPatternConcept */ - const TeamSpec_t & teamspec() const { + const team_spec & teamspec() const { return _teamspec; } @@ -1472,9 +1470,9 @@ class ShiftTilePattern * distribution spec. */ BlockSizeSpec_t initialize_blocksizespec( - const SizeSpec_t & sizespec, - const DistributionSpec_t & distspec, - const TeamSpec_t & teamspec) const { + const size_spec & sizespec, + const distribution_spec & distspec, + const team_spec & teamspec) const { DASH_LOG_TRACE("ShiftTilePattern.init_blocksizespec()"); // Extents of a single block: std::array s_blocks{}; @@ -1497,9 +1495,9 @@ class ShiftTilePattern * spec. */ BlockSpec_t initialize_blockspec( - const SizeSpec_t & sizespec, + const size_spec & sizespec, const BlockSizeSpec_t & blocksizespec, - const TeamSpec_t & teamspec) const + const team_spec & teamspec) const { DASH_LOG_TRACE("ShiftTilePattern.init_blockspec()", "pattern size:", sizespec.extents(), @@ -1583,7 +1581,7 @@ class ShiftTilePattern * Return major dimension with tiled distribution, i.e. lowest tiled * dimension. */ - dim_t initialize_major_tiled_dim(const DistributionSpec_t & ds) + dim_t initialize_major_tiled_dim(const distribution_spec & ds) { DASH_LOG_TRACE("ShiftTilePattern.init_major_tiled_dim()"); if (Arrangement == dash::COL_MAJOR) { diff --git a/dash/include/dash/pattern/ShiftTilePattern1D.h b/dash/include/dash/pattern/ShiftTilePattern1D.h index 1ff4f81a1..cfba63989 100644 --- a/dash/include/dash/pattern/ShiftTilePattern1D.h +++ b/dash/include/dash/pattern/ShiftTilePattern1D.h @@ -81,12 +81,6 @@ class ShiftTilePattern<1, Arrangement, IndexType> LocalMemoryLayout_t; typedef CartesianSpace BlockSpec_t; - typedef DistributionSpec - DistributionSpec_t; - typedef TeamSpec - TeamSpec_t; - typedef SizeSpec - SizeSpec_t; typedef ViewSpec ViewSpec_t; typedef internal::PatternArguments @@ -105,6 +99,10 @@ class ShiftTilePattern<1, Arrangement, IndexType> std::array coords; } local_coords_t; + typedef DistributionSpec distribution_spec; + typedef TeamSpec team_spec; + typedef SizeSpec size_spec; + private: /// Extent of the linear pattern. SizeType _size; @@ -112,11 +110,11 @@ class ShiftTilePattern<1, Arrangement, IndexType> MemoryLayout_t _memory_layout; /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC or NONE) of /// all dimensions. Defaults to BLOCKED. - DistributionSpec_t _distspec; + distribution_spec _distspec; /// Team containing the units to which the patterns element are mapped dash::Team * _team = nullptr; /// Cartesian arrangement of units within the team - TeamSpec_t _teamspec; + team_spec _teamspec; /// Total amount of units to which this pattern's elements are mapped SizeType _nunits = 0; /// Maximum extents of a block in this pattern @@ -199,11 +197,11 @@ class ShiftTilePattern<1, Arrangement, IndexType> */ ShiftTilePattern( /// Pattern size (extent, number of elements) in every dimension - const SizeSpec_t &sizespec, + const size_spec &sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC or NONE). - DistributionSpec_t dist, + distribution_spec dist, /// Cartesian arrangement of units within the team - const TeamSpec_t &teamspec, + const team_spec &teamspec, /// Team containing units to which this pattern maps its elements dash::Team &team = dash::Team::All()) : _size(sizespec.size()) @@ -251,12 +249,12 @@ class ShiftTilePattern<1, Arrangement, IndexType> */ ShiftTilePattern( /// Pattern size (extent, number of elements) in every dimension - const SizeSpec_t & sizespec, + const size_spec & sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE). /// Defaults to BLOCKED in first. - const DistributionSpec_t & dist = DistributionSpec_t(), + const distribution_spec & dist = distribution_spec(), /// Team containing units to which this pattern maps its elements - Team & team = dash::Team::All()) + Team & team = dash::Team::All()) : _size(sizespec.size()), _memory_layout(std::array { _size }), _distspec(dist), @@ -512,10 +510,10 @@ class ShiftTilePattern<1, Arrangement, IndexType> * \see DashPatternConcept */ std::array local_extents( - team_unit_t unit) const { + team_unit_t unit = UNDEFINED_TEAM_UNIT_ID) const { DASH_LOG_DEBUG_VAR("ShiftTilePattern<1>.local_extents()", unit); DASH_LOG_DEBUG_VAR("ShiftTilePattern<1>.local_extents >", _local_size); - return std::array { _local_size }; + return std::array {{ _local_size }}; } //////////////////////////////////////////////////////////////////////////// @@ -911,8 +909,7 @@ class ShiftTilePattern<1, Arrangement, IndexType> * Cartesian arrangement of pattern blocks. */ BlockSpec_t blockspec() const { - BlockSpec_t bspec({{ dash::math::div_ceil(_size, _blocksize) }}); - return bspec; + return BlockSpec_t({ _nblocks }); } /** @@ -1010,7 +1007,7 @@ class ShiftTilePattern<1, Arrangement, IndexType> /** * Distribution specification of this pattern. */ - const DistributionSpec_t & distspec() const { + const distribution_spec & distspec() const { return _distspec; } @@ -1019,8 +1016,8 @@ class ShiftTilePattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - SizeSpec_t sizespec() const { - return SizeSpec_t(std::array {{ _size }}); + size_spec sizespec() const { + return size_spec(std::array {{ _size }}); } /** @@ -1028,8 +1025,8 @@ class ShiftTilePattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - const std::array & extents() const { - return std::array { _size }; + const std::array extents() const { + return std::array {{ _size }}; } /** @@ -1038,7 +1035,7 @@ class ShiftTilePattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - const TeamSpec_t & teamspec() const { + const team_spec & teamspec() const { return _teamspec; } @@ -1111,7 +1108,7 @@ class ShiftTilePattern<1, Arrangement, IndexType> */ SizeType initialize_blocksize( SizeType size, - const DistributionSpec_t & distspec, + const distribution_spec & distspec, SizeType nunits) const { DASH_LOG_TRACE_VAR("ShiftTilePattern<1>.init_blocksize", nunits); if (nunits == 0) { diff --git a/dash/include/dash/pattern/TilePattern.h b/dash/include/dash/pattern/TilePattern.h index c28bdf5a0..f59397832 100644 --- a/dash/include/dash/pattern/TilePattern.h +++ b/dash/include/dash/pattern/TilePattern.h @@ -89,12 +89,6 @@ class TilePattern BlockSpec_t; typedef CartesianIndexSpace BlockSizeSpec_t; - typedef DistributionSpec - DistributionSpec_t; - typedef TeamSpec - TeamSpec_t; - typedef SizeSpec - SizeSpec_t; typedef ViewSpec ViewSpec_t; typedef internal::PatternArguments @@ -113,17 +107,21 @@ class TilePattern std::array coords{}; } local_coords_t; + typedef DistributionSpec distribution_spec; + typedef TeamSpec team_spec; + typedef SizeSpec size_spec; + private: /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. Defaults to BLOCKED in first, and NONE in higher /// dimensions - DistributionSpec_t _distspec; + distribution_spec _distspec; /// Team containing the units to which the patterns element are mapped dash::Team * _team = nullptr; /// The active unit's id. team_unit_t _myid; /// Cartesian arrangement of units within the team - TeamSpec_t _teamspec; + team_spec _teamspec; /// The global layout of the pattern's elements in memory respective to /// memory order. Also specifies the extents of the pattern space. MemoryLayout_t _memory_layout; @@ -232,12 +230,12 @@ class TilePattern */ TilePattern( /// TilePattern size (extent, number of elements) in every dimension - const SizeSpec_t &sizespec, + const size_spec &sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. - DistributionSpec_t dist, + distribution_spec dist, /// Cartesian arrangement of units within the team - const TeamSpec_t &teamspec, + const team_spec &teamspec, /// Team containing units to which this pattern maps its elements dash::Team &team = dash::Team::All()) : _distspec(std::move(dist)) @@ -293,11 +291,11 @@ class TilePattern */ TilePattern( /// TilePattern size (extent, number of elements) in every dimension - const SizeSpec_t &sizespec, + const size_spec &sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of /// all dimensions. Defaults to BLOCKED in first, and NONE in higher /// dimensions - DistributionSpec_t dist = DistributionSpec_t(), + distribution_spec dist = distribution_spec(), /// Team containing units to which this pattern maps its elements Team &team = dash::Team::All()) : _distspec(std::move(dist)) @@ -1395,7 +1393,7 @@ class TilePattern /** * Distribution specification of this pattern. */ - constexpr const DistributionSpec_t & distspec() const { + constexpr const distribution_spec & distspec() const { return _distspec; } @@ -1404,8 +1402,8 @@ class TilePattern * * \see DashPatternConcept */ - constexpr SizeSpec_t sizespec() const { - return SizeSpec_t(_memory_layout.extents()); + constexpr size_spec sizespec() const { + return size_spec(_memory_layout.extents()); } /** @@ -1423,7 +1421,7 @@ class TilePattern * * \see DashPatternConcept */ - constexpr const TeamSpec_t & teamspec() const { + constexpr const team_spec & teamspec() const { return _teamspec; } @@ -1516,9 +1514,9 @@ class TilePattern * distribution spec. */ BlockSizeSpec_t initialize_blocksizespec( - const SizeSpec_t & sizespec, - const DistributionSpec_t & distspec, - const TeamSpec_t & teamspec) const { + const size_spec & sizespec, + const distribution_spec & distspec, + const team_spec & teamspec) const { DASH_LOG_TRACE("TilePattern.init_blocksizespec()", "sizespec:", sizespec.extents(), "distspec:", distspec.values(), @@ -1559,9 +1557,9 @@ class TilePattern * spec. */ BlockSpec_t initialize_blockspec( - const SizeSpec_t & sizespec, + const size_spec & sizespec, const BlockSizeSpec_t & blocksizespec, - const TeamSpec_t & teamspec) const + const team_spec & teamspec) const { DASH_LOG_TRACE("TilePattern.init_blockspec()", "pattern size:", sizespec.extents(), @@ -1594,7 +1592,7 @@ class TilePattern BlockSpec_t initialize_local_blockspec( const BlockSpec_t & blockspec, const BlockSizeSpec_t & blocksizespec, - const TeamSpec_t & teamspec, + const team_spec & teamspec, team_unit_t unit_id = UNDEFINED_TEAM_UNIT_ID) const { DASH_LOG_TRACE_VAR("TilePattern.init_local_blockspec()", diff --git a/dash/include/dash/pattern/TilePattern1D.h b/dash/include/dash/pattern/TilePattern1D.h index 23b46a47a..bea80982f 100644 --- a/dash/include/dash/pattern/TilePattern1D.h +++ b/dash/include/dash/pattern/TilePattern1D.h @@ -80,12 +80,6 @@ class TilePattern<1, Arrangement, IndexType> LocalMemoryLayout_t; typedef CartesianSpace BlockSpec_t; - typedef DistributionSpec - DistributionSpec_t; - typedef TeamSpec - TeamSpec_t; - typedef SizeSpec - SizeSpec_t; typedef ViewSpec ViewSpec_t; typedef internal::PatternArguments @@ -104,6 +98,10 @@ class TilePattern<1, Arrangement, IndexType> std::array coords; } local_coords_t; + typedef DistributionSpec distribution_spec; + typedef TeamSpec team_spec; + typedef SizeSpec size_spec; + private: /// Extent of the linear pattern. SizeType _size; @@ -111,11 +109,11 @@ class TilePattern<1, Arrangement, IndexType> MemoryLayout_t _memory_layout; /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC or NONE) of /// all dimensions. Defaults to BLOCKED. - DistributionSpec_t _distspec; + distribution_spec _distspec; /// Team containing the units to which the patterns element are mapped dash::Team * _team = nullptr; /// Cartesian arrangement of units within the team - TeamSpec_t _teamspec; + team_spec _teamspec; /// Total amount of units to which this pattern's elements are mapped SizeType _nunits = 0; /// Maximum extents of a block in this pattern @@ -199,11 +197,11 @@ class TilePattern<1, Arrangement, IndexType> */ TilePattern( /// Pattern size (extent, number of elements) in every dimension - const SizeSpec_t sizespec, + const size_spec sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC or NONE). - const DistributionSpec_t dist, + const distribution_spec dist, /// Cartesian arrangement of units within the team - const TeamSpec_t teamspec, + const team_spec teamspec, /// Team containing units to which this pattern maps its elements dash::Team & team = dash::Team::All()) : _size(sizespec.size()), @@ -262,10 +260,10 @@ class TilePattern<1, Arrangement, IndexType> */ TilePattern( /// Pattern size (extent, number of elements) in every dimension - const SizeSpec_t &sizespec, + const size_spec &sizespec, /// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE). /// Defaults to BLOCKED in first. - DistributionSpec_t dist = DistributionSpec_t(), + distribution_spec dist = distribution_spec(), /// Team containing units to which this pattern maps its elements Team &team = dash::Team::All()) : _size(sizespec.size()) @@ -509,10 +507,10 @@ class TilePattern<1, Arrangement, IndexType> */ constexpr local_coords_t local( const std::array & global_coords) const { - return local_coords_t {{ + return local_coords_t { unit_at(global_coords), local_coords(global_coords) - }}; + }; } /** @@ -969,7 +967,7 @@ class TilePattern<1, Arrangement, IndexType> /** * Distribution specification of this pattern. */ - constexpr const DistributionSpec_t & distspec() const { + constexpr const distribution_spec & distspec() const { return _distspec; } @@ -978,8 +976,8 @@ class TilePattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - constexpr SizeSpec_t sizespec() const { - return SizeSpec_t(std::array {{ _size }}); + constexpr size_spec sizespec() const { + return size_spec(std::array {{ _size }}); } /** @@ -997,7 +995,7 @@ class TilePattern<1, Arrangement, IndexType> * * \see DashPatternConcept */ - const TeamSpec_t & teamspec() const { + const team_spec & teamspec() const { return _teamspec; } @@ -1069,7 +1067,7 @@ class TilePattern<1, Arrangement, IndexType> */ SizeType initialize_blocksize( SizeType size, - const DistributionSpec_t & distspec, + const distribution_spec & distspec, SizeType nunits) const { DASH_LOG_TRACE_VAR("TilePattern<1>.init_blocksize", nunits); if (nunits == 0) { diff --git a/dash/test/pattern/BlockPatternTest.cc b/dash/test/pattern/BlockPatternTest.cc index 4cdd3d4e4..3028fed76 100644 --- a/dash/test/pattern/BlockPatternTest.cc +++ b/dash/test/pattern/BlockPatternTest.cc @@ -1203,3 +1203,29 @@ TEST_F(BlockPatternTest, UnderfilledPatternExtent1Dim) EXPECT_EQ_U(bextent, desired); } + +TEST_F(BlockPatternTest, BlockPattern1DFunctionalCheck) +{ + auto num_units = dash::Team::All().size(); + + //series of default test + typedef dash::BlockPattern<1> pattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i); + + // series of unsigned COLUMN MAJOR test + typedef dash::BlockPattern<1, dash::COL_MAJOR, unsigned long> upattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i); +} + +TEST_F(BlockPatternTest, BlockPatternFunctionalCheck) +{ + auto num_units = dash::Team::All().size(); + + //series of default 2D test + typedef dash::BlockPattern<2> pattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i, i); + + // series of unsigned COLUMN MAJOR 2D test + typedef dash::BlockPattern<2, dash::COL_MAJOR, unsigned long> upattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i, i); +} diff --git a/dash/test/pattern/BlockPatternTest.h b/dash/test/pattern/BlockPatternTest.h index 2e6a7394b..603c598cd 100644 --- a/dash/test/pattern/BlockPatternTest.h +++ b/dash/test/pattern/BlockPatternTest.h @@ -2,7 +2,7 @@ #define DASH__TEST__BLOCK_PATTERN_TEST_H_ #include "../TestBase.h" - +#include "PatternTest.h" /** * Test fixture for class dash::Pattern diff --git a/dash/test/pattern/PatternTest.h b/dash/test/pattern/PatternTest.h new file mode 100644 index 000000000..a2d2ac2e5 --- /dev/null +++ b/dash/test/pattern/PatternTest.h @@ -0,0 +1,111 @@ +#ifndef DASH__TEST__PATTERN_TEST_H_ +#define DASH__TEST__PATTERN_TEST_H_ + +#include "../TestBase.h" + +/** + * Template test function for pattern functionalities + */ + + +template +void test_pattern(typename PatternType::size_type array_size, Args &&... args) // array_size is first dim size +{ + using namespace std; + + typedef typename PatternType::size_type SizeType; + typedef typename PatternType::index_type IndexType; + + typedef typename PatternType::distribution_spec DistributionSpecType; + typedef typename PatternType::team_spec TeamSpecType; + typedef typename PatternType::size_spec SizeSpecType; + + const SizeType dims = PatternType::ndim(); + + auto num_units = dash::Team::All().size(); + auto unit_id = dash::myid(); + + std::array coord = {0, static_cast(!(bool) args)...}; // test coordinate {0, 0...} + + // test constructors + //PatternType pattern1(array_size, args...); // check compiling, not check equality with other constructor due to the difference in DistributionSpec + + PatternType pattern2(SizeSpecType(array_size, args...), + DistributionSpecType(dash::TILE(array_size / num_units), dash::TILE(args / num_units)...)); + + PatternType pattern3(SizeSpecType(array_size, args...), + DistributionSpecType(dash::TILE(array_size / num_units), dash::TILE(args / num_units)...), + TeamSpecType(num_units, static_cast((bool) args)...)); // a hack to input default 1 for higher dims depended on number of args + + PatternType pattern4 = pattern3; + + ASSERT_EQ_U(pattern2 == pattern3, true); + ASSERT_EQ_U(pattern3 == pattern4, true); + + //test .extents + ASSERT_EQ_U(pattern2.extent(0), array_size); + + auto l_extents = pattern2.local_extents(); + ASSERT_EQ_U(accumulate(begin(l_extents), end(l_extents), 1, multiplies()), pattern2.local_size()); + + auto g_extents = pattern2.extents(); + ASSERT_EQ_U(accumulate(begin(g_extents), end(g_extents), 1, multiplies()), pattern2.size()); + + ASSERT_EQ_U(pattern2.local_size(), pattern2.local_capacity()); //assumed balanced extents + ASSERT_EQ_U(pattern2.size(), pattern2.capacity()); + + //test .at + ASSERT_EQ_U(pattern2.at(coord), 0); + + //test .unit_at, .local, .local_index, local_at, .global, .global_index, , global_at, .is_local + auto unit_at_coord = pattern2.unit_at(coord); + auto l_pos = pattern2.local(coord); + auto l_index = pattern2.local_index(coord); + auto g_index = pattern2.global_index(unit_at_coord, l_pos.coords); // unit_at({0, 0}) is unit 0 + + ASSERT_EQ_U(pattern2.local_at(l_pos.coords), l_index.index); + + ASSERT_EQ_U(pattern2.global(unit_at_coord, l_pos.coords), coord); + ASSERT_EQ_U(pattern2.global_at(coord), g_index); + + ASSERT_EQ_U(pattern2.is_local(g_index), unit_id == 0); + + //test .block, .block_at, .local_block, .has_local_elements + auto g_blockid = pattern2.block_at(coord); + //auto l_blockid = pattern2.local_block_at(coord); + + auto g_view = pattern2.block(g_blockid); + //auto l_view = pattern2.local_block(l_blockid.index); + + // member function .includes_index is still currently TODO, it is not implemented yet in CartesianIndexSpace class + //ASSERT_EQ_U(pattern2.has_local_elements(static_cast(0), static_cast(0), unit_at_coord, g_view), unit_id == 0); + + //test BlockSpec, Local BlockSpec, .blocksize, .max_blocksize + auto block_spec = pattern2.blockspec(); + auto l_block_spec = pattern2.local_blockspec(); + + int nblocks = static_cast(pow(num_units, dims)); + + ASSERT_EQ_U(block_spec.size(), nblocks); + ASSERT_EQ_U(l_block_spec.size(), nblocks / num_units); //assumed balanced extents + + int blocksize = 1; + for (int dim = 0; dim < dims; dim++) + blocksize *= pattern2.blocksize(dim); + ASSERT_EQ_U(blocksize, pattern2.max_blocksize()); + + //test .coords + IndexType idx = 0; + ASSERT_EQ_U(pattern2.coords(idx), coord); + + + //test .sizespec, .teamspec + auto size_spec = pattern2.sizespec(); + auto team_spec = pattern2.teamspec(); + + ASSERT_EQ_U(size_spec.extent(0), array_size); + ASSERT_EQ_U(team_spec.size(), num_units); +} + + +#endif // DASH__TEST__PATTERN_TEST_H_ diff --git a/dash/test/pattern/SeqTilePatternTest.cc b/dash/test/pattern/SeqTilePatternTest.cc index 6c456c714..ce045b25a 100644 --- a/dash/test/pattern/SeqTilePatternTest.cc +++ b/dash/test/pattern/SeqTilePatternTest.cc @@ -91,3 +91,29 @@ TEST_F(SeqTilePatternTest, Distribute2DimTile) } } } + +TEST_F(SeqTilePatternTest, SeqTilePattern1DFunctionalCheck) +{ + auto num_units = dash::Team::All().size(); + + //series of default test + typedef dash::SeqTilePattern<1> pattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i); + + // series of unsigned COLUMN MAJOR test + typedef dash::SeqTilePattern<1, dash::COL_MAJOR, unsigned long> upattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i); +} + +TEST_F(SeqTilePatternTest, SeqTilePatternFunctionalCheck) +{ + auto num_units = dash::Team::All().size(); + + //series of default 2D test + typedef dash::SeqTilePattern<2> pattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i, i); + + // series of unsigned COLUMN MAJOR 2D test + typedef dash::SeqTilePattern<2, dash::COL_MAJOR, unsigned long> upattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i, i); +} diff --git a/dash/test/pattern/SeqTilePatternTest.h b/dash/test/pattern/SeqTilePatternTest.h index 50446400d..cbddc0d9c 100644 --- a/dash/test/pattern/SeqTilePatternTest.h +++ b/dash/test/pattern/SeqTilePatternTest.h @@ -2,6 +2,7 @@ #define DASH__TEST__SEQ_TILE_PATTERN_TEST_H_ #include "../TestBase.h" +#include "PatternTest.h" /** * Test fixture for class dash::Pattern diff --git a/dash/test/pattern/ShiftTilePatternTest.cc b/dash/test/pattern/ShiftTilePatternTest.cc index 00e47c2fc..30f3c8dae 100644 --- a/dash/test/pattern/ShiftTilePatternTest.cc +++ b/dash/test/pattern/ShiftTilePatternTest.cc @@ -304,3 +304,29 @@ TEST_F(ShiftTilePatternTest, Tile2DimTeam1Dim) DASH_LOG_DEBUG_VAR("ShiftTilePatternTest.Tile2DimTeam1Dim", row_units); } } + +TEST_F(ShiftTilePatternTest, ShiftTilePattern1DFunctionalCheck) +{ + auto num_units = dash::Team::All().size(); + + //series of default test + typedef dash::ShiftTilePattern<1> pattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i); + + // series of unsigned COLUMN MAJOR test + typedef dash::ShiftTilePattern<1, dash::COL_MAJOR, unsigned long> upattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i); +} + +TEST_F(ShiftTilePatternTest, ShiftTilePatternFunctionalCheck) +{ + auto num_units = dash::Team::All().size(); + + //series of default 2D test + typedef dash::ShiftTilePattern<2> pattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i, i); + + // series of unsigned COLUMN MAJOR 2D test + typedef dash::ShiftTilePattern<2, dash::COL_MAJOR, unsigned long> upattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i, i); +} diff --git a/dash/test/pattern/ShiftTilePatternTest.h b/dash/test/pattern/ShiftTilePatternTest.h index b53f8736d..602cb46b6 100644 --- a/dash/test/pattern/ShiftTilePatternTest.h +++ b/dash/test/pattern/ShiftTilePatternTest.h @@ -2,6 +2,7 @@ #define DASH__TEST__SHIFT_TILE_PATTERN_TEST_H_ #include "../TestBase.h" +#include "PatternTest.h" /** * Test fixture for class dash::ShiftTilePattern diff --git a/dash/test/pattern/TilePatternTest.cc b/dash/test/pattern/TilePatternTest.cc index 081ac1119..7638b6eab 100644 --- a/dash/test/pattern/TilePatternTest.cc +++ b/dash/test/pattern/TilePatternTest.cc @@ -301,17 +301,28 @@ TEST_F(TilePatternTest, Tile4Dim) } } -TEST_F(TilePatternTest, TileFunctionalCheck) +TEST_F(TilePatternTest, TilePattern1DFunctionalCheck) { - const size_t dims = 1; - using pattern_t = typename dash::TilePattern; - using IndexType = typename pattern_t::index_type; + auto num_units = dash::Team::All().size(); + + //series of default test + typedef dash::TilePattern<1> pattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i); + + // series of unsigned COLUMN MAJOR test + typedef dash::TilePattern<1, dash::COL_MAJOR, unsigned long> upattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i); +} + +TEST_F(TilePatternTest, TilePatternFunctionalCheck) +{ + auto num_units = dash::Team::All().size(); - // create simple TilePattern 1D BLOCKED for functional checks, now the test just checks for issue 692, unfinished - size_t array_size = 100; - pattern_t pattern(array_size, dash::BLOCKED); + //series of default 2D test + typedef dash::TilePattern<2> pattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i, i); - // tested local_blockspec() - const auto &lblockspec = pattern.local_blockspec(); - ASSERT_EQ_U(dims, lblockspec.size()); + // series of unsigned COLUMN MAJOR 2D test + typedef dash::TilePattern<2, dash::COL_MAJOR, unsigned long> upattern_t; + for (size_t i = num_units; i <= 1000 * num_units; i *= 10) test_pattern(i, i); } \ No newline at end of file diff --git a/dash/test/pattern/TilePatternTest.h b/dash/test/pattern/TilePatternTest.h index 3dfc72dc7..3df59dc0b 100644 --- a/dash/test/pattern/TilePatternTest.h +++ b/dash/test/pattern/TilePatternTest.h @@ -2,6 +2,7 @@ #define DASH__TEST__TILE_PATTERN_TEST_H_ #include "../TestBase.h" +#include "PatternTest.h" /** * Test fixture for class dash::Pattern