Open3D (C++ API)  0.19.0
Loading...
Searching...
No Matches
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
16
17#pragma once
18
19#include <algorithm>
20#include <cstdint>
21#include <memory>
22#include <string>
23#include <vector>
24
25#include "open3d/core/Device.h"
26
27#ifdef BUILD_SYCL_MODULE
28// Host TUs forward-declare sycl::queue; SYCL-compiled TUs include the runtime.
29#if defined(SYCL_LANGUAGE_VERSION)
30#include <sycl/sycl.hpp>
31#else
32namespace sycl {
33class queue;
34}
35#endif
36#endif
37
38namespace open3d {
39namespace core {
40namespace sy {
41
43struct SYCLDevice {
44 std::string name{};
45 std::string device_type{};
47 bool fp64 = false;
49 false;
52 bool discrete_gpu = false;
53 uint64_t global_mem_size = 0;
57 std::vector<size_t> sub_group_sizes{};
58
61 bool SupportsSubgroupSize(size_t size) const {
62 return std::find(sub_group_sizes.begin(), sub_group_sizes.end(),
63 size) != sub_group_sizes.end();
64 }
65};
66
67#ifdef BUILD_SYCL_MODULE
68
72class SYCLContext {
73public:
74 SYCLContext(SYCLContext const&) = delete;
75 void operator=(SYCLContext const&) = delete;
76 ~SYCLContext();
77
79 static SYCLContext& GetInstance();
80
82 bool IsAvailable();
83
85 bool IsDeviceAvailable(const Device& device);
86
88 std::vector<Device> GetAvailableSYCLDevices();
89
91 sycl::queue GetDefaultQueue(const Device& device);
92
95 SYCLDevice GetDeviceProperties(const Device& device);
96
100 static void Clear();
101
102private:
103 SYCLContext();
104
106 struct Impl;
107 std::unique_ptr<Impl> impl_;
108};
109
110#endif // BUILD_SYCL_MODULE
111
112} // namespace sy
113} // namespace core
114} // namespace open3d
sycl::queue queue
Definition SYCLContext.cpp:51
Definition Device.h:18
int size
Definition FilePCD.cpp:41
std::vector< Device > GetAvailableSYCLDevices()
Return a list of available SYCL devices.
Definition SYCLUtils.cpp:230
bool IsAvailable()
Returns true if there is at least one SYCL device available.
Definition SYCLUtils.cpp:199
bool IsDeviceAvailable(const Device &device)
Returns true if the specified SYCL device is available.
Definition SYCLUtils.cpp:207
Definition PinholeCameraIntrinsic.cpp:16
Cached SYCL device properties (no SYCL runtime types in this struct).
Definition SYCLContext.h:43
uint64_t global_mem_size
Definition SYCLContext.h:53
std::string device_type
cpu, gpu, host, acc, custom, unknown.
Definition SYCLContext.h:45
std::vector< size_t > sub_group_sizes
Definition SYCLContext.h:57
bool SupportsSubgroupSize(size_t size) const
Definition SYCLContext.h:61
std::string name
Friendly / descriptive name of the device.
Definition SYCLContext.h:44
bool discrete_gpu
Definition SYCLContext.h:52
bool usm_device_allocations
Definition SYCLContext.h:48
size_t max_work_group_size
Device max work-group size.
Definition SYCLContext.h:46
bool fp64
Native fp64; else may need emulation on some GPUs.
Definition SYCLContext.h:47