PaStiX Handbook  6.4.0
s_refine_functions.c
Go to the documentation of this file.
1 /**
2  *
3  * @file s_refine_functions.c
4  *
5  * PaStiX refinement functions implementations.
6  *
7  * @copyright 2015-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8  * Univ. Bordeaux. All rights reserved.
9  *
10  * @version 6.4.0
11  * @author Mathieu Faverge
12  * @author Pierre Ramet
13  * @author Theophile Terraz
14  * @author Xavier Lacoste
15  * @author Gregoire Pichon
16  * @author Tony Delarue
17  * @author Vincent Bridonneau
18  * @date 2024-07-05
19  * @generated from /builds/solverstack/pastix/refinement/z_refine_functions.c, normal z -> s, Fri Jul 12 15:10:19 2024
20  *
21  **/
22 #include "common.h"
23 #include "cblas.h"
24 #include "bcsc/bcsc.h"
25 #include "bcsc/bvec.h"
26 #include "bcsc/bcsc_s.h"
27 #include "sopalin/sopalin_data.h"
29 
30 /**
31  *******************************************************************************
32  *
33  * @ingroup pastix_dev_refine
34  *
35  * @brief Print statistics about one iteration
36  *
37  *******************************************************************************
38  *
39  * @param[in] t0
40  * The clock value at the beginning of the iteration
41  *
42  * @param[in] tf
43  * The clock value at the end of the iteration
44  *
45  * @param[in] err
46  * The backward error after the iteration
47  *
48  * @param[in] nb_iters
49  * Current number of refinement iterations
50  *
51  *******************************************************************************/
53 {
54  pastix_fixdbl_t stt;
55 
56  stt = tf - t0;
57  fprintf(stdout, OUT_ITERREFINE_ITER, (int)nb_iters);
58  fprintf(stdout, OUT_ITERREFINE_TTT, stt);
59  fprintf(stdout, OUT_ITERREFINE_ERR, err);
60 }
61 
62 /**
63  *******************************************************************************
64  *
65  * @ingroup pastix_dev_refine
66  *
67  * @brief Final output
68  *
69  *******************************************************************************
70  *
71  * @param[in] pastix_data
72  * The PaStiX data structure that describes the solver instance.
73  *
74  * @param[in] err
75  * The final backward error
76  *
77  * @param[in] nb_iters
78  * The final number of iterations
79  *
80  * @param[in] tf
81  * The final clock value
82  *
83  * @param[inout] x
84  * The vector that is to be overwritten by gmresx
85  *
86  * @param[in] gmresx
87  * The final solution
88  *
89  *******************************************************************************/
91  float err,
92  pastix_int_t nb_iters,
93  pastix_fixdbl_t tf,
94  void *x,
95  float *gmresx )
96 {
97  (void)pastix_data;
98  (void)err;
99  (void)nb_iters;
100  (void)tf;
101  (void)x;
102  (void)gmresx;
103 }
104 
105 /**
106  *******************************************************************************
107  *
108  * @ingroup pastix_dev_refine
109  *
110  * @brief Initiate functions pointers to define basic operations
111  *
112  *******************************************************************************
113  *
114  * @param[out] solver
115  * The structure to be filled
116  *
117  * @param[in] pastix_data
118  * TODO
119  *
120  *******************************************************************************/
121 void s_refine_init( struct s_solver *solver,
122  pastix_data_t *pastix_data )
123 {
124  pastix_scheduler_t sched = pastix_data->iparm[IPARM_SCHEDULER];
125 
126  /* Allocations */
127  solver->malloc = &bvec_malloc;
128  solver->free = &bvec_free;
129 
130  /* Output */
131  solver->output_oneiter = &s_refine_output_oneiter;
132  solver->output_final = &s_refine_output_final;
133 
134  /* Basic operations */
135  solver->spsv = &bcsc_sspsv;
136  if ( sched == PastixSchedSequential )
137  {
138  solver->spmv = &bcsc_sspmv;
139  solver->copy = &bvec_scopy_seq;
140  solver->dot = &bvec_sdot_seq;
141  solver->axpy = &bvec_saxpy_seq;
142  solver->scal = &bvec_sscal_seq;
143  solver->norm = &bvec_snrm2_seq;
144  solver->gemv = &bvec_sgemv_seq;
145  } else {
146  solver->spmv = &bcsc_sspmv;
147  solver->copy = &bvec_scopy_smp;
148  solver->dot = &bvec_sdot_smp;
149  solver->axpy = &bvec_saxpy_smp;
150  solver->scal = &bvec_sscal_smp;
151  solver->norm = &bvec_snrm2_smp;
152  solver->gemv = &bvec_sgemv_smp;
153  }
154 }
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
double pastix_fixdbl_t
Definition: datatypes.h:65
void bvec_free(void *x)
Free a vector.
Definition: bvec.c:62
void bvec_sgemv_seq(pastix_data_t *pastix_data, pastix_int_t m, pastix_int_t n, float alpha, const float *A, pastix_int_t lda, const float *x, float beta, float *y)
Compute.
float bvec_sdot_smp(pastix_data_t *pastix_data, pastix_int_t n, const float *x, const float *y)
Compute a regular scalar product x.y (Parallel version)
void bvec_scopy_smp(pastix_data_t *pastix_data, pastix_int_t n, const float *x, float *y)
Copy a vector y = x (parallel version)
void bvec_sscal_smp(pastix_data_t *pastix_data, pastix_int_t n, float alpha, float *x)
Scale a vector (Parallel version)
void * bvec_malloc(size_t size)
Allocate a vector.
Definition: bvec.c:42
void bvec_sscal_seq(pastix_data_t *pastix_data, pastix_int_t n, float alpha, float *x)
Scale a vector by the scalar alpha. (Sequential version)
void bvec_saxpy_seq(pastix_data_t *pastix_data, pastix_int_t n, float alpha, const float *x, float *y)
Compute y <- alpha * x + y. (Sequential version)
void bcsc_sspsv(pastix_data_t *pastix_data, float *b, float *work)
Solve A x = b with A the sparse matrix.
void bvec_scopy_seq(pastix_data_t *pastix_data, pastix_int_t n, const float *x, float *y)
Copy a vector y = x (Sequential version)
void bvec_sgemv_smp(pastix_data_t *pastix_data, pastix_int_t m, pastix_int_t n, float alpha, const float *A, pastix_int_t lda, const float *x, float beta, float *y)
Compute.
float bvec_snrm2_smp(pastix_data_t *pastix_data, pastix_int_t n, const float *x)
Compute the norm 2 of a vector. (Parallel version)
void bcsc_sspmv(const pastix_data_t *pastix_data, pastix_trans_t trans, float alpha, const float *x, float beta, float *y)
Compute the matrix-vector product y = alpha * op(A) * x + beta * y.
Definition: bcsc_sspmv.c:629
float bvec_snrm2_seq(pastix_data_t *pastix_data, pastix_int_t n, const float *x)
Compute the norm 2 of a vector. (Sequential version)
Definition: bvec_scompute.c:71
float bvec_sdot_seq(pastix_data_t *pastix_data, pastix_int_t n, const float *x, const float *y)
Compute the scalar product x.y. (Sequential version)
void bvec_saxpy_smp(pastix_data_t *pastix_data, pastix_int_t n, float alpha, const float *x, float *y)
Perform y = alpha * x + y (Parallel version)
enum pastix_scheduler_e pastix_scheduler_t
Scheduler.
@ IPARM_SCHEDULER
Definition: api.h:117
@ PastixSchedSequential
Definition: api.h:334
void s_refine_init(struct s_solver *, pastix_data_t *)
Initiate functions pointers to define basic operations.
void s_refine_output_final(pastix_data_t *pastix_data, float err, pastix_int_t nb_iters, pastix_fixdbl_t tf, void *x, float *gmresx)
Final output.
void s_refine_output_oneiter(pastix_fixdbl_t t0, pastix_fixdbl_t tf, float err, pastix_int_t nb_iters)
Print statistics about one iteration.
pastix_int_t * iparm
Definition: pastixdata.h:70
Main PaStiX data structure.
Definition: pastixdata.h:68