Class Mass#

Class Documentation#

class Mass#

Public Static Functions

static void init(int argc, char *argv[])#

Initializes the MASS environment based on the CLI arguments Must be called prior to all other MASS methods.

static void init()#

Initializes the MASS environment with default setting.

In this case, the current host is treated as the master node and no other nodes will join the simulation

Must be called prior to all other MASS methods.

static void finish()#

Shuts down the MASS environment, releasing all resources.

static std::shared_ptr<Places> getPlaces(EntityHandle handle)#

Gets the places object for this handle.

Parameters:

handle – an int that uniquely identifies a places collection.

Returns:

NULL if not found.

static Count getNumPlaces()#

Gets the number of Places collections in this simulation.

static const internal::DeviceDriver &getLocalDeviceDriver(DeviceRank rank)#
static const std::vector<DeviceRank> &getLocalDeviceRanks()#

Get the list of device ranks of the GPUs on this host

Returns:

a vector of the device ranks

static Count getHostCount()#

Get the number of hosts joined in this simulation

Returns:

number of hosts

template<typename DeviceRankCollection, internal::type_deduction::require_span_convertible_t<DeviceRankCollection, DeviceRank> = 0>
static std::unique_ptr<CudaEventTimer> createCudaTimer(const DeviceRankCollection &includedDeviceRanks)#

Create a timer based on GPU events for measuring execution time

Parameters:

includedDeviceRanks – the collection of ranks of the devices that should be included for the time measurement. Leave empty to include all the devices on this host

Returns:

the created timer

static std::unique_ptr<CudaEventTimer> createCudaTimer(std::initializer_list<DeviceRank> includedDeviceRanks = {})#

Create a timer based on GPU events for measuring execution time

Parameters:

includedDeviceRanks – the collection of ranks of the devices that should be included for the time measurement Leave empty to include all the devices on this host

Returns:

the created timer

template<typename PlaceType>
static std::shared_ptr<Places> createPlaces(EntityHandle handle, Dimension dimensions, const Size size[], MemoryOrder majorType = MemoryOrder::ROW_MAJOR, std::variant<Size, GhostSize> ghostSize = 1)#

Creates a Places instance with the provided parameters.

Parameters:
  • handle – The unique handle for this Places collection.

  • dimensions – The number of dimensions of the grid of places.

  • size – The size of the grid of places.

  • majorType – The major type of the grid of places. It can be either Place::ROW_MAJOR or Place::COL_MAJOR. This will be used to calculate the offset from relative coordinates when updating neighbors of a place.

  • ghostSize – The size of the

Returns:

The Places instance created.

template<typename PlaceType>
static std::shared_ptr<Places> createPlaces(EntityHandle handle, Dimension dimensions, const Size32 size[], MemoryOrder majorType = MemoryOrder::ROW_MAJOR, std::variant<Size, GhostSize> ghostSize = 1)#

Creates a Places instance with the provided parameters.

Parameters:
  • handle – The unique handle for this Places collection.

  • dimensions – The number of dimensions of the grid of places.

  • size – The size of the grid of places.

  • majorType – The major type of the grid of places. It can be either Place::ROW_MAJOR or Place::COL_MAJOR. This will be used to calculate the offset from relative coordinates when updating neighbors of a place.

  • ghostSize – the size of the ghost regions

Returns:

The Places instance created.

template<typename PlaceType>
static std::shared_ptr<Places> createPlaces(EntityHandle handle, NDSize globalSize, std::variant<Size, GhostSize> ghostSize = 1, const std::optional<NDArray<DeviceRank>> &globalDeviceMap = std::nullopt, MemoryOrder majorType = MemoryOrder::ROW_MAJOR)#

Create a Places instance with the provided parameters

Template Parameters:

PlaceType – the type of the custom mass::Place implementation

Parameters:
  • handle – the unique integer handle used for the newly created Places

  • globalSize – the size of the complete Places grid

  • ghostSize – the size of the ghost regions

  • globalDeviceMap – rules for mapping devices to block of Places

  • majorType – the memory order of the Places grid

Returns:

the created Places

template<typename PlaceType>
static std::shared_ptr<Places> createPlaces(EntityHandle handle, PlacesConfig config)#

Create a Places instance with the provided parameters

Template Parameters:

PlaceType – the type of the custom mass::Place implementation

Parameters:
  • handle – the unique integer handle used for the newly created Places

  • config – the configuration used for creating the Places

Returns:

the created Places

template<typename AgentType>
static std::shared_ptr<Agents> createAgents(EntityHandle handle, Count nAgents, EntityHandle placesHandle, std::optional<Count> maxAgents = std::nullopt, const Index *placeIdxs = nullptr)#

Creates a Agents instance with the provided parameters.

Parameters:
  • handle – the unique handle used for the newly created Agents

  • nAgents – is the initial number of agents instantiated in the system

  • placesHandle – is the handle of the Places over which to instantiate the Agents.

  • maxAgents – is the maximum number of agents that can be present in the system thoughout the whole simulation. If the maxAgents parameter is omitted the library set it to the default value of nAgents*2.

  • placeIdxs – is the array of size nAgents, specifying the index of a place for where each of the Agents should be instantiated. If placeIdxs parameter is omitted, the libary randomly distributes agents over the grid of places.

template<typename AgentType>
static std::shared_ptr<Agents> createAgents(EntityHandle handle, Count nAgents, const std::shared_ptr<Places> &places, std::optional<Count> maxAgents = std::nullopt, const Index *placeIdxs = nullptr)#

Creates a Agents instance with the provided parameters.

Parameters:
  • handle – the unique handle used for the newly created Agents

  • nAgents – is the initial number of agents instantiated in the system

  • places – is the handle of the Places collection over which to instantiate the Agents collection.

  • maxAgents – is the maximum number of agents that can be present in the system thoughout the whole simulation. If the maxAgents parameter is omitted the library set it to the default value of nAgents*2.

  • placeIdxs – is the array of size nAgents, specifying the index of a place for where each of the Agents should be instantiated. If placeIdxs parameter is omitted, the libary randomly distributes agents over the grid of places.

template<typename AgentType>
static std::shared_ptr<Agents> createAgents(EntityHandle handle, const AgentsConfig &config)#

Creates a Agents instance with the provided parameters.

Template Parameters:

AgentType – the type of the custom mass::Agent implementation

Parameters:
  • handle – the unique handle used for the newly created Agents

  • config – the configuration used for creating the Agents

Returns:

the created Agents