PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
codelet_cblk_spotrfsp.c
Go to the documentation of this file.
1/**
2 *
3 * @file codelet_cblk_spotrfsp.c
4 *
5 * StarPU codelets for Cholesky 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_zpotrfsp.c, normal z -> s, Thu Jul 16 08:33:17 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_scores.h"
30#include "pastix_starpu.h"
31#include "pastix_sstarpu.h"
32#include "codelets.h"
33
34/**
35 * @brief Main structure for all tasks of cblk_sgemmsp type
36 */
37struct cl_cblk_spotrfsp_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_spotrfsp_profile = {
52 .next = NULL,
53 .name = "cblk_spotrfsp"
54};
55
56/**
57 * @brief Profiling registration function
58 */
59void cblk_spotrfsp_profile_register( void ) __attribute__( ( constructor ) );
60void
61cblk_spotrfsp_profile_register( void )
62{
63 profiling_register_cl( &cblk_spotrfsp_profile );
64}
65
66#ifndef DOXYGEN_SHOULD_SKIP_THIS
67#if defined(PASTIX_STARPU_PROFILING_LOG)
68static void
69cl_profiling_cb_cblk_spotrfsp( 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_spotrfsp_args_s *args = (struct cl_cblk_spotrfsp_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_spotrfsp", M, N, 0, flops, speed );
91}
92#endif
93
94#if defined(PASTIX_STARPU_PROFILING_LOG)
95static void (*cblk_spotrfsp_callback)(void*) = cl_profiling_cb_cblk_spotrfsp;
96#else
97static void (*cblk_spotrfsp_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_spotrfsp_cost( struct starpu_task *task,
130 struct starpu_perfmodel_arch *arch,
131 unsigned nimpl )
132{
133 struct cl_cblk_spotrfsp_args_s *args = (struct cl_cblk_spotrfsp_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[PastixFloat-2][PastixKernelPOTRF][0]);
144 coefs2 = &(args->sopalin_data->cpu_models->coefficients[PastixFloat-2][PastixKernelTRSMCblk2d][0]);
145 break;
146 case STARPU_CUDA_WORKER:
147 coefs1 = &(args->sopalin_data->gpu_models->coefficients[PastixFloat-2][PastixKernelPOTRF][0]);
148 coefs2 = &(args->sopalin_data->gpu_models->coefficients[PastixFloat-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 );
158
159 (void)nimpl;
160 return cost;
161}
162#endif
163
164#ifndef DOXYGEN_SHOULD_SKIP_THIS
165static struct starpu_perfmodel starpu_cblk_spotrfsp_model = {
166#if defined( PASTIX_STARPU_COST_PER_ARCH )
167 .type = STARPU_PER_ARCH,
168 .arch_cost_function = cblk_potrf_cost,
169#else
170 .type = STARPU_HISTORY_BASED,
171#endif
172 .symbol = "cblk_spotrfsp",
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_spotrfsp_cpu( void *descr[], void *cl_arg )
192{
193 struct cl_cblk_spotrfsp_args_s *args = (struct cl_cblk_spotrfsp_args_s *)cl_arg;
194 void *L;
195
196 L = pastix_starpu_cblk_get_ptr( descr[0] );
197
198 cpucblk_spotrfsp1d_panel( args->sopalin_data->solvmtx, args->cblk, L );
199}
200#endif /* !defined(PASTIX_STARPU_SIMULATION) */
201
202CODELETS_CPU( cblk_spotrfsp, 1 );
203#endif /* DOXYGEN_SHOULD_SKIP_THIS */
204
205/**
206 *******************************************************************************
207 *
208 * @brief TODO
209 *
210 *******************************************************************************
211 *
212 * @param[in] sopalin_data
213 * TODO
214 *
215 * @param[in] cblk
216 * TODO
217 *
218 * @param[in] prio
219 * TODO
220 *
221 *******************************************************************************/
222void
223starpu_task_cblk_spotrfsp( sopalin_data_t *sopalin_data,
224 SolverCblk *cblk,
225 int prio )
226{
227 struct cl_cblk_spotrfsp_args_s *cl_arg = NULL;
228 int need_exec = 1;
229#if defined(PASTIX_DEBUG_STARPU)
230 char *task_name;
231#endif
232
233 /*
234 * Check if it needs to be submitted
235 */
236#if defined(PASTIX_WITH_MPI)
237 {
238 int need_submit = 0;
239 if ( cblk->ownerid == sopalin_data->solvmtx->clustnum ) {
240 need_submit = 1;
241 }
242 else {
243 need_exec = 0;
244 }
245 if ( starpu_mpi_cached_receive( cblk->handler[0] ) ) {
246 need_submit = 1;
247 }
248 if ( !need_submit ) {
249 return;
250 }
251 }
252#endif
253
254 /*
255 * Create the arguments array
256 */
257 if ( need_exec ) {
258 cl_arg = malloc( sizeof( struct cl_cblk_spotrfsp_args_s) );
259 cl_arg->sopalin_data = sopalin_data;
260#if defined(PASTIX_STARPU_PROFILING)
261 cl_arg->profile_data.measures = cblk_spotrfsp_profile.measures;
262 cl_arg->profile_data.flops = NAN;
263#endif
264 cl_arg->cblk = cblk;
265 }
266
267#if defined(PASTIX_DEBUG_STARPU)
268 /* This actually generates a memory leak */
269 asprintf( &task_name, "%s( %ld )",
270 cl_cblk_spotrfsp_cpu.name,
271 (long)(cblk - sopalin_data->solvmtx->cblktab) );
272#endif
273
274 pastix_starpu_insert_task(
275 &cl_cblk_spotrfsp_cpu,
276 STARPU_CL_ARGS, cl_arg, sizeof( struct cl_cblk_spotrfsp_args_s ),
277#if defined(PASTIX_STARPU_PROFILING)
278 STARPU_CALLBACK_WITH_ARG_NFREE, cblk_spotrfsp_callback, cl_arg,
279#endif
280 STARPU_RW, cblk->handler[0],
281#if defined(PASTIX_DEBUG_STARPU)
282 STARPU_NAME, task_name,
283#endif
284#if defined(PASTIX_STARPU_HETEROPRIO)
285 STARPU_PRIORITY, BucketFacto1D,
286#else
287 STARPU_PRIORITY, prio,
288#endif
289 0);
290 (void)prio;
291}
292
293/**
294 * @}
295 */
BEGIN_C_DECLS typedef int pastix_int_t
Definition datatypes.h:51
double pastix_fixdbl_t
Definition datatypes.h:65
@ PastixKernelTRSMCblk2d
@ PastixKernelPOTRF
int cpucblk_spotrfsp1d_panel(SolverMatrix *solvmtx, SolverCblk *cblk, void *L)
Compute the Cholesky factorization of one panel.
void starpu_task_cblk_spotrfsp(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