Class CUDAMessage

Class Documentation

class flamegpu::CUDAMessage

This class is CUDASimulation’s internal handler for message functionality

Public Functions

explicit CUDAMessage(const MessageBruteForce::Data &description, const CUDASimulation &cudaSimulation)

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

Parameters
  • description – The message to represent

  • cudaSimulation – The simulation which owns the CUDAMessage

virtual ~CUDAMessage(void)

Destructor, releases CUDA memory

const MessageBruteForce::Data &getMessageDescription() const

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

unsigned int getMaximumListSize() const
Returns

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

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)

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

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

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

  • cuda_agent – Agent which owns the agent function (condition) being mapped, if RTC function this holds the RTC header

  • 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

  • cuda_agent – Agent which owns the agent function (condition) being mapped, if RTC function this holds the RTC header

  • 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 CUDAMessageMap &getReadList()
inline const CUDAMessageMap &getWriteList()
void swap(bool isOptional, const unsigned int &newMessageCount, CUDAScatter &scatter, const unsigned int &streamId)

Swaps the two internal maps within message_list

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

  • newMessageCount – 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

exception::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 – The stream index to use for accessing stream specific resources such as scan compaction arrays and buffers

  • stream – CUDA stream to be used for async CUDA operations

const void *getMetaDataDevicePtr() const

Protected Functions

void zeroAllMessageData()

Zero all message variable data.