Loading...
Searching...
No Matches
hydrocoupledistributed.h
Go to the documentation of this file.
1
21
22#ifndef HYDROCOUPLEDISTRIBUTED_H
23#define HYDROCOUPLEDISTRIBUTED_H
24
25#include "hydrocouple.h"
26
36#if defined(__GNUC__) || defined(__clang__)
37#pragma GCC visibility push(default)
38#endif
39
40namespace HydroCouple
41{
43 namespace Distributed
44 {
53 {
54 public:
66 virtual ~IExchangeRequest() = default;
67
75 [[nodiscard]] virtual bool cancel() = 0;
76
81 [[nodiscard]] virtual bool test() = 0;
82
86 virtual void wait() = 0;
87
97 [[nodiscard]] virtual bool waitFor(double timeoutSeconds) = 0;
98
104 [[nodiscard]] virtual bool failed(std::string &message) const = 0;
105 };
106
144 class ITransport : public virtual IIdentity
145 {
146 public:
150 struct Endpoint
151 {
152 std::string address;
153 int32_t rank = -1;
154 };
155
159 virtual ~ITransport() = default;
160
165 [[nodiscard]] virtual Endpoint localEndpoint() const = 0;
166
171 [[nodiscard]] virtual int32_t participantCount() const = 0;
172
181 [[nodiscard]] virtual bool send(const Endpoint &to, int32_t tag, const BufferDescriptor &payload, std::string *message = nullptr) = 0;
182
191 [[nodiscard]] virtual bool receive(const Endpoint &from, int32_t tag, const BufferDescriptor &into, std::string *message = nullptr) = 0;
192
200 [[nodiscard]] virtual std::unique_ptr<IExchangeRequest> sendAsync(const Endpoint &to, int32_t tag, const BufferDescriptor &payload) = 0;
201
209 [[nodiscard]] virtual std::unique_ptr<IExchangeRequest> receiveAsync(const Endpoint &from, int32_t tag, const BufferDescriptor &into) = 0;
210 };
211
221 {
222 public:
226 virtual ~IDistributedModelComponent() = default;
227
232 [[nodiscard]] virtual ITransport *transport() const = 0;
233
238 [[nodiscard]] virtual int32_t partitionCount() const = 0;
239
244 [[nodiscard]] virtual int32_t partitionRank() const = 0;
245 };
246
270 {
271
272 public:
276 virtual ~IProxyModelComponent() = default;
277
282 [[nodiscard]] virtual ITransport::Endpoint remoteEndpoint() const = 0;
283
288 [[nodiscard]] virtual std::string remoteId() const = 0;
289
298 [[nodiscard]] virtual bool connectToPeer(std::string &message) = 0;
299
303 virtual void disconnectFromPeer() = 0;
304
309 [[nodiscard]] virtual bool isConnected() const = 0;
310
316 [[nodiscard]] virtual bool ping(double timeoutSeconds) = 0;
317
322 [[nodiscard]] virtual double requestTimeout() const = 0;
323
328 virtual void setRequestTimeout(double seconds) = 0;
329 };
330
354 {
355 public:
360
365 [[nodiscard]] virtual int32_t partitionedDimension() const = 0;
366
371 [[nodiscard]] virtual int64_t globalCount() const = 0;
372
379 [[nodiscard]] virtual std::span<const int64_t> ownedGlobalIndexes() const = 0;
380
387 [[nodiscard]] virtual std::span<const int64_t> virtualGlobalIndexes() const = 0;
388
393 [[nodiscard]] virtual std::span<const int32_t> virtualOwners() const = 0;
394
399 [[nodiscard]] virtual uint64_t synchronizationEpoch() const = 0;
400
409 [[nodiscard]] virtual std::unique_ptr<IExchangeRequest> synchronizeAsync() = 0;
410 };
411 }
412}
413
414#if defined(__GNUC__) || defined(__clang__)
415#pragma GCC visibility pop
416#endif
417
418#endif // HYDROCOUPLEDISTRIBUTED_H
IDistributedModelComponent is an IModelComponent that participates in distributed execution through a...
Definition hydrocoupledistributed.h:221
virtual int32_t partitionRank() const =0
The partition this instance computes.
virtual ITransport * transport() const =0
The transport this component communicates through.
virtual int32_t partitionCount() const =0
The number of partitions this component's domain is decomposed into.
virtual ~IDistributedModelComponent()=default
~IDistributedModelComponent destructor.
IExchangeRequest is a handle to an asynchronous communication operation.
Definition hydrocoupledistributed.h:53
virtual bool waitFor(double timeoutSeconds)=0
Blocks until the operation completes or the timeout elapses.
virtual bool test()=0
Non-blocking completion test.
virtual bool failed(std::string &message) const =0
Checks whether the operation completed with an error.
virtual ~IExchangeRequest()=default
IExchangeRequest::~IExchangeRequest is a virtual destructor.
virtual void wait()=0
Blocks until the operation completes.
virtual bool cancel()=0
Asks the implementation to abandon the operation.
IPartitionedComponentDataItem is an IComponentDataItem whose entity dimension is decomposed across pa...
Definition hydrocoupledistributed.h:354
virtual int64_t globalCount() const =0
The global entity count across all partitions.
virtual ~IPartitionedComponentDataItem()=default
~IPartitionedComponentDataItem destructor.
virtual std::span< const int64_t > ownedGlobalIndexes() const =0
Global identities of the locally owned entities.
virtual uint64_t synchronizationEpoch() const =0
The synchronization epoch of the virtual entities.
virtual std::span< const int32_t > virtualOwners() const =0
Owner partition of each virtual entity.
virtual std::unique_ptr< IExchangeRequest > synchronizeAsync()=0
Begins an asynchronous halo synchronization of the virtual entities.
virtual std::span< const int64_t > virtualGlobalIndexes() const =0
Global identities of the local virtual (ghost/halo) entities.
virtual int32_t partitionedDimension() const =0
Which axis of shape() is decomposed across partitions.
The IProxyModelComponent class is a local stand-in for a remote IModelComponent reachable through a t...
Definition hydrocoupledistributed.h:270
virtual std::string remoteId() const =0
The unique identifier of the remote component this proxy represents.
virtual void setRequestTimeout(double seconds)=0
Sets the timeout applied to forwarded requests.
virtual double requestTimeout() const =0
The timeout applied to forwarded requests.
virtual ITransport::Endpoint remoteEndpoint() const =0
The endpoint of the remote component this proxy represents.
virtual void disconnectFromPeer()=0
Closes the connection to the remote component.
virtual bool ping(double timeoutSeconds)=0
Liveness probe of the remote component.
virtual bool isConnected() const =0
Checks whether the proxy currently holds a live connection.
virtual ~IProxyModelComponent()=default
~IProxyModelComponent destructor.
virtual bool connectToPeer(std::string &message)=0
Establishes the connection to the remote component.
ITransport is a transport-neutral, tagged message channel between processes.
Definition hydrocoupledistributed.h:145
virtual std::unique_ptr< IExchangeRequest > receiveAsync(const Endpoint &from, int32_t tag, const BufferDescriptor &into)=0
Nonblocking receive; the destination buffer must remain valid until the request completes.
virtual int32_t participantCount() const =0
The number of participants reachable through this transport.
virtual std::unique_ptr< IExchangeRequest > sendAsync(const Endpoint &to, int32_t tag, const BufferDescriptor &payload)=0
Nonblocking send; the payload buffer must remain valid until the request completes.
virtual bool receive(const Endpoint &from, int32_t tag, const BufferDescriptor &into, std::string *message=nullptr)=0
Receives a typed payload from a peer, blocking until it arrives.
virtual bool send(const Endpoint &to, int32_t tag, const BufferDescriptor &payload, std::string *message=nullptr)=0
Sends a typed payload to a peer, blocking until the payload buffer is reusable.
virtual ~ITransport()=default
ITransport::~ITransport is a virtual destructor.
virtual Endpoint localEndpoint() const =0
The endpoint of the calling process on this transport.
IComponentDataItem is a fundamental unit of data for a component.
Definition hydrocouple.h:1844
IIdentity interface class defines a method to get the Id of an HydroCouple entity.
Definition hydrocouple.h:476
IModelComponent interface is the core interface in the HydroCouple standard defining a model componen...
Definition hydrocouple.h:696
Core interface definitions for the HydroCouple component-based modeling framework.
HydroCouple's interfaces for distributed and cloud execution.
Definition hydrocoupledistributed.h:44
HydroCouple namespace contains the core interface specifications for the HydroCouple component-based ...
Definition hydrocouple.h:54
BufferDescriptor describes a typed, possibly strided, possibly device-resident multi-dimensional arra...
Definition hydrocouple.h:279
Endpoint identifies one participant reachable through this transport.
Definition hydrocoupledistributed.h:151
std::string address
Transport-specific address (empty for rank-addressed transports).
Definition hydrocoupledistributed.h:152
int32_t rank
Participant rank for rank-addressed transports; -1 otherwise.
Definition hydrocoupledistributed.h:153