Skip to content

Commit

Permalink
Fixing MPI parcel port issue exposed by #6623
Browse files Browse the repository at this point in the history
  • Loading branch information
hkaiser committed Feb 26, 2025
1 parent 6bdd76e commit 3d42559
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ namespace hpx::parcelset::policies::mpi {
{
if (need_recv_tchunks)
{
util::mpi_environment::scoped_lock l;

request_ = util::mpi_environment::irecv(
buffer_.transmission_chunks_.data(),
buffer_.transmission_chunks_.size() *
Expand Down Expand Up @@ -200,8 +198,6 @@ namespace hpx::parcelset::policies::mpi {
HPX_ASSERT(request_ptr_ == nullptr);

{
util::mpi_environment::scoped_lock l;

ack_ = static_cast<char>(
connection_state::acked_transmission_chunks);
request_ = util::mpi_environment::isend(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,7 @@ namespace hpx::parcelset::policies::mpi {
auto const& chunks = buffer_.transmission_chunks_;
if (!chunks.empty() && !header_.piggy_back_tchunk())
{
request_ = util::mpi_environment::isend(
const_cast<void*>(
reinterpret_cast<const void*>(chunks.data())),
request_ = util::mpi_environment::isend(chunks.data(),
chunks.size() *
sizeof(parcel_buffer_type::transmission_chunk_type),
dst_, tag_);
Expand Down Expand Up @@ -263,8 +261,6 @@ namespace hpx::parcelset::policies::mpi {

if (!header_.piggy_back_data())
{
util::mpi_environment::scoped_lock l;

request_ = util::mpi_environment::isend(
buffer_.data_.data(), buffer_.data_.size(), dst_, tag_);
request_ptr_ = &request_;
Expand Down Expand Up @@ -325,7 +321,7 @@ namespace hpx::parcelset::policies::mpi {
}
HPX_ASSERT(request_ptr_ == nullptr);
request_ = util::mpi_environment::isend(
const_cast<void*>(c.data()), c.size(), dst_, tag_);
c.data(), c.size(), dst_, tag_);
request_ptr_ = &request_;
}

Expand Down
29 changes: 11 additions & 18 deletions libs/full/parcelset/tests/regressions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,9 @@
# Distributed under the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

# Copyright (c) 2024 Hartmut Kaiser
#
# SPDX-License-Identifier: BSL-1.0 Distributed under the Boost Software License,
# Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)

if(HPX_WITH_NETWORKING)
set(tests ${tests} very_big_parcel)
set(tests ${tests} nested_vectors_6623 very_big_parcel)
set(nested_vectors_6623_PARAMETERS LOCALITIES 2)
set(very_big_parcel_PARAMETERS LOCALITIES 2)
endif()

Expand All @@ -29,19 +24,17 @@ foreach(test ${tests})
FOLDER "Tests/Regressions/Modules/Full/Parcelset"
)

# Disable the test due to limited CircleCI resources

# add_hpx_regression_test( "modules.parcelset" ${test} ${${test}_PARAMETERS}
# TIMEOUT 900 )

add_hpx_regression_test(
"modules.parcelset" ${test} ${${test}_PARAMETERS} TIMEOUT 900
)
endforeach()

if(HPX_WITH_NETWORKING)
# Disable the test due to limited CircleCI resources

# very_big_parcel with one additional configurations

# add_hpx_regression_test( "modules.parcelset" very_big_parcel_int_max_plus_1
# EXECUTABLE very_big_parcel TIMEOUT 900 PSEUDO_DEPS_NAME very_big_parcel
# ${very_big_parcel_PARAMETERS} --nbytes-add=1 )
add_hpx_regression_test(
"modules.parcelset" very_big_parcel_int_max_plus_1
EXECUTABLE very_big_parcel TIMEOUT 900
PSEUDO_DEPS_NAME very_big_parcel ${very_big_parcel_PARAMETERS}
--nbytes-add=1
)
endif()
108 changes: 108 additions & 0 deletions libs/full/parcelset/tests/regressions/nested_vectors_6623.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
// Copyright (c) 2025 Marco Diers
//
// SPDX-License-Identifier: BSL-1.0
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <hpx/hpx_init.hpp>
#include <hpx/include/actions.hpp>
#include <hpx/include/async.hpp>
#include <hpx/include/components.hpp>
#include <hpx/include/runtime.hpp>
#include <hpx/include/serialization.hpp>

#include <algorithm>
#include <cstddef>
#include <iostream>
#include <iterator>
#include <utility>
#include <vector>

class Data
{
public:
Data() = default;

Data(std::size_t x, std::size_t y, std::size_t z)
: _data(x, std::vector<std::vector<float>>(y, std::vector<float>(z)))
{
}

auto size() const
{
return _data.size() * _data.begin()->size() *
_data.begin()->begin()->size();
}

template <typename Archive>
friend auto serialize(Archive& archive, Data& object, unsigned int version)
{
// clang-format off
archive & object._data;
// clang-format on
return;
}

private:
std::vector<std::vector<std::vector<float>>> _data{};
};

class Component : public hpx::components::component_base<Component>
{
public:
Component() = default;

auto call(Data data) -> void
{
std::cout << "Data size: " << data.size() << '\n';
return;
}

HPX_DEFINE_COMPONENT_ACTION(Component, call);
};

HPX_REGISTER_COMPONENT(hpx::components::component<Component>, Component);
HPX_REGISTER_ACTION(Component::call_action);

class ComponentClient
: public hpx::components::client_base<ComponentClient, Component>
{
using BaseType = hpx::components::client_base<ComponentClient, Component>;

public:
template <typename... Arguments>
ComponentClient(Arguments... arguments)
: BaseType(std::move(arguments)...)
{
}

template <typename... Arguments>
auto call(Arguments... arguments)
{
return hpx::async<Component::call_action>(
this->get_id(), std::move(arguments)...);
}
};

int hpx_main()
{
std::vector<ComponentClient> clients;
auto localities(hpx::find_all_localities());
std::transform(std::begin(localities), std::end(localities),
std::back_inserter(clients),
[](auto& loc) { return hpx::new_<ComponentClient>(loc); });
Data data(3173, 1379, 277);
std::vector<decltype(clients.front().call(data))> calls;
for (auto& client : clients)
{
calls.emplace_back(client.call(data));
}
hpx::wait_all(calls);

return hpx::finalize();
}

int main(int argc, char* argv[])
{
return hpx::init(argc, argv);
}

0 comments on commit 3d42559

Please sign in to comment.