Open3D (C++ API)  0.17.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes
open3d::core::Device Class Reference

#include <Device.h>

Public Types

enum class  DeviceType { CPU = 0 , CUDA = 1 , SYCL = 2 }
 Type for device. More...
 

Public Member Functions

 Device ()=default
 Default constructor -> "CPU:0". More...
 
 Device (DeviceType device_type, int device_id)
 Constructor with device specified. More...
 
 Device (const std::string &device_type, int device_id)
 Constructor from device type string and device id. More...
 
 Device (const std::string &type_colon_id)
 Constructor from string, e.g. "CUDA:0". More...
 
bool operator== (const Device &other) const
 
bool operator!= (const Device &other) const
 
bool operator< (const Device &other) const
 
bool IsCPU () const
 Returns true iff device type is CPU. More...
 
bool IsCUDA () const
 Returns true iff device type is CUDA. More...
 
bool IsSYCL () const
 Returns true iff device type is SYCL GPU. More...
 
std::string ToString () const
 Returns string representation of device, e.g. "CPU:0", "CUDA:0". More...
 
DeviceType GetType () const
 Returns type of the device, e.g. DeviceType::CPU, DeviceType::CUDA. More...
 
int GetID () const
 Returns the device index (within the same device type). More...
 
bool IsAvailable () const
 Returns true if the device is available. More...
 

Static Public Member Functions

static std::vector< DeviceGetAvailableDevices ()
 Returns a vector of available devices. More...
 
static std::vector< DeviceGetAvailableCPUDevices ()
 Returns a vector of available CPU device. More...
 
static std::vector< DeviceGetAvailableCUDADevices ()
 Returns a vector of available CUDA device. More...
 
static std::vector< DeviceGetAvailableSYCLDevices ()
 Returns a vector of available SYCL device. More...
 
static void PrintAvailableDevices ()
 Print all available devices. More...
 

Protected Attributes

DeviceType device_type_ = DeviceType::CPU
 
int device_id_ = 0
 

Detailed Description

Device context specifying device type and device id. For CPU, there is only one device with id 0.

Member Enumeration Documentation

◆ DeviceType

Type for device.

Enumerator
CPU 
CUDA 
SYCL 

Constructor & Destructor Documentation

◆ Device() [1/4]

open3d::core::Device::Device ( )
default

Default constructor -> "CPU:0".

◆ Device() [2/4]

open3d::core::Device::Device ( DeviceType  device_type,
int  device_id 
)
explicit

Constructor with device specified.

◆ Device() [3/4]

open3d::core::Device::Device ( const std::string &  device_type,
int  device_id 
)
explicit

Constructor from device type string and device id.

◆ Device() [4/4]

open3d::core::Device::Device ( const std::string &  type_colon_id)
explicit

Constructor from string, e.g. "CUDA:0".

Member Function Documentation

◆ GetAvailableCPUDevices()

std::vector< Device > open3d::core::Device::GetAvailableCPUDevices ( )
static

Returns a vector of available CPU device.

◆ GetAvailableCUDADevices()

std::vector< Device > open3d::core::Device::GetAvailableCUDADevices ( )
static

Returns a vector of available CUDA device.

◆ GetAvailableDevices()

std::vector< Device > open3d::core::Device::GetAvailableDevices ( )
static

Returns a vector of available devices.

◆ GetAvailableSYCLDevices()

std::vector< Device > open3d::core::Device::GetAvailableSYCLDevices ( )
static

Returns a vector of available SYCL device.

◆ GetID()

int open3d::core::Device::GetID ( ) const
inline

Returns the device index (within the same device type).

◆ GetType()

DeviceType open3d::core::Device::GetType ( ) const
inline

Returns type of the device, e.g. DeviceType::CPU, DeviceType::CUDA.

◆ IsAvailable()

bool open3d::core::Device::IsAvailable ( ) const

Returns true if the device is available.

◆ IsCPU()

bool open3d::core::Device::IsCPU ( ) const
inline

Returns true iff device type is CPU.

◆ IsCUDA()

bool open3d::core::Device::IsCUDA ( ) const
inline

Returns true iff device type is CUDA.

◆ IsSYCL()

bool open3d::core::Device::IsSYCL ( ) const
inline

Returns true iff device type is SYCL GPU.

◆ operator!=()

bool open3d::core::Device::operator!= ( const Device other) const

◆ operator<()

bool open3d::core::Device::operator< ( const Device other) const

◆ operator==()

bool open3d::core::Device::operator== ( const Device other) const

◆ PrintAvailableDevices()

void open3d::core::Device::PrintAvailableDevices ( )
static

Print all available devices.

◆ ToString()

std::string open3d::core::Device::ToString ( ) const

Returns string representation of device, e.g. "CPU:0", "CUDA:0".

Field Documentation

◆ device_id_

int open3d::core::Device::device_id_ = 0
protected

◆ device_type_

DeviceType open3d::core::Device::device_type_ = DeviceType::CPU
protected

The documentation for this class was generated from the following files: