Skip to content

Commit

Permalink
Merge pull request #3236 from STEllAR-GROUP/fixing_3226
Browse files Browse the repository at this point in the history
Fixing memory_block
  • Loading branch information
msimberg committed Mar 14, 2018
2 parents 86e53e6 + bc77492 commit 1f121ec
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
39 changes: 39 additions & 0 deletions hpx/runtime/components/server/memory_block.hpp
Expand Up @@ -11,6 +11,7 @@
#include <hpx/runtime/actions/component_action.hpp>
#include <hpx/runtime/actions/manage_object_action.hpp>
#include <hpx/runtime/components/component_type.hpp>
#include <hpx/runtime/components/server/destroy_component.hpp>
#include <hpx/runtime/components/server/managed_component_base.hpp>
#include <hpx/runtime/components/server/wrapper_heap.hpp>
#include <hpx/runtime/components/server/wrapper_heap_list.hpp>
Expand Down Expand Up @@ -454,6 +455,7 @@ namespace hpx { namespace components { namespace server
public:
typedef detail::memory_block_header wrapped_type;
typedef memory_block type_holder;
typedef memory_block base_type_holder;

/// \brief Construct an empty managed_component
memory_block()
Expand Down Expand Up @@ -499,6 +501,7 @@ namespace hpx { namespace components { namespace server
component_.reset(p);
}

public:
/// \brief finalize() will be called just before the instance gets
/// destructed
///
Expand Down Expand Up @@ -704,6 +707,42 @@ namespace hpx { namespace components { namespace server
return wrapper_->get_base_gid();
}
}

template <>
inline void destroy<memory_block>(
naming::gid_type const& gid, naming::address const& addr)
{
// make sure this component is located here
components::component_type type =
components::get_component_type<memory_block>();
if (get_locality() != addr.locality_)
{
std::ostringstream strm;
strm << "global id " << gid << " should not have been migrated "
"instance of type: memory_block";
HPX_THROW_EXCEPTION(hpx::unknown_component_address,
"destroy<memory_block>", strm.str());
return;
}

// make sure it's the correct component type
if (!types_are_compatible(type, addr.type_))
{
std::ostringstream strm;
strm << "global id " << gid << " is not bound to a component "
"instance of type: " << get_component_type_name(type)
<< " (it is bound to a " << get_component_type_name(addr.type_)
<< ")";
HPX_THROW_EXCEPTION(hpx::unknown_component_address,
"destroy<memory_block>", strm.str());
return;
}

--instance_count(type);

// delete the local instances
memory_block::destroy(reinterpret_cast<memory_block*>(addr.address_));
}
}}}

namespace hpx { namespace traits
Expand Down
15 changes: 14 additions & 1 deletion src/runtime/agas/server/primary_namespace_server.cpp
Expand Up @@ -1084,9 +1084,22 @@ void primary_namespace::free_components_sync(
HPX_ASSERT(e.locality_ == e.gva_.prefix);
naming::address addr(e.locality_, e.gva_.type, e.gva_.lva());
if (e.locality_ == locality_)
components::deleter(e.gva_.type)(e.gid_, std::move(addr));
{
auto deleter = components::deleter(e.gva_.type);
if (deleter == nullptr)
{
HPX_THROWS_IF(ec, internal_server_error,
"primary_namespace::free_components_sync",
"Attempting to delete object of unknown component type: "
+ std::to_string(e.gva_.type));
return;
}
deleter(e.gid_, std::move(addr));
}
else
{
components::server::destroy_component(e.gid_, addr);
}
}

if (&ec != &throws)
Expand Down
6 changes: 6 additions & 0 deletions src/runtime/components/server/memory_block.cpp
Expand Up @@ -5,6 +5,7 @@

#include <hpx/config.hpp>
#include <hpx/runtime/components/component_factory.hpp>
#include <hpx/runtime/components/component_registry.hpp>
#include <hpx/runtime/components/server/memory_block.hpp>
#include <hpx/runtime/actions/continuation.hpp>
#include <hpx/runtime/actions/manage_object_action.hpp>
Expand Down Expand Up @@ -51,6 +52,11 @@ HPX_REGISTER_BASE_LCO_WITH_VALUE_ID(
hpx::actions::base_lco_with_value_hpx_memory_data_get,
hpx::actions::base_lco_with_value_hpx_memory_data_set)

HPX_DEFINE_COMPONENT_NAME(
hpx::components::server::memory_block, component_memory_block);
HPX_REGISTER_MINIMAL_COMPONENT_REGISTRY(
hpx::components::server::memory_block, component_memory_block);

///////////////////////////////////////////////////////////////////////////////
namespace hpx { namespace components { namespace server { namespace detail
{
Expand Down
5 changes: 5 additions & 0 deletions src/util/runtime_configuration.cpp
Expand Up @@ -326,6 +326,11 @@ namespace hpx { namespace util
"[hpx.components.elapsed_time_counter]",
"name = hpx",
"path = $[hpx.location]/bin/" HPX_DLL_STRING,
"enabled = 1",

"[hpx.components.component_memory_block]",
"name = hpx",
"path = $[hpx.location]/bin/" HPX_DLL_STRING,
"enabled = 1"
};

Expand Down

0 comments on commit 1f121ec

Please sign in to comment.