Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes incorrect team in Pattern/Array by calling the wrong ctor unintended #354

Merged
merged 10 commits into from
Apr 12, 2017
112 changes: 93 additions & 19 deletions dash/include/dash/pattern/BlockPattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class BlockPattern
} local_coords_t;

private:
PatternArguments_t _arguments;
/// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of
/// all dimensions. Defaults to BLOCKED in first, and NONE in higher
/// dimensions
Expand Down Expand Up @@ -187,18 +186,65 @@ class BlockPattern
/// elements) in every dimension followed by optional distribution
/// types.
Args && ... args)
: _arguments(arg, args...),
_distspec(_arguments.distspec()),
_team(&_arguments.team()),
_teamspec(_arguments.teamspec()),
: BlockPattern(PatternArguments_t(arg, args...))
{
DASH_LOG_TRACE("BlockPattern()", "Constructor with argument list");
initialize_local_range();
DASH_LOG_TRACE("BlockPattern()", "BlockPattern initialized");
}

/**
* Constructor, initializes a pattern from explicit instances of
* \c SizeSpec, \c DistributionSpec, \c TeamSpec and a \c Team.
*
* Examples:
*
* \code
* // A 5x3 rectangle with blocked distribution in the first dimension
* Pattern p1(SizeSpec<2>(5,3),
* DistributionSpec<2>(BLOCKED, NONE),
* // How teams are arranged in all dimensions, default is
* // an extent of all units in first, and 1 in all higher
* // dimensions:
* TeamSpec<2>(dash::Team::All(), 1),
* // The team containing the units to which the pattern
* // maps the global indices. Defaults to all all units:
* dash::Team::All());
* // Same as
* Pattern p1(5,3, BLOCKED);
* // Same as
* Pattern p1(SizeSpec<2>(5,3),
* DistributionSpec<2>(BLOCKED, NONE));
* // Same as
* Pattern p1(SizeSpec<2>(5,3),
* DistributionSpec<2>(BLOCKED, NONE),
* TeamSpec<2>(dash::Team::All(), 1));
* \endcode
*/
BlockPattern(
/// Pattern size (extent, number of elements) in every dimension
const SizeSpec_t & sizespec,
/// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE) of
/// all dimensions.
const DistributionSpec_t & dist,
/// Cartesian arrangement of units within the team
const TeamSpec_t & teamspec,
/// Team containing units to which this pattern maps its elements
dash::Team & team = dash::Team::All())
: _distspec(dist),
_team(&team),
_teamspec(
teamspec,
_distspec,
*_team),
_nunits(_teamspec.size()),
_memory_layout(_arguments.sizespec().extents()),
_memory_layout(sizespec.extents()),
_blocksize_spec(initialize_blocksizespec(
_arguments.sizespec(),
sizespec,
_distspec,
_teamspec)),
_blockspec(initialize_blockspec(
_arguments.sizespec(),
sizespec,
_distspec,
_blocksize_spec,
_teamspec)),
Expand All @@ -212,21 +258,27 @@ class BlockPattern
_local_memory_layout)),
_local_capacity(initialize_local_capacity())
{
DASH_LOG_TRACE("BlockPattern()", "Constructor with argument list");
DASH_LOG_TRACE("BlockPattern()", "(sizespec, dist, teamspec, team)");
initialize_local_range();
DASH_LOG_TRACE("BlockPattern()", "BlockPattern initialized");
}

