ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
SolveSYCL.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 
8 #include <sycl/sycl.hpp>
9 
10 #include "cloudViewer/core/Blob.h"
14 #include "oneapi/mkl.hpp"
15 
16 namespace cloudViewer {
17 namespace core {
18 
19 void SolveSYCL(void* A_data,
20  void* B_data,
21  void* ipiv_data,
22  int64_t n,
23  int64_t k,
24  Dtype dtype,
25  const Device& device) {
26  using namespace oneapi::mkl;
27  sycl::queue queue = sy::SYCLContext::GetInstance().GetDefaultQueue(device);
28  int64_t nrhs = k, lda = n, ldb = n;
30  int64_t scratchpad_size = lapack::gesv_scratchpad_size<scalar_t>(
31  queue, n, nrhs, lda, ldb);
32  // Use blob to ensure cleanup of scratchpad memory.
33  Blob scratchpad(scratchpad_size * sizeof(scalar_t), device);
34  lapack::gesv(queue, n, nrhs, static_cast<scalar_t*>(A_data), lda,
35  static_cast<int64_t*>(ipiv_data),
36  static_cast<scalar_t*>(B_data), ldb,
37  static_cast<scalar_t*>(scratchpad.GetDataPtr()),
38  scratchpad_size)
39  .wait_and_throw();
40  });
41 }
42 
43 } // namespace core
44 } // namespace cloudViewer
#define DISPATCH_LINALG_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition: LinalgUtils.h:23
SYCL queue manager.
void * GetDataPtr()
Definition: Blob.h:75
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 SolveSYCL(void *A_data, void *B_data, void *ipiv_data, int64_t n, int64_t k, Dtype dtype, const Device &device)
Definition: SolveSYCL.cpp:19
Generic file read and write utility for python interface.