ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
InverseCUDA.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 
16 void InverseCUDA(void* A_data,
17  void* ipiv_data,
18  void* output_data,
19  int64_t n,
20  Dtype dtype,
21  const Device& device) {
22  cusolverDnHandle_t handle =
23  CuSolverContext::GetInstance().GetHandle(device);
24 
26  int len;
27  Blob dinfo(sizeof(int), device);
28 
29  OPEN3D_CUSOLVER_CHECK(
30  getrf_cuda_buffersize<scalar_t>(handle, n, n, n, &len),
31  "getrf_buffersize failed in InverseCUDA");
32  Blob workspace(len * sizeof(scalar_t), device);
33 
34  OPEN3D_CUSOLVER_CHECK_WITH_DINFO(
35  getrf_cuda<scalar_t>(
36  handle, n, n, static_cast<scalar_t*>(A_data), n,
37  static_cast<scalar_t*>(workspace.GetDataPtr()),
38  static_cast<int*>(ipiv_data),
39  static_cast<int*>(dinfo.GetDataPtr())),
40  "getrf failed in InverseCUDA",
41  static_cast<int*>(dinfo.GetDataPtr()), device);
42 
43  OPEN3D_CUSOLVER_CHECK_WITH_DINFO(
44  getrs_cuda<scalar_t>(handle, CUBLAS_OP_N, n, n,
45  static_cast<scalar_t*>(A_data), n,
46  static_cast<int*>(ipiv_data),
47  static_cast<scalar_t*>(output_data), n,
48  static_cast<int*>(dinfo.GetDataPtr())),
49  "getrs failed in InverseCUDA",
50  static_cast<int*>(dinfo.GetDataPtr()), device);
51  });
52 }
53 
54 } // namespace core
55 } // namespace cloudViewer
#define DISPATCH_LINALG_DTYPE_TO_TEMPLATE(DTYPE,...)
Definition: LinalgUtils.h:23
void * GetDataPtr()
Definition: Blob.h:75
ccGuiPythonInstance * GetInstance() noexcept
Definition: Runtime.cpp:72
void InverseCUDA(void *A_data, void *ipiv_data, void *output_data, int64_t n, Dtype dtype, const Device &device)
Definition: InverseCUDA.cpp:16
Generic file read and write utility for python interface.