Code Monkey home page Code Monkey logo

Comments (4)

a-jp avatar a-jp commented on July 26, 2024

Just to see if it would work (not suggesting you'd adopt this addition or in this way): I did the following on the current master:

diff --git a/mpl/comm_group.hpp b/mpl/comm_group.hpp
index a01fd30..66f9958 100644
--- a/mpl/comm_group.hpp
+++ b/mpl/comm_group.hpp
@@ -280,6 +280,14 @@ namespace mpl {
     MPI_Comm comm_{MPI_COMM_NULL};
 
   public:
+
+    /// \brief Obtain access to underlying mpi communicator
+    /// \return raw MPI_Comm communicator
+    MPI_Comm get_mpi_comm() const
+    {
+        return comm_;
+    }
+
     /// \brief Equality types for communicator comparison.
     enum class equality_type {
       /// communicators are identical, i.e., communicators represent the same communication

This works perfectly for my needs. I can then use this like:

MPI_Intercomm_create(groupcomm.get_mpi_comm(), 0, comm_world.get_mpi_comm(), rl, tag, &intercomm);

Am I doing anything silly here? Are there any mistakes to watch for with regards to the way your library works?

Thanks,

from mpl.

rabauke avatar rabauke commented on July 26, 2024

Hi, I would hesitate to incorporate a get_mpi_comm method into MPL. For your usage scenario, it is, however, a reasonable work-around. When you keep in mind the following things, you should not run into trouble: In MPI an object of the type MPI_Commis actually not a communicator, it is just a handle (like a pointer) to a communicator. The actual communicator is not visible to you. In typical MPI applications you can have several handles to the same communicator, which raises ownership issues (Who calls MPI_Comm_free?).

An MPL communicator has also a handle to an MPI communicator and the MPL communicator owns this handle. In MPL there are never two communicators that have handles that point to the same underlying MPI communicator. When a MPL communicator goes out of scope, MPI_Comm_free is called. When and MPL communicator is created by copying, i.e., the copy constructor is called, also a new MPI communicator is created via MPI_Comm_dup.

Therefore, you must never call MPI_Comm_free on a handle that was returned by get_mpi_comm and you must never use this handle after the MPL communicator of which you called get_mpi_comm went out of scope.

from mpl.

a-jp avatar a-jp commented on July 26, 2024

Ok, I understand this from your perspective and the points you raised. I certainly use the library due to a number of the points you raised and they are positive.

I guess you can see from my perspective and anyone else in the same boat, via the concrete example and use-case that I'm working through right now, that unless MPL implements every mpi function then this will keep coming up; co-existence of mpi and MPL within the same code base will be tricky.

If you do implement the inter-comm api then this goes away for me, until then i guess I need to retain a local fork.

I was really pleased to see the version contribution to spack. Again, not that straightforward I guess if I'm maintaining a local unversioned fork due to the above requirements.

Many thanks

from mpl.

VictorEijkhout avatar VictorEijkhout commented on July 26, 2024

from mpl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.