Class MessageBruteForce
Defined in File MessageBruteForce.h
Nested Relationships
Nested Types
Class Documentation
-
class MessageBruteForce
Brute force messaging functionality
Every agent accesses all messages This technique is expensive, and other techniques are preferable if operating with more than 1000 messages.
-
class CDescription
Subclassed by flamegpu::MessageArray2D::CDescription, flamegpu::MessageArray3D::CDescription, flamegpu::MessageArray::CDescription, flamegpu::MessageBruteForce::Description, flamegpu::MessageBucket::CDescription, flamegpu::MessageSpatial2D::CDescription
Public Functions
-
Constructor, creates an interface to the MessageData
- Parameters:
data – Data store of this message’s data
-
CDescription(const CDescription &other_agent) = default
Copy constructor Creates a new interface to the same MessageData/ModelData
-
CDescription(CDescription &&other_agent) = default
-
CDescription &operator=(const CDescription &other_agent) = default
Assignment operator Assigns this interface to the same MessageData/ModelData
-
CDescription &operator=(CDescription &&other_agent) = default
-
bool operator==(const CDescription &rhs) const
Equality operator, checks whether message Description hierarchies are functionally the same
Note
Instead compare pointers if you wish to check that they are the same instance
- Parameters:
rhs – right hand side
- Returns:
True when messages are the same
-
bool operator!=(const CDescription &rhs) const
Equality operator, checks whether message Description hierarchies are functionally different
Note
Instead compare pointers if you wish to check that they are not the same instance
- Parameters:
rhs – right hand side
- Returns:
True when messages are not the same
-
std::string getName() const
Const Accessors
- Returns:
The message’s name
-
bool getPersistent() const
Query if the message list is a persistent message list or not (messages will persist from one iteration to the next)
- Returns:
if the message list is persistent or not
-
const std::type_index &getVariableType(const std::string &variable_name) const
- Parameters:
variable_name – Name used to refer to the desired variable
- Throws:
exception::InvalidMessageVar – If a variable with the name does not exist within the message
- Returns:
The type of the named variable
-
size_t getVariableSize(const std::string &variable_name) const
- Parameters:
variable_name – Name used to refer to the desired variable
- Throws:
exception::InvalidMessageVar – If a variable with the name does not exist within the message
- Returns:
The size of the named variable’s type
-
size_type getVariableLength(const std::string &variable_name) const
- Parameters:
variable_name – Name used to refer to the desired variable
- Throws:
exception::InvalidMessageVar – If a variable with the name does not exist within the agent
- Returns:
The number of elements in the name variable (1 if it isn’t an array)
-
bool hasVariable(const std::string &variable_name) const
- Parameters:
variable_name – Name of the variable to check
- Returns:
True when a variable with the specified name exists within the message
Protected Functions
-
inline void setPersistent(const bool persistent)
These mutable accessors will only be available via mutable subclasses This solves a multiple inheritance issue Set that the message list should be persistent or not
- Parameters:
persistent – new value for message list persistence
-
template<typename T>
void newVariable(const std::string &variable_name) Adds a new variable to the message
Template implementation
- Parameters:
variable_name – Name of the variable
- Template Parameters:
T – Type of the message variable, this must be an arithmetic type
- Throws:
exception::InvalidMessageVar – If a variable already exists within the message with the same name
-
template<typename T, flamegpu::size_type N>
void newVariable(const std::string &variable_name) Adds a new variable array to the message
- Parameters:
variable_name – Name of the variable array
- Template Parameters:
T – Type of the message variable, this must be an arithmetic type
N – The length of the variable array (1 if not an array, must be greater than 0)
- Throws:
exception::InvalidMessageVar – If a variable already exists within the message with the same name
exception::InvalidMessageVar – If N is <= 0
-
-
class CUDAModelHandler : public flamegpu::MessageSpecialisationHandler
Blank handler, brute force requires no index or special allocations Only stores the length on device
Public Functions
-
inline explicit CUDAModelHandler(detail::CUDAMessage &a)
Constructor Allocates memory on device for message list length
- Parameters:
a – Parent CUDAMessage, used to access message settings, data ptrs etc
-
inline ~CUDAModelHandler()
Destructor. Should free any local host memory (device memory cannot be freed in destructors)
-
virtual void init(detail::CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream) override
Allocates memory for the constructed index. Sets data asthough message list is empty
- 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 – The CUDAStream to use for CUDA operations
-
virtual void buildIndex(detail::CUDAScatter &scatter, unsigned int streamId, cudaStream_t stream) override
Updates the length of the messagelist stored on device
- 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 – The CUDAStream to use for CUDA operations
-
virtual void allocateMetaDataDevicePtr(cudaStream_t stream) override
Allocates memory for the constructed index. The memory allocation is checked by build index.
-
virtual void freeMetaDataDevicePtr() override
Releases memory for the constructed index.
-
inline virtual const void *getMetaDataDevicePtr() const override
Returns a pointer to the metadata struct, this is required for reading the message data
-
inline explicit CUDAModelHandler(detail::CUDAMessage &a)
-
struct Data
This is the internal data store for MessageDescription Users should only access that data stored within via an instance of MessageDescription
Subclassed by flamegpu::MessageArray2D::Data, flamegpu::MessageArray3D::Data, flamegpu::MessageArray::Data, flamegpu::MessageBucket::Data, flamegpu::MessageSpatial2D::Data
Public Functions
-
virtual ~Data() = default
-
bool operator==(const Data &rhs) const
Equality operator, checks whether MessageData hierarchies are functionally the same
Note
Instead compare pointers if you wish to check that they are the same instance
- Returns:
True when messages are the same
-
bool operator!=(const Data &rhs) const
Equality operator, checks whether MessageData hierarchies are functionally different
Note
Instead compare pointers if you wish to check that they are not the same instance
- Returns:
True when messages are not the same
-
virtual std::unique_ptr<MessageSpecialisationHandler> getSpecialisationHander(detail::CUDAMessage &owner) const
-
virtual std::type_index getType() const
Used internally to validate that the corresponding Message type is attached via the agent function shim.
- Returns:
The std::type_index of the Message type which must be used.
-
virtual flamegpu::MessageSortingType getSortingType() const
Return the sorting type for this message type
Public Members
-
VariableMap variables
Holds all of the message’s variable definitions
-
std::string name
Name of the message, used to refer to the message in many functions
-
bool persistent
Boolean indicating if the message list is allowed to persist iterations or not
-
unsigned int optional_outputs
The number of functions that have optional output of this message type This value is modified by AgentFunctionDescription
Protected Functions
Copy constructor This is unsafe, should only be used internally, use clone() instead
-
Normal constructor, only to be called by ModelDescription
Friends
- friend class ModelDescription
- friend struct ModelData
-
virtual ~Data() = default
-
class Description : public flamegpu::MessageBruteForce::CDescription
Within the model hierarchy, this class represents the definition of an message for a FLAMEGPU model This class is used to configure external elements of messages, such as variables Base-class, represents brute-force messages Can be extended by more advanced message descriptors
See also
MessageData The internal data store for this class
See also
ModelDescription::newMessage(const std::string&) For creating instances of this class
Public Functions
-
Constructor, creates an interface to the MessageData
- Parameters:
data – Data store of this message’s data
-
Description(const Description &other_message) = default
Copy constructor Creates a new interface to the same MessageData/ModelData
-
Description(Description &&other_message) = default
-
Description &operator=(const Description &other_message) = default
Assignment operator Assigns this interface to the same MessageData/ModelData
-
Description &operator=(Description &&other_message) = default
-
-
class In
This class is accessible via DeviceAPI.message_in if MessageBruteForce is specified in FLAMEGPU_AGENT_FUNCTION It gives access to functionality for reading brute force messages
Public Functions
-
__device__ inline In(const void *metadata)
Constructor Initialises member variables
- Parameters:
metadata – Reinterpreted as type MessageBruteForce::MetaData to extract length
-
class iterator
Stock iterator for iterating MessageBruteForce::In::Message objects
-
class Message
Provides access to a specific message Returned by the iterator
See also
Public Functions
-
__device__ inline Message(const MessageBruteForce::In &parent)
Constructs a message and directly initialises all of it’s member variables index is always init to 0
Note
See member variable documentation for their purposes
-
__device__ inline Message(const MessageBruteForce::In &parent, size_type index)
Alternate constructor, allows index to be manually set
Note
I think this is unused
-
__host__ __device__ inline bool operator==(const Message &rhs) const
Equality operator Compares all internal member vars for equality
Note
Does not compare _parent
-
__host__ __device__ inline bool operator!=(const Message &rhs) const
Inequality operator Returns inverse of equality operator
See also
operator==(const Message&)
-
__host__ __device__ inline Message &operator++()
Updates the message to return variables from the next message in the message list
- Returns:
Returns itself
-
__host__ __device__ inline size_type getIndex() const
Returns the index of the message within the full message list
-
template<typename T, unsigned int N>
__device__ T getVariable(const char (&variable_name)[N]) const Returns the value for the current message attached to the named variable
- Parameters:
variable_name – Name of the variable
- Template Parameters:
T – type of the variable
N – Length of variable name (this should be implicit if a string literal is passed to variable name)
- Throws:
exception::DeviceError – If name is not a valid variable within the agent (flamegpu must be built with FLAMEGPU_SEATBELTS enabled for device error checking)
exception::DeviceError – If T is not the type of variable ‘name’ within the agent (flamegpu must be built with FLAMEGPU_SEATBELTS enabled for device error checking)
- Returns:
The specified variable, else 0x0 if an error occurs
-
template<typename T, flamegpu::size_type N, unsigned int M>
__device__ T getVariable(const char (&variable_name)[M], unsigned int index) const Returns the specified variable array element from the current message attached to the named variable
- Parameters:
variable_name – name used for accessing the variable, this value should be a string literal e.g. “foobar”
index – Index of the element within the variable array to return
- Template Parameters:
T – Type of the message variable being accessed
N – The length of the array variable, as set within the model description hierarchy
M – Length of variable_name, this should always be implicit if passing a string literal
- Throws:
exception::DeviceError – If name is not a valid variable within the agent (flamegpu must be built with FLAMEGPU_SEATBELTS enabled for device error checking)
exception::DeviceError – If T is not the type of variable ‘name’ within the message (flamegpu must be built with FLAMEGPU_SEATBELTS enabled for device error checking)
exception::DeviceError – If index is out of bounds for the variable array specified by name (flamegpu must be built with FLAMEGPU_SEATBELTS enabled for device error checking)
-
__device__ inline Message(const MessageBruteForce::In &parent)
-
__device__ inline In(const void *metadata)
-
struct MetaData
MetaData required by brute force during message reads
Public Members
-
unsigned int length = 0
-
unsigned int length = 0
-
class Out
This class is accessible via DeviceAPI.message_out if MessageBruteForce is specified in FLAMEGPU_AGENT_FUNCTION It gives access to functionality for outputting brute force messages
Subclassed by flamegpu::MessageBucket::Out, flamegpu::MessageSpatial2D::Out, flamegpu::MessageSpatial3D::Out
Public Functions
-
__device__ inline Out(const void*, unsigned int *scan_flag_messageOutput)
Constructer Initialises member variables
- Parameters:
scan_flag_messageOutput – Scan flag array for optional message output
-
template<typename T, unsigned int N>
__device__ void setVariable(const char (&variable_name)[N], T value) const Sets the specified variable for this agents message
- Parameters:
variable_name – Name of the variable
value – The value to set the specified variable
- Template Parameters:
T – type of the variable
N – Length of variable name (this should be implicit if a string literal is passed to variable name)
- Returns:
The specified variable, else 0x0 if an error occurs
-
template<typename T, unsigned int N, unsigned int M>
__device__ void setVariable(const char (&variable_name)[M], unsigned int index, T value) const Sets an element of an array variable for this agents message
- Parameters:
variable_name – The name of the array variable
index – The index to set within the array variable
value – The value to set the element of the array element
- Template Parameters:
T – The type of the variable, as set within the model description hierarchy
N – The length of the array variable, as set within the model description hierarchy
M – variable_name length, this should be ignored as it is implicitly set
- Throws:
exception::DeviceError – If name is not a valid variable within the message (flamegpu must be built with FLAMEGPU_SEATBELTS enabled for device error checking)
exception::DeviceError – If T is not the type of variable ‘name’ within the message (flamegpu must be built with FLAMEGPU_SEATBELTS enabled for device error checking)
exception::DeviceError – If index is out of bounds for the variable array specified by name (flamegpu must be built with FLAMEGPU_SEATBELTS enabled for device error checking)
Protected Attributes
-
unsigned int *scan_flag
Scan flag array for optional message output
-
__device__ inline Out(const void*, unsigned int *scan_flag_messageOutput)
-
class CDescription