/**
* Constructor, initializes a pattern from explicit instances of
* \c SizeSpec, \c DistributionSpec, \c TeamSpec and a \c Team.
* \c SizeSpec, \c DistributionSpec and a \c Team.
*
* Examples:
*
* \code
* // A 5x3 rectangle with blocked distribution in the first dimension
* Pattern p1(SizeSpec<2>(5,3),
* DistributionSpec<2>(BLOCKED, NONE),
* // The team containing the units to which the pattern
* // maps the global indices. Defaults to all all units:
* dash::Team::All());
* // Same as
* Pattern p1(SizeSpec<2>(5,3),
* DistributionSpec<2>(BLOCKED, NONE),
* // How teams are arranged in all dimensions, default is
* // an extent of all units in first, and 1 in all higher
* // dimensions:
Expand All @@ -251,17 +303,12 @@ class BlockPattern
/// 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(),
/// Cartesian arrangement of units within the team
const TeamSpec_t & teamspec = TeamSpec_t::TeamSpec(),
const DistributionSpec_t & dist = DistributionSpec_t(),
/// Team containing units to which this pattern maps its elements
dash::Team & team = dash::Team::All())
Team & team = dash::Team::All())
: _distspec(dist),
_team(&team),
_teamspec(
teamspec,
_distspec,
*_team),
_teamspec(_distspec, *_team),
_nunits(_teamspec.size()),
_memory_layout(sizespec.extents()),
_blocksize_spec(initialize_blocksizespec(
Expand All @@ -283,7 +330,7 @@ class BlockPattern
_local_memory_layout)),
_local_capacity(initialize_local_capacity())
{
DASH_LOG_TRACE("BlockPattern()", "(sizespec, dist, teamspec, team)");
DASH_LOG_TRACE("BlockPattern()", "(sizespec, dist, team)");
initialize_local_range();
DASH_LOG_TRACE("BlockPattern()", "BlockPattern initialized");
}
Expand Down Expand Up @@ -1354,6 +1401,33 @@ class BlockPattern
}

private:

BlockPattern(const PatternArguments_t & arguments)
: _distspec(arguments.distspec()),
_team(&arguments.team()),
_teamspec(arguments.teamspec()),
_nunits(_teamspec.size()),
_memory_layout(arguments.sizespec().extents()),
_blocksize_spec(initialize_blocksizespec(
arguments.sizespec(),
_distspec,
_teamspec)),
_blockspec(initialize_blockspec(
arguments.sizespec(),
_distspec,
_blocksize_spec,
_teamspec)),
_local_memory_layout(
initialize_local_extents(_team->myid())),
_local_blockspec(initialize_local_blockspec(
_blockspec,
_blocksize_spec,
_distspec,
_teamspec,
_local_memory_layout)),
_local_capacity(initialize_local_capacity())
{}

/**
* Initialize block size specs from memory layout, team spec and
* distribution spec.
Expand Down
96 changes: 79 additions & 17 deletions dash/include/dash/pattern/BlockPattern1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ class BlockPattern<1, Arrangement, IndexType>
} local_coords_t;

private:
PatternArguments_t _arguments;
/// Extent of the linear pattern.
SizeType _size = 0;
/// Global memory layout of the pattern.
Expand Down Expand Up @@ -156,7 +155,7 @@ class BlockPattern<1, Arrangement, IndexType>
* \endcode
*/
template<typename ... Args>
constexpr BlockPattern(
BlockPattern(
/// Argument list consisting of the pattern size (extent, number of
/// elements) in every dimension followed by optional distribution
/// types.
Expand All @@ -165,12 +164,51 @@ class BlockPattern<1, Arrangement, IndexType>
/// elements) in every dimension followed by optional distribution
/// types.
Args && ... args)
: _arguments(arg, args...),
_size(_arguments.sizespec().size()),
: BlockPattern(PatternArguments_t(arg, args...))
{ }

/**
* Constructor, initializes a pattern from explicit instances of
* \c SizeSpec, \c DistributionSpec, \c TeamSpec and a \c Team.
*
* Examples:
*
* \code
* // 500 elements with blocked distribution:
* Pattern p1(SizeSpec<1>(500),
* DistributionSpec<1>(BLOCKED),
* TeamSpec<1>(dash::Team::All()),
* // The team containing the units to which the pattern
* // maps the global indices. Defaults to all all units:
* dash::Team::All());
* // Same as
* Pattern p1(500, BLOCKED);
* // Same as
* Pattern p1(SizeSpec<1>(500),
* DistributionSpec<1>(BLOCKED));
* // Same as
* Pattern p1(SizeSpec<1>(500),
* DistributionSpec<1>(BLOCKED),
* TeamSpec<1>(dash::Team::All()));
* \endcode
*/
BlockPattern(
/// Pattern size (extent, number of elements) in every dimension
const SizeSpec_t sizespec,
/// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC or NONE).
const DistributionSpec_t dist,
/// Cartesian arrangement of units within the team
const TeamSpec_t teamspec,
/// Team containing units to which this pattern maps its elements
dash::Team & team = dash::Team::All())
: _size(sizespec.size()),
_memory_layout(std::array<SizeType, 1> {{ _size }}),
_distspec(_arguments.distspec()),
_team(&_arguments.team()),
_teamspec(_arguments.teamspec()),
_distspec(dist),
_team(&team),
_teamspec(
teamspec,
_distspec,
*_team),
_nunits(_team->size()),
_blocksize(initialize_blocksize(
_size,
Expand All @@ -195,7 +233,7 @@ class BlockPattern<1, Arrangement, IndexType>

/**
* Constructor, initializes a pattern from explicit instances of
* \c SizeSpec, \c DistributionSpec, \c TeamSpec and a \c Team.
* \c SizeSpec, \c DistributionSpec and a \c Team.
*
* Examples:
*
Expand All @@ -221,21 +259,16 @@ class BlockPattern<1, Arrangement, IndexType>
BlockPattern(
/// Pattern size (extent, number of elements) in every dimension
const SizeSpec_t sizespec,
/// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC or NONE).
/// Distribution type (BLOCKED, CYCLIC, BLOCKCYCLIC, TILE or NONE).
/// Defaults to BLOCKED.
const DistributionSpec_t dist = DistributionSpec_t(),
/// Cartesian arrangement of units within the team
const TeamSpec_t teamspec = TeamSpec_t::TeamSpec(),
const DistributionSpec_t dist = DistributionSpec_t(),
/// Team containing units to which this pattern maps its elements
dash::Team & team = dash::Team::All())
Team & team = dash::Team::All())
: _size(sizespec.size()),
_memory_layout(std::array<SizeType, 1> {{ _size }}),
_distspec(dist),
_team(&team),
_teamspec(
teamspec,
_distspec,
*_team),
_teamspec(_distspec, *_team),
_nunits(_team->size()),
_blocksize(initialize_blocksize(
_size,
Expand Down Expand Up @@ -1068,6 +1101,35 @@ class BlockPattern<1, Arrangement, IndexType>
}

private:

BlockPattern(const PatternArguments_t & arguments)
: _size(arguments.sizespec().size()),
_memory_layout(std::array<SizeType, 1> {{ _size }}),
_distspec(arguments.distspec()),
_team(&arguments.team()),
_teamspec(arguments.teamspec()),
_nunits(_team->size()),
_blocksize(initialize_blocksize(
_size,
_distspec,
_nunits)),
_nblocks(initialize_num_blocks(
_size,
_blocksize,
_nunits)),
_local_size(
initialize_local_extent(_team->myid())),
_local_memory_layout(std::array<SizeType, 1> {{ _local_size }}),
_nlblocks(initialize_num_local_blocks(
_nblocks,
_blocksize,
_distspec,
_nunits,
_local_size)),
_local_capacity(initialize_local_capacity()),
_lbegin_lend(initialize_local_range(_local_size))
{}

/**
* Initialize block size specs from memory layout, team spec and
* distribution spec.
Expand Down
Loading