From f3c6bf5c212125c58cd78a5f2ebab83ed445c6f5 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 16 Apr 2020 20:17:40 -0600 Subject: [PATCH 01/88] #781: Migratable: de-template --- src/vt/vrt/collection/balance/elm_stats.h | 1 - .../vrt/collection/migrate/manager_migrate_attorney.h | 2 +- src/vt/vrt/collection/types/indexable.h | 2 +- src/vt/vrt/collection/types/indexable.impl.h | 4 ++-- src/vt/vrt/collection/types/migratable.cc | 7 +++++++ src/vt/vrt/collection/types/migratable.fwd.h | 1 - src/vt/vrt/collection/types/migratable.h | 1 - src/vt/vrt/collection/types/migratable.impl.h | 11 +---------- 8 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/vt/vrt/collection/balance/elm_stats.h b/src/vt/vrt/collection/balance/elm_stats.h index d1a9503142..1923ee1203 100644 --- a/src/vt/vrt/collection/balance/elm_stats.h +++ b/src/vt/vrt/collection/balance/elm_stats.h @@ -106,7 +106,6 @@ struct ElementStats { template static void syncNextPhase(PhaseMsg* msg, ColT* col); - template friend struct collection::Migratable; protected: diff --git a/src/vt/vrt/collection/migrate/manager_migrate_attorney.h b/src/vt/vrt/collection/migrate/manager_migrate_attorney.h index 1d33f8d67c..9fdd4cc37c 100644 --- a/src/vt/vrt/collection/migrate/manager_migrate_attorney.h +++ b/src/vt/vrt/collection/migrate/manager_migrate_attorney.h @@ -66,7 +66,7 @@ struct CollectionElmAttorney { friend struct CollectionBase; friend struct MigrateHandlers; - friend struct Migratable; + friend struct Migratable; private: static void migrate( diff --git a/src/vt/vrt/collection/types/indexable.h b/src/vt/vrt/collection/types/indexable.h index a86899dc32..6b17f4b6c9 100644 --- a/src/vt/vrt/collection/types/indexable.h +++ b/src/vt/vrt/collection/types/indexable.h @@ -54,7 +54,7 @@ namespace vt { namespace vrt { namespace collection { template -struct Indexable : Migratable { +struct Indexable : Migratable { explicit Indexable(IndexT&& in_index); Indexable() = default; diff --git a/src/vt/vrt/collection/types/indexable.impl.h b/src/vt/vrt/collection/types/indexable.impl.h index 2c8841bec9..69d5a2fbc4 100644 --- a/src/vt/vrt/collection/types/indexable.impl.h +++ b/src/vt/vrt/collection/types/indexable.impl.h @@ -57,7 +57,7 @@ namespace vt { namespace vrt { namespace collection { template Indexable::Indexable(IndexT&& in_index) - : Migratable(), + : Migratable(), index_(std::move(in_index)), set_index_(true) { } @@ -77,7 +77,7 @@ IndexT const& Indexable::getIndex() const { template template void Indexable::serialize(SerializerT& s) { - Migratable::serialize(s); + Migratable::serialize(s); s | set_index_; s | index_; } diff --git a/src/vt/vrt/collection/types/migratable.cc b/src/vt/vrt/collection/types/migratable.cc index 98ab81c2d2..513979852c 100644 --- a/src/vt/vrt/collection/types/migratable.cc +++ b/src/vt/vrt/collection/types/migratable.cc @@ -49,4 +49,11 @@ namespace vt { namespace vrt { namespace collection { +/*virtual*/ void Migratable::destroy() { + debug_print( + vrt_coll, node, + "Migratable::destroy(): this={}\n", print_ptr(this) + ); +} + }}} /* end namespace vt::vrt::collection */ diff --git a/src/vt/vrt/collection/types/migratable.fwd.h b/src/vt/vrt/collection/types/migratable.fwd.h index 9a500fd80c..e4623e1c2b 100644 --- a/src/vt/vrt/collection/types/migratable.fwd.h +++ b/src/vt/vrt/collection/types/migratable.fwd.h @@ -50,7 +50,6 @@ namespace vt { namespace vrt { namespace collection { -template struct Migratable; }}} /* end namespace vt::vrt::collection */ diff --git a/src/vt/vrt/collection/types/migratable.h b/src/vt/vrt/collection/types/migratable.h index f43fa6c6b9..099062bbd8 100644 --- a/src/vt/vrt/collection/types/migratable.h +++ b/src/vt/vrt/collection/types/migratable.h @@ -56,7 +56,6 @@ namespace vt { namespace vrt { namespace collection { -template struct Migratable : MigrateHookBase { Migratable() diff --git a/src/vt/vrt/collection/types/migratable.impl.h b/src/vt/vrt/collection/types/migratable.impl.h index 2063b8f3c1..a050bfc9fa 100644 --- a/src/vt/vrt/collection/types/migratable.impl.h +++ b/src/vt/vrt/collection/types/migratable.impl.h @@ -50,23 +50,14 @@ namespace vt { namespace vrt { namespace collection { -template template -void Migratable::serialize(Serializer& s) { +void Migratable::serialize(Serializer& s) { MigrateHookBase::serialize(s); s | stats_; s | stats_elm_id_; s | temp_elm_id_; } -template -/*virtual*/ void Migratable::destroy() { - debug_print( - vrt_coll, node, - "Migratable::destroy(): this={}\n", print_ptr(this) - ); -} - }}} /* end namespace vt::vrt::collection */ #endif /*INCLUDED_VRT_COLLECTION_TYPES_MIGRATABLE_IMPL_H*/ From 302a7deeb85be5a6f8a100d9cda432f3b3a5dc31 Mon Sep 17 00:00:00 2001 From: Phil Miller Date: Thu, 16 Apr 2020 20:23:00 -0600 Subject: [PATCH 02/88] #781: Indexable: de-template over ColT collection element type --- src/vt/vrt/collection/types/base.h | 2 +- src/vt/vrt/collection/types/base.impl.h | 4 ++-- src/vt/vrt/collection/types/indexable.h | 2 +- src/vt/vrt/collection/types/indexable.impl.h | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/vt/vrt/collection/types/base.h b/src/vt/vrt/collection/types/base.h index 8a8f9c7caa..be37002dd8 100644 --- a/src/vt/vrt/collection/types/base.h +++ b/src/vt/vrt/collection/types/base.h @@ -58,7 +58,7 @@ namespace vt { namespace vrt { namespace collection { template -struct CollectionBase : Indexable { +struct CollectionBase : Indexable { using ProxyType = VirtualElmProxyType; using CollectionProxyType = CollectionProxy; using IndexType = IndexT; diff --git a/src/vt/vrt/collection/types/base.impl.h b/src/vt/vrt/collection/types/base.impl.h index a30e8f66f7..e927eb9a53 100644 --- a/src/vt/vrt/collection/types/base.impl.h +++ b/src/vt/vrt/collection/types/base.impl.h @@ -59,7 +59,7 @@ template CollectionBase::CollectionBase( bool const static_size, bool const elms_fixed, VirtualElmCountType const num -) : Indexable(), +) : Indexable(), numElems_(num), hasStaticSize_(static_size), elmsFixedAtCreation_(elms_fixed) @@ -106,7 +106,7 @@ template template template void CollectionBase::serialize(Serializer& s) { - Indexable::serialize(s); + Indexable::serialize(s); s | hasStaticSize_; s | elmsFixedAtCreation_; s | cur_bcast_epoch_; diff --git a/src/vt/vrt/collection/types/indexable.h b/src/vt/vrt/collection/types/indexable.h index 6b17f4b6c9..ca5ff57424 100644 --- a/src/vt/vrt/collection/types/indexable.h +++ b/src/vt/vrt/collection/types/indexable.h @@ -53,7 +53,7 @@ namespace vt { namespace vrt { namespace collection { -template +template struct Indexable : Migratable { explicit Indexable(IndexT&& in_index); diff --git a/src/vt/vrt/collection/types/indexable.impl.h b/src/vt/vrt/collection/types/indexable.impl.h index 69d5a2fbc4..899bbef091 100644 --- a/src/vt/vrt/collection/types/indexable.impl.h +++ b/src/vt/vrt/collection/types/indexable.impl.h @@ -55,16 +55,16 @@ namespace vt { namespace vrt { namespace collection { -template -Indexable::Indexable(IndexT&& in_index) +template +Indexable::Indexable(IndexT&& in_index) : Migratable(), index_(std::move(in_index)), set_index_(true) { } -template -IndexT const& Indexable::getIndex() const { +template +IndexT const& Indexable::getIndex() const { if (!set_index_) { auto ctx_idx = theCollection()->queryIndexContext(); vtAssertExpr(ctx_idx != nullptr); @@ -74,16 +74,16 @@ IndexT const& Indexable::getIndex() const { } } -template +template template -void Indexable::serialize(SerializerT& s) { +void Indexable::serialize(SerializerT& s) { Migratable::serialize(s); s | set_index_; s | index_; } -template -void Indexable::setIndex(IndexT const& in_index) { +template +void Indexable::setIndex(IndexT const& in_index) { // Set the field and then indicate that the `index_` field is now valid with // `set_index_` index_ = in_index; From 43d65c1cb29f8c4f9d76ad2b48066b6be320456e Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 29 Apr 2020 16:15:17 -0700 Subject: [PATCH 03/88] #797: worker: remove unused variable --- src/vt/worker/worker_stdthread.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vt/worker/worker_stdthread.h b/src/vt/worker/worker_stdthread.h index 0e5fd60c4a..db54496bf5 100644 --- a/src/vt/worker/worker_stdthread.h +++ b/src/vt/worker/worker_stdthread.h @@ -85,7 +85,6 @@ struct StdThreadWorker { private: std::atomic should_terminate_ = {false}; WorkerIDType worker_id_ = no_worker_id; - WorkerCountType num_thds_ = no_workers; WorkUnitContainerType work_queue_; ThreadPtrType thd_ = nullptr; WorkerFinishedFnType finished_fn_ = nullptr; From 84b96632c4e01dd4cd7c4d830d25c949058ada0c Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 29 Apr 2020 16:29:45 -0700 Subject: [PATCH 04/88] #797: worker: remove num_thds from constructor --- src/vt/worker/worker_stdthread.cc | 5 ++--- src/vt/worker/worker_stdthread.h | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/vt/worker/worker_stdthread.cc b/src/vt/worker/worker_stdthread.cc index 77e07acafd..eb7d16f9d7 100644 --- a/src/vt/worker/worker_stdthread.cc +++ b/src/vt/worker/worker_stdthread.cc @@ -59,9 +59,8 @@ namespace vt { namespace worker { StdThreadWorker::StdThreadWorker( - WorkerIDType const& in_worker_id_, WorkerCountType const& in_num_thds, - WorkerFinishedFnType finished_fn -) : worker_id_(in_worker_id_), num_thds_(in_num_thds), finished_fn_(finished_fn) + WorkerIDType const& in_worker_id_, WorkerFinishedFnType finished_fn +) : worker_id_(in_worker_id_), finished_fn_(finished_fn) { } void StdThreadWorker::enqueue(WorkUnitType const& work_unit) { diff --git a/src/vt/worker/worker_stdthread.h b/src/vt/worker/worker_stdthread.h index db54496bf5..6c49126a41 100644 --- a/src/vt/worker/worker_stdthread.h +++ b/src/vt/worker/worker_stdthread.h @@ -67,8 +67,7 @@ struct StdThreadWorker { using WorkUnitContainerType = util::container::ConcurrentDeque; StdThreadWorker( - WorkerIDType const& in_worker_id_, WorkerCountType const& in_num_thds, - WorkerFinishedFnType finished_fn + WorkerIDType const& in_worker_id_, WorkerFinishedFnType finished_fn ); StdThreadWorker(StdThreadWorker const&) = delete; From d56032653de317236b807918d75d978c7b343dd3 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 29 Apr 2020 16:57:58 -0700 Subject: [PATCH 05/88] #797: worker: put back in constructor (trait required) --- src/vt/worker/worker_stdthread.cc | 3 ++- src/vt/worker/worker_stdthread.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vt/worker/worker_stdthread.cc b/src/vt/worker/worker_stdthread.cc index eb7d16f9d7..7fe628581a 100644 --- a/src/vt/worker/worker_stdthread.cc +++ b/src/vt/worker/worker_stdthread.cc @@ -59,7 +59,8 @@ namespace vt { namespace worker { StdThreadWorker::StdThreadWorker( - WorkerIDType const& in_worker_id_, WorkerFinishedFnType finished_fn + WorkerIDType const& in_worker_id_, WorkerCountType const&, + WorkerFinishedFnType finished_fn ) : worker_id_(in_worker_id_), finished_fn_(finished_fn) { } diff --git a/src/vt/worker/worker_stdthread.h b/src/vt/worker/worker_stdthread.h index 6c49126a41..7922a1e1b6 100644 --- a/src/vt/worker/worker_stdthread.h +++ b/src/vt/worker/worker_stdthread.h @@ -67,7 +67,8 @@ struct StdThreadWorker { using WorkUnitContainerType = util::container::ConcurrentDeque; StdThreadWorker( - WorkerIDType const& in_worker_id_, WorkerFinishedFnType finished_fn + WorkerIDType const& in_worker_id_, WorkerCountType const&, + WorkerFinishedFnType finished_fn ); StdThreadWorker(StdThreadWorker const&) = delete; From fecdb299e61abfc8b4173924800112bdb4b21110 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 7 May 2020 16:50:33 -0700 Subject: [PATCH 06/88] #803: serialization: conform to new API, make checkpoint required dep - Conform to 1.0.0-beta.8 changes in checkpoint, refactoring the namespaces and checkpoint API - Checkpoint is considered a optional dependency, but VT has been failing to compile without checkpoint for a long time. Thus, make it a required dependency. - Remove all the conditional logic on HAS_SERIALIZTION_LIBRARY - Remove the "mock" checkpoint-replacement serializer that handled all the basic types, std::vector, std::tuple of basic arthimetic types when checkpoinmt was not present. --- cmake/link_vt.cmake | 14 +- cmake/load_local_packages.cmake | 21 +- cmake/vtConfig.cmake.in | 8 +- cmake_config.h.in | 2 - .../messaging/message/shared_message.impl.h | 6 +- src/vt/serialization/auto_sizing/sizing.h | 106 ------- .../messaging/serialized_data_msg.h | 5 +- .../messaging/serialized_messenger.h | 2 - .../messaging/serialized_messenger.impl.h | 16 +- src/vt/serialization/mock_serializer.h | 286 ------------------ src/vt/serialization/serialization.h | 61 ---- src/vt/serialization/serialize_interface.h | 92 ------ .../serialization/serialize_interface.impl.h | 56 ---- src/vt/serialization/sizer.h | 12 +- src/vt/transport.h | 1 - src/vt/vrt/collection/manager.impl.h | 5 +- .../vrt/collection/messages/system_create.h | 1 - src/vt/vrt/collection/messages/user_wrap.h | 8 +- .../migrate/migrate_handlers.impl.h | 9 +- .../vrt/context/context_vrt_internal_msgs.h | 1 - src/vt/vrt/context/context_vrtmanager.h | 1 - src/vt/vrt/context/context_vrtmanager.impl.h | 1 - .../test_serialize_messenger_virtual.cc | 2 - 23 files changed, 35 insertions(+), 681 deletions(-) delete mode 100644 src/vt/serialization/auto_sizing/sizing.h delete mode 100644 src/vt/serialization/mock_serializer.h delete mode 100644 src/vt/serialization/serialization.h delete mode 100644 src/vt/serialization/serialize_interface.h delete mode 100644 src/vt/serialization/serialize_interface.impl.h diff --git a/cmake/link_vt.cmake b/cmake/link_vt.cmake index 751083af92..5052e0d4d3 100644 --- a/cmake/link_vt.cmake +++ b/cmake/link_vt.cmake @@ -129,16 +129,12 @@ function(link_target_with_vt) endif() if (NOT DEFINED ARG_LINK_CHECKPOINT AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_CHECKPOINT) - if (${VT_HAS_SERIALIZATION_LIBRARY}) - if (${ARG_DEBUG_LINK}) - message(STATUS "link_target_with_vt: checkpoint=${ARG_LINK_CHECKPOINT}") - endif() - target_link_libraries( - ${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${CHECKPOINT_LIBRARY} - ) - else() - message(FATAL_ERROR "Trying to link with nonexistent checkpoint library") + if (${ARG_DEBUG_LINK}) + message(STATUS "link_target_with_vt: checkpoint=${ARG_LINK_CHECKPOINT}") endif() + target_link_libraries( + ${ARG_TARGET} PUBLIC ${ARG_BUILD_TYPE} ${CHECKPOINT_LIBRARY} + ) endif() if (NOT DEFINED ARG_LINK_DETECTOR AND ${ARG_DEFAULT_LINK_SET} OR ARG_LINK_DETECTOR) diff --git a/cmake/load_local_packages.cmake b/cmake/load_local_packages.cmake index 88d9d5a4cb..ca15b1d48f 100644 --- a/cmake/load_local_packages.cmake +++ b/cmake/load_local_packages.cmake @@ -5,20 +5,15 @@ include(cmake/local_package.cmake) + # require directories for these packages require_pkg_directory(detector "VT detector library") # find these required packages locally find_package_local(detector "${detector_DIR}" detector) -# optional directory for this package -optional_pkg_directory(checkpoint "Serialization/Checkpoint" 1) -# find the optional packages locally if identified -if (${checkpoint_DIR_FOUND}) - find_package_local(checkpoint "${checkpoint_DIR}" checkpoint) - if(NOT projHasParent) - if (NOT ${checkpoint_FOUND}) - message(FATAL_ERROR "Serialization/checkpoint library not found") - endif() - endif() - set(VT_HAS_SERIALIZATION_LIBRARY 1) - set(CHECKPOINT_LIBRARY vt::lib::checkpoint) -endif() + +# require directories for these packages +require_pkg_directory(checkpoint "VT checkpoint library") +# find these required packages locally +find_package_local(checkpoint "${checkpoint_DIR}" checkpoint) + +set(CHECKPOINT_LIBRARY vt::lib::checkpoint) diff --git a/cmake/vtConfig.cmake.in b/cmake/vtConfig.cmake.in index 603013516c..5c92e0275c 100644 --- a/cmake/vtConfig.cmake.in +++ b/cmake/vtConfig.cmake.in @@ -21,13 +21,7 @@ set (detector_DIR @detector_DIR@) find_dependency(detector REQUIRED HINTS @detector_DIR@) set (checkpoint_DIR @checkpoint_DIR@) -set (vt_has_checkpoint @checkpoint_DIR_FOUND@) -if (@VT_HAS_SERIALIZATION_LIBRARY@) - find_dependency(checkpoint REQUIRED HINTS @checkpoint_DIR@) - set(VT_HAS_CHECKPOINT "TRUE") -else() - set(VT_HAS_CHECKPOINT "FALSE") -endif() +find_dependency(checkpoint REQUIRED HINTS @checkpoint_DIR@) set (VT_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/include") set (VT_CXX_COMPILER "@CMAKE_CXX_COMPILER@") diff --git a/cmake_config.h.in b/cmake_config.h.in index 30adc15192..d10723dcc2 100644 --- a/cmake_config.h.in +++ b/cmake_config.h.in @@ -42,8 +42,6 @@ //@HEADER */ -#define HAS_SERIALIZATION_LIBRARY @VT_HAS_SERIALIZATION_LIBRARY@ - #cmakedefine01 cmake_config_debug_enabled #define cmake_config_debug_modes @cmake_vt_debug_modes@ #define cmake_config_modes @cmake_vt_modes@ diff --git a/src/vt/messaging/message/shared_message.impl.h b/src/vt/messaging/message/shared_message.impl.h index 488f97b05f..742a2bb217 100644 --- a/src/vt/messaging/message/shared_message.impl.h +++ b/src/vt/messaging/message/shared_message.impl.h @@ -50,9 +50,7 @@ #include "vt/messaging/message/smart_ptr.h" #include "vt/pool/pool.h" -#if HAS_SERIALIZATION_LIBRARY - #include "serialization_library_headers.h" -#endif +#include namespace vt { @@ -60,7 +58,7 @@ template void messageTypeChecks() { static_assert( std::is_trivially_destructible::value or - serdes::SerializableTraits::has_serialize_function, + checkpoint::SerializableTraits::has_serialize_function, "All messages must either be trivially destructible or " "have a valid serialization function associated with them" ); diff --git a/src/vt/serialization/auto_sizing/sizing.h b/src/vt/serialization/auto_sizing/sizing.h deleted file mode 100644 index 1ba9cbcb8c..0000000000 --- a/src/vt/serialization/auto_sizing/sizing.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// sizing.h -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 -*/ - -#if !defined INCLUDED_VT_SERIALIZATION_AUTO_SIZING_SIZING_H -#define INCLUDED_VT_SERIALIZATION_AUTO_SIZING_SIZING_H - -#include "vt/config.h" -#include "vt/serialization/serialize_interface.h" - -#if HAS_SERIALIZATION_LIBRARY - #define HAS_DETECTION_COMPONENT 1 - #include "serialization_library_headers.h" - #include "traits/serializable_traits.h" -#endif - -namespace vt { namespace serialization { - -template -struct Size { - static std::size_t getSize(MsgT* msg); -}; - -#if HAS_SERIALIZATION_LIBRARY -template -struct Size< - MsgT, - typename std::enable_if_t< - ::serdes::SerializableTraits::has_serialize_function - > -> { - static std::size_t getSize(MsgT* msg) { - return ::serialization::interface::getSize(*msg); - } -}; - -template -struct Size< - MsgT, - typename std::enable_if_t< - !::serdes::SerializableTraits::has_serialize_function - > -> { - static std::size_t getSize(MsgT* msg) { - return sizeof(MsgT); - } -}; - -#else - -template -struct Size< - MsgT, - typename std::enable_if_t -> { - static std::size_t getSize(MsgT* msg) { - return sizeof(MsgT); - } -}; - -#endif - - -}} /* end namespace vt::serialization */ - -#endif /*INCLUDED_VT_SERIALIZATION_AUTO_SIZING_SIZING_H*/ diff --git a/src/vt/serialization/messaging/serialized_data_msg.h b/src/vt/serialization/messaging/serialized_data_msg.h index cb9209c264..c3dd8800eb 100644 --- a/src/vt/serialization/messaging/serialized_data_msg.h +++ b/src/vt/serialization/messaging/serialized_data_msg.h @@ -47,12 +47,11 @@ #include "vt/config.h" #include "vt/messaging/message.h" -#include "vt/serialization/serialization.h" - -using namespace ::serialization::interface; namespace vt { namespace serialization { +using SizeType = std::size_t; + static constexpr SizeType const serialized_msg_eager_size = 128; struct NoneVrt { }; diff --git a/src/vt/serialization/messaging/serialized_messenger.h b/src/vt/serialization/messaging/serialized_messenger.h index 1ba97ec7e8..2331949771 100644 --- a/src/vt/serialization/messaging/serialized_messenger.h +++ b/src/vt/serialization/messaging/serialized_messenger.h @@ -56,8 +56,6 @@ #include #include -using namespace ::serialization::interface; - namespace vt { namespace serialization { template diff --git a/src/vt/serialization/messaging/serialized_messenger.impl.h b/src/vt/serialization/messaging/serialized_messenger.impl.h index 9abfac8d6d..aba7e7b89b 100644 --- a/src/vt/serialization/messaging/serialized_messenger.impl.h +++ b/src/vt/serialization/messaging/serialized_messenger.impl.h @@ -50,7 +50,6 @@ #include "vt/messaging/active.h" #include "vt/registry/auto/auto_registry_interface.h" #include "vt/registry/auto/vc/auto_registry_vc.h" -#include "vt/serialization/serialization.h" #include "vt/runnable/general.h" #include "vt/serialization/messaging/serialized_data_msg.h" #include "vt/serialization/messaging/serialized_messenger.h" @@ -97,7 +96,7 @@ template auto ptr_offset = reinterpret_cast(sys_msg) + sizeof(SerialWrapperMsgType); auto user_msg = makeMessage(); - deserializeInPlace(ptr_offset,ptr_size,user_msg.get()); + checkpoint::deserializeInPlace(ptr_offset,user_msg.get()); messageResetDeserdes(user_msg); runnable::Runnable::run( handler, nullptr, user_msg.get(), sys_msg->from_node @@ -132,9 +131,8 @@ template (RDMA_GetType ptr, ActionType action){ // be careful here not to use "msg", it is no longer valid auto raw_ptr = reinterpret_cast(std::get<0>(ptr)); - auto ptr_size = std::get<1>(ptr); auto msg = makeMessage(); - deserializeInPlace(raw_ptr, ptr_size, msg.get()); + checkpoint::deserializeInPlace(raw_ptr, msg.get()); messageResetDeserdes(msg); debug_print( @@ -165,8 +163,8 @@ template auto const handler = sys_msg->handler; auto user_msg = makeMessage(); - deserializeInPlace( - sys_msg->payload.data(), sys_msg->bytes, user_msg.get() + checkpoint::deserializeInPlace( + sys_msg->payload.data(), user_msg.get() ); messageResetDeserdes(user_msg); @@ -377,7 +375,7 @@ template SizeType ptr_size = 0; auto sys_size = sizeof(typename decltype(sys_msg)::MsgType); - auto serialized_msg = serialize( + auto serialized_msg = checkpoint::serialize( *msg.get(), [&](SizeType size) -> SerialByteType* { ptr_size = size; if (size >= serialized_msg_eager_size) { @@ -460,7 +458,7 @@ template SerialByteType* ptr = nullptr; SizeType ptr_size = 0; - auto serialized_msg = serialize( + auto serialized_msg = checkpoint::serialize( *msg.get(), [&](SizeType size) -> SerialByteType* { ptr_size = size; @@ -520,7 +518,7 @@ template ); } else { auto user_msg = makeMessage(); - deserializeInPlace(ptr, ptr_size, user_msg.get()); + checkpoint::deserializeInPlace(ptr, user_msg.get()); messageResetDeserdes(user_msg); debug_print( diff --git a/src/vt/serialization/mock_serializer.h b/src/vt/serialization/mock_serializer.h deleted file mode 100644 index ebbcc16a7e..0000000000 --- a/src/vt/serialization/mock_serializer.h +++ /dev/null @@ -1,286 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// mock_serializer.h -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 -*/ - -#if !defined INCLUDED_SERIALIZATION_MOCK_SERIALIZER_H -#define INCLUDED_SERIALIZATION_MOCK_SERIALIZER_H - -#include "vt/config.h" -#include "vt/utils/static_checks/all_true.h" - -#include -#include -#include -#include -#include -#include -#include - -/* - * Mock serializer that implements the serialization interface for - * byte-serializable types (std::is_arithmetic and std::tuple) by simply calling - * std::memcpy on the type. -*/ - -#if !HAS_SERIALIZATION_LIBRARY - -namespace vt { namespace serialization { - -using namespace ::serialization::interface; -using namespace ::vt::util; - -struct ByteSerializedBuffer : SerializedInfo { - using ByteType = SerialByteType[]; - - ByteSerializedBuffer(SizeType const& size) - : size_(size), buffer_(std::make_unique(size)) - { } - - virtual SerialByteType* getBuffer() const override { - return buffer_.get(); - } - - virtual SizeType getSize() const override { - return size_; - } - -private: - SizeType size_ = 0; - - std::unique_ptr buffer_ = nullptr; -}; - -using ByteSerializedBufferPtrType = std::unique_ptr; -using BufferPtrType = ByteSerializedBufferPtrType; - -template -static inline std::unique_ptr serializeByte( - T* target, bool hasSize = false, SizeType inSize = 0 -) { - using PtrType = std::unique_ptr; - - SizeType size = 0; - PtrType buf = nullptr; - - auto tptr = reinterpret_cast(target); - - if (hasSize) { - size = inSize + sizeof(SizeType); - buf = std::make_unique(size); - SerialByteType* cur = buf->getBuffer(); - std::memcpy(cur, reinterpret_cast(&inSize), sizeof(SizeType)); - std::memcpy(cur + sizeof(SizeType), tptr, inSize); - } else { - size = sizeof(T); - buf = std::make_unique(size); - std::memcpy(buf->getBuffer(), tptr, size); - } - - return buf; -} - -template -struct isTuple : std::false_type { }; -template -struct isTuple> : std::true_type { }; - -template -struct isVector : std::false_type { }; -template -struct isVector> : std::true_type { }; - -template -struct hasByteCopyTrait { - template - static typename C::isByteCopyable test(int); - - template - static std::false_type test(...); - - static constexpr bool value = decltype(test(0))::value; -}; - -template -struct SerializationTraits { - - template - using arith = typename std::is_arithmetic; - - template - using tuple = isTuple::type>; - - template - using vector = isVector::type>; - - static constexpr auto const is_byte_cp = - arith::value or hasByteCopyTrait::value; - static constexpr auto const is_byte_cp_tuple = is_byte_cp or tuple::value; - - static constexpr auto const is_not_byte_cp = - not tuple::value and - not arith::value and - not hasByteCopyTrait::value and - not vector::value; - - static constexpr auto const is_tuple = tuple::value and not is_byte_cp; - static constexpr auto const is_vec = vector::value and not is_byte_cp; -}; - - -template -struct ByteCopyableTraits { - using BufferPtrType = std::unique_ptr; - - template - using isByteCopyType = - typename std::enable_if::is_byte_cp, T>::type; - - template - using isVecType = - typename std::enable_if::is_vec, T>::type; - - template - using isTupleType = - typename std::enable_if::is_tuple, T>::type; - - template - using isNotByteCopyType = - typename std::enable_if::is_not_byte_cp, T>::type; - - template - static void tupleStaticCheck(std::tuple& tup) { - // @todo: do recursive check of tuple for byte-copyability - using cond = all_true::is_byte_cp_tuple...>; - - static_assert( - std::is_same::value == true, - "All tuple elms must be byte copyable" - ); - } - - template - static BufferPtrType apply(T* val, SizeType num, isByteCopyType* x = nullptr) { - return serializeByte(val); - } - - // Hack to make mock serializer work with vectors - template - static BufferPtrType apply(T* val, SizeType num, isVecType* x = nullptr) { - using ValueType = typename T::value_type; - return serializeByte( - &(*val)[0], true, val->size()*sizeof(typename T::value_type) - ); - } - - // Specialize std::tuple type so that the elements can be checked for - // byte-wise serializability - template - static BufferPtrType apply(T* val, SizeType num, isTupleType* x = nullptr) { - //tupleStaticCheck(*val); - return serializeByte(val); - } - - template - static BufferPtrType apply(T* val, SizeType num, isNotByteCopyType* x = nullptr) { - vtAssert(false, "Non-byte copyable serialization not implemented"); - } -}; - -template -struct DeserTraits { - template - using isVecType = typename std::enable_if::is_vec, T>::type; - - template - using isNotVecType = typename std::enable_if::is_vec, T>::type; - - template - void operator()(SerialByteType* buf, T& vec, SizeType size, isVecType* x = nullptr) { - SizeType* buf_as_size = reinterpret_cast(buf); - SizeType vec_bytes_size = *buf_as_size; - vec.resize(vec_bytes_size / sizeof(typename T::value_type)); - std::memcpy(&vec[0], buf_as_size+1, vec_bytes_size); - } - - template - void operator()(SerialByteType* buf, T& val, SizeType num, isNotVecType* x = nullptr) { - std::memcpy(static_cast(&val), buf, sizeof(T)); - } -}; - -}} /* end namespace vt::serialization */ - -namespace serialization { namespace interface { - -using namespace ::vt::serialization; - -template -SerializedReturnType serialize(T& target, BufferCallbackType fn) { - auto buf = ByteCopyableTraits::apply(&target, 1); - if (fn != nullptr) { - auto user_buf = fn(buf->getSize()); - std::memcpy(user_buf, buf->getBuffer(), buf->getSize()); - } - std::unique_ptr base_ptr( - static_cast(buf.release()) - ); - return base_ptr; -} - -template -T* deserialize(SerialByteType* buf, SizeType size, T* allocBuf) { - SerialByteType* mem = allocBuf ? - reinterpret_cast(allocBuf) : new SerialByteType[sizeof(T)]; - T* t_ptr = new (mem) T{}; - - DeserTraits ap; - ap(buf, *t_ptr, size); - - return t_ptr; -} - -}} /* end namespace serialization::interface */ - -#endif - -#endif /*INCLUDED_SERIALIZATION_MOCK_SERIALIZER_H*/ diff --git a/src/vt/serialization/serialization.h b/src/vt/serialization/serialization.h deleted file mode 100644 index fb58d065a6..0000000000 --- a/src/vt/serialization/serialization.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// serialization.h -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 -*/ - -#if !defined INCLUDED_SERIALIZATION_SERIALIZATION_H -#define INCLUDED_SERIALIZATION_SERIALIZATION_H - -#include "vt/config.h" -#include "vt/serialization/serialize_interface.h" -#include "vt/serialization/messaging/serialized_messenger.h" -#include "vt/serialization/messaging/serialized_param_messenger.h" -#include "vt/serialization/traits/byte_copy_trait.h" - -namespace vt { namespace serialization { - -using SerialByteType = ::serialization::interface::SerialByteType; - -}} /* end namespace vt::serialization */ - -#endif /*INCLUDED_SERIALIZATION_SERIALIZATION_H*/ - diff --git a/src/vt/serialization/serialize_interface.h b/src/vt/serialization/serialize_interface.h deleted file mode 100644 index ec350cad6d..0000000000 --- a/src/vt/serialization/serialize_interface.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// serialize_interface.h -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 -*/ - -#if !defined INCLUDED_SERIALIZATION_SERIALIZE_INTERFACE_H -#define INCLUDED_SERIALIZATION_SERIALIZE_INTERFACE_H - -#include -#include -#include - -#if HAS_SERIALIZATION_LIBRARY - #include "serialization_library_headers.h" -#else - -namespace serialization { namespace interface { - -using SizeType = size_t; -using SerialByteType = char; - -using BufferCallbackType = std::function; - -struct SerializedInfo { - virtual SizeType getSize() const = 0; - virtual SerialByteType* getBuffer() const = 0; - virtual ~SerializedInfo() { } -}; - -using SerializedInfoPtrType = std::unique_ptr; -using SerializedReturnType = SerializedInfoPtrType; - -template -SerializedReturnType serialize(T& target, BufferCallbackType fn = nullptr); - -template -T* deserialize(SerialByteType* buf, SizeType size, T* user_buf = nullptr); - -template -SerializedReturnType serializePartial(T& target, BufferCallbackType fn = nullptr); - -template -T* deserializePartial(SerialByteType* buf, SizeType size, T* user_buf = nullptr); - - -}} /* end namespace serialization::interface */ - -#include "vt/serialize_interface.impl.h" - -#endif - -#endif /*INCLUDED_SERIALIZATION_SERIALIZE_INTERFACE_H*/ - diff --git a/src/vt/serialization/serialize_interface.impl.h b/src/vt/serialization/serialize_interface.impl.h deleted file mode 100644 index eab0320ee0..0000000000 --- a/src/vt/serialization/serialize_interface.impl.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// serialize_interface.impl.h -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 -*/ - -#if !defined INCLUDED_SERIALIZATION_SERIALIZE_INTERFACE_IMPL_H -#define INCLUDED_SERIALIZATION_SERIALIZE_INTERFACE_IMPL_H - -#include "vt/serialize_interface.h" - -#if HAS_SERIALIZATION_LIBRARY - #include "serialization_library_headers.h" -#endif - -#include "vt/mock_serializer.h" - -#endif /*INCLUDED_SERIALIZATION_SERIALIZE_INTERFACE_IMPL_H*/ diff --git a/src/vt/serialization/sizer.h b/src/vt/serialization/sizer.h index f215ea10b4..54a0e4ef32 100644 --- a/src/vt/serialization/sizer.h +++ b/src/vt/serialization/sizer.h @@ -46,13 +46,8 @@ #define INCLUDED_VT_SERIALIZATION_SIZER_H #include "vt/config.h" -#include "vt/serialization/serialize_interface.h" -#if HAS_SERIALIZATION_LIBRARY - #define HAS_DETECTION_COMPONENT 1 - #include "serialization_library_headers.h" - #include "traits/serializable_traits.h" -#endif +#include namespace vt { namespace serialization { @@ -63,7 +58,6 @@ struct MsgSizer { } }; -#if HAS_SERIALIZATION_LIBRARY template struct MsgSizer< MsgT, @@ -73,12 +67,10 @@ struct MsgSizer< > { static std::size_t get(MsgT* msg) { auto& msg_ref = *msg; - return ::serialization::interface::getSize(msg_ref); + return ::checkpoint::getSize(msg_ref); } }; -#endif - }} /* end namespace vt::serialization */ #endif /*INCLUDED_VT_SERIALIZATION_SIZER_H*/ diff --git a/src/vt/transport.h b/src/vt/transport.h index c797064bc6..f9ffae7f10 100644 --- a/src/vt/transport.h +++ b/src/vt/transport.h @@ -71,7 +71,6 @@ #include "vt/topos/mapping/mapping_headers.h" #include "vt/vrt/context/context_vrtheaders.h" #include "vt/vrt/collection/collection_headers.h" -#include "vt/serialization/serialization.h" #include "vt/standalone/vt_main.h" #include "vt/utils/tls/tls.h" #include "vt/utils/atomic/atomic.h" diff --git a/src/vt/vrt/collection/manager.impl.h b/src/vt/vrt/collection/manager.impl.h index 2debd805c1..74040a6968 100644 --- a/src/vt/vrt/collection/manager.impl.h +++ b/src/vt/vrt/collection/manager.impl.h @@ -74,9 +74,8 @@ #include "vt/registry/auto/auto_registry_common.h" #include "vt/topos/mapping/mapping_headers.h" #include "vt/termination/term_headers.h" -#include "vt/serialization/serialization.h" #include "vt/serialization/auto_dispatch/dispatch.h" -#include "vt/serialization/auto_sizing/sizing.h" +#include "vt/serialization/sizer.h" #include "vt/collective/reduce/reduce_hash.h" #include "vt/runnable/collection.h" @@ -769,7 +768,7 @@ template auto const pfrom = msg->getElm(); auto const tfrom = msg->getElmTemp(); auto& stats = col_ptr->getStats(); - auto const msg_size = serialization::Size::getSize(msg); + auto const msg_size = serialization::MsgSizer::get(msg); auto const cat = msg->getCat(); debug_print( vrt_coll, node, diff --git a/src/vt/vrt/collection/messages/system_create.h b/src/vt/vrt/collection/messages/system_create.h index 87f028925c..464117c3f8 100644 --- a/src/vt/vrt/collection/messages/system_create.h +++ b/src/vt/vrt/collection/messages/system_create.h @@ -50,7 +50,6 @@ #include "vt/vrt/collection/proxy_builder/elm_proxy_builder.h" #include "vt/vrt/collection/types/headers.h" #include "vt/messaging/message.h" -#include "vt/serialization/serialization.h" #include "vt/collective/reduce/reduce.h" #include "vt/vrt/proxy/collection_proxy.h" diff --git a/src/vt/vrt/collection/messages/user_wrap.h b/src/vt/vrt/collection/messages/user_wrap.h index 3c1d883484..413648d750 100644 --- a/src/vt/vrt/collection/messages/user_wrap.h +++ b/src/vt/vrt/collection/messages/user_wrap.h @@ -52,11 +52,7 @@ #include "vt/vrt/collection/manager.fwd.h" #include "vt/vrt/vrt_common.h" -#if HAS_SERIALIZATION_LIBRARY - #define HAS_DETECTION_COMPONENT 1 - #include "serialization_library_headers.h" - #include "traits/serializable_traits.h" -#endif +#include #include @@ -95,7 +91,7 @@ struct ColMsgWrap : CollectionMessage { typename SerializerT, typename T=void, typename = typename std::enable_if< - ::serdes::SerializableTraits::has_serialize_function, T + ::checkpoint::SerializableTraits::has_serialize_function, T >::type > void serialize(SerializerT& s) { diff --git a/src/vt/vrt/collection/migrate/migrate_handlers.impl.h b/src/vt/vrt/collection/migrate/migrate_handlers.impl.h index c4f6289025..dc7f78b268 100644 --- a/src/vt/vrt/collection/migrate/migrate_handlers.impl.h +++ b/src/vt/vrt/collection/migrate/migrate_handlers.impl.h @@ -50,7 +50,6 @@ #include "vt/vrt/collection/migrate/migrate_msg.h" #include "vt/vrt/collection/migrate/migrate_handlers.h" #include "vt/vrt/collection/migrate/manager_migrate_attorney.h" -#include "vt/serialization/serialization.h" #include #include @@ -81,12 +80,12 @@ template // auto const& buf_size = msg->getPutSize(); // auto vc_elm_ptr = std::make_unique(); - // auto vc_raw_ptr = ::serialization::interface::deserialize( - // buf, buf_size, vc_elm_ptr.get() + // auto vc_raw_ptr = ::checkpoint::deserialize( + // buf, vc_elm_ptr.get() // ); // ColT* col_t = new ColT(); - // auto vc_raw_ptr = ::serialization::interface::deserialize( - // buf, buf_size, col_t + // auto vc_raw_ptr = ::checkpoint::deserialize( + // buf, col_t // ); auto vc_elm_ptr = std::make_unique(std::move(*msg->elm_)); diff --git a/src/vt/vrt/context/context_vrt_internal_msgs.h b/src/vt/vrt/context/context_vrt_internal_msgs.h index a42d628785..fe92875065 100644 --- a/src/vt/vrt/context/context_vrt_internal_msgs.h +++ b/src/vt/vrt/context/context_vrt_internal_msgs.h @@ -49,7 +49,6 @@ #include "vt/vrt/proxy/proxy_bits.h" #include "vt/vrt/context/context_vrt_fwd.h" #include "vt/messaging/message.h" -#include "vt/serialization/serialization.h" #include diff --git a/src/vt/vrt/context/context_vrtmanager.h b/src/vt/vrt/context/context_vrtmanager.h index 9508b1e81d..e011304961 100644 --- a/src/vt/vrt/context/context_vrtmanager.h +++ b/src/vt/vrt/context/context_vrtmanager.h @@ -61,7 +61,6 @@ #include "vt/utils/bits/bits_common.h" #include "vt/activefn/activefn.h" #include "vt/topos/mapping/mapping_function.h" -#include "vt/serialization/serialization.h" namespace vt { namespace vrt { diff --git a/src/vt/vrt/context/context_vrtmanager.impl.h b/src/vt/vrt/context/context_vrtmanager.impl.h index 44c8d0c661..541b139f19 100644 --- a/src/vt/vrt/context/context_vrtmanager.impl.h +++ b/src/vt/vrt/context/context_vrtmanager.impl.h @@ -54,7 +54,6 @@ #include "vt/topos/location/manager.h" #include "vt/registry/auto/vc/auto_registry_vc.h" #include "vt/registry/auto/map/auto_registry_map.h" -#include "vt/serialization/serialization.h" #include "vt/worker/worker_headers.h" #include diff --git a/tests/unit/serialization/test_serialize_messenger_virtual.cc b/tests/unit/serialization/test_serialize_messenger_virtual.cc index de09fe7ca0..a8f220b7a5 100644 --- a/tests/unit/serialization/test_serialize_messenger_virtual.cc +++ b/tests/unit/serialization/test_serialize_messenger_virtual.cc @@ -96,7 +96,6 @@ struct TestSerialMessengerVirtual : TestParallelHarness { } }; -#if HAS_SERIALIZATION_LIBRARY TEST_F(TestSerialMessengerVirtual, test_serial_messenger_1) { auto const& my_node = theContext()->getNode(); @@ -107,6 +106,5 @@ TEST_F(TestSerialMessengerVirtual, test_serial_messenger_1) { theVirtualManager()->sendSerialMsg(proxy, msg); } } -#endif }}} // end namespace vt::tests::unit From c9d7cd98367c1f61fdd650046a8395d239707da9 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Sat, 9 May 2020 13:16:09 -0700 Subject: [PATCH 07/88] #803: build: stop searching system path when user specified path --- cmake/local_package.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/local_package.cmake b/cmake/local_package.cmake index 4959f7a776..856d0de5bf 100644 --- a/cmake/local_package.cmake +++ b/cmake/local_package.cmake @@ -66,6 +66,7 @@ macro(find_package_local pkg_name pkg_directory pkg_other_name) NO_CMAKE_BUILDS_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_SYSTEM_PACKAGE_REGISTRY + NO_SYSTEM_ENVIRONMENT_PATH QUIET ) From 52ca527647baf4e704e4e7af150e1c747da83b83 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Sun, 10 May 2020 16:53:01 -0700 Subject: [PATCH 08/88] #802: util: implement MPI max tag utility --- src/CMakeLists.txt | 2 +- src/vt/utils/mpi_limits/mpi_max_tag.cc | 73 ++++++++++++++++++++++ src/vt/utils/mpi_limits/mpi_max_tag.h | 83 ++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 src/vt/utils/mpi_limits/mpi_max_tag.cc create mode 100644 src/vt/utils/mpi_limits/mpi_max_tag.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a3223d1b4..46de5ee120 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,7 +87,7 @@ set( serialization/sizing utils/demangle utils/container utils/bits utils/mutex utils/hash utils/atomic utils/tls utils/static_checks utils/string - utils/memory + utils/memory utils/mpi_limits registry/auto registry/auto/functor registry/auto/map registry/auto/collection registry/auto/vc registry/auto/rdma registry/auto/index diff --git a/src/vt/utils/mpi_limits/mpi_max_tag.cc b/src/vt/utils/mpi_limits/mpi_max_tag.cc new file mode 100644 index 0000000000..49f2676796 --- /dev/null +++ b/src/vt/utils/mpi_limits/mpi_max_tag.cc @@ -0,0 +1,73 @@ +/* +//@HEADER +// ***************************************************************************** +// +// mpi_max_tag.cc +// DARMA Toolkit v. 1.0.0 +// DARMA/vt => Virtual Transport +// +// Copyright 2019 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 "vt/config.h" +#include "vt/utils/mpi_limits/mpi_max_tag.h" + +namespace vt { namespace util { namespace mpi_limits { + +/*static*/ int MPI_MaxTag::get() { + + if (max_tag_ != 0) { + return max_tag_; + } + + void* p = nullptr; + int flag = 0; + auto comm = theContext()->getComm(); + MPI_Comm_get_attr(comm, MPI_TAG_UB, &p, &flag); + + if (not flag) { + vtAbort("Failed to obtain MPI_TAG_UB attribute"); + } else { + max_tag_ = *static_cast(p); + vtAssert(max_tag_ >= 32767, "MPI standard requires tag >= 32767"); + } + + return max_tag_; +} + +/*static*/ int MPI_MaxTag::max_tag_ = 0; + +}}} /* end namespace vt::util::mpi_limits */ diff --git a/src/vt/utils/mpi_limits/mpi_max_tag.h b/src/vt/utils/mpi_limits/mpi_max_tag.h new file mode 100644 index 0000000000..84944bc7a1 --- /dev/null +++ b/src/vt/utils/mpi_limits/mpi_max_tag.h @@ -0,0 +1,83 @@ +/* +//@HEADER +// ***************************************************************************** +// +// mpi_max_tag.h +// DARMA Toolkit v. 1.0.0 +// DARMA/vt => Virtual Transport +// +// Copyright 2019 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 +*/ + +#if !defined INCLUDED_VT_UTILS_MPI_LIMITS_MPI_MAX_TAG_H +#define INCLUDED_VT_UTILS_MPI_LIMITS_MPI_MAX_TAG_H + +#include "vt/config.h" +#include "vt/context/context.h" + +#include + +namespace vt { namespace util { namespace mpi_limits { + +/** + * \struct MPI_MaxTag + * + * \brief Get the MPI maximum value for a tag. This can vary across MPI + * implementations, but the MPI standard dictates it be at least 32767. + */ +struct MPI_MaxTag { + + /** + * \brief Get the maximum tag for the current context communicator. VT must be + * initialized for this to run correctly. + * + * \return the max tag + */ + static int get(); + +private: + static int max_tag_; /**< The cached max tag used. */ +}; + +}}} /* end namespace vt::util::mpi_limits */ + +namespace vt { namespace util { + +using MPI_MaxTag = mpi_limits::MPI_MaxTag; + +}} /* end namespace vt::util */ + +#endif /*INCLUDED_VT_UTILS_MPI_LIMITS_MPI_MAX_TAG_H*/ From d1a1969823f9aed95633fd87d5f3b7ed79fae309 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Sun, 10 May 2020 17:02:48 -0700 Subject: [PATCH 09/88] #802: util: expand to include the MPI version --- src/vt/utils/mpi_limits/mpi_max_tag.cc | 16 ++++++++++++++-- src/vt/utils/mpi_limits/mpi_max_tag.h | 22 ++++++++++++++++------ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src/vt/utils/mpi_limits/mpi_max_tag.cc b/src/vt/utils/mpi_limits/mpi_max_tag.cc index 49f2676796..04e08012cd 100644 --- a/src/vt/utils/mpi_limits/mpi_max_tag.cc +++ b/src/vt/utils/mpi_limits/mpi_max_tag.cc @@ -47,7 +47,7 @@ namespace vt { namespace util { namespace mpi_limits { -/*static*/ int MPI_MaxTag::get() { +/*static*/ int MPI_Attr::getMaxTag() { if (max_tag_ != 0) { return max_tag_; @@ -68,6 +68,18 @@ namespace vt { namespace util { namespace mpi_limits { return max_tag_; } -/*static*/ int MPI_MaxTag::max_tag_ = 0; +/*static*/ std::tuple MPI_Attr::getVersion() { + if (version_ == 0) { + MPI_Get_version(&version_, &subversion_); + } + + return std::make_tuple(version_, subversion_); +} + +/*static*/ int MPI_Attr::max_tag_ = 0; + +/*static*/ int MPI_Attr::version_ = 0; + +/*static*/ int MPI_Attr::subversion_ = 0; }}} /* end namespace vt::util::mpi_limits */ diff --git a/src/vt/utils/mpi_limits/mpi_max_tag.h b/src/vt/utils/mpi_limits/mpi_max_tag.h index 84944bc7a1..463296b4ec 100644 --- a/src/vt/utils/mpi_limits/mpi_max_tag.h +++ b/src/vt/utils/mpi_limits/mpi_max_tag.h @@ -53,12 +53,13 @@ namespace vt { namespace util { namespace mpi_limits { /** - * \struct MPI_MaxTag + * \struct MPI_Attr * - * \brief Get the MPI maximum value for a tag. This can vary across MPI - * implementations, but the MPI standard dictates it be at least 32767. + * \brief Get MPI attributes, including the MPI maximum value for a tag. This + * can vary across MPI implementations, but the MPI standard dictates it be at + * least 32767. */ -struct MPI_MaxTag { +struct MPI_Attr { /** * \brief Get the maximum tag for the current context communicator. VT must be @@ -66,17 +67,26 @@ struct MPI_MaxTag { * * \return the max tag */ - static int get(); + static int getMaxTag(); + + /** + * \brief Get the MPI version and subversion. + * + * \return a tuple: (version, subversion) + */ + static std::tuple getVersion(); private: static int max_tag_; /**< The cached max tag used. */ + static int version_; /**< The cached MPI version */ + static int subversion_; /**< The cached MPI sub-version */ }; }}} /* end namespace vt::util::mpi_limits */ namespace vt { namespace util { -using MPI_MaxTag = mpi_limits::MPI_MaxTag; +using MPI_Attr = mpi_limits::MPI_Attr; }} /* end namespace vt::util */ From e428d3464e7821f3fb59e8346702c0305250b8c0 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Sun, 10 May 2020 18:05:40 -0700 Subject: [PATCH 10/88] #802: runtime: add MPI max tag and version --- src/vt/runtime/runtime.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index 42db7098da..787c9a3f73 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -69,6 +69,7 @@ #include "vt/configs/error/stack_out.h" #include "vt/configs/error/pretty_print_stack.h" #include "vt/utils/memory/memory_usage.h" +#include "vt/utils/mpi_limits/mpi_max_tag.h" #include #include @@ -374,9 +375,18 @@ void Runtime::printStartupBanner() { dirty = red + std::string("*dirty*") + reset; } + auto const max_tag = util::MPI_Attr::getMaxTag(); + auto const max_tag_str = std::to_string(max_tag); + auto const version_tuple = util::MPI_Attr::getVersion(); + auto const version = std::to_string(std::get<0>(version_tuple)); + auto const subversion = std::to_string(std::get<1>(version_tuple)); + auto f1 = fmt::format("{} {}{}\n", reg(init), reg(mode), emph(mode_type + thd)); auto f2 = fmt::format("{}Running on: {}\n", green, emph(all_node)); auto f3 = fmt::format("{}Machine Hostname: {}\n", green, emph(hostname)); + auto f3a = fmt::format("{}MPI Version: {}.{}\n", green, emph(version), emph(subversion)); + auto f3b = fmt::format("{}MPI Max tag: {}\n", green, emph(max_tag_str)); + auto f4 = fmt::format("{}Build SHA: {}\n", green, emph(vt_git_sha1)); auto f5 = fmt::format("{}Build Ref: {}\n", green, emph(vt_git_refspec)); auto f6 = fmt::format("{}Description: {} {}\n", green, emph(vt_git_description), dirty); @@ -385,6 +395,8 @@ void Runtime::printStartupBanner() { fmt::print("{}{}{}", vt_pre, f1, reset); fmt::print("{}{}{}", vt_pre, f2, reset); fmt::print("{}{}{}", vt_pre, f3, reset); + fmt::print("{}{}{}", vt_pre, f3a, reset); + fmt::print("{}{}{}", vt_pre, f3b, reset); fmt::print("{}{}{}", vt_pre, f4, reset); fmt::print("{}{}{}", vt_pre, f5, reset); fmt::print("{}{}{}", vt_pre, f6, reset); From 8fb83ee1bfbbcb36fa5c0cda262162ca2e853a59 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Sun, 10 May 2020 18:13:20 -0700 Subject: [PATCH 11/88] #802: active: wrap tag around when hits max tag (attribute MPI_TAG_UB) --- src/vt/messaging/active.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index d0427c5c56..3a7a54c35d 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -52,6 +52,7 @@ #include "vt/runnable/general.h" #include "vt/timing/timing.h" #include "vt/scheduler/priority.h" +#include "vt/utils/mpi_limits/mpi_max_tag.h" namespace vt { namespace messaging { @@ -314,7 +315,19 @@ ActiveMessenger::SendDataRetType ActiveMessenger::sendData( ) { auto const& data_ptr = std::get<0>(ptr); auto const& num_bytes = std::get<1>(ptr); - auto const send_tag = tag == no_tag ? cur_direct_buffer_tag_++ : tag; + + int send_tag = 0; + if (tag == no_tag) { + send_tag = tag; + } else { + auto const max_tag = util::MPI_Attr::getMaxTag(); + send_tag = cur_direct_buffer_tag_++; + + // If max, wrap around back to the starting tag + if (cur_direct_buffer_tag_ >= max_tag) { + cur_direct_buffer_tag_ = starting_direct_buffer_tag; + } + } auto const event_id = theEvent()->createMPIEvent(this_node_); auto& holder = theEvent()->getEventHolder(event_id); From bacff54b80565d26c8e9d0a6fa6a37c1a9188ff3 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 11 May 2020 13:40:58 -0700 Subject: [PATCH 12/88] #802: active: fix reversed logic --- src/vt/messaging/active.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 3a7a54c35d..387319606c 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -317,7 +317,7 @@ ActiveMessenger::SendDataRetType ActiveMessenger::sendData( auto const& num_bytes = std::get<1>(ptr); int send_tag = 0; - if (tag == no_tag) { + if (tag != no_tag) { send_tag = tag; } else { auto const max_tag = util::MPI_Attr::getMaxTag(); From d4f69a64b40f94b22bc05b4e2c13157cb1f1d0a6 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 11 May 2020 13:41:10 -0700 Subject: [PATCH 13/88] #802: util: fix improperly placed comment --- src/vt/utils/mpi_limits/mpi_max_tag.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vt/utils/mpi_limits/mpi_max_tag.h b/src/vt/utils/mpi_limits/mpi_max_tag.h index 463296b4ec..a27efe229f 100644 --- a/src/vt/utils/mpi_limits/mpi_max_tag.h +++ b/src/vt/utils/mpi_limits/mpi_max_tag.h @@ -55,15 +55,14 @@ namespace vt { namespace util { namespace mpi_limits { /** * \struct MPI_Attr * - * \brief Get MPI attributes, including the MPI maximum value for a tag. This - * can vary across MPI implementations, but the MPI standard dictates it be at - * least 32767. + * \brief Get MPI attributes, including the MPI maximum value for a tag. */ struct MPI_Attr { /** * \brief Get the maximum tag for the current context communicator. VT must be - * initialized for this to run correctly. + * initialized for this to run correctly. This can vary across MPI + * implementations, but the MPI standard dictates it be at least 32767. * * \return the max tag */ From 49ffb1a2fe16ad8d0c0161be9987c5ad498c130b Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 11 May 2020 13:42:19 -0700 Subject: [PATCH 14/88] #802: active: increment after check for max_tag --- src/vt/messaging/active.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/vt/messaging/active.cc b/src/vt/messaging/active.cc index 387319606c..e8b99aab2b 100644 --- a/src/vt/messaging/active.cc +++ b/src/vt/messaging/active.cc @@ -321,12 +321,11 @@ ActiveMessenger::SendDataRetType ActiveMessenger::sendData( send_tag = tag; } else { auto const max_tag = util::MPI_Attr::getMaxTag(); - send_tag = cur_direct_buffer_tag_++; - // If max, wrap around back to the starting tag - if (cur_direct_buffer_tag_ >= max_tag) { + if (cur_direct_buffer_tag_ == max_tag) { cur_direct_buffer_tag_ = starting_direct_buffer_tag; } + send_tag = cur_direct_buffer_tag_++; } auto const event_id = theEvent()->createMPIEvent(this_node_); From f7fa756f38367fe85bc5e061317a0cd0501544d9 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 5 Nov 2019 16:58:20 -0800 Subject: [PATCH 15/88] #526: example: remove examples/broadcast_test.cc (redundant w/test) --- examples/CMakeLists.txt | 1 - examples/broadcast_test.cc | 117 ------------------------------------- 2 files changed, 118 deletions(-) delete mode 100644 examples/broadcast_test.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a72068f499..f4b1de810c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,6 @@ set( location_test location_test_msg lb_iter - broadcast_test index_test hello_world_vrtContext hello_world_vc diff --git a/examples/broadcast_test.cc b/examples/broadcast_test.cc deleted file mode 100644 index 04e4b4bd7d..0000000000 --- a/examples/broadcast_test.cc +++ /dev/null @@ -1,117 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// broadcast_test.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -using namespace vt; - -#define BCAST_DEBUG 0 - -static constexpr int32_t const num_bcasts = 4; -static NodeType my_node = uninitialized_destination; -static int32_t bcast_count = 0; - -struct Msg : vt::Message { - NodeType broot; - - Msg(NodeType const& in_broot) : Message(), broot(in_broot) { } -}; - -static void bcastTest(Msg* msg) { - auto const& root = msg->broot; - - #if BCAST_DEBUG - fmt::print("{}: bcastTestHandler root={}\n", theContext()->getNode(), msg->broot); - #endif - - vtAssert( - root != my_node, "Broadcast should deliver to all but this node" - ); - - bcast_count++; -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - - NodeType from_node = uninitialized_destination; - - if (argc > 1) { - from_node = atoi(argv[1]); - } - - int32_t const expected = num_bcasts * - (from_node == uninitialized_destination ? theContext()->getNumNodes() - 1 : ( - from_node == my_node ? 0 : 1 - )); - - theTerm()->addAction([=]{ - fmt::print("[{}] verify: bcast_count={}, expected={}\n", my_node, bcast_count, expected); - vtAssertExpr(bcast_count == expected); - }); - - if (from_node == uninitialized_destination or from_node == my_node) { - fmt::print("[{}] broadcast_test: broadcasting {} times\n", my_node, num_bcasts); - for (int i = 0; i < num_bcasts; i++) { - theMsg()->broadcastMsg(makeSharedMessage(my_node)); - } - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From 2e745e8c1d3781c70b2cfb1fd4be4a51cf0fd582 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 7 Nov 2019 08:33:36 -0800 Subject: [PATCH 16/88] #526: example: make ex../collection_group.cc a test instead --- examples/CMakeLists.txt | 1 - examples/collection_group.cc | 161 ------------------ .../unit/collection/test_collection_group.cc | 99 +++++++++++ 3 files changed, 99 insertions(+), 162 deletions(-) delete mode 100644 examples/collection_group.cc create mode 100644 tests/unit/collection/test_collection_group.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index f4b1de810c..868a375596 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -38,7 +38,6 @@ set( simple_collection_insert simple_collection_reduce collection_insert - collection_group rdma_unsized_collection group_example_1 group_collective diff --git a/examples/collection_group.cc b/examples/collection_group.cc deleted file mode 100644 index c293426dca..0000000000 --- a/examples/collection_group.cc +++ /dev/null @@ -1,161 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// collection_group.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -using namespace vt; -using namespace vt::group; - -struct TestMsg; - -struct MyReduceMsg : collective::ReduceMsg { - MyReduceMsg(int const& in_num) : num(in_num) {} - int num = 0; -}; - -struct ColA : Collection { - ColA() - : Collection() - { - // auto const& this_node = theContext()->getNode(); - // ::fmt::print("{}: constructing: idx={}\n", this_node, getIndex().x()); - } - - void work(TestMsg* msg); - void work2(TestMsg* msg); -}; - -struct TestMsg : CollectionMessage { }; - -void ColA::work2(TestMsg* msg) { - auto const& this_node = theContext()->getNode(); - ::fmt::print("work2: node={}, idx={}\n", this_node, getIndex().x()); -} - -static void reduceNone(MyReduceMsg* msg) { - if (msg->isRoot()) { - fmt::print("{}: at root: final num={}\n", theContext()->getNode(), msg->num); - } else { - MyReduceMsg* fst_msg = msg; - MyReduceMsg* cur_msg = msg->getNext(); - while (cur_msg != nullptr) { - // fmt::print( - // "{}: while fst_msg={}: cur_msg={}, is_root={}, count={}, next={}, num={}\n", - // theContext()->getNode(), - // print_ptr(fst_msg), print_ptr(cur_msg), print_bool(cur_msg->isRoot()), - // cur_msg->getCount(), print_ptr(cur_msg->getNext()), - // cur_msg->num - // ); - fst_msg->num += cur_msg->num; - cur_msg = cur_msg->getNext(); - } - } -} - -void ColA::work(TestMsg* msg) { - auto const& this_node = theContext()->getNode(); - ::fmt::print("work: node={}, idx={}\n", this_node, getIndex().x()); - - if (getIndex().x() == 2) { - auto const& proxy = getCollectionProxy(); - auto const& msg2 = makeSharedMessage(); - proxy.broadcast(msg2); - } - - auto reduce_msg = makeSharedMessage(getIndex().x()); - auto const& proxy = getCollectionProxy(); - theCollection()->reduceMsg(proxy, reduce_msg); -} - -struct HelloMsg : vt::Message { - int from; - - explicit HelloMsg(int const& in_from) - : Message(), from(in_from) - { } -}; - -struct SysMsg : collective::ReduceTMsg { - explicit SysMsg(int in_num) - : ReduceTMsg(in_num) - { } -}; - -struct Print { - void operator()(SysMsg* msg) { - fmt::print("final value={}\n", msg->getConstVal()); - } -}; - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); - - if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - - if (my_node == 0) { - auto const& range = Index1D(std::max(num_nodes / 2, 1)); - //auto const& range = Index1D(static_cast(num_nodes)); - auto const& proxy = theCollection()->construct(range); - auto const& msg = makeSharedMessage(); - proxy.broadcast(msg); - // proxy.broadcast(msg); - // proxy.broadcast(msg); - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} diff --git a/tests/unit/collection/test_collection_group.cc b/tests/unit/collection/test_collection_group.cc new file mode 100644 index 0000000000..0e6c126f61 --- /dev/null +++ b/tests/unit/collection/test_collection_group.cc @@ -0,0 +1,99 @@ +/* +//@HEADER +// ***************************************************************************** +// +// test_collection_group.cc +// DARMA Toolkit v. 1.0.0 +// DARMA/vt => Virtual Transport +// +// Copyright 2019 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 + +#include "test_parallel_harness.h" +#include "test_collection_common.h" +#include "data_message.h" + +#include "vt/transport.h" + +#include + +namespace vt { namespace tests { namespace unit { + +struct MyReduceMsg : collective::ReduceTMsg { + explicit MyReduceMsg(int const in_num) + : collective::ReduceTMsg(in_num) + { } +}; + +struct ColA : Collection { + struct TestMsg : CollectionMessage { }; + + void finishedReduce(MyReduceMsg* m) { + fmt::print("at root: final num={}\n", m->getVal()); + finished = true; + } + + void doReduce(TestMsg* msg) { + auto const proxy = getCollectionProxy(); + auto cb = theCB()->makeBcast(proxy); + auto reduce_msg = makeMessage(getIndex().x()); + proxy.reduce>(reduce_msg.get(),cb); + } + + virtual ~ColA() { + EXPECT_TRUE(finished); + } + +private: + bool finished = false; +}; + +struct TestCollectionGroup : TestParallelHarness { }; + + +TEST_F(TestCollectionGroup, test_collection_group_1) { + auto const my_node = theContext()->getNode(); + auto const num_nodes = theContext()->getNumNodes(); + if (my_node == 0) { + auto const range = Index1D(std::max(num_nodes / 2, 1)); + auto const proxy = theCollection()->construct(range); + proxy.broadcast(); + } +} + +}}} // end namespace vt::tests::unit From 40d8e27c2ecb9432a792fc75309221982d2111f3 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 7 Nov 2019 08:39:02 -0800 Subject: [PATCH 17/88] #526: example: make ex../comm_func.cc a perf-test instead --- examples/CMakeLists.txt | 1 - tests/CMakeLists.txt | 2 ++ examples/comm_func.cc => tests/perf/comm_cost_curve.cc | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) rename examples/comm_func.cc => tests/perf/comm_cost_curve.cc (98%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 868a375596..c42e638c0b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -3,7 +3,6 @@ set( PROJECT_EXAMPLES_LIST hello_world ring - comm_func rdma_simple_get rdma_simple_get_direct rdma_simple_put diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a4bce791d2..d0f4134fa9 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,6 +2,7 @@ # CMake for gtests # ################################################################################ + set(PROJECT_TEST_UNIT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/unit) set(PROJECT_TEST_PERF_DIR ${CMAKE_CURRENT_SOURCE_DIR}/perf) @@ -9,6 +10,7 @@ set( PROJECT_PERF_TESTS ping_pong memory_checker + comm_cost_curve ) set( diff --git a/examples/comm_func.cc b/tests/perf/comm_cost_curve.cc similarity index 98% rename from examples/comm_func.cc rename to tests/perf/comm_cost_curve.cc index b2a4616b8c..a28158a890 100644 --- a/examples/comm_func.cc +++ b/tests/perf/comm_cost_curve.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// comm_func.cc +// comm_cost_curve.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // From 879f05aa1ccc1cc5acf385d42301534b6bc5532f Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 13 Nov 2019 17:01:44 -0800 Subject: [PATCH 18/88] #526: example: cleanup/rewrite ctx_callback --- examples/ctx_callback.cc | 55 +++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/examples/ctx_callback.cc b/examples/ctx_callback.cc index 69d1dbd0b7..f100495a64 100644 --- a/examples/ctx_callback.cc +++ b/examples/ctx_callback.cc @@ -42,18 +42,16 @@ //@HEADER */ -#include "vt/transport.h" +#include -#include -#include - -using namespace ::vt; +#include +// Define a context class struct MyContext { int x = 29; }; -struct DataMsg : Message { +struct DataMsg : vt::Message { DataMsg() = default; template @@ -64,49 +62,54 @@ struct DataMsg : Message { std::vector vec_; }; -struct Msg : Message { - Msg() = default; - explicit Msg(Callback in_cb) : cb(in_cb) { } +// Message that contains the callback +struct CallbackMsg : vt::Message { + CallbackMsg() = default; + explicit CallbackMsg(vt::Callback in_cb) : cb(in_cb) { } - Callback cb; + vt::Callback cb; }; -static void callback_fn(DataMsg* msg, MyContext* ctx) { - ::fmt::print("callback_fn: msg={}, ctx={}\n", print_ptr(msg), print_ptr(ctx)); - ::fmt::print("callback_fn: x={}, vec.size={}\n", ctx->x, msg->vec_.size()); +// Special handler that takes a data message and a context +static void callbackFn(DataMsg* msg, MyContext* ctx) { + fmt::print("callbackFn: msg={}, ctx={}\n", print_ptr(msg), print_ptr(ctx)); + fmt::print("callbackFn: x={}, vec.size={}\n", ctx->x, msg->vec_.size()); for (auto&& elm : msg->vec_) { - ::fmt::print("\t elm={}\n", elm); + fmt::print("\t elm={}\n", elm); } } -static void handler(Msg* msg) { +// Handler that triggers the callback +static void handler(CallbackMsg* msg) { auto cb = msg->cb; - auto data_msg = makeSharedMessage(); + auto data_msg = vt::makeMessage(); data_msg->vec_ = std::vector{18,45,28,-1,344}; - ::fmt::print("handler: vec.size={}\n", data_msg->vec_.size()); - cb.send(data_msg); + fmt::print("handler: vec.size={}\n", data_msg->vec_.size()); + cb.send(data_msg.get()); } +// Some instance of the context static MyContext my_global_ctx = {}; int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& this_node = theContext()->getNode(); + vt::NodeType this_node = vt::theContext()->getNode(); if (this_node == 0) { my_global_ctx.x = 1283; - auto cb = theCB()->makeFunc(&my_global_ctx, callback_fn); - auto msg = makeSharedMessage(cb); - theMsg()->sendMsg(1, msg); + // Make a callback that triggers the callback with a context + auto cb = vt::theCB()->makeFunc(&my_global_ctx, callbackFn); + auto msg = vt::makeMessage(cb); + vt::theMsg()->sendMsg(1, msg.get()); } - while (!rt->isTerminated()) { - runScheduler(); + while (!vt::rt->isTerminated()) { + vt::runScheduler(); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From adc308b7b8fd3f322f323a23b77e006ed6ef9d5b Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 13 Nov 2019 17:21:19 -0800 Subject: [PATCH 19/88] #526: example: remove epoch_example---not an example --- examples/CMakeLists.txt | 1 - examples/epoch_example.cc | 90 --------------------------------------- 2 files changed, 91 deletions(-) delete mode 100644 examples/epoch_example.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c42e638c0b..20a3e7a86e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -17,7 +17,6 @@ set( term_epoch term_epoch_advanced term_ds - epoch_example trace_ring location_test location_test_msg diff --git a/examples/epoch_example.cc b/examples/epoch_example.cc deleted file mode 100644 index c6d6a229c5..0000000000 --- a/examples/epoch_example.cc +++ /dev/null @@ -1,90 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// epoch_example.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" - -#include -#include - -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - - { - EpochType seq = 0xFFAA; - auto const rooted = epoch::EpochManip::makeEpoch(seq, true, my_node, false); - auto const is_rooted = epoch::EpochManip::isRooted(rooted); - auto const is_user = epoch::EpochManip::isUser(rooted); - auto const has_category = epoch::EpochManip::hasCategory(rooted); - auto const get_seq = epoch::EpochManip::seq(rooted); - auto const ep_node = epoch::EpochManip::node(rooted); - auto const next = epoch::EpochManip::next(rooted); - auto const next_seq = epoch::EpochManip::seq(next); - - fmt::print( - "rooted epoch={}, is_rooted={}, has_cat={}, is_user={}, get_seq={}, " - "node={}, next={}, next_seq={}, num={}, end={}\n", - rooted, is_rooted, has_category, is_user, get_seq, ep_node, next, - next_seq, epoch::epoch_seq_num_bits, epoch::eEpochLayout::EpochSentinelEnd - ); - fmt::print("epoch={}, seq={}\n", rooted, get_seq); - fmt::print("epoch {}, {:x} : seq {}, {:x}\n", rooted, rooted, get_seq, get_seq); - fmt::print("epoch {}, {:x} : seq {}, {:x}\n", next, next, next_seq, next_seq); - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From f0b88a243598ae98164d08f7f6bd16561212df01 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 13 Nov 2019 17:22:30 -0800 Subject: [PATCH 20/88] #526: example: minor cleanup on hello_world --- examples/hello_world.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/hello_world.cc b/examples/hello_world.cc index aab2aadbc5..46ab2e0997 100644 --- a/examples/hello_world.cc +++ b/examples/hello_world.cc @@ -42,8 +42,7 @@ //@HEADER */ -#include "vt/transport.h" -#include +#include struct HelloMsg : vt::Message { HelloMsg(vt::NodeType in_from) : from(in_from) { } From c7d2770a133339b2f356181a1bb48ce17943cb69 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 13 Nov 2019 17:23:46 -0800 Subject: [PATCH 21/88] #526: example: remove index_test, redundant w/real test --- examples/CMakeLists.txt | 1 - examples/index_test.cc | 101 ---------------------------------------- 2 files changed, 102 deletions(-) delete mode 100644 examples/index_test.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 20a3e7a86e..99a3c53c23 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -21,7 +21,6 @@ set( location_test location_test_msg lb_iter - index_test hello_world_vrtContext hello_world_vc jacobi1d_recur_vc diff --git a/examples/index_test.cc b/examples/index_test.cc deleted file mode 100644 index c0b0644876..0000000000 --- a/examples/index_test.cc +++ /dev/null @@ -1,101 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// index_test.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 - -#include "vt/transport.h" - -using namespace vt; - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - auto const& num_nodes = theContext()->getNumNodes(); - - Index2D idx(2, 3); - Index2D idx2(5, 10); - Index2D idx3 = idx2 - idx; - - Index1D idx_1d(10); - Index1D idx_1d_2(20); - - auto node = mapping::dense1DBlockMap(&idx_1d, &idx_1d_2, num_nodes); - - fmt::print( - "idx={}, idx2={}, idx3={}, size={}, node={}\n", - idx, idx2, idx3, sizeof(idx), node - ); - - int const dim1 = 4, dim2 = 5; - Index2D idx_a(2, 2); - Index2D idx_a_max(dim1, dim2); - - auto node_a = mapping::dense2DBlockMap(&idx_a, &idx_a_max, num_nodes); - - int cur_val = 0; - for (int i = 0; i < dim1; i++) { - for (int j = 0; j < dim2; j++) { - auto cur_idx = Index2D(i,j); - auto lin_idx = mapping::linearizeDenseIndexColMajor(&cur_idx, &idx_a_max); - fmt::print( - "idx={}, max={}, lin={}\n", - cur_idx, idx_a_max, lin_idx - ); - vtAssertExpr(lin_idx == cur_val); - cur_val++; - } - } - - fmt::print( - "idx_a={}, indx_a_max={}, node={}\n", idx_a, idx_a_max, node_a - ); - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From c5aaf3c5d718b2db2ff391b0fa202107aaa156d5 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 13 Nov 2019 17:26:14 -0800 Subject: [PATCH 22/88] #526: example: minor cleanup of objgroup --- examples/objgroup.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/objgroup.cc b/examples/objgroup.cc index c88574058b..07b50aadc1 100644 --- a/examples/objgroup.cc +++ b/examples/objgroup.cc @@ -42,7 +42,7 @@ //@HEADER */ -#include "vt/transport.h" +#include struct MyMsg : vt::Message { MyMsg(int in_a, int in_b) : a(in_a), b(in_b) { } @@ -59,8 +59,8 @@ struct MyObjGroup { int main(int argc, char** argv) { vt::initialize(argc, argv, nullptr); - auto const& this_node = vt::theContext()->getNode(); - auto const& num_nodes = vt::theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes < 2) { return 0; From 8dc991123efede1de3a27f83c887e711d3f226ec Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:28:04 -0700 Subject: [PATCH 23/88] #526: example: rewrite/cleanup group_collective --- examples/group_collective.cc | 84 +++++++++++++----------------------- 1 file changed, 31 insertions(+), 53 deletions(-) diff --git a/examples/group_collective.cc b/examples/group_collective.cc index d68dc2cc6b..06930baab9 100644 --- a/examples/group_collective.cc +++ b/examples/group_collective.cc @@ -42,99 +42,77 @@ //@HEADER */ -#include "vt/transport.h" -#include - -using namespace vt; -using namespace vt::group; - -static GroupType this_group = no_group; +#include struct HelloMsg : vt::Message { int from; explicit HelloMsg(int const& in_from) - : Message(), from(in_from) + : from(in_from) { } }; -struct HelloGroupMsg : ::vt::Message { - HelloGroupMsg() = default; -}; - -#pragma GCC diagnostic ignored "-Wunused-function" -static void hello_world(HelloMsg* msg) { - fmt::print("{}: Hello from node {}\n", theContext()->getNode(), msg->from); -} +struct HelloGroupMsg : vt::Message { }; static void hello_group_handler(HelloGroupMsg* msg) { - fmt::print("{}: Hello from group handler\n", theContext()->getNode()); + fmt::print("{}: Hello from group handler\n", vt::theContext()->getNode()); } -struct SysMsg : collective::ReduceTMsg { - explicit SysMsg(int in_num) - : ReduceTMsg(in_num) - { } -}; +using ReduceMsg = vt::collective::ReduceTMsg; struct Print { - void operator()(SysMsg* msg) { + void operator()(ReduceMsg* msg) { fmt::print("final value={}\n", msg->getConstVal()); } }; int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes < 2) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); + vt::output("requires at least 2 nodes"); + vt::finalize(); return 0; } - srand48(my_node * 29); + srand48(this_node * 29); - //auto const& random_node_filter = drand48() < 0.5; - //auto const& even_node_filter = my_node % 2 == 0; - auto const& odd_node_filter = my_node % 2 == 1; + bool odd_node_filter = this_node % 2 == 1; - this_group = theGroup()->newGroupCollective( - odd_node_filter, [=](GroupType group){ + vt::GroupType new_group = vt::theGroup()->newGroupCollective( + odd_node_filter, [=](vt::GroupType group){ auto const& root = 0; - auto const& in_group = theGroup()->inGroup(group); - auto const& root_node = theGroup()->groupRoot(group); - auto const& is_default_group = theGroup()->groupDefault(group); + auto const& in_group = vt::theGroup()->inGroup(group); + auto const& root_node = vt::theGroup()->groupRoot(group); + auto const& is_default_group = vt::theGroup()->groupDefault(group); fmt::print( "{}: Group is created: group={}, in_group={}, root={}, " "is_default_group={}\n", - my_node, group, in_group, root_node, is_default_group + this_node, group, in_group, root_node, is_default_group ); if (in_group) { - auto msg = makeSharedMessage(1); - //fmt::print("msg->num={}\n", msg->getConstVal()); - theGroup()->groupReduce(group)->reduce< - SysMsg, SysMsg::msgHandler,Print> - >(root, msg); + using Op = vt::collective::PlusOp; + auto msg = vt::makeMessage(1); + vt::theGroup()->groupReduce(group)->reduce(root, msg.get()); } - fmt::print("node={}\n", my_node); - if (my_node == 1) { - //vtAssertExpr(in_group); - auto msg = makeSharedMessage(); - envelopeSetGroup(msg->env, group); - fmt::print("calling broadcasting={}\n", my_node); - theMsg()->broadcastMsg(msg); + if (this_node == 1) { + auto msg = vt::makeMessage(); + vt::envelopeSetGroup(msg->env, group); + vt::theMsg()->broadcastMsg(msg.get()); } } ); - while (!rt->isTerminated()) { - runScheduler(); + fmt::print("{}: New group={}\n", this_node, new_group); + + while (!vt::rt->isTerminated()) { + vt::runScheduler(); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From db197c856aad500264f40f4f9aa6e506ad080de8 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:34:42 -0700 Subject: [PATCH 24/88] #526: example: rewrite/cleanup group_example_1->group_rooted --- examples/CMakeLists.txt | 2 +- .../{group_example_1.cc => group_rooted.cc} | 60 +++++++------------ 2 files changed, 24 insertions(+), 38 deletions(-) rename examples/{group_example_1.cc => group_rooted.cc} (62%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 99a3c53c23..d758a15a11 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -36,7 +36,7 @@ set( simple_collection_reduce collection_insert rdma_unsized_collection - group_example_1 + group_rooted group_collective reduce transpose diff --git a/examples/group_example_1.cc b/examples/group_rooted.cc similarity index 62% rename from examples/group_example_1.cc rename to examples/group_rooted.cc index a319cd9edd..894b3a6c46 100644 --- a/examples/group_example_1.cc +++ b/examples/group_rooted.cc @@ -42,69 +42,55 @@ //@HEADER */ -#include "vt/transport.h" -#include - -using namespace vt; -using namespace vt::group; - -static GroupType this_group = no_group; +#include struct HelloMsg : vt::Message { int from; HelloMsg(int const& in_from) - : Message(), from(in_from) + : from(in_from) { } }; -struct HelloGroupMsg : ::vt::Message { - HelloGroupMsg() = default; -}; - static void hello_world(HelloMsg* msg) { - fmt::print("{}: Hello from node {}\n", theContext()->getNode(), msg->from); + fmt::print("{}: Hello from node {}\n", vt::theContext()->getNode(), msg->from); } -static void hello_group_handler(HelloGroupMsg* msg) { - fmt::print("{}: Hello from group handler\n", theContext()->getNode()); +static void hello_group_handler(HelloMsg* msg) { + fmt::print("{}: Hello from group {}\n", vt::theContext()->getNode(), msg->from); } int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); + vt::output("requires at least 2 nodes"); + vt::finalize(); return 0; } - if (my_node == 0) { - HelloMsg* msg = makeSharedMessage(my_node); - theMsg()->broadcastMsg(msg); + if (this_node == 0) { + auto msg = vt::makeMessage(this_node); + vt::theMsg()->broadcastMsg(msg.get()); + + using RangeType = vt::group::region::Range; + auto list = std::make_unique(num_nodes / 2, num_nodes); - //std::vector vec{0,1,2,3,4,5,6,7}; - //auto list = std::make_unique(vec); - auto list = std::make_unique( - theContext()->getNumNodes() / 2, - theContext()->getNumNodes() - ); - this_group = theGroup()->newGroup(std::move(list), [](GroupType group){ - fmt::print("Group is created\n"); - auto gmsg = makeSharedMessage(); - envelopeSetGroup(gmsg->env, group); - theMsg()->broadcastMsg(gmsg); + vt::theGroup()->newGroup(std::move(list), [=](vt::GroupType group){ + auto gmsg = vt::makeMessage(this_node); + vt::envelopeSetGroup(gmsg->env, group); + vt::theMsg()->broadcastMsg(gmsg.get()); }); } - while (!rt->isTerminated()) { - runScheduler(); + while (!vt::rt->isTerminated()) { + vt::runScheduler(); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From 06a5aa38ab6f8ba80c3a31c76ec2bac458f18554 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:35:36 -0700 Subject: [PATCH 25/88] #526: example: use MsgSharedPtr in hello_world --- examples/hello_world.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/hello_world.cc b/examples/hello_world.cc index 46ab2e0997..2dcf769d48 100644 --- a/examples/hello_world.cc +++ b/examples/hello_world.cc @@ -66,8 +66,8 @@ int main(int argc, char** argv) { } if (this_node == 0) { - auto msg = vt::makeSharedMessage(this_node); - vt::theMsg()->broadcastMsg(msg); + auto msg = vt::makeMessage(this_node); + vt::theMsg()->broadcastMsg(msg.get()); } while (!vt::rt->isTerminated()) { From 7a13632f7562a1d339521e37680c2c09e82c22df Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:37:54 -0700 Subject: [PATCH 26/88] #526: example: cleanup hello_world_functor --- examples/hello_world_functor.cc | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/examples/hello_world_functor.cc b/examples/hello_world_functor.cc index 9b12cc4584..809d2718bf 100644 --- a/examples/hello_world_functor.cc +++ b/examples/hello_world_functor.cc @@ -42,47 +42,44 @@ //@HEADER */ -#include "vt/transport.h" -#include - -using namespace vt; +#include struct HelloMsg : vt::Message { int from; - HelloMsg(int const& in_from) - : Message(), from(in_from) + explicit HelloMsg(int const& in_from) + : from(in_from) { } }; struct HelloWorld { void operator()(HelloMsg* msg) const { - fmt::print("{}: Hello from node {}\n", theContext()->getNode(), msg->from); + fmt::print("{}: Hello from node {}\n", vt::theContext()->getNode(), msg->from); } }; int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); + vt::output("requires at least 2 nodes"); + vt::finalize(); return 0; } - if (my_node == 0) { - HelloMsg* msg = makeSharedMessage(my_node); - theMsg()->broadcastMsg(msg); + if (this_node == 0) { + auto msg = vt::makeMessage(this_node); + vt::theMsg()->broadcastMsg(msg.get()); } - while (!rt->isTerminated()) { - runScheduler(); + while (!vt::rt->isTerminated()) { + vt::runScheduler(); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From 5c21c477de2ea887dcabe8d058c3d577dc9232fb Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:43:50 -0700 Subject: [PATCH 27/88] #526: example: remove some scheduler loops, use rerror --- examples/ctx_callback.cc | 4 ---- examples/group_collective.cc | 8 +------- examples/group_rooted.cc | 8 +------- examples/hello_world.cc | 4 ---- examples/hello_world_functor.cc | 8 +------- 5 files changed, 3 insertions(+), 29 deletions(-) diff --git a/examples/ctx_callback.cc b/examples/ctx_callback.cc index f100495a64..f0649fe168 100644 --- a/examples/ctx_callback.cc +++ b/examples/ctx_callback.cc @@ -105,10 +105,6 @@ int main(int argc, char** argv) { vt::theMsg()->sendMsg(1, msg.get()); } - while (!vt::rt->isTerminated()) { - vt::runScheduler(); - } - vt::finalize(); return 0; diff --git a/examples/group_collective.cc b/examples/group_collective.cc index 06930baab9..c6b03a619d 100644 --- a/examples/group_collective.cc +++ b/examples/group_collective.cc @@ -73,9 +73,7 @@ int main(int argc, char** argv) { vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes < 2) { - vt::output("requires at least 2 nodes"); - vt::finalize(); - return 0; + return vt::rerror("requires at least 2 nodes"); } srand48(this_node * 29); @@ -108,10 +106,6 @@ int main(int argc, char** argv) { fmt::print("{}: New group={}\n", this_node, new_group); - while (!vt::rt->isTerminated()) { - vt::runScheduler(); - } - vt::finalize(); return 0; diff --git a/examples/group_rooted.cc b/examples/group_rooted.cc index 894b3a6c46..740587e26b 100644 --- a/examples/group_rooted.cc +++ b/examples/group_rooted.cc @@ -67,9 +67,7 @@ int main(int argc, char** argv) { vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes == 1) { - vt::output("requires at least 2 nodes"); - vt::finalize(); - return 0; + return vt::rerror("requires at least 2 nodes"); } if (this_node == 0) { @@ -86,10 +84,6 @@ int main(int argc, char** argv) { }); } - while (!vt::rt->isTerminated()) { - vt::runScheduler(); - } - vt::finalize(); return 0; diff --git a/examples/hello_world.cc b/examples/hello_world.cc index 2dcf769d48..2acec33261 100644 --- a/examples/hello_world.cc +++ b/examples/hello_world.cc @@ -70,10 +70,6 @@ int main(int argc, char** argv) { vt::theMsg()->broadcastMsg(msg.get()); } - while (!vt::rt->isTerminated()) { - vt::runScheduler(); - } - vt::finalize(); return 0; diff --git a/examples/hello_world_functor.cc b/examples/hello_world_functor.cc index 809d2718bf..cb1dcbc746 100644 --- a/examples/hello_world_functor.cc +++ b/examples/hello_world_functor.cc @@ -65,9 +65,7 @@ int main(int argc, char** argv) { vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes == 1) { - vt::output("requires at least 2 nodes"); - vt::finalize(); - return 0; + return vt::rerror("requires at least 2 nodes"); } if (this_node == 0) { @@ -75,10 +73,6 @@ int main(int argc, char** argv) { vt::theMsg()->broadcastMsg(msg.get()); } - while (!vt::rt->isTerminated()) { - vt::runScheduler(); - } - vt::finalize(); return 0; From 21fe00bf550e663a9fc068250e69ef0fc1669a09 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:49:22 -0700 Subject: [PATCH 28/88] #526: example: fix hello_world_start --- examples/CMakeLists.txt | 1 + examples/hello_world_start.cc | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d758a15a11..c45de30a78 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -13,6 +13,7 @@ set( ctx_callback param hello_world_functor + hello_world_start test_seq term_epoch term_epoch_advanced diff --git a/examples/hello_world_start.cc b/examples/hello_world_start.cc index 15dc93b851..bfc2e71273 100644 --- a/examples/hello_world_start.cc +++ b/examples/hello_world_start.cc @@ -70,6 +70,9 @@ using namespace vt::mapping; #endif struct ProxyMsg : vt::vrt::VirtualMessage { + using MessageParentType = vt::vrt::VirtualMessage; + vt_msg_serialize_required(); // by proxies + std::vector proxies; ProxyMsg() = default; @@ -79,17 +82,21 @@ struct ProxyMsg : vt::vrt::VirtualMessage { template void serialize(SerializerT& s) { + MessageParentType::serialize(s); s | proxies; } }; struct WorkMsg : vt::vrt::VirtualMessage { + using MessageParentType = vt::vrt::VirtualMessage; + vt_msg_serialize_required(); // by work_vec std::vector work_vec; WorkMsg() = default; template void serialize(SerializerT& s) { + MessageParentType::serialize(s); s | work_vec; } }; From 3eaea50590ae92a43531b11b3bdd009c2e764a4b Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:49:41 -0700 Subject: [PATCH 29/88] #526: example: remove hello_world_start, not a good example --- examples/CMakeLists.txt | 1 - examples/hello_world_start.cc | 251 ---------------------------------- 2 files changed, 252 deletions(-) delete mode 100644 examples/hello_world_start.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c45de30a78..d758a15a11 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -13,7 +13,6 @@ set( ctx_callback param hello_world_functor - hello_world_start test_seq term_epoch term_epoch_advanced diff --git a/examples/hello_world_start.cc b/examples/hello_world_start.cc deleted file mode 100644 index bfc2e71273..0000000000 --- a/examples/hello_world_start.cc +++ /dev/null @@ -1,251 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// hello_world_start.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include "vt/utils/tls/tls.h" - -#include -#include -#include - -using namespace vt; -using namespace vt::vrt; -using namespace vt::mapping; - -#define DEBUG_START_EXAMPLE 0 - -#define DEBUG_PRINTER_START(str, ...) \ - do{ \ - fmt::print( \ - "node={},worker={}: " str, \ - theContext()->getNode(), theContext()->getWorker(), __VA_ARGS__ \ - ); \ - } while (false); - -#if DEBUG_START_EXAMPLE - #define DEBUG_PRINT_START(str, ...) DEBUG_PRINTER_START(str, __VA_ARGS__) -#else - #define DEBUG_PRINT_START(str, ...) -#endif - -struct ProxyMsg : vt::vrt::VirtualMessage { - using MessageParentType = vt::vrt::VirtualMessage; - vt_msg_serialize_required(); // by proxies - - std::vector proxies; - - ProxyMsg() = default; - ProxyMsg(std::vector const& in_proxies) - : VirtualMessage(), proxies(in_proxies) - { } - - template - void serialize(SerializerT& s) { - MessageParentType::serialize(s); - s | proxies; - } -}; - -struct WorkMsg : vt::vrt::VirtualMessage { - using MessageParentType = vt::vrt::VirtualMessage; - vt_msg_serialize_required(); // by work_vec - std::vector work_vec; - - WorkMsg() = default; - - template - void serialize(SerializerT& s) { - MessageParentType::serialize(s); - s | work_vec; - } -}; - -struct TestVC; -static void doWorkRight(WorkMsg* msg, TestVC* vc); - -static ::vt::util::atomic::AtomicType num_work_finished = {0}; - -DeclareInitTLS(int, tls_work, 0); - -struct TestVC : vt::vrt::VirtualContext { - VirtualProxyType my_proxy = no_vrt_proxy; - VirtualProxyType right_proxy = no_vrt_proxy; - int my_index = 0; - int work_amt = 0; - - double stored_val = 0.0; - - TestVC(int const in_my_index, int const in_work_amt) - : my_index(in_my_index), work_amt(in_work_amt) - { - DEBUG_PRINT_START( - "node={}, worker={}: {}: constructing TestVC: my_index={}, work amt={}\n", - theContext()->getNode(), theContext()->getWorker(), this, my_index, - work_amt - ); - } - - void getRightProxy(ProxyMsg* msg) { - my_proxy = msg->proxies[my_index]; - - DEBUG_PRINT_START( - "my_proxy={}, index={}, getProxy()={}, ptr={}\n", - my_proxy, my_index, getProxy(), this - ); - - vtAssertExpr(my_proxy == getProxy()); - - auto const to_right = my_index+1; - bool const has_right = to_right < msg->proxies.size(); - - if (has_right) { - right_proxy = msg->proxies[to_right]; - } - - DEBUG_PRINT_START( - "my_proxy={}, proxies size={}, right={} vc={} has_right={}, " - "right proxy={}\n", - getProxy(), msg->proxies.size(), to_right, this, print_bool(has_right), - right_proxy - ); - - if (has_right) { - auto msg = makeSharedMessage(); - for (auto i = 0; i < my_index + 29; i++) { - msg->work_vec.push_back(static_cast(work_amt)); - } - - theVirtualManager()->sendSerialMsg( - right_proxy, msg - ); - } - } - - void doWork(WorkMsg* msg) { - DEBUG_PRINT_START( - "my_proxy={}, doing work size={}\n", my_proxy, msg->work_vec.size() - ); - - double val = 1.23; - for (auto&& elm : msg->work_vec) { - val += elm * 3.14159; - } - stored_val = val; - - num_work_finished++; - AccessTLS(tls_work)++; - - DEBUG_PRINT_START( - "my_proxy={}, finished work val={}\n", my_proxy, stored_val - ); - } -}; - -static void doWorkRight(WorkMsg* msg, TestVC* vc) { - DEBUG_PRINT_START( - "doWorkRight: msg->work_vec.size()={}, vc={}\n", msg->work_vec.size(), vc - ); - vc->doWork(msg); -} - -static void proxyHan(ProxyMsg* msg, TestVC* vc) { - DEBUG_PRINT_START("proxyHan: msg->proxies={}, vc={}\n", msg->proxies.size(), vc); - vc->getRightProxy(msg); -} - -struct MakeMainMsg : vt::Message { }; -static void makeMain(MakeMainMsg* msg); - -struct MainVC : vt::vrt::MainVirtualContext { - int my_data = -1; - - MainVC() : my_data(29) { - DEBUG_PRINT_START("constructing MainVC: data={}\n", my_data); - - if (theContext()->getNode() == 0) { - auto msg = makeSharedMessage(); - theMsg()->broadcastMsg(msg); - } - - theTerm()->addAction([]{ - auto const num_work_units = num_work_finished.load(); - DEBUG_PRINTER_START("num_work_units={}\n", num_work_units); - - // theWorkerGrp()->enqueueAllWorkers([]{ - // auto const num_work_units = AccessTLS(tls_work); - // DEBUG_PRINTER_START("tls work_units={}\n", num_work_units); - // }); - }); - - std::vector proxies; - - for (auto i = 0; i < my_data; i++) { - //auto proxy = theVirtualManager()->makeVirtual(i, i * 82773); - auto proxy = theVirtualManager()->makeVirtualMap( - i, i * 82773 - ); - proxies.push_back(proxy); - - DEBUG_PRINT_START( - "{}: constructing proxy {}, size={}, work={}\n", - i, proxy, proxies.size(), i*82773 - ); - } - - int i = 0; - for (auto&& elm : proxies) { - ProxyMsg* msg = makeSharedMessage(proxies); - DEBUG_PRINT_START("{}: sending to proxy {}\n", i, elm); - theVirtualManager()->sendSerialMsg(elm, msg); - i++; - } - } -}; - -static void makeMain(MakeMainMsg* msg) { - theVirtualManager()->makeVirtual(); -} - - -VT_REGISTER_MAIN_CONTEXT(MainVC); From 9d81216f8939d6fa8477fefd547b336e62ef512a Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:54:07 -0700 Subject: [PATCH 30/88] #526: example: rewrite hello_world_vc --- examples/CMakeLists.txt | 2 +- ...d_vc.cc => hello_world_virtual_context.cc} | 58 ++++++++----------- 2 files changed, 26 insertions(+), 34 deletions(-) rename examples/{hello_world_vc.cc => hello_world_virtual_context.cc} (69%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index d758a15a11..9cd38b957f 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,7 +22,7 @@ set( location_test_msg lb_iter hello_world_vrtContext - hello_world_vc + hello_world_virtual_context jacobi1d_recur_vc jacobi1d_node jacobi1d_vt diff --git a/examples/hello_world_vc.cc b/examples/hello_world_virtual_context.cc similarity index 69% rename from examples/hello_world_vc.cc rename to examples/hello_world_virtual_context.cc index 87d2f0602c..d6709213f6 100644 --- a/examples/hello_world_vc.cc +++ b/examples/hello_world_virtual_context.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// hello_world_vc.cc +// hello_world_virtual_context.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // @@ -42,82 +42,74 @@ //@HEADER */ -#include "vt/transport.h" -#include - -using namespace vt; -using namespace vt::vrt; +#include struct HelloMsg : vt::Message { - VirtualProxyType proxy; + vt::VirtualProxyType proxy; - HelloMsg(VirtualProxyType const& in_proxy) - : Message(), proxy(in_proxy) + explicit HelloMsg(vt::VirtualProxyType const& in_proxy) + : proxy(in_proxy) { } }; struct TestMsg : vt::vrt::VirtualMessage { int from = 0; - TestMsg(int const& in_from) - : VirtualMessage(), from(in_from) + explicit TestMsg(int const& in_from) + : from(in_from) { } }; struct MyVC : vt::vrt::VirtualContext { int my_data = 10; - MyVC(int const& my_data_in) : my_data(my_data_in) { } + explicit MyVC(int const& my_data_in) + : my_data(my_data_in) + { } }; static void my_han(TestMsg* msg, MyVC* vc) { - auto this_node = theContext()->getNode(); + auto this_node = vt::theContext()->getNode(); fmt::print( "{}: vc={}: msg->from={}, vc->my_data={}\n", this_node, print_ptr(vc), msg->from, vc->my_data ); } -static void sendMsgToProxy(VirtualProxyType const& proxy) { - auto this_node = theContext()->getNode(); +static void sendMsgToProxy(vt::VirtualProxyType const& proxy) { + auto this_node = vt::theContext()->getNode(); fmt::print("{}: sendMsgToProxy: proxy={}\n", this_node, proxy); - auto m = makeSharedMessage(this_node + 32); - theVirtualManager()->sendMsg(proxy, m); + auto m = vt::makeMessage(this_node + 32); + vt::theVirtualManager()->sendMsg(proxy, m.get()); } static void hello_world(HelloMsg* msg) { - auto this_node = theContext()->getNode(); + auto this_node = vt::theContext()->getNode(); fmt::print("{}: hello: proxy={}\n", this_node, msg->proxy); sendMsgToProxy(msg->proxy); } int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; + return vt::rerror("requires at least 2 nodes"); } - if (my_node == 0) { - auto proxy = theVirtualManager()->makeVirtual(29); + if (this_node == 0) { + auto proxy = vt::theVirtualManager()->makeVirtual(29); sendMsgToProxy(proxy); // send out the proxy to all the nodes - HelloMsg* msg = makeSharedMessage(proxy); - theMsg()->broadcastMsg(msg); - } - - while (!rt->isTerminated()) { - runScheduler(); + auto msg = vt::makeMessage(proxy); + vt::theMsg()->broadcastMsg(msg.get()); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From a19de4c6f7b421a75b89390d325c0598a2df55f9 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:57:08 -0700 Subject: [PATCH 31/88] #526: example: rewrite hello_world_vc_remote --- examples/CMakeLists.txt | 2 +- ... => hello_world_virtual_context_remote.cc} | 41 ++++++++----------- 2 files changed, 18 insertions(+), 25 deletions(-) rename examples/{hello_world_vc_remote.cc => hello_world_virtual_context_remote.cc} (75%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9cd38b957f..22b098bc4c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -28,7 +28,7 @@ set( jacobi1d_vt jacobi2d_vt serialize_example - hello_world_vc_remote + hello_world_virtual_context_remote hello_world_collection simple_collection simple_collection_collective diff --git a/examples/hello_world_vc_remote.cc b/examples/hello_world_virtual_context_remote.cc similarity index 75% rename from examples/hello_world_vc_remote.cc rename to examples/hello_world_virtual_context_remote.cc index 4b6d8bed35..efce4874d7 100644 --- a/examples/hello_world_vc_remote.cc +++ b/examples/hello_world_virtual_context_remote.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// hello_world_vc_remote.cc +// hello_world_virtual_context_remote.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // @@ -42,24 +42,22 @@ //@HEADER */ -#include "vt/transport.h" -#include - -using namespace vt; -using namespace vt::vrt; +#include struct TestMsg : vt::vrt::VirtualMessage { int from = 0; - TestMsg(int const& in_from) - : VirtualMessage(), from(in_from) + explicit TestMsg(int const& in_from) + : from(in_from) { } }; struct MyVC : vt::vrt::VirtualContext { int my_data = -1; - MyVC(int const& my_data_in) : my_data(my_data_in) { + explicit MyVC(int const& my_data_in) + : my_data(my_data_in) + { fmt::print("constructing myVC: data={}\n", my_data_in); } }; @@ -69,28 +67,23 @@ static void testHan(TestMsg* msg, MyVC* vc) { } int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - - if (my_node == 0) { - auto proxy = theVirtualManager()->makeVirtualNode(1, 45); - auto msg = makeSharedMessage(my_node); - theVirtualManager()->sendMsg(proxy, msg); + return vt::rerror("requires at least 2 nodes"); } - while (!rt->isTerminated()) { - runScheduler(); + if (this_node == 0) { + // Create a virtual context remotely on node 1, getting a proxy to it + auto proxy = vt::theVirtualManager()->makeVirtualNode(1, 45); + auto msg = vt::makeMessage(this_node); + vt::theVirtualManager()->sendMsg(proxy, msg.get()); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From a76eaf396896051918e48493d2879365d77bee08 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:58:23 -0700 Subject: [PATCH 32/88] #526: example: remove dirty, un-useful example --- examples/CMakeLists.txt | 1 - examples/hello_world_vrtContext.cc | 172 ----------------------------- 2 files changed, 173 deletions(-) delete mode 100644 examples/hello_world_vrtContext.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 22b098bc4c..a0b685d21c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -21,7 +21,6 @@ set( location_test location_test_msg lb_iter - hello_world_vrtContext hello_world_virtual_context jacobi1d_recur_vc jacobi1d_node diff --git a/examples/hello_world_vrtContext.cc b/examples/hello_world_vrtContext.cc deleted file mode 100644 index eeea46c50d..0000000000 --- a/examples/hello_world_vrtContext.cc +++ /dev/null @@ -1,172 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// hello_world_vrtContext.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 -#include - -#include "vt/transport.h" -#include "vt/vrt/context/context_vrt.h" -#include "vt/vrt/context/context_vrtmanager.h" - -using namespace vt; -using namespace vt::vrt; - -struct HelloMsg : vt::Message { - int from; - - explicit HelloMsg(int const& in_from) - : Message(), from(in_from) {} -}; - -struct HelloVrtContext : VirtualContext { - int from; - - explicit HelloVrtContext(int const& in_from) - : VirtualContext(), from(in_from) {} -}; - -static void hello_world(HelloMsg *msg) { - fmt::print("{}: Hello from node {}\n", theContext()->getNode(), msg->from); -} - -int main(int argc, char **argv) { - CollectiveOps::initialize(argc, argv); - - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); - - if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - - - - if (my_node == 1) { - - auto vrtc1 = theVirtualManager()->makeVirtual(10); - (void)vrtc1; - auto vrtc2 = theVirtualManager()->makeVirtual(20); - (void)vrtc2; - - // auto temp1 = theVrtCManager->getVrtContextByID(vrtc1); - // auto hello1 = static_cast(temp1); - - // theVrtCManager->destroyVrtContextByID(vrtc1); - // auto temp1_ = theVrtCManager->getVrtContextByID(vrtc1); - // auto hello1_ = static_cast(temp1); - - // if (temp1_ != nullptr) { - // std::cout << "Boom "<getVrtContextByID(vrtc2); - // auto hello2 = static_cast(temp2); - - // if (temp2 != nullptr) { - // std::cout << "Boom "<getVrtContextByID(id1); -//// auto temp2 = reinterpret_cast(theVrtCManager->find(id2)); -// -// if (temp1 == nullptr) { -// std::cout << "Cool" << std::endl; -// } -// -// auto temping = theVrtCManager->getVrtContextByID(id2); -// -// auto temp2 = static_cast(temping); -// -//// if (temp2 != nullptr) { -// std::cout << temp2->getVrtContextNode() << std::endl; -//// } -// -// auto vrtc1 = theVrtCManager->newVrtContext(); - -// vrtc.printVrtContext(); -// vrtc1.printVrtContext(); -// -// HelloVrtContext my_vrtc(20); -// -// my_vrtc.printVrtContext(); -// -// auto myHelloVrtC_proxy = -// theVrtCManager->newVrtContext(&my_vrtc); -// -// my_vrtc.printVrtContext(); -// std::cout << my_vrtc.from << std::endl; - - -// my_vrtc.printVrtContext(); -// theVrtCManager->newVrtContext(my_vrtc); -// my_vrtc.printVrtContext(); -// vrtc.printVrtContext(); -// vrtc1.printVrtContext(); -//// std::cout << "My node: " << vrtc.getVrtContextNode() << std::endl; -//// std::cout << theVrtCManager_->newVrtContext() << std::endl; -// -// std::cout << my_vrtc.getVrtContextUId() << std::endl; -// std::cout << my_vrtc.isCollection() << std::endl; - - auto msg = makeSharedMessage(my_node); - theMsg()->broadcastMsg(msg); - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From 12d1d0ce86e188f3f8bfeed559040691176e167d Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 18:59:36 -0700 Subject: [PATCH 33/88] #526: example: rename ctx_callback --- examples/CMakeLists.txt | 2 +- examples/{ctx_callback.cc => callback_context.cc} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename examples/{ctx_callback.cc => callback_context.cc} (98%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a0b685d21c..7ef0a9b5f4 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -10,7 +10,7 @@ set( rdma_simple_channel rdma_channel_sync rdma_collective - ctx_callback + callback_context param hello_world_functor test_seq diff --git a/examples/ctx_callback.cc b/examples/callback_context.cc similarity index 98% rename from examples/ctx_callback.cc rename to examples/callback_context.cc index f0649fe168..c6cb37c9b3 100644 --- a/examples/ctx_callback.cc +++ b/examples/callback_context.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// ctx_callback.cc +// callback_context.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // From 38f027e1401ab088d50531fb6277e0d29104e3b5 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 19:11:42 -0700 Subject: [PATCH 34/88] #526: example: rewrite collection_insert --- examples/CMakeLists.txt | 2 +- ...ion_insert.cc => insertable_collection.cc} | 66 +++++-------------- 2 files changed, 18 insertions(+), 50 deletions(-) rename examples/{collection_insert.cc => insertable_collection.cc} (63%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 7ef0a9b5f4..6d59937bda 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -33,7 +33,7 @@ set( simple_collection_collective simple_collection_insert simple_collection_reduce - collection_insert + insertable_collection rdma_unsized_collection group_rooted group_collective diff --git a/examples/collection_insert.cc b/examples/insertable_collection.cc similarity index 63% rename from examples/collection_insert.cc rename to examples/insertable_collection.cc index 57dcb65060..925c0ea5c2 100644 --- a/examples/collection_insert.cc +++ b/examples/insertable_collection.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// collection_insert.cc +// insertable_collection.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // @@ -42,82 +42,50 @@ //@HEADER */ -#include "vt/transport.h" - -#include - -using namespace ::vt; -using namespace ::vt::collective; -using namespace ::vt::mapping; +#include static constexpr int32_t const default_num_elms = 64; -struct InsertCol : InsertableCollection { - InsertCol() - : InsertableCollection() - { - auto const& this_node = theContext()->getNode(); +struct InsertCol : vt::InsertableCollection { + InsertCol() { + vt::NodeType this_node = vt::theContext()->getNode(); ::fmt::print("{}: constructing: idx={}\n", this_node, getIndex().x()); - } + } }; -struct TestMsg : CollectionMessage { }; - -static void work(TestMsg* msg, InsertCol* col) { - auto const& this_node = theContext()->getNode(); - ::fmt::print("work: node={}, idx={}\n", this_node, col->getIndex().x()); -} - int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& this_node = theContext()->getNode(); + vt::NodeType this_node = vt::theContext()->getNode(); int32_t num_elms = default_num_elms; - if (argc > 1) { num_elms = atoi(argv[1]); } - auto const epoch = theTerm()->makeEpochCollective(); - theMsg()->setGlobalEpoch(epoch); - if (this_node == 0) { - auto const& range = Index1D(num_elms); - auto proxy = theCollection()->construct(range); + auto range = vt::Index1D(num_elms); + auto proxy = vt::theCollection()->construct(range); - theTerm()->addActionEpoch(epoch,[=]{ - ::fmt::print("broadcasting\n"); - auto msg = makeSharedMessage(); - proxy.broadcast(msg); - }); for (int i = 0; i < range.x() / 2; i++) { proxy[i].insert(i % 2); - /* - * Alternative syntax: - * theCollection()->insert(proxy, Index1D(i)); - */ } - theTerm()->finishedEpoch(epoch); - ::fmt::print("calling finished insert\n"); + + fmt::print("calling finished insert\n"); + proxy.finishedInserting([=]{ - ::fmt::print("insertions are finished\n"); + fmt::print("insertions are finished (first phase)\n"); for (int i = range.x()/2; i < range.x(); i++) { proxy[i].insert(i % 2); } + proxy.finishedInserting([]{ - ::fmt::print("insertions are finished2\n"); + fmt::print("insertions are finished (second phase)\n"); }); }); - } else { - theTerm()->finishedEpoch(epoch); - } - - while (!rt->isTerminated()) { - runScheduler(); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From 902732d673e8a7369344fd70f350123d6c885974 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 19:38:28 -0700 Subject: [PATCH 35/88] #526: example: rewrite hello_world_collection --- examples/hello_world_collection.cc | 238 +++++++---------------------- 1 file changed, 55 insertions(+), 183 deletions(-) diff --git a/examples/hello_world_collection.cc b/examples/hello_world_collection.cc index e4c3ba0c39..756d5badb8 100644 --- a/examples/hello_world_collection.cc +++ b/examples/hello_world_collection.cc @@ -42,227 +42,99 @@ //@HEADER */ -#include "vt/transport.h" -#include +#include -using namespace vt; +static constexpr int32_t const default_num_elms = 16; -struct MyCol : Collection { - Index1D idx; - double test_val = 0.0; - - MyCol(Index1D in_idx) - : Collection(), idx(in_idx) - { - auto const& node = theContext()->getNode(); - fmt::print( - "{}: constructing MyCol on node={}: idx.x()={}, ptr={}\n", - node, node, idx.x(), print_ptr(this) - ); - } - MyCol() = default; +struct Hello : vt::Collection { + Hello() = default; - virtual ~MyCol() { - auto const& node = theContext()->getNode(); - fmt::print( - "{}: invoking destructor MyCol on node={}: idx.x()={}, ptr={}\n", - node, node, idx.x(), print_ptr(this) - ); + explicit Hello(vt::NodeType create) { + vt::NodeType this_node = vt::theContext()->getNode(); + fmt::print("{}: Hello: create={}, index={}\n", this_node, create, getIndex()); + test_val = getIndex().x() * 29.3; } template void serialize(Serializer& s) { - Collection::serialize(s); - s | idx; + vt::Collection::serialize(s); s | test_val; } -}; - -struct OtherColl : Collection { - Index2D idx; - - OtherColl() = default; - OtherColl(Index2D in_idx) - : Collection(), idx(in_idx) - { - auto const& node = theContext()->getNode(); - fmt::print( - "{}: constructing OtherColl on node={}: idx=[{},{}]\n", - node, node, idx.x(), idx.y() - ); - } - - virtual ~OtherColl() { - auto const& node = theContext()->getNode(); - fmt::print( - "{}: invoking destructor OtherColl on node={}: idx=[{},{}]\n", - node, node, idx.x(), idx.y() - ); - } - template - void serialize(Serializer& s) { - Collection::serialize(s); - s | idx; - } + double test_val = 0.0; }; -template -struct ColMsg : CollectionMessage { - NodeType from_node; - int val_ = 0; - - ColMsg() = default; - explicit ColMsg(NodeType const& in_from_node) - : CollectionMessage(), from_node(in_from_node) +struct ColMsg : vt::CollectionMessage { + explicit ColMsg(vt::NodeType const& in_from_node) + : from_node(in_from_node) { } - ColMsg(NodeType const& in_from_node, int32_t const val) - : CollectionMessage(), from_node(in_from_node), val_(val) - { } -}; -static void colHan2(ColMsg* msg, MyCol* col) { - auto const& node = theContext()->getNode(); - fmt::print( - "{}: colHan2 received: ptr={}, idx={}, getIndex={}\n", - node, print_ptr(col), col->idx.x(), col->getIndex().x() - ); -} + vt::NodeType from_node = vt::uninitialized_destination; +}; -#pragma GCC diagnostic ignored "-Wunused-function" -static void method1(ColMsg* msg, MyCol* col) { - auto const& node = theContext()->getNode(); - fmt::print( - "{}: method1 received: ptr={}, idx={}, getIndex={}\n", - node, print_ptr(col), col->idx.x(), col->getIndex().x() - ); - double val = 0.1f; - double val2 = 0.4f * msg->val_; - int x = col->getIndex().x() < 8 ? 10000 : (col->getIndex().x() > 40 ? 1000 : 10); - for (int i = 0; i < 10000 * x; i++) { - val *= val2 + i*29.4; - val2 += 1.0; - } - col->test_val += val + val2; +static void doWork(ColMsg* msg, Hello* col) { + vt::NodeType this_node = vt::theContext()->getNode(); + fmt::print("{}: idx={}: val={}\n", this_node, col->getIndex(), col->test_val); } -static void colHan(ColMsg* msg, MyCol* col) { - auto const& node = theContext()->getNode(); - fmt::print( - "{}: colHan received: ptr={}, idx={}, getIndex={}\n", - node, print_ptr(col), col->idx.x(), col->getIndex().x() - ); - - #define TEST_MIGRATE 0 - #if TEST_MIGRATE - if (col->idx.x() == 2) { - auto const& this_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); - auto const& next_node = this_node + 1; - fmt::print( - "{}: colHan calling migrate: idx={}\n", node, col->idx.x() - ); - col->migrate(next_node >= num_nodes ? 0 : next_node); - } - #endif -} +static void migrateToNext(ColMsg* msg, Hello* col) { + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + vt::NodeType next_node = (this_node + 1) % num_nodes; -#pragma GCC diagnostic ignored "-Wunused-function" -static void colHanOther(ColMsg* msg, OtherColl* col) { - auto const& node = theContext()->getNode(); - fmt::print( - "{}: colHanOther received: idx=[{},{}]\n", - node, col->idx.x(), col->idx.y() - ); + fmt::print("{}: migrateToNext: idx={}\n", this_node, col->getIndex()); + col->migrate(next_node); } -struct HelloMsg : vt::Message { - int from; - - HelloMsg(int const& in_from) - : Message(), from(in_from) - { } -}; - -#pragma GCC diagnostic ignored "-Wunused-function" -static void hello_world(HelloMsg* msg) { - fmt::print("{}: Hello from node {}\n", theContext()->getNode(), msg->from); +template +void executeInEpoch(Callable&& fn) { + auto this_node = vt::theContext()->getNode(); + auto ep = vt::theTerm()->makeEpochRooted(); + vt::theMsg()->pushEpoch(ep); + fn(); + vt::theMsg()->popEpoch(ep); + vt::theTerm()->finishedEpoch(ep); + bool done = false; + vt::theTerm()->addAction(ep, [&done]{ done = true; }); + do vt::runScheduler(); while (!done); } -static constexpr int32_t const default_num_elms = 128; - int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; + return vt::rerror("requires at least 2 nodes"); } int32_t num_elms = default_num_elms; - if (argc > 1) { num_elms = atoi(argv[1]); } - #if 1 - #if LB_ENABLED - EpochType const epoch = theTerm()->makeEpochCollective(); - theMsg()->setGlobalEpoch(epoch); - #endif + if (this_node == 0) { + auto range = vt::Index1D(num_elms); + auto proxy = vt::theCollection()->construct(range, this_node); - if (my_node == 0) { - auto const& this_node = theContext()->getNode(); - auto const& range = Index1D(num_elms); - auto proxy = theCollection()->construct(range); + executeInEpoch([=]{ + auto msg = vt::makeMessage(this_node); + proxy.broadcast(msg.get()); + }); - #if !LB_ENABLED - for (int i = 0; i < num_elms; i++) { - proxy[i].send,colHan>(this_node); - proxy[i].send,colHan2>(this_node); - } - #endif - - auto msg = makeSharedMessage>(this_node); - proxy.broadcast,colHan>(msg); - - #if LB_ENABLED - for (int i = 0; i < num_elms; i++) { - proxy[i].send,method1>(this_node, i); - } - theTerm()->addEpochAction(epoch,[=]{ - theCollection()->nextPhase(proxy,0); - }); - #endif - } - #endif - #if 0 - if (my_node == 1) { - auto const& dim1 = num_elms/2; - auto const& dim2 = (num_elms+2)/2; - auto const& range_2d = Index2D(dim1,dim2); - auto proxy = theCollection()->construct(range_2d); - for (int i = 0; i < dim1; i++) { - for (int j = 0; j < dim2; j++) { - auto const& this_node = theContext()->getNode(); - auto msg = makeSharedMessage>(this_node); - theCollection()->sendMsg, colHanOther>( - proxy(i,j), msg, nullptr - ); - } - } - } - #endif + executeInEpoch([=]{ + auto msg = vt::makeMessage(this_node); + proxy.broadcast(msg.get()); + }); - while (!rt->isTerminated()) { - runScheduler(); + executeInEpoch([=]{ + auto msg = vt::makeMessage(this_node); + proxy.broadcast(msg.get()); + }); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From 585ffb6e9e12df1f1f6b3aa8cf625aec8e81e06c Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 19:41:20 -0700 Subject: [PATCH 36/88] #526: example: remove old/bad jacobi example --- examples/CMakeLists.txt | 2 - examples/jacobi1d_node.cc | 364 ---------------------------------- examples/jacobi1d_recur_vc.cc | 148 -------------- 3 files changed, 514 deletions(-) delete mode 100644 examples/jacobi1d_node.cc delete mode 100644 examples/jacobi1d_recur_vc.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 6d59937bda..935d8303df 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,8 +22,6 @@ set( location_test_msg lb_iter hello_world_virtual_context - jacobi1d_recur_vc - jacobi1d_node jacobi1d_vt jacobi2d_vt serialize_example diff --git a/examples/jacobi1d_node.cc b/examples/jacobi1d_node.cc deleted file mode 100644 index eca5c00539..0000000000 --- a/examples/jacobi1d_node.cc +++ /dev/null @@ -1,364 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// jacobi1d_node.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" - -#include -#include -#include -#include -#include -#include -#include - -#define DEBUG_JACOBI 0 - -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -static RDMA_HandleType jac_t1_han = no_rdma_handle; -static RDMA_HandleType jac_t2_han = no_rdma_handle; -static RDMA_HandleType jac_resid = no_rdma_handle; - -using ActionBoolType = std::function; -using JacobiSizeType = int64_t; - -static JacobiSizeType blk_size = -1; -static double* t1 = nullptr; -static double* t2 = nullptr; -static constexpr double bound_l_val[1] = { 1.0 }; -static constexpr double bound_r_val[1] = { -1.0 }; -static double* local_resid_buf = nullptr; -static double resid_val = 0.0; -static double max_resid_val = 0.0; - -static JacobiSizeType total_size = 1024; -static JacobiSizeType max_iterations = 128; -static constexpr double const error_tolerance = 0.01; - -static int cur_iter = 0; -static int wait_count = 0; - -struct StartWorkMsg : ShortMessage { - bool const converged; - - StartWorkMsg(bool const& in_conv) : converged(in_conv) { } -}; - -struct JacobiKernelMsg : ShortMessage { - int iter = 0; - - JacobiKernelMsg(int const& in_iter) : iter(in_iter) { } -}; - -using FinishedMsg = ShortMessage; - -static void startJacobi1dHandler(StartWorkMsg* msg); - -static double kernel(int const iter) { - double* const c1 = iter % 2 == 0 ? t1 : t2; - double* const c2 = iter % 2 != 0 ? t1 : t2; - - double diff = 0.0, local_error = 0.0; - for (int i = 1; i < blk_size + 1; i++) { - c1[i] = 0.3333 * (c2[i-1] + c2[i] + c2[i+1]); - - diff = c2[i] - c1[i]; - if (diff < 0.0) { - diff *= -1.0; - } - local_error = local_error > diff ? local_error : diff; - } - - return local_error; -} - -static void calcResid(ActionBoolType action) { - if (resid_val < error_tolerance) { - // obviously very unscalable, but just for the sake of testing - theRDMA()->getTypedDataInfoBuf( - jac_resid, local_resid_buf, num_nodes, 0, no_tag, [=]{ - bool found_greater = false; - max_resid_val = 0.0; - for (int i = 0; i < num_nodes; i++) { - #if DEBUG_JACOBI - fmt::print("{}: resid:i={}:val={}:iter={}\n", my_node, i, local_resid_buf[i], cur_iter); - #endif - max_resid_val = std::max(max_resid_val, local_resid_buf[i]); - if (local_resid_buf[i] > error_tolerance) { - found_greater = true; - } - } - action(!found_greater); - } - ); - } else { - action(false); - } -} - -static void finished() { - fmt::print("{}: finished computation: error={}, iter={}\n", my_node, resid_val, cur_iter); -} - -static void boundaryFinished(bool const is_left) { - wait_count--; - - #if DEBUG_JACOBI - fmt::print( - "{}: finished get {}: wait_count={}\n", my_node, (is_left ? "left" : "right"), - wait_count - ); - #endif - - if (wait_count == 0) { - resid_val = kernel(cur_iter); - - theRDMA()->putTypedData(jac_resid, &resid_val, 1, my_node, no_tag, []{ - theCollective()->barrierThen([]{ - if (cur_iter >= max_iterations) { - finished(); - } else { - cur_iter++; - - if (my_node == 0) { - calcResid([](bool has_converged){ - theMsg()->broadcastMsg( - makeSharedMessage(has_converged) - ); - - auto msg = std::make_unique(has_converged); - startJacobi1dHandler(msg.get()); - }); - } - } - }); - }); - } -} - -static void doKernel(JacobiKernelMsg* msg) { - auto const& iter = msg->iter; - - double* const c1 = msg->iter % 2 == 0 ? t1 : t2; - #if DEBUG_JACOBI - double* const c2 = msg->iter % 2 != 0 ? t1 : t2; - #endif - auto const& l_bound = (blk_size * my_node) - 1; - auto const& r_bound = ((blk_size + 1) * my_node) + 1; - - auto const is_far_left = my_node == 0; - auto const is_far_right = my_node == num_nodes - 1; - - wait_count = (is_far_left ? 0 : 1) + (is_far_right ? 0 : 1); - - #if DEBUG_JACOBI - fmt::print( - "{}: doKernel: iter={}, c1={}, c2={}, l_bound={}, r_bound={}, wait_count={}\n", - my_node, iter, c1, c2, l_bound, r_bound, wait_count - ); - #endif - - if (wait_count == 0) { - kernel(iter); - } else { - if (my_node != 0) { - #if DEBUG_JACOBI - fmt::print("{}: doKernel: iter={}, get left wait_count={}\n", my_node, iter, wait_count); - #endif - auto fn = std::bind(boundaryFinished, true); - theRDMA()->getTypedDataInfoBuf(jac_t1_han, c1, 1, l_bound, no_tag, fn); - } - - if (my_node != num_nodes - 1) { - #if DEBUG_JACOBI - fmt::print("{}: doKernel: iter={}, get right wait_count={}\n", my_node, iter, wait_count); - #endif - auto fn = std::bind(boundaryFinished, false); - theRDMA()->getTypedDataInfoBuf(jac_t1_han, c1, 1, r_bound, no_tag, fn); - } - } -} - -static void startJacobi1dHandler(StartWorkMsg* msg) { - bool const& converged = msg->converged; - - #if DEBUG_JACOBI - fmt::print( - "{}: startJacobi1dHandler: cur_iter={}: converged={}\n", - my_node, cur_iter, print_bool(converged) - ); - #endif - - if (my_node == 0) { - fmt::print("iter={}: starting: max_residual={}\n", cur_iter, max_resid_val); - } - - if (cur_iter == 0) { - if (my_node == 0) { - t1[0] = t2[0] = bound_l_val[0]; - } - if (my_node == num_nodes - 1) { - t1[blk_size + 1] = t2[blk_size + 1] = bound_r_val[0]; - } - } - - theCollective()->barrierThen([=]{ - #if DEBUG_JACOBI - fmt::print( - "{}: jacobi1d: barrierThen next iter={}: converged={}\n", - my_node, cur_iter, print_bool(converged) - ); - #endif - - if (not converged) { - #if DEBUG_JACOBI - fmt::print("{}: jacobi1d: next iter={}\n", my_node, cur_iter); - #endif - - if (my_node == 0) { - theMsg()->broadcastMsg( - makeSharedMessage(cur_iter) - ); - JacobiKernelMsg kmsg(cur_iter); - doKernel(&kmsg); - } - } else { - finished(); - } - }); -} - -static int exitEarly( - NodeType const node, int const exit_code, std::string const reason -) { - if (node == 0) { - CollectiveOps::output(std::string{reason}); - CollectiveOps::finalize(); - return 0; - } - - CollectiveOps::finalize(); - return exit_code; -} - -#define sstmac_app_name jacobi1d_node_vt - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - - std::string name(argv[0]); - - if (argc == 1) { - total_size = 1024; - max_iterations = 64; - ::fmt::print( - stderr, "{}: using default arguments since none provided\n", name - ); - } else { - if (argc != 3) { - std::string const buf = fmt::format( - "usage: {} ", name - ); - return exitEarly(my_node, 1, buf); - } - - total_size = atoi(argv[1]); - max_iterations = atoi(argv[2]); - } - - if (num_nodes == 1) { - std::string const buf = fmt::format( - "Need >= 2 ranks:\n mpirun-mpich-clang -n 2 {}\0", name - ); - return exitEarly(my_node, 1, buf); - } - - blk_size = total_size / num_nodes; - - vtAssertExpr(blk_size * num_nodes == total_size); - vtAssertExpr(blk_size * num_nodes == total_size); - - t1 = new double[blk_size + 2]; - t2 = new double[blk_size + 2]; - local_resid_buf = new double[num_nodes]; - - for (int i = 0; i < blk_size + 2; i++) { - t1[i] = 0.0; - t2[i] = 0.0; - } - - fmt::print("{}: total_size={}, blk_size={}\n", my_node, total_size, blk_size); - - jac_t1_han = theRDMA()->registerCollectiveTyped(t1 + 1, blk_size, total_size); - jac_t2_han = theRDMA()->registerCollectiveTyped(t2 + 1, blk_size, total_size); - jac_resid = theRDMA()->registerCollectiveTyped(&resid_val, 1, num_nodes); - - theCollective()->barrierThen([]{ - if (my_node == 0) { - theMsg()->broadcastMsg( - makeSharedMessage(false) - ); - auto msg = std::make_unique(false); - startJacobi1dHandler(msg.get()); - } - }); - - while (!rt->isTerminated()) { - runScheduler(); - } - - delete [] t1; - delete [] t2; - delete [] local_resid_buf; - - CollectiveOps::finalize(); - - return 0; -} diff --git a/examples/jacobi1d_recur_vc.cc b/examples/jacobi1d_recur_vc.cc deleted file mode 100644 index 1b2972e5c0..0000000000 --- a/examples/jacobi1d_recur_vc.cc +++ /dev/null @@ -1,148 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// jacobi1d_recur_vc.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -using namespace vt; -using namespace vt::vrt; - -static constexpr int64_t const total_size = 1024; -static constexpr int64_t const block_size = 64; - -struct CreateJacobi1DMsg : vt::vrt::VirtualMessage { - VirtualProxyType parent; - int64_t lo = 0, hi = 0; - - CreateJacobi1DMsg( - int64_t const& in_lo, int64_t const& in_hi, VirtualProxyType in_parent - ) : VirtualMessage(), parent(in_parent), lo(in_lo), hi(in_hi) - { } -}; - -struct Jacobi1D; -static void create_jacobi1d(CreateJacobi1DMsg* msg, Jacobi1D* j1d); - -struct Jacobi1D : vt::vrt::VirtualContext { - bool has_parent = false; - VirtualProxyType parent; - VirtualProxyType c1, c2; - int64_t lo = 0, hi = 0; - - Jacobi1D( - int64_t const& in_lo, int64_t const& in_hi, VirtualProxyType in_parent - ) : parent(in_parent), lo(in_lo), hi(in_hi) - { - fmt::print("construct: lo={}, hi={}, parent={}\n", lo, hi, parent); - } - - void create_children() { - auto proxy = getProxy(); - auto const size = hi - lo; - auto const mid = size / 2 + lo; - - fmt::print( - "create_children: lo={}, mid={}, hi={}, size={}\n", - lo, mid, hi, size - ); - - c1 = theVirtualManager()->makeVirtual(lo, mid, proxy); - c2 = theVirtualManager()->makeVirtual(mid, hi, proxy); - - { - auto msg = makeSharedMessage(lo, mid, proxy); - theVirtualManager()->sendMsg( - c1, msg - ); - } - - { - auto msg = makeSharedMessage(mid, hi, proxy); - theVirtualManager()->sendMsg( - c2, msg - ); - } - } -}; - -static void create_jacobi1d(CreateJacobi1DMsg* msg, Jacobi1D* j1d) { - auto const this_node = theContext()->getNode(); - auto const lo = msg->lo; - auto const hi = msg->hi; - auto const size = hi - lo; - auto const mid = size / 2 + lo; - - fmt::print( - "{}: lo={}, mid={}, hi={}, size={}\n", this_node, lo, mid, hi, size - ); - - if (size > block_size) { - j1d->create_children(); - } -} - -#define sstmac_app_name jacobi1d_recur_vc_vt - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - auto const& my_node = theContext()->getNode(); - - if (my_node == 0) { - auto root = theVirtualManager()->makeVirtual(0, total_size, -1); - - //CreateJacobi1DMsg* msg = new CreateJacobi1DMsg(0, total_size, root); - theVirtualManager()->sendMsg( - root, makeSharedMessage(0, total_size, root) - ); - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From a88be3b331ebea411029d9d35770eaafcb5c9ec3 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 19:49:02 -0700 Subject: [PATCH 37/88] #526: example: cleanup jacobi1d_vt --- examples/jacobi1d_vt.cc | 63 +++++++++++++++-------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) diff --git a/examples/jacobi1d_vt.cc b/examples/jacobi1d_vt.cc index 2c80621db8..9d11f669fd 100644 --- a/examples/jacobi1d_vt.cc +++ b/examples/jacobi1d_vt.cc @@ -60,22 +60,17 @@ // -#include "vt/transport.h" +#include #include #include #include - -using namespace ::vt; - - static constexpr std::size_t const default_nrow_object = 8; static constexpr std::size_t const default_num_objs = 4; static constexpr double const default_tol = 1.0e-02; - -struct LinearPb1DJacobi : vt::Collection { +struct LinearPb1DJacobi : vt::Collection { private: @@ -109,13 +104,11 @@ struct LinearPb1DJacobi : vt::Collection { LPMsg() = default; LPMsg(const size_t nobjs, const size_t nrow, const size_t itMax) : - CollectionMessage(), numObjects(nobjs), nRowPerObject(nrow), iterMax(itMax) { } }; - struct ReduxMsg : vt::collective::ReduceTMsg { ReduxMsg() = default; explicit ReduxMsg(double in_val) : ReduceTMsg(in_val) { } @@ -137,8 +130,8 @@ struct LinearPb1DJacobi : vt::Collection { // Start a new iteration // auto proxy = getCollectionProxy(); - auto loopMsg = makeSharedMessage(); - proxy.broadcast(loopMsg); + auto loopMsg = vt::makeMessage(); + proxy.broadcast(loopMsg.get()); } else if (iter > maxIter) { fmt::print("\n Maximum Number of Iterations Reached. \n\n"); @@ -183,23 +176,19 @@ struct LinearPb1DJacobi : vt::Collection { } auto proxy = this->getCollectionProxy(); - auto cb = theCB()->makeSend< + auto cb = vt::theCB()->makeSend< LinearPb1DJacobi,ReduxMsg,&LinearPb1DJacobi::checkCompleteCB >(proxy[0]); - auto msg2 = makeMessage(maxNorm); - proxy.reduce>(msg2.get(),cb); + auto msg2 = vt::makeMessage(maxNorm); + proxy.reduce>(msg2.get(),cb); } struct VecMsg : vt::CollectionMessage { - - IdxBase from_index = 0; - double val = 0.0; - VecMsg() = default; - VecMsg(IdxBase const& in_index, double const& ref) : + VecMsg(vt::IdxBase const& in_index, double const& ref) : vt::CollectionMessage(), from_index(in_index), val(ref) { } @@ -217,7 +206,7 @@ struct LinearPb1DJacobi : vt::Collection { // Receive and treat the message from a neighboring object. - const IdxBase myIdx = getIndex().x(); + const vt::IdxBase myIdx = getIndex().x(); if (myIdx > msg->from_index) { this->told_[0] = msg->val; @@ -264,16 +253,14 @@ struct LinearPb1DJacobi : vt::Collection { //--- Send the values to the left auto proxy = this->getCollectionProxy(); if (myIdx > 0) { - auto leftMsg = vt::makeSharedMessage(myIdx, told_[1]); - proxy[myIdx-1].send(leftMsg); + auto leftMsg = vt::makeMessage(myIdx, told_[1]); + proxy[myIdx-1].send(leftMsg.get()); } //--- Send values to the right if (size_t(myIdx) < numObjs_ - 1) { - auto rightMsg = vt::makeSharedMessage( - myIdx, told_[numRowsPerObject_] - ); - proxy[myIdx+1].send(rightMsg); + auto rightMsg = vt::makeMessage(myIdx, told_[numRowsPerObject_]); + proxy[myIdx+1].send(rightMsg.get()); } } @@ -324,8 +311,8 @@ struct LinearPb1DJacobi : vt::Collection { // Start the algorithm with a neighbor-to-neighbor communication using CollType = LinearPb1DJacobi; auto proxy = this->getCollectionProxy(); - auto cb = theCB()->makeBcast(proxy); - auto empty = makeMessage(); + auto cb = vt::theCB()->makeBcast(proxy); + auto empty = vt::makeMessage(); proxy.reduce(empty.get(),cb); } @@ -340,10 +327,10 @@ int main(int argc, char** argv) { std::string name(argv[0]); - vt::CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& this_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (argc == 1) { if (this_node == 0) { @@ -375,22 +362,18 @@ int main(int argc, char** argv) { if (this_node == 0) { // Create the decomposition into objects - using BaseIndexType = typename Index1D::DenseIndexType; - auto const& range = Index1D(static_cast(num_objs)); + using BaseIndexType = typename vt::Index1D::DenseIndexType; + auto range = vt::Index1D(static_cast(num_objs)); auto proxy = vt::theCollection()->construct(range); - auto rootMsg = makeSharedMessage( + auto rootMsg = vt::makeMessage( num_objs, numRowsPerObject, maxIter ); - proxy.broadcast(rootMsg); - - } + proxy.broadcast(rootMsg.get()); - while (!rt->isTerminated()) { - runScheduler(); } - CollectiveOps::finalize(); + vt::finalize(); return 0; From b191e90d75eeeaedc88d3816318c0fa507156384 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 19:52:21 -0700 Subject: [PATCH 38/88] #526: example: cleanup jacobi2d_vt --- examples/jacobi2d_vt.cc | 66 ++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 37 deletions(-) diff --git a/examples/jacobi2d_vt.cc b/examples/jacobi2d_vt.cc index e2044a5be6..96a4c7a13c 100644 --- a/examples/jacobi2d_vt.cc +++ b/examples/jacobi2d_vt.cc @@ -42,7 +42,7 @@ //@HEADER */ -#include "vt/transport.h" +#include #include #include @@ -74,19 +74,16 @@ // -using namespace ::vt; - - static constexpr std::size_t const default_nrow_object = 8; static constexpr std::size_t const default_num_objs = 4; static constexpr double const default_tol = 1.0e-02; -struct LinearPb2DJacobi : vt::Collection { +struct LinearPb2DJacobi : vt::Collection { private: - Index2D idx_; + vt::Index2D idx_; std::vector tcur_, told_; std::vector rhs_; size_t iter_ = 0; @@ -99,8 +96,8 @@ struct LinearPb2DJacobi : vt::Collection { LinearPb2DJacobi() = default; - explicit LinearPb2DJacobi(Index2D in_idx) - : vt::Collection(), idx_(in_idx), + explicit LinearPb2DJacobi(vt::Index2D in_idx) + : idx_(in_idx), tcur_(), told_(), rhs_(), iter_(0), msgReceived_(0), totalReceive_(0), numObjsX_(1), numObjsY_(1), @@ -121,9 +118,8 @@ struct LinearPb2DJacobi : vt::Collection { LPMsg() = default; - LPMsg(const size_t nx, const size_t ny, const size_t nref) : - CollectionMessage(), - numXObjs(nx), numYObjs(ny), numIter(nref) + LPMsg(const size_t nx, const size_t ny, const size_t nref) + : numXObjs(nx), numYObjs(ny), numIter(nref) { } }; @@ -151,8 +147,8 @@ struct LinearPb2DJacobi : vt::Collection { // Start a new iteration // auto proxy = getCollectionProxy(); - auto loopMsg = makeSharedMessage(); - proxy.broadcast(loopMsg); + auto loopMsg = vt::makeMessage(); + proxy.broadcast(loopMsg.get()); } else if (iter > maxIter) { fmt::print("\n Maximum Number of Iterations Reached. \n\n"); @@ -226,12 +222,12 @@ struct LinearPb2DJacobi : vt::Collection { } auto proxy = this->getCollectionProxy(); - auto cb = theCB()->makeSend< + auto cb = vt::theCB()->makeSend< LinearPb2DJacobi,ReduxMsg,&LinearPb2DJacobi::checkCompleteCB >(proxy(0,0)); - auto msg2 = makeMessage(maxNorm); - proxy.reduce>(msg2.get(),cb); + auto msg2 = vt::makeMessage(maxNorm); + proxy.reduce>(msg2.get(),cb); } struct VecMsg : vt::CollectionMessage { @@ -318,16 +314,16 @@ struct LinearPb2DJacobi : vt::Collection { std::vector tcopy(numRowsPerObject_ + 2, 0.0); for (size_t jy = 1; jy <= numRowsPerObject_; ++jy) tcopy[jy] = told_[1 + jy * (numRowsPerObject_ + 2)]; - auto leftX = makeSharedMessage(idx_, tcopy); - proxy(x-1, y).send(leftX); + auto leftX = vt::makeMessage(idx_, tcopy); + proxy(x-1, y).send(leftX.get()); } if (y > 0) { std::vector tcopy(numRowsPerObject_ + 2, 0.0); for (size_t jx = 1; jx <= numRowsPerObject_; ++jx) tcopy[jx] = told_[jx + (numRowsPerObject_ + 2)]; - auto bottomY = makeSharedMessage(idx_, tcopy); - proxy(x, y-1).send(bottomY); + auto bottomY = vt::makeMessage(idx_, tcopy); + proxy(x, y-1).send(bottomY.get()); } if (size_t(x) < numObjsX_ - 1) { @@ -336,16 +332,16 @@ struct LinearPb2DJacobi : vt::Collection { tcopy[jy] = told_[numRowsPerObject_ + jy * (numRowsPerObject_ + 2)]; } - auto rightX = makeSharedMessage(idx_, tcopy); - proxy(x+1, y).send(rightX); + auto rightX = vt::makeMessage(idx_, tcopy); + proxy(x+1, y).send(rightX.get()); } if (size_t(y) < numObjsY_ - 1) { std::vector tcopy(numRowsPerObject_ + 2, 0.0); for (size_t jx = 1; jx <= numRowsPerObject_; ++jx) tcopy[jx] = told_[jx + numRowsPerObject_ * (numRowsPerObject_ + 2)]; - auto topY = makeSharedMessage(idx_, tcopy); - proxy(x, y+1).send(topY); + auto topY = vt::makeMessage(idx_, tcopy); + proxy(x, y+1).send(topY.get()); } } @@ -434,8 +430,8 @@ struct LinearPb2DJacobi : vt::Collection { // Start the algorithm with a neighbor-to-neighbor communication using CollType = LinearPb2DJacobi; auto proxy = this->getCollectionProxy(); - auto cb = theCB()->makeBcast(proxy); - auto empty = makeMessage(); + auto cb = vt::theCB()->makeBcast(proxy); + auto empty = vt::makeMessage(); proxy.reduce(empty.get(),cb); } @@ -450,9 +446,9 @@ int main(int argc, char** argv) { std::string name(argv[0]); - vt::CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& this_node = theContext()->getNode(); + vt::NodeType this_node = vt::theContext()->getNode(); if (argc == 1) { if (this_node == 0) { @@ -501,26 +497,22 @@ int main(int argc, char** argv) { if (this_node == 0) { // Create the decomposition into objects - using BaseIndexType = typename Index2D::DenseIndexType; - auto const& range = Index2D( + using BaseIndexType = typename vt::Index2D::DenseIndexType; + auto range = vt::Index2D( static_cast(numX_objs), static_cast(numY_objs) ); auto proxy = vt::theCollection()->construct(range); - auto rootMsg = makeSharedMessage( + auto rootMsg = vt::makeMessage( numX_objs, numY_objs, maxIter ); - proxy.broadcast(rootMsg); - - } + proxy.broadcast(rootMsg.get()); - while (!rt->isTerminated()) { - runScheduler(); } - CollectiveOps::finalize(); + vt::finalize(); return 0; From 703548925e17dfe447849f08857f3ee6ee4b79a9 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 20:48:54 -0700 Subject: [PATCH 39/88] #526: example: fix non-explicit constructor --- examples/group_rooted.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/group_rooted.cc b/examples/group_rooted.cc index 740587e26b..e2764cc902 100644 --- a/examples/group_rooted.cc +++ b/examples/group_rooted.cc @@ -45,9 +45,9 @@ #include struct HelloMsg : vt::Message { - int from; + vt::NodeType from = vt::uninitialized_destination; - HelloMsg(int const& in_from) + explicit HelloMsg(vt::NodeType const& in_from) : from(in_from) { } }; From 9d6ba2d5dfc25d2057467f216daa5501f8e37c12 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 21 Apr 2020 20:49:59 -0700 Subject: [PATCH 40/88] #526: example: fix bug in jacobi2d_vt init code --- examples/jacobi2d_vt.cc | 43 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/examples/jacobi2d_vt.cc b/examples/jacobi2d_vt.cc index 96a4c7a13c..c8f348d163 100644 --- a/examples/jacobi2d_vt.cc +++ b/examples/jacobi2d_vt.cc @@ -83,7 +83,6 @@ struct LinearPb2DJacobi : vt::Collection { private: - vt::Index2D idx_; std::vector tcur_, told_; std::vector rhs_; size_t iter_ = 0; @@ -94,11 +93,8 @@ struct LinearPb2DJacobi : vt::Collection { public: - LinearPb2DJacobi() = default; - - explicit LinearPb2DJacobi(vt::Index2D in_idx) - : idx_(in_idx), - tcur_(), told_(), rhs_(), iter_(0), + LinearPb2DJacobi() + : tcur_(), told_(), rhs_(), iter_(0), msgReceived_(0), totalReceive_(0), numObjsX_(1), numObjsY_(1), numRowsPerObject_(default_nrow_object), @@ -254,25 +250,25 @@ struct LinearPb2DJacobi : vt::Collection { // Receive and treat the message from a neighboring object. - if (this->idx_.x() > msg->from_index.x()) { + if (this->getIndex().x() > msg->from_index.x()) { const size_t ldx = numRowsPerObject_ + 2; for (size_t jy = 0; jy < msg->val.size(); ++jy) { this->told_[jy*ldx] = msg->val[jy]; } msgReceived_ += 1; } - else if (this->idx_.x() < msg->from_index.x()) { + else if (this->getIndex().x() < msg->from_index.x()) { const size_t ldx = numRowsPerObject_ + 2; for (size_t jy = 0; jy < msg->val.size(); ++jy) { this->told_[numRowsPerObject_ + 1 + jy*ldx] = msg->val[jy]; } msgReceived_ += 1; } - else if (this->idx_.y() > msg->from_index.y()) { + else if (this->getIndex().y() > msg->from_index.y()) { std::copy(msg->val.begin(), msg->val.end(), this->told_.begin()); msgReceived_ += 1; } - else if (this->idx_.y() < msg->from_index.y()) { + else if (this->getIndex().y() < msg->from_index.y()) { std::copy(msg->val.begin(), msg->val.end(), &this->told_[(numRowsPerObject_ + 1)*(numRowsPerObject_ + 2)]); msgReceived_ += 1; @@ -307,14 +303,15 @@ struct LinearPb2DJacobi : vt::Collection { // auto proxy = this->getCollectionProxy(); - auto const x = idx_.x(); - auto const y = idx_.y(); + auto idx = this->getIndex(); + auto const x = idx.x(); + auto const y = idx.y(); if (x > 0) { std::vector tcopy(numRowsPerObject_ + 2, 0.0); for (size_t jy = 1; jy <= numRowsPerObject_; ++jy) tcopy[jy] = told_[1 + jy * (numRowsPerObject_ + 2)]; - auto leftX = vt::makeMessage(idx_, tcopy); + auto leftX = vt::makeMessage(idx, tcopy); proxy(x-1, y).send(leftX.get()); } @@ -322,7 +319,7 @@ struct LinearPb2DJacobi : vt::Collection { std::vector tcopy(numRowsPerObject_ + 2, 0.0); for (size_t jx = 1; jx <= numRowsPerObject_; ++jx) tcopy[jx] = told_[jx + (numRowsPerObject_ + 2)]; - auto bottomY = vt::makeMessage(idx_, tcopy); + auto bottomY = vt::makeMessage(idx, tcopy); proxy(x, y-1).send(bottomY.get()); } @@ -332,7 +329,7 @@ struct LinearPb2DJacobi : vt::Collection { tcopy[jy] = told_[numRowsPerObject_ + jy * (numRowsPerObject_ + 2)]; } - auto rightX = vt::makeMessage(idx_, tcopy); + auto rightX = vt::makeMessage(idx, tcopy); proxy(x+1, y).send(rightX.get()); } @@ -340,7 +337,7 @@ struct LinearPb2DJacobi : vt::Collection { std::vector tcopy(numRowsPerObject_ + 2, 0.0); for (size_t jx = 1; jx <= numRowsPerObject_; ++jx) tcopy[jx] = told_[jx + numRowsPerObject_ * (numRowsPerObject_ + 2)]; - auto topY = vt::makeMessage(idx_, tcopy); + auto topY = vt::makeMessage(idx, tcopy); proxy(x, y+1).send(topY.get()); } @@ -369,10 +366,12 @@ struct LinearPb2DJacobi : vt::Collection { size_t maxNObjs = (size_t) std::max(numObjsX_, numObjsY_); int nf = 3 * int(numRowsPerObject_ * maxNObjs + 1) / 4; + auto idx = this->getIndex(); + for (size_t iy = 0; iy < ldy; ++iy) { for (size_t ix = 0; ix < ldx; ++ix) { - double x0 = ( numRowsPerObject_ * idx_.x() + ix) * hx; - double y0 = ( numRowsPerObject_ * idx_.y() + iy) * hy; + double x0 = ( numRowsPerObject_ * idx.x() + ix) * hx; + double y0 = ( numRowsPerObject_ * idx.y() + iy) * hy; size_t node = ix + iy * ldx; tcur_[node] = sin(nf * M_PI * (x0 * x0 + y0 * y0)); } @@ -388,25 +387,25 @@ struct LinearPb2DJacobi : vt::Collection { //--- The total number of grid points in Y-direction is //--- (numRowsPerObject_ * numObjsY_) + 2 // - if (idx_.x() == 0) { + if (idx.x() == 0) { for (size_t jy = 0; jy < ldy; ++jy) tcur_[jy * ldy] = 0.0; totalReceive_ -= 1; } - if (idx_.y() == 0) { + if (idx.y() == 0) { for (size_t jx = 0; jx < ldx; ++jx) tcur_[jx] = 0.0; totalReceive_ -= 1; } - if (numObjsX_ == size_t(idx_.x()) + 1) { + if (numObjsX_ == size_t(idx.x()) + 1) { for (size_t jy = 0; jy < ldy; ++jy) tcur_[jy * ldy + (ldx - 1)] = 0.0; totalReceive_ -= 1; } - if (numObjsY_ == size_t(idx_.y()) + 1) { + if (numObjsY_ == size_t(idx.y()) + 1) { for (size_t jx = 0; jx < ldx; ++jx) tcur_[jx + (ldx - 1)*ldy] = 0.0; totalReceive_ -= 1; From 518dc13f084141ab5e46ae7e15d4d31ded1bb403 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 12:52:32 -0700 Subject: [PATCH 41/88] #526: example: remove unused variable --- examples/hello_world_collection.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/hello_world_collection.cc b/examples/hello_world_collection.cc index 756d5badb8..66ba335bcf 100644 --- a/examples/hello_world_collection.cc +++ b/examples/hello_world_collection.cc @@ -88,7 +88,6 @@ static void migrateToNext(ColMsg* msg, Hello* col) { template void executeInEpoch(Callable&& fn) { - auto this_node = vt::theContext()->getNode(); auto ep = vt::theTerm()->makeEpochRooted(); vt::theMsg()->pushEpoch(ep); fn(); From caddc64753ffea414c35e54d2347e6e0b21189fe Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 12:52:43 -0700 Subject: [PATCH 42/88] #526: example: rewrite lb_iter to be cleaner --- examples/lb_iter.cc | 147 +++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 92 deletions(-) diff --git a/examples/lb_iter.cc b/examples/lb_iter.cc index 964001af36..eee6af1492 100644 --- a/examples/lb_iter.cc +++ b/examples/lb_iter.cc @@ -42,23 +42,17 @@ //@HEADER */ -#include "vt/transport.h" - -#include - -using namespace ::vt; -using namespace ::vt::collective; +#include static constexpr int32_t const default_num_elms = 64; static int32_t num_iter = 8; -struct IterCol : Collection { +struct IterCol : vt::Collection { IterCol() = default; - struct ContinueMsg : collective::ReduceNoneMsg { - vt::CollectionProxy proxy; - }; - struct IterMsg : CollectionMessage { + using EmptyMsg = vt::CollectionMessage; + + struct IterMsg : vt::CollectionMessage { IterMsg() = default; explicit IterMsg(int64_t const in_work_amt, int64_t const in_iter) : iter_(in_iter), work_amt_(in_work_amt) @@ -69,49 +63,27 @@ struct IterCol : Collection { }; void iterWork(IterMsg* msg); - void nextIter(IterMsg* msg); - void finished(ContinueMsg* msg); + + void runLB(EmptyMsg* msg) { + auto const idx = getIndex(); + auto proxy = getCollectionProxy(); + proxy[idx].LB(); + } + + void doneLB(EmptyMsg* msg) { } template void serialize(SerializerT& s) { - Collection::serialize(s); - s | cur_iter | data_2; + vt::Collection::serialize(s); + s | data_2; } private: - int64_t cur_iter = 0; float data_2 = 2.4f; }; -static bool touch = true; -static TimeType cur_time = 0; - static double weight = 1.0f; -void finishedNode(int64_t iter) { - auto const this_node = vt::theContext()->getNode(); - if (not touch && this_node == 0) { - auto total_time = vt::timing::Timing::getCurrentTime() - cur_time; - ::fmt::print("iteration: iter={},time={}\n", iter, total_time); - touch = not touch; - } -} - -void nodeLBHandler(IterCol::ContinueMsg* msg) { - static int64_t iter = 0; - - finishedNode(iter); - iter++; - - auto proxy = msg->proxy; - - vt::theCollection()->startPhaseCollective([=]{ - if (vt::theContext()->getNode() == 0) { - proxy.template broadcast(10,iter); - } - }); -} - void IterCol::iterWork(IterMsg* msg) { double val = 0.1f; double val2 = 0.4f * msg->work_amt_; @@ -130,51 +102,25 @@ void IterCol::iterWork(IterMsg* msg) { if (idx == 0) { fmt::print("{}: iterWork: idx={}\n", this_node, getIndex()); } - - auto proxy = getCollectionProxy(); - auto cmsg = makeMessage(); - cmsg->proxy = proxy; - - // auto cb = theCB()->makeBcast(proxy); - // proxy.reduce(cmsg.get(),cb); - - auto cb = theCB()->makeBcast(); - proxy.reduce(cmsg.get(),cb); -} - -void IterCol::finished(ContinueMsg* msg) { - auto const idx = getIndex().x(); - - finishedNode(cur_iter); - - cur_iter++; - - auto proxy = getCollectionProxy(); - proxy[idx].LB(10,cur_iter); } -void IterCol::nextIter(IterMsg* msg) { - auto const this_node = vt::theContext()->getNode(); - - //fmt::print("{}: nextIter: idx={}\n", this_node, getIndex()); - - if (touch && this_node == 0) { - cur_time = vt::timing::Timing::getCurrentTime(); - touch = not touch; - } - - if (msg->iter_ < num_iter) { - auto proxy = getCollectionProxy(); - auto idx = getIndex().x(); - auto nmsg = makeMessage(*msg); - proxy(idx).send(nmsg.get()); +template +void executeInEpoch(Callable&& fn) { + auto this_node = vt::theContext()->getNode(); + auto ep = vt::theTerm()->makeEpochCollective(); + vt::theMsg()->pushEpoch(ep); + if (this_node == 0) { + fn(); } + vt::theMsg()->popEpoch(ep); + vt::theTerm()->finishedEpoch(ep); + bool done = false; + vt::theTerm()->addAction(ep, [&done]{ done = true; }); + do vt::runScheduler(); while (!done); } int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - auto const& this_node = theContext()->getNode(); + vt::initialize(argc, argv); int32_t num_elms = default_num_elms; @@ -188,23 +134,40 @@ int main(int argc, char** argv) { num_iter = atoi(argv[3]); } + vt::NodeType this_node = vt::theContext()->getNode(); + if (this_node == 0) { - ::fmt::print( + fmt::print( "lb_iter: elms={}, weight={}, num_iter={}\n", num_elms, weight, num_iter ); - - auto const& range = Index1D(num_elms); - auto proxy = theCollection()->construct(range); - auto msg = makeMessage(10,0); - proxy.broadcast(msg.get()); } - while (!rt->isTerminated()) { - runScheduler(); - } + auto range = vt::Index1D(num_elms); + auto proxy = vt::theCollection()->constructCollective( + range, [](vt::Index1D){ + return std::make_unique(); + } + ); + + for (int i = 0; i < num_iter; i++) { + auto cur_time = vt::timing::Timing::getCurrentTime(); - CollectiveOps::finalize(); + executeInEpoch([=]{ + proxy.broadcast(10, i); + }); + + auto total_time = vt::timing::Timing::getCurrentTime() - cur_time; + if (this_node == 0) { + fmt::print("iteration: iter={},time={}\n", i, total_time); + } + + executeInEpoch([=]{ + proxy.broadcast(); + }); + + } + vt::finalize(); return 0; } From 22c4a1697eb774c0fd2d64ba85864d27e4090c6c Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 12:54:35 -0700 Subject: [PATCH 43/88] #526: example: cleanup objgroup --- examples/objgroup.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/objgroup.cc b/examples/objgroup.cc index 07b50aadc1..99a33d8029 100644 --- a/examples/objgroup.cc +++ b/examples/objgroup.cc @@ -62,22 +62,16 @@ int main(int argc, char** argv) { vt::NodeType this_node = vt::theContext()->getNode(); vt::NodeType num_nodes = vt::theContext()->getNumNodes(); - if (num_nodes < 2) { - return 0; - } - auto proxy = vt::theObjGroup()->makeCollective(); if (this_node == 0) { proxy[0].send(5,10); - proxy[1].send(10,20); + if (num_nodes > 1) { + proxy[1].send(10,20); + } proxy.broadcast(400,500); } - while (!vt::rt->isTerminated()) { - vt::runScheduler(); - } - vt::finalize(); return 0; From fcabb8b1e812262ac8032e3d12a986b0bf1297bb Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 15:15:08 -0700 Subject: [PATCH 44/88] #526: param: fix gcc bugs in parameterization so example compiles/runs --- src/vt/parameterization/param_meta.h | 16 ++-- src/vt/parameterization/parameterization.h | 82 ++++++++++---------- src/vt/registry/auto/auto_registry_general.h | 33 ++++++++ src/vt/registry/auto/auto_registry_impl.h | 2 +- 4 files changed, 84 insertions(+), 49 deletions(-) diff --git a/src/vt/parameterization/param_meta.h b/src/vt/parameterization/param_meta.h index 6721d69207..c75015ec40 100644 --- a/src/vt/parameterization/param_meta.h +++ b/src/vt/parameterization/param_meta.h @@ -60,11 +60,11 @@ using MultiParamType = void(*)(Args...); template struct NonType {}; -#define PARAM_FUNCTION_RHS(value) vt::param::NonType() -#define PARAM_FUNCTION(value) decltype(value),(value) +#define PARAM_FUNCTION_RHS(value) vt::param::NonType() +#define PARAM_FUNCTION(value) decltype(&value),(&value) template -auto callFnTuple(Function f, Tuple&& t, std::index_sequence) { +auto callFnTuple(Function f, Tuple t, std::index_sequence) { return f( std::forward::type>( std::get(t) @@ -73,21 +73,21 @@ auto callFnTuple(Function f, Tuple&& t, std::index_sequence) { } template -void invokeFnTuple(TypedFnT f, std::tuple&& t) { +void invokeFnTuple(TypedFnT f, std::tuple t) { using TupleType = std::tuple; callFnTuple(f, std::forward(t), std::make_index_sequence{}); } template -void invokeCallableTuple(std::tuple&& tup, FnT fn, bool const& is_functor) { +void invokeCallableTuple(std::tuple& tup, FnT fn, bool const& is_functor) { using TupleType = typename std::decay::type; static constexpr auto size = std::tuple_size::value; if (is_functor) { - auto typed_fn = reinterpret_cast>(fn); - return invokeFnTuple(typed_fn, std::forward(tup)); + auto typed_fn = reinterpret_cast>(fn); + return invokeFnTuple(typed_fn, tup); } else { auto typed_fn = reinterpret_cast>(fn); - return invokeFnTuple(typed_fn, std::forward(tup)); + return invokeFnTuple(typed_fn, tup); } } diff --git a/src/vt/parameterization/parameterization.h b/src/vt/parameterization/parameterization.h index 05e4278e09..887e7c8b7c 100644 --- a/src/vt/parameterization/parameterization.h +++ b/src/vt/parameterization/parameterization.h @@ -65,9 +65,13 @@ using HandlerManagerType = vt::HandlerManager; template struct DataMsg : vt::Message { + using MessageParentType = vt::Message; + vt_msg_serialize_if_needed_by_parent_or_type1(Tuple); // by tup + Tuple tup; HandlerType sub_han = uninitialized_handler; + DataMsg() = default; DataMsg(HandlerType const& in_sub_han, Tuple&& a) : Message(), tup(std::forward(a)), sub_han(in_sub_han) { } @@ -76,6 +80,13 @@ struct DataMsg : vt::Message { DataMsg(HandlerType const& in_sub_han, Args&&... a) : Message(), tup(std::forward(a)...), sub_han(in_sub_han) { } + + template + void serialize(SerializerT& s) { + MessageParentType::serialize(s); + s | tup; + s | sub_han; + } }; @@ -104,11 +115,11 @@ static void dataMessageHandler(DataMsg* msg) { if (HandlerManagerType::isHandlerFunctor(msg->sub_han)) { auto fn = auto_registry::getAutoHandlerFunctor(msg->sub_han); - invokeCallableTuple(std::forward(msg->tup), fn, true); + invokeCallableTuple(msg->tup, fn, true); } else { // regular active function auto fn = auto_registry::getAutoHandler(msg->sub_han); - invokeCallableTuple(std::forward(msg->tup), fn, false); + invokeCallableTuple(msg->tup, fn, false); } #if backend_check_enabled(trace_enabled) @@ -119,20 +130,17 @@ static void dataMessageHandler(DataMsg* msg) { struct Param { template - EventType sendDataTuple( + void sendDataTuple( NodeType const& dest, HandlerType const& han, std::tuple&& tup ) { staticCheckCopyable(); using TupleType = typename std::decay::type; - DataMsg* m = new DataMsg( + auto m = makeMessage>( han, std::forward>(tup) ); - - return theMsg()->sendMsg, dataMessageHandler>( - dest, m, [=]{ delete m; } - ); + theMsg()->sendMsg, dataMessageHandler>(dest, m.get()); } template @@ -146,36 +154,34 @@ struct Param { } template - EventType sendDataMsg( + void sendDataMsg( NodeType const& dest, HandlerType const& __attribute__((unused)) han, - DataMsg* m + MsgSharedPtr m ) { - return theMsg()->sendMsg( - dest, m, [=]{ delete m; } - ); + theMsg()->sendMsg(dest, m.get()); } template - EventType sendData( + void sendData( NodeType const& dest, Tuple tup, NonType __attribute__((unused)) non = NonType() ) { auto const& han = auto_registry::makeAutoHandlerParam(); - return sendDataTuple(dest, han, std::forward(tup)); + sendDataTuple(dest, han, std::forward(tup)); } template - EventType sendData( - NodeType const& dest, DataMsg>* msg, + void sendData( + NodeType const& dest, MsgSharedPtr>> msg, NonType __attribute__((unused)) non = NonType() ) { auto const& han = auto_registry::makeAutoHandlerParam(); msg->sub_han = han; - return sendDataMsg(dest, han, msg); + sendDataMsg(dest, han, msg); } template - EventType sendData( + void sendData( NodeType const& dest, NonType __attribute__((unused)) non, Args&&... a ) { @@ -185,16 +191,13 @@ struct Param { using TupleType = std::tuple; - DataMsg* m = new DataMsg( - han, std::forward(a)... - ); - - return sendDataMsg(dest, han, m); + auto m = makeMessage>(han, std::forward(a)...); + sendDataMsg(dest, han, m); } template - EventType sendData(NodeType const& dest, Args&&... a) { - return sendData(dest, NonType(), std::forward(a)...); + void sendData(NodeType const& dest, Args&&... a) { + sendData(dest, NonType(), std::forward(a)...); } /* @@ -202,22 +205,24 @@ struct Param { */ template - EventType sendDataHelperFunctor( + void sendDataHelperFunctor( NodeType const& dest, std::tuple&& tup ) { auto const& han = auto_registry::makeAutoHandlerFunctor< FunctorT, false, Args... >(); - return sendDataTuple(dest, han, std::forward>(tup)); + sendDataTuple(dest, han, std::forward>(tup)); } template - EventType sendData(NodeType const& dest, Tuple tup) { - return sendDataHelperFunctor(dest, std::forward(tup)); + void sendData(NodeType const& dest, Tuple tup) { + sendDataHelperFunctor(dest, std::forward(tup)); } template - EventType sendData(NodeType const& dest, DataMsg>* msg) { + void sendData( + NodeType const& dest, MsgSharedPtr>> msg + ) { staticCheckCopyable(); auto const& han = auto_registry::makeAutoHandlerFunctor< @@ -225,11 +230,11 @@ struct Param { >(); msg->sub_han = han; - return sendDataMsg(dest, han, msg); + sendDataMsg(dest, han, msg); } template - EventType sendData(NodeType const& dest, Args&&... a) { + void sendData(NodeType const& dest, Args&&... a) { staticCheckCopyable(); auto const& han = auto_registry::makeAutoHandlerFunctor< @@ -238,11 +243,8 @@ struct Param { using TupleType = std::tuple; - DataMsg* m = new DataMsg( - han, std::forward(a)... - ); - - return sendDataMsg(dest, han, m); + auto m = makeMessage>(han, std::forward(a)...); + sendDataMsg(dest, han, m); } }; @@ -253,8 +255,8 @@ namespace vt { extern param::Param* theParam(); template -param::DataMsg>* buildData(Args&&... a) { - return new param::DataMsg>( +MsgSharedPtr>> buildData(Args&&... a) { + return makeMessage>>( uninitialized_handler, std::forward(a)... ); } diff --git a/src/vt/registry/auto/auto_registry_general.h b/src/vt/registry/auto/auto_registry_general.h index 466f1e6a9e..94da78fc78 100644 --- a/src/vt/registry/auto/auto_registry_general.h +++ b/src/vt/registry/auto/auto_registry_general.h @@ -113,6 +113,39 @@ struct FunctorAdapterArgs { #endif // end trace_enabled }; +// Need to provide a non-pointer overload for parameterization auto-registered +// functions for GCC +template +struct FunctorAdapterParam { + using FunctionPtrType = F; + using ObjType = void; + + static constexpr FunctionPtrType getFunction() { return f; } + + static NumArgsType getNumArgs() { + return 0; // lies - see NumArgsTag, perhaps + } + +#if backend_check_enabled(trace_enabled) + static std::string traceGetEventType() { + using TE = vt::util::demangle::TemplateExtract; + using DU = vt::util::demangle::DemanglerUtils; + auto ns = TE::getNamespace(TE::getValueName()); + if (ns.empty()) + ns = "(none)"; + return DU::removeSpaces(ns); + } + + static std::string traceGetEventName() { + using TE = vt::util::demangle::TemplateExtract; + using DU = vt::util::demangle::DemanglerUtils; + auto barename = TE::getBarename(TE::getValueName()); + auto args = TE::getVoidFuncStrArgs(TE::getTypeName()); + return DU::removeSpaces(barename + "(" + args + ")"); + } +#endif // end trace_enabled +}; + template struct FunctorAdapter { using FunctionPtrType = F*; diff --git a/src/vt/registry/auto/auto_registry_impl.h b/src/vt/registry/auto/auto_registry_impl.h index 5f95daa30f..a644f9ddd7 100644 --- a/src/vt/registry/auto/auto_registry_impl.h +++ b/src/vt/registry/auto/auto_registry_impl.h @@ -98,7 +98,7 @@ inline HandlerType makeAutoHandler(MessageT* const __attribute__((unused)) msg) template inline HandlerType makeAutoHandlerParam() { - using AdapterT = FunctorAdapter; + using AdapterT = FunctorAdapterParam; using ContainerType = AutoActiveContainerType; using RegInfoType = AutoRegInfoType; using FuncType = ActiveFnPtrType; From 2e2b4a7f94e111a651f095f6e5eea3c9a6c7e5b9 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 15:15:28 -0700 Subject: [PATCH 45/88] #526: build: fix missing debug enable for parameterization --- cmake/define_build_types.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/define_build_types.cmake b/cmake/define_build_types.cmake index 0917399d72..f0d0b736ff 100644 --- a/cmake/define_build_types.cmake +++ b/cmake/define_build_types.cmake @@ -36,6 +36,7 @@ set( CatEnum::termds | \ CatEnum::barrier | \ CatEnum::pipe | \ + CatEnum::param | \ CatEnum::pool | \ CatEnum::reduce | \ CatEnum::rdma | \ From d5189fd922c6bc434cd8dd5f74fc3f56f4469a03 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 15:15:46 -0700 Subject: [PATCH 46/88] #526: example: rewrite and fix param.cc --- examples/param.cc | 49 ++++++++++++++++------------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/examples/param.cc b/examples/param.cc index cb431a7080..716abd612e 100644 --- a/examples/param.cc +++ b/examples/param.cc @@ -42,25 +42,16 @@ //@HEADER */ -#include "vt/transport.h" -#include +#include -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -#pragma GCC diagnostic ignored "-Wunused-function" static void fnTest(int a, int b, bool x) { fmt::print("fn: a={}, b={}, x={}\n", a, b, x ? "true" : "false"); } -#pragma GCC diagnostic ignored "-Wunused-function" static void fnTest2(int x, int y) { fmt::print("fn2: x={},y={}\n",x,y); } -#pragma GCC diagnostic ignored "-Wunused-function" static void fnTest3(int x, double y) { fmt::print("fn3: x={},y={}\n",x,y); } @@ -72,38 +63,30 @@ struct FunctorTest1 { }; int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; + return vt::rerror("requires at least 2 nodes"); } - if (my_node == 0) { - #if 0 - theParam()->sendData(1, buildData(10, 20, false), PARAM_FUNCTION_RHS(fnTest)); - theParam()->sendData(1, PARAM_FUNCTION_RHS(fnTest), 50, 29, false); - theParam()->sendData(1, buildData(10, 20, false)); - theParam()->sendData(1, 45, 23, true); + if (this_node == 0) { + vt::theParam()->sendData(1, vt::buildData(10, 20, false), PARAM_FUNCTION_RHS(fnTest)); + vt::theParam()->sendData(1, PARAM_FUNCTION_RHS(fnTest), 50, 29, false); + vt::theParam()->sendData(1, vt::buildData(10, 20, false)); + vt::theParam()->sendData(1, 45, 23, true); - theParam()->sendData(1, 20, 10); - theParam()->sendData(1, 20, 50.0); - - theParam()->sendData(1, buildData(20, 50.0)); - theParam()->sendData(1, 20, 100.0); - theParam()->sendData(1, buildData(10, 70.0)); - #endif - } + vt::theParam()->sendData(1, 20, 10); + vt::theParam()->sendData(1, 20, 50.0); - while (!rt->isTerminated()) { - runScheduler(); + vt::theParam()->sendData(1, vt::buildData(20, 50.0)); + vt::theParam()->sendData(1, 20, 100.0); + vt::theParam()->sendData(1, vt::buildData(10, 70.0)); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From 34184e62956fed398b83fd506d8937457d7a42ef Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 16:08:39 -0700 Subject: [PATCH 47/88] #526: example: remove un-useful location tests --- examples/CMakeLists.txt | 2 - examples/location_test.cc | 113 ----------------------------- examples/location_test_msg.cc | 133 ---------------------------------- 3 files changed, 248 deletions(-) delete mode 100644 examples/location_test.cc delete mode 100644 examples/location_test_msg.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 935d8303df..c3d4f5ee79 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -18,8 +18,6 @@ set( term_epoch_advanced term_ds trace_ring - location_test - location_test_msg lb_iter hello_world_virtual_context jacobi1d_vt diff --git a/examples/location_test.cc b/examples/location_test.cc deleted file mode 100644 index 516ef8dbce..0000000000 --- a/examples/location_test.cc +++ /dev/null @@ -1,113 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// location_test.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -using namespace vt; - -using EntityType = int32_t; - -struct EntityMsg : vt::Message { - EntityType entity; - NodeType home; - - EntityMsg(EntityType const& in_entity, NodeType const& in_home) - : Message(), entity(in_entity), home(in_home) - { } -}; - -static void entityTestHandler(EntityMsg* msg) { - fmt::print( - "{}: entityTestHandler entity={}\n", theContext()->getNode(), msg->entity - ); - - theLocMan()->virtual_loc->getLocation(msg->entity, msg->home, [](NodeType node){ - fmt::print("{}: entityTestHandler: location={}\n", theContext()->getNode(), node); - theLocMan()->virtual_loc->printCurrentCache(); - }); -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); - - if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - - int32_t entity = 10, entity2 = 11, entity3 = 12; - - if (my_node == 0) { - theLocMan()->virtual_loc->registerEntity(entity,my_node); - theLocMan()->virtual_loc->registerEntity(entity2,my_node); - } else if (my_node == 1) { - theLocMan()->virtual_loc->registerEntity(entity3,my_node); - } - - if (my_node == 0) { - theMsg()->broadcastMsg( - makeSharedMessage(entity, my_node) - ); - theMsg()->broadcastMsg( - makeSharedMessage(entity2, my_node) - ); - } else if (my_node == 1) { - theMsg()->broadcastMsg( - makeSharedMessage(entity3, my_node) - ); - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} diff --git a/examples/location_test_msg.cc b/examples/location_test_msg.cc deleted file mode 100644 index 367eee3e67..0000000000 --- a/examples/location_test_msg.cc +++ /dev/null @@ -1,133 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// location_test_msg.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 -#include -#include - -#include "vt/transport.h" - -using namespace vt; - -using EntityType = int32_t; -static constexpr EntityType const arbitrary_entity_id = 10; - -static constexpr int const magic_number = 29; - -struct EntityMsg : Message { - EntityType entity; - NodeType home; - - EntityMsg(EntityType const& in_entity, NodeType const& in_home) - : Message(), entity(in_entity), home(in_home) - { } -}; - -struct MyTestMsg : LocationRoutedMsg { - NodeType from_node = uninitialized_destination; - int data = 0; - - MyTestMsg(int const& in_data, NodeType const& in_from_node) - : LocationRoutedMsg(), - from_node(in_from_node), data(in_data) - { } -}; - -static void entityTestHandler(EntityMsg* msg) { - auto const& node = theContext()->getNode(); - - fmt::print( - "{}: entityTestHandler entity={}\n", node, msg->entity - ); - - auto test_msg = makeMessage(magic_number + node, node); - theLocMan()->virtual_loc->routeMsg( - msg->entity, msg->home, test_msg - ); -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); - - if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - - EntityType entity = arbitrary_entity_id; - - if (my_node == 0) { - theLocMan()->virtual_loc->registerEntity( - entity, my_node, [](BaseMessage* in_msg){ - auto msg = static_cast(in_msg); - - vtAssert( - msg->data == magic_number + msg->from_node, - "Message data is corrupted" - ); - - fmt::print( - "{}: handler triggered for test msg: data={}\n", - theContext()->getNode(), msg->data - ); - } - ); - - theMsg()->broadcastMsg( - makeSharedMessage(entity, my_node) - ); - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From ec8b413f1e832c1d9c7f22fffaaafda2890b644d Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 16:12:03 -0700 Subject: [PATCH 48/88] #526: example: turn pipe_simple into useful callback example --- examples/CMakeLists.txt | 1 + examples/callback.cc | 163 +++++++++++++++ examples/pipe_simple.cc | 427 ---------------------------------------- 3 files changed, 164 insertions(+), 427 deletions(-) create mode 100644 examples/callback.cc delete mode 100644 examples/pipe_simple.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index c3d4f5ee79..54d1b9e849 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -37,6 +37,7 @@ set( transpose tutorial objgroup + callback ) if (VT_NO_BUILD_EXAMPLES) diff --git a/examples/callback.cc b/examples/callback.cc new file mode 100644 index 0000000000..973546ffa6 --- /dev/null +++ b/examples/callback.cc @@ -0,0 +1,163 @@ +/* +//@HEADER +// ***************************************************************************** +// +// pipe_simple.cc +// DARMA Toolkit v. 1.0.0 +// DARMA/vt => Virtual Transport +// +// Copyright 2019 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 + +// Message sent from the callback to the callback endpoint +struct TestMsg : vt::Message { + using MessageParentType = ::vt::Message; + vt_msg_serialize_required(); // for string + + TestMsg() = default; + + explicit TestMsg(int in_val, std::string const& in_s = "hello") + : val_(in_val), + s_(in_s) + { } + + template + void serialize(SerializerT& s) { + MessageParentType::serialize(s); + s | val_; + s | s_; + } + + int val_ = 0; + std::string s_; +}; + +// Message containing the callback to invoke +struct HelloMsg : vt::Message { + explicit HelloMsg(vt::Callback in_cb) + : cb_(in_cb) + { } + + vt::Callback cb_; +}; + +// Handler function to invoke the callback from +void hello_world(HelloMsg* msg) { + static int val = 1; + fmt::print("{}: Sending callback\n", vt::theContext()->getNode()); + auto to_send = vt::makeSharedMessage(292 + val++, "test string"); + msg->cb_.send(to_send); +} + +void printOutput(TestMsg* msg, std::string type) { + vt::NodeType this_node = vt::theContext()->getNode(); + fmt::print("{}: cb {}: val={}, str={}\n", this_node, type, msg->val_, msg->s_); +} + +// Functor callback endpoint +struct CallbackFunctor { + void operator()(TestMsg* msg) { + printOutput(msg, "CallbackFunctor"); + } +}; + +// Function callback endpoint +static void callbackFunc(TestMsg* msg) { + printOutput(msg, "callbackFunc"); +} + +struct MyObj { + // Objgroup callback endpoint + void handler(TestMsg* msg) { + printOutput(msg, "MyObj::handler"); + } +}; + +struct MyCol : vt::Collection { }; + +// Collection handler callback endpoint +void colHan(TestMsg* msg, MyCol* col) { + printOutput(msg, "MyCol colHan (non-intrusive)"); +} + +void bounceCallback(vt::Callback cb) { + auto msg = vt::makeMessage(cb); + vt::theMsg()->sendMsg(1, msg.get()); +} + +int main(int argc, char** argv) { + vt::initialize(argc, argv); + + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + + if (num_nodes == 1) { + return vt::rerror("requires at least 2 nodes"); + } + + auto obj = vt::theObjGroup()->makeCollective(); + auto col = vt::theCollection()->constructCollective( + vt::Index1D(8), [](vt::Index1D){ return std::make_unique(); } + ); + + if (this_node == 0) { + vt::NodeType dest = num_nodes > 2 ? 2 : 0; + + auto cb_functor = vt::theCB()->makeSend(dest); + bounceCallback(cb_functor); + + auto cb_func = vt::theCB()->makeSend(dest); + bounceCallback(cb_func); + + auto cb_obj = vt::theCB()->makeSend(obj[dest]); + bounceCallback(cb_obj); + + auto cb_obj_bcast = vt::theCB()->makeBcast(obj); + bounceCallback(cb_obj_bcast); + + auto cb_col = vt::theCB()->makeSend(col[5]); + bounceCallback(cb_col); + + auto cb_col_bcast = vt::theCB()->makeBcast(col); + bounceCallback(cb_col_bcast); + } + + vt::finalize(); + + return 0; +} diff --git a/examples/pipe_simple.cc b/examples/pipe_simple.cc deleted file mode 100644 index 84d40f3f40..0000000000 --- a/examples/pipe_simple.cc +++ /dev/null @@ -1,427 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// pipe_simple.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -using namespace vt; -using namespace vt::index; -using namespace vt::mapping; - -struct MyCol : Collection { - MyCol() = default; -}; - - -template -struct HelloMsg : vt::Message { - int from; - CallbackT cb; - - HelloMsg(int const& in_from, CallbackT cb) - : Message(), from(in_from), cb(cb) - { } - - template - void serialize(SerializerT& s) { - s | from; - s | cb; - } -}; - -struct TestMsg : vt::Message { - int val = 0; - std::string s; - - TestMsg() : s("hello") {} - - template - void serialize(SerializerT& m) { - m | val; - m | s; - } -}; -struct TestColMsg : CollectionMessage { - int val = 0; -}; -struct TestMsg2 : vt::Message { - int val = 0; -}; - -static void handler(TestColMsg* msg, MyCol* col) { - fmt::print( - "{}: triggering collection handler: idx={}\n", - theContext()->getNode(), col->getIndex() - ); -} - -template -static void hello_world(HelloMsg* msg) { - fmt::print("{}: Hello from node {}\n", theContext()->getNode(), msg->from); - auto nmsg = makeSharedMessage(); - nmsg->val = 2883; - msg->cb.send(nmsg); -} - -template -static void hello_world_2(HelloMsg* msg) { - fmt::print("{}: (ANON) Hello from node {}\n", theContext()->getNode(), msg->from); - auto nmsg = makeSharedMessage(); - nmsg->val = 2773; - msg->cb.send(nmsg); -} - - -template -static void hello_world_3(HelloMsg* msg) { - fmt::print("{}: (ANON) Hello from node {}\n", theContext()->getNode(), msg->from); - msg->cb.send(); -} - - -template -static void hello_world_4(HelloMsg* msg) { - fmt::print("{}: (ANON) Hello from node {}\n", theContext()->getNode(), msg->from); - auto nmsg = makeSharedMessage(); - nmsg->val = 2847; - msg->cb.send(nmsg); -} - -static void callback_method(TestMsg* msg) { - fmt::print("{}: triggering callback_method: {}\n", theContext()->getNode(), msg->s); -} -static void callback_method_2(TestMsg* msg) { - fmt::print("{}: triggering callback_method_2: {}\n", theContext()->getNode(), msg->s); -} -static void callback_method_3(TestMsg* msg) { - fmt::print("{}: triggering callback_method_3: {}\n", theContext()->getNode(), msg->s); -} -static void callback_method_4(TestMsg* msg) { - fmt::print("{}: triggering callback_method_4: {}\n", theContext()->getNode(), msg->s); -} - -struct CallbackMethodFunctor { - void operator()(TestMsg* msg) { - fmt::print("{}: triggering functor 1\n", theContext()->getNode()); - } -}; - -struct CallbackMethodFunctorNew { - void operator()(TestMsg* msg) { - fmt::print("{}: triggering functor NEW\n", theContext()->getNode()); - } -}; - -struct CallbackMethodFunctorVoid { - void operator()() { - fmt::print("{}: triggering functor VOID\n", theContext()->getNode()); - } -}; - -struct CallbackMethodFunctorB { - void operator()(TestMsg* msg) { - fmt::print("{}: triggering functor 1 bcast\n", theContext()->getNode()); - } -}; - -struct CallbackMethodFunctorVoidB { - void operator()() { - fmt::print("{}: triggering functor VOID bcast\n", theContext()->getNode()); - } -}; - -struct CallbackMethodFunctor { - void operator()(TestMsg* msg) { - fmt::print("{}: triggering functor 1\n", theContext()->getNode()); - } -}; - -struct CallbackMethodFunctorNew { - void operator()(TestMsg* msg) { - fmt::print("{}: triggering functor NEW\n", theContext()->getNode()); - } -}; - -struct CallbackMethodFunctorVoid { - void operator()() { - fmt::print("{}: triggering functor VOID\n", theContext()->getNode()); - } -}; - -struct CallbackMethodFunctorB { - void operator()(TestMsg* msg) { - fmt::print("{}: triggering functor 1 bcast\n", theContext()->getNode()); - } -}; - -struct CallbackMethodFunctorVoidB { - void operator()() { - fmt::print("{}: triggering functor VOID bcast\n", theContext()->getNode()); - } -}; - -#define sstmac_app_name hello_world_vt -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - auto const& my_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); - - if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - - if (my_node == 0) { - auto const dest_x = num_nodes < 4 ? 1 : 2; - auto cb = theCB()->makeCallbackSingleSendTyped( - true, dest_x - ); - // auto cb2 = theCB()->makeCallbackMultiSendTyped< - // TestMsg,callback_method,callback_method_2 - // >(true, 2); - - auto cb3a = theCB()->pushTarget(1); - auto cb3b = theCB()->pushTarget(cb3a,dest_x); - auto cb3c = theCB()->pushTarget(cb3b,1); - auto cb3d = theCB()->pushTargetBcast(cb3c,true); - auto cb2 = theCB()->buildMultiCB(cb3d); - - //auto cb2 = theCB()->makeCallbackSingleBcast(true); - //auto cb2 = theCB()->makeCallbackSingleBcastTyped(true); - - auto msg = makeSharedMessage>(my_node, cb2); - theMsg()->sendMsg, hello_world>(1, msg); - - { - auto cbx = theCB()->makeCallbackSingleAnonTyped(true,[](TestMsg* msg){ - ::fmt::print("A: callback has been triggered! val={}\n", msg->val); - }); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_2>(1, msgx); - } - - { - auto cbx = theCB()->makeCallbackSingleAnonVoidTyped<>(true,[](){ - ::fmt::print("B: callback has been triggered!\n"); - }); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_3>(1, msgx); - } - - - // Functor variants - { - auto cbx = theCB()->makeCallbackSingleSendFunctorTyped< - CallbackMethodFunctor - >(true,dest_x); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_2>(1, msgx); - } - - { - auto cbx = theCB()->makeCallbackSingleSendFunctorVoidTyped< - CallbackMethodFunctorVoid - >(true,dest_x); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_3>(1, msgx); - } - - { - auto cbx = theCB()->makeCallbackSingleBcastFunctorTyped< - CallbackMethodFunctorB - >(true); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_2>(1, msgx); - } - - { - auto cbx = theCB()->makeCallbackSingleBcastFunctorVoidTyped< - CallbackMethodFunctorVoidB - >(true); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_3>(1, msgx); - } - - - auto range = Index1D(32); - auto proxy = theCollection()->construct(range); - { - auto cbx = theCB()->makeCallbackSingleProxySendTyped< - MyCol,TestColMsg,&handler - >(proxy[10]); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_4>(1, msgx); - } - - /////////////////////////////// typeless //////////////////////////////// - - { - auto cbx = theCB()->makeCallbackSingleProxySend< - MyCol,TestColMsg,&handler - >(proxy[3]); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_4>(1, msgx); - } - - // { - // auto cbx = theCB()->makeCallbackSingleProxyBcast< - // MyCol,TestColMsg,&handler - // >(proxy); - // auto msgx = makeSharedMessage>(my_node, cbx); - // theMsg()->sendMsg, hello_world_4>(1, msgx); - // } - - { - auto cbx = theCB()->makeCallbackSingleProxyBcastDirect< - MyCol,TestColMsg,&handler - >(proxy); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_4>(1, msgx); - } - - // non-proxy - { - auto cbx = theCB()->makeCallbackSingleAnon([](TestMsg* msg){ - ::fmt::print("C: callback has been triggered! val={}\n", msg->val); - }); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_2>(1, msgx); - } - - { - auto cbx = theCB()->makeCallbackSingleAnonVoid<>([]{ - ::fmt::print("D: callback has been triggered!\n"); - }); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_3>(1, msgx); - } - - - { - auto cbx = theCB()->makeCallback<>(); - theCB()->addListener(cbx,1); - theCB()->addListenerFunctor(cbx,dest_x); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_2>(1, msgx); - } - - // { - // auto cbx = theCB()->makeCallbackTyped(); - // theCB()->addListener(cbx,1); - // theCB()->addListenerFunctor(cbx,dest_x); - // auto msgx = makeSharedMessage>(my_node, cbx); - // theMsg()->sendMsg, hello_world_2>(1, msgx); - // } - - // Functor variants - { - auto cbx = theCB()->makeCallbackFunctorSend(dest_x); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_2>(1, msgx); - } - - { - auto cbx = theCB()->makeCallbackFunctorSendVoid< - CallbackMethodFunctorVoid - >(dest_x); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_3>(1, msgx); - } - - { - auto cbx = theCB()->makeCallbackFunctorBcast(true); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_2>(1, msgx); - } - - { - auto cbx = theCB()->makeCallbackFunctorBcastVoid< - CallbackMethodFunctorVoidB - >(true); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_3>(1, msgx); - } - - - auto cby = theCB()->makeCallbackSingleAnonVoid<>([]{ - ::fmt::print("anon callback has been triggered!\n"); - }); - - // New variants - { - auto cbx = theCB()->makeSend(dest_x); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_2>(1, msgx); - } - - { - auto cbx = theCB()->makeSend(dest_x); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_3>(1, msgx); - } - - { - auto cbx = theCB()->makeBcast(); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_2>(1, msgx); - } - - { - auto cbx = theCB()->makeBcast(); - auto msgx = makeSharedMessage>(my_node, cbx); - theMsg()->sendMsg, hello_world_3>(1, msgx); - } - - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From acef6e88fafb7a48d01d17f8e11d17d0da7bf913 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 16:36:00 -0700 Subject: [PATCH 49/88] #526: example: cleanup reduce.cc -> reduce_integral.cc --- examples/CMakeLists.txt | 2 +- examples/{reduce.cc => reduce_integral.cc} | 120 +++++++-------------- 2 files changed, 42 insertions(+), 80 deletions(-) rename examples/{reduce.cc => reduce_integral.cc} (66%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 54d1b9e849..88f6e899a0 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -33,7 +33,7 @@ set( rdma_unsized_collection group_rooted group_collective - reduce + reduce_integral transpose tutorial objgroup diff --git a/examples/reduce.cc b/examples/reduce_integral.cc similarity index 66% rename from examples/reduce.cc rename to examples/reduce_integral.cc index fa46aae211..0497f0f9a1 100644 --- a/examples/reduce.cc +++ b/examples/reduce_integral.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// reduce.cc +// reduce_integral.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // @@ -59,17 +59,13 @@ // -#include "vt/transport.h" +#include #include -#include - - -using namespace ::vt; - static constexpr std::size_t const default_nparts_object = 8; static constexpr std::size_t const default_num_objs = 4; static constexpr std::size_t const verbose = 1; +static constexpr vt::NodeType const reduce_root_node = 0; static bool root_reduce_finished = false; static double exactIntegral = 0.0; @@ -89,8 +85,9 @@ double f(double x) { return sin(M_PI * x); } +using ReduceMsg = vt::collective::ReduceTMsg; -struct Integration1D : vt::Collection { +struct Integration1D : vt::Collection { private: @@ -100,39 +97,18 @@ struct Integration1D : vt::Collection { public: explicit Integration1D() - : vt::Collection(), - numObjs_(default_num_objs), numPartsPerObject_(default_nparts_object) + : numObjs_(default_num_objs), + numPartsPerObject_(default_nparts_object) { } - // - // QuadSum: structure used for the reduction without callback - // - struct QuadSum { - - void operator()(vt::collective::ReduceTMsg* msg) { - // - // The root index knows the reduced value. - // It is obtained with ' msg->getConstVal() ' - // - ::fmt::print(" ## The integral over [0, 1] is {}\n", - msg->getConstVal()); - ::fmt::print(" ## The absolute error is {}\n", - std::fabs(msg->getConstVal() - exactIntegral)); - // - // Set the 'root_reduce_finished' variable to true. - // - root_reduce_finished = true; - } - - }; - struct CheckIntegral { - void operator()(vt::collective::ReduceTMsg* msg) { - ::fmt::print(" >> The integral over [0, 1] is {}\n", - msg->getConstVal()); - ::fmt::print(" >> The absolute error is {}\n", - std::fabs(msg->getConstVal() - exactIntegral)); + void operator()(ReduceMsg* msg) { + fmt::print(" >> The integral over [0, 1] is {}\n", msg->getConstVal()); + fmt::print( + " >> The absolute error is {}\n", + std::fabs(msg->getConstVal() - exactIntegral) + ); // // Set the 'root_reduce_finished' variable to true. // @@ -146,11 +122,8 @@ struct Integration1D : vt::Collection { size_t numObjects = 0; size_t nIntervalPerObject = 0; - InitMsg() = default; - - InitMsg(const size_t nobjs, const size_t nint) : - CollectionMessage(), - numObjects(nobjs), nIntervalPerObject(nint) + InitMsg(const size_t nobjs, const size_t nint) + : numObjects(nobjs), nIntervalPerObject(nint) { } }; @@ -192,9 +165,11 @@ struct Integration1D : vt::Collection { if (verbose > 0) { double b = a + numPartsPerObject_ * h; - ::fmt::print(" Interval [{}, {}], on node {} & object {}, " - "has integral {}.\n", a, b, theContext()->getNode(), - getIndex().x(), quadsum); + fmt::print( + " Interval [{}, {}], on node {} & object {}, " + "has integral {}.\n", a, b, vt::theContext()->getNode(), + getIndex(), quadsum + ); } // @@ -202,21 +177,9 @@ struct Integration1D : vt::Collection { // auto proxy = this->getCollectionProxy(); - auto msgCB = vt::makeSharedMessage< - vt::collective::ReduceTMsg - >(quadsum); - auto cback = vt::theCB()->makeSend(0); - proxy.reduce>(msgCB,cback); - - // - // Syntax without a callback function: - // -// auto proxy = this->getCollectionProxy(); -// auto msg2 = vt::makeSharedMessage< -// vt::collective::ReduceTMsg -// >(quadsum); -// proxy.reduce, QuadSum>(msg2); - + auto msgCB = vt::makeMessage(quadsum); + auto cback = vt::theCB()->makeSend(reduce_root_node); + proxy.reduce>(msgCB.get(),cback); } }; @@ -229,14 +192,14 @@ int main(int argc, char** argv) { std::string name(argv[0]); - vt::CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& this_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (argc == 1) { if (this_node == 0) { - ::fmt::print( + fmt::print( stderr, "{}: using default arguments since none provided\n", name ); } @@ -250,9 +213,10 @@ int main(int argc, char** argv) { numIntPerObject = (size_t) strtol(argv[2], nullptr, 10); } else { - ::fmt::print(stderr, - "usage: {} \n", - name); + fmt::print( + stderr, + "usage: {} \n", name + ); return 1; } } @@ -261,27 +225,25 @@ int main(int argc, char** argv) { // // Create the interval decomposition into objects // - using BaseIndexType = typename Index1D::DenseIndexType; - auto const& range = Index1D(static_cast(num_objs)); + using BaseIndexType = typename vt::Index1D::DenseIndexType; + auto range = vt::Index1D(static_cast(num_objs)); auto proxy = vt::theCollection()->construct(range); - auto rootMsg = makeSharedMessage< Integration1D::InitMsg > - (num_objs, numIntPerObject); - proxy.broadcast(rootMsg); - } - - while (!rt->isTerminated()) { - runScheduler(); + proxy.broadcast( + num_objs, numIntPerObject + ); } // Add something like this to validate the reduction. // Create the variable root_reduce_finished as a static variable, // which is only checked on one node. - theTerm()->addAction([]{ - vtAssertExpr(root_reduce_finished == true); + vt::theTerm()->addAction([]{ + if (vt::theContext()->getNode() == reduce_root_node) { + vtAssertExpr(root_reduce_finished == true); + } }); - vt::CollectiveOps::finalize(); + vt::finalize(); return 0; From d5a96aaa1bcc904029a0f1fb1305ca7905c66581 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 16:36:14 -0700 Subject: [PATCH 50/88] #526: example: fix name in header for callback.cc --- examples/callback.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/callback.cc b/examples/callback.cc index 973546ffa6..b0e79c7a54 100644 --- a/examples/callback.cc +++ b/examples/callback.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// pipe_simple.cc +// callback.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // From 661feca2e3eab734443b17d4a321d4049ca983a7 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 16:39:38 -0700 Subject: [PATCH 51/88] #526: example: clean up ring.cc --- examples/ring.cc | 51 ++++++++++++++++++++---------------------------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/examples/ring.cc b/examples/ring.cc index a9a0027b48..d3679aac4e 100644 --- a/examples/ring.cc +++ b/examples/ring.cc @@ -42,67 +42,58 @@ //@HEADER */ -#include "vt/transport.h" -#include - -using namespace vt; - -static NodeType next_node = uninitialized_destination; -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; +#include static int num_total_rings = 2; static int num_times = 0; struct RingMsg : vt::Message { - int from; + vt::NodeType from = vt::uninitialized_destination; - RingMsg(int const& in_from) - : Message(), from(in_from) + explicit RingMsg(vt::NodeType const& in_from) + : from(in_from) { } }; static void sendToNext(); static void ring(RingMsg* msg) { - fmt::print("{}: Hello from node {}: num_times={}\n", my_node, msg->from, num_times); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + + fmt::print("{}: Hello from node {}: num_times={}\n", this_node, msg->from, num_times); num_times++; - if (msg->from != num_nodes-1 or num_times < num_total_rings) { + if (msg->from != num_nodes - 1 or num_times < num_total_rings) { sendToNext(); } } static void sendToNext() { - RingMsg* msg = makeSharedMessage(my_node); - theMsg()->sendMsg(next_node, msg); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + vt::NodeType next_node = this_node + 1 >= num_nodes ? 0 : this_node + 1; + + auto msg = vt::makeMessage(this_node); + vt::theMsg()->sendMsg(next_node, msg.get()); } int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - next_node = my_node+1 >= num_nodes ? 0 : my_node+1; - - fmt::print("{}: my_node = {} here\n",theContext()->getNode(),my_node); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; + return vt::rerror("requires at least 2 nodes"); } - if (my_node == 0) { + if (this_node == 0) { sendToNext(); } - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); + vt::finalize(); return 0; } From 51180f17aaf00ecbafeba3d0c0b7969ed1265f27 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 16:47:49 -0700 Subject: [PATCH 52/88] #526: example: remove serialize_example --- examples/CMakeLists.txt | 1 - examples/serialize_example.cc | 246 ---------------------------------- 2 files changed, 247 deletions(-) delete mode 100644 examples/serialize_example.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 88f6e899a0..cc6b41f8fa 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -22,7 +22,6 @@ set( hello_world_virtual_context jacobi1d_vt jacobi2d_vt - serialize_example hello_world_virtual_context_remote hello_world_collection simple_collection diff --git a/examples/serialize_example.cc b/examples/serialize_example.cc deleted file mode 100644 index edc0c8db78..0000000000 --- a/examples/serialize_example.cc +++ /dev/null @@ -1,246 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// serialize_example.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -#include -#include -#include -#include -#include - -using namespace vt; -using namespace ::serialization::interface; - -struct MyTest3ByteSerializable { - using isByteCopyable = std::true_type; - - int c = 41, d = 29; - - void print() { - fmt::print("\t MyTest3ByteSerializable: c={}, d={}\n", c, d); - } -}; - -struct MyTest2 { - int c = 41; - - template - void serialize(Serializer& s) { - fmt::print("MyTest2 serialize\n"); - s | c; - } - - void print() { - fmt::print("\t MyTest2: c={}\n", c); - } -}; - -struct MyTest { - int a = 29, b = 31; - MyTest2 my_test_2; - - MyTest() = default; - - void print() { - fmt::print("MyTest: a={}, b={}\n", a, b); - my_test_2.print(); - } - - template - void serialize(Serializer& s) { - fmt::print("MyTest serialize\n"); - s | a; - s | b; - s | my_test_2; - } -}; - -void testSerializeVector() { - std::vector vec{10,20,40}; - - for (auto&& elm : vec) { - fmt::print("vec: before elm={}\n", elm); - } - - auto serialized = serialize(vec); - auto const& buf = serialized->getBuffer(); - auto const& buf_size = serialized->getSize(); - - fmt::print("vec: ptr={}, size={}\n", buf, buf_size); - - auto buffer = new std::vector; - auto* tptr1 = deserialize>(buf, buf_size, buffer); - auto& t = *tptr1; - - for (auto&& elm : t) { - fmt::print("vec: deserialized elm={}\n", elm); - } - - delete buffer; -} - -void testSerializeUserClass() { - MyTest my_test_inst{10}; - - my_test_inst.print(); - - auto serialized = serialize(my_test_inst); - - auto const& buf = serialized->getBuffer(); - auto const& buf_size = serialized->getSize(); - - fmt::print("ptr={}, size={}\n", buf, buf_size); - - auto buffer = new MyTest; - auto* tptr1 = deserialize(buf, buf_size, buffer); - auto& t = *tptr1; - - t.print(); - - delete buffer; -} - -void testSerializeByteUserClass() { - using Type = MyTest3ByteSerializable; - - Type my_test_inst; - - my_test_inst.print(); - - auto serialized = serialize(my_test_inst); - - auto const& buf = serialized->getBuffer(); - auto const& buf_size = serialized->getSize(); - - fmt::print("ptr={}, size={}\n", buf, buf_size); - - auto buffer = new Type; - auto* tptr1 = deserialize(buf, buf_size, buffer); - auto& t = *tptr1; - - t.print(); - - delete buffer; -} - -void testSerializeTuple() { - // Tuple test - using serial_type_t = std::tuple; - - serial_type_t tup{10, 20}; - - fmt::print("[[ {}, {} ]]\n", std::get<0>(tup), std::get<1>(tup)); - - auto s1 = serialize(tup); - - auto const& buf2 = s1; - - fmt::print( - "ptr={}, val={}, size={}\n", - buf2->getBuffer(), *reinterpret_cast(buf2->getBuffer()), - s1->getSize() - ); - - auto buffer = new serial_type_t; - auto tptr = deserialize( - buf2->getBuffer(), s1->getSize(), buffer - ); - auto& t1 = *tptr; - - fmt::print("[[ {}, {} ]]\n", std::get<0>(t1), std::get<1>(t1)); - - delete buffer; -} - -void testSerializeTupleVector() { - // Tuple test - using serial_type_t = std::tuple>; - - serial_type_t tup{10,{20,30}}; - - fmt::print("[[ {}, {} ]]\n", std::get<0>(tup), std::get<1>(tup)[0]); - - auto s1 = serialize(tup); - - auto const& buf2 = s1; - - fmt::print( - "ptr={}, val={}, size={}\n", - buf2->getBuffer(), *reinterpret_cast(buf2->getBuffer()), - s1->getSize() - ); - - auto buffer = new serial_type_t; - auto tptr = deserialize( - buf2->getBuffer(), s1->getSize(), buffer - ); - auto& t1 = *tptr; - - fmt::print("[[ {}, {} ]]\n", std::get<0>(t1), std::get<1>(t1)[0]); - - delete buffer; -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - testSerializeVector(); - testSerializeTuple(); - testSerializeByteUserClass(); - - #if HAS_SERIALIZATION_LIBRARY - testSerializeTupleVector(); - testSerializeUserClass(); - #endif - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From f93cbfc0bf085b3c2343a48d4bea73c818667be9 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 16:48:13 -0700 Subject: [PATCH 53/88] #526: example: cleanup simple_collection --- examples/simple_collection.cc | 40 +++++++++++------------------------ 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/examples/simple_collection.cc b/examples/simple_collection.cc index b2f057447e..9fbb19c2eb 100644 --- a/examples/simple_collection.cc +++ b/examples/simple_collection.cc @@ -42,27 +42,16 @@ //@HEADER */ -#include "vt/transport.h" +#include -#include -#include +struct MyCol : vt::Collection { + MyCol() = default; -using namespace ::vt; -using namespace ::vt::collective; -using namespace ::vt::mapping; - -static constexpr std::size_t const default_num_elms = 64; - -using IndexType = IdxType1D; - -struct TestColl : Collection { - TestColl() = default; - - virtual ~TestColl() { + virtual ~MyCol() { vtAssert(counter_ == 1, "Must be equal"); } - struct TestMsg : CollectionMessage { }; + using TestMsg = vt::CollectionMessage; void doWork(TestMsg* msg) { counter_++; @@ -73,28 +62,23 @@ struct TestColl : Collection { }; int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& this_node = theContext()->getNode(); + vt::NodeType this_node = vt::theContext()->getNode(); - int32_t num_elms = default_num_elms; + int num_elms = 64; if (argc > 1) { num_elms = atoi(argv[1]); } if (this_node == 0) { - using BaseIndexType = typename IndexType::DenseIndexType; - auto const& range = IndexType(static_cast(num_elms)); - auto proxy = theCollection()->construct(range); - proxy.broadcast(); - } - - while (!rt->isTerminated()) { - runScheduler(); + auto range = vt::Index1D(num_elms); + auto proxy = vt::theCollection()->construct(range); + proxy.broadcast(); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From a246ece975a81c13f93c9e742a7f956cfdfd529d Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 16:51:37 -0700 Subject: [PATCH 54/88] #526: example: rename simple_collection with migrate, cleanup --- examples/CMakeLists.txt | 2 +- examples/hello_world_collection.cc | 78 +++-------------- ...le_collection.cc => migrate_collection.cc} | 83 +++++++++++++++---- 3 files changed, 82 insertions(+), 81 deletions(-) rename examples/{simple_collection.cc => migrate_collection.cc} (51%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index cc6b41f8fa..605ac35b43 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,8 +23,8 @@ set( jacobi1d_vt jacobi2d_vt hello_world_virtual_context_remote + migrate_collection hello_world_collection - simple_collection simple_collection_collective simple_collection_insert simple_collection_reduce diff --git a/examples/hello_world_collection.cc b/examples/hello_world_collection.cc index 66ba335bcf..8c0406e607 100644 --- a/examples/hello_world_collection.cc +++ b/examples/hello_world_collection.cc @@ -44,93 +44,39 @@ #include -static constexpr int32_t const default_num_elms = 16; - struct Hello : vt::Collection { Hello() = default; - explicit Hello(vt::NodeType create) { - vt::NodeType this_node = vt::theContext()->getNode(); - fmt::print("{}: Hello: create={}, index={}\n", this_node, create, getIndex()); - test_val = getIndex().x() * 29.3; + virtual ~Hello() { + vtAssert(counter_ == 1, "Must be equal"); } - template - void serialize(Serializer& s) { - vt::Collection::serialize(s); - s | test_val; - } + using TestMsg = vt::CollectionMessage; - double test_val = 0.0; -}; - -struct ColMsg : vt::CollectionMessage { - explicit ColMsg(vt::NodeType const& in_from_node) - : from_node(in_from_node) - { } + void doWork(TestMsg* msg) { + fmt::print("Hello from {}\n", this->getIndex()); + counter_++; + } - vt::NodeType from_node = vt::uninitialized_destination; +private: + int32_t counter_ = 0; }; -static void doWork(ColMsg* msg, Hello* col) { - vt::NodeType this_node = vt::theContext()->getNode(); - fmt::print("{}: idx={}: val={}\n", this_node, col->getIndex(), col->test_val); -} - -static void migrateToNext(ColMsg* msg, Hello* col) { - vt::NodeType this_node = vt::theContext()->getNode(); - vt::NodeType num_nodes = vt::theContext()->getNumNodes(); - vt::NodeType next_node = (this_node + 1) % num_nodes; - - fmt::print("{}: migrateToNext: idx={}\n", this_node, col->getIndex()); - col->migrate(next_node); -} - -template -void executeInEpoch(Callable&& fn) { - auto ep = vt::theTerm()->makeEpochRooted(); - vt::theMsg()->pushEpoch(ep); - fn(); - vt::theMsg()->popEpoch(ep); - vt::theTerm()->finishedEpoch(ep); - bool done = false; - vt::theTerm()->addAction(ep, [&done]{ done = true; }); - do vt::runScheduler(); while (!done); -} - int main(int argc, char** argv) { vt::initialize(argc, argv); vt::NodeType this_node = vt::theContext()->getNode(); - vt::NodeType num_nodes = vt::theContext()->getNumNodes(); - if (num_nodes == 1) { - return vt::rerror("requires at least 2 nodes"); - } + int num_elms = 64; - int32_t num_elms = default_num_elms; if (argc > 1) { num_elms = atoi(argv[1]); } if (this_node == 0) { auto range = vt::Index1D(num_elms); - auto proxy = vt::theCollection()->construct(range, this_node); - - executeInEpoch([=]{ - auto msg = vt::makeMessage(this_node); - proxy.broadcast(msg.get()); - }); - - executeInEpoch([=]{ - auto msg = vt::makeMessage(this_node); - proxy.broadcast(msg.get()); - }); - - executeInEpoch([=]{ - auto msg = vt::makeMessage(this_node); - proxy.broadcast(msg.get()); - }); + auto proxy = vt::theCollection()->construct(range); + proxy.broadcast(); } vt::finalize(); diff --git a/examples/simple_collection.cc b/examples/migrate_collection.cc similarity index 51% rename from examples/simple_collection.cc rename to examples/migrate_collection.cc index 9fbb19c2eb..4bdb3d303e 100644 --- a/examples/simple_collection.cc +++ b/examples/migrate_collection.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// simple_collection.cc +// migrate_collection.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // @@ -44,38 +44,93 @@ #include -struct MyCol : vt::Collection { - MyCol() = default; +static constexpr int32_t const default_num_elms = 16; - virtual ~MyCol() { - vtAssert(counter_ == 1, "Must be equal"); - } +struct Hello : vt::Collection { + Hello() = default; - using TestMsg = vt::CollectionMessage; + explicit Hello(vt::NodeType create) { + vt::NodeType this_node = vt::theContext()->getNode(); + fmt::print("{}: Hello: create={}, index={}\n", this_node, create, getIndex()); + test_val = getIndex().x() * 29.3; + } - void doWork(TestMsg* msg) { - counter_++; + template + void serialize(Serializer& s) { + vt::Collection::serialize(s); + s | test_val; } -private: - int32_t counter_ = 0; + double test_val = 0.0; +}; + +struct ColMsg : vt::CollectionMessage { + explicit ColMsg(vt::NodeType const& in_from_node) + : from_node(in_from_node) + { } + + vt::NodeType from_node = vt::uninitialized_destination; }; +static void doWork(ColMsg* msg, Hello* col) { + vt::NodeType this_node = vt::theContext()->getNode(); + fmt::print("{}: idx={}: val={}\n", this_node, col->getIndex(), col->test_val); +} + +static void migrateToNext(ColMsg* msg, Hello* col) { + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + vt::NodeType next_node = (this_node + 1) % num_nodes; + + fmt::print("{}: migrateToNext: idx={}\n", this_node, col->getIndex()); + col->migrate(next_node); +} + +template +void executeInEpoch(Callable&& fn) { + auto ep = vt::theTerm()->makeEpochRooted(); + vt::theMsg()->pushEpoch(ep); + fn(); + vt::theMsg()->popEpoch(ep); + vt::theTerm()->finishedEpoch(ep); + bool done = false; + vt::theTerm()->addAction(ep, [&done]{ done = true; }); + do vt::runScheduler(); while (!done); +} + int main(int argc, char** argv) { vt::initialize(argc, argv); vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); - int num_elms = 64; + if (num_nodes == 1) { + return vt::rerror("requires at least 2 nodes"); + } + int32_t num_elms = default_num_elms; if (argc > 1) { num_elms = atoi(argv[1]); } if (this_node == 0) { auto range = vt::Index1D(num_elms); - auto proxy = vt::theCollection()->construct(range); - proxy.broadcast(); + auto proxy = vt::theCollection()->construct(range, this_node); + + executeInEpoch([=]{ + auto msg = vt::makeMessage(this_node); + proxy.broadcast(msg.get()); + }); + + executeInEpoch([=]{ + auto msg = vt::makeMessage(this_node); + proxy.broadcast(msg.get()); + }); + + executeInEpoch([=]{ + auto msg = vt::makeMessage(this_node); + proxy.broadcast(msg.get()); + }); } vt::finalize(); From f775cf8ae2990c22d0bd58dd14587125067a5632 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 16:57:35 -0700 Subject: [PATCH 55/88] #526: example: rewrite simple_collection_collective --- examples/simple_collection_collective.cc | 59 +++++++----------------- 1 file changed, 17 insertions(+), 42 deletions(-) diff --git a/examples/simple_collection_collective.cc b/examples/simple_collection_collective.cc index 5213cb2313..da889148d0 100644 --- a/examples/simple_collection_collective.cc +++ b/examples/simple_collection_collective.cc @@ -42,69 +42,44 @@ //@HEADER */ -#include "vt/transport.h" +#include -#include -#include +struct Hello : vt::Collection { + Hello() = default; -using namespace ::vt; -using namespace ::vt::collective; -using namespace ::vt::mapping; - -static constexpr std::size_t const default_num_elms = 64; - -using IndexType = IdxType1D; - -struct TestColl : Collection { - TestColl() = default; - - virtual ~TestColl() { - auto num_nodes = theContext()->getNumNodes(); - vtAssertInfo( - counter_ == num_nodes, "Must be equal", - counter_, num_nodes, getIndex(), theContext()->getNode() - ); + virtual ~Hello() { + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + vtAssert(counter_ == num_nodes, "Should receive # nodes broadcasts"); } - struct TestMsg : CollectionMessage { }; + using TestMsg = vt::CollectionMessage; void doWork(TestMsg* msg) { - auto const& this_node = theContext()->getNode(); counter_++; - ::fmt::print( - "{}: doWork: idx={}, cnt={}\n", this_node, getIndex().x(), counter_ - ); + fmt::print("Hello from {}, counter_={}\n", this->getIndex().x(), counter_); } private: - int32_t counter_ = 0; + int counter_ = 0; }; int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - int32_t num_elms = default_num_elms; + vt::initialize(argc, argv); + int32_t num_elms = 16; if (argc > 1) { num_elms = atoi(argv[1]); } - using BaseIndexType = typename IndexType::DenseIndexType; - auto const& range = IndexType(static_cast(num_elms)); - auto proxy = theCollection()->constructCollective( - range, [](IndexType idx){ - return std::make_unique(); - } + auto range = vt::Index1D(num_elms); + auto proxy = vt::theCollection()->constructCollective( + range, [](vt::Index1D){ return std::make_unique(); } ); - auto msg = makeSharedMessage(); - proxy.broadcast(msg); - - while (!rt->isTerminated()) { - runScheduler(); - } + // All nodes send a broadcast to all elements + proxy.broadcast(); - CollectiveOps::finalize(); + vt::finalize(); return 0; } From ace549699030243e36b5388b316352e271402e63 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 17:15:22 -0700 Subject: [PATCH 56/88] #526: example: rename simple_collection_collective --- examples/CMakeLists.txt | 2 +- ...ction_collective.cc => hello_world_collection_collective.cc} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename examples/{simple_collection_collective.cc => hello_world_collection_collective.cc} (100%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 605ac35b43..179aca3edb 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -25,7 +25,7 @@ set( hello_world_virtual_context_remote migrate_collection hello_world_collection - simple_collection_collective + hello_world_collection_collective simple_collection_insert simple_collection_reduce insertable_collection diff --git a/examples/simple_collection_collective.cc b/examples/hello_world_collection_collective.cc similarity index 100% rename from examples/simple_collection_collective.cc rename to examples/hello_world_collection_collective.cc From a8343cbbe7e64b6825f944cb002754a15434b9fc Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 17:15:43 -0700 Subject: [PATCH 57/88] #526: example: rewrite simple_collection_insert.cc --- examples/simple_collection_insert.cc | 79 ++++++++++++---------------- 1 file changed, 34 insertions(+), 45 deletions(-) diff --git a/examples/simple_collection_insert.cc b/examples/simple_collection_insert.cc index 6b3e8c47fc..a689e31fd2 100644 --- a/examples/simple_collection_insert.cc +++ b/examples/simple_collection_insert.cc @@ -42,81 +42,70 @@ //@HEADER */ -#include "vt/transport.h" - -#include -#include - -using namespace ::vt; -using namespace ::vt::collective; -using namespace ::vt::mapping; +#include static constexpr std::size_t const default_num_elms = 64; -using IndexType = IdxType1D; +struct Hello : vt::Collection { -struct TestColl : Collection { - TestColl() = default; + // Default constructor for migration + Hello() = default; - virtual ~TestColl() { - // auto num_nodes = theContext()->getNumNodes(); - // vtAssertInfo( - // counter_ == num_nodes, "Must be equal", - // counter_, num_nodes, getIndex(), theContext()->getNode() - // ); - fmt::print("{}: destroying TestColl\n", getIndex()); + // Constructor used during insertion + explicit Hello(std::string const& input_string) + : in(input_string) + { } + + virtual ~Hello() { + vtAssert(counter_ == 1, "Must be equal"); } - struct TestMsg : CollectionMessage { }; + using TestMsg = vt::CollectionMessage; void doWork(TestMsg* msg) { - auto const& this_node = theContext()->getNode(); counter_++; - ::fmt::print( - "{}: doWork: idx={}, cnt={}\n", this_node, getIndex().x(), counter_ - ); + + vt::NodeType this_node = vt::theContext()->getNode(); + fmt::print("{}: Hello from {}: {}\n", this_node, this->getIndex(), in); } private: - int32_t counter_ = 0; + int counter_ = 0; + std::string in; }; int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - auto const& this_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); - - int32_t num_elms = default_num_elms; + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + int num_elms = 32; if (argc > 1) { num_elms = atoi(argv[1]); } - using BaseIndexType = typename IndexType::DenseIndexType; - auto const& range = IndexType(static_cast(num_elms)); - auto token = theCollection()->constructInsert(range); + auto range = vt::Index1D(num_elms); + auto token = vt::theCollection()->constructInsert(range); + + for (int i = 0; i < num_elms; i++) { + // Insert even elements, round-robin the insertions from each node + if ((i / 2) % num_nodes == this_node and i % 2 == 0) { + auto str = fmt::format("inserted from {}", this_node); - for (size_t i = 0; i < default_num_elms; i++) { - if (i % num_nodes == static_cast(this_node)) { - fmt::print("node={}: inserting {}\n", this_node, i); - token[i].insert(); + // Construct the i'th element on this node, passing str to the constructor + token[i].insert(str); } } - fmt::print("finishedInsert: node={}: finished\n", this_node); - auto proxy = theCollection()->finishedInsert(std::move(token)); + // Finish all inserts on this node by invalidating the insert token + auto proxy = vt::theCollection()->finishedInsert(std::move(token)); if (this_node == 1) { - auto msg = makeSharedMessage(); - proxy[2].send(msg); - } - - while (!rt->isTerminated()) { - runScheduler(); + proxy.broadcast(); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From e5d7b1cf2b61428ab927c7d5cf53406ea4392272 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 17:16:45 -0700 Subject: [PATCH 58/88] #526: example: rename simple_collection_insert.cc --- examples/CMakeLists.txt | 2 +- ...ection_insert.cc => hello_world_collection_staged_insert.cc} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename examples/{simple_collection_insert.cc => hello_world_collection_staged_insert.cc} (98%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 179aca3edb..65cc8d6ed3 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -26,7 +26,7 @@ set( migrate_collection hello_world_collection hello_world_collection_collective - simple_collection_insert + hello_world_collection_staged_insert simple_collection_reduce insertable_collection rdma_unsized_collection diff --git a/examples/simple_collection_insert.cc b/examples/hello_world_collection_staged_insert.cc similarity index 98% rename from examples/simple_collection_insert.cc rename to examples/hello_world_collection_staged_insert.cc index a689e31fd2..0f60f0752f 100644 --- a/examples/simple_collection_insert.cc +++ b/examples/hello_world_collection_staged_insert.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// simple_collection_insert.cc +// hello_world_collection_staged_insert.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // From cb485d17985e21e2ace2d2fb31027e16df4dbaae Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 17:37:01 -0700 Subject: [PATCH 59/88] #526: example: rewrite simple_collection_reduce.cc --- .../hello_world_collection_staged_insert.cc | 2 - examples/simple_collection_reduce.cc | 66 +++++++------------ 2 files changed, 22 insertions(+), 46 deletions(-) diff --git a/examples/hello_world_collection_staged_insert.cc b/examples/hello_world_collection_staged_insert.cc index 0f60f0752f..a0941004d4 100644 --- a/examples/hello_world_collection_staged_insert.cc +++ b/examples/hello_world_collection_staged_insert.cc @@ -44,8 +44,6 @@ #include -static constexpr std::size_t const default_num_elms = 64; - struct Hello : vt::Collection { // Default constructor for migration diff --git a/examples/simple_collection_reduce.cc b/examples/simple_collection_reduce.cc index 42387010b6..dbab232595 100644 --- a/examples/simple_collection_reduce.cc +++ b/examples/simple_collection_reduce.cc @@ -42,71 +42,49 @@ //@HEADER */ -#include "vt/transport.h" +#include -#include -#include +struct Hello : vt::Collection { + using ReduceMsg = vt::collective::ReduceTMsg; -using namespace ::vt; -using namespace ::vt::collective; -using namespace ::vt::mapping; - -static constexpr std::size_t const default_num_elms = 8; - -using TestReduceMsg = ReduceTMsg; - -struct TestColl : Collection { - TestColl() = default; - - virtual ~TestColl() = default; - - struct TestMsg : CollectionMessage { }; - - void done(TestReduceMsg* msg) { - auto const& this_node = theContext()->getNode(); - ::fmt::print("{}: done: idx={}, val={}\n", this_node, getIndex().x(), msg->getVal()); + void done(ReduceMsg* msg) { + fmt::print("Reduce complete at {} value {}\n", this->getIndex(), msg->getVal()); } + using TestMsg = vt::CollectionMessage; + void doWork(TestMsg* msg) { - auto const& this_node = theContext()->getNode(); - ::fmt::print("{}: doWork: idx={}\n", this_node, getIndex().x()); + fmt::print("Hello from {}\n", this->getIndex()); + // Get the proxy for the collection auto proxy = this->getCollectionProxy(); - auto cb = theCB()->makeSend(proxy(2)); - vtAssertExpr(cb.valid()); - auto rmsg = makeMessage(); - rmsg->getVal() = 10; - proxy.reduce>(rmsg.get(),cb); + // Create a callback for when the reduction finishes + auto cb = vt::theCB()->makeSend(proxy(2)); + + // Create and send the reduction message holding an int + auto red_msg = vt::makeMessage(this->getIndex().x()); + proxy.reduce>(red_msg.get(),cb); } }; int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - auto const& this_node = theContext()->getNode(); + vt::initialize(argc, argv); - int32_t num_elms = default_num_elms; + vt::NodeType this_node = vt::theContext()->getNode(); + int32_t num_elms = 16; if (argc > 1) { num_elms = atoi(argv[1]); } if (this_node == 0) { - using IndexType = typename TestColl::IndexType; - using BaseIndexType = typename IndexType::DenseIndexType; - auto const& range = IndexType(static_cast(num_elms)); - auto proxy = theCollection()->construct(range); - - auto msg = makeSharedMessage(); - proxy.broadcast(msg); - } - - while (!rt->isTerminated()) { - runScheduler(); + auto range = vt::Index1D(num_elms); + auto proxy = vt::theCollection()->construct(range); + proxy.broadcast(); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From b32dd7478b3b7fee6951bd49bbb3debec06e8c02 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 17:37:55 -0700 Subject: [PATCH 60/88] #526: example: rename simple_collection_reduce.cc --- examples/CMakeLists.txt | 2 +- ...le_collection_reduce.cc => hello_world_collection_reduce.cc} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename examples/{simple_collection_reduce.cc => hello_world_collection_reduce.cc} (98%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 65cc8d6ed3..1714dedb01 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -27,7 +27,7 @@ set( hello_world_collection hello_world_collection_collective hello_world_collection_staged_insert - simple_collection_reduce + hello_world_collection_reduce insertable_collection rdma_unsized_collection group_rooted diff --git a/examples/simple_collection_reduce.cc b/examples/hello_world_collection_reduce.cc similarity index 98% rename from examples/simple_collection_reduce.cc rename to examples/hello_world_collection_reduce.cc index dbab232595..eaac7ef29b 100644 --- a/examples/simple_collection_reduce.cc +++ b/examples/hello_world_collection_reduce.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// simple_collection_reduce.cc +// hello_world_collection_reduce.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // From 5fcf4dd18aafd787a7ce37741f38232483174a79 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 17:49:02 -0700 Subject: [PATCH 61/88] #526: example: rewrite term_ds.cc --- examples/term_ds.cc | 75 ++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 45 deletions(-) diff --git a/examples/term_ds.cc b/examples/term_ds.cc index 462260d5c7..e13a374efe 100644 --- a/examples/term_ds.cc +++ b/examples/term_ds.cc @@ -48,70 +48,55 @@ using namespace vt; -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; -static EpochType cur_epoch = no_epoch; -static int32_t num = 2; +using TestMsg = vt::Message; -struct TestMsg : Message {}; +vt::NodeType nextNode() { + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + return (this_node + 1) % num_nodes; +} static void test_handler(TestMsg* msg) { - ::fmt::print("node={}, running handler: num={}\n", my_node, num); - num--; + static int num = 3; + + vt::NodeType this_node = vt::theContext()->getNode(); + + auto epoch = vt::envelopeGetEpoch(msg->env); + fmt::print("{}: test_handler: num={}, epoch={:x}\n", this_node, num, epoch); + num--; if (num > 0) { - auto msg2 = makeSharedMessage(); - envelopeSetEpoch(msg2->env, cur_epoch); - theMsg()->sendMsg((my_node + 1) % num_nodes,msg2); + auto msg_send = vt::makeMessage(); + vt::theMsg()->sendMsg(nextNode(), msg_send.get()); } } int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; + return vt::rerror("requires at least 2 nodes"); } - if (0) { - cur_epoch = theTerm()->makeEpochCollective(); - - fmt::print("{}: new cur_epoch={}\n", my_node, cur_epoch); - - theMsg()->sendMsg( - (my_node + 1) % num_nodes, - makeSharedMessage() - ); + if (this_node == 0) { + auto epoch = vt::theTerm()->makeEpochRooted(term::UseDS{true}); - theTerm()->addAction(cur_epoch, []{ - fmt::print("{}: running attached action: cur_epoch={}\n", my_node, cur_epoch); + // This action will not run until all messages originating from the + // following send are completed + vt::theTerm()->addAction(epoch, [=]{ + fmt::print("{}: finished epoch={:x}\n", this_node, epoch); }); - theTerm()->finishedEpoch(cur_epoch); - } - - if (my_node == 0) { - cur_epoch = theTerm()->makeEpochRooted(term::UseDS{true}); - - theTerm()->addAction(cur_epoch, []{ - fmt::print("{}: running attached action: cur_epoch={}\n", my_node, cur_epoch); - }); - - auto msg = makeSharedMessage(); - envelopeSetEpoch(msg->env, cur_epoch); - theMsg()->sendMsg((my_node + 1) % num_nodes,msg); - theTerm()->finishedEpoch(cur_epoch); - } - while (!rt->isTerminated()) { - runScheduler(); + auto msg = vt::makeMessage(); + vt::envelopeSetEpoch(msg->env, epoch); + vt::theMsg()->sendMsg(nextNode(), msg.get()); + vt::theTerm()->finishedEpoch(epoch); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From f1e5a53aa940c36004a208a99b8a61004cb30093 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 17:50:56 -0700 Subject: [PATCH 62/88] #526: example: rename term_ds.cc --- examples/CMakeLists.txt | 2 +- examples/{term_ds.cc => termination_dijkstra_scholten.cc} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename examples/{term_ds.cc => termination_dijkstra_scholten.cc} (98%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1714dedb01..5f50e01f67 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -16,7 +16,7 @@ set( test_seq term_epoch term_epoch_advanced - term_ds + termination_dijkstra_scholten.cc trace_ring lb_iter hello_world_virtual_context diff --git a/examples/term_ds.cc b/examples/termination_dijkstra_scholten.cc similarity index 98% rename from examples/term_ds.cc rename to examples/termination_dijkstra_scholten.cc index e13a374efe..7614a41719 100644 --- a/examples/term_ds.cc +++ b/examples/termination_dijkstra_scholten.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// term_ds.cc +// termination_dijkstra_scholten.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // From 3a092ec376137b50a0c32d3519a35f5105a65583 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 17:58:03 -0700 Subject: [PATCH 63/88] #526: example: rewrite rest of TD examples --- examples/CMakeLists.txt | 5 +- examples/term_epoch.cc | 176 ---------------------- examples/term_epoch_advanced.cc | 151 ------------------- examples/termination_collective.cc | 100 ++++++++++++ examples/termination_dijkstra_scholten.cc | 6 +- 5 files changed, 103 insertions(+), 335 deletions(-) delete mode 100644 examples/term_epoch.cc delete mode 100644 examples/term_epoch_advanced.cc create mode 100644 examples/termination_collective.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5f50e01f67..da070fe3a7 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -14,9 +14,8 @@ set( param hello_world_functor test_seq - term_epoch - term_epoch_advanced - termination_dijkstra_scholten.cc + termination_collective + termination_dijkstra_scholten trace_ring lb_iter hello_world_virtual_context diff --git a/examples/term_epoch.cc b/examples/term_epoch.cc deleted file mode 100644 index fcda72ed6f..0000000000 --- a/examples/term_epoch.cc +++ /dev/null @@ -1,176 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// term_epoch.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" - -#include - -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -static EpochType cur_epoch = no_epoch; - -using TTLType = int32_t; - -static constexpr EpochType const max_epochs = 5; -static constexpr TTLType const max_life_time = 5; -static constexpr TTLType const no_ttl = -1000; -static constexpr int32_t const max_msgs_per_node = 5; - -static bool use_epoch = true; - -struct PropagateMsg : vt::Message { - NodeType from = uninitialized_destination; - TTLType life_time = no_ttl; - - PropagateMsg(NodeType const& in_from) - : Message(), from(in_from), life_time(drand48() * max_life_time) - { } - - PropagateMsg(NodeType const& in_from, TTLType const& in_ttl) - : Message(), from(in_from), life_time(in_ttl) - { } -}; - -static void sendMsgEpoch(EpochType const& epoch, TTLType const& ttl = no_ttl); - -static void propagate_handler(PropagateMsg* msg) { - EpochType const epoch = envelopeGetEpoch(msg->env); - fmt::print( - "{}: propagate_handler: msg={}, epoch={:x}\n", my_node, print_ptr(msg), epoch - ); - if (msg->life_time > 0) { - sendMsgEpoch(epoch, msg->life_time); - } -} - -static void sendMsgEpoch(EpochType const& epoch, TTLType const& ttl) { - NodeType random_node = drand48() * num_nodes; - while (random_node == my_node) { - random_node = drand48() * num_nodes; - } - vtAssertExpr(random_node != my_node); - PropagateMsg* msg = nullptr; - - if (ttl == no_ttl) { - // generate a random TLL for the new msg - msg = makeSharedMessage(my_node); - } else { - msg = makeSharedMessage(my_node, ttl - 1); - } - - if (epoch != no_epoch) { - theMsg()->setEpochMessage(msg, epoch); - } - - fmt::print("{}: sending msg: epoch={:x}, ttl={}\n", my_node, epoch, msg->life_time); - - theMsg()->sendMsg(random_node, msg); - - fmt::print( - "{}: sendMsgEpoch: epoch={:x}, node={}, ttl-{}\n", - my_node, epoch, random_node, ttl - ); -} - -static void sendStartEpoch(EpochType const& epoch) { - int32_t const num_msgs = drand48() * max_msgs_per_node; - for (int i = 0; i < num_msgs; i++) { - sendMsgEpoch(epoch); - } -} - -static void next_epoch() { - fmt::print("{}: cur_epoch={:x}\n", my_node, cur_epoch); - - if (use_epoch) { - - if (cur_epoch + 1 < max_epochs) { - cur_epoch = theTerm()->makeEpochCollective(); - - fmt::print("{}: new cur_epoch={:x}\n", my_node, cur_epoch); - - sendStartEpoch(cur_epoch); - - theTerm()->addAction(cur_epoch, []{ - fmt::print("{}: running attached action: cur_epoch={:x}\n", my_node, cur_epoch); - next_epoch(); - }); - theTerm()->finishedEpoch(cur_epoch); - } - } else { - sendStartEpoch(no_epoch); - } -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - - if (argc > 1) { - use_epoch = atoi(argv[1]) == 1 ? true : false; - } - - fmt::print("{}:use_epoch={}\n", my_node, print_bool(use_epoch)); - - if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - - next_epoch(); - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} diff --git a/examples/term_epoch_advanced.cc b/examples/term_epoch_advanced.cc deleted file mode 100644 index 54258e2a8d..0000000000 --- a/examples/term_epoch_advanced.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// term_epoch_advanced.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" - -#include - -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -using TTLType = int32_t; - -static constexpr TTLType const max_life_time = 5; -static constexpr TTLType const no_ttl = -1000; - -struct PropagateMsg : vt::Message { - NodeType from = uninitialized_destination; - TTLType life_time = no_ttl; - - explicit PropagateMsg(NodeType const& in_from) - : ::vt::Message(), from(in_from), life_time(drand48() * max_life_time) - { } - - PropagateMsg(NodeType const& in_from, TTLType const& in_ttl) - : ::vt::Message(), from(in_from), life_time(in_ttl) - { } -}; - -static void sendMsgEpoch( - EpochType const& epoch, bool const set_epoch = false, - TTLType const& ttl = no_ttl -); - -static void propagateHandler(PropagateMsg* msg) { - EpochType const epoch = envelopeGetEpoch(msg->env); - fmt::print( - "{}: propagate_handler: msg={}, epoch={}\n", my_node, print_ptr(msg), epoch - ); - if (msg->life_time > 0) { - sendMsgEpoch(epoch, false, msg->life_time); - } -} - -static void sendMsgEpoch( - EpochType const& epoch, bool const set_epoch, TTLType const& ttl -) { - NodeType random_node = drand48() * num_nodes; - while (random_node == my_node) { - random_node = drand48() * num_nodes; - } - vtAssertExpr(random_node != my_node); - - PropagateMsg* msg = nullptr; - - if (ttl == no_ttl) { - // generate a random TLL for the new msg - msg = makeSharedMessage(my_node); - } else { - msg = makeSharedMessage(my_node, ttl - 1); - } - - if (epoch != no_epoch && set_epoch) { - theMsg()->setEpochMessage(msg, epoch); - } - - fmt::print( - "{}: sending msg: epoch={}, ttl={}, random_node={}\n", - my_node, epoch, msg->life_time, random_node - ); - - theMsg()->sendMsg(random_node, msg); - - fmt::print( - "{}: sendMsgEpoch: epoch={}, node={}, ttl={}\n", - my_node, epoch, random_node, ttl - ); -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - - if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - - if (my_node == 1) { - auto const& rooted_new_epoch = theTerm()->makeEpochRooted(); - ::fmt::print("{}: new epoch={}\n", my_node, rooted_new_epoch); - sendMsgEpoch(rooted_new_epoch, true, 5); - theTerm()->addAction(rooted_new_epoch, [=]{ - ::fmt::print("{}: epoch={}, action\n", my_node, rooted_new_epoch); - }); - theTerm()->finishedEpoch(rooted_new_epoch); - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} diff --git a/examples/termination_collective.cc b/examples/termination_collective.cc new file mode 100644 index 0000000000..5ff5ad33d9 --- /dev/null +++ b/examples/termination_collective.cc @@ -0,0 +1,100 @@ +/* +//@HEADER +// ***************************************************************************** +// +// termination_collective.cc +// DARMA Toolkit v. 1.0.0 +// DARMA/vt => Virtual Transport +// +// Copyright 2019 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 "vt/transport.h" + +using TestMsg = vt::Message; + +vt::NodeType nextNode() { + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + return (this_node + 1) % num_nodes; +} + +static void test_handler(TestMsg* msg) { + static int num = 3; + + vt::NodeType this_node = vt::theContext()->getNode(); + + auto epoch = vt::envelopeGetEpoch(msg->env); + fmt::print("{}: test_handler: num={}, epoch={:x}\n", this_node, num, epoch); + + num--; + if (num > 0) { + auto msg_send = vt::makeMessage(); + vt::theMsg()->sendMsg(nextNode(), msg_send.get()); + } +} + +int main(int argc, char** argv) { + vt::initialize(argc, argv); + + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); + + if (num_nodes == 1) { + return vt::rerror("requires at least 2 nodes"); + } + + auto epoch = vt::theTerm()->makeEpochCollective(); + + // This action will not run until all messages originating from the + // sends are completed + vt::theTerm()->addAction(epoch, [=]{ + fmt::print("{}: finished epoch={:x}\n", this_node, epoch); + }); + + // Message must go out of scope before finalize + { + auto msg = vt::makeMessage(); + vt::envelopeSetEpoch(msg->env, epoch); + vt::theMsg()->sendMsg(nextNode(), msg.get()); + } + + vt::theTerm()->finishedEpoch(epoch); + + vt::finalize(); + + return 0; +} diff --git a/examples/termination_dijkstra_scholten.cc b/examples/termination_dijkstra_scholten.cc index 7614a41719..56339c52d9 100644 --- a/examples/termination_dijkstra_scholten.cc +++ b/examples/termination_dijkstra_scholten.cc @@ -44,10 +44,6 @@ #include "vt/transport.h" -#include - -using namespace vt; - using TestMsg = vt::Message; vt::NodeType nextNode() { @@ -82,7 +78,7 @@ int main(int argc, char** argv) { } if (this_node == 0) { - auto epoch = vt::theTerm()->makeEpochRooted(term::UseDS{true}); + auto epoch = vt::theTerm()->makeEpochRooted(vt::term::UseDS{true}); // This action will not run until all messages originating from the // following send are completed From 221ce05a2acd2a0bde60deaf44f81796bed42cd7 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 17:59:38 -0700 Subject: [PATCH 64/88] #526: example: rename termination_dijkstra_scholten -> rooted --- examples/CMakeLists.txt | 2 +- .../{termination_dijkstra_scholten.cc => termination_rooted.cc} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename examples/{termination_dijkstra_scholten.cc => termination_rooted.cc} (98%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index da070fe3a7..93e0f41a62 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -15,7 +15,7 @@ set( hello_world_functor test_seq termination_collective - termination_dijkstra_scholten + termination_rooted trace_ring lb_iter hello_world_virtual_context diff --git a/examples/termination_dijkstra_scholten.cc b/examples/termination_rooted.cc similarity index 98% rename from examples/termination_dijkstra_scholten.cc rename to examples/termination_rooted.cc index 56339c52d9..905a9be918 100644 --- a/examples/termination_dijkstra_scholten.cc +++ b/examples/termination_rooted.cc @@ -2,7 +2,7 @@ //@HEADER // ***************************************************************************** // -// termination_dijkstra_scholten.cc +// termination_rooted.cc // DARMA Toolkit v. 1.0.0 // DARMA/vt => Virtual Transport // From 807c3ad4c983252087f0e81f4222d9ae7c88ad53 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 17:59:55 -0700 Subject: [PATCH 65/88] #526: example: remove test_seq --- examples/CMakeLists.txt | 1 - examples/test_seq.cc | 345 ---------------------------------------- 2 files changed, 346 deletions(-) delete mode 100644 examples/test_seq.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 93e0f41a62..3c2c436f45 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -13,7 +13,6 @@ set( callback_context param hello_world_functor - test_seq termination_collective termination_rooted trace_ring diff --git a/examples/test_seq.cc b/examples/test_seq.cc deleted file mode 100644 index f2909ae5e2..0000000000 --- a/examples/test_seq.cc +++ /dev/null @@ -1,345 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// test_seq.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -struct EmptyMsg : vt::Message { - EmptyMsg() : Message() { } -}; - -#define PRINT_SEQUENCE_ON 1 - -#if PRINT_SEQUENCE_ON -#define PRINT_SEQUENCE(...) \ - do { \ - vt_print( \ - sequence, __VA_ARGS__ \ - ); \ - } while (0); -#else -#define PRINT_SEQUENCE(...) -#endif - -SEQUENCE_REGISTER_HANDLER(EmptyMsg, action1) - -#pragma GCC diagnostic ignored "-Wunused-function" -static void mySeq(SeqType const& seq_id) { - PRINT_SEQUENCE("mySeq: executing sequence\n"); - - theSeq()->wait(10, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 WAIT-1 triggered\n"); - }); - - theSeq()->sequenced([]{ - PRINT_SEQUENCE("action1 sequenced_block triggered\n"); - auto const& this_node = theContext()->getNode(); - theMsg()->sendMsg( - this_node, makeSharedMessage(), 20 - ); - }); - - theSeq()->sequenced(seq_id, [=]{ - PRINT_SEQUENCE("SEQUENCED: (begin) unraveling child closure triggered\n\n"); - - theSeq()->wait(20, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 WAIT-2 triggered\n"); - }); - - theSeq()->wait(30, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 WAIT-3 triggered\n"); - - auto const& nd = my_node == 0 ? 1 : 0; - // send messages for the parallel region following - //theMsg()->sendMsg(nd, makeSharedMessage(), 229); - //theMsg()->sendMsg(nd, makeSharedMessage(), 129); - - theMsg()->sendMsg(nd, makeSharedMessage(), 900); - }); - - PRINT_SEQUENCE("SEQUENCED: (end) unraveling child closure triggered\n\n"); - }); - - theSeq()->sequenced([]{ - theSeq()->wait(900, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 WAIT-6 FINAL triggered\n"); - }); - }); -} - -#pragma GCC diagnostic ignored "-Wunused-function" -static void mySeqParallel(SeqType const& seq_id) { - PRINT_SEQUENCE("mySeqParallel: executing sequence\n"); - - theSeq()->wait(10, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 w1 triggered\n"); - theMsg()->sendMsg(0, makeSharedMessage(), 20); - theMsg()->sendMsg(0, makeSharedMessage(), 30); - theMsg()->sendMsg(0, makeSharedMessage(), 40); - }); - - theSeq()->parallel(seq_id, []{ - theSeq()->wait(20, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 w2-par-1 parallel triggered\n"); - }); - }, []{ - theSeq()->wait(30, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 w2-par-2 parallel triggered\n"); - }); - }); - - theSeq()->sequenced([]{ - theSeq()->wait(40, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 w3 FINAL triggered\n"); - }); - }); -} - -static void mySeqFor(SeqType const& seq_id) { - PRINT_SEQUENCE("mySeqParallel: executing sequence\n"); - - theSeq()->for_loop(0, 10, 1, [](vt::seq::ForIndex i) { - PRINT_SEQUENCE("for loop: i={}\n", i); - theSeq()->wait([](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 triggered\n"); - }); - }); -} - -#pragma GCC diagnostic ignored "-Wunused-function" -static void mySeqSingleNode(SeqType const& seq_id) { - PRINT_SEQUENCE("mySeqSingleNode: executing sequence\n"); - - theSeq()->wait(10, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 WAIT-1 triggered\n"); - }); - - theSeq()->sequenced([]{ - PRINT_SEQUENCE("action1 sequenced_block triggered\n"); - theMsg()->sendMsg(0, makeSharedMessage(), 20); - }); - - theSeq()->sequenced(seq_id, [=]{ - PRINT_SEQUENCE("SEQUENCED: (begin) unraveling child closure triggered\n"); - - theSeq()->wait(20, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 WAIT-2 triggered\n"); - }); - - theSeq()->wait(30, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 WAIT-3 triggered\n"); - theMsg()->sendMsg(0, makeSharedMessage(), 900); - }); - - PRINT_SEQUENCE("SEQUENCED: (end) unraveling child closure triggered\n"); - }); - - theSeq()->sequenced([]{ - PRINT_SEQUENCE("SEQUENCED: (begin) unraveling FINAL child closure triggered\n"); - - theSeq()->wait(900, [](EmptyMsg* msg){ - PRINT_SEQUENCE("action1 WAIT-6 FINAL triggered\n"); - }); - }); -} - -#pragma GCC diagnostic ignored "-Wunused-function" -static void simpleSeq(SeqType const& seq_id) { - PRINT_SEQUENCE("simpleSeq: executing sequence: seq_id={}\n", seq_id); - - theSeq()->wait(10, [](EmptyMsg* msg){ - auto const& cur_seq_id = theSeq()->getCurrentSeq(); - PRINT_SEQUENCE( - "simpleSeq: seq={}: w1 triggered: msg={}\n", cur_seq_id, print_ptr(msg) - ); - }); - - theSeq()->sequenced([]{ - PRINT_SEQUENCE("SEQUENCED: (begin) unraveling child closure\n"); - theSeq()->wait(100, [](EmptyMsg* msg){ - PRINT_SEQUENCE("simpleSeq: w100 inner triggered\n"); - }); - theSeq()->wait(200, [](EmptyMsg* msg){ - PRINT_SEQUENCE("simpleSeq: w200 inner triggered\n"); - }); - PRINT_SEQUENCE("SEQUENCED: (end) unraveling child closure\n"); - }); - - theSeq()->wait(20, [](EmptyMsg* msg){ - auto const& cur_seq_id = theSeq()->getCurrentSeq(); - PRINT_SEQUENCE( - "simpleSeq: seq={}: w2 triggered: msg={}\n", cur_seq_id, print_ptr(msg) - ); - theMsg()->sendMsg(0, makeSharedMessage(), 30); - }); - - theSeq()->wait(30, [](EmptyMsg* msg){ - auto const& cur_seq_id = theSeq()->getCurrentSeq(); - PRINT_SEQUENCE("simpleSeq: seq={}: w3 triggered\n", cur_seq_id); - }); - - theSeq()->sequenced([]{ - PRINT_SEQUENCE("SEQUENCED: (begin) unraveling child closure 2\n"); - theSeq()->wait(1000, [](EmptyMsg* msg){ - PRINT_SEQUENCE("simpleSeq: w1000 inner triggered\n"); - theMsg()->sendMsg(0, makeSharedMessage(), 40); - }); - - theSeq()->sequenced([]{ - PRINT_SEQUENCE("SEQUENCED: (begin) unraveling child closure 2a\n"); - theSeq()->wait(10000, [](EmptyMsg* msg){ - PRINT_SEQUENCE("simpleSeq: w10000 inner-inner triggered\n"); - }); - theSeq()->wait(20000, [](EmptyMsg* msg){ - PRINT_SEQUENCE("simpleSeq: w20000 inner-inner triggered\n"); - }); - PRINT_SEQUENCE("SEQUENCED: (end) unraveling child closure 2a\n"); - }); - - theSeq()->wait(2000, [](EmptyMsg* msg){ - PRINT_SEQUENCE("simpleSeq: w2000 inner triggered\n"); - }); - PRINT_SEQUENCE("SEQUENCED: (end) unraveling child closure 2\n"); - }); - - theSeq()->wait(40, [](EmptyMsg* msg){ - auto const& cur_seq_id = theSeq()->getCurrentSeq(); - PRINT_SEQUENCE("simpleSeq: seq={}: w4 triggered\n", cur_seq_id); - }); -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - - //#define SIMPLE_SEQ_MULTI_NODE 1 - //#define SIMPLE_SEQ_PARALLEL 1 - #define SIMPLE_SEQ_FOR 1 - - #if SIMPLE_SEQ_MULTI_NODE - if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - #endif - - #if SIMPLE_SEQ - if (my_node == 0) { - SeqType const& seq_id = theSeq()->nextSeq(); - theSeq()->sequenced(seq_id, simpleSeq); - - theMsg()->sendMsg(0, makeSharedMessage(), 10); - theMsg()->sendMsg(0, makeSharedMessage(), 20); - - theMsg()->sendMsg(0, makeSharedMessage(), 100); - theMsg()->sendMsg(0, makeSharedMessage(), 200); - - theMsg()->sendMsg(0, makeSharedMessage(), 1000); - theMsg()->sendMsg(0, makeSharedMessage(), 2000); - - theMsg()->sendMsg(0, makeSharedMessage(), 10000); - theMsg()->sendMsg(0, makeSharedMessage(), 20000); - } - #endif - - #if SIMPLE_SEQ_MULTI_NODE - if (my_node == 0) { - SeqType const& seq_id = theSeq()->nextSeq(); - theSeq()->sequenced(seq_id, mySeq); - - theMsg()->sendMsg(1, makeSharedMessage(), 30); - theMsg()->sendMsg(1, makeSharedMessage(), 10); - - theMsg()->sendMsg(0, makeSharedMessage(), 30); - theMsg()->sendMsg(0, makeSharedMessage(), 10); - } else if (my_node == 1) { - SeqType const& seq_id2 = theSeq()->nextSeq(); - theSeq()->sequenced(seq_id2, mySeq); - } - #endif - - #if SIMPLE_SEQ_SINGLE_NODE - if (my_node == 0) { - SeqType const& seq_id = theSeq()->nextSeq(); - theSeq()->sequenced(seq_id, mySeqSingleNode); - theMsg()->sendMsg(0, makeSharedMessage(), 30); - theMsg()->sendMsg(0, makeSharedMessage(), 10); - } - #endif - - #if SIMPLE_SEQ_PARALLEL - if (my_node == 0) { - SeqType const& seq_id = theSeq()->nextSeq(); - theSeq()->sequenced(seq_id, mySeqParallel); - theMsg()->sendMsg(0, makeSharedMessage(), 10); - } - #endif - - #if SIMPLE_SEQ_FOR - if (my_node == 0) { - SeqType const& seq_id = theSeq()->nextSeq(); - theSeq()->sequenced(seq_id, mySeqFor); - } else if (my_node == 1) { - for (int i = 0; i < 10; i++) { - theMsg()->sendMsg(0, makeSharedMessage()); - } - } - #endif - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From 3feafde2926907c05444c57ccb974e39c47b94a4 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 18:00:42 -0700 Subject: [PATCH 66/88] #526: example: remove trace_ring --- examples/CMakeLists.txt | 1 - examples/trace_ring.cc | 126 ---------------------------------------- 2 files changed, 127 deletions(-) delete mode 100644 examples/trace_ring.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3c2c436f45..18c5a44f65 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -15,7 +15,6 @@ set( hello_world_functor termination_collective termination_rooted - trace_ring lb_iter hello_world_virtual_context jacobi1d_vt diff --git a/examples/trace_ring.cc b/examples/trace_ring.cc deleted file mode 100644 index 2d038cb210..0000000000 --- a/examples/trace_ring.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// trace_ring.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -using namespace vt; - -static NodeType next_node = uninitialized_destination; -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -static int64_t kernel_weight = 1000; - -static int num_total_rings = 10; -static int num_times = 0; - -struct RingMsg : vt::Message { - NodeType from; - RingMsg(NodeType const& in_from) : Message(), from(in_from) { } -}; - -static void sendToNext(); - -static double kernel(NodeType const& from_node) { - double my_val = 19.234; - for (int i = 0; i < kernel_weight; i++) { - my_val += i - (2.34-1.28882) * from_node; - } - return my_val; -} - -static void ring(RingMsg* msg) { - auto const& ring_from_node = msg->from; - - num_times++; - - double const val = kernel(ring_from_node); - - fmt::print( - "{}: Hello from node {}: num_times={}: kernel val={}\n", - my_node, ring_from_node, num_times, val - ); - - if (ring_from_node != num_nodes-1 or num_times < num_total_rings) { - sendToNext(); - } -} - -static void sendToNext() { - auto msg = vt::makeMessage(my_node); - theMsg()->sendMsg(next_node, msg.get()); -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - next_node = my_node+1 >= num_nodes ? 0 : my_node+1; - - fmt::print("{}: my_node = {} here\n",theContext()->getNode(),my_node); - - if (num_nodes == 1) { - CollectiveOps::output("requires at least 2 nodes"); - CollectiveOps::finalize(); - return 0; - } - - if (argc > 1) { - kernel_weight = atoi(argv[1]); - } - - if (my_node == 0) { - sendToNext(); - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From c3c4e379c3d035c2882bf7e06d450190ddadf9ba Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 18:10:51 -0700 Subject: [PATCH 67/88] #526: example: cleanup transpose --- examples/transpose.cc | 118 +++++++++++++++++++----------------------- 1 file changed, 54 insertions(+), 64 deletions(-) diff --git a/examples/transpose.cc b/examples/transpose.cc index bdd05e9b8d..e5bc94bac9 100644 --- a/examples/transpose.cc +++ b/examples/transpose.cc @@ -42,29 +42,26 @@ //@HEADER */ -#include "vt/transport.h" +#include #include -using namespace vt; - static constexpr int const num_pieces = 4; static constexpr int const num_elem = 1024; static constexpr int const block_size = num_elem / num_pieces; template -struct SolveMsg : CollectionMessage {}; +struct SolveMsg : vt::CollectionMessage {}; template -struct RequestDataMsg : CollectionMessage { - RequestDataMsg() = default; - RequestDataMsg(NodeType in_node) : node_(in_node) { } - NodeType node_; +struct RequestDataMsg : vt::CollectionMessage { + explicit RequestDataMsg(vt::NodeType in_node) : node_(in_node) { } + vt::NodeType node_; }; -struct InitMsg : ::vt::collective::ReduceNoneMsg { }; +struct InitMsg : vt::collective::ReduceNoneMsg { }; -struct DataMsg : ::vt::Message { +struct DataMsg : vt::Message { DataMsg() = default; DataMsg(std::vector const& payload_in, int from_idx_in) @@ -81,19 +78,20 @@ struct DataMsg : ::vt::Message { int from_idx_ = 0; }; -struct SubSolveMsg : ::vt::Message { - SubSolveMsg() = default; - SubSolveMsg(VirtualProxyType in_proxy) +struct SubSolveMsg : vt::Message { + explicit SubSolveMsg(vt::VirtualProxyType in_proxy) : coll_proxy_(in_proxy) { } - VirtualProxyType coll_proxy_ = no_vrt_proxy; + vt::VirtualProxyType coll_proxy_ = vt::no_vrt_proxy; }; struct ProxyMsg : vt::Message { - ProxyMsg() = default; - ProxyMsg(VirtualProxyType in_proxy) : proxy_(in_proxy) { } - VirtualProxyType proxy_ = no_vrt_proxy; + explicit ProxyMsg(vt::VirtualProxyType in_proxy) + : proxy_(in_proxy) + { } + + vt::VirtualProxyType proxy_ = vt::no_vrt_proxy; }; struct SetupGroup { @@ -131,13 +129,13 @@ struct SubSolveInfo { /*static*/ SubSolveInfo solver_info = {}; // The VT collection with blocks of data -struct Block : Collection { +struct Block : vt::Collection { Block() = default; Block(int num_elm, int n_pieces) { - ::fmt::print( + fmt::print( "construct: node={}, elm={}, pieces={}\n", - theContext()->getNode(), num_elm, n_pieces + vt::theContext()->getNode(), num_elm, n_pieces ); } @@ -151,7 +149,7 @@ struct Block : Collection { template void serialize(SerializerT& s) { - Collection::serialize(s); + vt::Collection::serialize(s); s | data_; } @@ -164,19 +162,19 @@ struct Block : Collection { getIndex(), requesting_node ); auto const from_idx = getIndex().x(); - auto data_msg = makeSharedMessage(data_,from_idx); - theMsg()->sendMsgAuto( - requesting_node, data_msg + auto data_msg = vt::makeMessage(data_,from_idx); + vt::theMsg()->sendMsg( + requesting_node, data_msg.get() ); } - void doneInit(InitMsg *msg) { + void doneInit(InitMsg* msg) { if (getIndex().x() == 0) { auto proxy = this->getCollectionProxy(); - auto proxy_msg = ::vt::makeMessage(proxy.getProxy()); - theMsg()->broadcastMsg(proxy_msg.get()); + auto proxy_msg = vt::makeMessage(proxy.getProxy()); + vt::theMsg()->broadcastMsg(proxy_msg.get()); // Invoke it locally: broadcast sends to all other nodes - auto proxy_msg_local = ::vt::makeMessage(proxy.getProxy()); + auto proxy_msg_local = vt::makeMessage(proxy.getProxy()); SetupGroup()(proxy_msg_local.get()); } } @@ -186,8 +184,8 @@ struct Block : Collection { initialize(); // Wait for all initializations to complete auto proxy = this->getCollectionProxy(); - auto cb = theCB()->makeBcast(proxy); - auto empty = makeMessage(); + auto cb = vt::theCB()->makeBcast(proxy); + auto empty = vt::makeMessage(); proxy.reduce(empty.get(), cb); } @@ -197,23 +195,23 @@ struct Block : Collection { //using ActiveMapTypedFnType = NodeType(IndexT*, IndexT*, NodeType); template -::vt::NodeType my_map(IndexT* idx, IndexT* max_idx, NodeType num_nodes) { +vt::NodeType my_map(IndexT* idx, IndexT* max_idx, vt::NodeType num_nodes) { // simple round-robin for 1-d only. return idx->x() % num_nodes; } // group-targeted handler for the sub-solve /*static*/ void SubSolveInfo::subSolveHandler(SubSolveMsg* msg) { - auto const& this_node = theContext()->getNode(); - auto const& num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); - auto const group_id = envelopeGetGroup(msg->env); - MPI_Comm sub_comm = theGroup()->getGroupComm(group_id); + auto const group_id = vt::envelopeGetGroup(msg->env); + MPI_Comm sub_comm = vt::theGroup()->getGroupComm(group_id); int sub_size = 0, sub_rank = 0; MPI_Comm_size(sub_comm, &sub_size); MPI_Comm_rank(sub_comm, &sub_rank); - ::fmt::print( + fmt::print( "subSolveHandler: node={}, num={}, sub_rank={}, sub_size={}\n", this_node, num_nodes, sub_rank, sub_size ); @@ -225,7 +223,7 @@ ::vt::NodeType my_map(IndexT* idx, IndexT* max_idx, NodeType num_nodes) { // Reconstruct the collection proxy type. Note: you can transfer the typed // proxy and skip this step, but then the proxy has to carry the type or be // templated - CollectionProxy proxy(msg->coll_proxy_); + vt::CollectionProxy proxy(msg->coll_proxy_); // Do a simple "blocked" map from collection pieces to node auto const blocks_to_node = num_pieces / sub_size; @@ -258,11 +256,11 @@ ::vt::NodeType my_map(IndexT* idx, IndexT* max_idx, NodeType num_nodes) { solver_info.have_blocks_++; } else { // It's a remote collection block - auto msg2 = makeSharedMessage>(this_node); + auto msg2 = vt::makeMessage>(this_node); // Here we will send "this_node" to indicate which nod it should come back // to. Eventually, I will implement a "sub_rank" in VT which can use the // sub-rank instead of the global node id. - proxy[block_id].send,&Block::dataRequest>(msg2); + proxy[block_id].send,&Block::dataRequest>(msg2.get()); } } @@ -292,34 +290,32 @@ ::vt::NodeType my_map(IndexT* idx, IndexT* max_idx, NodeType num_nodes) { } } -static void solveGroupSetup(NodeType this_node, VirtualProxyType coll_proxy) { +static void solveGroupSetup(vt::NodeType this_node, vt::VirtualProxyType coll_proxy) { auto const& is_even_node = this_node % 2 == 0; - auto const& the_comm = theContext()->getComm(); - (void)the_comm; // don't warn about unused variable - // This is how you would explicitly create/get a new communicator for this // group. Because of the change I made, there is automatically one created for // you, so unless you want to restructure the communicator (reorganize the // ranks), you can use the one that is created automatically by VT. See below: // theGroup()->getGroupComm(...) + // auto const& the_comm = vt::theContext()->getComm(); // MPI_Comm manual_sub_comm; // MPI_Comm_split(the_comm, is_even_node, this_node, &manual_sub_comm); // solver_info.sub_comm = manual_sub_comm; - ::fmt::print( + fmt::print( "solveGroupSetup: node={}, is_even_node={}\n", this_node, is_even_node ); - theGroup()->newGroupCollective( - is_even_node, [=](GroupType group_id){ + vt::theGroup()->newGroupCollective( + is_even_node, [=](vt::GroupType group_id){ fmt::print("Group is created: id={:x}\n", group_id); if (this_node == 1) { - auto msg = makeSharedMessage(coll_proxy); - envelopeSetGroup(msg->env, group_id); - theMsg()->broadcastMsg(msg); + auto msg = vt::makeMessage(coll_proxy); + vt::envelopeSetGroup(msg->env, group_id); + vt::theMsg()->broadcastMsg(msg.get()); } }, true ); @@ -327,31 +323,25 @@ static void solveGroupSetup(NodeType this_node, VirtualProxyType coll_proxy) { } void SetupGroup::operator()(ProxyMsg* msg) { - auto const& this_node = theContext()->getNode(); - ::fmt::print("SetupGroup: node={}\n", this_node); + vt::NodeType this_node = vt::theContext()->getNode(); + fmt::print("SetupGroup: node={}\n", this_node); // Example using the group collective solveGroupSetup(this_node, msg->proxy_); } int main(int argc, char** argv) { - ::vt::CollectiveOps::initialize(argc,argv); + vt::initialize(argc, argv); - auto const& this_node = theContext()->getNode(); + vt::NodeType this_node = vt::theContext()->getNode(); if (this_node == 0) { - auto const& range = Index1D(num_pieces); - auto proxy = theCollection()->construct( - range,num_elem,num_pieces + auto range = vt::Index1D(num_pieces); + auto proxy = vt::theCollection()->construct( + range, num_elem, num_pieces ); - // - auto msg = ::vt::makeSharedMessage>(); - proxy.broadcast, &Block::solve>(msg); - } - - while (!::vt::rt->isTerminated()) { - runScheduler(); + proxy.broadcast, &Block::solve>(); } - ::vt::CollectiveOps::finalize(); + vt::finalize(); return 0; } From e51e8eca6940090cd30667f0fc31340fad17f258 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Wed, 22 Apr 2020 18:11:03 -0700 Subject: [PATCH 68/88] #526: example: remove extremely old example vt_mpi --- examples/vt_mpi.cc | 179 --------------------------------------------- 1 file changed, 179 deletions(-) delete mode 100644 examples/vt_mpi.cc diff --git a/examples/vt_mpi.cc b/examples/vt_mpi.cc deleted file mode 100644 index d7f066d26b..0000000000 --- a/examples/vt_mpi.cc +++ /dev/null @@ -1,179 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// vt_mpi.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" - -#include -#include - -using namespace vt; - -NodeType this_node = -1; -NodeType num_nodes = -1; -HandlerType test_msg_han = 0; -HandlerType test_msg_han2 = 0; -EpochType test_epoch = -1; - -struct TestMsg : vt::Message { - int val; - int val2; - EventType event; - - TestMsg(int const& in_val, int const& in_val2, EventType const& in_event) - : val(in_val), val2(in_val2), event(in_event) - { } -}; - -void handle_test_msg(vt::Message* in_msg) { -} - -void send_to_neighbor() { - auto msg = makeSharedMessage(this_node, num_nodes, -1); - - int const next = this_node+1 < num_nodes ? this_node+1 : 0; - - //theMsg()->set_epoch_message(msg, test_epoch); - - EventType evt = theMsg()->sendMsg(next, test_msg_han, msg, [=]{ - //std::cout << "deleting msg" << std::endl; - delete msg; - }); - - auto msg2 = makeSharedMessage(this_node, num_nodes, evt); - - EventType evt2 = theMsg()->sendMsg(next, test_msg_han2, msg2, [=]{ - //std::cout << "deleting msg" << std::endl; - delete msg2; - }); - - auto const& own_node = theEvent()->get_owning_node(evt); - - fmt::print( - "this_node={}, event_id={}, own_node={}\n", - this_node, evt, own_node - ); - - // std::cout << "this_node=" << this_node << ", " - // << "event_id=" << evt << ", " - // << "own_node=" << own_node - // << std::endl; -} - -int main(int argc, char** argv) { - CollectiveOps::initialize_context(argc, argv); - CollectiveOps::initialize_runtime(); - - this_node = theContext()->getNode(); - num_nodes = theContext()->get_num_nodes(); - - std::cout << "this_node=" << this_node << std::endl; - - fmt::print("sizeof(Envelope)={}\n", sizeof(Envelope)); - fmt::print("sizeof(EpochEnvelope)={}\n", sizeof(EpochEnvelope)); - fmt::print("sizeof(EpochTagEnvelope)={}\n", sizeof(EpochTagEnvelope)); - - fmt::print("{}: calling wait_unnamed_barrier\n", this_node); - theCollective()->barrier(); - fmt::print("{}: out of wait_unnamed_barrier\n", this_node); - - fmt::print("{}: calling cont_unnamed_barrier\n", this_node); - theCollective()->barrier_then([=]{ - fmt::print("{}: out of cont_unnamed_barrier\n", this_node); - }); - - //test_msg_han = theMsg()->collective_register_handler(handle_test_msg); - - // test_epoch = theTerm()->new_epoch(); - // theTerm()->attach_epoch_term_action(test_epoch, [=]{ - // fmt::print( - // "{}: EPOCH: finished: test_epoch={}\n", - // theContext()->getNode(), test_epoch - // ); - // }); - - test_msg_han = theMsg()->collective_register_handler([](vt::BaseMessage* in_msg){ - TestMsg& msg = *static_cast(in_msg); - - fmt::print( - "this_node={}, from_node={}, num_nodes={}\n", - this_node, msg.val, msg.val2 - ); - - if (this_node != 0) { - send_to_neighbor(); - } - }); - - test_msg_han2 = theMsg()->collective_register_handler([](vt::BaseMessage* in_msg){ - TestMsg& msg = *static_cast(in_msg); - - fmt::print( - "this_node={}, evt={}, owner={}\n", - this_node, msg.event, theEvent()->get_owning_node(msg.event) - ); - - theEvent()->attach_action(msg.event, [=]{ - fmt::print("triggering remote event\n"); - }); - }); - - if (this_node == 0) { - send_to_neighbor(); - - auto msg = makeSharedMessage(this_node, num_nodes, -1); - - // theMsg()->broadcast_msg(test_msg_han, msg, [=]{ - // //std::cout << "deleting msg" << std::endl; - // delete msg; - // }); - } - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From 9cdbfa25ecb2af3cd0f59f0970838eebe074c3a9 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 09:52:28 -0700 Subject: [PATCH 69/88] #526: example: use new style message in callback.cc --- examples/callback.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/callback.cc b/examples/callback.cc index b0e79c7a54..d717a7d1b1 100644 --- a/examples/callback.cc +++ b/examples/callback.cc @@ -80,8 +80,8 @@ struct HelloMsg : vt::Message { void hello_world(HelloMsg* msg) { static int val = 1; fmt::print("{}: Sending callback\n", vt::theContext()->getNode()); - auto to_send = vt::makeSharedMessage(292 + val++, "test string"); - msg->cb_.send(to_send); + auto to_send = vt::makeMessage(292 + val++, "test string"); + msg->cb_.send(to_send.get()); } void printOutput(TestMsg* msg, std::string type) { From 0be28c5dbfca9fe7fdf3b5e2fa68900b7aa2d28a Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 10:58:22 -0700 Subject: [PATCH 70/88] #526: example: remove rdma_channel_sync.cc --- examples/rdma_channel_sync.cc | 184 ---------------------------------- 1 file changed, 184 deletions(-) delete mode 100644 examples/rdma_channel_sync.cc diff --git a/examples/rdma_channel_sync.cc b/examples/rdma_channel_sync.cc deleted file mode 100644 index 37326fadc6..0000000000 --- a/examples/rdma_channel_sync.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// rdma_channel_sync.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -static RDMA_HandleType my_handle_1 = no_rdma_handle; - -static int const put_len = 2; -#if backend_check_enabled(mpi_rdma) -static int const my_data_len = 8; -#endif -static double* my_data = nullptr; - -static bool use_paired_sync = true; - -struct TestMsg : vt::Message { - RDMA_HandleType han; - TestMsg(RDMA_HandleType const& in_han) : Message(), han(in_han) { } -}; - -static void put_channel_setup(TestMsg* msg); - -static void read_data_fn(TestMsg* msg) { - fmt::print("{}: read_data_fn: handle={}\n", my_node, msg->han); - - if (my_node == 0) { - theRDMA()->syncLocalPutChannel(msg->han, 1, [=]{ - for (auto i = 0; i < put_len*2; i++) { - fmt::print("{}: han={} \t: my_data[{}] = {}\n", my_node, msg->han, i, my_data[i]); - } - - theRDMA()->newGetChannel(my_handle_1, 0, 2, [=]{ - TestMsg* msg1 = makeSharedMessage(my_handle_1); - theMsg()->sendMsg(2, msg1); - }); - }); - } else if (my_node == 2) { - theRDMA()->syncLocalGetChannel(msg->han, [=]{ - for (auto i = 0; i < put_len*2; i++) { - fmt::print("{}: han={} \t: my_data[{}] = {}\n", my_node, msg->han, i, my_data[i]); - } - }); - } -} - -static void put_channel_setup(TestMsg* msg) { - auto const& handle = msg->han; - - fmt::print("{}: put_channel_setup: handle={}\n", my_node, msg->han); - - if (my_node == 1) { - theRDMA()->newPutChannel(handle, 0, 1, [=]{ - int const num_elm = 2; - - if (use_paired_sync) { - theRDMA()->putTypedData(handle, my_data, num_elm, no_byte, [=]{ - TestMsg* back = makeSharedMessage(handle); - theMsg()->sendMsg(0, back); - }); - } else { - theRDMA()->putTypedData(handle, my_data, num_elm); - theRDMA()->syncRemotePutChannel(handle, [=]{ - TestMsg* back = makeSharedMessage(handle); - theMsg()->sendMsg(0, back); - }); - } - }); - } - else if (my_node == 2) { - theRDMA()->newGetChannel(handle, 0, 2, [=]{ - fmt::print( - "{}: creating get channel complete\n", my_node - ); - int const num_elm = 2; - - if (use_paired_sync) { - theRDMA()->getTypedDataInfoBuf(handle, my_data, num_elm, [=]{ - TestMsg* back = makeSharedMessage(handle); - theMsg()->sendMsg(2, back); - }); - } else { - theRDMA()->getTypedDataInfoBuf(handle, my_data, num_elm); - // theRDMA()->get_typed_data_info_buf(handle, my_data+2, num_elm); - theRDMA()->syncLocalGetChannel(handle, [=]{ - TestMsg* back = makeSharedMessage(handle); - theMsg()->sendMsg(2, back); - }); - } - }); - } -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - - if (num_nodes != 4) { - fmt::print("requires exactly 4 nodes\n"); - CollectiveOps::finalize(); - return 0; - } - -#if backend_check_enabled(mpi_rdma) - my_data = new double[my_data_len]; - - if (my_node < 3) { - // initialize my_data buffer, all but node 0 get -1.0 - for (auto i = 0; i < 4; i++) { - my_data[i] = my_node != 0 ? (my_node+1)*i+1 : -1.0; - fmt::print("{}: \t: my_data[{}] = {}\n", my_node, i, my_data[i]); - } - } - - if (my_node == 0) { - my_handle_1 = theRDMA()->registerNewTypedRdmaHandler(my_data, put_len); - - fmt::print( - "{}: initializing my_handle_1={}\n", my_node, my_handle_1 - ); - - theRDMA()->newPutChannel(my_handle_1, 0, 1, [=]{ - TestMsg* msg1 = makeSharedMessage(my_handle_1); - theMsg()->sendMsg(1, msg1); - }); - } -#endif - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From a891bda0363da4de6d8e4724e84dbc4531214b90 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 10:58:31 -0700 Subject: [PATCH 71/88] #526: example: remove rdma_simple_channel.cc --- examples/rdma_simple_channel.cc | 132 -------------------------------- 1 file changed, 132 deletions(-) delete mode 100644 examples/rdma_simple_channel.cc diff --git a/examples/rdma_simple_channel.cc b/examples/rdma_simple_channel.cc deleted file mode 100644 index 33ef91fd6e..0000000000 --- a/examples/rdma_simple_channel.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// rdma_simple_channel.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -#if backend_check_enabled(mpi_rdma) -static RDMA_HandleType my_handle_1 = no_rdma_handle; -#endif - -static int const put_len = 2; -#if backend_check_enabled(mpi_rdma) -static int const my_data_len = 8; -#endif -static double* my_data = nullptr; - -struct TestMsg : vt::Message { - RDMA_HandleType han; - TestMsg(RDMA_HandleType const& in_han) : Message(), han(in_han) { } -}; - -static void read_data_fn(TestMsg* msg) { - fmt::print("{}: read_data_fn: handle={}\n", my_node, msg->han); - - for (auto i = 0; i < put_len*2; i++) { - fmt::print("{}: han={} \t: my_data[{}] = {}\n", my_node, msg->han, i, my_data[i]); - } -} - -#pragma GCC diagnostic ignored "-Wunused-function" -static void put_channel_setup(TestMsg* msg) { - auto const& handle = msg->han; - - fmt::print("{}: put_channel_setup: handle={}\n", my_node, msg->han); - - if (my_node == 1) { - int const num_elm = 2; - theRDMA()->putTypedData( - handle, my_data, num_elm, no_byte, no_tag, - [=]{ - TestMsg* back = makeSharedMessage(handle); - theMsg()->sendMsg(0, back); - } - ); - } -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - -#if backend_check_enabled(mpi_rdma) - my_data = new double[my_data_len]; - - if (my_node < 2) { - // initialize my_data buffer, all but node 0 get -1.0 - for (auto i = 0; i < 4; i++) { - my_data[i] = my_node != 0 ? (my_node+1)*i+1 : -1.0; - fmt::print("{}: \t: my_data[{}] = {}\n", my_node, i, my_data[i]); - } - } - - if (my_node == 0) { - my_handle_1 = theRDMA()->registerNewTypedRdmaHandler(my_data, put_len); - - fmt::print( - "{}: initializing my_handle_1={}\n", my_node, my_handle_1 - ); - - theRDMA()->newPutChannel(my_handle_1, 0, 1, [=]{ - TestMsg* msg1 = makeSharedMessage(my_handle_1); - theMsg()->sendMsg(1, msg1); - }); - } -#endif - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From f475f540f9dcdd430c327be15060f367e3345aae Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 10:58:41 -0700 Subject: [PATCH 72/88] #526: example: remove rdma_collective.cc --- examples/rdma_collective.cc | 138 ------------------------------------ 1 file changed, 138 deletions(-) delete mode 100644 examples/rdma_collective.cc diff --git a/examples/rdma_collective.cc b/examples/rdma_collective.cc deleted file mode 100644 index 9b869c7886..0000000000 --- a/examples/rdma_collective.cc +++ /dev/null @@ -1,138 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// rdma_collective.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" -#include - -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -static RDMA_HandleType my_handle = no_rdma_handle; - -#if backend_check_enabled(mpi_rdma) -static int const my_data_len = 8; -static double* my_data = nullptr; -#endif -static int const local_data_len = 24; -static double* local_data = nullptr; - -struct TestMsg : vt::Message { - RDMA_HandleType han; - - TestMsg(RDMA_HandleType const& in_han) : Message(), han(in_han) { } -}; - -#pragma GCC diagnostic ignored "-Wunused-function" -static void announce(TestMsg* msg) { - auto const& rdma_handle = msg->han; - - fmt::print("{}: handle={}, requesting data\n", my_node, rdma_handle); - - if (my_node == 1) { - theRDMA()->newGetChannel(my_handle, 2, 1, [=]{ - fmt::print("set up channel with 2\n"); - - theRDMA()->getTypedDataInfoBuf(rdma_handle, local_data, local_data_len, 5, no_tag, [=]{ - fmt::print("{}: handle={}, finished getting data\n", my_node, rdma_handle); - for (int i = 0; i < local_data_len; i++) { - fmt::print("{}: \t local_data[{}] = {}\n", my_node, i, local_data[i]); - vtAssertExpr(local_data[i] == 5.0+i); - } - }); - }); - } -} - -int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - - if (num_nodes < 4) { - fmt::print("requires exactly 4 nodes\n"); - CollectiveOps::finalize(); - return 0; - } - -#if backend_check_enabled(mpi_rdma) - my_data = new double[my_data_len]; - local_data = new double[local_data_len]; - - // initialize my_data buffer, all but node 0 get -1.0 - for (auto i = 0; i < my_data_len; i++) { - my_data[i] = (my_node)*my_data_len + i; - } - - for (auto i = 0; i < local_data_len; i++) { - local_data[i] = 0.0; - } - - my_handle = theRDMA()->registerCollectiveTyped( - my_data, my_data_len, my_data_len*num_nodes - ); - - theCollective()->barrier(); - - fmt::print("{}: handle={}, create handle\n", my_node, my_handle); - - if (my_node == 0) { - theRDMA()->newGetChannel(my_handle, 0, 1, [=]{ - TestMsg* msg = makeSharedMessage(my_node); - msg->han = my_handle; - theMsg()->broadcastMsg(msg); - }); - } -#endif - - while (!rt->isTerminated()) { - runScheduler(); - } - - CollectiveOps::finalize(); - - return 0; -} From 0a4c14bb086831ba981b2a46048d11241fb5331c Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 10:58:53 -0700 Subject: [PATCH 73/88] #526: example: remove from cmake --- examples/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 18c5a44f65..3e88509a2b 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -7,9 +7,6 @@ set( rdma_simple_get_direct rdma_simple_put rdma_simple_put_direct - rdma_simple_channel - rdma_channel_sync - rdma_collective callback_context param hello_world_functor From 5808598d8419a719e2ef8f2b1a675d8ffbc71ae6 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 11:00:59 -0700 Subject: [PATCH 74/88] #526: example: remove rdma_unsized_collection.cc --- examples/CMakeLists.txt | 1 - examples/rdma_unsized_collection.cc | 216 ---------------------------- 2 files changed, 217 deletions(-) delete mode 100644 examples/rdma_unsized_collection.cc diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 3e88509a2b..10a7e72244 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -23,7 +23,6 @@ set( hello_world_collection_staged_insert hello_world_collection_reduce insertable_collection - rdma_unsized_collection group_rooted group_collective reduce_integral diff --git a/examples/rdma_unsized_collection.cc b/examples/rdma_unsized_collection.cc deleted file mode 100644 index 476e4f3bfc..0000000000 --- a/examples/rdma_unsized_collection.cc +++ /dev/null @@ -1,216 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// rdma_unsized_collection.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 "vt/transport.h" - -#include -#include - -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -static RDMA_HandleType my_handle = no_rdma_handle; -static int const num_elms = 10; - -struct Msg : ::vt::Message { - int state = -100; -}; - -using RDMAMsgType = Msg; - -static RDMAMsgType* rdma_state = nullptr; -static constexpr RDMA_ElmType const rdma_num_elements = 10; -static std::unordered_map rdma_data; - -static void doGetHandler(Msg* m) { - using namespace vt::rdma; - - RDMACollectionManager::getElement(my_handle, 1, [](void* data, size_t num_bytes){ - double* const ptr = static_cast(data); - size_t const num_elems = num_bytes / sizeof(double); - fmt::print( - "{}: data arrived: data={}, num_bytes={}\n", - my_node, print_ptr(data), num_bytes - ); - for (size_t i = 0; i < num_elems; i++) { - fmt::print("\t: my_data[{}] = {}\n", i, ptr[i]); - } - }); -} - -static void initData(ByteType const& offset, double* const data_ptr) { - for (RDMA_ElmType i = 0; i < rdma_num_elements; i++) { - data_ptr[i] = i * 1.0 * (offset + 1); - } -} - -std::vector ptrs; - -static RDMA_PtrType obtain_data_ptr( - RDMA_ElmType const& elm, - RDMA_PtrType const& in_ptr = nullptr, - bool const& initDemand = true -) { - auto iter = rdma_data.find(elm); - if (iter == rdma_data.end()) { - double* new_ptr = nullptr; - if (initDemand) { - new_ptr = new double[rdma_num_elements]; - ptrs.push_back(new_ptr); - if (in_ptr) { - //std::memcpy(new_ptr, in_ptr, rdma_num_elements * sizeof(double)); - } else { - initData(elm, new_ptr); - } - } else if (in_ptr != nullptr) { - new_ptr = reinterpret_cast(in_ptr); - } - if (new_ptr) { - rdma_data.emplace( - std::piecewise_construct, - std::forward_as_tuple(elm), - std::forward_as_tuple(new_ptr) - ); - iter = rdma_data.find(elm); - } else { - return nullptr; - } - } - - if (in_ptr) { - std::memcpy(iter->second, in_ptr, rdma_num_elements * sizeof(double)); - } - return iter->second; -} - -static RDMA_GetType get_fn( - RDMAMsgType* msg, ByteType num_bytes, ByteType offset, TagType tag, bool -) { - fmt::print( - "{}: running get_fn: msg={}, num_bytes={}, offset={}, tag={}, state={}\n", - my_node, print_ptr(msg), num_bytes, offset, tag, msg->state - ); - - auto const& ret_ptr = obtain_data_ptr(offset); - - return RDMA_GetType{ret_ptr, sizeof(double)*rdma_num_elements}; -} - -static void put_fn( - RDMAMsgType* msg, RDMA_PtrType ptr, ByteType num_bytes, ByteType offset, - TagType tag, bool -) { - fmt::print( - "{}: put_fn: ptr={}, num_bytes={}, tag={}, offset={}\n", - my_node, print_ptr(ptr), num_bytes, tag, offset - ); - - obtain_data_ptr(offset, ptr, true); -} - -static RDMA_PutRetType serialize_put_fn(RDMA_PutRetType put_in) { - fmt::print( - "{}: serialize_put_fn: ptr={}, num_bytes={}\n", - my_node, print_ptr(std::get<0>(put_in)), std::get<1>(put_in) - ); - - return RDMA_PutRetType{std::get<0>(put_in), rdma_num_elements*sizeof(double)}; -} - -int main(int argc, char** argv) { - using namespace ::vt::rdma; - - CollectiveOps::initialize(argc, argv); - - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); - - if (num_nodes < 4) { - fmt::print("requires exactly 4 nodes\n"); - CollectiveOps::finalize(); - return 0; - } - - rdma_state = new RDMAMsgType(); - - my_handle = RDMACollectionManager::registerUnsizedCollection(num_elms); - theRDMA()->associateGetFunction( - rdma_state, my_handle, get_fn, true - ); - theRDMA()->associatePutFunction( - rdma_state, my_handle, put_fn, true - ); - - theCollective()->barrier(); - - double* test_data = new double[rdma_num_elements]; - if (my_node == 0) { - initData(10, test_data); - // this message that causes a `get' races with the following `put' - theMsg()->sendMsg(3, makeSharedMessage()); - RDMACollectionManager::putElement( - my_handle, 1, test_data, serialize_put_fn, []{ - fmt::print("{}: put finished\n", my_node); - theMsg()->sendMsg(1, makeSharedMessage()); - } - ); - } - - fmt::print("{}: handle={}, create handle\n", my_node, my_handle); - - while (!rt->isTerminated()) { - runScheduler(); - } - - delete [] test_data; - for (auto&& elm : ptrs) { - delete [] elm; - } - - CollectiveOps::finalize(); - - return 0; -} From dd02283b294720aa03f72ec8d270e7a89d15ed29 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 11:02:33 -0700 Subject: [PATCH 75/88] #526: example: rewrite rdma_simple_get --- examples/rdma_simple_get.cc | 77 +++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/examples/rdma_simple_get.cc b/examples/rdma_simple_get.cc index d39b712d70..2111d9ac3a 100644 --- a/examples/rdma_simple_get.cc +++ b/examples/rdma_simple_get.cc @@ -42,34 +42,30 @@ //@HEADER */ -#include "vt/transport.h" -#include +#include -using namespace vt; +#include -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -static RDMA_HandleType my_handle = no_rdma_handle; - -struct TestMsg : vt::Message { - RDMA_HandleType han; - TestMsg(RDMA_HandleType const& in_han) : Message(), han(in_han) { } +struct HandleMsg : vt::Message { + vt::RDMA_HandleType han; + explicit HandleMsg(vt::RDMA_HandleType const& in_han) : han(in_han) { } }; -static void tell_handle(TestMsg* msg) { - fmt::print("{}: handle={}\n", my_node, msg->han); +static void tell_handle(HandleMsg* msg) { + vt::NodeType this_node = vt::theContext()->getNode(); + + fmt::print("{}: handle={}\n", this_node, msg->han); - if (my_node == 1 || my_node == 2) { - fmt::print("{}: requesting data\n", my_node); - theRDMA()->getData( - msg->han, my_node, sizeof(double)*3, no_byte, - [](void* data, size_t num_bytes){ + if (this_node == 1 || this_node == 2) { + fmt::print("{}: requesting data\n", this_node); + vt::theRDMA()->getData( + msg->han, this_node, sizeof(double)*3, vt::no_byte, + [=](void* data, size_t num_bytes){ double* const ptr = static_cast(data); size_t const num_elems = num_bytes / sizeof(double); fmt::print( "{}: data arrived: data={}, num_bytes={}\n", - my_node, print_ptr(data), num_bytes + this_node, print_ptr(data), num_bytes ); for (size_t i = 0; i < num_elems; i++) { fmt::print("\t: my_data[{}] = {}\n", i, ptr[i]); @@ -79,51 +75,48 @@ static void tell_handle(TestMsg* msg) { } } -static double* my_data = nullptr; -static TestMsg* test_msg = nullptr; +static std::unique_ptr my_data = nullptr; -static RDMA_GetType -test_get_fn(TestMsg* msg, ByteType num_bytes, ByteType offset, TagType tag, bool) { +static vt::RDMA_GetType test_get_fn( + vt::BaseMessage*, vt::ByteType num_bytes, vt::ByteType offset, vt::TagType tag, + bool +) { + vt::NodeType this_node = vt::theContext()->getNode(); fmt::print( - "{}: running test_get_fn: msg={}, num_bytes={}, tag={}\n", - my_node, print_ptr(msg), num_bytes, tag + "{}: running test_get_fn: num_bytes={}, tag={}\n", + this_node, num_bytes, tag ); - return RDMA_GetType{ - my_data+tag, num_bytes == no_byte ? sizeof(double)*10 : num_bytes + return vt::RDMA_GetType{ + &my_data[0] + tag, num_bytes == vt::no_byte ? sizeof(double)*10 : num_bytes }; } int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); - if (my_node == 0) { + if (this_node == 0) { auto const len = 64; - my_data = new double[len]; + my_data = std::make_unique(len); for (auto i = 0; i < len; i++) { my_data[i] = i+1; } - my_handle = theRDMA()->registerNewRdmaHandler(); - theRDMA()->associateGetFunction( - test_msg, my_handle, test_get_fn, true + vt::RDMA_HandleType my_handle = vt::theRDMA()->registerNewRdmaHandler(); + vt::theRDMA()->associateGetFunction( + nullptr, my_handle, test_get_fn, true ); fmt::print("initializing my_handle={}\n", my_handle); - auto msg = makeSharedMessage(my_node); + auto msg = vt::makeMessage(this_node); msg->han = my_handle; - theMsg()->broadcastMsg(msg); - } - - while (!rt->isTerminated()) { - runScheduler(); + vt::theMsg()->broadcastMsg(msg.get()); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From d9672031026202915852f86777ec32950454c02f Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 11:02:38 -0700 Subject: [PATCH 76/88] #526: example: rewrite rdma_simple_put --- examples/rdma_simple_put.cc | 99 ++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 52 deletions(-) diff --git a/examples/rdma_simple_put.cc b/examples/rdma_simple_put.cc index f00dcdef03..f52e82d033 100644 --- a/examples/rdma_simple_put.cc +++ b/examples/rdma_simple_put.cc @@ -42,27 +42,23 @@ //@HEADER */ -#include "vt/transport.h" -#include +#include -using namespace vt; +#include -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -static RDMA_HandleType my_handle = no_rdma_handle; - -struct TestMsg : vt::Message { - RDMA_HandleType han; - TestMsg(RDMA_HandleType const& in_han) : Message(), han(in_han) { } +struct HandleMsg : vt::Message { + vt::RDMA_HandleType han; + explicit HandleMsg(vt::RDMA_HandleType const& in_han) : han(in_han) { } }; -static double* my_data = nullptr; +static std::unique_ptr my_data = nullptr; + +static void read_data_fn(HandleMsg* msg) { + vt::NodeType this_node = vt::theContext()->getNode(); -static void read_data_fn(TestMsg* msg) { - fmt::print("{}: read_data_fn: handle={}\n", my_node, msg->han); + fmt::print("{}: read_data_fn: handle={}\n", this_node, msg->han); - if (my_node == 0) { + if (this_node == 0) { int const len = 10; for (auto i = 0; i < len; i++) { fmt::print("\t: my_data[{}] = {}\n", i, my_data[i]); @@ -70,90 +66,89 @@ static void read_data_fn(TestMsg* msg) { } } -static void put_data_fn(TestMsg* msg) { - fmt::print("{}: put_data_fn: handle={}\n", my_node, msg->han); +static void put_data_fn(HandleMsg* msg) { + vt::NodeType this_node = vt::theContext()->getNode(); + vt::RDMA_HandleType handle = msg->han; - if (my_node < 4) { - fmt::print("{}: putting data\n", my_node); + fmt::print("{}: put_data_fn: handle={}\n", this_node, handle); + + if (this_node < 4) { + fmt::print("{}: putting data\n", this_node); int const local_data_len = 3; double* local_data = new double[local_data_len]; for (auto i = 0; i < local_data_len; i++) { - local_data[i] = (i+1)*1000*(my_node+1); + local_data[i] = (i+1)*1000*(this_node+1); } - theRDMA()->putData( - msg->han, local_data, sizeof(double)*local_data_len, - (my_node-1)*local_data_len, no_tag, vt::rdma::rdma_default_byte_size, + + vt::theRDMA()->putData( + handle, local_data, sizeof(double)*local_data_len, + (this_node-1)*local_data_len, vt::no_tag, vt::rdma::rdma_default_byte_size, [=]{ delete [] local_data; - fmt::print("{}: after put: sending msg back to 0\n", my_node); - auto msg2 = makeSharedMessage(my_node); - msg2->han = my_handle; - theMsg()->sendMsg(0, msg2); + fmt::print("{}: after put: sending msg back to 0\n", this_node); + auto msg2 = vt::makeMessage(this_node); + msg2->han = handle; + vt::theMsg()->sendMsg(0, msg2.get()); } ); } } static void put_handler_fn( - BaseMessage* msg, RDMA_PtrType in_ptr, ByteType in_num_bytes, ByteType offset, - TagType tag, bool + vt::BaseMessage*, vt::RDMA_PtrType in_ptr, vt::ByteType in_num_bytes, + vt::ByteType offset, vt::TagType tag, bool ) { + vt::NodeType this_node = vt::theContext()->getNode(); + fmt::print( "{}: put_handler_fn: my_data={}, in_ptr={}, in_num_bytes={}, tag={}, " "offset={}\n", - my_node, print_ptr(my_data), print_ptr(in_ptr), in_num_bytes, tag, offset + this_node, print_ptr(&my_data[0]), print_ptr(in_ptr), in_num_bytes, tag, + offset ); auto count = in_num_bytes/sizeof(double); for (decltype(count) i = 0; i < count; i++) { ::fmt::print( "{}: put_handler_fn: data[{}] = {}\n", - my_node, i, static_cast(in_ptr)[i] + this_node, i, static_cast(in_ptr)[i] ); } - std::memcpy(my_data + offset, in_ptr, in_num_bytes); + std::memcpy(&my_data[0] + offset, in_ptr, in_num_bytes); } - int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes != 4) { - fmt::print("requires exactly 4 nodes\n"); - CollectiveOps::finalize(); - return 0; + return vt::rerror("requires exactly 4 nodes"); } - if (my_node == 0) { + if (this_node == 0) { auto const len = 64; - my_data = new double[len]; + my_data = std::make_unique(len); for (auto i = 0; i < len; i++) { my_data[i] = i+1; } - //my_handle = theRDMA()->register_new_typed_rdma_handler(my_data, 10); - my_handle = theRDMA()->registerNewRdmaHandler(); - theRDMA()->associatePutFunction( + vt::RDMA_HandleType my_handle = vt::theRDMA()->registerNewRdmaHandler(); + vt::theRDMA()->associatePutFunction( nullptr, my_handle, put_handler_fn, false ); - fmt::print("{}: initializing my_handle={}\n", my_node, my_handle); + fmt::print("{}: initializing my_handle={}\n", this_node, my_handle); - auto msg = makeSharedMessage(my_node); + auto msg = vt::makeMessage(this_node); msg->han = my_handle; - theMsg()->broadcastMsg(msg); - } - - while (!rt->isTerminated()) { - runScheduler(); + vt::theMsg()->broadcastMsg(msg.get()); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From 965d24c157cb983bd53ec62406eee2b047aa73b6 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 11:02:43 -0700 Subject: [PATCH 77/88] #526: example: rewrite rdma_simple_put_direct --- examples/rdma_simple_put_direct.cc | 81 ++++++++++++++---------------- 1 file changed, 37 insertions(+), 44 deletions(-) diff --git a/examples/rdma_simple_put_direct.cc b/examples/rdma_simple_put_direct.cc index df4211c520..ecb9cfdfba 100644 --- a/examples/rdma_simple_put_direct.cc +++ b/examples/rdma_simple_put_direct.cc @@ -42,94 +42,87 @@ //@HEADER */ -#include "vt/transport.h" -#include +#include -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -static RDMA_HandleType my_handle_1 = no_rdma_handle; +#include static int const put_len = 2; static int const my_data_len = 8; -static double* my_data = nullptr; +static std::unique_ptr my_data = nullptr; -struct TestMsg : vt::Message { - RDMA_HandleType han; - TestMsg(RDMA_HandleType const& in_han) : Message(), han(in_han) { } +struct HandleMsg : vt::Message { + vt::RDMA_HandleType han; + explicit HandleMsg(vt::RDMA_HandleType const& in_han) : han(in_han) { } }; -static void readDataFn(TestMsg* msg) { - fmt::print("{}: readDataFn: handle={}\n", my_node, msg->han); +static void readDataFn(HandleMsg* msg) { + vt::NodeType this_node = vt::theContext()->getNode(); + + fmt::print("{}: readDataFn: handle={}\n", this_node, msg->han); for (auto i = 0; i < put_len*2; i++) { fmt::print( - "{}: han={} \t: my_data[{}] = {}\n", my_node, msg->han, i, my_data[i] + "{}: han={} \t: my_data[{}] = {}\n", this_node, msg->han, i, my_data[i] ); } } -static void putDataFn(TestMsg* msg) { - if (my_node == 1 or my_node == 2) { +static void putDataFn(HandleMsg* msg) { + vt::NodeType this_node = vt::theContext()->getNode(); + + if (this_node == 1 or this_node == 2) { fmt::print( "{}: putting data, handle={}, my_data={}\n", - my_node, msg->han, print_ptr(my_data) + this_node, msg->han, print_ptr(&my_data[0]) ); int const num_elm = 2; - int const offset = num_elm*(my_node-1); + int const offset = num_elm*(this_node-1); auto han = msg->han; - theRDMA()->putTypedData(msg->han, my_data, num_elm, offset, [=]{ + vt::theRDMA()->putTypedData(msg->han, &my_data[0], num_elm, offset, [=]{ fmt::print( - "{}: after put: sending msg back to 0: offset={}\n", my_node, offset + "{}: after put: sending msg back to 0: offset={}\n", this_node, offset ); - auto back = makeMessage(han); - theMsg()->sendMsg(0, back.get()); + auto back = vt::makeMessage(han); + vt::theMsg()->sendMsg(0, back.get()); }); } } int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); + vt::NodeType num_nodes = vt::theContext()->getNumNodes(); if (num_nodes < 4) { - fmt::print("requires exactly 4 nodes\n"); - CollectiveOps::finalize(); - return 0; + return vt::rerror("requires exactly 4 nodes"); } - my_data = new double[my_data_len]; + my_data = std::make_unique(my_data_len); // initialize my_data buffer, all but node 0 get -1.0 for (auto i = 0; i < my_data_len; i++) { - my_data[i] = my_node != 0 ? (my_node+1)*i+1 : -1.0; + my_data[i] = this_node != 0 ? (this_node+1)*i+1 : -1.0; } - if (my_node == 0) { - my_handle_1 = theRDMA()->registerNewTypedRdmaHandler(my_data, put_len); + if (this_node == 0) { + vt::RDMA_HandleType my_handle = + vt::theRDMA()->registerNewTypedRdmaHandler(&my_data[0], put_len); fmt::print( - "{}: initializing my_handle_1={}\n", - my_node, my_handle_1 + "{}: initializing my_handle={}\n", + this_node, my_handle ); - auto msg1 = makeMessage(my_handle_1); - auto msg2 = makeMessage(my_handle_1); - theMsg()->sendMsg(1, msg1.get()); - theMsg()->sendMsg(2, msg2.get()); - } - - while (!rt->isTerminated()) { - runScheduler(); + auto msg1 = vt::makeMessage(my_handle); + auto msg2 = vt::makeMessage(my_handle); + vt::theMsg()->sendMsg(1, msg1.get()); + vt::theMsg()->sendMsg(2, msg2.get()); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From 31cd9bf87af074aa175e1dcd0c0246d47258f64b Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 11:02:49 -0700 Subject: [PATCH 78/88] #526: example: rewrite rdma_simple_get_direct --- examples/rdma_simple_get_direct.cc | 60 ++++++++++++++---------------- 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/examples/rdma_simple_get_direct.cc b/examples/rdma_simple_get_direct.cc index bf32967082..1a4a5aaa5d 100644 --- a/examples/rdma_simple_get_direct.cc +++ b/examples/rdma_simple_get_direct.cc @@ -42,62 +42,56 @@ //@HEADER */ -#include "vt/transport.h" -#include +#include -using namespace vt; - -static NodeType my_node = uninitialized_destination; -static NodeType num_nodes = uninitialized_destination; - -static RDMA_HandleType my_handle = no_rdma_handle; +#include static int const my_data_len = 8; -static double* my_data = nullptr; +static std::unique_ptr my_data = nullptr; -struct TestMsg : vt::Message { - RDMA_HandleType han; - TestMsg(RDMA_HandleType const& in_han) : Message(), han(in_han) { } +struct HandleMsg : vt::Message { + vt::RDMA_HandleType han; + HandleMsg(vt::RDMA_HandleType const& in_han) : han(in_han) { } }; -static void tellHandle(TestMsg* msg) { - if (my_node != 0) { - fmt::print("{}: handle={}, requesting data\n", my_node, msg->han); +static void tellHandle(HandleMsg* msg) { + vt::NodeType this_node = vt::theContext()->getNode(); + + if (this_node != 0) { + fmt::print("{}: handle={}, requesting data\n", this_node, msg->han); int const num_elm = 2; - theRDMA()->getTypedDataInfoBuf(msg->han, my_data, num_elm, no_byte, no_tag, [=]{ - for (auto i = 0; i < num_elm; i++) { - fmt::print("node {}: \t: my_data[{}] = {}\n", my_node, i, my_data[i]); + vt::theRDMA()->getTypedDataInfoBuf( + msg->han, &my_data[0], num_elm, vt::no_byte, vt::no_tag, [=]{ + for (auto i = 0; i < num_elm; i++) { + fmt::print("node {}: \t: my_data[{}] = {}\n", this_node, i, my_data[i]); + } } - }); + ); } } int main(int argc, char** argv) { - CollectiveOps::initialize(argc, argv); + vt::initialize(argc, argv); - my_node = theContext()->getNode(); - num_nodes = theContext()->getNumNodes(); + vt::NodeType this_node = vt::theContext()->getNode(); - my_data = new double[my_data_len]; + my_data = std::make_unique(my_data_len); // initialize my_data buffer, all but node 0 get -1.0 for (auto i = 0; i < my_data_len; i++) { - my_data[i] = my_node == 0 ? (my_node+1)*i+1 : -1.0; + my_data[i] = this_node == 0 ? (this_node+1)*i+1 : -1.0; } - if (my_node == 0) { - my_handle = theRDMA()->registerNewTypedRdmaHandler(my_data, my_data_len); + if (this_node == 0) { + vt::RDMA_HandleType my_handle = + vt::theRDMA()->registerNewTypedRdmaHandler(&my_data[0], my_data_len); - auto msg = makeSharedMessage(my_node); + auto msg = vt::makeMessage(this_node); msg->han = my_handle; - theMsg()->broadcastMsg(msg); - } - - while (!rt->isTerminated()) { - runScheduler(); + vt::theMsg()->broadcastMsg(msg.get()); } - CollectiveOps::finalize(); + vt::finalize(); return 0; } From 5d62db7d0f8298e7fc64ea69b8695a05e5c36eb9 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 11:14:43 -0700 Subject: [PATCH 79/88] #526: example: fix missing explicit --- examples/rdma_simple_get_direct.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/rdma_simple_get_direct.cc b/examples/rdma_simple_get_direct.cc index 1a4a5aaa5d..990669e97f 100644 --- a/examples/rdma_simple_get_direct.cc +++ b/examples/rdma_simple_get_direct.cc @@ -51,7 +51,7 @@ static std::unique_ptr my_data = nullptr; struct HandleMsg : vt::Message { vt::RDMA_HandleType han; - HandleMsg(vt::RDMA_HandleType const& in_han) : han(in_han) { } + explicit HandleMsg(vt::RDMA_HandleType const& in_han) : han(in_han) { } }; static void tellHandle(HandleMsg* msg) { From 26fe6519e9521495df5278892baebce30e1c941d Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Thu, 23 Apr 2020 11:52:37 -0700 Subject: [PATCH 80/88] #526: example: create sub-directories for example types --- examples/CMakeLists.txt | 72 ++++++------------- examples/callback/CMakeLists.txt | 12 ++++ examples/{ => callback}/callback.cc | 0 examples/{ => callback}/callback_context.cc | 0 examples/collection/CMakeLists.txt | 17 +++++ .../{ => collection}/insertable_collection.cc | 0 examples/{ => collection}/jacobi1d_vt.cc | 0 examples/{ => collection}/jacobi2d_vt.cc | 0 examples/{ => collection}/lb_iter.cc | 0 .../{ => collection}/migrate_collection.cc | 0 examples/{ => collection}/reduce_integral.cc | 0 examples/{ => collection}/transpose.cc | 0 examples/group/CMakeLists.txt | 12 ++++ examples/{ => group}/group_collective.cc | 0 examples/{ => group}/group_rooted.cc | 0 examples/hello_world/CMakeLists.txt | 21 ++++++ examples/{ => hello_world}/hello_world.cc | 0 .../hello_world_collection.cc | 0 .../hello_world_collection_collective.cc | 0 .../hello_world_collection_reduce.cc | 0 .../hello_world_collection_staged_insert.cc | 0 .../{ => hello_world}/hello_world_functor.cc | 0 .../hello_world_virtual_context.cc | 0 .../hello_world_virtual_context_remote.cc | 0 examples/{ => hello_world}/objgroup.cc | 0 examples/{ => hello_world}/param.cc | 0 examples/{ => hello_world}/ring.cc | 0 examples/rdma/CMakeLists.txt | 14 ++++ examples/{ => rdma}/rdma_simple_get.cc | 0 examples/{ => rdma}/rdma_simple_get_direct.cc | 0 examples/{ => rdma}/rdma_simple_put.cc | 0 examples/{ => rdma}/rdma_simple_put_direct.cc | 0 examples/termination/CMakeLists.txt | 12 ++++ .../termination_collective.cc | 0 .../{ => termination}/termination_rooted.cc | 0 35 files changed, 111 insertions(+), 49 deletions(-) create mode 100644 examples/callback/CMakeLists.txt rename examples/{ => callback}/callback.cc (100%) rename examples/{ => callback}/callback_context.cc (100%) create mode 100644 examples/collection/CMakeLists.txt rename examples/{ => collection}/insertable_collection.cc (100%) rename examples/{ => collection}/jacobi1d_vt.cc (100%) rename examples/{ => collection}/jacobi2d_vt.cc (100%) rename examples/{ => collection}/lb_iter.cc (100%) rename examples/{ => collection}/migrate_collection.cc (100%) rename examples/{ => collection}/reduce_integral.cc (100%) rename examples/{ => collection}/transpose.cc (100%) create mode 100644 examples/group/CMakeLists.txt rename examples/{ => group}/group_collective.cc (100%) rename examples/{ => group}/group_rooted.cc (100%) create mode 100644 examples/hello_world/CMakeLists.txt rename examples/{ => hello_world}/hello_world.cc (100%) rename examples/{ => hello_world}/hello_world_collection.cc (100%) rename examples/{ => hello_world}/hello_world_collection_collective.cc (100%) rename examples/{ => hello_world}/hello_world_collection_reduce.cc (100%) rename examples/{ => hello_world}/hello_world_collection_staged_insert.cc (100%) rename examples/{ => hello_world}/hello_world_functor.cc (100%) rename examples/{ => hello_world}/hello_world_virtual_context.cc (100%) rename examples/{ => hello_world}/hello_world_virtual_context_remote.cc (100%) rename examples/{ => hello_world}/objgroup.cc (100%) rename examples/{ => hello_world}/param.cc (100%) rename examples/{ => hello_world}/ring.cc (100%) create mode 100644 examples/rdma/CMakeLists.txt rename examples/{ => rdma}/rdma_simple_get.cc (100%) rename examples/{ => rdma}/rdma_simple_get_direct.cc (100%) rename examples/{ => rdma}/rdma_simple_put.cc (100%) rename examples/{ => rdma}/rdma_simple_put_direct.cc (100%) create mode 100644 examples/termination/CMakeLists.txt rename examples/{ => termination}/termination_collective.cc (100%) rename examples/{ => termination}/termination_rooted.cc (100%) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 10a7e72244..51acd3a912 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -1,62 +1,36 @@ +# +# Examples +# + set( PROJECT_EXAMPLES_LIST - hello_world - ring - rdma_simple_get - rdma_simple_get_direct - rdma_simple_put - rdma_simple_put_direct - callback_context - param - hello_world_functor - termination_collective - termination_rooted - lb_iter - hello_world_virtual_context - jacobi1d_vt - jacobi2d_vt - hello_world_virtual_context_remote - migrate_collection - hello_world_collection - hello_world_collection_collective - hello_world_collection_staged_insert - hello_world_collection_reduce - insertable_collection - group_rooted - group_collective - reduce_integral - transpose tutorial - objgroup - callback ) -if (VT_NO_BUILD_EXAMPLES) - message( - STATUS "VT: not building examples because VT_NO_BUILD_EXAMPLES is set" - ) -else() - foreach(EXAMPLE_NAME ${PROJECT_EXAMPLES_LIST}) - # message("Example: building example >>>>> ${EXAMPLE}") - - set(EXAMPLE_FILE "${EXAMPLE_NAME}.cc") +macro(add_example example_name) + set(EXAMPLE_FILE "${example_name}.cc") - add_executable(${EXAMPLE_NAME} ${EXAMPLE_FILE}) - add_dependencies(examples ${EXAMPLE_NAME}) + add_executable(${example_name} ${EXAMPLE_FILE}) + add_dependencies(examples ${example_name}) - link_target_with_vt( - TARGET ${EXAMPLE_NAME} - DEFAULT_LINK_SET - LINK_GTEST ON - ) + link_target_with_vt( + TARGET ${example_name} + DEFAULT_LINK_SET + ) + if (BUILD_TESTING) add_test_for_example_vt( - ${EXAMPLE_NAME} + ${example_name} ${EXAMPLE_FILE} example_tests ) - - endforeach() -endif() - + endif() +endmacro() + +add_subdirectory(callback) +add_subdirectory(collection) +add_subdirectory(group) +add_subdirectory(hello_world) +add_subdirectory(rdma) +add_subdirectory(termination) diff --git a/examples/callback/CMakeLists.txt b/examples/callback/CMakeLists.txt new file mode 100644 index 0000000000..e651b0a675 --- /dev/null +++ b/examples/callback/CMakeLists.txt @@ -0,0 +1,12 @@ + +set( + CALLBACK_EXAMPLES + callback + callback_context +) + +foreach(EXAMPLE_NAME ${CALLBACK_EXAMPLES}) + # message("Example: building callback example >>>>> ${EXAMPLE_NAME}") + + add_example(${EXAMPLE_NAME}) +endforeach() diff --git a/examples/callback.cc b/examples/callback/callback.cc similarity index 100% rename from examples/callback.cc rename to examples/callback/callback.cc diff --git a/examples/callback_context.cc b/examples/callback/callback_context.cc similarity index 100% rename from examples/callback_context.cc rename to examples/callback/callback_context.cc diff --git a/examples/collection/CMakeLists.txt b/examples/collection/CMakeLists.txt new file mode 100644 index 0000000000..e10b333597 --- /dev/null +++ b/examples/collection/CMakeLists.txt @@ -0,0 +1,17 @@ + +set( + COLLECTION_EXAMPLES + lb_iter + jacobi1d_vt + jacobi2d_vt + migrate_collection + insertable_collection + reduce_integral + transpose +) + +foreach(EXAMPLE_NAME ${COLLECTION_EXAMPLES}) + # message("Example: building collection example >>>>> ${EXAMPLE_NAME}") + + add_example(${EXAMPLE_NAME}) +endforeach() diff --git a/examples/insertable_collection.cc b/examples/collection/insertable_collection.cc similarity index 100% rename from examples/insertable_collection.cc rename to examples/collection/insertable_collection.cc diff --git a/examples/jacobi1d_vt.cc b/examples/collection/jacobi1d_vt.cc similarity index 100% rename from examples/jacobi1d_vt.cc rename to examples/collection/jacobi1d_vt.cc diff --git a/examples/jacobi2d_vt.cc b/examples/collection/jacobi2d_vt.cc similarity index 100% rename from examples/jacobi2d_vt.cc rename to examples/collection/jacobi2d_vt.cc diff --git a/examples/lb_iter.cc b/examples/collection/lb_iter.cc similarity index 100% rename from examples/lb_iter.cc rename to examples/collection/lb_iter.cc diff --git a/examples/migrate_collection.cc b/examples/collection/migrate_collection.cc similarity index 100% rename from examples/migrate_collection.cc rename to examples/collection/migrate_collection.cc diff --git a/examples/reduce_integral.cc b/examples/collection/reduce_integral.cc similarity index 100% rename from examples/reduce_integral.cc rename to examples/collection/reduce_integral.cc diff --git a/examples/transpose.cc b/examples/collection/transpose.cc similarity index 100% rename from examples/transpose.cc rename to examples/collection/transpose.cc diff --git a/examples/group/CMakeLists.txt b/examples/group/CMakeLists.txt new file mode 100644 index 0000000000..8338469873 --- /dev/null +++ b/examples/group/CMakeLists.txt @@ -0,0 +1,12 @@ + +set( + GROUP_EXAMPLES + group_rooted + group_collective +) + +foreach(EXAMPLE_NAME ${GROUP_EXAMPLES}) + # message("Example: building group example >>>>> ${EXAMPLE_NAME}") + + add_example(${EXAMPLE_NAME}) +endforeach() diff --git a/examples/group_collective.cc b/examples/group/group_collective.cc similarity index 100% rename from examples/group_collective.cc rename to examples/group/group_collective.cc diff --git a/examples/group_rooted.cc b/examples/group/group_rooted.cc similarity index 100% rename from examples/group_rooted.cc rename to examples/group/group_rooted.cc diff --git a/examples/hello_world/CMakeLists.txt b/examples/hello_world/CMakeLists.txt new file mode 100644 index 0000000000..2fa6194395 --- /dev/null +++ b/examples/hello_world/CMakeLists.txt @@ -0,0 +1,21 @@ + +set( + HELLO_WORLD_EXAMPLES + hello_world + hello_world_functor + hello_world_collection + hello_world_collection_collective + hello_world_collection_staged_insert + hello_world_collection_reduce + hello_world_virtual_context + hello_world_virtual_context_remote + ring + param + objgroup +) + +foreach(EXAMPLE_NAME ${HELLO_WORLD_EXAMPLES}) + # message("Example: building hello_world example >>>>> ${EXAMPLE_NAME}") + + add_example(${EXAMPLE_NAME}) +endforeach() diff --git a/examples/hello_world.cc b/examples/hello_world/hello_world.cc similarity index 100% rename from examples/hello_world.cc rename to examples/hello_world/hello_world.cc diff --git a/examples/hello_world_collection.cc b/examples/hello_world/hello_world_collection.cc similarity index 100% rename from examples/hello_world_collection.cc rename to examples/hello_world/hello_world_collection.cc diff --git a/examples/hello_world_collection_collective.cc b/examples/hello_world/hello_world_collection_collective.cc similarity index 100% rename from examples/hello_world_collection_collective.cc rename to examples/hello_world/hello_world_collection_collective.cc diff --git a/examples/hello_world_collection_reduce.cc b/examples/hello_world/hello_world_collection_reduce.cc similarity index 100% rename from examples/hello_world_collection_reduce.cc rename to examples/hello_world/hello_world_collection_reduce.cc diff --git a/examples/hello_world_collection_staged_insert.cc b/examples/hello_world/hello_world_collection_staged_insert.cc similarity index 100% rename from examples/hello_world_collection_staged_insert.cc rename to examples/hello_world/hello_world_collection_staged_insert.cc diff --git a/examples/hello_world_functor.cc b/examples/hello_world/hello_world_functor.cc similarity index 100% rename from examples/hello_world_functor.cc rename to examples/hello_world/hello_world_functor.cc diff --git a/examples/hello_world_virtual_context.cc b/examples/hello_world/hello_world_virtual_context.cc similarity index 100% rename from examples/hello_world_virtual_context.cc rename to examples/hello_world/hello_world_virtual_context.cc diff --git a/examples/hello_world_virtual_context_remote.cc b/examples/hello_world/hello_world_virtual_context_remote.cc similarity index 100% rename from examples/hello_world_virtual_context_remote.cc rename to examples/hello_world/hello_world_virtual_context_remote.cc diff --git a/examples/objgroup.cc b/examples/hello_world/objgroup.cc similarity index 100% rename from examples/objgroup.cc rename to examples/hello_world/objgroup.cc diff --git a/examples/param.cc b/examples/hello_world/param.cc similarity index 100% rename from examples/param.cc rename to examples/hello_world/param.cc diff --git a/examples/ring.cc b/examples/hello_world/ring.cc similarity index 100% rename from examples/ring.cc rename to examples/hello_world/ring.cc diff --git a/examples/rdma/CMakeLists.txt b/examples/rdma/CMakeLists.txt new file mode 100644 index 0000000000..3b6112604b --- /dev/null +++ b/examples/rdma/CMakeLists.txt @@ -0,0 +1,14 @@ + +set( + RDMA_EXAMPLES + rdma_simple_get + rdma_simple_get_direct + rdma_simple_put + rdma_simple_put_direct +) + +foreach(EXAMPLE_NAME ${RDMA_EXAMPLES}) + # message("Example: building rdma example >>>>> ${EXAMPLE_NAME}") + + add_example(${EXAMPLE_NAME}) +endforeach() diff --git a/examples/rdma_simple_get.cc b/examples/rdma/rdma_simple_get.cc similarity index 100% rename from examples/rdma_simple_get.cc rename to examples/rdma/rdma_simple_get.cc diff --git a/examples/rdma_simple_get_direct.cc b/examples/rdma/rdma_simple_get_direct.cc similarity index 100% rename from examples/rdma_simple_get_direct.cc rename to examples/rdma/rdma_simple_get_direct.cc diff --git a/examples/rdma_simple_put.cc b/examples/rdma/rdma_simple_put.cc similarity index 100% rename from examples/rdma_simple_put.cc rename to examples/rdma/rdma_simple_put.cc diff --git a/examples/rdma_simple_put_direct.cc b/examples/rdma/rdma_simple_put_direct.cc similarity index 100% rename from examples/rdma_simple_put_direct.cc rename to examples/rdma/rdma_simple_put_direct.cc diff --git a/examples/termination/CMakeLists.txt b/examples/termination/CMakeLists.txt new file mode 100644 index 0000000000..8469bdbd82 --- /dev/null +++ b/examples/termination/CMakeLists.txt @@ -0,0 +1,12 @@ + +set( + TERMINATION_EXAMPLES + termination_collective + termination_rooted +) + +foreach(EXAMPLE_NAME ${TERMINATION_EXAMPLES}) + # message("Example: building term example >>>>> ${EXAMPLE_NAME}") + + add_example(${EXAMPLE_NAME}) +endforeach() diff --git a/examples/termination_collective.cc b/examples/termination/termination_collective.cc similarity index 100% rename from examples/termination_collective.cc rename to examples/termination/termination_collective.cc diff --git a/examples/termination_rooted.cc b/examples/termination/termination_rooted.cc similarity index 100% rename from examples/termination_rooted.cc rename to examples/termination/termination_rooted.cc From 18a88382e9700b7b5a42a0278b309e25cfb5d6ba Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Mon, 11 May 2020 17:40:43 -0700 Subject: [PATCH 81/88] serialization: a bunch of fixes due to merge conflicts --- cmake/define_build_types.cmake | 1 - cmake_config.h.in | 1 - examples/callback/callback.cc | 4 - examples/collection/jacobi1d_vt.cc | 2 + examples/collection/transpose.cc | 2 +- src/vt/configs/features/features_defines.h | 1 - .../configs/features/features_featureswitch.h | 1 - src/vt/parameterization/parameterization.h | 4 - src/vt/runtime/runtime.cc | 3 - src/vt/serialization/auto_dispatch/dispatch.h | 34 +-- .../auto_dispatch/dispatch.impl.h | 19 -- .../auto_dispatch/dispatch_functor.h | 36 +-- .../auto_dispatch/dispatch_functor.impl.h | 24 -- .../auto_dispatch/dispatch_handler.h | 37 +-- .../auto_dispatch/dispatch_handler.impl.h | 19 -- .../messaging/serialized_messenger.h | 42 --- .../messaging/serialized_messenger.impl.h | 147 --------- src/vt/serialization/sizer.h | 2 +- .../balance/greedylb/greedylb_msgs.h | 15 +- .../balance/hierarchicallb/hierlb_msgs.h | 31 +- tests/unit/serialization/test_parserdes.cc | 281 ----------------- .../test_parserdes_collection.cc | 282 ------------------ .../serialization/test_serialize_messenger.cc | 3 - 23 files changed, 22 insertions(+), 969 deletions(-) delete mode 100644 tests/unit/serialization/test_parserdes.cc delete mode 100644 tests/unit/serialization/test_parserdes_collection.cc diff --git a/cmake/define_build_types.cmake b/cmake/define_build_types.cmake index f0d0b736ff..06a7b8c9af 100644 --- a/cmake/define_build_types.cmake +++ b/cmake/define_build_types.cmake @@ -132,7 +132,6 @@ set(vt_feature_cmake_no_feature "0") set(vt_feature_cmake_production "0") set (vt_feature_cmake_mpi_rdma "0") -set (vt_feature_cmake_parserdes "0") set (vt_feature_cmake_print_term_msgs "0") set (vt_feature_cmake_default_threading "1") set (vt_feature_cmake_no_pool_alloc_env "0") diff --git a/cmake_config.h.in b/cmake_config.h.in index d10723dcc2..44bc0fe51f 100644 --- a/cmake_config.h.in +++ b/cmake_config.h.in @@ -55,7 +55,6 @@ #define vt_feature_cmake_production @vt_feature_cmake_production@ #define vt_feature_cmake_stdthread @vt_feature_cmake_stdthread@ #define vt_feature_cmake_mpi_rdma @vt_feature_cmake_mpi_rdma@ -#define vt_feature_cmake_parserdes @vt_feature_cmake_parserdes@ #define vt_feature_cmake_print_term_msgs @vt_feature_cmake_print_term_msgs@ #define vt_feature_cmake_default_threading @vt_feature_cmake_default_threading@ #define vt_feature_cmake_no_pool_alloc_env @vt_feature_cmake_no_pool_alloc_env@ diff --git a/examples/callback/callback.cc b/examples/callback/callback.cc index d717a7d1b1..a6b3a4db32 100644 --- a/examples/callback/callback.cc +++ b/examples/callback/callback.cc @@ -46,9 +46,6 @@ // Message sent from the callback to the callback endpoint struct TestMsg : vt::Message { - using MessageParentType = ::vt::Message; - vt_msg_serialize_required(); // for string - TestMsg() = default; explicit TestMsg(int in_val, std::string const& in_s = "hello") @@ -58,7 +55,6 @@ struct TestMsg : vt::Message { template void serialize(SerializerT& s) { - MessageParentType::serialize(s); s | val_; s | s_; } diff --git a/examples/collection/jacobi1d_vt.cc b/examples/collection/jacobi1d_vt.cc index 9d11f669fd..544e46817b 100644 --- a/examples/collection/jacobi1d_vt.cc +++ b/examples/collection/jacobi1d_vt.cc @@ -199,6 +199,8 @@ struct LinearPb1DJacobi : vt::Collection { s | val; } + vt::IdxBase from_index; + double val = 0.0; }; diff --git a/examples/collection/transpose.cc b/examples/collection/transpose.cc index e5bc94bac9..0b630a8279 100644 --- a/examples/collection/transpose.cc +++ b/examples/collection/transpose.cc @@ -163,7 +163,7 @@ struct Block : vt::Collection { ); auto const from_idx = getIndex().x(); auto data_msg = vt::makeMessage(data_,from_idx); - vt::theMsg()->sendMsg( + vt::theMsg()->sendMsgAuto( requesting_node, data_msg.get() ); } diff --git a/src/vt/configs/features/features_defines.h b/src/vt/configs/features/features_defines.h index 0c905575c0..7c04ff7745 100644 --- a/src/vt/configs/features/features_defines.h +++ b/src/vt/configs/features/features_defines.h @@ -59,7 +59,6 @@ #define vt_feature_production 0 || vt_feature_cmake_production #define vt_feature_stdthread 0 || vt_feature_cmake_stdthread #define vt_feature_mpi_rdma 0 || vt_feature_cmake_mpi_rdma -#define vt_feature_parserdes 0 || vt_feature_cmake_parserdes #define vt_feature_print_term_msgs 0 || vt_feature_cmake_print_term_msgs #define vt_feature_default_threading 0 || vt_feature_cmake_default_threading #define vt_feature_no_pool_alloc_env 0 || vt_feature_cmake_no_pool_alloc_env diff --git a/src/vt/configs/features/features_featureswitch.h b/src/vt/configs/features/features_featureswitch.h index 3758f169e5..009723d820 100644 --- a/src/vt/configs/features/features_featureswitch.h +++ b/src/vt/configs/features/features_featureswitch.h @@ -59,7 +59,6 @@ #define vt_feature_str_no_feature "No feature" #define vt_feature_str_no_pool_alloc_env "No memory pool envelope" #define vt_feature_str_openmp "OpenMP Threading" -#define vt_feature_str_parserdes "Partial Inline Serialization" #define vt_feature_str_print_term_msgs "Print Termination Control Messages" #define vt_feature_str_production "Production Build" #define vt_feature_str_stdthread "std::thread Threading" diff --git a/src/vt/parameterization/parameterization.h b/src/vt/parameterization/parameterization.h index 887e7c8b7c..c8b1c41311 100644 --- a/src/vt/parameterization/parameterization.h +++ b/src/vt/parameterization/parameterization.h @@ -65,9 +65,6 @@ using HandlerManagerType = vt::HandlerManager; template struct DataMsg : vt::Message { - using MessageParentType = vt::Message; - vt_msg_serialize_if_needed_by_parent_or_type1(Tuple); // by tup - Tuple tup; HandlerType sub_han = uninitialized_handler; @@ -83,7 +80,6 @@ struct DataMsg : vt::Message { template void serialize(SerializerT& s) { - MessageParentType::serialize(s); s | tup; s | sub_han; } diff --git a/src/vt/runtime/runtime.cc b/src/vt/runtime/runtime.cc index 787c9a3f73..d788d8b56b 100644 --- a/src/vt/runtime/runtime.cc +++ b/src/vt/runtime/runtime.cc @@ -357,9 +357,6 @@ void Runtime::printStartupBanner() { #if backend_check_enabled(mpi_rdma) features.push_back(vt_feature_str_mpi_rdma); #endif -#if backend_check_enabled(parserdes) - features.push_back(vt_feature_str_parserdes); -#endif #if backend_check_enabled(print_term_msgs) features.push_back(vt_feature_str_print_term_msgs); #endif diff --git a/src/vt/serialization/auto_dispatch/dispatch.h b/src/vt/serialization/auto_dispatch/dispatch.h index 17995a1a1e..41911f785d 100644 --- a/src/vt/serialization/auto_dispatch/dispatch.h +++ b/src/vt/serialization/auto_dispatch/dispatch.h @@ -48,13 +48,8 @@ #include "vt/config.h" #include "vt/activefn/activefn.h" #include "vt/messaging/pending_send.h" -#include "vt/serialization/serialize_interface.h" -#if HAS_SERIALIZATION_LIBRARY - #define HAS_DETECTION_COMPONENT 1 - #include "serialization_library_headers.h" - #include "traits/serializable_traits.h" -#endif +#include namespace vt { namespace serialization { namespace auto_dispatch { @@ -106,13 +101,12 @@ struct RequiredSerialization { } }; -#if HAS_SERIALIZATION_LIBRARY template * f> struct RequiredSerialization< MsgT, f, typename std::enable_if_t< - ::serdes::SerializableTraits::has_serialize_function + ::checkpoint::SerializableTraits::has_serialize_function > > { static messaging::PendingSend sendMsg( @@ -127,30 +121,6 @@ struct RequiredSerialization< } }; -template * f> -struct RequiredSerialization< - MsgT, - f, - typename std::enable_if_t< - ::serdes::SerializableTraits::is_parserdes - > -> { - static messaging::PendingSend sendMsg( - NodeType const& node, MsgT* msg, TagType const& tag = no_tag - ) { - return SenderSerialize::sendMsgParserdes(node,msg,tag); - } - static messaging::PendingSend broadcastMsg( - MsgT* msg, TagType const& tag = no_tag - ) { - return BroadcasterSerialize::broadcastMsgParserdes( - msg,tag - ); - } -}; - -#endif - }}} /* end namespace vt::serialization::auto_dispatch */ namespace vt { diff --git a/src/vt/serialization/auto_dispatch/dispatch.impl.h b/src/vt/serialization/auto_dispatch/dispatch.impl.h index 3432464dc4..942c880386 100644 --- a/src/vt/serialization/auto_dispatch/dispatch.impl.h +++ b/src/vt/serialization/auto_dispatch/dispatch.impl.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/serialization/auto_dispatch/dispatch.h" -#include "vt/serialization/serialize_interface.h" #include "vt/serialization/messaging/serialized_messenger.h" #include "vt/messaging/active.h" @@ -76,14 +75,6 @@ template * f> * Serialization message send/broadcast detected based on the is_serializable * type traits */ -template * f> -/*static*/ messaging::PendingSend SenderSerialize::sendMsgParserdes( - NodeType const& node, MsgT* msg, TagType const& tag -) { - vtAssert(tag == no_tag, "Tagged messages serialized not implemented"); - return SerializedMessenger::sendParserdesMsg(node,msg); -} - template * f> /*static*/ messaging::PendingSend SenderSerialize::sendMsg( NodeType const& node, MsgT* msg, TagType const& tag @@ -92,16 +83,6 @@ template * f> return SerializedMessenger::sendSerialMsg(node,msg); } - -template * f> -/*static*/ messaging::PendingSend BroadcasterSerialize::broadcastMsgParserdes( - MsgT* msg, TagType const& tag -) { - vtAssert(tag == no_tag, "Tagged messages serialized not implemented"); - return SerializedMessenger::broadcastParserdesMsg(msg); -} - - template * f> /*static*/ messaging::PendingSend BroadcasterSerialize::broadcastMsg( MsgT* msg, TagType const& tag diff --git a/src/vt/serialization/auto_dispatch/dispatch_functor.h b/src/vt/serialization/auto_dispatch/dispatch_functor.h index e8528670ec..6d692d50a0 100644 --- a/src/vt/serialization/auto_dispatch/dispatch_functor.h +++ b/src/vt/serialization/auto_dispatch/dispatch_functor.h @@ -48,14 +48,9 @@ #include "vt/config.h" #include "vt/activefn/activefn.h" #include "vt/messaging/pending_send.h" -#include "vt/serialization/serialize_interface.h" #include "vt/utils/static_checks/functor.h" -#if HAS_SERIALIZATION_LIBRARY - #define HAS_DETECTION_COMPONENT 1 - #include "serialization_library_headers.h" - #include "traits/serializable_traits.h" -#endif +#include namespace vt { namespace serialization { namespace auto_dispatch { @@ -108,13 +103,11 @@ struct RequiredSerializationFunctor { } }; -#if HAS_SERIALIZATION_LIBRARY - template struct RequiredSerializationFunctor< FunctorT, MsgT, typename std::enable_if_t< - ::serdes::SerializableTraits::has_serialize_function + ::checkpoint::SerializableTraits::has_serialize_function > > { static messaging::PendingSend sendMsg( @@ -131,31 +124,6 @@ struct RequiredSerializationFunctor< } }; -template -struct RequiredSerializationFunctor< - FunctorT, MsgT, - typename std::enable_if_t< - ::serdes::SerializableTraits::is_parserdes - > -> { - static messaging::PendingSend sendMsg( - NodeType const& node, MsgT* msg, TagType const& tag = no_tag - ) { - return SenderSerializeFunctor::sendMsgParserdes( - node,msg,tag - ); - } - static messaging::PendingSend broadcastMsg( - MsgT* msg, TagType const& tag = no_tag - ) { - return BroadcasterSerializeFunctor::broadcastMsgParserdes( - msg,tag - ); - } -}; - -#endif - }}} /* end namespace vt::serialization::auto_dispatch */ namespace vt { diff --git a/src/vt/serialization/auto_dispatch/dispatch_functor.impl.h b/src/vt/serialization/auto_dispatch/dispatch_functor.impl.h index 2679f49a25..d365e857ab 100644 --- a/src/vt/serialization/auto_dispatch/dispatch_functor.impl.h +++ b/src/vt/serialization/auto_dispatch/dispatch_functor.impl.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/serialization/auto_dispatch/dispatch_functor.h" -#include "vt/serialization/serialize_interface.h" #include "vt/serialization/messaging/serialized_messenger.h" #include "vt/messaging/active.h" @@ -72,18 +71,6 @@ template return theMsg()->broadcastMsg(msg,tag); } -/* - * Serialization message send/broadcast detected based on the is_serializable - * type traits - */ -template -/*static*/ messaging::PendingSend SenderSerializeFunctor::sendMsgParserdes( - NodeType const& node, MsgT* msg, TagType const& tag -) { - vtAssert(tag == no_tag, "Tagged messages serialized not implemented"); - return SerializedMessenger::sendParserdesMsg(node,msg); -} - template /*static*/ messaging::PendingSend SenderSerializeFunctor::sendMsg( NodeType const& node, MsgT* msg, TagType const& tag @@ -92,17 +79,6 @@ template return SerializedMessenger::sendSerialMsg(node,msg); } - -template -/*static*/ PendingSend - BroadcasterSerializeFunctor::broadcastMsgParserdes( - MsgT* msg, TagType const& tag -) { - vtAssert(tag == no_tag, "Tagged messages serialized not implemented"); - return SerializedMessenger::broadcastParserdesMsg(msg); -} - - template /*static*/ messaging::PendingSend BroadcasterSerializeFunctor::broadcastMsg( MsgT* msg, TagType const& tag diff --git a/src/vt/serialization/auto_dispatch/dispatch_handler.h b/src/vt/serialization/auto_dispatch/dispatch_handler.h index 81f96ad697..e1f5510a73 100644 --- a/src/vt/serialization/auto_dispatch/dispatch_handler.h +++ b/src/vt/serialization/auto_dispatch/dispatch_handler.h @@ -48,13 +48,8 @@ #include "vt/config.h" #include "vt/activefn/activefn.h" #include "vt/messaging/pending_send.h" -#include "vt/serialization/serialize_interface.h" -#if HAS_SERIALIZATION_LIBRARY - #define HAS_DETECTION_COMPONENT 1 - #include "serialization_library_headers.h" - #include "traits/serializable_traits.h" -#endif +#include namespace vt { namespace serialization { namespace auto_dispatch { @@ -108,13 +103,11 @@ struct RequiredSerializationHandler { } }; -#if HAS_SERIALIZATION_LIBRARY - template struct RequiredSerializationHandler< MsgT, typename std::enable_if_t< - ::serdes::SerializableTraits::has_serialize_function + ::checkpoint::SerializableTraits::has_serialize_function > > { static messaging::PendingSend sendMsg( @@ -130,32 +123,6 @@ struct RequiredSerializationHandler< } }; -template -struct RequiredSerializationHandler< - MsgT, - typename std::enable_if_t< - ::serdes::SerializableTraits::is_parserdes - > -> { - static messaging::PendingSend sendMsg( - NodeType const& node, MsgT* msg, HandlerType const& han, - TagType const& tag = no_tag - ) { - return SenderSerializeHandler::sendMsgParserdes( - node,msg,han,tag - ); - } - static messaging::PendingSend broadcastMsg( - MsgT* msg, HandlerType const& han, TagType const& tag = no_tag - ) { - return BroadcasterSerializeHandler::broadcastMsgParserdes( - msg,han,tag - ); - } -}; - -#endif - }}} /* end namespace vt::serialization::auto_dispatch */ namespace vt { diff --git a/src/vt/serialization/auto_dispatch/dispatch_handler.impl.h b/src/vt/serialization/auto_dispatch/dispatch_handler.impl.h index ee328c0a5c..561c8370c1 100644 --- a/src/vt/serialization/auto_dispatch/dispatch_handler.impl.h +++ b/src/vt/serialization/auto_dispatch/dispatch_handler.impl.h @@ -47,7 +47,6 @@ #include "vt/config.h" #include "vt/serialization/auto_dispatch/dispatch_handler.h" -#include "vt/serialization/serialize_interface.h" #include "vt/serialization/messaging/serialized_messenger.h" #include "vt/messaging/active.h" @@ -70,15 +69,6 @@ template return theMsg()->broadcastMsg(handler,msg,tag); } -template -/*static*/ messaging::PendingSend SenderSerializeHandler::sendMsgParserdes( - NodeType const& node, HandlerType const& han, MsgT* msg, - TagType const& tag -) { - vtAssert(tag == no_tag, "Tagged messages serialized not implemented"); - return SerializedMessenger::sendParserdesMsgHandler(node,han,msg); -} - template /*static*/ messaging::PendingSend SenderSerializeHandler::sendMsg( NodeType const& node, MsgT* msg, HandlerType const& handler, @@ -88,15 +78,6 @@ template return SerializedMessenger::sendSerialMsgHandler(node,msg,handler); } -template -/*static*/ messaging::PendingSend - BroadcasterSerializeHandler::broadcastMsgParserdes( - MsgT* msg, HandlerType const& handler, TagType const& tag -) { - vtAssert(tag == no_tag, "Tagged messages serialized not implemented"); - return SerializedMessenger::broadcastParserdesMsgHandler(msg,handler); -} - template /*static*/ messaging::PendingSend BroadcasterSerializeHandler::broadcastMsg( MsgT* msg, HandlerType const& handler, TagType const& tag diff --git a/src/vt/serialization/messaging/serialized_messenger.h b/src/vt/serialization/messaging/serialized_messenger.h index 2331949771..32b2bf0a5f 100644 --- a/src/vt/serialization/messaging/serialized_messenger.h +++ b/src/vt/serialization/messaging/serialized_messenger.h @@ -48,7 +48,6 @@ #include "vt/config.h" #include "vt/messaging/message.h" #include "vt/messaging/pending_send.h" -#include "vt/serialization/serialization.h" #include "vt/serialization/messaging/serialized_data_msg.h" #include @@ -72,9 +71,6 @@ struct SerializedMessenger { template using SerialWrapperMsgType = SerializedDataMsg; - template - static void parserdesHandler(MsgT* msg); - template static void serialMsgHandlerBcast(SerialWrapperMsgType* sys_msg); @@ -86,44 +82,6 @@ struct SerializedMessenger { SerialEagerPayloadMsg* sys_msg ); - template *f, typename BaseT = Message> - static messaging::PendingSend sendParserdesMsg(NodeType dest, MsgT* msg); - - template - static messaging::PendingSend sendParserdesMsg(NodeType dest, MsgT* msg); - - template - static messaging::PendingSend sendParserdesMsgHandler( - NodeType dest, HandlerType const& handler, MsgT* msg - ); - - template - static messaging::PendingSend broadcastParserdesMsg(MsgT* msg); - - template *f, typename BaseT = Message> - static messaging::PendingSend broadcastParserdesMsg(MsgT* msg); - - template - static messaging::PendingSend broadcastParserdesMsgHandler( - MsgT* msg, HandlerType const& han - ); - - template *f, typename BaseT = Message> - static messaging::PendingSend parserdesMsg( - MsgT* msg, bool is_bcast = true, NodeType dest = uninitialized_destination - ); - - template - static messaging::PendingSend parserdesMsg( - MsgT* msg, bool is_bcast = true, NodeType dest = uninitialized_destination - ); - - template - static messaging::PendingSend parserdesMsgHandler( - MsgT* msg, HandlerType const& handler, bool is_bcast = true, - NodeType dest = uninitialized_destination - ); - template static messaging::PendingSend sendSerialMsg( NodeType dest, MsgT* msg, ActionEagerSend eager = nullptr diff --git a/src/vt/serialization/messaging/serialized_messenger.impl.h b/src/vt/serialization/messaging/serialized_messenger.impl.h index aba7e7b89b..39015c05ac 100644 --- a/src/vt/serialization/messaging/serialized_messenger.impl.h +++ b/src/vt/serialization/messaging/serialized_messenger.impl.h @@ -61,24 +61,6 @@ namespace vt { namespace serialization { -template -/*static*/ void SerializedMessenger::parserdesHandler(MsgT* msg) { - auto const& msg_size = sizeof(MsgT); - auto const& han_size = sizeof(HandlerType); - auto const& size_size = sizeof(size_t); - auto msg_ptr = reinterpret_cast(msg); - auto const& user_handler = *reinterpret_cast( - msg_ptr + msg_size - ); - auto const& ptr_size = *reinterpret_cast( - msg_ptr + msg_size + han_size - ); - auto ptr_offset = msg_ptr + msg_size + han_size + size_size; - auto t_ptr = deserializePartial(ptr_offset, ptr_size, msg); - auto const& from_node = theMsg()->getFromNodeCurrentHandler(); - runnable::Runnable::run(user_handler, nullptr, t_ptr, from_node); -} - template /*static*/ void SerializedMessenger::serialMsgHandlerBcast( SerialWrapperMsgType* sys_msg @@ -184,135 +166,6 @@ template ); } -template *f, typename BaseT> -/*static*/ messaging::PendingSend SerializedMessenger::sendParserdesMsg( - NodeType dest, MsgT* msg -) { - debug_print( - serial_msg, node, - "sendParserdesMsg: dest={}, msg={}\n", - dest, print_ptr(msg) - ); - return parserdesMsg(msg, false, dest); -} - -template -/*static*/ messaging::PendingSend SerializedMessenger::sendParserdesMsg( - NodeType dest, MsgT* msg -) { - debug_print( - serial_msg, node, - "sendParserdesMsg: (functor) dest={}, msg={}\n", - dest, print_ptr(msg) - ); - return parserdesMsg(msg, false, dest); -} - -template -/*static*/ messaging::PendingSend SerializedMessenger::sendParserdesMsgHandler( - NodeType dest, HandlerType const& handler, MsgT* msg -) { - debug_print( - serial_msg, node, - "sendParserdesMsg: dest={}, msg={}\n", - dest, print_ptr(msg) - ); - return parserdesMsgHandler(msg, handler, false, dest); -} - -template -/*static*/ messaging::PendingSend - SerializedMessenger::broadcastParserdesMsg(MsgT* msg) { - debug_print( - serial_msg, node, - "broadcastParserdesMsg: (functor) msg={}\n", print_ptr(msg) - ); - return parserdesMsg(msg,true); -} - -template *f, typename BaseT> -/*static*/ messaging::PendingSend - SerializedMessenger::broadcastParserdesMsg(MsgT* msg) { - debug_print( - serial_msg, node, - "broadcastParserdesMsg: msg={}\n", print_ptr(msg) - ); - return parserdesMsg(msg,true); -} - -template -/*static*/ messaging::PendingSend - SerializedMessenger::broadcastParserdesMsgHandler( - MsgT* msg, HandlerType const& han -) { - debug_print( - serial_msg, node, - "broadcastParserdesMsgHandler: msg={}, han={}\n", print_ptr(msg), han - ); - return parserdesMsgHandler(msg,han,true); -} - - -template -/*static*/ messaging::PendingSend SerializedMessenger::parserdesMsg( - MsgT* msg, bool is_bcast, NodeType dest -) { - auto const& h = auto_registry::makeAutoHandlerFunctor(); - return parserdesMsgHandler(msg,h,is_bcast,dest); -} - -template *f, typename BaseT> -/*static*/ messaging::PendingSend SerializedMessenger::parserdesMsg( - MsgT* msg, bool is_bcast, NodeType dest -) { - auto const& h = auto_registry::makeAutoHandler(nullptr); - return parserdesMsgHandler(msg,h,is_bcast,dest); -} - -template -/*static*/ messaging::PendingSend SerializedMessenger::parserdesMsgHandler( - MsgT* msg, HandlerType const& handler, bool is_bcast, NodeType dest -) { - auto const& user_handler = handler; - SizeType ptr_size = 0; - auto const& rem_size = thePool()->remainingSize(msg); - auto const& msg_size = sizeof(MsgT); - auto const& han_size = sizeof(HandlerType); - auto const& size_size = sizeof(size_t); - auto msg_ptr = reinterpret_cast(msg); - - auto serialized_msg = serializePartial( - *msg, [&](SizeType size) -> SerialByteType* { - ptr_size = size; - if (size + han_size <= rem_size) { - auto ptr = msg_ptr + msg_size + han_size + size_size; - return ptr; - } else { - vtAssert(0, "Must fit in remaining size (current limitation)"); - return nullptr; - } - } - ); - - debug_print( - serial_msg, node, - "parserdesMsg: ptr_size={}, rem_size={}, msg_size={}, is_bcast={}, " - "dest={}\n", - ptr_size, rem_size, msg_size, is_bcast, dest - ); - - *reinterpret_cast(msg_ptr + msg_size) = user_handler; - *reinterpret_cast(msg_ptr + msg_size + han_size) = ptr_size; - - auto const& total_size = ptr_size + msg_size + han_size + size_size; - auto const& tag = no_tag; - if (is_bcast) { - return theMsg()->broadcastMsgSz(msg, total_size, tag); - } else { - return theMsg()->sendMsgSz(dest, msg, total_size, tag); - } -} - template *f, typename BaseT> /*static*/ messaging::PendingSend SerializedMessenger::sendSerialMsg( NodeType dest, MsgT* msg, ActionEagerSend eager diff --git a/src/vt/serialization/sizer.h b/src/vt/serialization/sizer.h index 54a0e4ef32..9bb596881b 100644 --- a/src/vt/serialization/sizer.h +++ b/src/vt/serialization/sizer.h @@ -62,7 +62,7 @@ template struct MsgSizer< MsgT, typename std::enable_if_t< - ::serdes::SerializableTraits::has_serialize_function + ::checkpoint::SerializableTraits::has_serialize_function > > { static std::size_t get(MsgT* msg) { diff --git a/src/vt/vrt/collection/balance/greedylb/greedylb_msgs.h b/src/vt/vrt/collection/balance/greedylb/greedylb_msgs.h index 7a6c91c12c..4ecdf92129 100644 --- a/src/vt/vrt/collection/balance/greedylb/greedylb_msgs.h +++ b/src/vt/vrt/collection/balance/greedylb/greedylb_msgs.h @@ -113,17 +113,10 @@ struct GreedyCollectMsg : GreedyLBTypes, collective::ReduceTMsg { : collective::ReduceTMsg(GreedyPayload{in_load,in_profile}) { } - #if greedylb_use_parserdes - template - void parserdes(SerializerT& s) { - s & load_; - } - #else - template - void serialize(SerializerT& s) { - ReduceTMsg::invokeSerialize(s); - } - #endif + template + void serialize(SerializerT& s) { + ReduceTMsg::invokeSerialize(s); + } ObjSampleType const& getLoad() const { return collective::ReduceTMsg::getConstVal().getSample(); diff --git a/src/vt/vrt/collection/balance/hierarchicallb/hierlb_msgs.h b/src/vt/vrt/collection/balance/hierarchicallb/hierlb_msgs.h index fa0deb77d1..ea74254c03 100644 --- a/src/vt/vrt/collection/balance/hierarchicallb/hierlb_msgs.h +++ b/src/vt/vrt/collection/balance/hierarchicallb/hierlb_msgs.h @@ -65,17 +65,10 @@ struct LBTreeUpMsg : HierLBTypes, ::vt::Message { { } - #if hierlb_use_parserdes - template - void parserdes(SerializerT& s) { - s & load_; - } - #else - template - void serialize(SerializerT& s) { - s | child_load_ | child_ | load_ | child_size_; - } - #endif + template + void serialize(SerializerT& s) { + s | child_load_ | child_ | load_ | child_size_; + } LoadType getChildLoad() const { return child_load_; } NodeType getChild() const { return child_; } @@ -99,18 +92,10 @@ struct LBTreeDownMsg : HierLBTypes, ::vt::Message { ) : from_(in_from), excess_(in_excess), final_child_(in_final_child) { } - - #if hierlb_use_parserdes - template - void parserdes(SerializerT& s) { - s & excess_; - } - #else - template - void serialize(SerializerT& s) { - s | from_ | excess_ | final_child_; - } - #endif + template + void serialize(SerializerT& s) { + s | from_ | excess_ | final_child_; + } NodeType getFrom() const { return from_; } ObjSampleType const& getExcess() const { return excess_; } diff --git a/tests/unit/serialization/test_parserdes.cc b/tests/unit/serialization/test_parserdes.cc deleted file mode 100644 index c28927f83c..0000000000 --- a/tests/unit/serialization/test_parserdes.cc +++ /dev/null @@ -1,281 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// test_parserdes.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 - -#include -#include - -#include -#include - -#include "test_parallel_harness.h" -#include "data_message.h" - -#include "vt/transport.h" - -#define PRINT_DEBUG 0 - -#if backend_check_enabled(parserdes) - -namespace serdes { -template -void parserdes(Serializer& s, std::string& str) { - typename std::string::size_type str_size = str.length(); - s | str_size; - str.resize(str_size); - for (auto&& elm : str) { - s | elm; - } -} -} /* end namespace serdes */ - -namespace vt { namespace tests { namespace unit { - -using namespace vt; -using namespace vt::tests::unit; - -namespace test_data { -struct A : ::vt::Message { - int32_t a,b,c; - std::vector v; - // A() = default; - A(int32_t a,int32_t b,int32_t c,std::vector v) - : ::vt::Message(),a(a),b(b),c(c),v(v) - {} - /* - * This should not be required for parserdes: - */ - // template - // void serialize(Serializer& s) { - // #if PRINT_DEBUG - // ::fmt::print( - // "test_data::A serialize v.size()={}, elm={}\n", - // v.size(), (v.size() == 1 ? v[0] : -1) - // ); - // #endif - // } - template - void parserdes(Serializer& s) { - s & v; - #if PRINT_DEBUG - ::fmt::print( - "test_data::A parserdes v.size()={}, elm={}\n", - v.size(), (v.size() == 1 ? v[0] : -1) - ); - #endif - } - friend std::ostream& operator<<(std::ostream&os, A const& d) { - return os << d.a << "-" << d.b << "-" << d.c - << "," << (d.v.size() == 1 ? d.v[0] : -1); - } - friend bool operator==(A const& c1,A const& c2) { - return c1.a == c2.a && c1.b == c2.b && c1.c == c2.c && c1.v == c2.v; - } -}; -struct B : ::vt::Message { - std::string str; - // B() = default; - B(std::string str_) : ::vt::Message(),str(str_) {} - /* - * This should not be required for parserdes: - */ - // template - // void serialize(Serializer& s) { - // #if PRINT_DEBUG - // ::fmt::print("test_data::B serialize str={}\n", str); - // #endif - // } - template - void parserdes(Serializer& s) { - s & str; - #if PRINT_DEBUG - ::fmt::print("test_data::B parserdes str={}\n", str); - #endif - } - friend std::ostream& operator<<(std::ostream&os, B const& d) { - return os << "\"" << d.str << "\""; - } - friend bool operator==(B const& c1,B const& c2) { - return c1.str == c2.str; - } -}; -struct C : ::vt::Message { - std::string str; - int64_t a; - // C() = default; - C(std::string str,int64_t a) : ::vt::Message(),str(str),a(a) {} - /* - * This should not be required for parserdes: - */ - // template - // void serialize(Serializer& s) {} - template - void parserdes(Serializer& s) { - s & str; - } - friend std::ostream& operator<<(std::ostream&os, C const& d) { - return os << d.str << '-' << d.a; - } - friend bool operator==(C const& c1,C const& c2) { - return c1.str == c2.str && c1.a == c2.a; - } -}; -} /* end namespace test_data */ - -static test_data::A magic_A_t_ = test_data::A{28,2773,12,{32}}; -static test_data::B magic_B_t_ = test_data::B{"the-ultimate-test"}; -static test_data::C magic_C_t_ = test_data::C{"test123",34}; - -struct TestParserdes : TestParallelHarness { - template - static void testHandlerA(MsgT* msg) { - #if PRINT_DEBUG - ::fmt::print("testHandlerA: val={}\n", *msg); - #endif - EXPECT_EQ(*msg, magic_A_t_); - } - template - static void testHandlerB(MsgT* msg) { - #if PRINT_DEBUG - ::fmt::print("testHandlerB: val={}\n", *msg); - #endif - EXPECT_EQ(*msg, magic_B_t_); - } - template - static void testHandlerC(MsgT* msg) { - #if PRINT_DEBUG - ::fmt::print("testHandlerC: val={}\n", *msg); - #endif - EXPECT_EQ(*msg, magic_C_t_); - } -}; - -TEST_F(TestParserdes, test_send_parserdes_a_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto msg = makeSharedMessageSz(sizeof(int32_t), magic_A_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::A sending msg val={}\n", *msg); - #endif - SerializedMessenger::sendParserdesMsg(1, msg); - } - } -} - -TEST_F(TestParserdes, test_send_parserdes_b_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto msg = makeSharedMessageSz(128, magic_B_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::B sending msg val={}\n", *msg); - #endif - SerializedMessenger::sendParserdesMsg(1, msg); - } - } -} - -TEST_F(TestParserdes, test_send_parserdes_c_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto msg = makeSharedMessageSz(8*sizeof(char), magic_C_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::C sending msg val={}\n", *msg); - #endif - SerializedMessenger::sendParserdesMsg(1, msg); - } - } -} - -TEST_F(TestParserdes, test_broadcast_parserdes_a_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto msg = makeSharedMessageSz(sizeof(int32_t), magic_A_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::A broadcasting msg val={}\n", *msg); - #endif - SerializedMessenger::broadcastParserdesMsg(msg); - } - } -} - -TEST_F(TestParserdes, test_broadcast_parserdes_b_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto msg = makeSharedMessageSz(128, magic_B_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::B broadcasting msg val={}\n", *msg); - #endif - SerializedMessenger::broadcastParserdesMsg(msg); - } - } -} - -TEST_F(TestParserdes, test_broadcast_parserdes_c_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto msg = makeSharedMessageSz(8*sizeof(char), magic_C_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::C broadcasting msg val={}\n", *msg); - #endif - SerializedMessenger::broadcastParserdesMsg(msg); - } - } -} - -}}} // end namespace vt::tests::unit - -#endif /*backend_check_enabled(parserdes)*/ diff --git a/tests/unit/serialization/test_parserdes_collection.cc b/tests/unit/serialization/test_parserdes_collection.cc deleted file mode 100644 index abb6cf7c58..0000000000 --- a/tests/unit/serialization/test_parserdes_collection.cc +++ /dev/null @@ -1,282 +0,0 @@ -/* -//@HEADER -// ***************************************************************************** -// -// test_parserdes_collection.cc -// DARMA Toolkit v. 1.0.0 -// DARMA/vt => Virtual Transport -// -// Copyright 2019 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 - -#include -#include - -#include -#include - -#include "test_parallel_harness.h" -#include "data_message.h" - -#include "vt/transport.h" - -#define PRINT_DEBUG 0 - -#if backend_check_enabled(parserdes) - -namespace serdes { -template -void parserdes(Serializer& s, std::string& str) { - typename std::string::size_type str_size = str.length(); - s | str_size; - str.resize(str_size); - for (auto&& elm : str) { - s | elm; - } -} -} /* end namespace serdes */ - -namespace vt { namespace tests { namespace unit { - -using namespace vt; -using namespace vt::tests::unit; - -using TestIndex = ::vt::index::Index1D; - -struct Col : Collection { - Col() = default; -}; - -namespace test_data { -struct A : CollectionMessage { - int32_t a,b,c; - std::vector v; - A(int32_t a,int32_t b,int32_t c,std::vector v) - : CollectionMessage(),a(a),b(b),c(c),v(v) - {} - template - void parserdes(Serializer& s) { - s & v; - #if PRINT_DEBUG - ::fmt::print( - "test_data::A parserdes v.size()={}, elm={}\n", - v.size(), (v.size() == 1 ? v[0] : -1) - ); - #endif - } - friend std::ostream& operator<<(std::ostream&os, A const& d) { - return os << d.a << "-" << d.b << "-" << d.c - << "," << (d.v.size() == 1 ? d.v[0] : -1); - } - friend bool operator==(A const& c1,A const& c2) { - return c1.a == c2.a && c1.b == c2.b && c1.c == c2.c && c1.v == c2.v; - } -}; -struct B : CollectionMessage { - std::string str; - B(std::string str_) : CollectionMessage(),str(str_) {} - template - void parserdes(Serializer& s) { - s & str; - #if PRINT_DEBUG - ::fmt::print("test_data::B parserdes str={}\n", str); - #endif - } - friend std::ostream& operator<<(std::ostream&os, B const& d) { - return os << "\"" << d.str << "\""; - } - friend bool operator==(B const& c1,B const& c2) { - return c1.str == c2.str; - } -}; -struct C : CollectionMessage { - std::string str; - int64_t a; - C(std::string str,int64_t a) : CollectionMessage(),str(str),a(a) {} - template - void parserdes(Serializer& s) { - s & str; - } - friend std::ostream& operator<<(std::ostream&os, C const& d) { - return os << d.str << '-' << d.a; - } - friend bool operator==(C const& c1,C const& c2) { - return c1.str == c2.str && c1.a == c2.a; - } -}; -} /* end namespace test_data */ - -static test_data::A magic_A_t_ = test_data::A{28,2773,12,{32}}; -static test_data::B magic_B_t_ = test_data::B{"the-ultimate-test"}; -static test_data::C magic_C_t_ = test_data::C{"test123",34}; - -struct TestParserdes : TestParallelHarness { - template - static void testHandlerA(MsgT* msg, Col* col) { - #if PRINT_DEBUG - ::fmt::print("testHandlerA: val={}\n", *msg); - #endif - EXPECT_EQ(*msg, magic_A_t_); - } - template - static void testHandlerB(MsgT* msg, Col* col) { - #if PRINT_DEBUG - ::fmt::print("testHandlerB: val={}\n", *msg); - #endif - EXPECT_EQ(*msg, magic_B_t_); - } - template - static void testHandlerC(MsgT* msg, Col* col) { - #if PRINT_DEBUG - ::fmt::print("testHandlerC: val={}\n", *msg); - #endif - EXPECT_EQ(*msg, magic_C_t_); - } -}; - -TEST_F(TestParserdes, test_collection_send_parserdes_a_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto const& col_size = 32; - auto range = TestIndex(col_size); - auto proxy = theCollection()->construct(range); - auto msg = makeMessageSz(8*sizeof(char), magic_A_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::A sending msg to collection val={}\n", *msg); - #endif - for (int i = 0; i < col_size; i++) { - proxy[i].send(msg.get()); - } - } - } -} - -TEST_F(TestParserdes, test_collection_send_parserdes_b_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto const& col_size = 32; - auto range = TestIndex(col_size); - auto proxy = theCollection()->construct(range); - auto msg = makeMessageSz(8*sizeof(char), magic_B_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::B sending msg to collection val={}\n", *msg); - #endif - for (int i = 0; i < col_size; i++) { - proxy[i].send(msg.get()); - } - } - } -} - -TEST_F(TestParserdes, test_collection_send_parserdes_c_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto const& col_size = 32; - auto range = TestIndex(col_size); - auto proxy = theCollection()->construct(range); - auto msg = makeMessageSz(8*sizeof(char), magic_C_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::C sending msg to collection val={}\n", *msg); - #endif - for (int i = 0; i < col_size; i++) { - proxy[i].send(msg.get()); - } - } - } -} - -TEST_F(TestParserdes, test_collection_broadcast_parserdes_a_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto const& col_size = 32; - auto range = TestIndex(col_size); - auto proxy = theCollection()->construct(range); - auto msg = makeMessageSz(8*sizeof(char), magic_A_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::A sending msg to collection val={}\n", *msg); - #endif - proxy.broadcast(msg.get()); - } - } -} - -TEST_F(TestParserdes, test_collection_broadcast_parserdes_b_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto const& col_size = 32; - auto range = TestIndex(col_size); - auto proxy = theCollection()->construct(range); - auto msg = makeMessageSz(8*sizeof(char), magic_B_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::B sending msg to collection val={}\n", *msg); - #endif - proxy.broadcast(msg.get()); - } - } -} - -TEST_F(TestParserdes, test_collection_broadcast_parserdes_c_1) { - auto const& my_node = theContext()->getNode(); - - if (theContext()->getNumNodes() > 1) { - if (my_node == 0) { - auto const& col_size = 32; - auto range = TestIndex(col_size); - auto proxy = theCollection()->construct(range); - auto msg = makeMessageSz(8*sizeof(char), magic_C_t_); - #if PRINT_DEBUG - ::fmt::print("test_data::C sending msg to collection val={}\n", *msg); - #endif - proxy.broadcast(msg.get()); - } - } -} - -}}} // end namespace vt::tests::unit - -#endif /*backend_check_enabled(parserdes)*/ diff --git a/tests/unit/serialization/test_serialize_messenger.cc b/tests/unit/serialization/test_serialize_messenger.cc index 3a8b0405f4..ca28117646 100644 --- a/tests/unit/serialization/test_serialize_messenger.cc +++ b/tests/unit/serialization/test_serialize_messenger.cc @@ -155,8 +155,6 @@ TEST_F(TestSerialMessenger, test_serial_messenger_bcast_1) { } } - -#if HAS_SERIALIZATION_LIBRARY TEST_F(TestSerialMessenger, test_serial_messenger_2) { auto const& my_node = theContext()->getNode(); @@ -168,6 +166,5 @@ TEST_F(TestSerialMessenger, test_serial_messenger_2) { } } } -#endif }}} // end namespace vt::tests::unit From 251609a0fff0b3a19c4773b19e04296e48e1dbe7 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 12 May 2020 09:19:48 -0700 Subject: [PATCH 82/88] CI: update with new CI support from develop --- ci/Brewfile | 3 + ci/build_cpp.sh | 129 +++++++++ ci/clean_cpp.sh | 14 + ci/docker/alpine-cpp.dockerfile | 46 ++++ ci/docker/ubuntu-18.04-clang-cpp.dockerfile | 85 ++++++ ci/docker/ubuntu-18.04-gnu-cpp.dockerfile | 88 ++++++ ci/docker/ubuntu-18.04-gnu-docs.dockerfile | 65 +++++ ci/docker/ubuntu-18.04-nvidia-cpp.dockerfile | 61 +++++ ci/docker/ubuntu-20.04-clang-cpp.dockerfile | 85 ++++++ ci/docker/ubuntu-20.04-gnu-cpp.dockerfile | 61 +++++ ci/test_cpp.sh | 14 + docker-compose.yml | 265 +++++++++++++++++++ 12 files changed, 916 insertions(+) create mode 100644 ci/Brewfile create mode 100755 ci/build_cpp.sh create mode 100755 ci/clean_cpp.sh create mode 100644 ci/docker/alpine-cpp.dockerfile create mode 100644 ci/docker/ubuntu-18.04-clang-cpp.dockerfile create mode 100644 ci/docker/ubuntu-18.04-gnu-cpp.dockerfile create mode 100644 ci/docker/ubuntu-18.04-gnu-docs.dockerfile create mode 100644 ci/docker/ubuntu-18.04-nvidia-cpp.dockerfile create mode 100644 ci/docker/ubuntu-20.04-clang-cpp.dockerfile create mode 100644 ci/docker/ubuntu-20.04-gnu-cpp.dockerfile create mode 100755 ci/test_cpp.sh create mode 100644 docker-compose.yml diff --git a/ci/Brewfile b/ci/Brewfile new file mode 100644 index 0000000000..e03f25135a --- /dev/null +++ b/ci/Brewfile @@ -0,0 +1,3 @@ +brew "ccache" +brew "ninja" +brew "mpich" diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh new file mode 100755 index 0000000000..dad6040c75 --- /dev/null +++ b/ci/build_cpp.sh @@ -0,0 +1,129 @@ +#!/usr/bin/env bash + +set -ex + +source_dir=${1} +build_dir=${2} + +if test "${VT_DOXYGEN_ENABLED:-0}" -eq 1 +then + token=${3} +else + target=${3:-install} +fi + +echo -e "===\n=== ccache statistics before build\n===" +ccache -s + +mkdir -p "${build_dir}" +pushd "${build_dir}" + +if test -d "detector" +then + rm -Rf detector +fi + +if test -d "checkpoint" +then + rm -Rf checkpoint +fi + +git clone -b release-1.10.0 --depth 1 https://github.com/google/googletest.git +export GTEST=$PWD/googletest +export GTEST_BUILD=${build_dir}/googletest +mkdir -p "$GTEST_BUILD" +cd "$GTEST_BUILD" +mkdir build +cd build +cmake -G "${CMAKE_GENERATOR:-Ninja}" \ + -DCMAKE_INSTALL_PREFIX="$GTEST_BUILD/install" \ + "$GTEST" +cmake --build . --target install + +export GTEST_ROOT="$GTEST_BUILD/install" + + +if test -d "${source_dir}/lib/detector" +then + echo "Detector already in lib... not downloading, building, and installing" +else + git clone -b master --depth 1 https://github.com/DARMA-tasking/detector.git + export DETECTOR=$PWD/detector + export DETECTOR_BUILD=${build_dir}/detector + mkdir -p "$DETECTOR_BUILD" + cd "$DETECTOR_BUILD" + mkdir build + cd build + cmake -G "${CMAKE_GENERATOR:-Ninja}" \ + -DCMAKE_INSTALL_PREFIX="$DETECTOR_BUILD/install" \ + "$DETECTOR" + cmake --build . --target install +fi + +if test -d "${source_dir}/lib/checkpoint" +then + echo "Checkpoint already in lib... not downloading, building, and installing" +else + git clone -b develop --depth 1 https://github.com/DARMA-tasking/checkpoint.git + export CHECKPOINT=$PWD/checkpoint + export CHECKPOINT_BUILD=${build_dir}/checkpoint + mkdir -p "$CHECKPOINT_BUILD" + cd "$CHECKPOINT_BUILD" + mkdir build + cd build + cmake -G "${CMAKE_GENERATOR:-Ninja}" \ + -DCMAKE_INSTALL_PREFIX="$CHECKPOINT_BUILD/install" \ + -Ddetector_DIR="$DETECTOR_BUILD/install" \ + "$CHECKPOINT" + cmake --build . --target install +fi + +export VT=${source_dir} +export VT_BUILD=${build_dir}/vt +mkdir -p "$VT_BUILD" +cd "$VT_BUILD" +rm -Rf ./* +cmake -G "${CMAKE_GENERATOR:-Ninja}" \ + -Dvt_test_trace_runtime_enabled="${VT_TRACE_RUNTIME_ENABLED:-0}" \ + -Dvt_lb_enabled="${VT_LB_ENABLED:-1}" \ + -Dvt_trace_enabled="${VT_TRACE_ENABLED:-0}" \ + -Dvt_doxygen_enabled="${VT_DOXYGEN_ENABLED:-0}" \ + -Dvt_mimalloc_enabled="${VT_MIMALLOC_ENABLED:-0}" \ + -Dvt_asan_enabled="${VT_ASAN_ENABLED:-0}" \ + -Dvt_pool_enabled="${VT_POOL_ENABLED:-1}" \ + -DMI_INTERPOSE:BOOL=ON \ + -DMI_OVERRIDE:BOOL=ON \ + -DMPI_EXTRA_FLAGS="${MPI_EXTRA_FLAGS:-}" \ + -DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" \ + -DMPI_C_COMPILER="${MPICC:-mpicc}" \ + -DMPI_CXX_COMPILER="${MPICXX:-mpicxx}" \ + -DCMAKE_CXX_COMPILER="${CXX:-c++}" \ + -DCMAKE_C_COMPILER="${CC:-cc}" \ + -DCMAKE_EXE_LINKER_FLAGS="${CMAKE_EXE_LINKER_FLAGS:-}" \ + -Ddetector_DIR="$DETECTOR_BUILD/install" \ + -Dcheckpoint_DIR="$CHECKPOINT_BUILD/install" \ + -DCMAKE_PREFIX_PATH="${CMAKE_PREFIX_PATH:-}" \ + -DCMAKE_INSTALL_PREFIX="$VT_BUILD/install" \ + "$VT" + +if test "${VT_DOXYGEN_ENABLED:-0}" -eq 1 +then + MCSS=$PWD/m.css + GHPAGE=$PWD/DARMA-tasking.github.io + git clone "https://${token}@github.com/DARMA-tasking/DARMA-tasking.github.io" + git clone https://github.com/mosra/m.css + + "$MCSS/documentation/doxygen.py" Doxyfile-mcss + cp -R docs "$GHPAGE" + cd "$GHPAGE" + git config --global user.email "jliffla@sandia.gov" + git config --global user.name "Jonathan Lifflander" + git add docs + git commit -m "Update docs (auto-build)" + git push origin master +else + time cmake --build . --target "${target}" +fi + +echo -e "===\n=== ccache statistics after build\n===" +ccache -s diff --git a/ci/clean_cpp.sh b/ci/clean_cpp.sh new file mode 100755 index 0000000000..a152ac6257 --- /dev/null +++ b/ci/clean_cpp.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -ex + +source_dir=${1} +build_dir=${2} + +export VT=${source_dir} +export VT_BUILD=${build_dir}/vt +pushd "$VT_BUILD" + +cmake --build . --target clean + +popd diff --git a/ci/docker/alpine-cpp.dockerfile b/ci/docker/alpine-cpp.dockerfile new file mode 100644 index 0000000000..d23b4dcf2f --- /dev/null +++ b/ci/docker/alpine-cpp.dockerfile @@ -0,0 +1,46 @@ + +ARG arch=amd64 +FROM lifflander1/vt:alpine-final as base + +ARG proxy="" +ARG compiler=clang + +ENV https_proxy=${proxy} \ + http_proxy=${proxy} + +RUN source "$HOME/.bashrc" && \ + source /usr/share/spack/share/spack/setup-env.sh && \ + spack env activate clang-mpich + +ENV CMAKE_EXE_LINKER_FLAGS="-lexecinfo" \ + CC=mpicc \ + CXX=mpicxx \ + PATH=/usr/lib/ccache/:$PATH \ + PATH=/usr/share/spack/var/spack/environments/clang-mpich/.spack-env/view/bin/:$PATH + +FROM base as build +COPY . /vt + +ARG VT_LB_ENABLED +ARG VT_TRACE_ENABLED +ARG VT_TRACE_RUNTIME_ENABLED +ARG VT_MIMALLOC_ENABLED +ARG VT_DOXYGEN_ENABLED +ARG VT_ASAN_ENABLED +ARG VT_POOL_ENABLED +ARG CMAKE_BUILD_TYPE + +ENV VT_LB_ENABLED=${VT_LB_ENABLED} \ + VT_TRACE_ENABLED=${VT_TRACE_ENABLED} \ + VT_MIMALLOC_ENABLED=${VT_MIMALLOC_ENABLED} \ + VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \ + VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \ + VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \ + VT_POOL_ENABLED=${VT_POOL_ENABLED} \ + CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + +RUN /vt/ci/build_cpp.sh /vt /build +COPY /build/ /build + +FROM build as test +RUN /vt/ci/test_cpp.sh /vt /build diff --git a/ci/docker/ubuntu-18.04-clang-cpp.dockerfile b/ci/docker/ubuntu-18.04-clang-cpp.dockerfile new file mode 100644 index 0000000000..e0dc7d01f9 --- /dev/null +++ b/ci/docker/ubuntu-18.04-clang-cpp.dockerfile @@ -0,0 +1,85 @@ + +ARG arch=amd64 +FROM ${arch}/ubuntu:18.04 as base + +ARG proxy="" +ARG compiler=clang-7 + +ENV https_proxy=${proxy} \ + http_proxy=${proxy} + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -y -q && \ + apt-get install -y -q --no-install-recommends \ + ca-certificates \ + curl \ + cmake \ + git \ + wget \ + ${compiler} \ + zlib1g \ + zlib1g-dev \ + ninja-build \ + valgrind \ + make-guile \ + libomp5 \ + ccache && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN ln -s \ + "$(which $(echo ${compiler} | cut -d- -f1)++-$(echo ${compiler} | cut -d- -f2))" \ + /usr/bin/clang++ + +ENV CC=${compiler} \ + CXX=clang++ + +RUN wget http://www.mpich.org/static/downloads/3.3.2/mpich-3.3.2.tar.gz && \ + tar xzf mpich-3.3.2.tar.gz && \ + rm mpich-3.3.2.tar.gz && \ + cd mpich-3.3.2 && \ + ./configure \ + --enable-static=false \ + --enable-alloca=true \ + --disable-long-double \ + --enable-threads=single \ + --enable-fortran=no \ + --enable-fast=all \ + --enable-g=none \ + --enable-timing=none && \ + make -j4 && \ + make install && \ + cd - && \ + rm -rf mpich-3.3.2 + +ENV MPI_EXTRA_FLAGS="" \ + CMAKE_PREFIX_PATH="/lib/x86_64-linux-gnu/" \ + PATH=/usr/lib/ccache/:$PATH \ + CMAKE_EXE_LINKER_FLAGS="-pthread" + +FROM base as build +COPY . /vt + +ARG VT_LB_ENABLED +ARG VT_TRACE_ENABLED +ARG VT_TRACE_RUNTIME_ENABLED +ARG VT_MIMALLOC_ENABLED +ARG VT_DOXYGEN_ENABLED +ARG VT_ASAN_ENABLED +ARG VT_POOL_ENABLED +ARG CMAKE_BUILD_TYPE + +ENV VT_LB_ENABLED=${VT_LB_ENABLED} \ + VT_TRACE_ENABLED=${VT_TRACE_ENABLED} \ + VT_MIMALLOC_ENABLED=${VT_MIMALLOC_ENABLED} \ + VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \ + VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \ + VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \ + VT_POOL_ENABLED=${VT_POOL_ENABLED} \ + CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + +RUN /vt/ci/build_cpp.sh /vt /build + +FROM build as test +RUN /vt/ci/test_cpp.sh /vt /build diff --git a/ci/docker/ubuntu-18.04-gnu-cpp.dockerfile b/ci/docker/ubuntu-18.04-gnu-cpp.dockerfile new file mode 100644 index 0000000000..20ee4ce11d --- /dev/null +++ b/ci/docker/ubuntu-18.04-gnu-cpp.dockerfile @@ -0,0 +1,88 @@ + +ARG arch=amd64 +FROM ${arch}/ubuntu:18.04 as base + +ARG proxy="" +ARG compiler=gcc-7 + +ENV https_proxy=${proxy} \ + http_proxy=${proxy} + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -y -q && \ + apt-get install -y -q --no-install-recommends \ + g++-$(echo ${compiler} | cut -d- -f2) \ + ca-certificates \ + curl \ + cmake \ + git \ + wget \ + ${compiler} \ + zlib1g \ + zlib1g-dev \ + ninja-build \ + valgrind \ + make-guile \ + libomp5 \ + ccache && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN ln -s \ + "$(which g++-$(echo ${compiler} | cut -d- -f2))" \ + /usr/bin/g++ + +RUN ln -s \ + "$(which gcc-$(echo ${compiler} | cut -d- -f2))" \ + /usr/bin/gcc + +ENV CC=gcc \ + CXX=g++ + +RUN wget http://www.mpich.org/static/downloads/3.3.2/mpich-3.3.2.tar.gz && \ + tar xzf mpich-3.3.2.tar.gz && \ + rm mpich-3.3.2.tar.gz && \ + cd mpich-3.3.2 && \ + ./configure \ + --enable-static=false \ + --enable-alloca=true \ + --disable-long-double \ + --enable-threads=single \ + --enable-fortran=no \ + --enable-fast=all \ + --enable-g=none \ + --enable-timing=none && \ + make -j4 && \ + make install && \ + cd - && \ + rm -rf mpich-3.3.2 + +ENV MPI_EXTRA_FLAGS="" \ + PATH=/usr/lib/ccache/:$PATH + +FROM base as build +COPY . /vt + +ARG VT_LB_ENABLED +ARG VT_TRACE_ENABLED +ARG VT_TRACE_RUNTIME_ENABLED +ARG VT_MIMALLOC_ENABLED +ARG VT_DOXYGEN_ENABLED +ARG VT_ASAN_ENABLED +ARG VT_POOL_ENABLED +ARG CMAKE_BUILD_TYPE + +ENV VT_LB_ENABLED=${VT_LB_ENABLED} \ + VT_TRACE_ENABLED=${VT_TRACE_ENABLED} \ + VT_MIMALLOC_ENABLED=${VT_MIMALLOC_ENABLED} \ + VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \ + VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \ + VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \ + VT_POOL_ENABLED=${VT_POOL_ENABLED} \ + CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + +RUN /vt/ci/build_cpp.sh /vt /build + +FROM build as test +RUN /vt/ci/test_cpp.sh /vt /build diff --git a/ci/docker/ubuntu-18.04-gnu-docs.dockerfile b/ci/docker/ubuntu-18.04-gnu-docs.dockerfile new file mode 100644 index 0000000000..ac7b56bc12 --- /dev/null +++ b/ci/docker/ubuntu-18.04-gnu-docs.dockerfile @@ -0,0 +1,65 @@ + +ARG arch=amd64 +FROM ${arch}/ubuntu:18.04 as base + +ARG proxy="" +ARG compiler=gcc-7 +ARG token + +ENV https_proxy=${proxy} \ + http_proxy=${proxy} + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -y -q && \ + apt-get install -y -q --no-install-recommends \ + ca-certificates \ + curl \ + cmake \ + git \ + mpich \ + libmpich-dev \ + wget \ + ${compiler} \ + zlib1g \ + zlib1g-dev \ + ninja-build \ + doxygen \ + python3 \ + python3-jinja2 \ + python3-pygments \ + texlive-font-utils \ + ghostscript \ + ccache && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +ENV MPI_EXTRA_FLAGS="" \ + CMAKE_PREFIX_PATH="/lib/x86_64-linux-gnu/" \ + CC=mpicc \ + CXX=mpicxx \ + PATH=/usr/lib/ccache/:$PATH + +FROM base as build +COPY . /vt + +ARG token +ARG VT_LB_ENABLED +ARG VT_TRACE_ENABLED +ARG VT_TRACE_RUNTIME_ENABLED +ARG VT_MIMALLOC_ENABLED +ARG VT_DOXYGEN_ENABLED +ARG VT_ASAN_ENABLED +ARG VT_POOL_ENABLED +ARG CMAKE_BUILD_TYPE + +ENV VT_LB_ENABLED=${VT_LB_ENABLED} \ + VT_TRACE_ENABLED=${VT_TRACE_ENABLED} \ + VT_MIMALLOC_ENABLED=${VT_MIMALLOC_ENABLED} \ + VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \ + VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \ + VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \ + VT_POOL_ENABLED=${VT_POOL_ENABLED} \ + CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + +RUN /vt/ci/build_cpp.sh /vt /build "${token}" diff --git a/ci/docker/ubuntu-18.04-nvidia-cpp.dockerfile b/ci/docker/ubuntu-18.04-nvidia-cpp.dockerfile new file mode 100644 index 0000000000..86a6f050cf --- /dev/null +++ b/ci/docker/ubuntu-18.04-nvidia-cpp.dockerfile @@ -0,0 +1,61 @@ + +ARG cuda=10.1 +FROM nvidia/cuda:${cuda}-devel-ubuntu18.04 as base + +ARG proxy="" +ARG compiler=gcc-7 + +ENV https_proxy=${proxy} \ + http_proxy=${proxy} + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -y -q && \ + apt-get install -y -q --no-install-recommends \ + ca-certificates \ + curl \ + cmake \ + git \ + mpich \ + libmpich-dev \ + wget \ + ${compiler} \ + zlib1g \ + zlib1g-dev \ + ninja-build \ + valgrind \ + ccache && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +ENV MPI_EXTRA_FLAGS="" \ + CMAKE_PREFIX_PATH="/lib/x86_64-linux-gnu/" \ + CC=nvcc \ + CXX=nvcc \ + PATH=/usr/lib/ccache/:$PATH + +FROM base as build +COPY . /vt + +ARG VT_LB_ENABLED +ARG VT_TRACE_ENABLED +ARG VT_TRACE_RUNTIME_ENABLED +ARG VT_MIMALLOC_ENABLED +ARG VT_DOXYGEN_ENABLED +ARG VT_ASAN_ENABLED +ARG VT_POOL_ENABLED +ARG CMAKE_BUILD_TYPE + +ENV VT_LB_ENABLED=${VT_LB_ENABLED} \ + VT_TRACE_ENABLED=${VT_TRACE_ENABLED} \ + VT_MIMALLOC_ENABLED=${VT_MIMALLOC_ENABLED} \ + VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \ + VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \ + VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \ + VT_POOL_ENABLED=${VT_POOL_ENABLED} \ + CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + +RUN /vt/ci/build_cpp.sh /vt /build + +FROM build as test +RUN /vt/ci/test_cpp.sh /vt /build diff --git a/ci/docker/ubuntu-20.04-clang-cpp.dockerfile b/ci/docker/ubuntu-20.04-clang-cpp.dockerfile new file mode 100644 index 0000000000..0f470f171b --- /dev/null +++ b/ci/docker/ubuntu-20.04-clang-cpp.dockerfile @@ -0,0 +1,85 @@ + +ARG arch=amd64 +FROM ${arch}/ubuntu:20.04 as base + +ARG proxy="" +ARG compiler=clang-10 + +ENV https_proxy=${proxy} \ + http_proxy=${proxy} + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -y -q && \ + apt-get install -y -q --no-install-recommends \ + ca-certificates \ + curl \ + cmake \ + git \ + wget \ + ${compiler} \ + zlib1g \ + zlib1g-dev \ + ninja-build \ + valgrind \ + make-guile \ + libomp5 \ + ccache && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +RUN ln -s \ + "$(which $(echo ${compiler} | cut -d- -f1)++-$(echo ${compiler} | cut -d- -f2))" \ + /usr/bin/clang++ + +ENV CC=${compiler} \ + CXX=clang++ + +RUN wget http://www.mpich.org/static/downloads/3.3.2/mpich-3.3.2.tar.gz && \ + tar xzf mpich-3.3.2.tar.gz && \ + rm mpich-3.3.2.tar.gz && \ + cd mpich-3.3.2 && \ + ./configure \ + --enable-static=false \ + --enable-alloca=true \ + --disable-long-double \ + --enable-threads=single \ + --enable-fortran=no \ + --enable-fast=all \ + --enable-g=none \ + --enable-timing=none && \ + make -j4 && \ + make install && \ + cd - && \ + rm -rf mpich-3.3.2 + +ENV MPI_EXTRA_FLAGS="" \ + CMAKE_PREFIX_PATH="/lib/x86_64-linux-gnu/" \ + PATH=/usr/lib/ccache/:$PATH \ + CMAKE_EXE_LINKER_FLAGS="-pthread" + +FROM base as build +COPY . /vt + +ARG VT_LB_ENABLED +ARG VT_TRACE_ENABLED +ARG VT_TRACE_RUNTIME_ENABLED +ARG VT_MIMALLOC_ENABLED +ARG VT_DOXYGEN_ENABLED +ARG VT_ASAN_ENABLED +ARG VT_POOL_ENABLED +ARG CMAKE_BUILD_TYPE + +ENV VT_LB_ENABLED=${VT_LB_ENABLED} \ + VT_TRACE_ENABLED=${VT_TRACE_ENABLED} \ + VT_MIMALLOC_ENABLED=${VT_MIMALLOC_ENABLED} \ + VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \ + VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \ + VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \ + VT_POOL_ENABLED=${VT_POOL_ENABLED} \ + CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + +RUN /vt/ci/build_cpp.sh /vt /build + +FROM build as test +RUN /vt/ci/test_cpp.sh /vt /build diff --git a/ci/docker/ubuntu-20.04-gnu-cpp.dockerfile b/ci/docker/ubuntu-20.04-gnu-cpp.dockerfile new file mode 100644 index 0000000000..643049caa4 --- /dev/null +++ b/ci/docker/ubuntu-20.04-gnu-cpp.dockerfile @@ -0,0 +1,61 @@ + +ARG arch=amd64 +FROM ${arch}/ubuntu:20.04 + +ARG proxy="" +ARG compiler=gcc-9 + +ENV https_proxy=${proxy} \ + http_proxy=${proxy} + +ENV DEBIAN_FRONTEND=noninteractive + +RUN apt-get update -y -q && \ + apt-get install -y -q --no-install-recommends \ + ca-certificates \ + curl \ + cmake \ + git \ + mpich \ + libmpich-dev \ + wget \ + ${compiler} \ + zlib1g \ + zlib1g-dev \ + ninja-build \ + valgrind \ + ccache && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +ENV MPI_EXTRA_FLAGS="" \ + CMAKE_PREFIX_PATH="/lib/x86_64-linux-gnu/" \ + CC=mpicc \ + CXX=mpicxx \ + PATH=/usr/lib/ccache/:$PATH + +FROM base as build +COPY . /vt + +ARG VT_LB_ENABLED +ARG VT_TRACE_ENABLED +ARG VT_TRACE_RUNTIME_ENABLED +ARG VT_MIMALLOC_ENABLED +ARG VT_DOXYGEN_ENABLED +ARG VT_ASAN_ENABLED +ARG VT_POOL_ENABLED +ARG CMAKE_BUILD_TYPE + +ENV VT_LB_ENABLED=${VT_LB_ENABLED} \ + VT_TRACE_ENABLED=${VT_TRACE_ENABLED} \ + VT_MIMALLOC_ENABLED=${VT_MIMALLOC_ENABLED} \ + VT_DOXYGEN_ENABLED=${VT_DOXYGEN_ENABLED} \ + VT_TRACE_RUNTIME_ENABLED=${VT_TRACE_RUNTIME} \ + VT_ASAN_ENABLED=${VT_ASAN_ENABLED} \ + VT_POOL_ENABLED=${VT_POOL_ENABLED} \ + CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} + +RUN /vt/ci/build_cpp.sh /vt /build + +FROM build as test +RUN /vt/ci/test_cpp.sh /vt /build diff --git a/ci/test_cpp.sh b/ci/test_cpp.sh new file mode 100755 index 0000000000..93afad5074 --- /dev/null +++ b/ci/test_cpp.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -ex + +source_dir=${1} +build_dir=${2} + +export VT=${source_dir} +export VT_BUILD=${build_dir}/vt +pushd "$VT_BUILD" + +ctest --output-on-failure | tee cmake-output.log + +popd diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000000..94d812a5d7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,265 @@ + +# +# Usage: +# ------ +# +# This docker compose file parameterizes build configurations using environment +# variables from the host. The default values for the build configuration +# variables are set in `.env`. +# +# Variables: +# ARCH={amd64, arm64v8, ...} +# COMPILER_TYPE={gnu, clang} +# COMPILER={gcc-5, gcc-6, gcc-7, gcc-8, gcc-9, gcc-10, +# clang-3.9, clang-4.0, clang-5.0, clang-6.0, clang-7, clang-8, +# clang-9, clang-10} +# REPO=lifflander1/vt +# UBUNTU={18.04, 20.04} +# ULIMIT_CORE=0 +# +# DARMA/vt Configuration Variables: +# VT_LB=1 # Enable load balancing +# VT_TRACE=0 # Enable tracing +# VT_MIMALLOC=0 # Enable mimalloc memory allocator +# VT_DOCS=0 # Enable doxygen build +# VT_TRACE_RT=0 # Enable tracing at runtime (for testing) +# VT_ASAN=0 # Enable address sanitizer +# BUILD_TYPE=release # CMake build type +# +# Examples: +# +# $ COMPILER=gcc-8 docker-compose build ubuntu-cpp +# $ COMPILER=gcc-8 docker-compose run ubuntu-cpp +# + +# Need verision >= 3.5 for the features in use +version: '3.5' + +# Named volumes must be predefined according the docker compose rules. Many +# combinations have already been added, but if a needed configuration is missing +# add it to this list. For example, for ARM64v8 on Ubuntu 20.04 with clang-9, +# add `arm64v8-ubuntu-20.04-clang-9-cache`. +volumes: + amd64-ubuntu-18.04-clang-3.9-cache: + amd64-ubuntu-18.04-clang-4.0-cache: + amd64-ubuntu-18.04-clang-5.0-cache: + amd64-ubuntu-18.04-clang-6.0-cache: + amd64-ubuntu-18.04-clang-7-cache: + amd64-ubuntu-18.04-clang-8-cache: + amd64-ubuntu-18.04-clang-9-cache: + amd64-ubuntu-20.04-clang-10-cache: + amd64-ubuntu-18.04-gcc-5-cache: + amd64-ubuntu-18.04-gcc-6-cache: + amd64-ubuntu-18.04-gcc-7-cache: + amd64-ubuntu-18.04-gcc-8-cache: + amd64-ubuntu-20.04-gcc-9-cache: + amd64-ubuntu-20.04-gcc-10-cache: + amd64-alpine-clang-3.9-cache: + amd64-alpine-clang-4.0-cache: + amd64-alpine-clang-5.0-cache: + amd64-alpine-clang-6.0-cache: + amd64-alpine-clang-7-cache: + amd64-alpine-clang-8-cache: + amd64-alpine-clang-9-cache: + amd64-alpine-clang-10-cache: + amd64-alpine-gcc-5-cache: + amd64-alpine-gcc-6-cache: + amd64-alpine-gcc-7-cache: + amd64-alpine-gcc-8-cache: + amd64-alpine-gcc-9-cache: + amd64-alpine-gcc-10-cache: + arm64v8-ubuntu-18.04-gcc-7-cache: + arm64v8-alpine-gcc-7-cache: + +# Define basic rules for ccache used across multiple services. The beauty of +# docker compose with cached volumes is that similarily configured builds will +# reuse a ccache volume making build speeds much faster than a fresh build each +# time. +x-ccache: &ccache + CCACHE_COMPILERCHECK: content + CCACHE_COMPRESS: 1 + CCACHE_COMPRESSLEVEL: 5 + CCACHE_MAXSIZE: 5G + CCACHE_DIR: /build/ccache + +# Define rules for VT configuration options across various services +x-vtopts: &vtopts + VT_LB_ENABLED: ${VT_LB:-1} + VT_TRACE_ENABLED: ${VT_TRACE:-0} + VT_MIMALLOC_ENABLED: ${VT_MIMALLOC:-0} + VT_DOXYGEN_ENABLED: ${VT_DOCS:-0} + VT_TRACE_RUNTIME_ENABLED: ${VT_TRACE_RT:-0} + VT_ASAN_ENABLED: ${VT_ASAN:-0} + VT_POOL_ENABLED: ${VT_POOL:-1} + CMAKE_BUILD_TYPE: ${BUILD_TYPE:-release} + https_proxy: ${PROXY-} + http_proxy: ${PROXY-} + +services: + ############################################################################## + # C++ builds of VT on ubuntu/alpine platform from container baseline + # Ubuntu gcc-7 debug build: + # docker-compose run -e CMAKE_BUILD_TYPE=debug ubuntu-cpp|alpine-cpp + ubuntu-cpp: + image: ${REPO}:${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-cpp + build: + context: . + target: base + dockerfile: ci/docker/ubuntu-${UBUNTU}-${COMPILER_TYPE}-cpp.dockerfile + cache_from: + - ${REPO}:${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-cpp + args: &default-args + arch: ${ARCH} + proxy: ${PROXY} + compiler: ${COMPILER} + ulimits: &ulimits + core: ${ULIMIT_CORE} + environment: + <<: *ccache + <<: *vtopts + volumes: &ubuntu-volumes + - .:/vt:delegated + - ${CACHE}${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-cache:/build:delegated + command: &vt-cpp-command > + /bin/bash -c " + /vt/ci/build_cpp.sh /vt /build && + /vt/ci/test_cpp.sh /vt /build" + + ############################################################################## + # C++ build/test/clean target for VT on ubuntu platform from container + # baseline. + # + # Example: + # docker-compose run ubuntu-cpp-clean + ubuntu-cpp-clean: + image: ${REPO}:${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-cpp + build: + context: . + target: base + dockerfile: ci/docker/ubuntu-${UBUNTU}-${COMPILER_TYPE}-cpp.dockerfile + cache_from: + - ${REPO}:${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-cpp + args: *default-args + ulimits: *ulimits + environment: + <<: *ccache + <<: *vtopts + volumes: *ubuntu-volumes + command: &vt-build-test-clean-cpp-command > + /bin/bash -c " + /vt/ci/build_cpp.sh /vt /build && + /vt/ci/test_cpp.sh /vt /build && + /vt/ci/clean_cpp.sh /vt /build" + + ############################################################################## + # Interactive C++ setup of VT on ubuntu platform from container baseline. + # + # After running: + # docker-compose run ubuntu-cpp-interactive + # + # You will get a command line where you can run the build command: + # $ /vt/ci/build_cpp.sh /vt /build + # $ /vt/ci/test_cpp.sh /vt /build + ubuntu-cpp-interactive: + image: ${REPO}:${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-cpp + build: + context: . + target: base + dockerfile: ci/docker/ubuntu-${UBUNTU}-${COMPILER_TYPE}-cpp.dockerfile + cache_from: + - ${REPO}:${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-cpp + args: *default-args + ulimits: *ulimits + environment: + <<: *ccache + <<: *vtopts + volumes: *ubuntu-volumes + + ############################################################################## + # Build C++ container with VT installed in the container on ubuntu platform + # from container baseline. + ubuntu-vt: + image: ${REPO}:vt-${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-cpp + build: + context: . + target: build + dockerfile: ci/docker/ubuntu-${UBUNTU}-${COMPILER_TYPE}-cpp.dockerfile + cache_from: + - ${REPO}:${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-cpp + args: + <<: *default-args + <<: *vtopts + ulimits: *ulimits + environment: + <<: *ccache + <<: *vtopts + volumes: *ubuntu-volumes + command: &cpp-command > + /bin/bash -c " + /vt/ci/test_cpp.sh /vt /build" + + ############################################################################## + # Build documentation for VT in the container on ubuntu platform from + # container baseline. + ubuntu-docs: + image: ${REPO}:${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-docs + build: + context: . + target: base + dockerfile: ci/docker/ubuntu-${UBUNTU}-${COMPILER_TYPE}-docs.dockerfile + cache_from: + - ${REPO}:${ARCH}-ubuntu-${UBUNTU}-${COMPILER}-cpp + args: + <<: *default-args + token: ${TOKEN} + ulimits: *ulimits + environment: + <<: *ccache + VT_LB_ENABLED: ${VT_LB:-1} + VT_TRACE_ENABLED: ${VT_TRACE:-1} + VT_DOXYGEN_ENABLED: 1 + CMAKE_BUILD_TYPE: ${BUILD_TYPE:-release} + volumes: *ubuntu-volumes + command: &docs-cpp-command > + /bin/bash -c " + /vt/ci/build_cpp.sh /vt /build ${TOKEN}" + + ############################################################################## + # C++ build of VT within an alpine linux container (limited to clang + # compilers) + alpine-cpp: + image: ${REPO}:${ARCH}-alpine-${COMPILER}-cpp + build: + context: . + target: base + dockerfile: ci/docker/alpine-cpp.dockerfile + cache_from: + - ${REPO}:${ARCH}-alpine-${COMPILER}-cpp + args: *default-args + ulimits: *ulimits + environment: + <<: *ccache + <<: *vtopts + volumes: &alpine-volumes + - .:/vt:delegated + - ${CACHE}${ARCH}-alpine-${COMPILER}-cache:/build:delegated + command: *vt-cpp-command + + ############################################################################## + # C++ build/test/clean target for VT on alpine platform from container + # baseline. + alpine-cpp-clean: + image: ${REPO}:${ARCH}-alpine-${COMPILER}-cpp + build: + context: . + target: base + dockerfile: ci/docker/alpine-cpp.dockerfile + cache_from: + - ${REPO}:${ARCH}-alpine-${COMPILER}-cpp + args: *default-args + ulimits: *ulimits + environment: + <<: *ccache + <<: *vtopts + volumes: *alpine-volumes + command: *vt-build-test-clean-cpp-command From b1c28b551044fa2d65bf9418d3e91aa13ca6a97a Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 12 May 2020 09:53:48 -0700 Subject: [PATCH 83/88] CI: add github workflow --- .github/workflows/build-docs.yml | 35 +++++++++ .../dockerimage-clang-3.9-ubuntu-mpich.yml | 77 +++++++++++++++++++ .../dockerimage-clang-5.0-ubuntu-mpich.yml | 77 +++++++++++++++++++ .../dockerimage-clang-8-alpine-mpich.yml | 62 ++++++++++++++- .../dockerimage-gcc-5-ubuntu-mpich.yml | 69 ++++++++++++++++- .../dockerimage-gcc-6-ubuntu-mpich.yml | 77 +++++++++++++++++++ .../dockerimage-gcc-7-ubuntu-mpich.yml | 76 ++++++++++++++++++ .../dockerimage-gcc-8-ubuntu-mpich.yml | 77 +++++++++++++++++++ .github/workflows/macosx-clang-mpich.yml | 42 ++++++++++ .github/workflows/pushdockerimage.yml | 2 +- 10 files changed, 587 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/build-docs.yml create mode 100644 .github/workflows/dockerimage-clang-3.9-ubuntu-mpich.yml create mode 100644 .github/workflows/dockerimage-clang-5.0-ubuntu-mpich.yml create mode 100644 .github/workflows/dockerimage-gcc-6-ubuntu-mpich.yml create mode 100644 .github/workflows/dockerimage-gcc-7-ubuntu-mpich.yml create mode 100644 .github/workflows/dockerimage-gcc-8-ubuntu-mpich.yml create mode 100644 .github/workflows/macosx-clang-mpich.yml diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml new file mode 100644 index 0000000000..0e52e1b74a --- /dev/null +++ b/.github/workflows/build-docs.yml @@ -0,0 +1,35 @@ +name: Build Documentation + +on: + # Trigger the workflow on push or pull request, + # but only for the master branch + push: + branches: + - develop + +jobs: + + build: + + runs-on: ubuntu-latest + + env: + REPO: lifflander1/vt + ARCH: amd64 + UBUNTU: 18.04 + COMPILER_TYPE: gnu + COMPILER: gcc-5 + BUILD_TYPE: release + ULIMIT_CORE: 0 + VT_LB: 1 + VT_TRACE: 1 + VT_TRACE_RT: 0 + VT_MIMALLOC: 0 + VT_DOCS: 1 + VT_ASAN: 0 + TOKEN: ${{ secrets.GH_PAT }} + + steps: + - uses: actions/checkout@v2 + - name: Build the Docker image + run: docker-compose run ubuntu-docs diff --git a/.github/workflows/dockerimage-clang-3.9-ubuntu-mpich.yml b/.github/workflows/dockerimage-clang-3.9-ubuntu-mpich.yml new file mode 100644 index 0000000000..bc835d2f77 --- /dev/null +++ b/.github/workflows/dockerimage-clang-3.9-ubuntu-mpich.yml @@ -0,0 +1,77 @@ +name: PR tests (clang-3.9, ubuntu, mpich) + +# Trigger the workflow on push or pull request +on: + push: + branches: + - develop + - 1.* + pull_request: + +jobs: + + build: + + runs-on: ubuntu-latest + + env: + REPO: lifflander1/vt + ARCH: amd64 + UBUNTU: 18.04 + COMPILER_TYPE: clang + COMPILER: clang-3.9 + BUILD_TYPE: release + ULIMIT_CORE: 0 + VT_LB: 1 + VT_TRACE: 0 + VT_TRACE_RT: 0 + VT_MIMALLOC: 0 + VT_DOCS: 0 + VT_ASAN: 0 + CACHE: ~/.local/cache/ + + steps: + - name: Setup Build Root + uses: allenevans/set-env@v1.0.0 + with: + BUILD_ROOT: "~/.local/cache/${{ env.ARCH }}-ubuntu-${{ env.UBUNTU }}-${{ env.COMPILER }}-cache/" + - name: Prepare caching timestamp + id: cache_ts + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - uses: actions/cache@v1 + env: + cache-name: ubuntu-clang-3.9-cache + with: + path: ${{ env.BUILD_ROOT }}/ccache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.cache_ts.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}- + - uses: actions/checkout@v2 + - name: Docker Pull Base Image + shell: bash + run: docker-compose pull --ignore-pull-failures ubuntu-cpp-clean + - name: Build the Docker image + run: docker-compose run ubuntu-cpp-clean + - name: Docker Push Base Image + if: success() + continue-on-error: true + shell: bash + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} \ + -p ${{ secrets.DOCKER_PASSWORD }} + docker-compose push ubuntu-cpp-clean + - name: Zip up CMake output + run: | + zip -j LastTest.log.gz ${{ env.BUILD_ROOT }}/vt/Testing/Temporary/LastTest.log + zip -j cmake-output.log.gz ${{ env.BUILD_ROOT }}/vt/cmake-output.log + - uses: actions/upload-artifact@v1 + with: + name: CMake test output + path: cmake-output.log.gz + - uses: actions/upload-artifact@v1 + with: + name: CMake full output + path: LastTest.log.gz diff --git a/.github/workflows/dockerimage-clang-5.0-ubuntu-mpich.yml b/.github/workflows/dockerimage-clang-5.0-ubuntu-mpich.yml new file mode 100644 index 0000000000..c0a7c2ec5c --- /dev/null +++ b/.github/workflows/dockerimage-clang-5.0-ubuntu-mpich.yml @@ -0,0 +1,77 @@ +name: PR tests (clang-5.0, ubuntu, mpich, trace) + +# Trigger the workflow on push or pull request +on: + push: + branches: + - develop + - 1.* + pull_request: + +jobs: + + build: + + runs-on: ubuntu-latest + + env: + REPO: lifflander1/vt + ARCH: amd64 + UBUNTU: 18.04 + COMPILER_TYPE: clang + COMPILER: clang-5.0 + BUILD_TYPE: release + ULIMIT_CORE: 0 + VT_LB: 1 + VT_TRACE: 1 + VT_TRACE_RT: 0 + VT_MIMALLOC: 0 + VT_DOCS: 0 + VT_ASAN: 0 + CACHE: ~/.local/cache/ + + steps: + - name: Setup Build Root + uses: allenevans/set-env@v1.0.0 + with: + BUILD_ROOT: "~/.local/cache/${{ env.ARCH }}-ubuntu-${{ env.UBUNTU }}-${{ env.COMPILER }}-cache/" + - name: Prepare caching timestamp + id: cache_ts + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - uses: actions/cache@v1 + env: + cache-name: ubuntu-clang-5.0-cache + with: + path: ${{ env.BUILD_ROOT }}/ccache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.cache_ts.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}- + - uses: actions/checkout@v2 + - name: Docker Pull Base Image + shell: bash + run: docker-compose pull --ignore-pull-failures ubuntu-cpp-clean + - name: Build the Docker image + run: docker-compose run ubuntu-cpp-clean + - name: Docker Push Base Image + if: success() + continue-on-error: true + shell: bash + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} \ + -p ${{ secrets.DOCKER_PASSWORD }} + docker-compose push ubuntu-cpp-clean + - name: Zip up CMake output + run: | + zip -j LastTest.log.gz ${{ env.BUILD_ROOT }}/vt/Testing/Temporary/LastTest.log + zip -j cmake-output.log.gz ${{ env.BUILD_ROOT }}/vt/cmake-output.log + - uses: actions/upload-artifact@v1 + with: + name: CMake test output + path: cmake-output.log.gz + - uses: actions/upload-artifact@v1 + with: + name: CMake full output + path: LastTest.log.gz diff --git a/.github/workflows/dockerimage-clang-8-alpine-mpich.yml b/.github/workflows/dockerimage-clang-8-alpine-mpich.yml index e872e150dd..59262f1295 100644 --- a/.github/workflows/dockerimage-clang-8-alpine-mpich.yml +++ b/.github/workflows/dockerimage-clang-8-alpine-mpich.yml @@ -1,4 +1,4 @@ -name: PR tests (alpine, clang-8, mpich) +name: PR tests (clang-8, alpine, mpich) on: [pull_request] @@ -8,7 +8,63 @@ jobs: runs-on: ubuntu-latest + env: + REPO: lifflander1/vt + ARCH: amd64 + COMPILER_TYPE: clang + COMPILER: clang-8 + BUILD_TYPE: release + ULIMIT_CORE: 0 + VT_LB: 1 + VT_TRACE: 0 + VT_TRACE_RT: 0 + VT_MIMALLOC: 0 + VT_DOCS: 0 + VT_ASAN: 0 + CACHE: ~/.local/cache/ + steps: - - uses: actions/checkout@v1 + - name: Setup Build Root + uses: allenevans/set-env@v1.0.0 + with: + BUILD_ROOT: "~/.local/cache/${{ env.ARCH }}-alpine-${{ env.COMPILER }}-cache/" + - name: Prepare caching timestamp + id: cache_ts + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - uses: actions/cache@v1 + env: + cache-name: alpine-clang-8-cache + with: + path: ${{ env.BUILD_ROOT }}/ccache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.cache_ts.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}- + - uses: actions/checkout@v2 + - name: Docker Pull Base Image + shell: bash + run: docker-compose pull --ignore-pull-failures alpine-cpp-clean - name: Build the Docker image - run: docker build . --file Dockerfile --build-arg TRACE_ENABLED=0 --build-arg LB_ENABLED=0 --tag vt:$(date +%s) + run: docker-compose run alpine-cpp-clean + - name: Docker Push Base Image + if: success() + continue-on-error: true + shell: bash + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} \ + -p ${{ secrets.DOCKER_PASSWORD }} + docker-compose push alpine-cpp-clean + - name: Zip up CMake output + run: | + zip -j LastTest.log.gz ${{ env.BUILD_ROOT }}/vt/Testing/Temporary/LastTest.log + zip -j cmake-output.log.gz ${{ env.BUILD_ROOT }}/vt/cmake-output.log + - uses: actions/upload-artifact@v1 + with: + name: CMake test output + path: cmake-output.log.gz + - uses: actions/upload-artifact@v1 + with: + name: CMake full output + path: LastTest.log.gz diff --git a/.github/workflows/dockerimage-gcc-5-ubuntu-mpich.yml b/.github/workflows/dockerimage-gcc-5-ubuntu-mpich.yml index 6e24425841..cc83907f81 100644 --- a/.github/workflows/dockerimage-gcc-5-ubuntu-mpich.yml +++ b/.github/workflows/dockerimage-gcc-5-ubuntu-mpich.yml @@ -1,6 +1,12 @@ name: PR tests (gcc-5, ubuntu, mpich) -on: [pull_request] +# Trigger the workflow on push or pull request +on: + push: + branches: + - develop + - 1.* + pull_request: jobs: @@ -8,7 +14,64 @@ jobs: runs-on: ubuntu-latest + env: + REPO: lifflander1/vt + ARCH: amd64 + UBUNTU: 18.04 + COMPILER_TYPE: gnu + COMPILER: gcc-5 + BUILD_TYPE: release + ULIMIT_CORE: 0 + VT_LB: 1 + VT_TRACE: 0 + VT_TRACE_RT: 0 + VT_MIMALLOC: 0 + VT_DOCS: 0 + VT_ASAN: 0 + CACHE: ~/.local/cache/ + steps: - - uses: actions/checkout@v1 + - name: Setup Build Root + uses: allenevans/set-env@v1.0.0 + with: + BUILD_ROOT: "~/.local/cache/${{ env.ARCH }}-ubuntu-${{ env.UBUNTU }}-${{ env.COMPILER }}-cache/" + - name: Prepare caching timestamp + id: cache_ts + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - uses: actions/cache@v1 + env: + cache-name: ubuntu-gcc-5-cache + with: + path: ${{ env.BUILD_ROOT }}/ccache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.cache_ts.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}- + - uses: actions/checkout@v2 + - name: Docker Pull Base Image + shell: bash + run: docker-compose pull --ignore-pull-failures ubuntu-cpp-clean - name: Build the Docker image - run: docker build . --file Dockerfile-ubuntu --tag vt:$(date +%s) + run: docker-compose run ubuntu-cpp-clean + - name: Docker Push Base Image + if: success() + continue-on-error: true + shell: bash + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} \ + -p ${{ secrets.DOCKER_PASSWORD }} + docker-compose push ubuntu-cpp-clean + - name: Zip up CMake output + run: | + zip -j LastTest.log.gz ${{ env.BUILD_ROOT }}/vt/Testing/Temporary/LastTest.log + zip -j cmake-output.log.gz ${{ env.BUILD_ROOT }}/vt/cmake-output.log + - uses: actions/upload-artifact@v1 + with: + name: CMake test output + path: cmake-output.log.gz + - uses: actions/upload-artifact@v1 + with: + name: CMake full output + path: LastTest.log.gz diff --git a/.github/workflows/dockerimage-gcc-6-ubuntu-mpich.yml b/.github/workflows/dockerimage-gcc-6-ubuntu-mpich.yml new file mode 100644 index 0000000000..fc1aa72b73 --- /dev/null +++ b/.github/workflows/dockerimage-gcc-6-ubuntu-mpich.yml @@ -0,0 +1,77 @@ +name: PR tests (gcc-6, ubuntu, mpich) + +# Trigger the workflow on push or pull request +on: + push: + branches: + - develop + - 1.* + pull_request: + +jobs: + + build: + + runs-on: ubuntu-latest + + env: + REPO: lifflander1/vt + ARCH: amd64 + UBUNTU: 18.04 + COMPILER_TYPE: gnu + COMPILER: gcc-6 + BUILD_TYPE: release + ULIMIT_CORE: 0 + VT_LB: 1 + VT_TRACE: 0 + VT_TRACE_RT: 0 + VT_MIMALLOC: 0 + VT_DOCS: 0 + VT_ASAN: 0 + CACHE: ~/.local/cache/ + + steps: + - name: Setup Build Root + uses: allenevans/set-env@v1.0.0 + with: + BUILD_ROOT: "~/.local/cache/${{ env.ARCH }}-ubuntu-${{ env.UBUNTU }}-${{ env.COMPILER }}-cache/" + - name: Prepare caching timestamp + id: cache_ts + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - uses: actions/cache@v1 + env: + cache-name: ubuntu-gcc-6-cache + with: + path: ${{ env.BUILD_ROOT }}/ccache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.cache_ts.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}- + - uses: actions/checkout@v2 + - name: Docker Pull Base Image + shell: bash + run: docker-compose pull --ignore-pull-failures ubuntu-cpp-clean + - name: Build the Docker image + run: docker-compose run ubuntu-cpp-clean + - name: Docker Push Base Image + if: success() + continue-on-error: true + shell: bash + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} \ + -p ${{ secrets.DOCKER_PASSWORD }} + docker-compose push ubuntu-cpp-clean + - name: Zip up CMake output + run: | + zip -j LastTest.log.gz ${{ env.BUILD_ROOT }}/vt/Testing/Temporary/LastTest.log + zip -j cmake-output.log.gz ${{ env.BUILD_ROOT }}/vt/cmake-output.log + - uses: actions/upload-artifact@v1 + with: + name: CMake test output + path: cmake-output.log.gz + - uses: actions/upload-artifact@v1 + with: + name: CMake full output + path: LastTest.log.gz diff --git a/.github/workflows/dockerimage-gcc-7-ubuntu-mpich.yml b/.github/workflows/dockerimage-gcc-7-ubuntu-mpich.yml new file mode 100644 index 0000000000..5e00b71282 --- /dev/null +++ b/.github/workflows/dockerimage-gcc-7-ubuntu-mpich.yml @@ -0,0 +1,76 @@ +name: PR tests (gcc-7, ubuntu, mpich, trace runtime, LB) + +on: + push: + branches: + - develop + - 1.* + pull_request: + +jobs: + + build: + + runs-on: ubuntu-latest + + env: + REPO: lifflander1/vt + ARCH: amd64 + UBUNTU: 18.04 + COMPILER_TYPE: gnu + COMPILER: gcc-7 + BUILD_TYPE: release + ULIMIT_CORE: 0 + VT_LB: 1 + VT_TRACE: 1 + VT_TRACE_RT: 1 + VT_MIMALLOC: 0 + VT_DOCS: 0 + VT_ASAN: 0 + CACHE: ~/.local/cache/ + + steps: + - name: Setup Build Root + uses: allenevans/set-env@v1.0.0 + with: + BUILD_ROOT: "~/.local/cache/${{ env.ARCH }}-ubuntu-${{ env.UBUNTU }}-${{ env.COMPILER }}-cache/" + - name: Prepare caching timestamp + id: cache_ts + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - uses: actions/cache@v1 + env: + cache-name: ubuntu-gcc-7-cache + with: + path: ${{ env.BUILD_ROOT }}/ccache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.cache_ts.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}- + - uses: actions/checkout@v2 + - name: Docker Pull Base Image + shell: bash + run: docker-compose pull --ignore-pull-failures ubuntu-cpp-clean + - name: Build the Docker image + run: docker-compose run ubuntu-cpp-clean + - name: Docker Push Base Image + if: success() + continue-on-error: true + shell: bash + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} \ + -p ${{ secrets.DOCKER_PASSWORD }} + docker-compose push ubuntu-cpp-clean + - name: Zip up CMake output + run: | + zip -j LastTest.log.gz ${{ env.BUILD_ROOT }}/vt/Testing/Temporary/LastTest.log + zip -j cmake-output.log.gz ${{ env.BUILD_ROOT }}/vt/cmake-output.log + - uses: actions/upload-artifact@v1 + with: + name: CMake test output + path: cmake-output.log.gz + - uses: actions/upload-artifact@v1 + with: + name: CMake full output + path: LastTest.log.gz diff --git a/.github/workflows/dockerimage-gcc-8-ubuntu-mpich.yml b/.github/workflows/dockerimage-gcc-8-ubuntu-mpich.yml new file mode 100644 index 0000000000..8f7f5a2f93 --- /dev/null +++ b/.github/workflows/dockerimage-gcc-8-ubuntu-mpich.yml @@ -0,0 +1,77 @@ +name: PR tests (gcc-8, ubuntu, mpich, address sanitizer) + +on: + push: + branches: + - develop + - 1.* + pull_request: + +jobs: + + build: + + runs-on: ubuntu-latest + + env: + REPO: lifflander1/vt + ARCH: amd64 + UBUNTU: 18.04 + COMPILER_TYPE: gnu + COMPILER: gcc-8 + BUILD_TYPE: release + ULIMIT_CORE: 0 + VT_LB: 1 + VT_TRACE: 1 + VT_TRACE_RT: 0 + VT_MIMALLOC: 0 + VT_DOCS: 0 + VT_ASAN: 1 + VT_POOL: 0 + CACHE: ~/.local/cache/ + + steps: + - name: Setup Build Root + uses: allenevans/set-env@v1.0.0 + with: + BUILD_ROOT: "~/.local/cache/${{ env.ARCH }}-ubuntu-${{ env.UBUNTU }}-${{ env.COMPILER }}-cache/" + - name: Prepare caching timestamp + id: cache_ts + shell: cmake -P {0} + run: | + string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC) + message("::set-output name=timestamp::${current_date}") + - uses: actions/cache@v1 + env: + cache-name: ubuntu-gcc-8-cache + with: + path: ${{ env.BUILD_ROOT }}/ccache + key: ${{ runner.os }}-${{ env.cache-name }}-${{ steps.cache_ts.outputs.timestamp }} + restore-keys: | + ${{ runner.os }}-${{ env.cache-name }}- + - uses: actions/checkout@v2 + - name: Docker Pull Base Image + shell: bash + run: docker-compose pull --ignore-pull-failures ubuntu-cpp-clean + - name: Build the Docker image + run: docker-compose run ubuntu-cpp-clean + - name: Docker Push Base Image + if: success() + continue-on-error: true + shell: bash + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} \ + -p ${{ secrets.DOCKER_PASSWORD }} + docker-compose push ubuntu-cpp-clean + - name: Zip up CMake output + run: | + zip -j LastTest.log.gz ${{ env.BUILD_ROOT }}/vt/Testing/Temporary/LastTest.log + zip -j cmake-output.log.gz ${{ env.BUILD_ROOT }}/vt/cmake-output.log + - uses: actions/upload-artifact@v1 + with: + name: CMake test output + path: cmake-output.log.gz + - uses: actions/upload-artifact@v1 + with: + name: CMake full output + path: LastTest.log.gz diff --git a/.github/workflows/macosx-clang-mpich.yml b/.github/workflows/macosx-clang-mpich.yml new file mode 100644 index 0000000000..33fd24bd31 --- /dev/null +++ b/.github/workflows/macosx-clang-mpich.yml @@ -0,0 +1,42 @@ +name: PR tests (clang-8, macosx, mpich) + +# Trigger the workflow on push or pull request +on: + push: + branches: + - develop + - 1.* + pull_request: + +jobs: + + build: + + runs-on: macos-10.15 + + strategy: + fail-fast: false + + env: + CMAKE_BUILD_TYPE: release + VT_LB_ENABLED: 1 + VT_TRACE_ENABLED: 1 + + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v1 + with: + path: ~/.ccache + key: ${{ runner.os }}-macosx-clang-8-ccache-${{ hashFiles('**/*') }} + restore-keys: | + ${{ runner.os }}-macosx-clang-8-ccache- + - name: Install Dependencies + shell: bash + run: brew bundle --file=ci/Brewfile + - name: Build + shell: bash + run: ci/build_cpp.sh $(pwd) $(pwd)/build + - name: Test + shell: bash + run: | + ci/test_cpp.sh $(pwd) $(pwd)/build diff --git a/.github/workflows/pushdockerimage.yml b/.github/workflows/pushdockerimage.yml index f86e429d6c..c007177c38 100644 --- a/.github/workflows/pushdockerimage.yml +++ b/.github/workflows/pushdockerimage.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Docker Build & Push uses: jerray/publish-docker-action@master with: From 9a1cbe3b35dcd9b5c388b93287d132e9412af16d Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 12 May 2020 10:28:28 -0700 Subject: [PATCH 84/88] CI: use correct version of gtest --- ci/build_cpp.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ci/build_cpp.sh b/ci/build_cpp.sh index dad6040c75..61e6ea7bc6 100755 --- a/ci/build_cpp.sh +++ b/ci/build_cpp.sh @@ -28,7 +28,12 @@ then rm -Rf checkpoint fi -git clone -b release-1.10.0 --depth 1 https://github.com/google/googletest.git +if test -d "googletest" +then + rm -Rf googletest +fi + +git clone -b release-1.8.1 --depth 1 https://github.com/google/googletest.git export GTEST=$PWD/googletest export GTEST_BUILD=${build_dir}/googletest mkdir -p "$GTEST_BUILD" From aa5db5bbbb4babefe9927795dea435d6ef1120fb Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 12 May 2020 12:28:07 -0700 Subject: [PATCH 85/88] build: fix segfault when backtrace doesn't work --- src/vt/collective/basic.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vt/collective/basic.cc b/src/vt/collective/basic.cc index 98aa76fe94..1118dbee56 100644 --- a/src/vt/collective/basic.cc +++ b/src/vt/collective/basic.cc @@ -61,7 +61,7 @@ void output( } int rerror(char const* str) { - vt::output(std::string(str)); + fmt::print(std::string(str) + "\n"); vt::finalize(); return 0; } From 3ee7d163b5f6c93309deacf174ef1e70200309f3 Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 12 May 2020 12:40:48 -0700 Subject: [PATCH 86/88] build: some more adjustements to make CI match develop --- .env | 6 ++ ...kerimage-clang-8-alpine-mpich-trace-lb.yml | 14 ---- Dockerfile | 63 +-------------- Dockerfile-ubuntu | 78 ------------------- 4 files changed, 7 insertions(+), 154 deletions(-) create mode 100644 .env delete mode 100644 .github/workflows/dockerimage-clang-8-alpine-mpich-trace-lb.yml mode change 100644 => 120000 Dockerfile delete mode 100644 Dockerfile-ubuntu diff --git a/.env b/.env new file mode 100644 index 0000000000..b756b40623 --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +REPO=lifflander1/vt +ARCH=amd64 +UBUNTU=18.04 +ULIMIT_CORE=0 +COMPILER=gcc-7 +COMPILER_TYPE=gnu diff --git a/.github/workflows/dockerimage-clang-8-alpine-mpich-trace-lb.yml b/.github/workflows/dockerimage-clang-8-alpine-mpich-trace-lb.yml deleted file mode 100644 index 8c3fd62bee..0000000000 --- a/.github/workflows/dockerimage-clang-8-alpine-mpich-trace-lb.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: PR tests (alpine, clang-8, mpich, trace, LB) - -on: [pull_request] - -jobs: - - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v1 - - name: Build the Docker image - run: docker build . --file Dockerfile --build-arg TRACE_ENABLED=1 --build-arg LB_ENABLED=1 --tag vt:$(date +%s) diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index c703e2952d..0000000000 --- a/Dockerfile +++ /dev/null @@ -1,62 +0,0 @@ -FROM lifflander1/vt:alpine-final -MAINTAINER Jonathan Lifflander - -COPY . /usr/src/vt/ - -WORKDIR /usr/src - -ARG LB_ENABLED -ARG TRACE_ENABLED - -RUN /bin/bash -c 'source $HOME/.bashrc && \ - source /usr/share/spack/share/spack/setup-env.sh && \ - spack env activate clang-mpich && \ - ls /usr/src/vt && \ - export CC=clang && \ - export CXX=clang++ && \ - echo $HTTP_PROXY && \ - echo $HTTPS_PROXY && \ - echo $ALL_PROXY && \ - echo $http_proxy && \ - echo $https_proxy && \ - echo $all_proxy && \ - unset https_proxy && \ - unset http_proxy && \ - unset all_proxy && \ - unset HTTPS_PROXY && \ - unset HTTP_PROXY && \ - unset ALL_PROXY && \ - if [ -d "detector" ]; then rm -Rf detector; fi && \ - if [ -d "checkpoint" ]; then rm -Rf checkpoint; fi && \ - git clone -b develop --depth 1 https://github.com/DARMA-tasking/checkpoint.git && \ - export CHECKPOINT=$PWD/checkpoint && \ - export CHECKPOINT_BUILD=/usr/build/checkpoint && \ - git clone -b master --depth 1 https://github.com/DARMA-tasking/detector.git && \ - export DETECTOR=$PWD/detector && \ - export DETECTOR_BUILD=/usr/build/detector && \ - export VT=/usr/src/vt && \ - export VT_BUILD=/usr/build/vt && \ - echo $SOURCE_COMMIT && \ - cd $DETECTOR_BUILD && \ - mkdir build && \ - cd build && \ - cmake -DCMAKE_INSTALL_PREFIX=$DETECTOR_BUILD/install -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_C_COMPILER=$CC $DETECTOR && \ - make && \ - make install && \ - cd $CHECKPOINT_BUILD && \ - mkdir build && \ - cd build && \ - cmake -DCMAKE_INSTALL_PREFIX=$CHECKPOINT_BUILD/install -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_C_COMPILER=$CC -Ddetector_DIR=$DETECTOR_BUILD/install $CHECKPOINT && \ - make && \ - make install && \ - cd $VT_BUILD && \ - mkdir build && \ - cd build && \ - cmake -GNinja -Dvt_lb_enabled=$LB_ENABLED -Dvt_trace_enabled=$TRACE_ENABLED -DCMAKE_INSTALL_PREFIX=$VT_BUILD/install -DCMAKE_EXE_LINKER_FLAGS=-lexecinfo -DCMAKE_BUILD_TYPE=release -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_C_COMPILER=$CC -Ddetector_DIR=$DETECTOR_BUILD/install -Dcheckpoint_DIR=$CHECKPOINT_BUILD/install $VT && \ - ninja && \ - ninja install && \ - ninja test || ctest -V' - -COPY $DETECTOR_BUILD/ $DETECTOR_BUILD -COPY $CHECKPOINT_BUILD/ $CHECKPOINT_BUILD -COPY $VT_BUILD/ $VT_BUILD diff --git a/Dockerfile b/Dockerfile new file mode 120000 index 0000000000..82a5b091bb --- /dev/null +++ b/Dockerfile @@ -0,0 +1 @@ +ci/docker/ubuntu-18.04-gnu-cpp.dockerfile \ No newline at end of file diff --git a/Dockerfile-ubuntu b/Dockerfile-ubuntu deleted file mode 100644 index 383ef3f998..0000000000 --- a/Dockerfile-ubuntu +++ /dev/null @@ -1,78 +0,0 @@ -FROM ubuntu:18.04 -MAINTAINER Jonathan Lifflander - -RUN apt-get update && apt-get install -y \ - curl \ - cmake \ - git \ - googletest \ - libmpich-dev \ - wget \ - gcc-5 \ - zlib1g \ - zlib1g-dev \ - libopenmpi-dev \ - ninja-build - -COPY . /usr/src/vt/ - -WORKDIR /usr/src - -ARG LB_ENABLED -ARG TRACE_ENABLED - -RUN \ - dpkg -L zlib1g && \ - export CC=mpicc && \ - export CXX=mpicxx && \ - if [ -d "googletest" ]; then rm -Rf googletest; fi && \ - if [ -d "detector" ]; then rm -Rf detector; fi && \ - if [ -d "checkpoint" ]; then rm -Rf checkpoint; fi && \ - git clone -b release-1.8.1 --depth 1 https://github.com/google/googletest.git && \ - export GTEST=$PWD/googletest && \ - export GTEST_BUILD=/usr/build/googletest && \ - git clone -b develop --depth 1 https://github.com/DARMA-tasking/checkpoint.git && \ - export CHECKPOINT=$PWD/checkpoint && \ - export CHECKPOINT_BUILD=/usr/build/checkpoint && \ - git clone -b master --depth 1 https://github.com/DARMA-tasking/detector.git && \ - export DETECTOR=$PWD/detector && \ - export DETECTOR_BUILD=/usr/build/detector && \ - export VT=$PWD/vt && \ - export VT_BUILD=/usr/build/vt && \ - mkdir -p $DETECTOR_BUILD && \ - mkdir -p $GTEST_BUILD && \ - mkdir -p $VT_BUILD && \ - mkdir -p $CHECKPOINT_BUILD && \ - echo $SOURCE_COMMIT && \ - cd $GTEST_BUILD && \ - mkdir build && \ - cd build && \ - cmake -DCMAKE_INSTALL_PREFIX=$GTEST_BUILD/install -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_C_COMPILER=$CC $GTEST && \ - make && \ - make install && \ - cd $DETECTOR_BUILD && \ - mkdir build && \ - cd build && \ - cmake -DCMAKE_INSTALL_PREFIX=$DETECTOR_BUILD/install -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_C_COMPILER=$CC $DETECTOR && \ - make && \ - make install && \ - cd $CHECKPOINT_BUILD && \ - mkdir build && \ - cd build && \ - cmake -DCMAKE_INSTALL_PREFIX=$CHECKPOINT_BUILD/install -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_C_COMPILER=$CC -Ddetector_DIR=$DETECTOR_BUILD/install $CHECKPOINT && \ - make && \ - make install && \ - cd $VT_BUILD && \ - mkdir build && \ - cd build && \ - uname -p && \ - uname && \ - cmake -GNinja -Dvt_lb_enabled=$LB_ENABLED -Dvt_trace_enabled=$TRACE_ENABLED -DMPI_EXTRA_FLAGS=--allow-run-as-root -DVT_NO_BUILD_EXAMPLES=1 -Dgtest_DIR=$GTEST_BUILD/install -DGTEST_ROOT=$GTEST_BUILD/install -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_C_COMPILER=$CC -DMPI_C_COMPILER=mpicc -DMPI_CXX_COMPILER=mpicxx -Ddetector_DIR=$DETECTOR_BUILD/install -DCMAKE_PREFIX_PATH="$GTEST_BUILD/install;/lib/x86_64-linux-gnu/" -Dcheckpoint_DIR=$CHECKPOINT_BUILD/install $VT && \ - ninja && \ - ninja install && \ - ninja test - -COPY $DETECTOR_BUILD/ $DETECTOR_BUILD -COPY $CHECKPOINT_BUILD/ $CHECKPOINT_BUILD -COPY $VT_BUILD/ $VT_BUILD -COPY $GTEST_BUILD/ $GTEST_BUILD From 8e38d749db9dbd8e06a6e8aa48574f5aae95050f Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 12 May 2020 15:41:48 -0700 Subject: [PATCH 87/88] #814: build: include vt in cmake_config.h path to avoid ambiguity --- cmake/define_build_types.cmake | 6 +++--- src/vt/configs/debug/debug_masterconfig.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/define_build_types.cmake b/cmake/define_build_types.cmake index 06a7b8c9af..6f11274160 100644 --- a/cmake/define_build_types.cmake +++ b/cmake/define_build_types.cmake @@ -184,13 +184,13 @@ foreach(loop_build_type ${VT_CONFIG_TYPES}) # put the config file in a subdirectory corresponding to the lower case build name configure_file( ${PROJECT_BASE_DIR}/cmake_config.h.in - ${PROJECT_BIN_DIR}/${loop_build_type}/cmake_config.h @ONLY + ${PROJECT_BIN_DIR}/${loop_build_type}/vt/cmake_config.h @ONLY ) # install the correct config file when this build is selected install( - FILES "${PROJECT_BINARY_DIR}/${loop_build_type}/cmake_config.h" - DESTINATION include + FILES "${PROJECT_BINARY_DIR}/${loop_build_type}/vt/cmake_config.h" + DESTINATION include/vt CONFIGURATIONS ${loop_build_type} ) diff --git a/src/vt/configs/debug/debug_masterconfig.h b/src/vt/configs/debug/debug_masterconfig.h index e012717ba3..e2c8f35d65 100644 --- a/src/vt/configs/debug/debug_masterconfig.h +++ b/src/vt/configs/debug/debug_masterconfig.h @@ -45,7 +45,7 @@ #if !defined INCLUDED_VT_CONFIGS_DEBUG_DEBUG_MASTERCONFIG_H #define INCLUDED_VT_CONFIGS_DEBUG_DEBUG_MASTERCONFIG_H -#include +#include /* * Define the compile-time configuration options. Eventually this will be From 0058470b313e3065bdb147dc853c6f2de515c40e Mon Sep 17 00:00:00 2001 From: Jonathan Lifflander Date: Tue, 12 May 2020 17:54:24 -0700 Subject: [PATCH 88/88] util: work around bug causing crash in EMPIRE startup --- src/vt/utils/mpi_limits/mpi_max_tag.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/vt/utils/mpi_limits/mpi_max_tag.cc b/src/vt/utils/mpi_limits/mpi_max_tag.cc index 04e08012cd..edc190d2d0 100644 --- a/src/vt/utils/mpi_limits/mpi_max_tag.cc +++ b/src/vt/utils/mpi_limits/mpi_max_tag.cc @@ -55,8 +55,7 @@ namespace vt { namespace util { namespace mpi_limits { void* p = nullptr; int flag = 0; - auto comm = theContext()->getComm(); - MPI_Comm_get_attr(comm, MPI_TAG_UB, &p, &flag); + MPI_Comm_get_attr(MPI_COMM_WORLD, MPI_TAG_UB, &p, &flag); if (not flag) { vtAbort("Failed to obtain MPI_TAG_UB attribute");