Skip to content

Commit

Permalink
Merge pull request #1963 from DARMA-tasking/1899-improve-makerunnable…
Browse files Browse the repository at this point in the history
…-allocation-performance-new-variant

1899 Improve performance of Runnable and surrounding machinery
  • Loading branch information
lifflander authored Sep 27, 2022
2 parents c69e439 + 8568fb7 commit c724cf0
Show file tree
Hide file tree
Showing 51 changed files with 450 additions and 904 deletions.
4 changes: 0 additions & 4 deletions docs/md/registry.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
\page registry Registry
\brief Registered handlers

The registry component `vt::registry::Registry`, accessed via
`vt::theRegistry()` holds type-safe active handlers for execution across a
distributed machine.

- The \ref active-messenger uses the registry to store/dispatch active
function and active functor handlers.
- The \ref objgroup uses the registry to store/dispatch active member
Expand Down
5 changes: 0 additions & 5 deletions src/vt/collective/collective_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -334,11 +334,6 @@ void CollectiveAnyOps<instance>::output(
}
}

template <runtime::RuntimeInstType instance>
HandlerType CollectiveAnyOps<instance>::registerHandler(ActiveClosureFnType fn) {
return theRegistry()->registerActiveHandler(fn);
}

template struct CollectiveAnyOps<collective_default_inst>;

} /* end namespace vt */
3 changes: 0 additions & 3 deletions src/vt/collective/collective_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
#include "vt/config.h"
#include "vt/context/context.h"
#include "vt/runtime/runtime_headers.h"
#include "vt/registry/registry.h"

#include <string>

Expand Down Expand Up @@ -77,8 +76,6 @@ struct CollectiveAnyOps {
bool error = false, bool decorate = true, bool formatted = false,
bool abort_out = false
);

static HandlerType registerHandler(ActiveClosureFnType fn);
};

using CollectiveOps = CollectiveAnyOps<collective_default_inst>;
Expand Down
1 change: 0 additions & 1 deletion src/vt/collective/reduce/reduce.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

#include "vt/config.h"
#include "vt/collective/collective_alg.h"
#include "vt/registry/registry.h"
#include "vt/registry/auto/auto_registry_interface.h"
#include "vt/messaging/active.h"
#include "vt/messaging/message.h"
Expand Down
4 changes: 2 additions & 2 deletions src/vt/context/context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
*/

#include "vt/context/context.h"
#include "vt/context/runnable_context/from_node.h"
#include "vt/context/runnable_context/set_context.h"

#if vt_check_enabled(trace_only)
namespace vt { namespace runnable {
Expand Down Expand Up @@ -111,7 +111,7 @@ void Context::setTask(runnable::RunnableNew* in_task) {
NodeType Context::getFromNodeCurrentTask() const {
#if !vt_check_enabled(trace_only)
if (getTask() != nullptr) {
auto from = getTask()->get<ctx::FromNode>();
auto from = getTask()->get<ctx::SetContext>();
if (from != nullptr) {
return from->get();
}
Expand Down
107 changes: 0 additions & 107 deletions src/vt/context/runnable_context/base.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//@HEADER
// *****************************************************************************
//
// from_node.h
// collection.cc
// DARMA/vt => Virtual Transport
//
// Copyright 2019-2021 National Technology & Engineering Solutions of Sandia, LLC
Expand Down Expand Up @@ -41,41 +41,24 @@
//@HEADER
*/

#if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_FROM_NODE_H
#define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_FROM_NODE_H

#include "vt/context/runnable_context/base.h"
#include "vt/context/runnable_context/collection.h"

namespace vt { namespace ctx {

/**
* \struct FromNode
*
* \brief Get the node that instigated the current task running. Typically the
* logical node that caused an handler or event to run.
*/
struct FromNode final : Base {
void Collection::begin() {
set_();
}

/**
* \brief Construct a \c FromNode
*
* \param[in] in_node the node
*/
explicit FromNode(NodeType const in_node)
: node_(in_node)
{ }
void Collection::end() {
clear_();
}

/**
* \brief Get the node that instigated the current task
*
* \return the node
*/
NodeType get() const { return node_; }
void Collection::suspend() {
end();
}

private:
NodeType node_ = uninitialized_destination; /**< The from node */
};
void Collection::resume() {
begin();
}

}} /* end namespace vt::ctx */

#endif /*INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_FROM_NODE_H*/
20 changes: 11 additions & 9 deletions src/vt/context/runnable_context/collection.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_COLLECTION_H
#define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_COLLECTION_H

#include "vt/context/runnable_context/base.h"
#include <functional>

namespace vt { namespace vrt { namespace collection {

Expand All @@ -61,32 +61,34 @@ namespace vt { namespace ctx {
* \brief Context for a collection element that is running. Includes the index
* and proxy for the collection.
*/
template <typename IndexT>
struct Collection final : Base {
struct Collection {

Collection() = default;

/**
* \brief Construct a \c Collection
*
* \param[in] elm the collection element to extract the index and proxy
*/
template <typename IndexT>
explicit Collection(vrt::collection::Indexable<IndexT>* elm);

/**
* \brief Set the collection context
*/
void begin() final override;
void begin();

/**
* \brief Remove the collection context
*/
void end() final override;
void end();

void suspend() final override;
void resume() final override;
void suspend();
void resume();

private:
IndexT idx_ = {}; /**< the collection element index */
VirtualProxyType proxy_ = no_vrt_proxy; /**< the collection proxy */
std::function<void()> set_; /**< Set context function */
std::function<void()> clear_; /**< Clear context function */
};

}} /* end namespace vt::ctx */
Expand Down
33 changes: 10 additions & 23 deletions src/vt/context/runnable_context/collection.impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,17 @@
namespace vt { namespace ctx {

template <typename IndexT>
/*explicit*/ Collection<IndexT>::Collection(
/*explicit*/ Collection::Collection(
vrt::collection::Indexable<IndexT>* elm
) : idx_(elm->getIndex()),
proxy_(elm->getProxy())
{ }

template <typename IndexT>
void Collection<IndexT>::begin() {
vrt::collection::CollectionContextHolder<IndexT>::set(&idx_, proxy_);
}

template <typename IndexT>
void Collection<IndexT>::end() {
vrt::collection::CollectionContextHolder<IndexT>::clear();
}

template <typename IndexT>
void Collection<IndexT>::suspend() {
end();
}

template <typename IndexT>
void Collection<IndexT>::resume() {
begin();
) {
auto idx_ = elm->getIndex();
auto proxy_ = elm->getProxy();
set_ = [=]{
vrt::collection::CollectionContextHolder<IndexT>::set(&idx_, proxy_);
};
clear_ = []{
vrt::collection::CollectionContextHolder<IndexT>::clear();
};
}

}} /* end namespace vt::ctx */
Expand Down
8 changes: 4 additions & 4 deletions src/vt/context/runnable_context/continuation.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@
#if !defined INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_CONTINUATION_H
#define INCLUDED_VT_CONTEXT_RUNNABLE_CONTEXT_CONTINUATION_H

#include "vt/context/runnable_context/base.h"

namespace vt { namespace ctx {

/**
* \struct Continuation
*
* \brief A continuation that runs after a task is complete.
*/
struct Continuation final : Base {
struct Continuation {

Continuation() = default;

/**
* \brief Construct a \c Continuation
Expand All @@ -67,7 +67,7 @@ struct Continuation final : Base {
/**
* \brief After the task runs, invoke the continuation if non-null
*/
void end() final override {
void end() {
if (cont_) {
cont_();
}
Expand Down
Loading

0 comments on commit c724cf0

Please sign in to comment.