SST 15.0
Structural Simulation Toolkit
SST::Shared::SharedArray< bool >::Data Class Reference
Inheritance diagram for SST::Shared::SharedArray< bool >::Data:
SST::Shared::SharedObject SST::Shared::SharedObjectData SST::Core::Serialization::serializable SST::Core::Serialization::serializable SST::Core::Serialization::serializable_base SST::Core::Serialization::serializable_base

Public Types

using const_iterator
 
using const_reverse_iterator
 
- Public Types inherited from SST::Shared::SharedObject
enum  verify_type { VERIFY_UNINITIALIZED , FE_VERIFY , INIT_VERIFY , NO_VERIFY }
 Enum of verify types.
 

Public Member Functions

 Data (const std::string &name)
 
void setSize (size_t size, bool init_data, verify_type v_type)
 Set the size of the array.
 
size_t getSize ()
 
void update_write (int index, bool data)
 
void write (int index, bool data)
 
bool read (int index) const
 
bool mutex_read (int index) const
 
virtual SharedObjectChangeSetgetChangeSet () override
 Gets the changeset for this data on this rank.
 
virtual void resetChangeSet () override
 Resets the changeset for this data on this rank.
 
void serialize_order (SST::Core::Serialization::serializer &ser) override
 
 ImplementSerializable (SST::Shared::SharedArray< bool >::Data)
 
 Data (const std::string &name)
 
void setSize (size_t size, const bool &init_data, verify_type v_type)
 Set the size of the array.
 
size_t getSize ()
 
void update_write (int index, const bool &data)
 
void write (int index, const bool &data)
 
const bool & read (int index) const
 
const bool & mutex_read (int index) const
 
virtual SharedObjectChangeSetgetChangeSet () override
 Gets the changeset for this data on this rank.
 
virtual void resetChangeSet () override
 Resets the changeset for this data on this rank.
 
void serialize_order (SST::Core::Serialization::serializer &ser) override
 
 ImplementSerializable (SST::Shared::SharedArray< bool >::Data)
 
 SharedArray ()
 Default constructor for SharedArray.
 
 ~SharedArray ()
 Shared Array Destructor.
 
int initialize (const std::string &obj_name, size_t length=0, bool init_value=bool(), verify_type v_type=INIT_VERIFY)
 Initialize the SharedArray.
 
size_t size () const
 Get the length of the array.
 
bool empty () const
 Tests if array is empty.
 
const_iterator begin () const
 Get const_iterator to beginning of underlying map.
 
const_iterator end () const
 Get const_iterator to end of underlying map.
 
const_reverse_iterator rbegin () const
 Get const_reverse_iterator to beginning of underlying map.
 
const_reverse_iterator rend () const
 Get const_reverse_iterator to end of underlying map.
 
void publish ()
 Indicate that the calling element has written all the data it plans to write.
 
bool isFullyPublished ()
 Check whether all instances of this SharedArray have called publish().
 
void write (int index, const bool &value)
 Write data to the array.
 
const bool & operator[] (int index) const
 Read data from the array.
 
const bool & mutex_read (int index) const
 Read data from the array.
 
void serialize_order (SST::Core::Serialization::serializer &ser) override
 
- Public Member Functions inherited from SST::Shared::SharedObject
virtual void serialize_order (SST::Core::Serialization::serializer &UNUSED(ser)) override
 
void incPublishCount (SharedObjectData *data)
 
int incShareCount (SharedObjectData *data)
 
- Public Member Functions inherited from SST::Core::Serialization::serializable_base
virtual const char * cls_name () const =0
 
virtual uint32_t cls_id () const =0
 
virtual std::string serialization_name () const =0
 
- Public Member Functions inherited from SST::Shared::SharedObjectData
const std::string & getName ()
 Get the name of the SharedObject for this data.
 
bool isFullyPublished ()
 Checks to see if all instances of this SharedObject have called publish().
 
virtual int getShareCount ()
 Get the number of sharers for this data.
 
