imate
C++/CUDA Reference
cu_linear_operator.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright 2021, Siavash Ameli <sameli@berkeley.edu>
3  * SPDX-License-Identifier: BSD-3-Clause
4  * SPDX-FileType: SOURCE
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the license found in the LICENSE.txt file in the root
8  * directory of this source tree.
9  */
10 
11 
12 #ifndef _CU_LINEAR_OPERATOR_CU_LINEAR_OPERATOR_H_
13 #define _CU_LINEAR_OPERATOR_CU_LINEAR_OPERATOR_H_
14 
15 // =======
16 // Headers
17 // =======
18 
19 #include <cublas_v2.h> // cublasHandle_t
20 #include <cusparse.h> // cusparseHandle_t
21 #include "../_definitions/types.h" // FlagType, IndexType, LongIndexType
22 #include "../_c_linear_operator/c_linear_operator.h" // cLinearOperator
23 
24 
25 // ==================
26 // cu Linear Operator
27 // ==================
28 
41 
42 template <typename DataType>
43 class cuLinearOperator: virtual public cLinearOperator<DataType>
44 {
45  public:
46 
47  // Member methods
49  explicit cuLinearOperator(int num_gpu_devices_);
50 
51  virtual ~cuLinearOperator();
52 
53  cublasHandle_t get_cublas_handle() const;
54 
55  protected:
56 
57  // Member methods
58  int query_gpu_devices() const;
61 
62  // Member data
65  cublasHandle_t* cublas_handle;
66  cusparseHandle_t* cusparse_handle;
67 };
68 
69 #endif // _CU_LINEAR_OPERATOR_CU_LINEAR_OPERATOR_H_
Base class for linear operators. This class serves as interface for all derived classes.
Base class for linear operators. This class serves as interface for all derived classes.
void initialize_cusparse_handle()
Creates a cusparseHandle_t object, if not created already.
cublasHandle_t * cublas_handle
int query_gpu_devices() const
Before any numerical computation, this method chechs if any gpu device is available on the machine,...
cublasHandle_t get_cublas_handle() const
This function returns a reference to the cublasHandle_t object. The object will be created,...
cusparseHandle_t * cusparse_handle
void initialize_cublas_handle()
Creates a cublasHandle_t object, if not created already.