-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrocsolver-ilu.hpp
123 lines (113 loc) · 3.75 KB
/
rocsolver-ilu.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef ROCSOLVER_ILU_HPP
#define ROCSOLVER_ILU_HPP
#include <iostream>
#include <vector>
#include <hip/hip_runtime_api.h>
#include <hip/hip_runtime.h>
#include <hip/hip_version.h>
#include <rocsolver/rocsolver.h>
class RocsolverMSWContribution
{
private:
bool analysis_done = false;
rocblas_int M;
rocblas_int N;
rocblas_int Nrhs = 1;
rocblas_int lda;
rocblas_int ldb;
int sizeBvals;
int sizeBcols;
int sizeBrows;
unsigned int resSize;
unsigned int CzSize;
rocblas_int *info;
rocblas_int *ipiv;
double *d_Dmatrix_hip;
double *d_Cvals_hip;
double *d_Bvals_hip;
unsigned int *d_Brows_hip;
unsigned int *d_Bcols_hip;
void *d_buffer;
rocblas_handle handle;
//rocsparse_mat_descr descr_A, descr_M, descr_L, descr_U;
rocsolver_rfinfo ilu_info;
rocblas_operation operation = rocblas_operation_none;
double *x_hip;
double *z_hip;
double *y_hip;
double *sol_hip;
double *rhs_hip;
std::vector<double> vecSol;
std::vector<double> z1;
std::vector<double> vecY;
public:
~RocsolverMSWContribution();
void initialize(rocblas_int M,
rocblas_int N,
int sizeBvals,
int sizeBcols,
int sizeBrows,
int resSize,
int CzSize);
void copyHostToDevice(double *Dmatrix,
std::vector<double> Cvals,
std::vector<double> Bvals,
std::vector<unsigned int> Brows,
std::vector<unsigned int> Bcols,
std::vector<double> x,
std::vector<double> y);
std::vector<double> solveSytem();
void scalar_csr(int m,
int threads_per_block,
unsigned int * row_offsets,
unsigned int * cols,
double * vals,
double * x,
double * y,
double alpha,
double beta);
void scalar_csc(int n,
int threads_per_block,
unsigned int* col_offsets,
unsigned int* rows,
double* vals,
double* x,
double* y,
double alpha,
double beta);
void spmv_k(int n,
int threads_per_block,
unsigned int* row_offsets,
unsigned int* cols,
double* vals,
double* x,
double* y);
void blockrsmvBx(double* vals,
unsigned int* cols,
unsigned int* rows,
double* x,
double* rhs,
double* out,
unsigned int Nb,
unsigned int block_dimM,
unsigned int block_dimN,
const double op_sign);
/*void blocksrmvCtz(double* vals,
unsigned int* cols,
unsigned int* rows,
double* x,
double* rhs,
double* out,
unsigned int Nb,
unsigned int block_dimM,
unsigned int block_dimN,
const double op_sign,
const unsigned int resSize,
const int sizeBvals);*/
void blocksrmvB_x(double* vals, unsigned int* cols, unsigned int* rows, double* x, double* y, unsigned int Nb, unsigned int Nbr, unsigned int block_dimM, unsigned int block_dimN);
void blocksrmvC_z(double* vals, unsigned int* cols, unsigned int* rows, double* z, double* y, unsigned int Nb, unsigned int Nbr, unsigned int block_dimM, unsigned int block_dimN);
std::vector<double> apply();
std::vector<double> vectorCtz();
void freeRocSOLVER();
};
#endif