diff --git a/examples/collection/4d_collection.cc b/examples/collection/4d_collection.cc new file mode 100644 index 0000000000..c3d66ba4e5 --- /dev/null +++ b/examples/collection/4d_collection.cc @@ -0,0 +1,75 @@ +/* +//@HEADER +// ***************************************************************************** +// +// 4d_collection.cc +// DARMA/vt => Virtual Transport +// +// Copyright 2019-2024 National Technology & Engineering Solutions of Sandia, LLC +// (NTESS). Under the terms of Contract DE-NA0003525 with NTESS, the U.S. +// Government retains certain rights in this software. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// +// * Neither the name of the copyright holder nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// Questions? Contact darma@sandia.gov +// +// ***************************************************************************** +//@HEADER +*/ + +#include + +struct Example4D : vt::Collection { + + Example4D() = default; + + void hello() { + fmt::print( + "{}: Hello from Example4D: {}\n", vt::theContext()->getNode(), getIndex() + ); + } + +}; + +int main(int argc, char** argv) { + vt::initialize(argc, argv); + + auto range = vt::Index4D(2,4,3,2); + + auto proxy = vt::makeCollection("4d_collection") + .bounds(range) + .bulkInsert() + .wait(); + + if (vt::theContext()->getNode() == 0) { + proxy.broadcast<&Example4D::hello>(); + } + + + vt::finalize(); + return 0; +} diff --git a/examples/collection/CMakeLists.txt b/examples/collection/CMakeLists.txt index 5e959292e0..7daf1df4d4 100644 --- a/examples/collection/CMakeLists.txt +++ b/examples/collection/CMakeLists.txt @@ -10,6 +10,7 @@ set( insertable_collection reduce_integral transpose + 4d_collection ) foreach(EXAMPLE_NAME ${COLLECTION_EXAMPLES}) diff --git a/src/vt/topos/index/dense/dense_array.h b/src/vt/topos/index/dense/dense_array.h index 88180268b2..21f02d40e6 100644 --- a/src/vt/topos/index/dense/dense_array.h +++ b/src/vt/topos/index/dense/dense_array.h @@ -125,7 +125,7 @@ struct DenseIndexArray : BaseIndex, serialization::ByteCopyTrait { DenseIndexArrayType operator+(DenseIndexArrayType const& other) const; DenseIndexArrayType operator-(DenseIndexArrayType const& other) const; - // special accessors (x,y,z) enabled depending on the number of dimensions + // special accessors (x,y,z,u,v,w) enabled depending on the number of dimensions template < typename T = void, typename = typename std::enable_if= 1, T>::type > @@ -141,6 +141,21 @@ struct DenseIndexArray : BaseIndex, serialization::ByteCopyTrait { > IndexType z() const; + template < + typename T = void, typename = typename std::enable_if= 4, T>::type + > + IndexType u() const; + + template < + typename T = void, typename = typename std::enable_if= 5, T>::type + > + IndexType v() const; + + template < + typename T = void, typename = typename std::enable_if= 6, T>::type + > + IndexType w() const; + template friend std::ostream& operator<<( std::ostream& os, DenseIndexArray const& idx diff --git a/src/vt/topos/index/dense/dense_array.impl.h b/src/vt/topos/index/dense/dense_array.impl.h index 61b6f1cdf6..39593786bc 100644 --- a/src/vt/topos/index/dense/dense_array.impl.h +++ b/src/vt/topos/index/dense/dense_array.impl.h @@ -231,7 +231,7 @@ DenseIndexArray::operator-(DenseIndexArrayType const& other) co return val; } -// special accessors (x,y,z) enabled depending on the number of dimensions +// special accessors (x,y,z,u,v,w) enabled depending on the number of dimensions template template IndexType DenseIndexArray::x() const { @@ -250,6 +250,24 @@ IndexType DenseIndexArray::z() const { return dims[2]; } +template +template +IndexType DenseIndexArray::u() const { + return dims[3]; +} + +template +template +IndexType DenseIndexArray::v() const { + return dims[4]; +} + +template +template +IndexType DenseIndexArray::w() const { + return dims[5]; +} + template std::ostream& operator<<( std::ostream& os, ::vt::index::DenseIndexArray const& idx diff --git a/src/vt/topos/index/index.h b/src/vt/topos/index/index.h index aa68e41235..f9ed4707c9 100644 --- a/src/vt/topos/index/index.h +++ b/src/vt/topos/index/index.h @@ -59,11 +59,17 @@ using IdxBase = int32_t; template using Index1D = DenseIndexArray; template using Index2D = DenseIndexArray; template using Index3D = DenseIndexArray; +template using Index4D = DenseIndexArray; +template using Index5D = DenseIndexArray; +template using Index6D = DenseIndexArray; template using IdxType = DenseIndexArray; static_assert(IndexTraits>::is_index, "Does not conform"); static_assert(IndexTraits>::is_index, "Does not conform"); static_assert(IndexTraits>::is_index, "Does not conform"); +static_assert(IndexTraits>::is_index, "Does not conform"); +static_assert(IndexTraits>::is_index, "Does not conform"); +static_assert(IndexTraits>::is_index, "Does not conform"); }} // end namespace vt::index @@ -76,6 +82,9 @@ using IdxBase = index::IdxBase; using Index1D = index::Index1D; using Index2D = index::Index2D; using Index3D = index::Index3D; +using Index4D = index::Index4D; +using Index5D = index::Index5D; +using Index6D = index::Index6D; template using IndexND = index::IdxType; @@ -83,6 +92,9 @@ template using IdxType = index::IdxType; template using IdxType1D = index::Index1D; template using IdxType2D = index::Index2D; template using IdxType3D = index::Index3D; +template using IdxType4D = index::Index4D; +template using IdxType5D = index::Index5D; +template using IdxType6D = index::Index6D; } // end namespace vt