@@ -557,64 +557,19 @@ class Context {
557
557
friend class Endpoint ;
558
558
};
559
559
560
- // / A base class for objects that can be set up during @ref Communicator::setup().
561
- struct Setuppable {
562
- virtual ~Setuppable () = default ;
563
-
564
- // / Called inside @ref Communicator::setup() before any call to @ref endSetup() of any @ref Setuppable object that is
565
- // / being set up within the same @ref Communicator::setup() call.
566
- // /
567
- // / @param bootstrap A shared pointer to the bootstrap implementation.
568
- virtual void beginSetup (std::shared_ptr<Bootstrap> bootstrap);
569
-
570
- // / Called inside @ref Communicator::setup() after all calls to @ref beginSetup() of all @ref Setuppable objects that
571
- // / are being set up within the same @ref Communicator::setup() call.
572
- // /
573
- // / @param bootstrap A shared pointer to the bootstrap implementation.
574
- virtual void endSetup (std::shared_ptr<Bootstrap> bootstrap);
575
- };
576
-
577
- // / A non-blocking future that can be used to check if a value is ready and retrieve it.
578
560
template <typename T>
579
- class NonblockingFuture {
580
- std::shared_future<T> future;
581
-
582
- public:
583
- // / Default constructor.
584
- NonblockingFuture () = default ;
585
-
586
- // / Constructor that takes a shared future and moves it into the NonblockingFuture.
587
- // /
588
- // / @param future The shared future to move.
589
- NonblockingFuture (std::shared_future<T>&& future) : future(std::move(future)) {}
590
-
591
- // / Check if the value is ready to be retrieved.
592
- // /
593
- // / @return True if the value is ready, false otherwise.
594
- bool ready () const { return future.wait_for (std::chrono::seconds (0 )) == std::future_status::ready; }
595
-
596
- // / Get the value.
597
- // /
598
- // / @return The value.
599
- // /
600
- // / @throws Error if the value is not ready.
601
- T get () const {
602
- if (!ready ()) throw Error (" NonblockingFuture::get() called before ready" , ErrorCode::InvalidUsage);
603
- return future.get ();
604
- }
605
- };
561
+ using NonblockingFuture [[deprecated(" Use std::shared_future instead. This will be removed in a future release." )]] =
562
+ std::shared_future<T>;
606
563
607
564
// / A class that sets up all registered memories and connections between processes.
608
565
// /
609
566
// / A typical way to use this class:
610
- // / 1. Call @ref connectOnSetup () to declare connections between the calling process with other processes.
611
- // / 2. Call @ref registerMemory() to register memory regions that will be used for communication.
612
- // / 3. Call @ref sendMemoryOnSetup () or @ref recvMemoryOnSetup () to send/receive registered memory regions to/from
567
+ // / 1. Call connect () to declare connections between the calling process with other processes.
568
+ // / 2. Call registerMemory() to register memory regions that will be used for communication.
569
+ // / 3. Call sendMemory () or recvMemory () to send/receive registered memory regions to/from
613
570
// / other processes.
614
- // / 4. Call @ref setup() to set up all registered memories and connections declared in the previous steps.
615
- // / 5. Call @ref NonblockingFuture<RegisteredMemory>::get() to get the registered memory regions received from other
616
- // / processes.
617
- // / 6. All done; use connections and registered memories to build channels.
571
+ // / 4. Call get() on all futures returned by connect() and recvMemory().
572
+ // / 5. All done; use connections and registered memories to build channels.
618
573
// /
619
574
class Communicator {
620
575
public:
@@ -645,40 +600,57 @@ class Communicator {
645
600
// / @return RegisteredMemory A handle to the buffer.
646
601
RegisteredMemory registerMemory (void * ptr, size_t size, TransportFlags transports);
647
602
648
- // / Send information of a registered memory to the remote side on setup .
603
+ // / Send information of a registered memory to the remote side.
649
604
// /
650
- // / This function registers a send to a remote process that will happen by a following call of @ref setup(). The send
651
- // / will carry information about a registered memory on the local process.
605
+ // / The send will be performed immediately upon calling this function.
652
606
// /
653
607
// / @param memory The registered memory buffer to send information about.
654
608
// / @param remoteRank The rank of the remote process.
655
609
// / @param tag The tag to use for identifying the send.
656
- void sendMemoryOnSetup (RegisteredMemory memory, int remoteRank, int tag);
610
+ void sendMemory (RegisteredMemory memory, int remoteRank, int tag);
657
611
658
- // / Receive memory on setup.
612
+ [[deprecated(" Use sendMemory() instead. This will be removed in a future release." )]] void sendMemoryOnSetup (
613
+ RegisteredMemory memory, int remoteRank, int tag) {
614
+ sendMemory (memory, remoteRank, tag);
615
+ }
616
+
617
+ // / Receive memory information from a corresponding sendMemory call on the remote side.
659
618
// /
660
- // / This function registers a receive from a remote process that will happen by a following call of @ref setup(). The
661
- // / receive will carry information about a registered memory on the remote process .
619
+ // / This function returns a future immediately. The actual receive will be performed upon calling
620
+ // / the first get() on the future .
662
621
// /
663
622
// / @param remoteRank The rank of the remote process.
664
623
// / @param tag The tag to use for identifying the receive.
665
- // / @return NonblockingFuture <RegisteredMemory> A non-blocking future of registered memory.
666
- NonblockingFuture <RegisteredMemory> recvMemoryOnSetup (int remoteRank, int tag);
624
+ // / @return std::shared_future <RegisteredMemory> A non-blocking future of registered memory.
625
+ std::shared_future <RegisteredMemory> recvMemory (int remoteRank, int tag);
667
626
668
- // / Connect to a remote rank on setup.
627
+ [[deprecated(
628
+ " Use recvMemory() instead. This will be removed in a future release." )]] NonblockingFuture<RegisteredMemory>
629
+ recvMemoryOnSetup (int remoteRank, int tag) {
630
+ return recvMemory (remoteRank, tag);
631
+ }
632
+
633
+ // / Connect to a remote rank.
669
634
// /
670
- // / This function only prepares metadata for connection. The actual connection is made by a following call of
671
- // / @ref setup(). Note that this function is two-way and a connection from rank `i` to remote rank `j` needs
635
+ // / This function will immediately send metadata about the local endpoint to the remote rank, and return a future
636
+ // / without waiting for the remote rank to respond. The connection will be established when the remote rank
637
+ // / responds with its own endpoint and the local rank calls the first get() on the future.
638
+ // / Note that this function is two-way and a connection from rank `i` to remote rank `j` needs
672
639
// / to have a counterpart from rank `j` to rank `i`. Note that with IB, buffers are registered at a page level and if
673
640
// / a buffer is spread through multiple pages and do not fully utilize all of them, IB's QP has to register for all
674
641
// / involved pages. This potentially has security risks if the connection's accesses are given to a malicious process.
675
642
// /
676
643
// / @param remoteRank The rank of the remote process.
677
644
// / @param tag The tag of the connection for identifying it.
678
645
// / @param config The configuration for the local endpoint.
679
- // / @return NonblockingFuture<NonblockingFuture<std::shared_ptr<Connection>>> A non-blocking future of shared pointer
680
- // / to the connection.
681
- NonblockingFuture<std::shared_ptr<Connection>> connectOnSetup (int remoteRank, int tag, EndpointConfig localConfig);
646
+ // / @return std::shared_future<std::shared_ptr<Connection>> A non-blocking future of shared pointer to the connection.
647
+ std::shared_future<std::shared_ptr<Connection>> connect (int remoteRank, int tag, EndpointConfig localConfig);
648
+
649
+ [[deprecated(" Use connect() instead. This will be removed in a future release." )]] NonblockingFuture<
650
+ std::shared_ptr<Connection>>
651
+ connectOnSetup (int remoteRank, int tag, EndpointConfig localConfig) {
652
+ return connect (remoteRank, tag, localConfig);
653
+ }
682
654
683
655
// / Get the remote rank a connection is connected to.
684
656
// /
@@ -692,17 +664,7 @@ class Communicator {
692
664
// / @return The tag the connection was made with.
693
665
int tagOf (const Connection& connection);
694
666
695
- // / Add a custom Setuppable object to a list of objects to be setup later, when @ref setup() is called.
696
- // /
697
- // / @param setuppable A shared pointer to the Setuppable object.
698
- void onSetup (std::shared_ptr<Setuppable> setuppable);
699
-
700
- // / Setup all objects that have registered for setup.
701
- // /
702
- // / This includes previous calls of @ref sendMemoryOnSetup(), @ref recvMemoryOnSetup(), @ref connectOnSetup(), and
703
- // / @ref onSetup(). It is allowed to call this function multiple times, where the n-th call will only setup objects
704
- // / that have been registered after the (n-1)-th call.
705
- void setup ();
667
+ [[deprecated(" setup() is now no-op and no longer needed. This will be removed in a future release." )]] void setup () {}
706
668
707
669
private:
708
670
// The interal implementation.
0 commit comments