PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
codelet_cblk_zgetrfsp.c
Go to the documentation of this file.
1/**
2 *
3 * @file codelet_cblk_zgetrfsp.c
4 *
5 * StarPU codelets for LU functions
6 *
7 * @copyright 2016-2025 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 Ian Masliah
14 * @author Tom Moenne-Loccoz
15 * @date 2024-07-05
16 *
17 * @generated from /builds/7cspzRFxD/0/solverstack/pastix/sopalin/starpu/codelet_cblk_zgetrfsp.c, normal z -> z, Thu Jul 16 08:33:18 2026
18 *
19 * @addtogroup pastix_starpu
20 * @{
21 *
22 **/
23#ifndef DOXYGEN_SHOULD_SKIP_THIS
24#define _GNU_SOURCE
25#endif /* DOXYGEN_SHOULD_SKIP_THIS */
26#include "common.h"
27#include "blend/solver.h"
28#include "sopalin/sopalin_data.h"
29#include "pastix_zcores.h"
30#include "pastix_starpu.h"
31#include "pastix_zstarpu.h"
32#include "codelets.h"
33
34/**
35 * @brief Main structure for all tasks of cblk_zgemmsp type
36 */
37struct cl_cblk_zgetrfsp_args_s {
38 profile_data_t profile_data;
39 sopalin_data_t *sopalin_data;
40 SolverCblk *cblk;
41};
42
43#if defined(PASTIX_STARPU_PROFILING)
44/**
45 * @brief Functions to profile the codelet
46 *
47 * Two levels of profiling are available:
48 * 1) A generic one that returns the flops per worker
49 * 2) A more detailed one that generate logs of the performance for each kernel
50 */
51starpu_profile_t cblk_zgetrfsp_profile = {
52 .next = NULL,
53 .name = "cblk_zgetrfsp"
54};
55
56/**
57 * @brief Profiling registration function
58 */
59void cblk_zgetrfsp_profile_register( void ) __attribute__( ( constructor ) );
60void
61cblk_zgetrfsp_profile_register( void )
62{
63 profiling_register_cl( &cblk_zgetrfsp_profile );
64}
65
66#ifndef DOXYGEN_SHOULD_SKIP_THIS
67#if defined(PASTIX_STARPU_PROFILING_LOG)
68static void
69cl_profiling_cb_cblk_zgetrfsp( void *callback_arg )
70{
71 cl_profiling_callback( callback_arg );
72
73 struct starpu_task *task = starpu_task_get_current();
74 struct starpu_profiling_task_info *info = task->profiling_info;
75
76 /* Quick return */
77 if ( info == NULL ) {
78 return;
79 }
80
81 struct cl_cblk_zgetrfsp_args_s *args = (struct cl_cblk_zgetrfsp_args_s *) callback_arg;
82 pastix_fixdbl_t flops = args->profile_data.flops;
83 pastix_fixdbl_t duration = starpu_timing_timespec_delay_us( &info->start_time, &info->end_time );
84 pastix_fixdbl_t speed = flops / ( 1000.0 * duration );
85
86 pastix_int_t M = args->cblk->stride;
87 pastix_int_t N = cblk_colnbr( args->cblk );
88 M -= N;
89
90 cl_profiling_log_register( task->name, "cblk_zgetrfsp", M, N, 0, flops, speed );
91}
92#endif
93
94#if defined(PASTIX_STARPU_PROFILING_LOG)
95static void (*cblk_zgetrfsp_callback)(void*) = cl_profiling_cb_cblk_zgetrfsp;
96#else
97static void (*cblk_zgetrfsp_callback)(void*) = cl_profiling_callback;
98#endif
99#endif /* DOXYGEN_SHOULD_SKIP_THIS */
100
101#endif /* defined(PASTIX_STARPU_PROFILING) */
102
103#if defined(PASTIX_STARPU_COST_PER_ARCH)
104/**
105 *******************************************************************************
106 *
107 * @brief Cost model function
108 *
109 * The user can switch from the pastix static model to an history based model
110 * computed automatically.
111 *
112 *******************************************************************************
113 *
114 * @param[in] task
115 * TODO
116 *
117 * @param[in] arch
118 * TODO
119 *
120 * @param[in] nimpl
121 * TODO
122 *
123 *******************************************************************************
124 *
125 * @retval TODO
126 *
127 *******************************************************************************/
128static inline pastix_fixdbl_t
129fct_cblk_zgetrfsp_cost( struct starpu_task *task,
130 struct starpu_perfmodel_arch *arch,
131 unsigned nimpl )
132{
133 struct cl_cblk_zgetrfsp_args_s *args = (struct cl_cblk_zgetrfsp_args_s *)(task->cl_arg);
134
136 pastix_fixdbl_t *coefs1, *coefs2;
137 pastix_int_t M = args->cblk->stride;
138 pastix_int_t N = cblk_colnbr( args->cblk );
139 M -= N;
140
141 switch( arch->devices->type ) {
142 case STARPU_CPU_WORKER:
143 coefs1 = &(args->sopalin_data->cpu_models->coefficients[PastixComplex64-2][PastixKernelGETRF][0]);
144 coefs2 = &(args->sopalin_data->cpu_models->coefficients[PastixComplex64-2][PastixKernelTRSMCblk2d][0]);
145 break;
146 case STARPU_CUDA_WORKER:
147 coefs1 = &(args->sopalin_data->gpu_models->coefficients[PastixComplex64-2][PastixKernelGETRF][0]);
148 coefs2 = &(args->sopalin_data->gpu_models->coefficients[PastixComplex64-2][PastixKernelTRSMCblk2d][0]);
149 break;
150 default:
151 assert(0);
152 return 0.;
153 }
154
155 /* Get cost in us */
156 cost = modelsGetCost1Param( coefs1, N );
157 cost += modelsGetCost2Param( coefs2, M, N ) * 2.;
158
159 (void)nimpl;
160 return cost;
161}
162#endif
163
164#ifndef DOXYGEN_SHOULD_SKIP_THIS
165static struct starpu_perfmodel starpu_cblk_zgetrfsp_model = {
166#if defined( PASTIX_STARPU_COST_PER_ARCH )
167 .type = STARPU_PER_ARCH,
168 .arch_cost_function = cblk_getrf_cost,
169#else
170 .type = STARPU_HISTORY_BASED,
171#endif
172 .symbol = "cblk_zgetrfsp",
173};
174
175#if !defined(PASTIX_STARPU_SIMULATION)
176/**
177 *******************************************************************************
178 *
179 * @brief StarPU CPU implementation
180 *
181 *******************************************************************************
182 *
183 * @param[in] descr
184 * TODO
185 *
186 * @param[in] cl_arg
187 * TODO
188 *
189 *******************************************************************************/
190static void
191fct_cblk_zgetrfsp_cpu( void *descr[], void *cl_arg )
192{
193 struct cl_cblk_zgetrfsp_args_s *args = (struct cl_cblk_zgetrfsp_args_s *)cl_arg;
194 void *L;
195 void *U;
196
197 L = pastix_starpu_cblk_get_ptr( descr[0] );
198 U = pastix_starpu_cblk_get_ptr( descr[1] );
199
200 cpucblk_zgetrfsp1d_panel( args->sopalin_data->solvmtx, args->cblk, L, U );
201}
202#endif /* !defined(PASTIX_STARPU_SIMULATION) */
203
204CODELETS_CPU( cblk_zgetrfsp, 2 );
205#endif /* DOXYGEN_SHOULD_SKIP_THIS */
206
207/**
208 *******************************************************************************
209 *
210 * @brief TODO
211 *
212 *******************************************************************************
213 *
214 * @param[in] sopalin_data
215 * TODO
216 *
217 * @param[in] cblk
218 * TODO
219 *
220 * @param[in] prio
221 * TODO
222 *
223 *******************************************************************************/
224void
225starpu_task_cblk_zgetrfsp( sopalin_data_t *sopalin_data,
226 SolverCblk *cblk,
227 int prio )
228{
229 struct cl_cblk_zgetrfsp_args_s *cl_arg = NULL;
230 int need_exec = 1;
231#if defined(PASTIX_DEBUG_STARPU)
232 char *task_name;
233#endif
234
235 /*
236 * Check if it needs to be submitted
237 */
238#if defined(PASTIX_WITH_MPI)
239 {
240 int need_submit = 0;
241 if ( cblk->ownerid == sopalin_data->solvmtx->clustnum ) {
242 need_submit = 1;
243 }
244 else {
245 need_exec = 0;
246 }
247 if ( starpu_mpi_cached_receive( cblk->handler[0] ) ) {
248 need_submit = 1;
249 }
250 if ( starpu_mpi_cached_receive( cblk->handler[1] ) ) {
251 need_submit = 1;
252 }
253 if ( !need_submit ) {
254 return;
255 }
256 }
257#endif
258
259 /*
260 * Create the arguments array
261 */
262 if ( need_exec ) {
263 cl_arg = malloc( sizeof( struct cl_cblk_zgetrfsp_args_s) );
264 cl_arg->sopalin_data = sopalin_data;
265#if defined(PASTIX_STARPU_PROFILING)
266 cl_arg->profile_data.measures = cblk_zgetrfsp_profile.measures;
267 cl_arg->profile_data.flops = NAN;
268#endif
269 cl_arg->cblk = cblk;
270 }
271
272#if defined(PASTIX_DEBUG_STARPU)
273 /* This actually generates a memory leak */
274 asprintf( &task_name, "%s( %ld )",
275 cl_cblk_zgetrfsp_cpu.name,
276 (long)(cblk - sopalin_data->solvmtx->cblktab) );
277#endif
278
279 pastix_starpu_insert_task(
280 &cl_cblk_zgetrfsp_cpu,
281 STARPU_CL_ARGS, cl_arg, sizeof( struct cl_cblk_zgetrfsp_args_s ),
282#if defined(PASTIX_STARPU_PROFILING)
283 STARPU_CALLBACK_WITH_ARG_NFREE, cblk_zgetrfsp_callback, cl_arg,
284#endif
285 STARPU_RW, cblk->handler[0],
286 STARPU_RW, cblk->handler[1],
287#if defined(PASTIX_DEBUG_STARPU)
288 STARPU_NAME, task_name,
289#endif
290#if defined(PASTIX_STARPU_HETEROPRIO)
291 STARPU_PRIORITY, BucketFacto1D,
292#else
293 STARPU_PRIORITY, prio,
294#endif
295 0);
296 (void)prio;
297}
298
299/**
300 * @}
301 */
BEGIN_C_DECLS typedef int pastix_int_t
Definition datatypes.h:51
double pastix_fixdbl_t
Definition datatypes.h:65
@ PastixKernelTRSMCblk2d
@ PastixKernelGETRF
int cpucblk_zgetrfsp1d_panel(SolverMatrix *solvmtx, SolverCblk *cblk, void *L, void *U)
Compute the LU factorization of one panel.
void starpu_task_cblk_zgetrfsp(sopalin_data_t *sopalin_data, SolverCblk *cblk, int prio)
TODO.
Base structure to all codelet arguments that include the profiling data.
static double cost(symbol_cblk_t *cblk)
Computes the cost of a cblk.
static pastix_int_t cblk_colnbr(const SolverCblk *cblk)
Compute the number of columns in a column block.
Definition solver.h:329
void * handler[2]
Definition solver.h:179
Solver column block structure.
Definition solver.h:161