STEllAR-GROUP / hpx

The C++ Standard Library for Parallelism and Concurrency
https://hpx.stellar-group.org
Boost Software License 1.0
2.53k stars 430 forks source link

Development of HPX Components is Difficult #3992

Open stevenrbrandt opened 5 years ago

stevenrbrandt commented 5 years ago

This is a feature enhancement request. Currently, when writing a component, there is a lot of boilerplate. There needs to be client and server code. The server needs to call HPX_DEFINE_COMPONENT_ACTION for every exposed method, outside the server one needs to call HPX_REGISTER_ACTION_DECLARATION, and then the client (usually) has to have two methods, one static and one not. In addition, HPX_REGISTER_ACTION needs to be called. This is about 6 different places that need to be changed when a method is added. If one wants to change the arguments or return type of a function, one also has to change 5 lines of code in various places (client declaration, two server declarations, two server calls). For me, at least, trying to keep track of all this while developing is hard.

I have a prototype Python code to generate Components that looks something like the code below. The decorator generates Adder.hpp and Adder_macros.hpp. Is there any interest in making this official?

from comp import *

@Component(namespace="adder")
class Adder:

    # declare state variables
    counter : int = 33

    # declare functions
    def add(self, arg : int) -> int:
        pass
stevenrbrandt commented 5 years ago

It will probably take a little time before this code is ready for master. Until then, I invite you to look here: https://github.com/stevenrbrandt/HPXCompMaker

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

biddisco commented 4 years ago

(Just adding a comment to prevent this from being closed by the stale bot). The python solution looks promising and it should be encouraged... but can't we create some template magic that does all the action registration automatically without having to manually add macros everywhere - or somehow simply the process of client server component creation in the c++?

hkaiser commented 4 years ago

We know that parts of the macros can be avoided at the expense of increasing compile time (possibly significantly). It might also be possible to use some of the new C++17 language features to reduce the need for the macros. All of this needs investigation.