Core Class Reference

HiCR: HiCR::backend::pthreads::Core Class Reference
HiCR
HiCR::backend::pthreads::Core Class Reference

#include <core.hpp>

Public Member Functions

 Core (const size_t instanceCount)
 
__INLINE__ void insertGlobalSlot (const GlobalMemorySlot::tag_t tag, const GlobalMemorySlot::globalKey_t key, const std::shared_ptr< GlobalMemorySlot > &slot)
 
__INLINE__ std::shared_ptr< GlobalMemorySlotgetGlobalSlot (const GlobalMemorySlot::tag_t tag, const GlobalMemorySlot::globalKey_t key) const
 
__INLINE__ void removeGlobalSlot (const GlobalMemorySlot::tag_t tag, const GlobalMemorySlot::globalKey_t key)
 
__INLINE__ CommunicationManager::globalKeyToMemorySlotMap_t getKeyMemorySlots (const GlobalMemorySlot::tag_t tag) const
 
__INLINE__ void fence ()
 
__INLINE__ InstanceManager::instanceList_t getInstances () const
 
__INLINE__ std::shared_ptr< InstanceaddInstance (const pthread_t pthreadId)
 
__INLINE__ std::shared_ptr< InstancegetInstance (const pthread_t pthreadId) const
 
__INLINE__ Instance::instanceId_t getRootInstanceId () const
 

Detailed Description

Implementation of the Pthreads core to exchange global memory slots and detect HiCR instances.

This backend uses pthread-based mutexes and barriers to prevent concurrent access violations

Constructor & Destructor Documentation

◆ Core()

HiCR::backend::pthreads::Core::Core ( const size_t  instanceCount)
inline

Constructor

Parameters
[in]instanceCounthow many instances will be in the application

Member Function Documentation

◆ addInstance()

__INLINE__ std::shared_ptr< Instance > HiCR::backend::pthreads::Core::addInstance ( const pthread_t  pthreadId)
inline

Add a new instance in the core

Parameters
[in]pthreadIdpthread id of the new instance
Returns
the newly created instance
Note
this function is thread-safe

◆ fence()

__INLINE__ void HiCR::backend::pthreads::Core::fence ( )
inline

Synchronize all HiCR instances

◆ getGlobalSlot()

__INLINE__ std::shared_ptr< GlobalMemorySlot > HiCR::backend::pthreads::Core::getGlobalSlot ( const GlobalMemorySlot::tag_t  tag,
const GlobalMemorySlot::globalKey_t  key 
) const
inline

Retrieve a global memory slot

Parameters
[in]tagslot tag
[in]keyslot key
Returns
shared pointer to global memory slot if present, nullptr otherwise
Note
this function is thread-safe

◆ getInstance()

__INLINE__ std::shared_ptr< Instance > HiCR::backend::pthreads::Core::getInstance ( const pthread_t  pthreadId) const
inline

Get a specific instance

Parameters
[in]pthreadIdpthread id of the instance to retrieve
Returns
the HiCR instance associated with the given pthread id
Note
this function is thread-safe

◆ getInstances()

__INLINE__ InstanceManager::instanceList_t HiCR::backend::pthreads::Core::getInstances ( ) const
inline

Get all the instances registered in the core

Returns
a list of hicr instances
Note
this function is thread-safe

◆ getKeyMemorySlots()

__INLINE__ CommunicationManager::globalKeyToMemorySlotMap_t HiCR::backend::pthreads::Core::getKeyMemorySlots ( const GlobalMemorySlot::tag_t  tag) const
inline

Return the pair key-slots for a given tag

Parameters
[in]tag
Returns
key-slots pair, empty map otherwise
Note
this function is thread-safe

◆ getRootInstanceId()

__INLINE__ Instance::instanceId_t HiCR::backend::pthreads::Core::getRootInstanceId ( ) const
inline

Getter of the root instance id

Returns
the root instance id

◆ insertGlobalSlot()

__INLINE__ void HiCR::backend::pthreads::Core::insertGlobalSlot ( const GlobalMemorySlot::tag_t  tag,
const GlobalMemorySlot::globalKey_t  key,
const std::shared_ptr< GlobalMemorySlot > &  slot 
)
inline

Add an element into the shared memory space

Parameters
[in]tagslot tag
[in]keyslot key
[in]slotglobal memory slot
Note
this function is thread-safe

◆ removeGlobalSlot()

__INLINE__ void HiCR::backend::pthreads::Core::removeGlobalSlot ( const GlobalMemorySlot::tag_t  tag,
const GlobalMemorySlot::globalKey_t  key 
)
inline

Removes a global memory slot from the shared memory if present

Parameters
[in]tagslot tag
[in]keyslot key
Note
this function is thread-safe

The documentation for this class was generated from the following file:
  • /home/runner/work/HiCR/HiCR/include/hicr/backends/pthreads/core.hpp