PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
codelet_solve_cadd.c
Go to the documentation of this file.
1/**
2 *
3 * @file codelet_solve_cadd.c
4 *
5 * StarPU codelet for add function
6 *
7 * @copyright 2016-2024 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria,
8 * Univ. Bordeaux. All rights reserved.
9 *
10 * @version 6.4.0
11 * @author Vincent Bridonneau
12 * @author Mathieu Faverge
13 * @author Pierre Ramet
14 * @author Alycia Lisito
15 * @date 2024-07-05
16 *
17 * @generated from /builds/2mk6rsew/0/solverstack/pastix/sopalin/starpu/codelet_solve_zadd.c, normal z -> c, Tue Feb 25 14:35:23 2025
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_ccores.h"
30#include "pastix_starpu.h"
31#include "pastix_cstarpu.h"
32#include "codelets.h"
33
34#if defined( PASTIX_STARPU_PROFILING )
35/**
36 * @brief Block version
37 */
38starpu_profile_t solve_blok_cadd_profile = {
39 .next = NULL,
40 .name = "solve_blok_cadd"
41};
42
43/**
44 * @brief Profiling registration function
45 */
46void solve_blok_cadd_profile_register( void ) __attribute__( ( constructor ) );
47void
48solve_blok_cadd_profile_register( void )
49{
50 profiling_register_cl( &solve_blok_cadd_profile );
51}
52#endif
53
54#ifndef DOXYGEN_SHOULD_SKIP_THIS
55struct cl_solve_blok_cadd_args_s {
56 profile_data_t profile_data;
57 const SolverCblk *cblk;
58 SolverCblk *fcblk;
59};
60
61static struct starpu_perfmodel starpu_solve_blok_cadd_model = {
62 .type = STARPU_HISTORY_BASED,
63 .symbol = "solve_blok_cadd",
64};
65
66#if !defined(PASTIX_STARPU_SIMULATION)
67static void
68fct_solve_blok_cadd_cpu( void *descr[], void *cl_arg )
69{
70 const pastix_complex32_t *A;
72 pastix_int_t nrhs, ldb, lda;
73 struct cl_solve_blok_cadd_args_s *args = (struct cl_solve_blok_cadd_args_s *)cl_arg;
74
75#if defined(PASTIX_DEBUG_STARPU)
76 fprintf( stderr, "[pastix][%s] Add cblk recv = %d ok\n", __func__, args->cblk->gcblknum );
77#endif
78
79 A = (pastix_complex32_t *)STARPU_MATRIX_GET_PTR( descr[0] );
80 lda = (pastix_int_t) STARPU_MATRIX_GET_LD( descr[0] );
81 nrhs = (pastix_int_t) STARPU_MATRIX_GET_NY( descr[0] );
82 B = (pastix_complex32_t *)STARPU_MATRIX_GET_PTR( descr[1] );
83 ldb = (pastix_int_t) STARPU_MATRIX_GET_LD( descr[1] );
84
85 B += (args->cblk->lcolidx - args->fcblk->lcolidx);
86 core_cgeadd( PastixNoTrans, cblk_colnbr(args->cblk), nrhs,
87 1., A, lda, 1., B, ldb );
88
89}
90#endif /* !defined(PASTIX_STARPU_SIMULATION) */
91
92CODELETS_CPU( solve_blok_cadd, 2 );
93#endif /* DOXYGEN_SHOULD_SKIP_THIS */
94
95/**
96 *******************************************************************************
97 *
98 * @brief Insert the task to add a fanin cblk on the receiver side (The fanin is
99 * seen on this side as the RECV cblk). Note that the caller always execute the
100 * task.
101 *
102 *******************************************************************************
103 *
104 * @param[in] sopalin_data
105 * Solver matrix information structure that will guide the algorithm.
106 *
107 * @param[in] side
108 * Define which side of the cblk must be tested.
109 * @arg PastixLCoef if lower part only
110 * @arg PastixUCoef if upper part only
111 * @arg PastixLUCoef if both sides.
112 *
113 * @param[inout] rhsb
114 * The pointer to the rhs data structure that holds the vectors of the
115 * right hand side.
116 *
117 * @param[in] cblk
118 * The column block of the matrix.
119 *
120 * @param[in] fcblk
121 * The facing column block of the matrix.
122 *
123 * @param[in] prio
124 * The task priority.
125 *
126 *******************************************************************************/
127void
128starpu_stask_blok_cadd_fwd_recv( sopalin_data_t *sopalin_data,
129 pastix_rhs_t rhsb,
130 const SolverCblk *cblk,
131 SolverCblk *fcblk,
132 int prio )
133{
134 struct cl_solve_blok_cadd_args_s *cl_arg = NULL;
135 SolverMatrix *solvmtx = sopalin_data->solvmtx;
136 pastix_int_t cblknum = cblk - solvmtx->cblktab;
137 pastix_int_t fcblknum = fcblk - solvmtx->cblktab;
138#if defined(PASTIX_DEBUG_STARPU)
139 char *task_name;
140#endif
141
142#if defined(PASTIX_DEBUG_STARPU)
143 fprintf( stderr, "[%2d][%s] cblk = %d, ownerid = %d, handler = %p, size = %ld\n",
144 solvmtx->clustnum, __func__, cblk->gcblknum, cblk->ownerid, rhsb->starpu_desc->handletab[cblknum],
145 cblk_colnbr( cblk ) * sizeof(pastix_complex32_t) );
146#endif
147 /*
148 * Create the arguments array
149 */
150 cl_arg = malloc( sizeof( struct cl_solve_blok_cadd_args_s) );
151#if defined(PASTIX_STARPU_PROFILING)
152 cl_arg->profile_data.measures = solve_blok_cadd_profile.measures;
153 cl_arg->profile_data.flops = NAN;
154#endif
155 cl_arg->cblk = cblk;
156 cl_arg->fcblk = fcblk;
157
158#if defined(PASTIX_DEBUG_STARPU)
159 /* This actually generates a memory leak */
160 asprintf( &task_name, "%s( %ld )",
161 cl_solve_blok_cadd_cpu.name,
162 (long)(cblk - sopalin_data->solvmtx->cblktab) );
163#endif
164
165 assert( cblk->cblktype & CBLK_RECV );
166 assert( !(fcblk->cblktype & (CBLK_RECV|CBLK_FANIN)) );
167
168 pastix_starpu_insert_task(
169 &cl_solve_blok_cadd_cpu,
170 STARPU_CL_ARGS, cl_arg, sizeof( struct cl_solve_blok_cadd_args_s ),
171 STARPU_EXECUTE_ON_NODE, fcblk->ownerid,
172#if defined(PASTIX_STARPU_PROFILING)
173 STARPU_CALLBACK_WITH_ARG_NFREE, solve_blok_cadd_callback, cl_arg,
174#endif
175 STARPU_R, rhsb->starpu_desc->handletab[cblknum],
176 STARPU_RW, rhsb->starpu_desc->handletab[fcblknum],
177#if defined(PASTIX_DEBUG_STARPU)
178 STARPU_NAME, task_name,
179#endif
180#if defined(PASTIX_STARPU_HETEROPRIO)
181 STARPU_PRIORITY, BucketSolveGEMM,
182#else
183 STARPU_PRIORITY, prio,
184#endif
185 0);
186
187 (void)prio;
188}
189
190/**
191 * @}
192 */
BEGIN_C_DECLS typedef int pastix_int_t
Definition datatypes.h:51
float _Complex pastix_complex32_t
Definition datatypes.h:76
int core_cgeadd(pastix_trans_t trans, pastix_int_t M, pastix_int_t N, pastix_complex32_t alpha, const pastix_complex32_t *A, pastix_int_t LDA, pastix_complex32_t beta, pastix_complex32_t *B, pastix_int_t LDB)
Add two matrices together.
Definition core_cgeadd.c:78
@ PastixNoTrans
Definition api.h:445
void starpu_stask_blok_cadd_fwd_recv(sopalin_data_t *sopalin_data, pastix_rhs_t rhsb, const SolverCblk *cblk, SolverCblk *fcblk, int prio)
Insert the task to add a fanin cblk on the receiver side (The fanin is seen on this side as the RECV ...
Base structure to all codelet arguments that include the profiling data.
Main PaStiX RHS structure.
Definition pastixdata.h:155
static pastix_int_t cblk_colnbr(const SolverCblk *cblk)
Compute the number of columns in a column block.
Definition solver.h:329
pastix_int_t gcblknum
Definition solver.h:174
SolverCblk *restrict cblktab
Definition solver.h:228
int8_t cblktype
Definition solver.h:164
Solver column block structure.
Definition solver.h:161
Solver column block structure.
Definition solver.h:203