Skip to content

Commit

Permalink
#1544: Add unit test for Collection with indicies over 3 dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobDomagala committed Jun 6, 2022
1 parent 31a7e33 commit fe708cb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/vt/topos/mapping/dense/dense.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ using IdxPtr = Index*;
template <typename T = IdxBase> using Idx1DPtr = IdxType1D<T>*;
template <typename T = IdxBase> using Idx2DPtr = IdxType2D<T>*;
template <typename T = IdxBase> using Idx3DPtr = IdxType3D<T>*;
template <typename T, typename N> using IdxNDPtr = vt::index::IdxType<T, N>*;

template <typename Idx, index::NumDimensionsType ndim>
NodeType denseBlockMap(IdxPtr<Idx> idx, IdxPtr<Idx> max_idx, NodeType nnodes);
Expand All @@ -84,6 +85,8 @@ template <typename T = IdxBase>
NodeType defaultDenseIndex2DMap(Idx2DPtr<T> idx, Idx2DPtr<T> max, NodeType n);
template <typename T = IdxBase>
NodeType defaultDenseIndex3DMap(Idx3DPtr<T> idx, Idx3DPtr<T> max, NodeType n);
template <typename T, typename N>
NodeType defaultDenseIndex3DMap(IdxNDPtr<T,N> idx, IdxNDPtr<T,N> max, NodeType n);

template <typename T = IdxBase>
NodeType dense1DRoundRobinMap( Idx1DPtr<T> idx, Idx1DPtr<T> max, NodeType n);
Expand Down
18 changes: 13 additions & 5 deletions tests/unit/collection/test_collection_construct_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,25 @@ struct ConstructParams {
TYPED_TEST_SUITE_P(TestConstruct);
TYPED_TEST_SUITE_P(TestConstructDist);

template <typename ColT, uint8_t N>
typename ColT::IndexType CreateRange(typename ColT::IndexType::DenseIndexType range) {
std::array<typename ColT::IndexType::DenseIndexType, N> arr;
std::fill(arr.begin(), arr.end(), range);

return arr;
}

template<typename ColType>
void test_construct_1(std::string const& label) {
using MsgType = typename ColType::MsgType;

auto const& this_node = theContext()->getNode();
if (this_node == 0) {
auto const& col_size = 32;
auto rng = TestIndex(col_size);

auto rng = CreateRange<ColType, ColType::IndexType::ndims()>(col_size);
auto proxy = ConstructParams<ColType>::construct(label, rng);

proxy.template broadcast<
MsgType,
ConstructHandlers::handler<ColType,MsgType>
Expand All @@ -129,10 +139,8 @@ void test_construct_distributed_1() {
using MsgType = typename ColType::MsgType;

auto const& col_size = 32;
auto rng = TestIndex(col_size);
auto proxy = ConstructParams<ColType>::constructCollective(
rng, "test_construct_distributed_1"
);
auto rng = CreateRange<ColType, ColType::IndexType::ndims()>(col_size);
auto proxy = ConstructParams<ColType>::constructCollective(rng, "test_construct_distributed_1");
proxy.template broadcast<
MsgType,
ConstructHandlers::handler<ColType,MsgType>
Expand Down
22 changes: 16 additions & 6 deletions tests/unit/collection/test_construct.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,26 @@
namespace vt { namespace tests { namespace unit {

namespace default_ {
struct ColMsg;
struct TestCol : Collection<TestCol,vt::Index1D> {
using MsgType = ColMsg;
struct Col1DMsg;
struct Col4DMsg;

struct TestCol1D : Collection<TestCol1D, vt::Index1D> {
using MsgType = Col1DMsg;
};

struct TestCol4D : Collection<TestCol4D, vt::IndexND<4>> {
using MsgType = Col4DMsg;
};

struct ColMsg : CollectionMessage<TestCol> { };
struct Col1DMsg : CollectionMessage<TestCol1D> { };
struct Col4DMsg : CollectionMessage<TestCol4D> { };
} /* end namespace default_ */

using CollectionTestTypes = testing::Types<default_::TestCol>;
using CollectionTestDistTypes = testing::Types<default_::TestCol>;
using CollectionTestTypes =
testing::Types<default_::TestCol1D, default_::TestCol4D>;

using CollectionTestDistTypes =
testing::Types<default_::TestCol1D, default_::TestCol4D>;

TYPED_TEST_P(TestConstruct, test_construct_basic_1) {
test_construct_1<TypeParam>("test_construct_basic_1");
Expand Down
1 change: 1 addition & 0 deletions tests/unit/collection/test_construct_no_idx.extended.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ struct ColMsg;
struct TestCol : Collection<TestCol,vt::Index1D> {
using MsgType = ColMsg;
};

struct ColMsg : CollectionMessage<TestCol> {};
} /* end namespace multi_param_no_idx_ */

Expand Down

0 comments on commit fe708cb

Please sign in to comment.