Class HostCurve

Class Documentation

class HostCurve

Host instance of Curve

This class can be used to register variables within it’s curve hash table These variables can then have their values (pointers) updated at a later stage

The hash table is represented by a Curve::CurveTable, which can be copied to device memory for use with DeviceCurve

This interface does not support reading or unregistering variables, it is expected that variables registered to a HostCurve will persist for the lifetime of the HostCurve instance

Public Types

typedef Curve::Variable Variable
typedef Curve::VariableHash VariableHash
typedef Curve::NamespaceHash NamespaceHash

Public Functions

void registerAgentVariable(const std::string &variable_name, std::type_index type, size_t type_size, unsigned int elements)

Registers the specified agent variable within the curve hash table, storing the specified metadata Initially the variables device ptr will be set to nullptr

Note

It is recommend that you instead use the appropriate registerVariable() template function.

Parameters:
  • variable_name – The name used to access the agent variable

  • type – The type index of the variable, this is currently unused as device code does not support type checking

  • type_size – Size of the data type (this should be the size of a single element if an array variable)

  • elements – Number of elements (1 unless the variable is an array)

Returns:

Variable Handle of registered variable or UNKNOWN_VARIABLE if an error is encountered.

void registerMessageInputVariable(const std::string &variable_name, std::type_index type, size_t type_size, unsigned int elements)
void registerMessageOutputVariable(const std::string &variable_name, std::type_index type, size_t type_size, unsigned int elements)
void registerAgentOutputVariable(const std::string &variable_name, std::type_index type, size_t type_size, unsigned int elements)
void registerSetEnvironmentProperty(const std::string &variable_name, std::type_index type, size_t type_size, unsigned int elements, ptrdiff_t offset)
void registerSetMacroEnvironmentProperty(const std::string &variable_name, std::type_index type, size_t type_size, unsigned int elements, void *d_ptr)
void registerEnvironmentDirectedGraphVertexProperty(const std::string &graph_name, const std::string &variable_name, std::type_index type, size_t type_size, unsigned int elements)
void registerEnvironmentDirectedGraphEdgeProperty(const std::string &graph_name, const std::string &variable_name, std::type_index type, size_t type_size, unsigned int elements)
void setAgentVariable(const std::string &variable_name, void *d_ptr, unsigned int agent_count)

Updates the device pointer stored for the specified agent variable

Parameters:
  • variable_name – The name of the variable to update

  • d_ptr – The pointer to the variables buffer in device memory

  • agent_count – The number of variables in the buffer (currently unused?)

void setMessageInputVariable(const std::string &variable_name, void *d_ptr, unsigned int message_in_count)
void setMessageOutputVariable(const std::string &variable_name, void *d_ptr, unsigned int message_out_count)
void setAgentOutputVariable(const std::string &variable_name, void *d_ptr, unsigned int agent_count)
void setEnvironmentDirectedGraphVertexProperty(const std::string &graph_name, const std::string &variable_name, void *d_ptr, unsigned int vertex_count)
void setEnvironmentDirectedGraphEdgeProperty(const std::string &graph_name, const std::string &variable_name, void *d_ptr, unsigned int edge_count)
int size() const

Check how many items are in the hash table

Returns:

The number of items currently registered in the hash table

void updateDevice_async(cudaStream_t stream)

Copy host structures to device

This function copies the host hash table to the device, it must be used prior to launching agent functions (and agent function conditions) if Curve has been updated. 1 memcpy to device is always performed, CURVE does not track whether it has been changed internally.

Parameters:

stream – cuda stream for the copy

HostCurve()

Default constructor

~HostCurve()

Default destructor

Note

This attempts to free the Curve device buffer, so may throw an exception if the device has been reset, and purge() was not called

const CurveTable *getDevicePtr() const

Returns the pointer to curve in device memory

Public Static Attributes

static const int MAX_VARIABLES = Curve::MAX_VARIABLES
static const VariableHash EMPTY_FLAG = Curve::EMPTY_FLAG

Friends

friend class detail::CUDAAgent