ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::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.

Definition at line 18 of file Device.h.

Member Enumeration Documentation

◆ DeviceType

Type for device.

Enumerator
CPU 
CUDA 
SYCL 

Definition at line 21 of file Device.h.

Constructor & Destructor Documentation

◆ Device() [1/4]

cloudViewer::core::Device::Device ( )
default

Default constructor -> "CPU:0".

Referenced by GetAvailableCPUDevices(), and GetAvailableCUDADevices().

◆ Device() [2/4]

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

Constructor with device specified.

Definition at line 60 of file Device.cpp.

References CPU, device_id_, device_type_, and LogError.

◆ Device() [3/4]

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

Constructor from device type string and device id.

Definition at line 69 of file Device.cpp.

◆ Device() [4/4]

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

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

Definition at line 72 of file Device.cpp.

Member Function Documentation

◆ GetAvailableCPUDevices()

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

Returns a vector of available CPU device.

Definition at line 128 of file Device.cpp.

References CPU, and Device().

Referenced by GetAvailableDevices().

◆ GetAvailableCUDADevices()

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

Returns a vector of available CUDA device.

Definition at line 132 of file Device.cpp.

References CUDA, Device(), and cloudViewer::core::cuda::DeviceCount().

Referenced by GetAvailableDevices().

◆ GetAvailableDevices()

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

Returns a vector of available devices.

Definition at line 117 of file Device.cpp.

References GetAvailableCPUDevices(), GetAvailableCUDADevices(), and GetAvailableSYCLDevices().

Referenced by IsAvailable(), and PrintAvailableDevices().

◆ GetAvailableSYCLDevices()

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

Returns a vector of available SYCL device.

Definition at line 140 of file Device.cpp.

References cloudViewer::core::sy::GetAvailableSYCLDevices().

Referenced by GetAvailableDevices().

◆ GetID()

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

◆ GetType()

◆ IsAvailable()

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

◆ IsCPU()

◆ IsCUDA()

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

Returns true iff device type is CUDA.

Definition at line 49 of file Device.h.

References CUDA, and device_type_.

Referenced by cloudViewer::core::AddMM(), cloudViewer::core::cuda::AssertCUDADeviceAvailable(), cloudViewer::t::pipelines::registration::AssertInputMultiScaleICP(), cloudViewer::t::geometry::kernel::image::ClipTransform(), cloudViewer::t::geometry::kernel::image::ColorizeDepth(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultHybrid(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultIntensity(), cloudViewer::t::pipelines::kernel::odometry::ComputeOdometryResultPointToPlane(), cloudViewer::core::kernel::Copy(), cloudViewer::core::CreateDeviceHashBackend(), cloudViewer::t::geometry::kernel::image::CreateNormalMap(), cloudViewer::t::geometry::kernel::image::CreateVertexMap(), cloudViewer::core::HashBackendBuffer::HashBackendBuffer(), cloudViewer::core::LeastSquares(), cloudViewer::core::Matmul(), cloudViewer::core::MemoryManager::Memcpy(), cloudViewer::t::geometry::kernel::image::PyrDownDepth(), cloudViewer::core::HashBackendBuffer::ResetHeap(), cloudViewer::core::nns::FixedRadiusIndex::SearchHybrid(), cloudViewer::core::nns::KnnIndex::SearchKnn(), cloudViewer::core::nns::FixedRadiusIndex::SearchRadius(), cloudViewer::core::nns::FixedRadiusIndex::SetTensorData(), cloudViewer::core::cuda::SupportsMemoryPools(), cloudViewer::core::cuda::Synchronize(), cloudViewer::t::geometry::kernel::image::To(), cloudViewer::core::Tril(), cloudViewer::core::Triu(), cloudViewer::core::Triul(), and cloudViewer::core::kernel::UnaryEW().

◆ IsSYCL()

◆ operator!=()

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

Definition at line 81 of file Device.cpp.

References operator==().

◆ operator<()

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

Definition at line 85 of file Device.cpp.

References ToString().

◆ operator==()

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

Definition at line 76 of file Device.cpp.

References device_id_, and device_type_.

Referenced by operator!=().

◆ PrintAvailableDevices()

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

Print all available devices.

Definition at line 144 of file Device.cpp.

References GetAvailableDevices(), and LogInfo.

◆ ToString()

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

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

Definition at line 89 of file Device.cpp.

References CPU, CUDA, device_id_, device_type_, LogError, SYCL, and patch::to_string().

Referenced by cloudViewer::core::cuda::AssertCUDADeviceAvailable(), cloudViewer::core::TensorList::AssertDevice(), cloudViewer::core::tensor_check::AssertTensorDevice_(), cloudViewer::core::kernel::BinaryEW(), cloudViewer::core::kernel::CopySYCL(), cloudViewer::core::MemoryManagerStatistic::CountFree(), cloudViewer::core::MemoryManagerStatistic::CountMalloc(), cloudViewer::t::geometry::npp::Dilate(), cloudViewer::core::TensorList::Extend(), cloudViewer::t::geometry::npp::Filter(), cloudViewer::t::geometry::npp::FilterBilateral(), cloudViewer::t::geometry::npp::FilterGaussian(), cloudViewer::t::geometry::npp::FilterSobel(), cloudViewer::t::geometry::RGBDImage::GetDevice(), cloudViewer::core::Open3DDLManagedTensor< DLMT >::getDLPackDevice(), cloudViewer::core::MemoryManager::GetMemoryManagerDevice(), cloudViewer::core::MakeMemoryManager(), cloudViewer::core::MemoryManager::Memcpy(), std::hash< cloudViewer::core::Device >::operator()(), std::less< cloudViewer::core::Device >::operator()(), operator<(), cloudViewer::core::ParallelForCPU_(), cloudViewer::core::ParallelForSYCL(), cloudViewer::core::pybind_core_device(), cloudViewer::core::pybind_core_tensor(), cloudViewer::t::geometry::pybind_lineset(), cloudViewer::t::geometry::pybind_pointcloud(), cloudViewer::t::geometry::pybind_trianglemesh(), cloudViewer::core::kernel::Reduction(), cloudViewer::t::geometry::npp::Resize(), cloudViewer::t::geometry::npp::RGBToGray(), cloudViewer::t::geometry::PointCloud::SetPointAttr(), cloudViewer::t::geometry::RGBDImage::ToString(), cloudViewer::t::geometry::TensorMap::ToString(), cloudViewer::t::geometry::TriangleMesh::TriangleMesh(), and cloudViewer::core::kernel::UnaryEW().

Member Data Documentation

◆ device_id_

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

Definition at line 83 of file Device.h.

Referenced by Device(), GetID(), operator==(), and ToString().

◆ device_type_

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

Definition at line 82 of file Device.h.

Referenced by Device(), GetType(), IsCPU(), IsCUDA(), IsSYCL(), operator==(), and ToString().


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