PaStiX Handbook 6.4.0
Loading...
Searching...
No Matches
codelet_solve_scpy.c
Go to the documentation of this file.
1/**
2 *
3 * @file codelet_solve_scpy.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 * @date 2024-07-05
15 *
16 * @generated from /builds/2mk6rsew/0/solverstack/pastix/sopalin/starpu/codelet_solve_zcpy.c, normal z -> s, Tue Feb 25 14:35:24 2025
17 *
18 * @addtogroup pastix_starpu
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 <lapacke.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#if defined( PASTIX_STARPU_PROFILING )
35/**
36 * @brief Block version
37 */
38starpu_profile_t solve_blok_scpy_profile = {
39 .next = NULL,
40 .name = "solve_blok_scpy"
41};
42
43/**
44 * @brief Profiling registration function
45 */
46void solve_blok_scpy_profile_register( void ) __attribute__( ( constructor ) );
47void
48solve_blok_scpy_profile_register( void )
49{
50 profiling_register_cl( &solve_blok_scpy_profile );
51}
52#endif
53
54#ifndef DOXYGEN_SHOULD_SKIP_THIS
55struct cl_solve_blok_scpy_args_s {
56 profile_data_t profile_data;
57 SolverCblk *cblk;
58 const SolverCblk *fcblk;
59};
60
61static struct starpu_perfmodel starpu_solve_blok_scpy_model = {
62 .type = STARPU_HISTORY_BASED,
63 .symbol = "solve_blok_scpy",
64};
65
66#if !defined(PASTIX_STARPU_SIMULATION)
67static void
68fct_solve_blok_scpy_cpu( void *descr[], void *cl_arg )
69{
70 const float *A;
71 float *B;
72 pastix_int_t m, n, lda, ldb;
73 struct cl_solve_blok_scpy_args_s *args = (struct cl_solve_blok_scpy_args_s *)cl_arg;
74 int rc;
75
76#if defined(PASTIX_DEBUG_STARPU)
77 fprintf( stderr, "[pastix][%s] Add copy cblk into recv = %d ok\n", __func__, args->cblk->gcblknum );
78#endif
79
80 A = (float *)STARPU_MATRIX_GET_PTR( descr[0] );
81 lda = (pastix_int_t) STARPU_MATRIX_GET_LD( descr[0] );
82
83 m = (pastix_int_t) STARPU_MATRIX_GET_NX( descr[1] );
84 n = (pastix_int_t) STARPU_MATRIX_GET_NY( descr[1] );
85 ldb = (pastix_int_t) STARPU_MATRIX_GET_LD( descr[1] );
86 B = (float *)STARPU_MATRIX_GET_PTR( descr[1] );
87
88 assert( m <= ((pastix_int_t)STARPU_MATRIX_GET_NX( descr[0] )) );
89
90 A += (args->cblk->lcolidx - args->fcblk->lcolidx);
91
92 rc = LAPACKE_slacpy_work( LAPACK_COL_MAJOR, 'A', m, n, A, lda, B, ldb );
93 assert( rc == 0 );
94
95 (void)rc;
96}
97#endif /* !defined(PASTIX_STARPU_SIMULATION) */
98
99CODELETS_CPU( solve_blok_scpy, 2 );
100#endif /* DOXYGEN_SHOULD_SKIP_THIS */
101
102/**
103 *******************************************************************************
104 *
105 * @brief Insert the task to add a fanin cblk on the receiver side (The fanin is
106 * seen on this side as the RECV cblk). Note that the caller always execute the
107 * task.
108 *
109 *******************************************************************************
110 *
111 * @param[in] sopalin_data
112 * Solver matrix information structure that will guide the algorithm.
113 *
114 * @param[in] side
115 * Define which side of the cblk must be tested.
116 * @arg PastixLCoef if lower part only
117 * @arg PastixUCoef if upper part only
118 * @arg PastixLUCoef if both sides.
119 *
120 * @param[inout] rhsb
121 * The pointer to the rhs data structure that holds the vectors of the
122 * right hand side.
123 *
124 * @param[in] cblk
125 * The column block of the matrix.
126 *
127 * @param[in] fcblk
128 * The facing column block of the matrix.
129 *
130 * @param[in] prio
131 * The task priority.
132 *
133 *******************************************************************************/
134void
135starpu_stask_blok_scpy_bwd_recv( sopalin_data_t *sopalin_data,
136 pastix_rhs_t rhsb,
137 SolverCblk *cblk,
138 const SolverCblk *fcblk,
139 int prio )
140{
141 struct cl_solve_blok_scpy_args_s *cl_arg = NULL;
142 SolverMatrix *solvmtx = sopalin_data->solvmtx;
143 pastix_int_t cblknum = cblk - solvmtx->cblktab;
144 pastix_int_t fcblknum = fcblk - solvmtx->cblktab;
145#if defined(PASTIX_DEBUG_STARPU)
146 char *task_name;
147#endif
148
149#if defined(PASTIX_DEBUG_STARPU)
150 fprintf( stderr, "[%2d][%s] cblk = %d, ownerid = %d, handler = %p, size = %ld\n",
151 solvmtx->clustnum, __func__, cblk->gcblknum, cblk->ownerid, rhb->starpu_desc->handletab[cblknum],
152 cblk_colnbr( cblk ) * sizeof(float) );
153#endif
154
155 /*
156 * Create the arguments array
157 */
158 cl_arg = malloc( sizeof( struct cl_solve_blok_scpy_args_s) );
159#if defined(PASTIX_STARPU_PROFILING)
160 cl_arg->profile_data.measures = solve_blok_scpy_profile.measures;
161 cl_arg->profile_data.flops = NAN;
162#endif
163 cl_arg->cblk = cblk;
164 cl_arg->fcblk = fcblk;
165
166#if defined(PASTIX_DEBUG_STARPU)
167 /* This actually generates a memory leak */
168 asprintf( &task_name, "%s( %ld )",
169 cl_solve_blok_scpy_cpu.name,
170 (long)(cblk - sopalin_data->solvmtx->cblktab) );
171#endif
172
173 assert( cblk->cblktype & CBLK_RECV );
174 assert( !(fcblk->cblktype & (CBLK_RECV|CBLK_FANIN)) );
175
176 pastix_starpu_insert_task(
177 &cl_solve_blok_scpy_cpu,
178 STARPU_CL_ARGS, cl_arg, sizeof( struct cl_solve_blok_scpy_args_s ),
179#if defined(PASTIX_STARPU_PROFILING)
180 STARPU_CALLBACK_WITH_ARG_NFREE, solve_blok_scpy_callback, cl_arg,
181#endif
182 STARPU_R, rhsb->starpu_desc->handletab[fcblknum],
183 STARPU_W, rhsb->starpu_desc->handletab[cblknum],
184#if defined(PASTIX_DEBUG_STARPU)
185 STARPU_NAME, task_name,
186#endif
187#if defined(PASTIX_STARPU_HETEROPRIO)
188 STARPU_PRIORITY, BucketSolveGEMM,
189#else
190 STARPU_PRIORITY, prio,
191#endif
192 0);
193
194 (void)prio;
195}
196
197/**
198 * @}
199 */
BEGIN_C_DECLS typedef int pastix_int_t
Definition datatypes.h:51
void starpu_stask_blok_scpy_bwd_recv(sopalin_data_t *sopalin_data, pastix_rhs_t rhsb, SolverCblk *cblk, const 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