virtual int getPublishCount ()
 Get the number of instances that have called publish() on their instance of the shared object.
 

Data Fields

std::vector< bool > array
 
std::vector< bool > written
 
ChangeSet * change_set
 
bool init
 
verify_type verify
 
std::vector< bool > array
 
std::vector< bool > written
 
ChangeSet * change_set
 
bool init
 
verify_type verify
 
ImplementSerializable(SST::Shared::SharedArray< bool >) private Datadata
 

Additional Inherited Members

- Static Public Attributes inherited from SST::Shared::SharedObject
static ImplementSerializable(SST::Shared::SharedObject) protected SharedObjectDataManager manager
 
- Static Public Attributes inherited from SST::Core::Serialization::serializable
static constexpr uint32_t NullClsId = std::numeric_limits<uint32_t>::max()
 
- Static Public Attributes inherited from SST::Core::Serialization::serializable_base
static constexpr uint32_t NullClsId = std::numeric_limits<uint32_t>::max()
 
- Protected Types inherited from SST::Core::Serialization::serializable_base
enum  cxn_flag_t { ConstructorFlag }
 
- Protected Member Functions inherited from SST::Shared::SharedObjectData
void check_lock_for_write (const std::string &obj)
 
virtual int incShareCount ()
 Increment the count of sharers.
 
virtual void incPublishCount ()
 Increment the count of instances that have called publish.
 
void lock ()
 Called by the core when writing to shared regions is no longer allowed.
 
 SharedObjectData (const std::string &name)
 Constructor for SharedObjectData.
 
virtual ~SharedObjectData ()
 Destructor for SharedObjectData.
 
void serialize_order (SST::Core::Serialization::serializer &ser) override
 
 ImplementVirtualSerializable (SharedObjectData)
 
- Static Protected Member Functions inherited from SST::Core::Serialization::serializable_base
static void serializable_abort (uint32_t line, const char *file, const char *func, const char *obj)
 
- Protected Attributes inherited from SST::Shared::SharedObjectData
std::string name
 
int share_count
 
int publish_count
 
bool fully_published
 
bool locked
 
std::mutex mtx
 

Member Function Documentation

◆ empty()

bool SST::Shared::SharedArray< bool >::empty ( ) const
inline

Tests if array is empty.

Returns
true if array is empty (size = 0), false otherwise

◆ getChangeSet() [1/2]

virtual SharedObjectChangeSet * SST::Shared::SharedArray< bool >::Data::getChangeSet ( )
inlineoverridevirtual

Gets the changeset for this data on this rank.

This is called by the core when exchanging and merging data

Implements SST::Shared::SharedObjectData.

◆ getChangeSet() [2/2]

virtual SharedObjectChangeSet * SST::Shared::SharedArray< bool >::Data::getChangeSet ( )
inlineoverridevirtual

Gets the changeset for this data on this rank.

This is called by the core when exchanging and merging data

Implements SST::Shared::SharedObjectData.

◆ initialize()

int SST::Shared::SharedArray< bool >::initialize ( const std::string & obj_name,
size_t length = 0,
bool init_value = T(),
verify_type v_type = INIT_VERIFY )
inline

Initialize the SharedArray.

Parameters
obj_nameName of the object. This name is how the object is uniquely identified across ranks.
lengthLength of the array. The length can be 0 if no data is going to be written by the calling element, otherwise, it must be large enough to write the desired data. The final length of the array will be the maximum of the requested lengths. The length of the array can be queried using the size() method.
init_valuevalue that entries should be initialized to. By default, each array item will be initialized using the default constructor for the class being stored.
verify_modeSpecifies how multiply written data should be verified. FE_VERIFY uses a full/empty bit for each entry and if a value has previously been written, it will make sure the two values match. INIT_VERIFY will simply compare writes against the current value and will error unless the values aren't the same or the existing value is the init_value. When NO_VERIFY is passed, no verification will occur. This is mostly useful when you can guarantee that multiple elements won't write the same value and you want to do in-place modifications as you initialize. VERIFY_UNINITIALIZED is a reserved value and should not be passed.
Returns
returns the number of instances that have intialized themselve before this instance on this MPI rank.

