24#ifndef DOXYGEN_SHOULD_SKIP_THIS
29#include "sopalin/sopalin_data.h"
31#if defined(PASTIX_WITH_CUDA)
41struct cl_cblk_sgemmsp_args_s {
43 sopalin_data_t *sopalin_data;
51#if defined( PASTIX_STARPU_PROFILING )
59starpu_profile_t cblk_sgemmsp_profile = {
61 .name =
"cblk_sgemmsp"
67void cblk_sgemmsp_profile_register(
void ) __attribute__( ( constructor ) );
69cblk_sgemmsp_profile_register(
void )
71 profiling_register_cl( &cblk_sgemmsp_profile );
74#ifndef DOXYGEN_SHOULD_SKIP_THIS
75#if defined(PASTIX_STARPU_PROFILING_LOG)
77cl_profiling_cb_cblk_sgemmsp(
void *callback_arg )
79 cl_profiling_callback( callback_arg );
81 struct starpu_task *task = starpu_task_get_current();
82 struct starpu_profiling_task_info *info = task->profiling_info;
89 struct cl_cblk_sgemmsp_args_s *args = (
struct cl_cblk_sgemmsp_args_s *) callback_arg;
91 pastix_fixdbl_t duration = starpu_timing_timespec_delay_us( &info->start_time, &info->end_time );
98 M -= (args->cblk->cblktype & CBLK_LAYOUT_2D) ? args->blok->coefind / K : args->blok->coefind;
101 cl_profiling_log_register( task->name,
"cblk_sgemmsp", M, N, K, flops, speed );
105#if defined(PASTIX_STARPU_PROFILING_LOG)
106static void (*cblk_sgemmsp_callback)(
void*) = cl_profiling_cb_cblk_sgemmsp;
108static void (*cblk_sgemmsp_callback)(
void*) = cl_profiling_callback;
114#if defined(PASTIX_STARPU_COST_PER_ARCH)
140fct_cblk_sgemmsp_cost(
struct starpu_task *task,
141 struct starpu_perfmodel_arch *arch,
144 struct cl_cblk_sgemmsp_args_s *args = (
struct cl_cblk_sgemmsp_args_s *)(task->cl_arg);
152 M -= (args->cblk->cblktype & CBLK_LAYOUT_2D) ? args->blok->coefind / K : args->blok->coefind;
155 switch( arch->devices->type ) {
156 case STARPU_CPU_WORKER:
159 case STARPU_CUDA_WORKER:
168 cost = modelsGetCost3Param( coefs, M, N, K ) * 1e6;
175#ifndef DOXYGEN_SHOULD_SKIP_THIS
176static struct starpu_perfmodel starpu_cblk_sgemmsp_model = {
177#if defined(PASTIX_STARPU_COST_PER_ARCH)
178 .type = STARPU_PER_ARCH,
179 .arch_cost_function = fct_cblk_sgemmsp_cost,
181 .type = STARPU_HISTORY_BASED,
183 .symbol =
"cblk_sgemmsp",
187#if !defined(PASTIX_STARPU_SIMULATION)
205 struct cl_cblk_sgemmsp_args_s *args = (
struct cl_cblk_sgemmsp_args_s *)cl_arg;
210 A = pastix_starpu_cblk_get_ptr( descr[0] );
211 B = pastix_starpu_cblk_get_ptr( descr[1] );
212 C = pastix_starpu_cblk_get_ptr( descr[2] );
215 assert( args->cblk->cblktype & CBLK_LAYOUT_2D );
216 assert( args->fcblk->cblktype & CBLK_LAYOUT_2D );
219 args->cblk, args->blok, args->fcblk,
221 &( args->sopalin_data->solvmtx->lowrank ) );
227#if defined(PASTIX_WITH_CUDA)
229fct_cblk_sgemmsp_gpu(
void *descr[],
void *cl_arg )
231 struct cl_cblk_sgemmsp_args_s *args = (
struct cl_cblk_sgemmsp_args_s *)cl_arg;
236 A = pastix_starpu_cblk_get_ptr( descr[0] );
237 B = pastix_starpu_cblk_get_ptr( descr[1] );
238 C = pastix_starpu_cblk_get_ptr( descr[2] );
240 args->profile_data.flops = gpucblk_sgemmsp( args->sideA, args->trans,
241 args->cblk, args->blok, args->fcblk,
243 &( args->sopalin_data->solvmtx->lowrank ),
244 starpu_cuda_get_local_stream() );
249#ifndef DOXYGEN_SHOULD_SKIP_THIS
250CODELETS_GPU( cblk_sgemmsp, 3, STARPU_CUDA_ASYNC );
294 struct cl_cblk_sgemmsp_args_s *cl_arg = NULL;
295 long long execute_where = cl_cblk_sgemmsp_any.where;
297#if defined(PASTIX_DEBUG_STARPU) || defined(PASTIX_STARPU_PROFILING_LOG)
304#if defined(PASTIX_WITH_MPI)
307 if ( cblk->
ownerid == sopalin_data->solvmtx->clustnum ) {
310 if ( (fcblk->
cblktype & CBLK_FANIN) ||
311 (fcblk->
ownerid == sopalin_data->solvmtx->clustnum) )
318 if ( starpu_mpi_cached_receive( fcblk->
handler[sideA] ) ) {
321 if ( !need_submit ) {
331 cl_arg = malloc(
sizeof(
struct cl_cblk_sgemmsp_args_s ) );
332 cl_arg->sopalin_data = sopalin_data;
333#if defined(PASTIX_STARPU_PROFILING)
334 cl_arg->profile_data.measures = cblk_sgemmsp_profile.measures;
335 cl_arg->profile_data.flops = NAN;
337 cl_arg->sideA = sideA;
338 cl_arg->trans = trans;
341 cl_arg->fcblk = fcblk;
343#if defined(PASTIX_WITH_CUDA)
344 if ( (cblk->
cblktype & CBLK_COMPRESSED) ||
345 (fcblk->
cblktype & CBLK_COMPRESSED) )
348 execute_where &= (~STARPU_CUDA);
353#if defined(PASTIX_DEBUG_STARPU) || defined(PASTIX_STARPU_PROFILING_LOG)
355 asprintf( &task_name,
"%s( %ld, %ld, %ld )",
356 cl_cblk_sgemmsp_any.name,
357 (
long)(cblk - sopalin_data->solvmtx->cblktab),
358 (
long)(blok - sopalin_data->solvmtx->bloktab),
362 pastix_starpu_insert_task(
363 &cl_cblk_sgemmsp_any,
364 STARPU_CL_ARGS, cl_arg,
sizeof(
struct cl_cblk_sgemmsp_args_s ),
365 STARPU_EXECUTE_WHERE, execute_where,
366#
if defined(PASTIX_STARPU_PROFILING)
367 STARPU_CALLBACK_WITH_ARG_NFREE, cblk_sgemmsp_callback, cl_arg,
369 STARPU_R, cblk->
handler[sideA],
370 STARPU_R, cblk->
handler[sideB],
371 STARPU_RW, fcblk->
handler[sideA],
372#
if defined(PASTIX_DEBUG_STARPU) || defined(PASTIX_STARPU_PROFILING_LOG)
373 STARPU_NAME, task_name,
375#
if defined(PASTIX_STARPU_HETEROPRIO)
376 STARPU_PRIORITY, BucketGEMM1D,
378 STARPU_PRIORITY, prio,
BEGIN_C_DECLS typedef int pastix_int_t
@ PastixKernelGEMMCblk2d2d
pastix_fixdbl_t cpucblk_sgemmsp(pastix_coefside_t sideA, pastix_trans_t trans, const SolverCblk *cblk, const SolverBlok *blok, SolverCblk *fcblk, const void *A, const void *B, void *C, float *work, pastix_int_t lwork, const pastix_lr_t *lowrank)
Compute the updates associated to one off-diagonal block.
enum pastix_trans_e pastix_trans_t
Transpostion.
enum pastix_coefside_e pastix_coefside_t
Data blocks used in the kernel.
static void fct_cblk_sgemmsp_cpu(void *descr[], void *cl_arg)
StarPU CPU implementation.
void starpu_task_cblk_sgemmsp(sopalin_data_t *sopalin_data, pastix_coefside_t sideA, pastix_coefside_t sideB, pastix_trans_t trans, const SolverCblk *cblk, const SolverBlok *blok, SolverCblk *fcblk, int prio)
StarPU GPU implementation.
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 blok_rownbr(const SolverBlok *blok)
Compute the number of rows of a block.
static pastix_int_t cblk_colnbr(const SolverCblk *cblk)
Compute the number of columns in a column block.
Solver column block structure.