Struct CompNode::Locator

Nested Relationships

This struct is a nested type of Class CompNode.

Struct Documentation

struct mgb::CompNode::Locator

an identifier to specify a computing node

Note: logical locator is directly parsed from a string identifier given by user; it should be translated to physical locator by calling to_physical() before actual use.

Unless explicitly specified otherwise, all locators are physical locators.

Public Functions

Locator to_physical() const

get corresponding physical Locator

DeviceType::UNSPEC would be resolved, and device map would be applied on device number

std::string to_string() const

get string description of this locator that can be parsed again

bool operator==(const Locator &rhs) const

Public Members

DeviceType type = DeviceType::UNSPEC
int device = -1

corresponding to a physical computing device; memories between different devices are not shared.

device == -1 means logical default device (maps to 0 by default, and can be changed by set_device_map)

int stream = 0
int nr_threads
union mgb::CompNode::Locator::[anonymous] [anonymous]

multiple streams can execute on one computing device and share memory, when compnode type is multithread the field also stand for nr_threads

Public Static Functions

Locator parse(const std::string &id)

parse a string identifier

currently supported ID format: (gpu|cpu)<n>[:m] where n is the device number, possibly with m as the stream id.

void set_device_map(DeviceType type, int from, int to)

set mapping between device numbers of a device type

void set_unspec_device_type(DeviceType type)

set the actual device type to be used for DeviceType::UNSPEC

Public Static Attributes

constexpr int DEVICE_CPU_DEFAULT = -1024

special device number for the “cpu default” comp node, which dispatches all tasks in the caller thread

constexpr int DEVICE_MULTITHREAD_DEFAULT = -1025

special device number for the “multithread_default” comp node, which dispatches all tasks to thread pool and the caller thread is the main thread of thread pool