PaStiX Handbook  6.3.2
codelet_solve_zdiag.c
Go to the documentation of this file.
1 /**
2  *
3  * @file codelet_solve_zdiag.c
4  *
5  * StarPU codelets for diag functions.
6  *
7  * @copyright 2016-2023 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8  * Univ. Bordeaux. All rights reserved.
9  *
10  * @version 6.3.2
11  * @author Vincent Bridonneau
12  * @author Mathieu Faverge
13  * @author Pierre Ramet
14  * @author Alycia Lisito
15  * @author Nolan Bredel
16  * @author Tom Moenne-Loccoz
17  * @date 2023-11-07
18  *
19  * @generated from /builds/solverstack/pastix/sopalin/starpu/codelet_solve_zdiag.c, normal z -> z, Wed Dec 13 12:09:29 2023
20  *
21  * @addtogroup starpu_diag_solve
22  * @{
23  *
24  **/
25 #ifndef DOXYGEN_SHOULD_SKIP_THIS
26 #define _GNU_SOURCE
27 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
28 #include "common.h"
29 #include "blend/solver.h"
30 #include "sopalin/sopalin_data.h"
31 #include "pastix_zcores.h"
32 #include "pastix_starpu.h"
33 #include "pastix_zstarpu.h"
34 #include "codelets.h"
35 
36 #if defined( PASTIX_STARPU_PROFILING )
37 /**
38  * @brief Cblk version
39  */
40 starpu_profile_t solve_cblk_zdiag_profile = {
41  .next = NULL,
42  .name = "solve_cblk_zdiag"
43 };
44 
45 /**
46  * @brief Profiling registration function
47  */
48 void solve_cblk_zdiag_profile_register( void ) __attribute__( ( constructor ) );
49 void
50 solve_cblk_zdiag_profile_register( void )
51 {
52  profiling_register_cl( &solve_cblk_zdiag_profile );
53 }
54 #endif
55 
56 #ifndef DOXYGEN_SHOULD_SKIP_THIS
57 struct cl_solve_cblk_zdiag_args_s {
58  profile_data_t profile_data;
59  SolverCblk *cblk;
60 };
61 
62 static struct starpu_perfmodel starpu_solve_cblk_zdiag_model = {
63  .type = STARPU_HISTORY_BASED,
64  .symbol = "solve_cblk_zdiag",
65 };
66 
67 #if !defined(PASTIX_STARPU_SIMULATION)
68 static void
69 fct_solve_cblk_zdiag_cpu( void *descr[], void *cl_arg )
70 {
71  struct cl_solve_cblk_zdiag_args_s *args = (struct cl_solve_cblk_zdiag_args_s *) cl_arg;
72  void *A;
73  int nrhs;
74  pastix_complex64_t *b;
75  int ldb;
76 
77  A = pastix_starpu_cblk_get_ptr( descr[0] );
78  b = (pastix_complex64_t *)STARPU_MATRIX_GET_PTR( descr[1] );
79  ldb = (int)STARPU_MATRIX_GET_LD( descr[1] );
80  nrhs = (int)STARPU_MATRIX_GET_NY( descr[1] );
81 
82  solve_cblk_zdiag( args->cblk, A, nrhs, b, ldb, NULL );
83 }
84 #endif /* !defined(PASTIX_STARPU_SIMULATION) */
85 
86 CODELETS_CPU( solve_cblk_zdiag, 2 );
87 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
88 
89 /**
90  *******************************************************************************
91  *
92  * @brief Submit a task to perform a diagonal solve related to one cblk
93  * to all the right hand side.
94  *
95  *******************************************************************************
96  *
97  * @param[inout] sopalin_data
98  * The structure providing descriptor about b and the A matrix.
99  *
100  * @param[in] cblk
101  * The cblk structure to which diagonal block belongs to.
102  *
103  * @param[in] prio
104  * The priority of the task in the DAG.
105  *
106  *******************************************************************************/
107 void
108 starpu_stask_cblk_zdiag( sopalin_data_t *sopalin_data,
109  SolverCblk *cblk,
110  int prio )
111 {
112  struct cl_solve_cblk_zdiag_args_s *cl_arg;
113  starpu_data_handle_t handle;
114  SolverMatrix *solvmtx = sopalin_data->solvmtx;
115  pastix_int_t cblknum = cblk - solvmtx->cblktab;
116 #if defined(PASTIX_DEBUG_STARPU)
117  char *task_name;
118 #endif
119 
120  /*
121  * Check if it needs to be submitted
122  */
123 #if defined(PASTIX_WITH_MPI)
124  {
125  int need_submit = 0;
126  if ( cblk->ownerid == sopalin_data->solvmtx->clustnum ) {
127  need_submit = 1;
128  }
129  if ( starpu_mpi_cached_receive( solvmtx->starpu_desc_rhs->handletab[cblknum] ) ) {
130  need_submit = 1;
131  }
132  if ( !need_submit ) {
133  return;
134  }
135  }
136 #endif
137 
138  /*
139  * Create the arguments array
140  */
141  cl_arg = malloc( sizeof(struct cl_solve_cblk_zdiag_args_s) );
142 #if defined(PASTIX_STARPU_PROFILING)
143  cl_arg->profile_data.measures = solve_cblk_zdiag_profile.measures;
144  cl_arg->profile_data.flops = NAN;
145 #endif
146  cl_arg->cblk = cblk;
147 
148 #if defined(PASTIX_DEBUG_STARPU)
149  asprintf( &task_name, "%s( %ld )",
150  cl_solve_cblk_zdiag_cpu.name,
151  (long)cblknum );
152 #endif
153 
154  handle = cblk->handler[0];
155 
156  pastix_starpu_insert_task(
157  &cl_solve_cblk_zdiag_cpu,
158  STARPU_CL_ARGS, cl_arg, sizeof( struct cl_solve_cblk_zdiag_args_s ),
159 #if defined(PASTIX_STARPU_PROFILING)
160  STARPU_CALLBACK_WITH_ARG_NFREE, cl_profiling_callback, cl_arg,
161 #endif
162  STARPU_R, handle,
163  STARPU_RW, solvmtx->starpu_desc_rhs->handletab[cblknum],
164 #if defined(PASTIX_DEBUG_STARPU)
165  STARPU_NAME, task_name,
166 #endif
167 #if defined(PASTIX_STARPU_HETEROPRIO)
168  STARPU_PRIORITY, BucketSolveDiag,
169 #endif
170  0);
171  (void)prio;
172 }
173 /**
174  * @}
175  */
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
void solve_cblk_zdiag(const SolverCblk *cblk, const void *dataA, int nrhs, pastix_complex64_t *b, int ldb, pastix_complex64_t *work)
Apply the diagonal solve related to one cblk to all the right hand side.
Base structure to all codelet arguments that include the profiling data.
void starpu_stask_cblk_zdiag(sopalin_data_t *sopalin_data, SolverCblk *cblk, int prio)
Submit a task to perform a diagonal solve related to one cblk to all the right hand side.
SolverCblk *restrict cblktab
Definition: solver.h:222
void * handler[2]
Definition: solver.h:173
int ownerid
Definition: solver.h:175
Solver column block structure.
Definition: solver.h:156
Solver column block structure.
Definition: solver.h:200