Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering Nested Component Actions #5978

Open
alecbetancourt opened this issue Aug 8, 2022 · 1 comment
Open

Registering Nested Component Actions #5978

alecbetancourt opened this issue Aug 8, 2022 · 1 comment

Comments

@alecbetancourt
Copy link

Expected Behavior

I'm attempting to convert an established MPI code to HPX by writing an HPX version of the program's swappable communication submodule. I've been following along with the local to remote example in the documentation. I'm preserving most of the structure from the distributed memory verson of that example and trying to nest it in a class of the type being used for the communication submodule.

Actual Behavior

When running the example below as is, mimicking the local to remote example with an extra layer of indirection to the components, I get an error about the get_data_action that I registered using HPX_DEFINE_COMPONENT_DIRECT_ACTION() not naming a type:

error: ‘get_data_action’ in ‘struct CommHPX::partition_server’ does not name a type
  763 | typedef CommHPX::partition_server::get_data_action get_data_action;
      |                                    ^~~~~~~~~~~~~~~

Trying to make CommHPX inherit hpx::components::component_base<> in the same manner as the partition_server component and adding a matching call to HPX_REGISTER_COMPONENT() as shown below throws a long list of errors regarding multiple definitions. I think I'm either fundamentally misunderstanding nested components or trying to leverage a code structure that HPX doesn't support.

typedef hpx::components::component<CommHPX> comm_hpx_type;
HPX_REGISTER_COMPONENT(comm_hpx_type, CommHPX)

Steps to Reproduce the Problem

This is a stripped down version of the class structure of the communication module, as well as the macros I'm using to register the components and actions in global scope.

comm_hpx.h

class CommHPX {
    struct partition_data {}

    struct partition_server : hpx::components::component_base<partition_server> {
        partition_data get_data() const;
    }

    struct partition : hpx::components::client_base<partition, partition_server> {}
}

HPX_DEFINE_COMPONENT_DIRECT_ACTION(CommHPX::partition_server, get_data, get_data_action)

typedef hpx::components::component<CommHPX::partition_server> partition_server_type;
HPX_REGISTER_COMPONENT(partition_server_type, partition_server)

typedef CommHPX::partition_server::get_data_action get_data_action;
HPX_REGISTER_ACTION(get_data_action)

comm_hpx.cpp

hpx::future<CommHPX::partition_data> CommHPX::partition::get_data() const {
  get_data_action act;
  //return hpx::async(act, get_id(), t);
  return hpx::async(act, get_id());
}

Specifications

  • HPX Version: 1.8
  • Platform (compiler, OS): CMake/3.21.1, GCC/8.3.0, Arch
@Pansysk75 Pansysk75 pinned this issue Mar 18, 2023
@hkaiser
Copy link
Member

hkaiser commented Mar 21, 2023

I tried to reproduce your issue by composing the code you provided (with some minor modifications). Everything seems to work as expected:

#include <hpx/hpx_main.hpp>
#include <hpx/modules/async_distributed.hpp>
#include <hpx/modules/runtime_components.hpp>

class CommHPX
{
public:
    struct partition_data
    {
    };

    struct partition_server : hpx::components::component_base<partition_server>
    {
        partition_data get_data() const
        {
            return {};
        }
    };

    struct partition : hpx::components::client_base<partition, partition_server>
    {
        using client_base::client_base;

        hpx::future<CommHPX::partition_data> get_data() const;
    };
};

using partition_server_type =
    hpx::components::component<CommHPX::partition_server>;
HPX_REGISTER_COMPONENT(partition_server_type, partition_server)

HPX_DEFINE_COMPONENT_DIRECT_ACTION(
    CommHPX::partition_server, get_data, get_data_action)

HPX_REGISTER_ACTION(get_data_action)

hpx::future<CommHPX::partition_data> CommHPX::partition::get_data() const
{
    get_data_action act;
    return hpx::async(act, get_id());
}

int main()
{
    CommHPX::partition const p = hpx::local_new<CommHPX::partition>();
    hpx::wait_all(p.get_data());

    return 0;
}

@hkaiser hkaiser unpinned this issue Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants