CommunicationManager Class Reference
HiCR
|
#include <communicationManager.hpp>

Public Types | |
using | globalKeyMemorySlotPair_t = std::pair< GlobalMemorySlot::globalKey_t, std::shared_ptr< LocalMemorySlot > > |
using | globalKeyToMemorySlotMap_t = std::map< GlobalMemorySlot::globalKey_t, std::shared_ptr< GlobalMemorySlot > > |
using | globalMemorySlotTagKeyMap_t = std::map< GlobalMemorySlot::tag_t, globalKeyToMemorySlotMap_t > |
Public Member Functions | |
virtual | ~CommunicationManager ()=default |
virtual void | lock () |
virtual void | unlock () |
__INLINE__ void | exchangeGlobalMemorySlots (GlobalMemorySlot::tag_t tag, const std::vector< globalKeyMemorySlotPair_t > &memorySlots) |
__INLINE__ std::shared_ptr< GlobalMemorySlot > | getGlobalMemorySlot (GlobalMemorySlot::tag_t tag, GlobalMemorySlot::globalKey_t globalKey) |
virtual uint8_t * | serializeGlobalMemorySlot (const std::shared_ptr< HiCR::GlobalMemorySlot > &globalSlot) const |
virtual std::shared_ptr< GlobalMemorySlot > | deserializeGlobalMemorySlot (uint8_t *buffer, GlobalMemorySlot::tag_t tag) |
virtual std::shared_ptr< GlobalMemorySlot > | promoteLocalMemorySlot (const std::shared_ptr< LocalMemorySlot > &localMemorySlot, GlobalMemorySlot::tag_t tag) |
__INLINE__ void | deregisterGlobalMemorySlot (const std::shared_ptr< GlobalMemorySlot > &memorySlot) |
__INLINE__ void | destroyGlobalMemorySlot (const std::shared_ptr< GlobalMemorySlot > &memorySlot) |
virtual void | destroyPromotedGlobalMemorySlot (const std::shared_ptr< GlobalMemorySlot > &memorySlot) |
__INLINE__ void | queryMemorySlotUpdates (std::shared_ptr< LocalMemorySlot > memorySlot) |
__INLINE__ void | memcpy (const std::shared_ptr< LocalMemorySlot > &destination, size_t dst_offset, const std::shared_ptr< LocalMemorySlot > &source, size_t src_offset, size_t size) |
__INLINE__ void | memcpy (const std::shared_ptr< GlobalMemorySlot > &destination, size_t dst_offset, const std::shared_ptr< LocalMemorySlot > &source, size_t src_offset, size_t size) |
__INLINE__ void | memcpy (const std::shared_ptr< LocalMemorySlot > &destination, size_t dst_offset, const std::shared_ptr< GlobalMemorySlot > &source, size_t src_offset, size_t size) |
__INLINE__ void | fence (GlobalMemorySlot::tag_t tag) |
__INLINE__ void | fence (const std::shared_ptr< LocalMemorySlot > &slot, size_t expectedSent, size_t expectedRecvd) |
__INLINE__ void | fence (const std::shared_ptr< GlobalMemorySlot > &slot, size_t expectedSent, size_t expectedRecvd) |
__INLINE__ bool | acquireGlobalLock (const std::shared_ptr< GlobalMemorySlot > &memorySlot) |
__INLINE__ void | releaseGlobalLock (const std::shared_ptr< GlobalMemorySlot > &memorySlot) |
virtual __INLINE__ void | flushSent () |
virtual __INLINE__ void | flushReceived () |
Protected Member Functions | |
__INLINE__ void | registerGlobalMemorySlot (const std::shared_ptr< GlobalMemorySlot > &memorySlot) |
virtual std::shared_ptr< GlobalMemorySlot > | getGlobalMemorySlotImpl (GlobalMemorySlot::tag_t tag, GlobalMemorySlot::globalKey_t globalKey)=0 |
virtual void | exchangeGlobalMemorySlotsImpl (GlobalMemorySlot::tag_t tag, const std::vector< globalKeyMemorySlotPair_t > &memorySlots)=0 |
virtual void | queryMemorySlotUpdatesImpl (std::shared_ptr< LocalMemorySlot > memorySlot)=0 |
virtual void | deregisterGlobalMemorySlotImpl (const std::shared_ptr< GlobalMemorySlot > &memorySlot) |
virtual void | destroyGlobalMemorySlotImpl (std::shared_ptr< GlobalMemorySlot > memorySlot)=0 |
virtual void | memcpyImpl (const std::shared_ptr< LocalMemorySlot > &destination, size_t dst_offset, const std::shared_ptr< LocalMemorySlot > &source, size_t src_offset, size_t size) |
virtual void | memcpyImpl (const std::shared_ptr< GlobalMemorySlot > &destination, size_t dst_offset, const std::shared_ptr< LocalMemorySlot > &source, size_t src_offset, size_t size) |
virtual void | memcpyImpl (const std::shared_ptr< LocalMemorySlot > &destination, size_t dst_offset, const std::shared_ptr< GlobalMemorySlot > &source, size_t src_offset, size_t size) |
virtual void | fenceImpl (const std::shared_ptr< LocalMemorySlot > &slot, size_t expectedSent, size_t expectedRcvd) |
virtual void | fenceImpl (const std::shared_ptr< GlobalMemorySlot > &slot, size_t expectedSent, size_t expectedRcvd) |
virtual void | fenceImpl (GlobalMemorySlot::tag_t tag)=0 |
virtual bool | acquireGlobalLockImpl (std::shared_ptr< GlobalMemorySlot > memorySlot)=0 |
virtual void | releaseGlobalLockImpl (std::shared_ptr< GlobalMemorySlot > memorySlot)=0 |
__INLINE__ auto & | getGlobalMemorySlotsToDestroyPerTag () |
__INLINE__ auto & | getGlobalMemorySlotTagKeyMap () |
__INLINE__ void | increaseMessageRecvCounter (HiCR::LocalMemorySlot &memorySlot) noexcept |
__INLINE__ void | increaseMessageSentCounter (HiCR::LocalMemorySlot &memorySlot) noexcept |
__INLINE__ void | setMessagesRecv (HiCR::LocalMemorySlot &memorySlot, const size_t count) noexcept |
__INLINE__ void | setMessagesSent (HiCR::LocalMemorySlot &memorySlot, const size_t count) noexcept |
Detailed Description
Encapsulates a HiCR Backend Communication Manager.
Backends represent plugins to HiCR that provide support for a communication or device library. By adding new plugins developers extend HiCR's support for new hardware and software technologies.
Backends need to fulfill the abstract virtual functions described here, so that HiCR can perform communication operations on the supported device/network library.
Member Typedef Documentation
◆ globalKeyMemorySlotPair_t
using HiCR::CommunicationManager::globalKeyMemorySlotPair_t = std::pair<GlobalMemorySlot::globalKey_t, std::shared_ptr<LocalMemorySlot> > |
Type definition for a global key / local memory slot pair
◆ globalKeyToMemorySlotMap_t
using HiCR::CommunicationManager::globalKeyToMemorySlotMap_t = std::map<GlobalMemorySlot::globalKey_t, std::shared_ptr<GlobalMemorySlot> > |
Type definition for an array that stores sets of memory slots, separated by global key
◆ globalMemorySlotTagKeyMap_t
using HiCR::CommunicationManager::globalMemorySlotTagKeyMap_t = std::map<GlobalMemorySlot::tag_t, globalKeyToMemorySlotMap_t> |
Type definition for a tag-mapped set of key-mapped memory slot arrays
Constructor & Destructor Documentation
◆ ~CommunicationManager()
|
virtualdefault |
Default destructor
Reimplemented in HiCR::backend::pthreads::CommunicationManager, HiCR::backend::mpi::CommunicationManager, HiCR::backend::ascend::CommunicationManager, and HiCR::backend::opencl::CommunicationManager.
Member Function Documentation
◆ acquireGlobalLock()
|
inline |
This function ensures that the global memory slot is reserved exclusively for access by the caller.
This function might (or might not) block the caller to satisfy the exclusion, if the lock is already held by another caller.
- Parameters
-
[in] memorySlot The memory slot to reserve
- Returns
- true, if the lock was acquired successfully; false, otherwise
◆ acquireGlobalLockImpl()
|
protectedpure virtual |
Backend-specific implementation of the acquireGlobalLock function
- Parameters
-
[in] memorySlot See the acquireGlobalLock function
- Returns
- See the acquireGlobalLock function
◆ deregisterGlobalMemorySlot()
|
inline |
De-registers a previously registered global memory slot. This can be a local operation, and is a CommunicationManager internal operation. The slot is not destroyed, it can be used, but can no longer be accessed via getGlobalMemorySlot.
- Parameters
-
[in] memorySlot Memory slot to deregister.
- Note
- This method is not thread-safe. It is up to the application developer to ensure that it is called with proper locking.
◆ deregisterGlobalMemorySlotImpl()
|
inlineprotectedvirtual |
Optional backend-internal implementation of the deregisterGlobalMemorySlot function
- Parameters
-
[in] memorySlot Memory slot to deregister.
◆ deserializeGlobalMemorySlot()
|
inlinevirtual |
Deserializes a global memory slot from a given buffer.
- Parameters
-
[in] buffer The buffer to deserialize the global memory slot from [in] tag The tag to associate with the deserialized global memory slot
- Returns
- A pointer to the deserialized global memory slot
Reimplemented in HiCR::backend::lpf::CommunicationManager.
◆ destroyGlobalMemorySlot()
|
inline |
Destroys a (collectively exchanged) global memory slot. This operation is non-blocking and non-collective. Its effects will be visible after the next call to fence(GlobalMemorySlot::tag_t) where the tag is the tag of the memory slot to destroy. That means that multiple slots under the same tag can be destroyed in a single fence operation.
If the memory slot has not been created through exchangeGlobalMemorySlots, the behavior is undefined.
- Parameters
-
[in] memorySlot Memory slot to destroy.
- Note
- This method is not thread-safe. It is up to the application developer to ensure that
◆ destroyGlobalMemorySlotImpl()
|
protectedpure virtual |
Deletes a global memory slot from the backend. This operation is collective. Attempting to access the global memory slot after this operation will result in undefined behavior.
- Parameters
-
[in] memorySlot Memory slot to destroy.
◆ destroyPromotedGlobalMemorySlot()
|
inlinevirtual |
Destroys a (locally promoted) global memory slot. This operation is blocking and non-collective. The effects will be visible immediately after the call to this function.
If the memory slot has not been created through promoteLocalMemorySlot, the behavior is undefined.
- Parameters
-
[in] memorySlot Memory slot to destroy.
◆ exchangeGlobalMemorySlots()
|
inline |
Exchanges memory slots among different local instances of HiCR to enable global (remote) communication
- Parameters
-
[in] tag Identifies a particular subset of global memory slots [in] memorySlots Array of local memory slots to make globally accessible
◆ exchangeGlobalMemorySlotsImpl()
|
protectedpure virtual |
Exchanges memory slots among different local instances of HiCR to enable global (remote) communication
- Parameters
-
[in] tag Identifies a particular subset of global memory slots [in] memorySlots Array of local memory slots to make globally accessible
◆ fence() [1/3]
|
inline |
Fences locally on a global, but locally allocated memory slot, until a number of messages are sent/received
This is a non-collective and blocking call; returning from this function indicates that specific to this locally allocated memory slot, incoming memory movement has completed and that outgoing memory movement has left the local interface.
- Parameters
-
[in] slot A global memory slot which is locally allocated [in] expectedSent number of messages to finish sending on slot before returning [in] expectedRecvd number of messages to finish receiving on slot before returning
◆ fence() [2/3]
|
inline |
Fences locally on a local memory slot until a number of messages are sent/received
This is a non-collective and blocking call; returning from this function indicates that specific to this memory slot, incoming memory movement has completed and that outgoing memory movement has left the local interface.
- Parameters
-
[in] slot A local memory slot [in] expectedSent number of messages to finish sending on slot before returning [in] expectedRecvd number of messages to finish receiving on slot before returning
◆ fence() [3/3]
|
inline |
Fences a group of memory copies.
This is a collective and blocking call; returning from this function indicates that all local incoming memory movement has completed and that all outgoing memory movement has left the local interface (and is guaranteed to arrive at the remote memory space, modulo any fatal exception).
This function also finishes all pending local to global memory slot promotions, as well as destructions, only for the specified tag.
This call is thread-safe.
- Parameters
-
[in] tag A tag that releases all processes that share the same value once they have arrived at it Exceptions are thrown in the following cases: - One of the remote address spaces no longer has an active communication channel. This is a fatal exception from which HiCR cannot recover. The user is encouraged to exit gracefully without initiating any further communication or waits.
- Todo:
- How does this interact with malleability of resources of which HiCR is aware? One possible answer is a special event that if left unhandled, is promoted to a fatal exception.
◆ fenceImpl() [1/3]
|
inlineprotectedvirtual |
Backend-internal implementation of the fence on a global memory slot
- Parameters
-
[in] slot A global (but locally allocated) memory slot [in] expectedSent number of messages to finish sending on slot before returning [in] expectedRcvd number of messages to finish receiving on slot before returning
◆ fenceImpl() [2/3]
|
inlineprotectedvirtual |
Backend-internal implementation of the fence on a local memory slot
- Parameters
-
[in] slot A local memory slot [in] expectedSent number of messages to finish sending on slot before returning [in] expectedRcvd number of messages to finish receiving on slot before returning
◆ fenceImpl() [3/3]
|
protectedpure virtual |
Backend-internal implementation of the fence function
- Parameters
-
[in] tag A tag that releases all processes that share the same value once they have arrived at it
◆ flushReceived()
|
inlinevirtual |
This function flushes receives registered at remote queue of receiver
◆ flushSent()
|
inlinevirtual |
This function flushes pending send operations
◆ getGlobalMemorySlot()
|
inline |
Retrieves the map of globally registered slots
- Parameters
-
[in] tag Tag that identifies a subset of all global memory slots [in] globalKey The sorting key inside the tag subset that distinguished between registered slots
- Returns
- The map of registered global memory slots, filtered by tag and mapped by key
- Note
- This method is not thread-safe. It is up to the application developer to ensure that
◆ getGlobalMemorySlotImpl()
|
protectedpure virtual |
Backend-internal implementation of the getGlobalMemorySlot function
Retrieves the map of globally registered slots
- Parameters
-
[in] tag Tag that identifies a subset of all global memory slots [in] globalKey The sorting key inside the tag subset that distinguished between registered slots
- Returns
- The map of registered global memory slots, filtered by tag and mapped by key
Implemented in HiCR::backend::pthreads::CommunicationManager.
◆ getGlobalMemorySlotsToDestroyPerTag()
|
inlineprotected |
Accessor for the Global slots to destroy per tag field
- Returns
- A reference to the Global slots to destroy per tag field
◆ getGlobalMemorySlotTagKeyMap()
|
inlineprotected |
Accessor for the Global slots/tag key map
- Returns
- A reference to the Global slots/tag key map
◆ increaseMessageRecvCounter()
|
inlineprotectednoexcept |
Increases the message receive counter for a given memory slot
- Parameters
-
[in] memorySlot The provided memory slot
◆ increaseMessageSentCounter()
|
inlineprotectednoexcept |
Increases the message sent counter for a given memory slot
- Parameters
-
[in] memorySlot The provided memory slot
◆ lock()
|
inlinevirtual |
Backend-internal implementation of the locking of a mutual exclusion mechanism. By default, a single mutex can protect access to internal fields. It is up to the application developer to ensure that the mutex is used correctly and efficiently, e.g., grouping multiple operations under a single lock.
- Todo:
- : Implement a more fine-grained locking mechanism, e.g., per map mutex or parallel maps, and expose thread-safe operations to the user.
◆ memcpy() [1/3]
|
inline |
Instructs the backend to perform an asynchronous memory copy from within a local memory slot, to within a global memory slot.
- Parameters
-
[in] destination The destination global memory slot [in] dst_offset The offset (in bytes) within destination at dst_locality [in] source The local source memory slot [in] src_offset The offset (in bytes) within source at src_locality [in] size The number of bytes to copy from the source to the destination
◆ memcpy() [2/3]
|
inline |
Instructs the backend to perform an asynchronous memory copy from within a global memory slot, to within a local memory slot.
- Parameters
-
[in] destination The destination local memory slot [in] dst_offset The offset (in bytes) within destination at dst_locality [in] source The global source memory slot [in] src_offset The offset (in bytes) within source at src_locality [in] size The number of bytes to copy from the source to the destination
◆ memcpy() [3/3]
|
inline |
Instructs the backend to perform an asynchronous memory copy from within a local memory slot, to within a local memory slot.
- Parameters
-
[in] source The local source memory slot [in] src_offset The offset (in bytes) within source at src_locality [in] destination The destination local memory slot [in] dst_offset The offset (in bytes) within destination at dst_locality [in] size The number of bytes to copy from the source to the destination
◆ memcpyImpl() [1/3]
|
inlineprotectedvirtual |
Backend-internal implementation of the memcpy function
- Parameters
-
[in] destination The destination global memory slot [in] dst_offset The offset (in bytes) within destination at dst_locality [in] source The source local memory slot [in] src_offset The offset (in bytes) within source at src_locality [in] size The number of bytes to copy from the source to the destination
◆ memcpyImpl() [2/3]
|
inlineprotectedvirtual |
Backend-internal implementation of the memcpy function
- Parameters
-
[in] destination The destination local memory slot [in] dst_offset The offset (in bytes) within destination at dst_locality [in] source The source global memory slot [in] src_offset The offset (in bytes) within source at src_locality [in] size The number of bytes to copy from the source to the destination
◆ memcpyImpl() [3/3]
|
inlineprotectedvirtual |
Backend-internal implementation of the memcpy function
- Parameters
-
[in] destination The destination local memory slot [in] dst_offset The offset (in bytes) within destination at dst_locality [in] source The source local memory slot [in] src_offset The offset (in bytes) within source at src_locality [in] size The number of bytes to copy from the source to the destination
◆ promoteLocalMemorySlot()
|
inlinevirtual |
Promotes a local memory slot to a global memory slot without collective exchange across all instances. This is an alternative to the exchangeGlobalMemorySlots function, which is a collective operation, and remains the primary way to promote local memory slots to global memory slots, since using a slot produced by this promote operation requires communicating it via a pre-established communication channel.
- Parameters
-
[in] localMemorySlot The local memory slot to promote [in] tag The tag to associate with the promoted global memory slot
- Returns
- A pointer to the promoted global memory slot
◆ queryMemorySlotUpdates()
|
inline |
Queries the backend to update the internal state of the memory slot. One main use case of this function is to update the number of messages received and sent to/from this slot. This is a non-blocking, non-collective function.
- Parameters
-
[in] memorySlot Identifier of the memory slot to query for updates.
◆ queryMemorySlotUpdatesImpl()
|
protectedpure virtual |
Backend-internal implementation of the queryMemorySlotUpdates function
- Parameters
-
[in] memorySlot Memory slot to query updates for.
◆ registerGlobalMemorySlot()
|
inlineprotected |
Registers a global memory slot from a given address.
- Parameters
-
[in] memorySlot Newly created global memory slot to register
◆ releaseGlobalLock()
|
inline |
This function releases a previously acquired lock on a global memory slot
- Parameters
-
[in] memorySlot The memory slot to release
◆ releaseGlobalLockImpl()
|
protectedpure virtual |
Backend-specific implementation of the releaseGlobalLock function
- Parameters
-
[in] memorySlot See the releaseGlobalLock function
◆ serializeGlobalMemorySlot()
|
inlinevirtual |
Serializes a global memory slot, belonging to the current instance, into a buffer that can be sent over the network to other instances, without the need to engage in a collective operation.
- Parameters
-
[in] globalSlot The global memory slot to serialize
- Returns
- A pointer to the serialized representation of the global memory slot in a newly allocated buffer. An exception is thrown if the backend does not support the operation
- Note
- The user is responsible for freeing the buffer, using delete[]
◆ setMessagesRecv()
|
inlineprotectednoexcept |
Sets the message receive counter for a given memory slot
- Parameters
-
[in] memorySlot The provided memory slot [in] count The new value to set for the counter
◆ setMessagesSent()
|
inlineprotectednoexcept |
Sets the message sent counter for a given memory slot
- Parameters
-
[in] memorySlot The provided memory slot [in] count The new value to set for the counter
◆ unlock()
|
inlinevirtual |
Backend-internal implementation of the unlocking of a mutual exclusion mechanism. Same considerations as for lock() apply.
The documentation for this class was generated from the following file:
- /home/runner/work/HiCR/HiCR/include/hicr/core/communicationManager.hpp
Generated by