PaStiX Handbook  6.3.2
codelet_solve_dtrsm.c
Go to the documentation of this file.
1 /**
2  *
3  * @file codelet_solve_dtrsm.c
4  *
5  * StarPU codelet for TRSM function
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  * @date 2023-07-21
15  *
16  * @generated from /builds/solverstack/pastix/sopalin/starpu/codelet_solve_ztrsm.c, normal z -> d, Wed Dec 13 12:09:29 2023
17  *
18  * @addtogroup starpu_trsm_solve
19  * @{
20  *
21  **/
22 #ifndef DOXYGEN_SHOULD_SKIP_THIS
23 #define _GNU_SOURCE
24 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
25 #include "common.h"
26 #include "blend/solver.h"
27 #include "sopalin/sopalin_data.h"
28 #include "pastix_dcores.h"
29 #include "pastix_starpu.h"
30 #include "pastix_dstarpu.h"
31 #include "codelets.h"
32 
33 #if defined( PASTIX_STARPU_PROFILING )
34 /**
35  * @brief Block version
36  */
37 starpu_profile_t solve_blok_dtrsm_profile = {
38  .next = NULL,
39  .name = "solve_blok_dtrsm"
40 };
41 
42 /**
43  * @brief Profiling registration function
44  */
45 void solve_blok_dtrsm_profile_register( void ) __attribute__( ( constructor ) );
46 void
47 solve_blok_dtrsm_profile_register( void )
48 {
49  profiling_register_cl( &solve_blok_dtrsm_profile );
50 }
51 #endif
52 
53 #ifndef DOXYGEN_SHOULD_SKIP_THIS
54 struct cl_solve_blok_dtrsm_args_s {
55  profile_data_t profile_data;
56  pastix_side_t side;
57  pastix_uplo_t uplo;
58  pastix_trans_t trans;
59  pastix_diag_t diag;
60  const SolverCblk *cblk;
61 };
62 
63 static struct starpu_perfmodel starpu_solve_blok_dtrsm_model = {
64  .type = STARPU_HISTORY_BASED,
65  .symbol = "solve_blok_dtrsm",
66 };
67 
68 #if !defined(PASTIX_STARPU_SIMULATION)
69 static void
70 fct_solve_blok_dtrsm_cpu( void *descr[], void *cl_arg )
71 {
72  struct cl_solve_blok_dtrsm_args_s *args = (struct cl_solve_blok_dtrsm_args_s *) cl_arg;
73  void *A;
74  double *B;
75  pastix_int_t nrhs, ldb;
76 
77  A = pastix_starpu_cblk_get_ptr( descr[0] );
78  B = (double *)STARPU_MATRIX_GET_PTR( descr[1] );
79  ldb = (pastix_int_t) STARPU_MATRIX_GET_LD( descr[1] );
80  nrhs = (pastix_int_t) STARPU_MATRIX_GET_NY( descr[1] );
81 
82  solve_blok_dtrsm( args->side, args->uplo,
83  args->trans, args->diag, args->cblk,
84  nrhs, A, B, ldb );
85 }
86 #endif /* !defined(PASTIX_STARPU_SIMULATION) */
87 
88 CODELETS_CPU( solve_blok_dtrsm, 2 );
89 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
90 
91 /**
92  *******************************************************************************
93  *
94  * @brief Submit a task to do a trsm related to a diagonal
95  * block of the matrix A.
96  *
97  *******************************************************************************
98  *
99  * @param[in] coef
100  * Specify whether the computation are made with the L part, or the U
101  * part of A. It has to be either PastixLCoef, or PastixUCoef.
102  *
103  * @param[in] side
104  * Specify the side parameter of the TRSM.
105  *
106  * @param[in] uplo
107  * Specify the uplo parameter of the TRSM.
108  *
109  * @param[in] trans
110  * Specify the transposition used for the matrix A in the
111  * computation. It has to be either PastixTrans or PastixTrans.
112  *
113  * @param[in] diag
114  * Specify if the off-diagonal blocks are unit triangular. It has to be
115  * either PastixUnit or PastixNonUnit.
116  *
117  * @param[in] cblk
118  * The cblk structure that corresponds to the A and B matrix.
119  *
120  * @param[in] sopalin_data
121  * The data that provide the SolverMatrix structure from PaStiX, and
122  * descriptor of b (providing nrhs, b and ldb).
123 
124  * @param[in] prio
125  * The priority of the task in th DAG.
126  *
127  *******************************************************************************/
128 void
129 starpu_stask_blok_dtrsm( sopalin_data_t *sopalin_data,
130  pastix_coefside_t coef,
131  pastix_side_t side,
132  pastix_uplo_t uplo,
133  pastix_trans_t trans,
134  pastix_diag_t diag,
135  const SolverCblk *cblk,
136  pastix_int_t prio )
137 {
138  struct cl_solve_blok_dtrsm_args_s *cl_arg;
139  starpu_data_handle_t handle = cblk->handler[coef];
140  SolverMatrix *solvmtx = sopalin_data->solvmtx;
141  pastix_int_t cblknum = cblk - solvmtx->cblktab;
142 #if defined(PASTIX_DEBUG_STARPU)
143  char *task_name;
144 #endif
145 
146  /*
147  * Check if it needs to be submitted
148  */
149 #if defined(PASTIX_WITH_MPI)
150  {
151  int need_submit = 0;
152  if ( cblk->ownerid == sopalin_data->solvmtx->clustnum ) {
153  need_submit = 1;
154  }
155  if ( starpu_mpi_cached_receive( solvmtx->starpu_desc_rhs->handletab[cblknum] ) ) {
156  need_submit = 1;
157  }
158  if ( !need_submit ) {
159  return;
160  }
161  }
162 #endif
163 
164  /*
165  * Create the arguments array
166  */
167  cl_arg = malloc( sizeof(struct cl_solve_blok_dtrsm_args_s) );
168 #if defined(PASTIX_STARPU_PROFILING)
169  cl_arg->profile_data.measures = solve_blok_dtrsm_profile.measures;
170  cl_arg->profile_data.flops = NAN;
171 #endif
172  cl_arg->side = side;
173  cl_arg->trans = trans;
174  cl_arg->uplo = uplo;
175  cl_arg->diag = diag;
176  cl_arg->cblk = cblk;
177 
178 #if defined(PASTIX_DEBUG_STARPU)
179  asprintf( &task_name, "%s( %ld )",
180  cl_solve_blok_dtrsm_cpu.name,
181  (long)(cblknum) );
182 #endif
183 
184  pastix_starpu_insert_task(
185  &cl_solve_blok_dtrsm_cpu,
186  STARPU_CL_ARGS, cl_arg, sizeof( struct cl_solve_blok_dtrsm_args_s ),
187 #if defined(PASTIX_STARPU_PROFILING)
188  STARPU_CALLBACK_WITH_ARG_NFREE, cl_profiling_callback, cl_arg,
189 #endif
190  STARPU_R, handle,
191  STARPU_RW, solvmtx->starpu_desc_rhs->handletab[cblknum],
192 #if defined(PASTIX_DEBUG_STARPU)
193  STARPU_NAME, task_name,
194 #endif
195 #if defined(PASTIX_STARPU_HETEROPRIO)
196  STARPU_PRIORITY, BucketSolveTRSM,
197 #endif
198  0);
199  (void)prio;
200 }
201 
202 /**
203  * @}
204  */
BEGIN_C_DECLS typedef int pastix_int_t
Definition: datatypes.h:51
void solve_blok_dtrsm(pastix_side_t side, pastix_uplo_t uplo, pastix_trans_t trans, pastix_diag_t diag, const SolverCblk *cblk, int nrhs, const void *dataA, double *b, int ldb)
Apply a solve trsm update related to a diagonal block of the matrix A.
Definition: solve_dtrsmsp.c:76
enum pastix_diag_e pastix_diag_t
Diagonal.
enum pastix_uplo_e pastix_uplo_t
Upper/Lower part.
enum pastix_side_e pastix_side_t
Side of the operation.
enum pastix_trans_e pastix_trans_t
Transpostion.
enum pastix_coefside_e pastix_coefside_t
Data blocks used in the kernel.
Base structure to all codelet arguments that include the profiling data.
void starpu_stask_blok_dtrsm(sopalin_data_t *sopalin_data, pastix_coefside_t coef, pastix_side_t side, pastix_uplo_t uplo, pastix_trans_t trans, pastix_diag_t diag, const SolverCblk *cblk, pastix_int_t prio)
Submit a task to do a trsm related to a diagonal block of the matrix A.
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