Open3D (C++ API)
0.19.0
Toggle main menu visibility
Loading...
Searching...
No Matches
cpp
open3d
core
ParallelForSYCL.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
8
#pragma once
9
10
#include <cstdint>
11
#include <type_traits>
12
13
#include "
open3d/core/Device.h
"
14
#include "
open3d/core/Indexer.h
"
15
#include "
open3d/core/SYCLContext.h
"
16
#include "
open3d/utility/Logging.h
"
17
18
namespace
open3d
{
19
namespace
core
{
20
22
template
<
typename
Functor,
typename
... FuncArgs>
23
void
ParallelForSYCL
(
const
Device
& device,
24
Indexer
indexer,
25
FuncArgs... func_args) {
26
if
(!device.
IsSYCL
()) {
27
utility::LogError(
"ParallelFor for SYCL cannot run on device {}."
,
28
device.
ToString
());
29
}
30
int64_t n = indexer.
NumWorkloads
();
31
if
(n == 0) {
32
return
;
33
}
34
auto
queue =
sy::SYCLContext::GetInstance
().
GetDefaultQueue
(device);
36
queue.parallel_for<Functor>(n, [indexer, func_args...](int64_t i) {
37
Functor ef(indexer, func_args...);
38
ef(i);
39
}).wait_and_throw();
40
}
41
43
template
<
typename
Functor,
typename
... FuncArgs>
44
void
ParallelForSYCL
(
const
Device
& device,
45
int64_t num_workloads,
46
FuncArgs... func_args) {
47
if
(!device.
IsSYCL
()) {
48
utility::LogError(
"ParallelFor for SYCL cannot run on device {}."
,
49
device.
ToString
());
50
}
51
if
(num_workloads == 0) {
52
return
;
53
}
54
auto
queue =
sy::SYCLContext::GetInstance
().
GetDefaultQueue
(device);
56
queue.parallel_for<Functor>(num_workloads, [func_args...](int64_t i) {
57
Functor ef(func_args...);
58
ef(i);
59
}).wait_and_throw();
60
}
61
62
}
// namespace core
63
}
// namespace open3d
Device.h
Indexer.h
Logging.h
SYCLContext.h
SYCL queue manager.
open3d::core::Device
Definition
Device.h:18
open3d::core::Device::IsSYCL
bool IsSYCL() const
Returns true iff device type is SYCL GPU.
Definition
Device.h:52
open3d::core::Device::ToString
std::string ToString() const
Returns string representation of device, e.g. "CPU:0", "CUDA:0".
Definition
Device.cpp:88
open3d::core::Indexer
Definition
Indexer.h:261
open3d::core::Indexer::NumWorkloads
int64_t NumWorkloads() const
Definition
Indexer.cpp:406
open3d::core::sy::SYCLContext::GetInstance
static SYCLContext & GetInstance()
Get singleton instance.
Definition
SYCLContext.cpp:24
open3d::core::sy::SYCLContext::GetDefaultQueue
sycl::queue GetDefaultQueue(const Device &device)
Get the default SYCL queue given an Open3D device.
Definition
SYCLContext.cpp:42
open3d::core
Definition
AdvancedIndexing.cpp:15
open3d::core::ParallelForSYCL
void ParallelForSYCL(const Device &device, Indexer indexer, FuncArgs... func_args)
Run a function in parallel with SYCL.
Definition
ParallelForSYCL.h:23
open3d
Definition
PinholeCameraIntrinsic.cpp:16
Generated by
1.17.0