Device#

Fully qualified name: isaacsim::common::array::Device

class Device#

Represents a compute device, either CPU or a CUDA-capable GPU.

A Device encodes a compute target as a signed device index (ordinal). The CPU is represented by ordinal -1; CUDA devices are represented by their non-negative device index.

Instances can be constructed from an ordinal, a string descriptor (e.g. "cpu", "cuda", "cuda:0"), or via the named factory methods Cpu() and Cuda().

Public Functions

Device(details::SupportedDeviceSpecification input)#

Constructs a Device from a supported device specification.

Parameters:

input – [in] Integer ordinal or string descriptor identifying the device.

Device() = delete#
Device(const Device &other) = default#

Copy-constructs a device descriptor.

Device(Device &&other) = default#

Move-constructs a device descriptor.

~Device() = default#
Device &operator=(const Device &other) = default#

Copy-assigns a device descriptor.

Device &operator=(Device &&other) = default#

Move-assigns a device descriptor.

bool operator==(const Device &other) const#

Checks whether two devices refer to the same compute target.

Parameters:

other – [in] The Device to compare against.

Returns:

true if both devices have equal ordinals.

bool operator!=(const Device &other) const#

Checks whether two devices refer to different compute targets.

Parameters:

other – [in] The Device to compare against.

Returns:

true if the devices have different ordinals.

int32_t ordinal() const#

Returns the device ordinal.

Returns:

-1 for the CPU, or a non-negative CUDA device index.

bool isCpu() const#

Returns whether this device is the CPU.

Returns:

true if the ordinal is -1.

bool isCuda() const#

Returns whether this device is a CUDA GPU.

Returns:

true if the ordinal is non-negative.

bool isAvailable() const#

Returns whether this device is present and usable on the current system.

Returns:

true if the device is accessible at runtime.

std::string toString() const#

Returns a human-readable string descriptor for this device.

Returns:

"cpu" for the CPU, or "cuda:<ordinal>" for a CUDA device.

Public Static Functions

static Device fromString(const std::string &name)#

Constructs a Device from a string descriptor.

Accepted formats: "cpu", "cuda" (equivalent to "cuda:0"), and "cuda:<N>" where N is a non-negative integer ordinal.

Parameters:

name – [in] String descriptor of the device.

Throws:

std::invalid_argument – if name is not a recognized descriptor.

Returns:

The corresponding Device.

static Device Cpu()#

Constructs a Device representing the CPU.

Returns:

A Device with ordinal -1.

static Device Cuda(int32_t ordinal = 0)#

Constructs a Device representing a CUDA GPU.

Parameters:

ordinal – [in] Non-negative CUDA device index. Defaults to 0.

Returns:

A Device with the specified CUDA ordinal.