Open3D (C++ API)  0.19.0
SYCLContext.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - Open3D: www.open3d.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.open3d.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
14 
15 #pragma once
16 
17 #include <map>
18 #include <sycl/sycl.hpp>
19 
20 #include "open3d/core/Device.h"
21 
22 namespace open3d {
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;
37 };
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 open3d
Definition: Device.h:18
Definition: SYCLContext.h:41
bool IsDeviceAvailable(const Device &device)
Returns true if the specified SYCL device is available.
Definition: SYCLContext.cpp:31
static SYCLContext & GetInstance()
Get singleton instance.
Definition: SYCLContext.cpp:24
void operator=(SYCLContext const &)=delete
bool IsAvailable()
Returns true if there is at least one SYCL devices.
Definition: SYCLContext.cpp:29
sycl::queue GetDefaultQueue(const Device &device)
Get the default SYCL queue given an Open3D device.
Definition: SYCLContext.cpp:42
std::vector< Device > GetAvailableSYCLDevices()
Returns a list of all available SYCL devices.
Definition: SYCLContext.cpp:34
SYCLContext(SYCLContext const &)=delete
SYCLDevice GetDeviceProperties(const Device &device)
Get SYCL device properties given an Open3D device.
Definition: SYCLContext.h:62
Definition: PinholeCameraIntrinsic.cpp:16
SYCL device properties.
Definition: SYCLContext.h:27
std::string device_type
cpu, gpu, host, acc, custom, unknown.
Definition: SYCLContext.h:30
sycl::device device
SYCL device.
Definition: SYCLContext.h:31
std::string name
Fiendlly / descriptive name of the device.
Definition: SYCLContext.h:29
bool usm_device_allocations
Definition: SYCLContext.h:35
SYCLDevice(const sycl::device &sycl_device)
Definition: SYCLContext.cpp:46
size_t max_work_group_size
Preferred work group size.
Definition: SYCLContext.h:33
sycl::queue queue
Default queue for this device.
Definition: SYCLContext.h:32
bool fp64
Double precision support, else need to emulate.
Definition: SYCLContext.h:34