◆ isFullyPublished()

bool SST::Shared::SharedArray< bool >::isFullyPublished ( )
inline

Check whether all instances of this SharedArray have called publish().

NOTE: Is is possible that this could return true one round, but false the next if a new instance of the SharedArray was initialized but not published after the last call.

◆ mutex_read()

const bool & SST::Shared::SharedArray< bool >::mutex_read ( int index) const
inline

Read data from the array.

This returns a const reference, so is read only. This version of read is always thread safe (

See also
operator[]).
Parameters
indexindex to read
Returns
const reference to data at index

◆ operator[]()

const bool & SST::Shared::SharedArray< bool >::operator[] ( int index) const
inline

Read data from the array.

This returns a const reference, so is read only.

NOTE: This function does not use a mutex, so it is possible to get invalid results if another thread caused a resize of the underlying data structure at the same time as the read. However, after the init() phase of simulation is complete (in setup() and beyond), this is always a safe operation. If reading during init() and you can't guarantee that all elements have already written all data to the SharedArray, use mutex_read() to guarantee thread safety.

Parameters
indexindex to read
Returns
const reference to data at index

◆ publish()

void SST::Shared::SharedArray< bool >::publish ( )
inline

Indicate that the calling element has written all the data it plans to write.

Writing to the array through this instance after publish() is called will create an error.

◆ resetChangeSet() [1/2]

virtual void SST::Shared::SharedArray< bool >::Data::resetChangeSet ( )
inlineoverridevirtual

Resets the changeset for this data on this rank.

This is called by the core when exchanging and merging data

Implements SST::Shared::SharedObjectData.

◆ resetChangeSet() [2/2]

virtual void SST::Shared::SharedArray< bool >::Data::resetChangeSet ( )
inlineoverridevirtual

Resets the changeset for this data on this rank.

This is called by the core when exchanging and merging data

Implements SST::Shared::SharedObjectData.

◆ serialize_order() [1/3]

void SST::Shared::SharedArray< bool >::serialize_order ( SST::Core::Serialization::serializer & ser)
inlineoverridevirtual

◆ serialize_order() [2/3]

void SST::Shared::SharedArray< bool >::Data::serialize_order ( SST::Core::Serialization::serializer & ser)
inlineoverridevirtual

◆ serialize_order() [3/3]

void SST::Shared::SharedArray< bool >::Data::serialize_order ( SST::Core::Serialization::serializer & ser)
inlineoverridevirtual

◆ setSize() [1/2]

void SST::Shared::SharedArray< bool >::Data::setSize ( size_t size,
bool init_data,
verify_type v_type )
inline

Set the size of the array.

An element can only write up to the current size (reading or writing beyond the size will create undefined behavior). However, an element can put in the size it needs for its writes and it will end up being the largest size requested. We use a vector underneatch the covers to manage the memory/copying of data.

References SST::Shared::SharedObjectData::lock(), and size().

◆ setSize() [2/2]

void SST::Shared::SharedArray< bool >::Data::setSize ( size_t size,
const bool & init_data,
verify_type v_type )
inline

Set the size of the array.

An element can only write up to the current size (reading or writing beyond the size will create undefined behavior). However, an element can put in the size it needs for it's writes and it will end up being the largest size requested. We use a vector underneatch the covers to manage the memory/copying of data.

◆ size()

size_t SST::Shared::SharedArray< bool >::size ( ) const
inline

Get the length of the array.

Returns
length of the array

Referenced by setSize().

◆ write()

void SST::Shared::SharedArray< bool >::write ( int index,
const bool & value )
inline

Write data to the array.

This function is thread-safe, as a mutex is used to ensure only one write at a time.

Parameters
indexindex of the write
valuevalue to be written

The documentation for this class was generated from the following file: