ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
SYCLContext.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
14 
15 #pragma once
16 
17 #include <map>
18 #include <sycl/sycl.hpp>
19 
21 
22 namespace cloudViewer {
23 namespace core {
24 namespace sy {
25 
27 struct SYCLDevice {
28  SYCLDevice(const sycl::device& sycl_device);
29  std::string name;
30  std::string device_type;
31  sycl::device device;
32  sycl::queue queue;
34  bool fp64;
36 };
38 
41 class SYCLContext {
42 public:
43  SYCLContext(SYCLContext const&) = delete;
44  void operator=(SYCLContext const&) = delete;
45 
47  static SYCLContext& GetInstance();
48 
50  bool IsAvailable();
51 
53  bool IsDeviceAvailable(const Device& device);
54 
56  std::vector<Device> GetAvailableSYCLDevices();
57 
59  sycl::queue GetDefaultQueue(const Device& device);
60 
63  return devices_.at(device);
64  };
65 
66 private:
67  SYCLContext();
68 
70  std::map<Device, SYCLDevice> devices_;
71 };
72 
73 } // namespace sy
74 } // namespace core
75 } // namespace cloudViewer
cloudViewer::core::sy::SYCLContext::GetAvailableSYCLDevices
std::vector< Device > GetAvailableSYCLDevices()
Returns a list of all available SYCL devices.
Definition: SYCLContext.cpp:35
cloudViewer
Generic file read and write utility for python interface.
Definition: CloudViewerConfig.cpp:12
cloudViewer::core::sy::GetDeviceTypeName
CLOUDVIEWER_DLL_LOCAL std::string GetDeviceTypeName(const sycl::device &device)
Device.h
cloudViewer::core::sy::SYCLContext
Definition: SYCLContext.h:41
cloudViewer::core::sy::SYCLContext::IsDeviceAvailable
bool IsDeviceAvailable(const Device &device)
Returns true if the specified SYCL device is available.
Definition: SYCLContext.cpp:32
cloudViewer::core::sy::SYCLDevice::usm_device_allocations
bool usm_device_allocations
Definition: SYCLContext.h:35
cloudViewer::core::sy::SYCLDevice::fp64
bool fp64
Double precision support, else need to emulate.
Definition: SYCLContext.h:34
cloudViewer::core::sy::SYCLDevice
SYCL device properties.
Definition: SYCLContext.h:27
SYCLContext.h
SYCL queue manager.
CLOUDVIEWER_DLL_LOCAL
#define CLOUDVIEWER_DLL_LOCAL
Definition: Macro.h:23
cloudViewer::core::sy::SYCLDevice::queue
sycl::queue queue
Default queue for this device.
Definition: SYCLContext.h:32
e
const double * e
Definition: essential_matrix_poly.h:10
cloudViewer::core::sy::SYCLContext::IsAvailable
bool IsAvailable()
Returns true if there is at least one SYCL devices.
Definition: SYCLContext.cpp:30
cloudViewer::core::sy::SYCLDevice::name
std::string name
Fiendlly / descriptive name of the device.
Definition: SYCLContext.h:29
cloudViewer::core::Device
Definition: Device.h:18
cloudViewer::core::sy::SYCLDevice::device_type
std::string device_type
cpu, gpu, host, acc, custom, unknown.
Definition: SYCLContext.h:30
core
SYCLUtils.h
Common SYCL utilities.
cloudViewer::core::sy::SYCLDevice::device
sycl::device device
SYCL device.
Definition: SYCLContext.h:31
cloudViewer::core::sy::SYCLContext::GetDeviceProperties
SYCLDevice GetDeviceProperties(const Device &device)
Get SYCL device properties given an CloudViewer device.
Definition: SYCLContext.h:62
cloudViewer::core::sy::SYCLContext::operator=
void operator=(SYCLContext const &)=delete
cloudViewer::core::sy::SYCLContext::GetInstance
static SYCLContext & GetInstance()
Get singleton instance.
Definition: SYCLContext.cpp:25
LogWarning
#define LogWarning(...)
Definition: Logging.h:72
cloudViewer::core::sy::SYCLDevice::max_work_group_size
size_t max_work_group_size
Preferred work group size.
Definition: SYCLContext.h:33
cloudViewer::core::sy::SYCLContext::GetDefaultQueue
sycl::queue GetDefaultQueue(const Device &device)
Get the default SYCL queue given an CloudViewer device.
Definition: SYCLContext.cpp:43
patch::to_string
std::string to_string(const T &n)
Definition: Common.h:20
name
std::string name
Definition: FileIOFactory.cpp:129
cloudViewer::core::sy::SYCLDevice::SYCLDevice
SYCLDevice(const sycl::device &sycl_device)
Definition: SYCLContext.cpp:47