-
Notifications
You must be signed in to change notification settings - Fork 0
/
common.h
74 lines (62 loc) · 1.87 KB
/
common.h
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
#include<math.h>
#include<stdio.h>
#include <stdlib.h>
#define USE_FP64 0
#if USE_FP64
#define real_type double
#else
#define real_type float
#endif
#pragma once
#ifndef V100
# define V100 0
#endif
#ifndef NOACC
# define NOACC 0
#endif
#ifndef CUDA
# define CUDA 1
#endif
#ifndef OPENMP
# define OPENMP 0
#endif
#ifndef HIP
#define HIP 0
#endif
typedef struct{
int *lia;
int *lja;
real_type *la;
int lnnz;
int *uia;
int *uja;
real_type *ua;
int unnz;
real_type *ichol_vals;
real_type *d;
real_type *d_r;//d_r = 1./d
int n;
real_type *aux_vec1, *aux_vec2, *aux_vec3;
char *prec_op;
int m, k;//m is outer loop, k inner
} pdata;
void prec_function(int *ia, int *ja, real_type *a, int nnzA,pdata* prec_data, real_type * x, real_type *y);
void cg(int n, real_type nnz,
int *ia, //matrix csr data
int *ja,
real_type *a,
real_type *x, //solution vector, mmust be alocated prior to calling
real_type *b, //rhs
real_type tol, //DONT MULTIPLY BY NORM OF B
pdata *prec_data, //preconditioner data: all Ls, Us etc
int maxit,
int *it, //output: iteration
int *flag, //output: flag 0-converged, 1-maxit reached, 2-catastrophic failure
real_type *res_norm_history //output: residual norm history
);
/* preconditioners */
void GS_std(int *ia, int *ja, real_type *a, int nnzA, pdata* prec_data, real_type *vec_in, real_type *vec_out);
void GS_it(int *ia, int *ja, real_type *a, int nnzA, pdata* prec_data, real_type *vec_in, real_type *vec_out);
void GS_it2(int *ia, int *ja, real_type *a, int nnzA, pdata* prec_data, real_type *vec_in, real_type *vec_out);
void it_jacobi(int *ia, int *ja, real_type *a, int nnzA, pdata* prec_data, real_type *vec_in, real_type *vec_out);
void line_jacobi(int *ia, int *ja, real_type *a, int nnzA, pdata* prec_data, real_type *vec_in, real_type *vec_out);