Class CUDAMessage

Class Documentation

class CUDAMessage

This class is CUDASimulation’s internal handler for message functionality

Public Functions

explicit CUDAMessage(const MsgBruteForce::Data &description, const CUDASimulation &cuda_model)

allocates the hash table/list for message variables and copy the list to device

Constructs a CUDAMessage object Allocates enough memory for each variable within the provided MessageData CUDAMessage class

Parameters

description – The message to represent

virtual ~CUDAMessage(void)

Destroys the CUDAMessage object.

Destructor, releases CUDA memory

A destructor.

const MsgBruteForce::Data &getMessageDescription() const

Returns message description.

Return an immutable reference to the message description represented by the CUDAMessage instance

Parameters

none

Returns

MessageDescription object

unsigned int getMaximumListSize() const

Returns the maximum list size.

Note

may want to change this to maximum population size

Parameters

none

Returns

The currently allocated length of the message array (in the number of messages)

Returns

maximum size list that is equal to the maximum list size

unsigned int getMessageCount() const
Returns

The current number of messages

void setMessageCount(const unsigned int &_message_count)

Manually update the message count

Note

This should be used cautiously

Note

Required by array message types

void init(CUDAScatter &scatter, const unsigned int &streamId)

Initialise the CUDAMessagelist This allocates and initialises any CUDA data structures for reading the messagelist, and sets them asthough the messagelist were empty.

Parameters
  • scatter – Scatter instance and scan arrays to be used (CUDASimulation::singletons->scatter)

  • streamId – Index of stream specific structures used

void resize(unsigned int newSize, CUDAScatter &scatter, const unsigned int &streamId)

Sets initial message data to zero by allocating memory for message lists.

Updates message_count to equal newSize, internally reallocates buffer space if more space is required

Parameters
  • newSize – The number of messages that the buffer should be capable of storing

  • scatter – Scatter instance and scan arrays to be used (CUDASimulation::singletons->scatter)

  • streamId – Index of stream specific structures used

  • empty

Returns

none

void mapReadRuntimeVariables(const AgentFunctionData &func, const CUDAAgent &cuda_agent, const unsigned int &instance_id) const

Uses the cuRVE runtime to map the variables used by the agent function to the cuRVE library so that can be accessed by name within a n agent function The read runtime variables are to be used when reading messages

Bug:

message_name is input or output, run some tests to see which one is correct

Parameters
  • func – The agent function, this is used for the cuRVE hash mapping

  • instance_id – The CUDASimulation instance_id of the parent instance. This is added to the hash, to differentiate instances

void mapWriteRuntimeVariables(const AgentFunctionData &func, const CUDAAgent &cuda_agent, const unsigned int &writeLen, const unsigned int &instance_id) const

Uses the cuRVE runtime to map the variables used by the agent function to the cuRVE library so that can be accessed by name within a n agent function The write runtime variables are to be used when creating messages, as they are output to swap space

Note

swap() or scatter() should be called after the agent function has written messages

Parameters
  • func – The agent function, this is used for the cuRVE hash mapping

  • writeLen – The number of messages to be output, as the length isn’t updated till after output

  • instance_id – The CUDASimulation instance_id of the parent instance. This is added to the hash, to differentiate instances

void unmapRuntimeVariables(const AgentFunctionData &func, const unsigned int &instance_id) const

Uses the cuRVE runtime to unmap the variables used by the agent function to the cuRVE library so that they are unavailable to be accessed by name within an agent function.

Parameters
  • func – The agent function, this is used for the cuRVE hash mapping

  • instance_id – The CUDASimulation instance_id of the parent instance. This is added to the hash, to differentiate instances

void *getReadPtr(const std::string &var_name)
inline const CUDAMsgMap &getReadList()
inline const CUDAMsgMap &getWriteList()
void swap(bool isOptional, const unsigned int &newMsgCount, CUDAScatter &scatter, const unsigned int &streamId)

Swaps the two internal maps within message_list

Parameters
  • isOptional – If optional newMsgCount will be reduced based on scan_flag[streamId]

  • newMsgCount – The number of output messages (including optional messages which were not output)

  • scatter – Scatter instance and scan arrays to be used (CUDASimulation::singletons->scatter)

  • streamId – Index of stream specific structures used

Throws

InvalidCudaMessage – If this is called before the internal buffers have been allocated

void swap()

Basic list swap with no additional actions

inline bool getTruncateMessageListFlag() const
inline void setTruncateMessageListFlag()
inline void clearTruncateMessageListFlag()
inline bool getPBMConstructionRequiredFlag() const
inline void setPBMConstructionRequiredFlag()
inline void clearPBMConstructionRequiredFlag()
void buildIndex(CUDAScatter &scatter, const unsigned int &streamId, const cudaStream_t &stream)

Builds index, required to read messages (some messaging types won’t require an implementation)

Parameters
  • scatter – Scatter instance and scan arrays to be used (CUDASimulation::singletons->scatter)

  • streamId – Index of stream specific structures used

const void *getMetaDataDevicePtr() const

Protected Functions

void zeroAllMessageData()

Sets all message variable data to zero.

Zero all message variable data.

Parameters

none

Returns

none