Class ReadOnlyDeviceAPI

Class Documentation

class ReadOnlyDeviceAPI

FLAMEGPU_API is a singleton class for the device runtime.

Public Functions

__device__ inline ReadOnlyDeviceAPI(curandState *&d_rng)
Parameters

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]) const

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 being accessed

  • N – 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 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 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) const

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 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 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 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 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 ReadOnlyDeviceEnvironment environment

Provides access to environment variables inside agent functions

Public Static Functions

__forceinline__ __device__ static inline 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