ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ArangeSYCL.cpp
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 
12 
13 namespace cloudViewer {
14 namespace core {
15 namespace kernel {
16 
17 void ArangeSYCL(const Tensor& start,
18  const Tensor& stop,
19  const Tensor& step,
20  Tensor& dst) {
21  Dtype dtype = start.GetDtype();
22  sycl::queue queue =
24  DISPATCH_DTYPE_TO_TEMPLATE(dtype, [&]() {
25  scalar_t sstart = start.Item<scalar_t>();
26  scalar_t sstep = step.Item<scalar_t>();
27  scalar_t* dst_ptr = dst.GetDataPtr<scalar_t>();
28  int64_t n = dst.GetLength();
29  queue.parallel_for(n, [=](int64_t i) {
30  dst_ptr[i] = sstart + static_cast<scalar_t>(sstep * i);
31  }).wait_and_throw();
32  });
33 }
34 
35 } // namespace kernel
36 } // namespace core
37 } // namespace cloudViewer
#define DISPATCH_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition: Dispatch.h:31
SYCL queue manager.
int64_t GetLength() const
Definition: Tensor.h:1125
Dtype GetDtype() const
Definition: Tensor.h:1164
Device GetDevice() const override
Definition: Tensor.cpp:1435
static SYCLContext & GetInstance()
Get singleton instance.
Definition: SYCLContext.cpp:25
sycl::queue GetDefaultQueue(const Device &device)
Get the default SYCL queue given an CloudViewer device.
Definition: SYCLContext.cpp:43
void ArangeSYCL(const Tensor &start, const Tensor &stop, const Tensor &step, Tensor &dst)
Definition: ArangeSYCL.cpp:17
Generic file read and write utility for python interface.