From d359974a386564a29a3dd15513c8ef8136ed58bb Mon Sep 17 00:00:00 2001 From: Antoine JEGO <antoine.jego@etu.enseeiht.fr> Date: Fri, 19 Nov 2021 17:33:40 +0100 Subject: [PATCH] added option to disable flushing or enable pruning --- starpu_example_dgemm.c | 49 ++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/starpu_example_dgemm.c b/starpu_example_dgemm.c index 8f4d6a0..345b238 100644 --- a/starpu_example_dgemm.c +++ b/starpu_example_dgemm.c @@ -58,6 +58,8 @@ static struct argp_option options[] = { {"niter", 'l', "int", 0, "Number of iterations (loops)"}, {"mpi-thread",'t', "int", 0, "MPI thread level support : -1 StarPU, 0 SINGLE, 1 FUNNELED, 2 SERIALIZED, 3 MULTIPLE"}, {"datatype", 'd', 0, 0, "Whether or not to use our own datatype implementation"}, + {"no-flush", 's', 0, 0, "If handed out to the program, do not flush anything until computation has completed."}, + {"prune", 'r', 0, 0, "If handed out to the program, prune the DAG as tightly as possible."}, { 0 } }; @@ -69,6 +71,7 @@ struct arguments int check,verbose,trace; int niter; int mpi_thread, datatype; + int no_flush, prune; }; @@ -114,6 +117,12 @@ parse_opt (int key, char *arg, struct argp_state *state) case 'd': arguments->datatype = 1; break; + case 's': + arguments->no_flush = 1; + break; + case 'r': + arguments->prune = 1; + break; default: return ARGP_ERR_UNKNOWN; } @@ -134,6 +143,8 @@ static int datatype = STARPU_EXAMPLE_DGEMM_OWNDATATYPE; /* whether to register our own datatype */ static int mpi_thread = -1; /* whether to register our own datatype */ static int verbose = 0; +static int flush = 1; +static int prune = 0; #define MB ((M)/(BS)) /* Number of blocks */ #define NB ((N)/(BS)) /* Number of blocks */ @@ -338,6 +349,8 @@ int main(int argc, char *argv[]) arguments.niter = T; arguments.mpi_thread = mpi_thread; arguments.datatype = datatype; + arguments.no_flush = 0; + arguments.prune = 0; argp_parse(&argp, argc, argv, 0, 0, &arguments); M = arguments.m; @@ -352,6 +365,8 @@ int main(int argc, char *argv[]) T = arguments.niter; mpi_thread = arguments.mpi_thread; datatype = arguments.datatype; + flush = !arguments.no_flush; + prune = arguments.prune; /* Initializes StarPU and the StarPU-MPI layer */ starpu_fxt_autostart_profiling(0); @@ -411,6 +426,8 @@ int main(int argc, char *argv[]) if (trace) printf("- Tracing enabled\n"); if (datatype) printf("- MPI datatype enabled\n"); if (mpi_thread > -1) printf("MPI thread support level : %d\n", provided_mpi_thread); + if (!flush) printf("- Flushing disabled\n"); + if (prune) printf("- Pruning enabled\n"); } int barrier_ret, trial; double start, stop; @@ -433,23 +450,27 @@ int main(int argc, char *argv[]) for (b_aisle=0;b_aisle<KB;b_aisle++) { // printf("[%d] inserting C_%d,%d += A_%d,%d B_%d,%d\n",comm_rank, b_row,b_col, b_row,b_aisle, b_aisle,b_col); - struct cl_zgemm_args_s *clargs = NULL; - if (C->blocks[b_row*NB+b_col].owner == comm_rank) { - clargs = malloc(sizeof( struct cl_zgemm_args_s )); - clargs->alpha = alpha; - clargs->beta = b_aisle==0? beta : 1.0; + if (!prune || (A->blocks[b_row*KB+b_aisle].owner == comm_rank || B->blocks[b_aisle*NB+b_col].owner == comm_rank || C->blocks[b_row*NB+b_col].owner == comm_rank)) { + struct cl_zgemm_args_s *clargs = NULL; + if (C->blocks[b_row*NB+b_col].owner == comm_rank) { + clargs = malloc(sizeof( struct cl_zgemm_args_s )); + clargs->alpha = alpha; + clargs->beta = b_aisle==0? beta : 1.0; + } + starpu_mpi_task_insert(MPI_COMM_WORLD, &gemm_cl, + STARPU_CL_ARGS, clargs, sizeof(struct cl_zgemm_args_s), + STARPU_R, A_h[b_row*KB+b_aisle], + STARPU_R, B_h[b_aisle*NB+b_col], + STARPU_RW, C_h[b_row*NB+b_col], 0); +// printf("[%d] inserted C_%d,%d += A_%d,%d B_%d,%d\n",comm_rank, b_row,b_col, b_row,b_aisle, b_aisle,b_col); } - starpu_mpi_task_insert(MPI_COMM_WORLD, &gemm_cl, - STARPU_CL_ARGS, clargs, sizeof(struct cl_zgemm_args_s), - STARPU_R, A_h[b_row*KB+b_aisle], - STARPU_R, B_h[b_aisle*NB+b_col], - STARPU_RW, C_h[b_row*NB+b_col], 0); -// printf("[%d] inserted C_%d,%d += A_%d,%d B_%d,%d\n",comm_rank, b_row,b_col, b_row,b_aisle, b_aisle,b_col); } } - for (b_aisle=0;b_aisle<KB;b_aisle++) - { - starpu_mpi_cache_flush(MPI_COMM_WORLD, A_h[b_row*KB+b_aisle]); + if (flush) { + for (b_aisle=0;b_aisle<KB;b_aisle++) + { + starpu_mpi_cache_flush(MPI_COMM_WORLD, A_h[b_row*KB+b_aisle]); + } } } -- GitLab