Class ReadOnlyDeviceAPI

Class Documentation

class ReadOnlyDeviceAPI

FLAMEGPU_API is a singleton class for the device runtime.

Todo:

longer description

Public Functions

__device__ inline ReadOnlyDeviceAPI(const Curve::NamespaceHash &instance_id_hash, const Curve::NamespaceHash &agentfuncname_hash, curandState *&d_rng)
Parameters
  • instance_id_hash – CURVE hash of the CUDASimulation’s instance id

  • agentfuncname_hash – CURVE hash of the agent function

  • d_rng – Pointer to the device random state buffer to be used

template<typename T, unsigned int N>
__device__ T getVariable(const char (&variable_name)[N])

Returns the specified variable from the currently executing agent

Parameters

variable_name – name used for accessing the variable, this value should be a string literal e.g. “foobar”

Template Parameters
  • T – Type of the agent variable property being accessed

  • N – Length of variable name, this should always be implicit if passing a string literal

Throws
  • DeviceError – If name is not a valid variable within the agent (flamegpu must be built with SEATBELTS enabled for device error checking)

  • DeviceError – If T is not the type of variable ‘name’ within the agent (flamegpu must be built with SEATBELTS enabled for device error checking)

template<typename T, unsigned int N, unsigned int M>
__device__ T getVariable(const char (&variable_name)[M], const unsigned int &index)

Returns the specified variable array element from the currently executing agent

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 agent variable property being accessed

  • N – Length of variable_name, this should always be implicit if passing a string literal

Throws
  • DeviceError – If name is not a valid variable within the agent (flamegpu must be built with SEATBELTS enabled for device error checking)

  • DeviceError – If T is not the type of variable ‘name’ within the agent (flamegpu must be built with SEATBELTS enabled for device error checking)

  • DeviceError – If index is out of bounds for the variable array specified by name (flamegpu must be built with SEATBELTS enabled for device error checking)

__device__ inline id_t getID()

Returns the agent’s unique identifier

__forceinline__ __device__ inline unsigned int getStepCounter() const

Access the current stepCount

Returns

the current step count, 0 indexed unsigned.

Public Members

const AgentRandom random

Provides access to random functionality inside agent functions

Note

random state isn’t stored within the object, so it can be const

const DeviceEnvironment environment

Provides access to environment variables inside agent functions

Public Static Functions

static inline __forceinline__ static __device__ unsigned int getThreadIndex ()

Returns the current CUDA thread of the agent All agents execute in a unique thread, but their associated thread may change between agent functions Thread indices begin at 0 and continue to 1 below the number of agents executing

Protected Attributes

Curve::NamespaceHash agent_func_name_hash