Class CUDAMacroEnvironment

Nested Relationships

Nested Types

Class Documentation

class CUDAMacroEnvironment

This class is CUDASimulation’s internal handler for macro environment functionality

Public Functions

CUDAMacroEnvironment(const EnvironmentData &description, const CUDASimulation &_cudaSimulation)

Normal constructor

Parameters:
  • description – Agent description of the agent

  • _cudaSimulation – Parent CUDASimulation of the agent

CUDAMacroEnvironment(CUDAMacroEnvironment&) = delete
CUDAMacroEnvironment(CUDAMacroEnvironment&&) = delete
void init(cudaStream_t stream)

Performs CUDA allocations, and registers CURVE variables

void init(const SubEnvironmentData &mapping, std::shared_ptr<const detail::CUDAMacroEnvironment> master_macro_env, cudaStream_t stream)

Performs CUDA allocations, and registers CURVE variables Initialises submodel mappings too

Note

This must be called after the master model CUDAMacroEnvironment has init

Parameters:
  • mapping – The SubEnvironment mapping info

  • master_macro_env – The master model’s macro env to map sub macro properties with

  • stream – The CUDAStream to use for CUDA operations

void free()

Release all CUDA allocations, and unregisters CURVE variables

void mapRTCVariables(detail::curve::CurveRTCHost &curve_header) const

Register the properties to the provided RTC header

Parameters:

curve_header – The RTC header to act upon

void unmapRTCVariables(detail::curve::CurveRTCHost &curve_header) const

Release the properties to the provided RTC header

Parameters:

curve_header – The RTC header to act upon

void registerCurveVariables(detail::curve::HostCurve &curve) const

Register (and set) all owned macro properties within the specified curve instance

Parameters:

curve – The curve instance to act upon

void resetFlagsAsync(const std::vector<cudaStream_t> &streams)

Reset the flags used by seatbelts to catch potential race conditions

Parameters:

streams – Streams to async reset over

bool getDeviceReadFlag(const std::string &property_name)

Returns the current state of the device read flag for the named macro property

Parameters:

property_name – Name of the macro property to query

bool getDeviceWriteFlag(const std::string &property_name)

Returns the current state of the device read flag for the named macro property

Parameters:

property_name – Name of the macro property to query

unsigned int getDeviceRWFlags(const std::string &property_name)

Returns the raw flag variable used for read write flag for the named macro property

Note

This means both can be checked with a single memcpy

Note

Bit 0 being set means read has occurred, bit 1 being set means write has occurred

Parameters:

property_name – Name of the macro property to query

template<typename T, unsigned int I, unsigned int J, unsigned int K, unsigned int W>
HostMacroProperty<T, I, J, K, W> getProperty(const std::string &name)

Returns a HostAPI style direct accessor the macro property

Parameters:

name – Name of the macro property

Template Parameters:
  • T – Type of the macro property

  • I – 1st dimension length

  • J – 2nd dimension length

  • K – 3rd dimension length

  • W – 4th dimension length

const std::map<std::string, MacroEnvProp> &getPropertiesMap() const

Returns the full map of macro environment properties Used for IO

std::shared_ptr<HostMacroProperty_MetaData> getHostPropertyMetadata(const std::string property_name)

Return the metadata, if setup, for the named macro property

Parameters:

property_name – Name of the macro property to load

Returns:

nullptr if not currently cached

struct MacroEnvProp

Used to group items required by properties

Public Functions

inline MacroEnvProp(const std::type_index &_type, const size_t _type_size, const std::array<unsigned int, 4> &_elements)
Parameters:
  • _type – The type index of the base type (e.g. typeid(float))

  • _type_size – The size of the base type (e.g. sizeof(float))

  • _elements – Number of elements in each dimension

inline ~MacroEnvProp()
MacroEnvProp(const MacroEnvProp &other) = delete
inline MacroEnvProp(MacroEnvProp &&other)

Public Members

std::type_index type
size_t type_size
std::array<unsigned int, 4> elements
void *d_ptr
bool is_sub