From be9140fbc9c73cfd321c572adb1ada007b1c9289 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 5 Oct 2022 14:44:33 -0400 Subject: [PATCH 001/157] multidimensional grid + framework for data arrays --- parsec/data_dist/CMakeLists.txt | 6 ++- parsec/include/parsec/parsec_config_bottom.h | 4 +- parsec/interfaces/ptg/ptg-compiler/jdf.h | 2 + parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 21 ++++++++- parsec/interfaces/ptg/ptg-compiler/parsec.y | 47 +++++++++++++++----- 5 files changed, 63 insertions(+), 17 deletions(-) diff --git a/parsec/data_dist/CMakeLists.txt b/parsec/data_dist/CMakeLists.txt index c28c3d4da..f77eaead6 100644 --- a/parsec/data_dist/CMakeLists.txt +++ b/parsec/data_dist/CMakeLists.txt @@ -1,5 +1,6 @@ set(sources - ${CMAKE_CURRENT_LIST_DIR}/hash_datadist.c) + ${CMAKE_CURRENT_LIST_DIR}/hash_datadist.c + ${CMAKE_CURRENT_LIST_DIR}/multidimensional_grid.c) add_subdirectory(matrix) @@ -7,5 +8,6 @@ target_sources(parsec PRIVATE ${sources}) set_property(TARGET parsec APPEND PROPERTY - PRIVATE_HEADER_H data_dist/hash_datadist.h) + PRIVATE_HEADER_H data_dist/hash_datadist.h + data_dist/multidimensional_grid.h) diff --git a/parsec/include/parsec/parsec_config_bottom.h b/parsec/include/parsec/parsec_config_bottom.h index f87a74e6d..85a270913 100644 --- a/parsec/include/parsec/parsec_config_bottom.h +++ b/parsec/include/parsec/parsec_config_bottom.h @@ -159,8 +159,8 @@ typedef int32_t parsec_dependency_t; #define MAX_LOCAL_COUNT 20 #define MAX_PARAM_COUNT 20 -#define MAX_DEP_IN_COUNT 10 -#define MAX_DEP_OUT_COUNT 10 +#define MAX_DEP_IN_COUNT 24 +#define MAX_DEP_OUT_COUNT 24 #define MAX_TASK_STRLEN 128 diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.h b/parsec/interfaces/ptg/ptg-compiler/jdf.h index 189d276f7..6d23f069c 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.h @@ -284,6 +284,7 @@ struct jdf_dataflow { jdf_flow_flags_t flow_flags; jdf_dataflow_t *next; char *varname; + struct jdf_expr *array_offset; struct jdf_dep *deps; uint8_t flow_index; uint32_t flow_dep_mask_out; @@ -338,6 +339,7 @@ typedef struct jdf_call { struct jdf_object_t super; struct jdf_expr *local_defs; /**< Each call can have some local indicies, allowing to define sets of deps */ char *var; /**< If func_or_mem is a function, var is the name of the flow on that function */ + struct jdf_expr *array_offset; /**< Offset required if var is an array */ char *func_or_mem; /**< string of the function (task class) or data collection referred to in this call */ struct jdf_expr *parameters; /**< list of parameters for that task class / data collection */ } jdf_call_t; diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index ee7d0060a..fd53cd3ca 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -756,12 +756,29 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) string_arena_init(sa); + expr_info_t expr_info = EMPTY_EXPR_INFO; + + expr_info.sa = sa; + expr_info.prefix = ""; + expr_info.suffix = ""; + + /*if(f->array_offset != NULL) + { + string_arena_add_string(sa, " for(int i=0;i<("); + dump_expr((void**)f->array_offset, &expr_info); + + string_arena_add_string(sa, ");++i) {\n"); + }*/ string_arena_add_string(sa, - " parsec_data_copy_t *_f_%s = this_task->data._f_%s.data_%s;\n", + " parsec_data_copy_t *_f_%s = this_task->data._f_%s.data_%s;\n", varname, f->varname, where); string_arena_add_string(sa, - " void *%s = PARSEC_DATA_COPY_GET_PTR(_f_%s); (void)%s;\n", + " void *%s = PARSEC_DATA_COPY_GET_PTR(_f_%s); (void)%s;\n", varname, varname, varname); + /*if(f->array_offset != NULL) + { + string_arena_add_string(sa, " }\n"); + }*/ return string_arena_get_string(sa); } diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 92393ca41..dc1074c10 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -302,6 +302,7 @@ process_datatype(jdf_datatransfer_type_t *datatype, %type dataflow %type named_expr %type named_expr_list +%type array_offset %type dependencies %type dependency %type guarded_call @@ -641,17 +642,18 @@ simulation_cost: | { $$ = NULL; } ; -partitioning: COLON VAR OPEN_PAR expr_list CLOSE_PAR +partitioning: COLON VAR array_offset OPEN_PAR expr_list CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); int nbparams; c->var = NULL; + c->array_offset = $3; c->func_or_mem = $2; data = jdf_find_or_create_data(¤t_jdf, $2); - c->parameters = $4; - JDF_COUNT_LIST_ENTRIES($4, jdf_expr_t, next, nbparams); + c->parameters = $5; + JDF_COUNT_LIST_ENTRIES($5, jdf_expr_t, next, nbparams); if( data->nbparams != -1 ) { if( data->nbparams != nbparams ) { jdf_fatal(current_lineno, "Data %s used with %d parameters at line %d while used with %d parameters line %d\n", @@ -662,8 +664,16 @@ partitioning: COLON VAR OPEN_PAR expr_list CLOSE_PAR data->nbparams = nbparams; } $$ = c; - JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($4); + JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($5); } + /* + | COLON VAR PROPERTIES_ON expr_simple PROPERTIES_OFF OPEN_PAR expr_list_range CLOSE_PAR + { + printf("coucou ! %s, %s\n", $2, $4); + } + + | PROPERTIES_ON expr_list PROPERTIES_OFF + { printf("coucou\n"); }*/ ; dataflow_list: dataflow dataflow_list @@ -685,7 +695,7 @@ optional_flow_flags : | { $$ = JDF_FLOW_TYPE_READ | JDF_FLOW_TYPE_WRITE; } ; -dataflow: optional_flow_flags VAR dependencies +dataflow: optional_flow_flags VAR array_offset dependencies { for(jdf_global_entry_t* g = current_jdf.globals; g != NULL; g = g->next) { if( !strcmp(g->name, $2) ) { @@ -698,7 +708,8 @@ dataflow: optional_flow_flags VAR dependencies jdf_dataflow_t *flow = new(jdf_dataflow_t); flow->flow_flags = $1; flow->varname = $2; - flow->deps = $3; + flow->array_offset = $3; + flow->deps = $4; $$ = flow; if( NULL == $3) { @@ -732,6 +743,16 @@ named_expr_list: VAR ASSIGNMENT expr_range } ; +array_offset: PROPERTIES_ON expr_simple PROPERTIES_OFF + { + $$ = $2; + } + | + { + $$ = NULL; + } + ; + dependencies: dependency dependencies { $1->next = $2; @@ -899,6 +920,7 @@ call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR { jdf_call_t *c = new(jdf_call_t); c->var = $2; + c->array_offset = NULL; c->local_defs = $1; c->func_or_mem = $3; c->parameters = $5; @@ -907,21 +929,22 @@ call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR assert( 0 != JDF_OBJECT_LINENO($$) ); named_expr_pop_scope(); } - | VAR OPEN_PAR expr_list_range CLOSE_PAR + | VAR array_offset OPEN_PAR expr_list_range CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); int nbparams; c->var = NULL; + c->array_offset = $2; c->func_or_mem = $1; - c->parameters = $3; + c->parameters = $4; c->local_defs = NULL; - JDF_OBJECT_LINENO(c) = JDF_OBJECT_LINENO($3); + JDF_OBJECT_LINENO(c) = JDF_OBJECT_LINENO($4); $$ = c; assert( 0 != JDF_OBJECT_LINENO($$) ); data = jdf_find_or_create_data(¤t_jdf, $1); - JDF_COUNT_LIST_ENTRIES($3, jdf_expr_t, next, nbparams); + JDF_COUNT_LIST_ENTRIES($4, jdf_expr_t, next, nbparams); if( data->nbparams != -1 ) { if( data->nbparams != nbparams ) { jdf_fatal(current_lineno, "Data %s used with %d parameters at line %d while used with %d parameters line %d\n", @@ -931,12 +954,13 @@ call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR } else { data->nbparams = nbparams; } - JDF_OBJECT_LINENO(data) = JDF_OBJECT_LINENO($3); + JDF_OBJECT_LINENO(data) = JDF_OBJECT_LINENO($4); } | DATA_NEW { jdf_call_t *c = new(jdf_call_t); c->var = NULL; + c->array_offset = NULL; c->local_defs = NULL; c->func_or_mem = strdup(PARSEC_WRITE_MAGIC_NAME); c->parameters = NULL; @@ -947,6 +971,7 @@ call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR { jdf_call_t *c = new(jdf_call_t); c->var = NULL; + c->array_offset = NULL; c->local_defs = NULL; c->func_or_mem = strdup(PARSEC_NULL_MAGIC_NAME); c->parameters = NULL; From 8edc8fe13ec5b7f77ef471b4dc2eaf1d008cedf6 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 5 Oct 2022 14:44:33 -0400 Subject: [PATCH 002/157] multidimensional grid + framework for data arrays --- parsec/data_dist/CMakeLists.txt | 6 ++- parsec/include/parsec/parsec_config_bottom.h | 4 +- parsec/interfaces/ptg/ptg-compiler/jdf.h | 2 + parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 21 ++++++++- parsec/interfaces/ptg/ptg-compiler/parsec.y | 47 +++++++++++++++----- 5 files changed, 63 insertions(+), 17 deletions(-) diff --git a/parsec/data_dist/CMakeLists.txt b/parsec/data_dist/CMakeLists.txt index c28c3d4da..f77eaead6 100644 --- a/parsec/data_dist/CMakeLists.txt +++ b/parsec/data_dist/CMakeLists.txt @@ -1,5 +1,6 @@ set(sources - ${CMAKE_CURRENT_LIST_DIR}/hash_datadist.c) + ${CMAKE_CURRENT_LIST_DIR}/hash_datadist.c + ${CMAKE_CURRENT_LIST_DIR}/multidimensional_grid.c) add_subdirectory(matrix) @@ -7,5 +8,6 @@ target_sources(parsec PRIVATE ${sources}) set_property(TARGET parsec APPEND PROPERTY - PRIVATE_HEADER_H data_dist/hash_datadist.h) + PRIVATE_HEADER_H data_dist/hash_datadist.h + data_dist/multidimensional_grid.h) diff --git a/parsec/include/parsec/parsec_config_bottom.h b/parsec/include/parsec/parsec_config_bottom.h index f87a74e6d..85a270913 100644 --- a/parsec/include/parsec/parsec_config_bottom.h +++ b/parsec/include/parsec/parsec_config_bottom.h @@ -159,8 +159,8 @@ typedef int32_t parsec_dependency_t; #define MAX_LOCAL_COUNT 20 #define MAX_PARAM_COUNT 20 -#define MAX_DEP_IN_COUNT 10 -#define MAX_DEP_OUT_COUNT 10 +#define MAX_DEP_IN_COUNT 24 +#define MAX_DEP_OUT_COUNT 24 #define MAX_TASK_STRLEN 128 diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.h b/parsec/interfaces/ptg/ptg-compiler/jdf.h index 189d276f7..6d23f069c 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.h @@ -284,6 +284,7 @@ struct jdf_dataflow { jdf_flow_flags_t flow_flags; jdf_dataflow_t *next; char *varname; + struct jdf_expr *array_offset; struct jdf_dep *deps; uint8_t flow_index; uint32_t flow_dep_mask_out; @@ -338,6 +339,7 @@ typedef struct jdf_call { struct jdf_object_t super; struct jdf_expr *local_defs; /**< Each call can have some local indicies, allowing to define sets of deps */ char *var; /**< If func_or_mem is a function, var is the name of the flow on that function */ + struct jdf_expr *array_offset; /**< Offset required if var is an array */ char *func_or_mem; /**< string of the function (task class) or data collection referred to in this call */ struct jdf_expr *parameters; /**< list of parameters for that task class / data collection */ } jdf_call_t; diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index ee7d0060a..fd53cd3ca 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -756,12 +756,29 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) string_arena_init(sa); + expr_info_t expr_info = EMPTY_EXPR_INFO; + + expr_info.sa = sa; + expr_info.prefix = ""; + expr_info.suffix = ""; + + /*if(f->array_offset != NULL) + { + string_arena_add_string(sa, " for(int i=0;i<("); + dump_expr((void**)f->array_offset, &expr_info); + + string_arena_add_string(sa, ");++i) {\n"); + }*/ string_arena_add_string(sa, - " parsec_data_copy_t *_f_%s = this_task->data._f_%s.data_%s;\n", + " parsec_data_copy_t *_f_%s = this_task->data._f_%s.data_%s;\n", varname, f->varname, where); string_arena_add_string(sa, - " void *%s = PARSEC_DATA_COPY_GET_PTR(_f_%s); (void)%s;\n", + " void *%s = PARSEC_DATA_COPY_GET_PTR(_f_%s); (void)%s;\n", varname, varname, varname); + /*if(f->array_offset != NULL) + { + string_arena_add_string(sa, " }\n"); + }*/ return string_arena_get_string(sa); } diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 92393ca41..dc1074c10 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -302,6 +302,7 @@ process_datatype(jdf_datatransfer_type_t *datatype, %type dataflow %type named_expr %type named_expr_list +%type array_offset %type dependencies %type dependency %type guarded_call @@ -641,17 +642,18 @@ simulation_cost: | { $$ = NULL; } ; -partitioning: COLON VAR OPEN_PAR expr_list CLOSE_PAR +partitioning: COLON VAR array_offset OPEN_PAR expr_list CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); int nbparams; c->var = NULL; + c->array_offset = $3; c->func_or_mem = $2; data = jdf_find_or_create_data(¤t_jdf, $2); - c->parameters = $4; - JDF_COUNT_LIST_ENTRIES($4, jdf_expr_t, next, nbparams); + c->parameters = $5; + JDF_COUNT_LIST_ENTRIES($5, jdf_expr_t, next, nbparams); if( data->nbparams != -1 ) { if( data->nbparams != nbparams ) { jdf_fatal(current_lineno, "Data %s used with %d parameters at line %d while used with %d parameters line %d\n", @@ -662,8 +664,16 @@ partitioning: COLON VAR OPEN_PAR expr_list CLOSE_PAR data->nbparams = nbparams; } $$ = c; - JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($4); + JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($5); } + /* + | COLON VAR PROPERTIES_ON expr_simple PROPERTIES_OFF OPEN_PAR expr_list_range CLOSE_PAR + { + printf("coucou ! %s, %s\n", $2, $4); + } + + | PROPERTIES_ON expr_list PROPERTIES_OFF + { printf("coucou\n"); }*/ ; dataflow_list: dataflow dataflow_list @@ -685,7 +695,7 @@ optional_flow_flags : | { $$ = JDF_FLOW_TYPE_READ | JDF_FLOW_TYPE_WRITE; } ; -dataflow: optional_flow_flags VAR dependencies +dataflow: optional_flow_flags VAR array_offset dependencies { for(jdf_global_entry_t* g = current_jdf.globals; g != NULL; g = g->next) { if( !strcmp(g->name, $2) ) { @@ -698,7 +708,8 @@ dataflow: optional_flow_flags VAR dependencies jdf_dataflow_t *flow = new(jdf_dataflow_t); flow->flow_flags = $1; flow->varname = $2; - flow->deps = $3; + flow->array_offset = $3; + flow->deps = $4; $$ = flow; if( NULL == $3) { @@ -732,6 +743,16 @@ named_expr_list: VAR ASSIGNMENT expr_range } ; +array_offset: PROPERTIES_ON expr_simple PROPERTIES_OFF + { + $$ = $2; + } + | + { + $$ = NULL; + } + ; + dependencies: dependency dependencies { $1->next = $2; @@ -899,6 +920,7 @@ call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR { jdf_call_t *c = new(jdf_call_t); c->var = $2; + c->array_offset = NULL; c->local_defs = $1; c->func_or_mem = $3; c->parameters = $5; @@ -907,21 +929,22 @@ call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR assert( 0 != JDF_OBJECT_LINENO($$) ); named_expr_pop_scope(); } - | VAR OPEN_PAR expr_list_range CLOSE_PAR + | VAR array_offset OPEN_PAR expr_list_range CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); int nbparams; c->var = NULL; + c->array_offset = $2; c->func_or_mem = $1; - c->parameters = $3; + c->parameters = $4; c->local_defs = NULL; - JDF_OBJECT_LINENO(c) = JDF_OBJECT_LINENO($3); + JDF_OBJECT_LINENO(c) = JDF_OBJECT_LINENO($4); $$ = c; assert( 0 != JDF_OBJECT_LINENO($$) ); data = jdf_find_or_create_data(¤t_jdf, $1); - JDF_COUNT_LIST_ENTRIES($3, jdf_expr_t, next, nbparams); + JDF_COUNT_LIST_ENTRIES($4, jdf_expr_t, next, nbparams); if( data->nbparams != -1 ) { if( data->nbparams != nbparams ) { jdf_fatal(current_lineno, "Data %s used with %d parameters at line %d while used with %d parameters line %d\n", @@ -931,12 +954,13 @@ call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR } else { data->nbparams = nbparams; } - JDF_OBJECT_LINENO(data) = JDF_OBJECT_LINENO($3); + JDF_OBJECT_LINENO(data) = JDF_OBJECT_LINENO($4); } | DATA_NEW { jdf_call_t *c = new(jdf_call_t); c->var = NULL; + c->array_offset = NULL; c->local_defs = NULL; c->func_or_mem = strdup(PARSEC_WRITE_MAGIC_NAME); c->parameters = NULL; @@ -947,6 +971,7 @@ call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR { jdf_call_t *c = new(jdf_call_t); c->var = NULL; + c->array_offset = NULL; c->local_defs = NULL; c->func_or_mem = strdup(PARSEC_NULL_MAGIC_NAME); c->parameters = NULL; From 6f4cf43a7c5a9c8b437b53be5e81eeeab605ca65 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 5 Oct 2022 14:51:27 -0400 Subject: [PATCH 003/157] forgotten files --- parsec/data_dist/multidimensional_grid.c | 467 +++++++++++++++++++++++ parsec/data_dist/multidimensional_grid.h | 150 ++++++++ 2 files changed, 617 insertions(+) create mode 100644 parsec/data_dist/multidimensional_grid.c create mode 100644 parsec/data_dist/multidimensional_grid.h diff --git a/parsec/data_dist/multidimensional_grid.c b/parsec/data_dist/multidimensional_grid.c new file mode 100644 index 000000000..5e058f0f7 --- /dev/null +++ b/parsec/data_dist/multidimensional_grid.c @@ -0,0 +1,467 @@ +/* + * Copyright (c) 2010-2021 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + */ +/************************************************************ + *distributed multidimensional_grid generation + ************************************************************/ + +#include "parsec/parsec_config.h" +#include "parsec/parsec_internal.h" +#include "parsec/utils/debug.h" +#include "parsec/data.h" +#include "parsec/data_distribution.h" +#include "parsec/data_dist/multidimensional_grid.h" +#include "parsec/data_dist/matrix/two_dim_rectangle_cyclic.h" +#include "parsec/data_dist/matrix/sym_two_dim_rectangle_cyclic.h" +#include "parsec/data_dist/matrix/two_dim_tabular.h" + +#if defined(PARSEC_HAVE_MPI) +#include +#endif +#include + +#include "parsec/parsec_config.h" +#include "parsec/parsec_internal.h" +#include "parsec/utils/debug.h" +#include "parsec/data_dist/matrix/matrix.h" +#include "parsec/data_dist/matrix/two_dim_rectangle_cyclic.h" +#include "parsec/data_dist/matrix/matrix_internal.h" +#include "parsec/mca/device/device.h" +#include "parsec/vpmap.h" + + +static uint32_t MGRID_rank_of_coordinates(parsec_data_collection_t *desc, int tile_coordinates[((parsec_multidimensional_grid_t*)desc)->tiling_dimensions_number]); +void parsec_multidimensional_grid_key2coords(parsec_multidimensional_grid_t *dc, + parsec_data_key_t key, + int tile_coordinates[dc->tiling_dimensions_number]); + +static parsec_data_key_t grid_data_key(struct parsec_data_collection_s *desc, ...); + +static uint32_t MGRID_rank_of(parsec_data_collection_t *desc, ...); +static int32_t MGRID_vpid_of(parsec_data_collection_t* desc, ...); +static parsec_data_t* MGRID_data_of(parsec_data_collection_t* dc, ...); +static uint32_t MGRID_rank_of_key(parsec_data_collection_t* desc, parsec_data_key_t key); +static int32_t MGRID_vpid_of_key(parsec_data_collection_t* desc, parsec_data_key_t key); +static parsec_data_t* MGRID_data_of_key(parsec_data_collection_t* dc, parsec_data_key_t key); + + + + +static int MGRID_memory_register(parsec_data_collection_t* desc, parsec_device_module_t* device) +{ + parsec_multidimensional_grid_t * dc = (parsec_multidimensional_grid_t *)desc; + if( (NULL == dc->grid ) || (dc->nb_local_tiles == 0)) { + return PARSEC_SUCCESS; + } + + return device->memory_register(device, desc, + dc->grid, + ((size_t)dc->tile_number_of_values * + (size_t)parsec_datadist_getsizeoftype(dc->mtype))); +} + +static int MGRID_memory_unregister(parsec_data_collection_t* desc, parsec_device_module_t* device) +{ + parsec_multidimensional_grid_t * dc = (parsec_multidimensional_grid_t *)desc; + if( (NULL == dc->grid ) || (dc->nb_local_tiles == 0)) { + return PARSEC_SUCCESS; + } + + return device->memory_unregister(device, desc, dc->grid); +} + +void parsec_multidimensional_grid_init(parsec_multidimensional_grid_t * dc, + parsec_matrix_type_t mtype, + int nodes, int myrank, + int tiling_dimensions_number, int tile_dimensions_number, + ... + // tiling_size [tiling_dimensions_number times], + // tile_size [tile_dimensions_number times], + // mpi_stencil_size [tiling_dimensions_number times], + + + /* + int mb, int nb, // Tile size + int lm, int ln, // Global matrix size (what is stored) + int i, int j, // Staring point in the global matrix + int m, int n, // Submatrix size (the one concerned by the computation + int P, int Q, // process process grid + int kp, int kq, // k-cyclicity + int ip, int jq // starting point on the process grid + */ + ) +{ + va_list ap; + + // fill in the dc structure + dc->tiling_dimensions_number = tiling_dimensions_number; + dc->tile_dimensions_number = tile_dimensions_number; + + va_start(ap, tiling_dimensions_number); + for(int d=0;dtiling_dimensions_number;++d) + { + dc->tiling_size[d] = (int)va_arg(ap, unsigned int); + } + for(int d=0;dtile_dimensions_number;++d) + { + dc->tile_size[d] = (int)va_arg(ap, unsigned int); + } + for(int d=0;dtiling_dimensions_number;++d) + { + dc->mpi_stencil_size[d] = (int)va_arg(ap, unsigned int); + } + va_end(ap); + + dc->grid = NULL; // no data associated yet + dc->mtype = mtype; + + dc->tile_number_of_values = 1; + for(int d=0;dtile_dimensions_number;++d) + { + dc->tile_number_of_values *= dc->tile_size[d]; + } + + dc->tile_number = 1; + for(int d=0;dtiling_dimensions_number;++d) + { + dc->tile_number *= dc->tiling_size[d]; + } + + dc->nb_local_tiles = 0; + for(int t=0;ttile_number;++t) + { + int tile_coordinates[dc->tiling_dimensions_number]; + parsec_multidimensional_grid_key2coords(dc, t, tile_coordinates); + int target_rank = MGRID_rank_of_coordinates((parsec_data_collection_t*)dc, tile_coordinates); + if(target_rank == myrank) + { + ++dc->nb_local_tiles; + } + } + + dc->data_map = (parsec_data_t**)calloc(dc->nb_local_tiles, sizeof(parsec_data_t*)); + dc->bsiz = dc->tile_number_of_values * parsec_datadist_getsizeoftype(dc->mtype); + + + parsec_data_collection_t *o = &(dc->super); + + parsec_data_collection_init( o, nodes, myrank ); + + o->data_key = grid_data_key; + + /* set the methods */ + o->rank_of = MGRID_rank_of; + o->vpid_of = MGRID_vpid_of; + o->data_of = MGRID_data_of; + o->rank_of_key = MGRID_rank_of_key; + o->vpid_of_key = MGRID_vpid_of_key; + o->data_of_key = MGRID_data_of_key; + + o->register_memory = MGRID_memory_register; + o->unregister_memory = MGRID_memory_unregister; + + + /* finish to update the main object properties */ + /*o->key_to_string = tiled_matrix_key_to_string; // dont care atm YET + if( asprintf(&(o->key_dim), "(%d, %d)", tdesc->lmt, tdesc->lnt) <= 0 ) { + o->key_dim = NULL; + }*/ + + /* Define the default datatye of the datacollection */ + parsec_datatype_t elem_dt = PARSEC_DATATYPE_NULL; + ptrdiff_t extent; + parsec_translate_matrix_type( dc->mtype, &elem_dt ); + if( PARSEC_SUCCESS != parsec_matrix_define_datatype(&o->default_dtt, elem_dt, + PARSEC_MATRIX_FULL, 1 /*diag*/, + dc->tile_number_of_values, 1, dc->tile_number_of_values /*ld*/, + -1/*resized*/, &extent)){ + parsec_fatal("Unable to create a datatype for the data collection."); + } + +/* + // print the dc structure + printf("dc.tiling_dimensions_number = %d\n", dc->tiling_dimensions_number); + for(int d=0;dtiling_dimensions_number;++d) + { + printf("dc.tiling_size[%d] = %d\n", d, dc->tiling_size[d]); + } + for(int d=0;dtiling_dimensions_number;++d) + { + printf("dc.tile_size[%d] = %d\n", d, dc->tile_size[d]); + } + for(int d=0;dtiling_dimensions_number;++d) + { + printf("dc.mpi_stencil_size[%d] = %d\n", d, dc->mpi_stencil_size[d]); + } + printf("dc.tile_number_of_values = %d\n", dc->tile_number_of_values); + printf("dc.tile_number = %d\n", dc->tile_number); + printf("dc.nb_local_tiles = %d\n", dc->nb_local_tiles); +*/ + +} + +void parsec_grid_destroy_data( parsec_multidimensional_grid_t *grid ) +{ + if ( grid->data_map != NULL ) { + parsec_data_t **data = grid->data_map; + + for(int i = 0; i < grid->nb_local_tiles; i++, data++) { + if( NULL == *data ) continue; + parsec_data_destroy( *data ); + } + + free( grid->data_map ); + grid->data_map = NULL; + } +} + +void parsec_grid_destroy( parsec_multidimensional_grid_t *grid ) +{ + parsec_data_collection_t *dc = (parsec_data_collection_t*)grid; + parsec_type_free(&dc->default_dtt); + + parsec_grid_destroy_data( grid ); + parsec_data_collection_destroy( dc ); +} + +static inline int MGRID_coordinates_to_position(parsec_multidimensional_grid_t *dc, int tile_coordinates[dc->tiling_dimensions_number]) +{ + int position = 0; + int offset_multiplier = 1; + for(int d=0;dtiling_dimensions_number;++d) + { + position += tile_coordinates[d] * offset_multiplier; + offset_multiplier *= dc->tiling_size[d]; + } + + //printf("coordinates %d %d %d -> position %d\n", tile_coordinates[0], tile_coordinates[1], tile_coordinates[2], position); + + return position; +} + +/* return a unique key (unique only for the specified parsec_dc) associated to a data */ +static parsec_data_key_t grid_data_key(struct parsec_data_collection_s *desc, ...) +{ + parsec_multidimensional_grid_t *dc = (parsec_multidimensional_grid_t *)desc; + va_list ap; + + int tile_coordinates[dc->tiling_dimensions_number]; + + /* Get coordinates */ + va_start(ap, desc); + for(int d=0;dtiling_dimensions_number;++d) + { + tile_coordinates[d] = (int)va_arg(ap, unsigned int); + } + va_end(ap); + + int position = MGRID_coordinates_to_position(dc, tile_coordinates); + + return position; +} + +void parsec_multidimensional_grid_key2coords(parsec_multidimensional_grid_t *dc, + parsec_data_key_t key, + int tile_coordinates[dc->tiling_dimensions_number]) +{ + // compute the offset multiplier + int offset_multiplier = 1; + for(int d=0;dtiling_dimensions_number-1;++d) + { + offset_multiplier *= dc->tiling_size[d]; + } + + int d=dc->tiling_dimensions_number-1; + do + { + tile_coordinates[d] = (key / offset_multiplier) % dc->tiling_size[d]; + if(d <= 0) + { + break; + } + --d; + offset_multiplier /= dc->tiling_size[d]; + }while(true); +} + +/* + * + * Set of functions with no k-cyclicity support + * + */ + +static uint32_t MGRID_rank_of_coordinates(parsec_data_collection_t *desc, int tile_coordinates[((parsec_multidimensional_grid_t*)desc)->tiling_dimensions_number]) +{ + parsec_multidimensional_grid_t * dc = (parsec_multidimensional_grid_t *)desc; + + /* Assert using local info */ + for(int d=0;dtiling_dimensions_number;++d) + { + assert( tile_coordinates[d] < dc->tiling_size[d] ); + } + + int res = 0; + //int process_coordinates[dc->tiling_dimensions_number]; + int offset_multiplier = 1; + for(int d=0;dtiling_dimensions_number;++d) + { + // computes the process that should handle the tile depending on its cooresponding coordinates + + // coordinates of the tile inside the stencil + const int local_coordinates = tile_coordinates[d] % dc->mpi_stencil_size[d]; + + // coordinates of the process inside the stencil + // the pattern is the following (in 2D): + // 0 1 ... NX + // NX+1 NX+2 ... 2NX + // ... + // (NY-1)*NX (NY-1)*NX+1 ... NY*NX + res += offset_multiplier * local_coordinates; + + offset_multiplier *= dc->mpi_stencil_size[d]; + } + + return res; +} + + +static uint32_t MGRID_rank_of(parsec_data_collection_t *desc, ...) +{ + parsec_multidimensional_grid_t * dc = (parsec_multidimensional_grid_t *)desc; + int tile_coordinates[dc->tiling_dimensions_number]; + + va_list ap; + dc = (parsec_multidimensional_grid_t *)desc; + + /* Get coordinates */ + va_start(ap, desc); + for(int d=0;dtiling_dimensions_number;++d) + { + tile_coordinates[d] = (int)va_arg(ap, unsigned int); + } + va_end(ap); + + return MGRID_rank_of_coordinates(desc, tile_coordinates); +} + +static uint32_t MGRID_rank_of_key(parsec_data_collection_t *desc, parsec_data_key_t key) +{ + parsec_multidimensional_grid_t * dc = (parsec_multidimensional_grid_t *)desc; + int tile_coordinates[dc->tiling_dimensions_number]; + + parsec_multidimensional_grid_key2coords(dc, key, tile_coordinates); + + return MGRID_rank_of(desc, tile_coordinates); +} + +static int32_t MGRID_vpid_of_coordinates(parsec_data_collection_t *desc, int tile_coordinates[((parsec_multidimensional_grid_t *)desc)->tiling_dimensions_number]) +{ + + // TODO for the moment, vpid == rank + return MGRID_rank_of_coordinates(desc, tile_coordinates); +} + +static int32_t MGRID_vpid_of(parsec_data_collection_t *desc, ...) +{ + parsec_multidimensional_grid_t * dc; + va_list ap; + dc = (parsec_multidimensional_grid_t *)desc; + + int tile_coordinates[dc->tiling_dimensions_number]; + + /* Get coordinates */ + va_start(ap, desc); + for(int d=0;dtiling_dimensions_number;++d) + { + tile_coordinates[d] = (int)va_arg(ap, unsigned int); + } + va_end(ap); + + /* Assert using local info */ + for(int d=0;dtiling_dimensions_number;++d) + { + assert( tile_coordinates[d] < dc->tiling_size[d] ); + } + +#if defined(DISTRIBUTED) + assert(desc->myrank == MGRID_rank_of_coordinates(desc, tile_coordinates)); +#endif + +//printf("vpid of coordinates %d %d is %d\n", tile_coordinates[0], tile_coordinates[1], MGRID_vpid_of_coordinates(desc, tile_coordinates)); + + return MGRID_vpid_of_coordinates(desc, tile_coordinates); +} + +static int32_t MGRID_vpid_of_key(parsec_data_collection_t *desc, parsec_data_key_t key) +{ + parsec_multidimensional_grid_t *dc = (parsec_multidimensional_grid_t *)desc; + int tile_coordinates[dc->tiling_dimensions_number]; + + parsec_multidimensional_grid_key2coords(dc, key, tile_coordinates); + + return MGRID_vpid_of_coordinates(desc, tile_coordinates); +} + +static parsec_data_t* MGRID_data_of(parsec_data_collection_t *desc, ...) +{ + int position; + va_list ap; + parsec_multidimensional_grid_t * dc; + dc = (parsec_multidimensional_grid_t *)desc; + + int tile_coordinates[dc->tiling_dimensions_number]; // tile position in the whole grid + + /* Get coordinates */ + va_start(ap, desc); + for(int d=0;dtiling_dimensions_number;++d) + { + tile_coordinates[d] = (int)va_arg(ap, unsigned int); + } + va_end(ap); + + /* Assert using local info */ + for(int d=0;dtiling_dimensions_number;++d) + { + assert( tile_coordinates[d] < dc->tiling_size[d] ); + } + +#if defined(DISTRIBUTED) + assert(desc->myrank == MGRID_rank_of_coordinates(desc, tile_coordinates)); +#endif + + position = MGRID_coordinates_to_position(dc, tile_coordinates); + + int key = position; + int pos = 0; + + if(dc->grid != NULL) + { + pos = position; + } + + return parsec_data_create(dc->data_map + position, + desc, key, (char*)dc->grid + pos * dc->bsiz, + dc->bsiz, + PARSEC_DATA_FLAG_PARSEC_MANAGED); +} + +static parsec_data_t* MGRID_data_of_key(parsec_data_collection_t *desc, parsec_data_key_t key) +{ + parsec_multidimensional_grid_t *dc = (parsec_multidimensional_grid_t *)desc; + + int position = key; + int pos = 0; + + if(dc->grid != NULL) + { + pos = position; + } + + return parsec_data_create(dc->data_map + position, + desc, key, (char*)dc->grid + pos * dc->bsiz, + dc->bsiz, + PARSEC_DATA_FLAG_PARSEC_MANAGED); +} + diff --git a/parsec/data_dist/multidimensional_grid.h b/parsec/data_dist/multidimensional_grid.h new file mode 100644 index 000000000..edcbb825d --- /dev/null +++ b/parsec/data_dist/multidimensional_grid.h @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2010-2021 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + */ + + +#ifndef _MULTIDIMENSIONAL_GRID_H_ +#define _MULTIDIMENSIONAL_GRID_H_ + +#include "parsec/parsec_config.h" +#include +#include +#include "parsec/runtime.h" +#include "parsec/data_distribution.h" +#include "parsec/data.h" +#include "parsec/datatype.h" +#include "parsec/parsec_internal.h" +#include "parsec/data_dist/matrix/matrix.h" +#include "parsec/data_dist/matrix/grid_2Dcyclic.h" + +#define MAX_DIMENSIONS_NUMBER 8 + +BEGIN_C_DECLS + +/* +struct parsec_execution_stream_s; +struct parsec_taskpool_s; +*/ + +/* +TODO +- use bsiz for complete tile size including the overlap +- get the proper tile_coordinates in MGRID_data_of (the part with va_start(ap, desc);) (not just in MGRID_data_of...) +- init mpi_stencil_size +*/ + +typedef struct parsec_multidimensional_grid_s { + parsec_data_collection_t super; + void *grid; /**< pointer to the beginning of the grid */ + parsec_data_t** data_map; /**< map of the data */ + parsec_matrix_type_t mtype; /**< precision of the matrix */ + + size_t bsiz; + + int nb_local_tiles; /**< number of tile handled locally */ + + int tiling_dimensions_number; // Number of dimensions of the tiling + int tile_dimensions_number; // Number of dimensions of a tile + + int tiling_size[MAX_DIMENSIONS_NUMBER]; // size : [tiling_dimensions_number] // number of tiles in the grid + int tile_size[MAX_DIMENSIONS_NUMBER]; // size : [tile_dimensions_number] // size of a tile + //int grid_size[MAX_DIMENSIONS_NUMBER]; // size : [grid_dimensions_number] + int mpi_stencil_size[MAX_DIMENSIONS_NUMBER]; // size : [tiling_dimensions_number] + + int tile_number_of_values; // number of elements in a tile + int tile_number; // total number of tiles +} parsec_multidimensional_grid_t; + +// #define A(m,n) &((double*)descA.mat)[descA.bsiz*(m)+descA.bsiz*descA.lmt*(n)] + +/** + * Initialize the description of a 2-D block cyclic distributed matrix. + * @param dc matrix description structure, already allocated, that will be initialize + * @param mtype type of data used for this matrix + * @param storage type of storage of data + * @param nodes number of nodes + * @param myrank rank of the local node (as of mpi rank) + * @param mb number of row in a tile + * @param nb number of column in a tile + * @param lm number of rows of the entire matrix + * @param ln number of column of the entire matrix + * @param i starting row index for the computation on a submatrix + * @param j starting column index for the computation on a submatrix + * @param m number of rows of the entire submatrix + * @param n numbr of column of the entire submatrix + * @param p number of row of processes of the process grid the + * resulting distribution will be made so that pxq=nodes + * @param q number of col of processes of the process grid the + * resulting distribution will be made so that pxq=nodes + * @param kp number of rows of tiles for k-cyclic block distribution + * act as-if the process grid had nkp repetitions for every process row + * (see example for kq below) + * @param kq number of column of tiles for k-cyclic block distribution + * act as-if the process grid had kq repetitions for every process column + * For example, kp=1, kq=2 leads to the following pxq=2x4 process grid + * | 0 | 0 | 1 | 1 | 2 | 2 | 3 | 3 | + * | 4 | 4 | 5 | 5 | 6 | 6 | 7 | 7 | + * @param ip starting point on the process grid rows + * @param jq starting point on the process grid cols + */ +void parsec_multidimensional_grid_init(parsec_multidimensional_grid_t * dc, + parsec_matrix_type_t mtype, + int nodes, int myrank, + int tiling_dimensions_number, int tile_dimensions_number, + ... + // tiling_size [tiling_dimensions_number times], + // tile_size [tile_dimensions_number times], + // mpi_stencil_size [tiling_dimensions_number times], + + + /* + int mb, int nb, // Tile size + int lm, int ln, // Global matrix size (what is stored) + int i, int j, // Staring point in the global matrix + int m, int n, // Submatrix size (the one concerned by the computation + int P, int Q, // process process grid + int kp, int kq, // k-cyclicity + int ip, int jq // starting point on the process grid + */ + ); + +void parsec_grid_destroy( parsec_multidimensional_grid_t *grid ); + +/** + * kcyclic _view_ of the 2-D Block cyclic distributed matrix. The goal is to + * improve access locality by changing access order without incurring the cost of a physical + * redistribution of the dataset. The underlying data storage is unchanged, + * but the view provide accessors that swap lines and column blocks so that a block + * from the same processor is provided for @kp repetitions along the m direction + * (@kq along n, respectively); until such repetition is not possible anymore + * (right edge, or bottom of the matrix where not enough local tiles are available). + * + * For example, starting from a standard 2D grid PxQ=2x2 with kp=2; + * and m/mb = 6; + * rank_of(0,0) is 0; data_of(0,0) is origin (0,0) + * rank_of(1,0) is 0 (because kp=2); data_of(1,0) is origin (2,0) + * rank_of(2,0) is 1; data_of(2,0) is origin (1,0) + * rank_of(3,0) is 1 (because kp=2); data_of(3,0) is origin (3,0) + * rank_of(4,0) is 0; data_of(4,0) is origin (4,0) + * rank_of(5,0) is 1; data_of(5,0) is origin (5,0): despite kp=2, + * there are not enough local tiles on rank 0 to satisfy the view + * origin (6,0) does not exist), hence the view provides the next + * block on the m direction. + * + * Beware that using a kcyclic view is equivalent to swapping rows (or + * columns, respectively), and the algorithm operating on the data may have + * special requirements for it to be applicable. For example, a kcyclic + * view of a diagonal dominant matrix is not always diagonal dominant; and the + * result of a factorization on a kcyclic view is not a 'triangular' matrix, + * but a swap, according to the view (i.e., solving the system requires applying + * a compatible view on the right-hand side as well). + * + */ +void parsec_multidimensional_grid_kview( parsec_multidimensional_grid_t* target, + parsec_multidimensional_grid_t* origin, + int kp, int kq ); + +END_C_DECLS +#endif /* _MULTIDIMENSIONAL_GRID_H_ */ From 9de108d839e0bc837d3513b22ad60d1513d5b142 Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 6 Oct 2022 11:54:17 -0400 Subject: [PATCH 004/157] glitchy parametrized flow semantic --- parsec/interfaces/ptg/ptg-compiler/jdf.h | 6 +++ parsec/interfaces/ptg/ptg-compiler/parsec.y | 53 +++++++++++++++++---- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.h b/parsec/interfaces/ptg/ptg-compiler/jdf.h index 6d23f069c..8733414ac 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.h @@ -268,6 +268,12 @@ typedef struct jdf_def_list { struct jdf_def_list *properties; } jdf_def_list_t; +typedef struct jdf_flow_specifier { + struct jdf_object_t super; + struct jdf_expr *array_offset; + struct jdf_expr *expr; +} jdf_flow_specifier_t; + typedef struct jdf_dataflow jdf_dataflow_t; typedef struct jdf_dep jdf_dep_t; typedef uint32_t jdf_flow_flags_t; diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index dc1074c10..271b11d5a 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -280,6 +280,7 @@ process_datatype(jdf_datatransfer_type_t *datatype, jdf_def_list_t *property; jdf_name_list_t *name_list; jdf_variable_list_t *variable_list; + jdf_flow_specifier_t *flow_specifier; jdf_dataflow_t *dataflow; jdf_expr_t *named_expr; jdf_dep_t *dep; @@ -298,11 +299,13 @@ process_datatype(jdf_datatransfer_type_t *datatype, %type local_variable %type local_variables %type partitioning +%type flow_specifier %type dataflow_list %type dataflow %type named_expr %type named_expr_list %type array_offset +%type array_offset_or_nothing %type dependencies %type dependency %type guarded_call @@ -642,7 +645,7 @@ simulation_cost: | { $$ = NULL; } ; -partitioning: COLON VAR array_offset OPEN_PAR expr_list CLOSE_PAR +partitioning: COLON VAR array_offset_or_nothing OPEN_PAR expr_list CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); @@ -695,7 +698,32 @@ optional_flow_flags : | { $$ = JDF_FLOW_TYPE_READ | JDF_FLOW_TYPE_WRITE; } ; -dataflow: optional_flow_flags VAR array_offset dependencies +/* +typedef struct jdf_flow_specifier { + struct jdf_object_t super; + struct jdf_expr *array_offset; + struct jdf_expr *expr; +} jdf_flow_specifier_t; +*/ + +flow_specifier: array_offset named_expr + { + jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); + f->array_offset = $1; + f->expr = $2; + $$ = f; + } + | + { + jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); + f->array_offset = NULL; + f->expr = NULL; + $$ = f; + } + ; + + +dataflow: optional_flow_flags VAR flow_specifier dependencies { for(jdf_global_entry_t* g = current_jdf.globals; g != NULL; g = g->next) { if( !strcmp(g->name, $2) ) { @@ -705,17 +733,19 @@ dataflow: optional_flow_flags VAR array_offset dependencies } } + jdf_flow_specifier_t *flow_specifier = $3; + jdf_dataflow_t *flow = new(jdf_dataflow_t); flow->flow_flags = $1; flow->varname = $2; - flow->array_offset = $3; + flow->array_offset = flow_specifier->array_offset; flow->deps = $4; $$ = flow; - if( NULL == $3) { + if( NULL == $4) { JDF_OBJECT_LINENO($$) = current_lineno; } else { - JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($3); + JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($4); } } ; @@ -743,14 +773,21 @@ named_expr_list: VAR ASSIGNMENT expr_range } ; +array_offset_or_nothing: array_offset + { + $$ = $1; + } + | { $$ = NULL; } + ; + array_offset: PROPERTIES_ON expr_simple PROPERTIES_OFF { $$ = $2; } - | + /*| { $$ = NULL; - } + }*/ ; dependencies: dependency dependencies @@ -929,7 +966,7 @@ call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR assert( 0 != JDF_OBJECT_LINENO($$) ); named_expr_pop_scope(); } - | VAR array_offset OPEN_PAR expr_list_range CLOSE_PAR + | VAR array_offset_or_nothing OPEN_PAR expr_list_range CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); From 0041cd8e9d40e7b69ae53cfbee0ae6f10a42defb Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 6 Oct 2022 12:49:24 -0400 Subject: [PATCH 005/157] bug fix --- parsec/interfaces/ptg/ptg-compiler/parsec.y | 3 +++ 1 file changed, 3 insertions(+) diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 271b11d5a..25d9056c8 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -706,12 +706,15 @@ typedef struct jdf_flow_specifier { } jdf_flow_specifier_t; */ + flow_specifier: array_offset named_expr { jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); f->array_offset = $1; f->expr = $2; $$ = f; + + named_expr_pop_scope(); } | { From dd01e398ff9aa5025672cf9a837c99a9c51528aa Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 6 Oct 2022 13:23:26 -0400 Subject: [PATCH 006/157] base syntax parametrized flows --- parsec/interfaces/ptg/ptg-compiler/parsec.y | 22 ++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 25d9056c8..f03dfa1d2 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -956,35 +956,35 @@ guarded_call: call } ; -call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR +call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_range CLOSE_PAR { jdf_call_t *c = new(jdf_call_t); c->var = $2; - c->array_offset = NULL; + c->array_offset = $3; c->local_defs = $1; - c->func_or_mem = $3; - c->parameters = $5; + c->func_or_mem = $4; + c->parameters = $6; $$ = c; - JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($5); + JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($6); assert( 0 != JDF_OBJECT_LINENO($$) ); named_expr_pop_scope(); } - | VAR array_offset_or_nothing OPEN_PAR expr_list_range CLOSE_PAR + | VAR OPEN_PAR expr_list_range CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); int nbparams; c->var = NULL; - c->array_offset = $2; + c->array_offset = NULL; c->func_or_mem = $1; - c->parameters = $4; + c->parameters = $3; c->local_defs = NULL; - JDF_OBJECT_LINENO(c) = JDF_OBJECT_LINENO($4); + JDF_OBJECT_LINENO(c) = JDF_OBJECT_LINENO($3); $$ = c; assert( 0 != JDF_OBJECT_LINENO($$) ); data = jdf_find_or_create_data(¤t_jdf, $1); - JDF_COUNT_LIST_ENTRIES($4, jdf_expr_t, next, nbparams); + JDF_COUNT_LIST_ENTRIES($3, jdf_expr_t, next, nbparams); if( data->nbparams != -1 ) { if( data->nbparams != nbparams ) { jdf_fatal(current_lineno, "Data %s used with %d parameters at line %d while used with %d parameters line %d\n", @@ -994,7 +994,7 @@ call: named_expr VAR VAR OPEN_PAR expr_list_range CLOSE_PAR } else { data->nbparams = nbparams; } - JDF_OBJECT_LINENO(data) = JDF_OBJECT_LINENO($4); + JDF_OBJECT_LINENO(data) = JDF_OBJECT_LINENO($3); } | DATA_NEW { From 89b617cd43270f56d7c5ea4b377ee50c391645ac Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 7 Oct 2022 14:42:35 -0400 Subject: [PATCH 007/157] remove comment --- parsec/interfaces/ptg/ptg-compiler/parsec.y | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index f03dfa1d2..b5c7ad6c3 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -698,20 +698,12 @@ optional_flow_flags : | { $$ = JDF_FLOW_TYPE_READ | JDF_FLOW_TYPE_WRITE; } ; -/* -typedef struct jdf_flow_specifier { - struct jdf_object_t super; - struct jdf_expr *array_offset; - struct jdf_expr *expr; -} jdf_flow_specifier_t; -*/ - -flow_specifier: array_offset named_expr +flow_specifier: array_offset { named_expr_push_scope(); } named_expr { jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); f->array_offset = $1; - f->expr = $2; + f->expr = $3; $$ = f; named_expr_pop_scope(); @@ -736,6 +728,18 @@ dataflow: optional_flow_flags VAR flow_specifier dependencies } } +/* +jdf_dep_t *d = new(jdf_dep_t); + jdf_expr_t *expr; + jdf_expr_t *expr_remote; + jdf_expr_t *expr_data; + jdf_def_list_t* property = $4; + jdf_def_list_t* property_remote = $4; + jdf_def_list_t* property_data = $4; + + d->local_defs = $2; +*/ + jdf_flow_specifier_t *flow_specifier = $3; jdf_dataflow_t *flow = new(jdf_dataflow_t); From e8f140408eabc93c1d53bc1344504ecc656fc646 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 10 Oct 2022 16:08:18 -0400 Subject: [PATCH 008/157] add flow-local variables to the flow structure --- parsec/interfaces/ptg/ptg-compiler/jdf.c | 17 +- parsec/interfaces/ptg/ptg-compiler/jdf.h | 1 + parsec/interfaces/ptg/ptg-compiler/parsec.y | 269 +++++++++++++++++++- 3 files changed, 280 insertions(+), 7 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.c b/parsec/interfaces/ptg/ptg-compiler/jdf.c index 913da894f..801cce04a 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.c @@ -1733,7 +1733,7 @@ int jdf_function_property_is_keyword(const char *name) int jdf_assign_ldef_index(jdf_function_entry_t *f) { - int nb_ldef_for_locals, nb_ldef_for_deps, nb_ldef_for_calls = 0; + int nb_ldef_for_locals, nb_ldef_for_deps, nb_ldef_for_flows, nb_ldef_for_calls = 0; jdf_expr_t *ld; jdf_variable_list_t *vl; jdf_dataflow_t *fl; @@ -1762,9 +1762,21 @@ int jdf_assign_ldef_index(jdf_function_entry_t *f) nb_ldef_for_locals = f->nb_max_local_def; for(fl = f->dataflow; NULL != fl; fl = fl->next) { + + + nb_ldef_for_flows = nb_ldef_for_locals; + for(ld = fl->local_variables; NULL != ld; ld = ld->next) { + assert(NULL != ld->alias); + if( ld->ldef_index == -1 ) { + ld->ldef_index = nb_ldef_for_flows; + nb_ldef_for_flows++; + DO_DEBUG_VERBOSE(2, ({ fprintf(stderr, " Flow for %s, flow %p: ldef %s is at %d\n", fl->varname, fl, ld->alias, ld->ldef_index); }) ); // TODO check + } + } + int depi = 0; for(dep = fl->deps; NULL != dep; dep = dep->next, depi++) { - nb_ldef_for_deps = nb_ldef_for_locals; + nb_ldef_for_deps = nb_ldef_for_flows; for(ld = dep->local_defs; NULL != ld; ld = ld->next) { assert(NULL != ld->alias); if( ld->ldef_index == -1 ) { @@ -1773,6 +1785,7 @@ int jdf_assign_ldef_index(jdf_function_entry_t *f) DO_DEBUG_VERBOSE(2, ({ fprintf(stderr, " Flow for %s, dep %d: ldef %s is at %d\n", fl->varname, depi, ld->alias, ld->ldef_index); }) ); } } + switch( dep->guard->guard_type ) { case JDF_GUARD_UNCONDITIONAL: case JDF_GUARD_BINARY: diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.h b/parsec/interfaces/ptg/ptg-compiler/jdf.h index 8733414ac..58b712f8b 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.h @@ -289,6 +289,7 @@ struct jdf_dataflow { struct jdf_object_t super; jdf_flow_flags_t flow_flags; jdf_dataflow_t *next; + struct jdf_expr *local_variables; /**< flows can specify a range */ char *varname; struct jdf_expr *array_offset; struct jdf_dep *deps; diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index b5c7ad6c3..69b37768d 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -115,6 +115,216 @@ jdf_create_properties_list( const char* name, return property; } + +// // used structures: +// struct jdf_dep { +// struct jdf_object_t super; +// jdf_dep_t *next; +// struct jdf_expr *local_defs; /**< named ranges can specify sets of deps from this single dep */ +// struct jdf_guarded_call *guard; /**< there can be conditions and ternaries to produce the calls */ +// jdf_datatransfer_type_t datatype_local; /**< type reshaping */ +// jdf_datatransfer_type_t datatype_remote; /**< type for packing & sending to a remote */ +// jdf_datatransfer_type_t datatype_data; /**< type applied to the data collection when reading or writing */ +// jdf_dep_flags_t dep_flags; /**< flags (see JDF_DEP_* above) */ +// uint8_t dep_index; /**< the index of the dependency in the context of the function */ +// uint8_t dep_datatype_index; /**< the smallest index of all dependencies +// * sharing a common remote datatype. */ +// }; + +// typedef enum { JDF_GUARD_UNCONDITIONAL, +// JDF_GUARD_BINARY, +// JDF_GUARD_TERNARY } jdf_guard_type_t; + +// typedef struct jdf_guarded_call { +// struct jdf_object_t super; +// jdf_guard_type_t guard_type; +// struct jdf_expr *guard; +// struct jdf_def_list *properties; +// struct jdf_call *calltrue; +// struct jdf_call *callfalse; +// } jdf_guarded_call_t; + +// typedef struct jdf_call { +// struct jdf_object_t super; +// struct jdf_expr *local_defs; /**< Each call can have some local indicies, allowing to define sets of deps */ +// char *var; /**< If func_or_mem is a function, var is the name of the flow on that function */ +// struct jdf_expr *array_offset; /**< Offset required if var is an array */ +// char *func_or_mem; /**< string of the function (task class) or data collection referred to in this call */ +// struct jdf_expr *parameters; /**< list of parameters for that task class / data collection */ +// } jdf_call_t; + + +// typedef enum { JDF_EQUAL, +// JDF_NOTEQUAL, +// JDF_AND, +// JDF_OR, +// JDF_XOR, +// JDF_LESS, +// JDF_LEQ, +// JDF_MORE, +// JDF_MEQ, +// JDF_NOT, +// JDF_PLUS, +// JDF_MINUS, +// JDF_TIMES, +// JDF_DIV, +// JDF_MODULO, +// JDF_SHL, +// JDF_SHR, +// JDF_RANGE, +// JDF_TERNARY, +// JDF_VAR, +// JDF_STRING, +// JDF_CST, +// JDF_C_CODE +// } jdf_expr_operand_t; + +// #define JDF_OP_IS_UNARY(op) ( (op) == JDF_NOT ) +// #define JDF_OP_IS_TERNARY(op) ( (op) == JDF_TERNARY ) +// #define JDF_OP_IS_CST(op) ( (op) == JDF_CST ) +// #define JDF_OP_IS_STRING(op) ( (op) == JDF_STRING ) +// #define JDF_OP_IS_VAR(op) ( (op) == JDF_VAR ) +// #define JDF_OP_IS_C_CODE(op) ( (op) == JDF_C_CODE ) +// #define JDF_OP_IS_BINARY(op) ( !( JDF_OP_IS_UNARY(op) || \ +// JDF_OP_IS_TERNARY(op) || \ +// JDF_OP_IS_CST(op) || \ +// JDF_OP_IS_VAR(op) || \ +// JDF_OP_IS_C_CODE(op)) ) + +// typedef struct jdf_expr { +// struct jdf_object_t super; +// struct jdf_expr *next; +// struct jdf_expr *next_inline; +// struct jdf_expr *local_variables; /**< the list of named local variables that are defined with +// * a named range and are used to define this expression */ +// jdf_expr_operand_t op; +// char *protected_by; /**< if non NULL the function definition if protected by this #define */ +// char *alias; /**< if alias != NULL, this expression defines a local variable named alias */ +// int ldef_index; /**< if alias != NULL, the local variable is stored in ldef[ldef_index] */ +// int scope; /**< if alias != NULL, scope is the scope of that definition +// * (this is used internally by the parser to compute how many definitions to +// * remove; this is not used outside the parser) */ +// union { +// struct { +// struct jdf_expr *arg1; +// struct jdf_expr *arg2; +// struct jdf_expr *arg3; +// } ternary; +// struct { +// struct jdf_expr *arg1; +// struct jdf_expr *arg2; +// } binary; +// struct { +// struct jdf_expr *arg; +// } unary; +// char *varname; +// struct { +// int type; +// union{ +// struct { +// char *code; +// int lineno; +// char *fname; +// jdf_function_entry_t *function_context; +// } c_code; +// int32_t int32_cstval; +// int64_t int64_cstval; +// float float_cstval; +// double double_cstval; +// } w; +// } v; +// } u; +// } jdf_expr_t; + +/* +static void add_local_to_expr(jdf_expr_t *expr, jdf_expr_t *local) +{ + if(expr->) +} +*/ + +static void add_local_to_call( jdf_call_t *call, jdf_expr_t *local ) +{ + jdf_expr_t *l = call->local_defs; + + jdf_expr_t *newdef = new(jdf_expr_t); + memcpy( newdef, local, sizeof(jdf_expr_t) ); + newdef->next = call->local_defs; + call->local_defs = newdef; + + printf( "Adding local %s to call %s\n", local->alias, call->func_or_mem ); + + //add_local_to_expr( call->parameters, local ); +} + +static void add_local_to_guarded_call(jdf_guarded_call_t *call, jdf_expr_t *variable) +{ + jdf_expr_t *e; + jdf_def_list_t *def; + + if(call->guard_type == JDF_GUARD_UNCONDITIONAL) { + add_local_to_call(call->calltrue, variable); +/* + jdf_expr_t *newdef = new(jdf_expr_t); + newdef->op = JDF_VAR; + newdef->u.varname = strdup(variable->alias); + newdef->next = call->local_defs; + call->local_defs = newdef; +*/ + } + else if(call->guard_type == JDF_GUARD_BINARY) { + add_local_to_call(call->calltrue, variable); + //add_local_to_call(call->callfalse, variable); + } + else if(call->guard_type == JDF_GUARD_TERNARY) { + add_local_to_call(call->calltrue, variable); + add_local_to_call(call->callfalse, variable); + } + + printf("Adding local %s to guarded call %s\n", variable->alias, call->calltrue->func_or_mem); +} + +static void add_locals_to_dep(jdf_dep_t *dep, jdf_expr_t *variables) +{ +/* +// each variable that is defined in the dataflow: + while( dataflow_defs != NULL ) { + jdf_def_list_t *newdef = new(jdf_def_list_t); + newdef->name = strdup(dataflow_defs->alias); + printf("added def %s to flow %s\n", newdef->name, flow->varname); + newdef->next = def; + def = newdef; + dataflow_defs = dataflow_defs->next; + } + + dep->local_defs = def; +*/ + + + jdf_expr_t *v; + + // for each variable to add + for(v = variables; NULL != v; v = v->next) { + jdf_expr_t *def = dep->local_defs; + + // add the current local to te guarded call + add_local_to_guarded_call(dep->guard, v); + + // then inside the dep structure + jdf_expr_t *newdef = new(jdf_expr_t); + memcpy( newdef, v, sizeof(jdf_expr_t) ); + newdef->next = dep->local_defs; + dep->local_defs = newdef; + + printf( "Adding local %s to dep %p\n", v->alias, dep ); + + /*newdef->op = JDF_VAR; + newdef->u.v.varname = strdup(v->alias); + newdef->next = def; + dep->local_defs = newdef;*/ + } +} + static jdf_data_entry_t* jdf_find_or_create_data(jdf_t* jdf, const char* dname) { jdf_data_entry_t* data = jdf->data; @@ -578,6 +788,11 @@ function: VAR OPEN_PAR param_list CLOSE_PAR properties local_variables sim e->priority = $10; e->bodies = $11; +/* + for(jdf_expr_t *el = e->locals; NULL != el; el = el->next) { + printf("%s has a local named %s\n", e->fname, el->jdf_var); + }*/ + jdf_link_params_and_locals(e); /* link params and locals */ jdf_assign_ldef_index(e); /* find the datatype indexes */ @@ -698,15 +913,22 @@ optional_flow_flags : | { $$ = JDF_FLOW_TYPE_READ | JDF_FLOW_TYPE_WRITE; } ; +/* +PROPERTIES_ON { named_expr_push_scope(); } named_expr_list PROPERTIES_OFF expr_simple + { + $$ = $5; + named_expr_pop_scope(); + } +*/ -flow_specifier: array_offset { named_expr_push_scope(); } named_expr +flow_specifier: array_offset PROPERTIES_ON { named_expr_push_scope(); } named_expr_list PROPERTIES_OFF { jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); f->array_offset = $1; - f->expr = $3; + f->expr = $4; $$ = f; - named_expr_pop_scope(); + //named_expr_pop_scope(); } | { @@ -714,11 +936,15 @@ flow_specifier: array_offset { named_expr_push_scope(); } named_expr f->array_offset = NULL; f->expr = NULL; $$ = f; + + /* We still create a new scope for the (inexisting) named range + * as the scope will be popped unconditionally */ + named_expr_push_scope(); + //named_expr_pop_scope(); } ; - -dataflow: optional_flow_flags VAR flow_specifier dependencies +dataflow: optional_flow_flags VAR flow_specifier dependencies { named_expr_pop_scope(); } { for(jdf_global_entry_t* g = current_jdf.globals; g != NULL; g = g->next) { if( !strcmp(g->name, $2) ) { @@ -740,14 +966,47 @@ jdf_dep_t *d = new(jdf_dep_t); d->local_defs = $2; */ +/* +property: VAR ASSIGNMENT expr_simple + { + jdf_def_list_t* assign = new(jdf_def_list_t); + assign->next = NULL; + assign->name = strdup($1); + assign->expr = $3; + JDF_OBJECT_LINENO(assign) = JDF_OBJECT_LINENO($3); + $$ = assign; + } +*/ + jdf_flow_specifier_t *flow_specifier = $3; jdf_dataflow_t *flow = new(jdf_dataflow_t); flow->flow_flags = $1; flow->varname = $2; + flow->local_variables = flow_specifier->expr; flow->array_offset = flow_specifier->array_offset; flow->deps = $4; +/* + // add the dataflow bound variables to each part of each dependency + for(jdf_dep_t *dep = flow->deps; dep != NULL; dep = dep->next) { + jdf_def_list_t *def = dep->local_defs; + + // variables defined in the whole dataflow + jdf_expr_t *dataflow_defs = flow_specifier->expr; + + // add them to the current dependency + add_locals_to_dep(dep, dataflow_defs); + } +*/ + +/* + // add the dataflow bound variables to each dependency + for(jdf_dep_t *dep = flow->deps; dep != NULL; dep = dep->next) { + add_defs_to_flow(flow, flow_specifier->expr); + } +*/ + $$ = flow; if( NULL == $4) { JDF_OBJECT_LINENO($$) = current_lineno; From d082f822fbdf7deefbd3a8cd0f6542d5048fd6a7 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 11 Oct 2022 14:14:16 -0400 Subject: [PATCH 009/157] checkpoint --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 111 ++++++++++++++++----- 1 file changed, 88 insertions(+), 23 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index fd53cd3ca..c6bde6adc 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -756,29 +756,44 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) string_arena_init(sa); - expr_info_t expr_info = EMPTY_EXPR_INFO; + if(f->array_offset != NULL) + { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(8); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "parametrized flow range"; - expr_info.sa = sa; - expr_info.prefix = ""; - expr_info.suffix = ""; - /*if(f->array_offset != NULL) - { - string_arena_add_string(sa, " for(int i=0;i<("); - dump_expr((void**)f->array_offset, &expr_info); - - string_arena_add_string(sa, ");++i) {\n"); - }*/ - string_arena_add_string(sa, - " parsec_data_copy_t *_f_%s = this_task->data._f_%s.data_%s;\n", - varname, f->varname, where); - string_arena_add_string(sa, - " void *%s = PARSEC_DATA_COPY_GET_PTR(_f_%s); (void)%s;\n", - varname, varname, varname); - /*if(f->array_offset != NULL) - { + string_arena_add_string(sa, + " parsec_data_copy_t *_f_%s[(%s)];\n", + varname, dump_expr((void**)f->array_offset, &expr_info), varname); + string_arena_add_string(sa, + " void *%s[(%s)]; (void)%s;\n", + varname, dump_expr((void**)f->array_offset, &expr_info), varname); // TODO dump range instead of expr ... + + string_arena_add_string(sa, " /** Get data of parametrized flow's data %s */\n", varname); + string_arena_add_string(sa, " for(int i=0;i<(%s);++i) {\n", dump_expr((void**)f->array_offset, &expr_info)); + + + string_arena_add_string(sa, + " _f_%s[i] = this_task->data._f_%s.data_%s;\n", + varname, f->varname, where); + string_arena_add_string(sa, + " %s[i] = PARSEC_DATA_COPY_GET_PTR(_f_%s[i]); (void)%s;\n", + varname, varname, varname); string_arena_add_string(sa, " }\n"); - }*/ + } + else + { + string_arena_add_string(sa, + " parsec_data_copy_t *_f_%s = this_task->data._f_%s.data_%s;\n", + varname, f->varname, where); + string_arena_add_string(sa, + " void *%s = PARSEC_DATA_COPY_GET_PTR(_f_%s); (void)%s;\n", + varname, varname, varname); + } + return string_arena_get_string(sa); } @@ -1489,6 +1504,12 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) coutput("/** Predeclarations of the parameters */\n"); for(f = jdf->functions; f != NULL; f = f->next) { for(fl = f->dataflow; fl != NULL; fl = fl->next) { + /* + if(f->dataflow->local_variables != NULL) + { + rc = asprintf(&JDF_OBJECT_ONAME( fl ), "parametrized_"); + } + */ rc = asprintf(&JDF_OBJECT_ONAME( fl ), "flow_of_%s_%s_for_%s", jdf_basename, f->fname, fl->varname); assert(rc != -1); coutput("static const parsec_flow_t %s;\n", @@ -6173,9 +6194,53 @@ static void jdf_generate_code_cache_awareness_update(const jdf_t *jdf, const jdf sa = string_arena_new(64); (void)jdf; - UTIL_DUMP_LIST(sa, f->dataflow, next, - dump_dataflow_varname, NULL, - "", " cache_buf_referenced(es->closest_cache, ", ");\n", ""); + // if(f->dataflow && f->dataflow->array_offset != NULL) + // { + // expr_info_t expr_info = EMPTY_EXPR_INFO; + // expr_info.sa = string_arena_new(8); + // expr_info.prefix = ""; + // expr_info.suffix = ""; + // expr_info.assignments = "parametrized flow range"; + + // string_arena_add_string(sa, " for(int i=0;i<(%s);++i) {\n", dump_expr((void**)f->dataflow->array_offset, &expr_info)); + // /*UTIL_DUMP_LIST(sa, f->dataflow, next, + // dump_dataflow_varname, NULL, + // "", " cache_buf_referenced(es->closest_cache, ", "[i]);\n }\n", "");*/ + + // // add cache_buf_referenced for all the dataflow variables + // jdf_dataflow_t *df; + // for(df = f->dataflow; df != NULL; df = df->next) { + // string_arena_add_string(sa, " cache_buf_referenced(es->closest_cache, %s[i]);\n", df->varname); + // } + + // string_arena_add_string(sa, " }\n"); + // } + // else + // { + // UTIL_DUMP_LIST(sa, f->dataflow, next, + // dump_dataflow_varname, NULL, + // "", " cache_buf_referenced(es->closest_cache, ", ");\n", ""); + // } + + for(jdf_dataflow_t *df = f->dataflow; df != NULL; df = df->next) { + if(df->array_offset != NULL) + { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(8); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "parametrized flow range"; + + string_arena_add_string(sa, " for(int i=0;i<(%s);++i) {\n", dump_expr((void**)df->array_offset, &expr_info)); + string_arena_add_string(sa, " cache_buf_referenced(es->closest_cache, %s[i]);\n", df->varname); + string_arena_add_string(sa, " }\n"); + } + else + { + string_arena_add_string(sa, " cache_buf_referenced(es->closest_cache, %s);\n", df->varname); + } + } + if( strlen(string_arena_get_string(sa)) ) { coutput(" /** Cache Awareness Accounting */\n" "#if defined(PARSEC_CACHE_AWARENESS)\n" From 611477276bcc5b8e15bf04cc697967e5407911a4 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 11 Oct 2022 15:21:38 -0400 Subject: [PATCH 010/157] proper iterator for initialization --- parsec/interfaces/ptg/ptg-compiler/jdf.h | 2 +- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 49 +++++++++++++++++---- parsec/interfaces/ptg/ptg-compiler/parsec.y | 6 +-- 3 files changed, 44 insertions(+), 13 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.h b/parsec/interfaces/ptg/ptg-compiler/jdf.h index 58b712f8b..f8af76d8b 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.h @@ -271,7 +271,7 @@ typedef struct jdf_def_list { typedef struct jdf_flow_specifier { struct jdf_object_t super; struct jdf_expr *array_offset; - struct jdf_expr *expr; + struct jdf_expr *variables; } jdf_flow_specifier_t; typedef struct jdf_dataflow jdf_dataflow_t; diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index c6bde6adc..dfa6b8976 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -766,22 +766,53 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) string_arena_add_string(sa, - " parsec_data_copy_t *_f_%s[(%s)];\n", - varname, dump_expr((void**)f->array_offset, &expr_info), varname); + " parsec_data_copy_t *_f_%s[(%s)+1];\n", + varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info), varname); string_arena_add_string(sa, - " void *%s[(%s)]; (void)%s;\n", - varname, dump_expr((void**)f->array_offset, &expr_info), varname); // TODO dump range instead of expr ... + " void *%s[(%s)+1]; (void)%s;\n", + varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info), varname); + + // Generate the ranges + jdf_expr_t *variable=f->local_variables; + if(NULL != variable) { + if(variable->op == JDF_RANGE) { + jdf_expr_t *from = variable->jdf_ta1; + jdf_expr_t *to = variable->jdf_ta2; + jdf_expr_t *step = variable->jdf_ta3; + + string_arena_add_string(sa, " for(int %s=%s;", + variable->alias, + dump_expr((void**)from, &expr_info)); + string_arena_add_string(sa, "%s<=%s;", + variable->alias, + dump_expr((void**)to, &expr_info)); + string_arena_add_string(sa, "%s+=%s) {\n", + variable->alias, + dump_expr((void**)step, &expr_info)); + } + else + { + jdf_fatal(JDF_OBJECT_LINENO(f), "The flow variable is not a range\n"); + } - string_arena_add_string(sa, " /** Get data of parametrized flow's data %s */\n", varname); - string_arena_add_string(sa, " for(int i=0;i<(%s);++i) {\n", dump_expr((void**)f->array_offset, &expr_info)); + if(variable->next != NULL) + { + jdf_fatal(JDF_OBJECT_LINENO(f), "Parametrized flows can not handle more than one variable\n"); + } + } + else + { + jdf_fatal(JDF_OBJECT_LINENO(f), "Parametrized flows must have a variable\n"); + } string_arena_add_string(sa, - " _f_%s[i] = this_task->data._f_%s.data_%s;\n", - varname, f->varname, where); + " _f_%s[%s] = this_task->data._f_%s.data_%s;\n", + varname, variable->alias, f->varname, where); string_arena_add_string(sa, " %s[i] = PARSEC_DATA_COPY_GET_PTR(_f_%s[i]); (void)%s;\n", - varname, varname, varname); + varname, variable->alias, varname, varname); + string_arena_add_string(sa, " }\n"); } else diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 69b37768d..46945d16a 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -925,7 +925,7 @@ flow_specifier: array_offset PROPERTIES_ON { named_expr_push_scope(); } named_ex { jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); f->array_offset = $1; - f->expr = $4; + f->variables = $4; $$ = f; //named_expr_pop_scope(); @@ -934,7 +934,7 @@ flow_specifier: array_offset PROPERTIES_ON { named_expr_push_scope(); } named_ex { jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); f->array_offset = NULL; - f->expr = NULL; + f->variables = NULL; $$ = f; /* We still create a new scope for the (inexisting) named range @@ -983,7 +983,7 @@ property: VAR ASSIGNMENT expr_simple jdf_dataflow_t *flow = new(jdf_dataflow_t); flow->flow_flags = $1; flow->varname = $2; - flow->local_variables = flow_specifier->expr; + flow->local_variables = flow_specifier->variables; flow->array_offset = flow_specifier->array_offset; flow->deps = $4; From 2b0963441aac418d8b6515c05062197faff75d29 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 11 Oct 2022 16:23:43 -0400 Subject: [PATCH 011/157] generate parametrized for loop in a dump function --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 103 +++++++++++++-------- 1 file changed, 64 insertions(+), 39 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index dfa6b8976..7979df18d 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -579,6 +579,63 @@ char * dump_expr(void **elem, void *arg) return string_arena_get_string(sa); } +/** + * dump_parametrized_flow_loop: + * dumps the jdf_expr* pointed to by elem into arg->sa, prefixing each + * non-global variable with arg->prefix + */ +char * dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_name, void *arg) +{ + //expr_info_t* expr_info = (expr_info_t*)arg; + jdf_dataflow_t *f = (jdf_dataflow_t*)flow; + string_arena_t *sa = arg; + + if(f == NULL ) return "NULL"; + //string_arena_init(sa); + + // Generate the ranges + jdf_expr_t *variable=f->local_variables; + if(NULL != variable) { + if(variable->op == JDF_RANGE) { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "parametrized flow range"; + + jdf_expr_t *from = variable->jdf_ta1; + jdf_expr_t *to = variable->jdf_ta2; + jdf_expr_t *step = variable->jdf_ta3; + + string_arena_add_string(sa, " for(int %s=%s;", + iterator_name, + dump_expr((void**)from, &expr_info)); + string_arena_add_string(sa, "%s<=%s;", + iterator_name, + dump_expr((void**)to, &expr_info)); + string_arena_add_string(sa, "%s+=%s) {\n", + iterator_name, + dump_expr((void**)step, &expr_info)); + } + else + { + jdf_fatal(JDF_OBJECT_LINENO(f), "The flow variable is not a range\n"); + } + + + if(variable->next != NULL) + { + jdf_fatal(JDF_OBJECT_LINENO(f), "Parametrized flows can not handle more than one variable\n"); + } + } + else + { + jdf_fatal(JDF_OBJECT_LINENO(f), "Parametrized flows must have a variable\n"); + } + + return string_arena_get_string(sa); +} + /** * Dump a predicate like * #define F_pred(k, n, m) (__parsec_tp->ABC->rank == __parsec_tp->ABC->rank_of(__parsec_tp->ABC, k, n, m)) @@ -759,7 +816,7 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) if(f->array_offset != NULL) { expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(8); + expr_info.sa = string_arena_new(256); expr_info.prefix = ""; expr_info.suffix = ""; expr_info.assignments = "parametrized flow range"; @@ -767,51 +824,19 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) string_arena_add_string(sa, " parsec_data_copy_t *_f_%s[(%s)+1];\n", - varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info), varname); + varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info)); string_arena_add_string(sa, " void *%s[(%s)+1]; (void)%s;\n", varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info), varname); - - // Generate the ranges - jdf_expr_t *variable=f->local_variables; - if(NULL != variable) { - if(variable->op == JDF_RANGE) { - jdf_expr_t *from = variable->jdf_ta1; - jdf_expr_t *to = variable->jdf_ta2; - jdf_expr_t *step = variable->jdf_ta3; - - string_arena_add_string(sa, " for(int %s=%s;", - variable->alias, - dump_expr((void**)from, &expr_info)); - string_arena_add_string(sa, "%s<=%s;", - variable->alias, - dump_expr((void**)to, &expr_info)); - string_arena_add_string(sa, "%s+=%s) {\n", - variable->alias, - dump_expr((void**)step, &expr_info)); - } - else - { - jdf_fatal(JDF_OBJECT_LINENO(f), "The flow variable is not a range\n"); - } - - - if(variable->next != NULL) - { - jdf_fatal(JDF_OBJECT_LINENO(f), "Parametrized flows can not handle more than one variable\n"); - } - } - else - { - jdf_fatal(JDF_OBJECT_LINENO(f), "Parametrized flows must have a variable\n"); - } +// + dump_parametrized_flow_loop(f, f->local_variables->alias, sa); string_arena_add_string(sa, " _f_%s[%s] = this_task->data._f_%s.data_%s;\n", - varname, variable->alias, f->varname, where); + varname, f->local_variables->alias, f->varname, where); string_arena_add_string(sa, - " %s[i] = PARSEC_DATA_COPY_GET_PTR(_f_%s[i]); (void)%s;\n", - varname, variable->alias, varname, varname); + " %s[i] = PARSEC_DATA_COPY_GET_PTR(_f_%s[%s]); (void)%s;\n", + varname, varname, f->local_variables->alias, varname); string_arena_add_string(sa, " }\n"); } From ebf18311c0f73c5fad983224417ca183a3656086 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 11 Oct 2022 16:55:40 -0400 Subject: [PATCH 012/157] correct initialization and cache_buf_referenced --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 7979df18d..76ec671f6 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -835,8 +835,8 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) " _f_%s[%s] = this_task->data._f_%s.data_%s;\n", varname, f->local_variables->alias, f->varname, where); string_arena_add_string(sa, - " %s[i] = PARSEC_DATA_COPY_GET_PTR(_f_%s[%s]); (void)%s;\n", - varname, varname, f->local_variables->alias, varname); + " %s[%s] = PARSEC_DATA_COPY_GET_PTR(_f_%s[%s]); (void)%s;\n", + varname, f->local_variables->alias, varname, f->local_variables->alias, varname); string_arena_add_string(sa, " }\n"); } @@ -6287,8 +6287,8 @@ static void jdf_generate_code_cache_awareness_update(const jdf_t *jdf, const jdf expr_info.suffix = ""; expr_info.assignments = "parametrized flow range"; - string_arena_add_string(sa, " for(int i=0;i<(%s);++i) {\n", dump_expr((void**)df->array_offset, &expr_info)); - string_arena_add_string(sa, " cache_buf_referenced(es->closest_cache, %s[i]);\n", df->varname); + dump_parametrized_flow_loop(df, df->local_variables->alias, sa); + string_arena_add_string(sa, " cache_buf_referenced(es->closest_cache, %s[%s]);\n", df->varname, df->local_variables->alias); string_arena_add_string(sa, " }\n"); } else From 80edc32b70bf8f076d89d7a078d84850e551af45 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 11 Oct 2022 17:57:55 -0400 Subject: [PATCH 013/157] parsec_data_transfer_ownership_to_copy --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 31 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 76ec671f6..423be6212 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -584,7 +584,7 @@ char * dump_expr(void **elem, void *arg) * dumps the jdf_expr* pointed to by elem into arg->sa, prefixing each * non-global variable with arg->prefix */ -char * dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_name, void *arg) +void dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_name, void *arg) { //expr_info_t* expr_info = (expr_info_t*)arg; jdf_dataflow_t *f = (jdf_dataflow_t*)flow; @@ -632,8 +632,6 @@ char * dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_na { jdf_fatal(JDF_OBJECT_LINENO(f), "Parametrized flows must have a variable\n"); } - - return string_arena_get_string(sa); } /** @@ -7149,7 +7147,30 @@ static void jdf_generate_code_hook(const jdf_t *jdf, /* Applied only on the Write data, since the number of readers is not atomically increased yet */ if ((fl->flow_flags & JDF_FLOW_TYPE_READ) && (fl->flow_flags & JDF_FLOW_TYPE_WRITE) ) { - coutput(" if ( NULL != _f_%s ) {\n" + + if(fl->local_variables != NULL) { + string_arena_t *sa = string_arena_new(64); + dump_parametrized_flow_loop(fl, fl->local_variables->alias, sa); + coutput("%s", string_arena_get_string(sa)); + + coutput(" if ( NULL != _f_%s[%s] ) {\n" + " parsec_data_transfer_ownership_to_copy( _f_%s[%s]->original, 0 /* device */,\n" + " %s);\n" + " }\n", + fl->varname, + fl->local_variables->alias, + fl->varname, + fl->local_variables->alias, + ((fl->flow_flags & JDF_FLOW_TYPE_CTL) ? "PARSEC_FLOW_ACCESS_NONE" : + ((fl->flow_flags & JDF_FLOW_TYPE_READ) ? + ((fl->flow_flags & JDF_FLOW_TYPE_WRITE) ? "PARSEC_FLOW_ACCESS_RW" : "PARSEC_FLOW_ACCESS_READ") : "PARSEC_FLOW_ACCESS_WRITE"))); + + coutput(" }\n"); + } + else + { + + coutput(" if ( NULL != _f_%s ) {\n" " parsec_data_transfer_ownership_to_copy( _f_%s->original, 0 /* device */,\n" " %s);\n" " }\n", @@ -7158,6 +7179,8 @@ static void jdf_generate_code_hook(const jdf_t *jdf, ((fl->flow_flags & JDF_FLOW_TYPE_CTL) ? "PARSEC_FLOW_ACCESS_NONE" : ((fl->flow_flags & JDF_FLOW_TYPE_READ) ? ((fl->flow_flags & JDF_FLOW_TYPE_WRITE) ? "PARSEC_FLOW_ACCESS_RW" : "PARSEC_FLOW_ACCESS_READ") : "PARSEC_FLOW_ACCESS_WRITE"))); + + } } } coutput("#endif /* defined(PARSEC_HAVE_CUDA) */\n"); From 4940c6bd53b9c2538484c7e09a66c7f9a9ecd2d5 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 11 Oct 2022 22:01:09 -0400 Subject: [PATCH 014/157] partly fills the flow structure --- parsec/include/parsec/parsec_config_bottom.h | 3 + parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 80 +++++++++++++++----- 2 files changed, 65 insertions(+), 18 deletions(-) diff --git a/parsec/include/parsec/parsec_config_bottom.h b/parsec/include/parsec/parsec_config_bottom.h index 85a270913..0e73930e9 100644 --- a/parsec/include/parsec/parsec_config_bottom.h +++ b/parsec/include/parsec/parsec_config_bottom.h @@ -156,6 +156,9 @@ typedef int32_t parsec_dependency_t; * A set of constants defining the capabilities of the underlying * runtime. */ + +#define MAX_DATAFLOWS_PER_TASK 16 + #define MAX_LOCAL_COUNT 20 #define MAX_PARAM_COUNT 20 diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 423be6212..833b86357 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -584,14 +584,13 @@ char * dump_expr(void **elem, void *arg) * dumps the jdf_expr* pointed to by elem into arg->sa, prefixing each * non-global variable with arg->prefix */ -void dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_name, void *arg) +void dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_name, const char *indent, void *arg) { //expr_info_t* expr_info = (expr_info_t*)arg; jdf_dataflow_t *f = (jdf_dataflow_t*)flow; string_arena_t *sa = arg; - if(f == NULL ) return "NULL"; - //string_arena_init(sa); + if(f == NULL ) return; // Generate the ranges jdf_expr_t *variable=f->local_variables; @@ -607,7 +606,8 @@ void dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_name jdf_expr_t *to = variable->jdf_ta2; jdf_expr_t *step = variable->jdf_ta3; - string_arena_add_string(sa, " for(int %s=%s;", + string_arena_add_string(sa, "%sfor(int %s=%s;", + indent, iterator_name, dump_expr((void**)from, &expr_info)); string_arena_add_string(sa, "%s<=%s;", @@ -826,8 +826,8 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) string_arena_add_string(sa, " void *%s[(%s)+1]; (void)%s;\n", varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info), varname); -// - dump_parametrized_flow_loop(f, f->local_variables->alias, sa); + + dump_parametrized_flow_loop(f, f->local_variables->alias, " ", sa); string_arena_add_string(sa, " _f_%s[%s] = this_task->data._f_%s.data_%s;\n", @@ -1413,8 +1413,25 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) } JDF_COUNT_LIST_ENTRIES(f->dataflow, jdf_dataflow_t, next, nb_flows); + /* UTIL_DUMP_LIST_FIELD(sa_data, f->dataflow, next, varname, dump_string, NULL, "", " parsec_data_pair_t _f_", ";\n", ";\n"); + */ + // Add the list of data to sa_data without UTIL_DUMP_LIST_FIELD + { + jdf_dataflow_t *df; + for(df = f->dataflow; df != NULL; df = df->next) { + if( df->local_variables == NULL ) { + string_arena_add_string(sa_data, " parsec_data_pair_t _f_%s;\n", df->varname); + } + else + { // Parametrized flow + string_arena_add_string(sa_data, " parsec_data_pair_t _f_%s[MAX_DATAFLOWS_PER_TASK];\n", df->varname); + } + } + } + + string_arena_init(sa); /* Prepare the structure for the named assignments */ string_arena_add_string(sa, @@ -3228,16 +3245,43 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr { struct jdf_dataflow *dataflow = f->dataflow; for(idx = 0; NULL != dataflow; idx++, dataflow = dataflow->next ) { - coutput("%s new_task->data._f_%s.source_repo_entry = NULL;\n" - "%s new_task->data._f_%s.source_repo = NULL;\n" - "%s new_task->data._f_%s.data_in = NULL;\n" - "%s new_task->data._f_%s.data_out = NULL;\n" - "%s new_task->data._f_%s.fulfill = 0;\n", - indent(nesting), dataflow->varname, - indent(nesting), dataflow->varname, - indent(nesting), dataflow->varname, - indent(nesting), dataflow->varname, - indent(nesting), dataflow->varname); + + if(dataflow->local_variables == NULL) + { + coutput("%s new_task->data._f_%s.source_repo_entry = NULL;\n" + "%s new_task->data._f_%s.source_repo = NULL;\n" + "%s new_task->data._f_%s.data_in = NULL;\n" + "%s new_task->data._f_%s.data_out = NULL;\n" + "%s new_task->data._f_%s.fulfill = 0;\n", + indent(nesting), dataflow->varname, + indent(nesting), dataflow->varname, + indent(nesting), dataflow->varname, + indent(nesting), dataflow->varname, + indent(nesting), dataflow->varname); + } + else + { // Parametrized flow + nesting++; + + string_arena_t *sa = string_arena_new(64); + dump_parametrized_flow_loop(dataflow, dataflow->local_variables->alias, indent(nesting), sa); + coutput("%s", string_arena_get_string(sa)); + + coutput("%s new_task->data._f_%s[%s].source_repo_entry = NULL;\n" + "%s new_task->data._f_%s[%s].source_repo = NULL;\n" + "%s new_task->data._f_%s[%s].data_in = NULL;\n" + "%s new_task->data._f_%s[%s].data_out = NULL;\n" + "%s new_task->data._f_%s[%s].fulfill = 0;\n", + indent(nesting), dataflow->varname, dataflow->local_variables->alias, + indent(nesting), dataflow->varname, dataflow->local_variables->alias, + indent(nesting), dataflow->varname, dataflow->local_variables->alias, + indent(nesting), dataflow->varname, dataflow->local_variables->alias, + indent(nesting), dataflow->varname, dataflow->local_variables->alias); + + coutput("%s}\n", indent(nesting)); + + nesting--; + } } } @@ -6285,7 +6329,7 @@ static void jdf_generate_code_cache_awareness_update(const jdf_t *jdf, const jdf expr_info.suffix = ""; expr_info.assignments = "parametrized flow range"; - dump_parametrized_flow_loop(df, df->local_variables->alias, sa); + dump_parametrized_flow_loop(df, df->local_variables->alias, " ", sa); string_arena_add_string(sa, " cache_buf_referenced(es->closest_cache, %s[%s]);\n", df->varname, df->local_variables->alias); string_arena_add_string(sa, " }\n"); } @@ -7150,7 +7194,7 @@ static void jdf_generate_code_hook(const jdf_t *jdf, if(fl->local_variables != NULL) { string_arena_t *sa = string_arena_new(64); - dump_parametrized_flow_loop(fl, fl->local_variables->alias, sa); + dump_parametrized_flow_loop(fl, fl->local_variables->alias, " ", sa); coutput("%s", string_arena_get_string(sa)); coutput(" if ( NULL != _f_%s[%s] ) {\n" From 472b6a14f48ff049bb62c6f77b546f2af55aaf01 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 12 Oct 2022 10:58:05 -0400 Subject: [PATCH 015/157] allocate the parametrized data in jdf_generate_startup_tasks --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 833b86357..2e54f03ac 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1426,7 +1426,8 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) } else { // Parametrized flow - string_arena_add_string(sa_data, " parsec_data_pair_t _f_%s[MAX_DATAFLOWS_PER_TASK];\n", df->varname); + // Becomes an array of data pairs + string_arena_add_string(sa_data, " parsec_data_pair_t *_f_%s;\n", df->varname); } } } @@ -3111,6 +3112,28 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr fname, parsec_get_name(jdf, f, "task_t"), parsec_get_name(jdf, f, "task_t"), jdf_basename, jdf_basename); + + + // Generate the code to initialize the parametrized flow variables + for(jdf_dataflow_t *fl=f->dataflow; NULL != fl; fl=fl->next) { + if( NULL != fl->local_variables ) { // If is parametrized + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(32); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "max parametrized dataflow"; + + jdf_expr_t *variable = jdf_expr_lv_first(fl->local_variables); + assert(variable->op == JDF_RANGE); + jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; + + coutput(" this_task->data._f_%s = alloca(sizeof(parsec_data_pair_t)*((%s)+1));\n", + fl->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); + coutput(" assert( NULL != this_task->data._f_%s );\n", fl->varname); + coutput(" memset(this_task->data._f_%s, 0, sizeof(parsec_data_pair_t)*((%s)+1));\n", + fl->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); + } + } for(vl = f->locals; vl != NULL; vl = vl->next) coutput(" int %s = this_task->locals.%s.value; /* retrieve value saved during the last iteration */\n", vl->name, vl->name); @@ -4407,6 +4430,7 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f jdf_generate_code_release_deps(jdf, f, prefix); string_arena_add_string(sa, " .release_deps = (parsec_release_deps_t*)%s,\n", prefix); +// Parametrized flows: TODO sprintf(prefix, "data_lookup_of_%s_%s", jdf_basename, f->fname); jdf_generate_code_data_lookup(jdf, f, prefix); string_arena_add_string(sa, " .prepare_output = (parsec_hook_t*)%s,\n", "NULL"); From 95d3417acd029c56b7f8ae7914d43528b6a2752f Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 12 Oct 2022 11:43:40 -0400 Subject: [PATCH 016/157] macro FLOW_IS_PARAMETRIZED --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 14 ++++---------- parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h | 11 +++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 2e54f03ac..207b31bed 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1421,7 +1421,7 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) { jdf_dataflow_t *df; for(df = f->dataflow; df != NULL; df = df->next) { - if( df->local_variables == NULL ) { + if( !FLOW_IS_PARAMETRIZED(df) ) { string_arena_add_string(sa_data, " parsec_data_pair_t _f_%s;\n", df->varname); } else @@ -1576,12 +1576,6 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) coutput("/** Predeclarations of the parameters */\n"); for(f = jdf->functions; f != NULL; f = f->next) { for(fl = f->dataflow; fl != NULL; fl = fl->next) { - /* - if(f->dataflow->local_variables != NULL) - { - rc = asprintf(&JDF_OBJECT_ONAME( fl ), "parametrized_"); - } - */ rc = asprintf(&JDF_OBJECT_ONAME( fl ), "flow_of_%s_%s_for_%s", jdf_basename, f->fname, fl->varname); assert(rc != -1); coutput("static const parsec_flow_t %s;\n", @@ -3269,7 +3263,7 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr struct jdf_dataflow *dataflow = f->dataflow; for(idx = 0; NULL != dataflow; idx++, dataflow = dataflow->next ) { - if(dataflow->local_variables == NULL) + if(!FLOW_IS_PARAMETRIZED(dataflow)) { coutput("%s new_task->data._f_%s.source_repo_entry = NULL;\n" "%s new_task->data._f_%s.source_repo = NULL;\n" @@ -6345,7 +6339,7 @@ static void jdf_generate_code_cache_awareness_update(const jdf_t *jdf, const jdf // } for(jdf_dataflow_t *df = f->dataflow; df != NULL; df = df->next) { - if(df->array_offset != NULL) + if(FLOW_IS_PARAMETRIZED(df)) { expr_info_t expr_info = EMPTY_EXPR_INFO; expr_info.sa = string_arena_new(8); @@ -7216,7 +7210,7 @@ static void jdf_generate_code_hook(const jdf_t *jdf, if ((fl->flow_flags & JDF_FLOW_TYPE_READ) && (fl->flow_flags & JDF_FLOW_TYPE_WRITE) ) { - if(fl->local_variables != NULL) { + if(FLOW_IS_PARAMETRIZED(fl)) { string_arena_t *sa = string_arena_new(64); dump_parametrized_flow_loop(fl, fl->local_variables->alias, " ", sa); coutput("%s", string_arena_get_string(sa)); diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index f30b4826a..720e7e8c6 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -5,6 +5,17 @@ typedef char *(*dumper_function_t)(void **elt, void *arg); +/** + * FLOW_IS_PARAMETRIZED: + * Tells whether a flow is parametrized or not. + * @param [IN] flow: the flow to test. + * + * @return a boolean value. + */ +#define FLOW_IS_PARAMETRIZED(flow) \ + ((flow)->local_variables != NULL) + + /** * UTIL_DUMP_LIST_FIELD: * Iterate over the elements of a list, transforming each field element in a string using a parameter function, From f391841e7124f28f22a0ccf9554b2c05f9fdfd4f Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 12 Oct 2022 14:11:48 -0400 Subject: [PATCH 017/157] add helper functions to manipulate parametrized flow code --- .../redistribute/redistribute_wrapper.c | 1 - parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 109 +++++++++++++----- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 38 ++++++ 3 files changed, 121 insertions(+), 27 deletions(-) diff --git a/parsec/data_dist/matrix/redistribute/redistribute_wrapper.c b/parsec/data_dist/matrix/redistribute/redistribute_wrapper.c index 5b143cc62..1e5ba6cad 100644 --- a/parsec/data_dist/matrix/redistribute/redistribute_wrapper.c +++ b/parsec/data_dist/matrix/redistribute/redistribute_wrapper.c @@ -204,4 +204,3 @@ int parsec_redistribute(parsec_context_t *parsec, return PARSEC_ERR_NOT_SUPPORTED; } - diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 207b31bed..c85fee547 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -581,8 +581,7 @@ char * dump_expr(void **elem, void *arg) /** * dump_parametrized_flow_loop: - * dumps the jdf_expr* pointed to by elem into arg->sa, prefixing each - * non-global variable with arg->prefix + * dumps the loop preceding a block that needs an iterator for the parametrized flow */ void dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_name, const char *indent, void *arg) { @@ -634,6 +633,45 @@ void dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_name } } +/** + * dump_parametrized_flow_loop_end: + * dumps the loop end corresponding to the loop preceding a block that needs an iterator for the parametrized flow + */ +void dump_parametrized_flow_loop_end(jdf_dataflow_t *flow, const char *indent, void *arg) +{ + jdf_dataflow_t *f = (jdf_dataflow_t*)flow; + string_arena_t *sa = arg; + + if(f == NULL ) return; + + string_arena_add_string(sa, "%s}\n", indent); +} + +/** + * dump_parametrized_flow_loop_if_parametrized: + * dumps the loop preceding a block that needs an iterator for the parametrized flow if the flow is parametrized + * dumps nothing otherwise + */ +void dump_parametrized_flow_loop_if_parametrized(jdf_dataflow_t *flow, const char *indent, void *arg) +{ + if(FLOW_IS_PARAMETRIZED(flow)) { + dump_parametrized_flow_loop(flow, flow->local_variables->alias, indent, arg); + } +} + +/** + * dump_parametrized_flow_loop_end_if_parametrized: + * dumps the loop end corresponding to the loop preceding a block that needs an iterator for the parametrized flow if the flow is parametrized + * dumps nothing otherwise + */ +void dump_parametrized_flow_loop_end_if_parametrized(jdf_dataflow_t *flow, const char *indent, void *arg) +{ + if(FLOW_IS_PARAMETRIZED(flow)) { + dump_parametrized_flow_loop_end(flow, indent, arg); + } +} + + /** * Dump a predicate like * #define F_pred(k, n, m) (__parsec_tp->ABC->rank == __parsec_tp->ABC->rank_of(__parsec_tp->ABC, k, n, m)) @@ -811,8 +849,8 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) string_arena_init(sa); - if(f->array_offset != NULL) - { + // if(f->array_offset != NULL) + // { expr_info_t expr_info = EMPTY_EXPR_INFO; expr_info.sa = string_arena_new(256); expr_info.prefix = ""; @@ -820,33 +858,52 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) expr_info.assignments = "parametrized flow range"; - string_arena_add_string(sa, - " parsec_data_copy_t *_f_%s[(%s)+1];\n", - varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info)); - string_arena_add_string(sa, - " void *%s[(%s)+1]; (void)%s;\n", - varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info), varname); + if(FLOW_IS_PARAMETRIZED(f)) + { + string_arena_add_string(sa, + " parsec_data_copy_t *_f_%s[(%s)+1];\n", + varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info)); + string_arena_add_string(sa, + " void *%s[(%s)+1]; (void)%s;\n", + varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info), varname); + } + else + { + string_arena_add_string(sa, + " parsec_data_copy_t *_f_%s;\n", + varname); + string_arena_add_string(sa, + " void *%s;\n", + varname); + } - dump_parametrized_flow_loop(f, f->local_variables->alias, " ", sa); + dump_parametrized_flow_loop_if_parametrized(f, " ", sa); - string_arena_add_string(sa, - " _f_%s[%s] = this_task->data._f_%s.data_%s;\n", - varname, f->local_variables->alias, f->varname, where); - string_arena_add_string(sa, - " %s[%s] = PARSEC_DATA_COPY_GET_PTR(_f_%s[%s]); (void)%s;\n", - varname, f->local_variables->alias, varname, f->local_variables->alias, varname); + string_arena_t *osa = string_arena_new(32); - string_arena_add_string(sa, " }\n"); - } - else - { string_arena_add_string(sa, - " parsec_data_copy_t *_f_%s = this_task->data._f_%s.data_%s;\n", - varname, f->varname, where); + "%s _f_%s%s = this_task->data._f_%s.data_%s;\n", + INDENTATION_IF_PARAMETRIZED(f), varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), + varname, where); + string_arena_add_string(sa, - " void *%s = PARSEC_DATA_COPY_GET_PTR(_f_%s); (void)%s;\n", - varname, varname, varname); - } + "%s %s%s = PARSEC_DATA_COPY_GET_PTR(_f_%s%s);\n", + INDENTATION_IF_PARAMETRIZED(f), varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), + varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f)); + + string_arena_free(osa); + + dump_parametrized_flow_loop_end_if_parametrized(f, " ", sa); + // } + // else + // { + // string_arena_add_string(sa, + // " parsec_data_copy_t *_f_%s = this_task->data._f_%s.data_%s;\n", + // varname, f->varname, where); + // string_arena_add_string(sa, + // " void *%s = PARSEC_DATA_COPY_GET_PTR(_f_%s); (void)%s;\n", + // varname, varname, varname); + // } return string_arena_get_string(sa); } diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 720e7e8c6..4abef872e 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -15,6 +15,44 @@ typedef char *(*dumper_function_t)(void **elt, void *arg); #define FLOW_IS_PARAMETRIZED(flow) \ ((flow)->local_variables != NULL) +/** + * INDENTATION_IF_PARAMETRIZED: + * Returns an indentation string if the flow is parametrized. + * @param [IN] flow: said flow. + * + * @return a string containing an indentation if the flow is parametrized, an empty string otherwise. + */ +#define INDENTATION_IF_PARAMETRIZED(flow) \ + ((FLOW_IS_PARAMETRIZED(flow)) ? " " : "") + +/** + * DUMP_ARRAY_OFFSET_IF_PARAMETRIZED: + * Tells whether a flow is parametrized or not. + * @param [IN] sa: the string arena to use. + * @param [IN] flow: the flow to test. + * + * @return an empty string if not parametrized, [var] else (var being the name of the iterator variable). + */ +#define DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(sa, flow) \ + util_dump_array_offset_if_parametrized(sa, flow) + +/** + * util_dump_array_offset_if_parametrized: + * function used by the DUMP_ARRAY_OFFSET_IF_PARAMETRIZED* macros. Do not use directly. + */ +static inline char* +util_dump_array_offset_if_parametrized(string_arena_t *sa, jdf_dataflow_t *flow) +{ + // reinit sa + string_arena_init(sa); + + if (FLOW_IS_PARAMETRIZED(flow)) { + string_arena_add_string(sa, "[%s]", flow->local_variables->alias); + } + + return string_arena_get_string(sa); +} + /** * UTIL_DUMP_LIST_FIELD: From f52ca356a84ee4235eeebd160355599bbedd60c0 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 12 Oct 2022 14:41:31 -0400 Subject: [PATCH 018/157] use util functions for the _startup_ function generation --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 141 +++++++++------------ 1 file changed, 62 insertions(+), 79 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index c85fee547..d14b93420 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -849,61 +849,49 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) string_arena_init(sa); - // if(f->array_offset != NULL) - // { - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(256); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "parametrized flow range"; + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(256); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "parametrized flow range"; - if(FLOW_IS_PARAMETRIZED(f)) - { - string_arena_add_string(sa, - " parsec_data_copy_t *_f_%s[(%s)+1];\n", - varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info)); - string_arena_add_string(sa, - " void *%s[(%s)+1]; (void)%s;\n", - varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info), varname); - } - else - { - string_arena_add_string(sa, - " parsec_data_copy_t *_f_%s;\n", - varname); - string_arena_add_string(sa, - " void *%s;\n", - varname); - } + if(FLOW_IS_PARAMETRIZED(f)) + { + string_arena_add_string(sa, + " parsec_data_copy_t *_f_%s[(%s)+1];\n", + varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info)); + string_arena_add_string(sa, + " void *%s[(%s)+1]; (void)%s;\n", + varname, dump_expr((void**)f->local_variables->jdf_ta2, &expr_info), varname); + } + else + { + string_arena_add_string(sa, + " parsec_data_copy_t *_f_%s;\n", + varname); + string_arena_add_string(sa, + " void *%s; (void)%s;\n", + varname, varname); + } - dump_parametrized_flow_loop_if_parametrized(f, " ", sa); + dump_parametrized_flow_loop_if_parametrized(f, " ", sa); - string_arena_t *osa = string_arena_new(32); + string_arena_t *osa = string_arena_new(32); - string_arena_add_string(sa, - "%s _f_%s%s = this_task->data._f_%s.data_%s;\n", - INDENTATION_IF_PARAMETRIZED(f), varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), - varname, where); + string_arena_add_string(sa, + "%s _f_%s%s = this_task->data._f_%s.data_%s;\n", + INDENTATION_IF_PARAMETRIZED(f), varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), + varname, where); - string_arena_add_string(sa, - "%s %s%s = PARSEC_DATA_COPY_GET_PTR(_f_%s%s);\n", - INDENTATION_IF_PARAMETRIZED(f), varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), - varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f)); + string_arena_add_string(sa, + "%s %s%s = PARSEC_DATA_COPY_GET_PTR(_f_%s%s);\n", + INDENTATION_IF_PARAMETRIZED(f), varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), + varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f)); - string_arena_free(osa); + string_arena_free(osa); - dump_parametrized_flow_loop_end_if_parametrized(f, " ", sa); - // } - // else - // { - // string_arena_add_string(sa, - // " parsec_data_copy_t *_f_%s = this_task->data._f_%s.data_%s;\n", - // varname, f->varname, where); - // string_arena_add_string(sa, - // " void *%s = PARSEC_DATA_COPY_GET_PTR(_f_%s); (void)%s;\n", - // varname, varname, varname); - // } + dump_parametrized_flow_loop_end_if_parametrized(f, " ", sa); return string_arena_get_string(sa); } @@ -3320,42 +3308,37 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr struct jdf_dataflow *dataflow = f->dataflow; for(idx = 0; NULL != dataflow; idx++, dataflow = dataflow->next ) { - if(!FLOW_IS_PARAMETRIZED(dataflow)) - { - coutput("%s new_task->data._f_%s.source_repo_entry = NULL;\n" - "%s new_task->data._f_%s.source_repo = NULL;\n" - "%s new_task->data._f_%s.data_in = NULL;\n" - "%s new_task->data._f_%s.data_out = NULL;\n" - "%s new_task->data._f_%s.fulfill = 0;\n", - indent(nesting), dataflow->varname, - indent(nesting), dataflow->varname, - indent(nesting), dataflow->varname, - indent(nesting), dataflow->varname, - indent(nesting), dataflow->varname); - } - else - { // Parametrized flow - nesting++; + if(FLOW_IS_PARAMETRIZED(dataflow)) { + nesting++; + } - string_arena_t *sa = string_arena_new(64); - dump_parametrized_flow_loop(dataflow, dataflow->local_variables->alias, indent(nesting), sa); + string_arena_t *osa = string_arena_new(16); + + string_arena_t *sa = string_arena_new(256); + dump_parametrized_flow_loop_if_parametrized(dataflow, indent(nesting), sa); coutput("%s", string_arena_get_string(sa)); - coutput("%s new_task->data._f_%s[%s].source_repo_entry = NULL;\n" - "%s new_task->data._f_%s[%s].source_repo = NULL;\n" - "%s new_task->data._f_%s[%s].data_in = NULL;\n" - "%s new_task->data._f_%s[%s].data_out = NULL;\n" - "%s new_task->data._f_%s[%s].fulfill = 0;\n", - indent(nesting), dataflow->varname, dataflow->local_variables->alias, - indent(nesting), dataflow->varname, dataflow->local_variables->alias, - indent(nesting), dataflow->varname, dataflow->local_variables->alias, - indent(nesting), dataflow->varname, dataflow->local_variables->alias, - indent(nesting), dataflow->varname, dataflow->local_variables->alias); - - coutput("%s}\n", indent(nesting)); + coutput("%s new_task->data._f_%s%s.source_repo_entry = NULL;\n" + "%s new_task->data._f_%s%s.source_repo = NULL;\n" + "%s new_task->data._f_%s%s.data_in = NULL;\n" + "%s new_task->data._f_%s%s.data_out = NULL;\n" + "%s new_task->data._f_%s%s.fulfill = 0;\n", + indent(nesting), dataflow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, dataflow), + indent(nesting), dataflow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, dataflow), + indent(nesting), dataflow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, dataflow), + indent(nesting), dataflow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, dataflow), + indent(nesting), dataflow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, dataflow)); + + string_arena_init(sa); + dump_parametrized_flow_loop_end_if_parametrized(dataflow, indent(nesting), sa); + coutput("%s", string_arena_get_string(sa)); - nesting--; - } + string_arena_free(sa); + string_arena_free(osa); + + if(FLOW_IS_PARAMETRIZED(dataflow)) { + nesting--; + } } } From 9939b8b86d175c3cdea8333f6de2a0cbf0f9c27c Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 12 Oct 2022 15:02:04 -0400 Subject: [PATCH 019/157] use util functions in jdf_generate_code_cache_awareness_update --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 33 +++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index d14b93420..60e29bcc5 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6379,22 +6379,23 @@ static void jdf_generate_code_cache_awareness_update(const jdf_t *jdf, const jdf // } for(jdf_dataflow_t *df = f->dataflow; df != NULL; df = df->next) { - if(FLOW_IS_PARAMETRIZED(df)) - { - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(8); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "parametrized flow range"; - - dump_parametrized_flow_loop(df, df->local_variables->alias, " ", sa); - string_arena_add_string(sa, " cache_buf_referenced(es->closest_cache, %s[%s]);\n", df->varname, df->local_variables->alias); - string_arena_add_string(sa, " }\n"); - } - else - { - string_arena_add_string(sa, " cache_buf_referenced(es->closest_cache, %s);\n", df->varname); - } + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(128); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "parametrized flow range"; + + string_arena_t *osa = string_arena_new(16); + + dump_parametrized_flow_loop_if_parametrized(df, " ", sa); + //dump_parametrized_flow_loop(df, df->local_variables->alias, " ", sa); + string_arena_add_string(sa, "%s cache_buf_referenced(es->closest_cache, %s%s);\n", + INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df)); + dump_parametrized_flow_loop_end_if_parametrized(df, " ", sa); + //string_arena_add_string(sa, " }\n"); + + string_arena_free(expr_info.sa); + string_arena_free(osa); } if( strlen(string_arena_get_string(sa)) ) { From d9efdd843d21f431ac313379b7d482bdecb0ffc6 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 12 Oct 2022 15:17:24 -0400 Subject: [PATCH 020/157] use util functions for the generation of parsec_data_transfer_ownership_to_copy --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 55 +++++++++------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 60e29bcc5..b87030534 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7251,39 +7251,30 @@ static void jdf_generate_code_hook(const jdf_t *jdf, if ((fl->flow_flags & JDF_FLOW_TYPE_READ) && (fl->flow_flags & JDF_FLOW_TYPE_WRITE) ) { - if(FLOW_IS_PARAMETRIZED(fl)) { - string_arena_t *sa = string_arena_new(64); - dump_parametrized_flow_loop(fl, fl->local_variables->alias, " ", sa); - coutput("%s", string_arena_get_string(sa)); - - coutput(" if ( NULL != _f_%s[%s] ) {\n" - " parsec_data_transfer_ownership_to_copy( _f_%s[%s]->original, 0 /* device */,\n" - " %s);\n" - " }\n", - fl->varname, - fl->local_variables->alias, - fl->varname, - fl->local_variables->alias, - ((fl->flow_flags & JDF_FLOW_TYPE_CTL) ? "PARSEC_FLOW_ACCESS_NONE" : - ((fl->flow_flags & JDF_FLOW_TYPE_READ) ? - ((fl->flow_flags & JDF_FLOW_TYPE_WRITE) ? "PARSEC_FLOW_ACCESS_RW" : "PARSEC_FLOW_ACCESS_READ") : "PARSEC_FLOW_ACCESS_WRITE"))); - - coutput(" }\n"); - } - else - { - - coutput(" if ( NULL != _f_%s ) {\n" - " parsec_data_transfer_ownership_to_copy( _f_%s->original, 0 /* device */,\n" - " %s);\n" - " }\n", - fl->varname, - fl->varname, - ((fl->flow_flags & JDF_FLOW_TYPE_CTL) ? "PARSEC_FLOW_ACCESS_NONE" : - ((fl->flow_flags & JDF_FLOW_TYPE_READ) ? - ((fl->flow_flags & JDF_FLOW_TYPE_WRITE) ? "PARSEC_FLOW_ACCESS_RW" : "PARSEC_FLOW_ACCESS_READ") : "PARSEC_FLOW_ACCESS_WRITE"))); + string_arena_t *sa = string_arena_new(64); + string_arena_t *osa = string_arena_new(16); + dump_parametrized_flow_loop_if_parametrized(fl, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + coutput("%s if ( NULL != _f_%s%s ) {\n" + "%s parsec_data_transfer_ownership_to_copy( _f_%s%s->original, 0 /* device */,\n" + "%s %s);\n" + "%s }\n", + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + INDENTATION_IF_PARAMETRIZED(fl), ((fl->flow_flags & JDF_FLOW_TYPE_CTL) ? "PARSEC_FLOW_ACCESS_NONE" : + ((fl->flow_flags & JDF_FLOW_TYPE_READ) ? + ((fl->flow_flags & JDF_FLOW_TYPE_WRITE) ? "PARSEC_FLOW_ACCESS_RW" : "PARSEC_FLOW_ACCESS_READ") : "PARSEC_FLOW_ACCESS_WRITE")), + INDENTATION_IF_PARAMETRIZED(fl)); + + string_arena_init(sa); + + dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + string_arena_free(sa); + string_arena_free(osa); - } } } coutput("#endif /* defined(PARSEC_HAVE_CUDA) */\n"); From 5dcd14ec0e01a5e7aebb12a50bea69dc49a8205e Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 12 Oct 2022 16:54:34 -0400 Subject: [PATCH 021/157] incorrect patch for release_deps_of_..., releases all deps of a parametrized flow --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 118 ++++++++++++++------- 1 file changed, 80 insertions(+), 38 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index b87030534..6f8b32db4 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7251,29 +7251,29 @@ static void jdf_generate_code_hook(const jdf_t *jdf, if ((fl->flow_flags & JDF_FLOW_TYPE_READ) && (fl->flow_flags & JDF_FLOW_TYPE_WRITE) ) { - string_arena_t *sa = string_arena_new(64); - string_arena_t *osa = string_arena_new(16); - dump_parametrized_flow_loop_if_parametrized(fl, " ", sa); - coutput("%s", string_arena_get_string(sa)); - - coutput("%s if ( NULL != _f_%s%s ) {\n" - "%s parsec_data_transfer_ownership_to_copy( _f_%s%s->original, 0 /* device */,\n" - "%s %s);\n" - "%s }\n", - INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), - INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), - INDENTATION_IF_PARAMETRIZED(fl), ((fl->flow_flags & JDF_FLOW_TYPE_CTL) ? "PARSEC_FLOW_ACCESS_NONE" : - ((fl->flow_flags & JDF_FLOW_TYPE_READ) ? - ((fl->flow_flags & JDF_FLOW_TYPE_WRITE) ? "PARSEC_FLOW_ACCESS_RW" : "PARSEC_FLOW_ACCESS_READ") : "PARSEC_FLOW_ACCESS_WRITE")), - INDENTATION_IF_PARAMETRIZED(fl)); - - string_arena_init(sa); - - dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa); - coutput("%s", string_arena_get_string(sa)); - - string_arena_free(sa); - string_arena_free(osa); + string_arena_t *sa = string_arena_new(64); + string_arena_t *osa = string_arena_new(16); + dump_parametrized_flow_loop_if_parametrized(fl, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + coutput("%s if ( NULL != _f_%s%s ) {\n" + "%s parsec_data_transfer_ownership_to_copy( _f_%s%s->original, 0 /* device */,\n" + "%s %s);\n" + "%s }\n", + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + INDENTATION_IF_PARAMETRIZED(fl), ((fl->flow_flags & JDF_FLOW_TYPE_CTL) ? "PARSEC_FLOW_ACCESS_NONE" : + ((fl->flow_flags & JDF_FLOW_TYPE_READ) ? + ((fl->flow_flags & JDF_FLOW_TYPE_WRITE) ? "PARSEC_FLOW_ACCESS_RW" : "PARSEC_FLOW_ACCESS_READ") : "PARSEC_FLOW_ACCESS_WRITE")), + INDENTATION_IF_PARAMETRIZED(fl)); + + string_arena_init(sa); + + dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + string_arena_free(sa); + string_arena_free(osa); } } @@ -7387,25 +7387,59 @@ static void jdf_generate_code_hooks(const jdf_t *jdf, static void jdf_generate_code_free_hash_table_entry(const jdf_t *jdf, const jdf_function_entry_t *f, int consume_repo, int release_inputs) { - jdf_dataflow_t *dl; + jdf_dataflow_t *df; coutput(" if( action_mask & PARSEC_ACTION_RELEASE_LOCAL_REFS ) {\n"); - for( dl = f->dataflow; dl != NULL; dl = dl->next ) { - if( dl->flow_flags & JDF_FLOW_TYPE_CTL ) continue; + for( df = f->dataflow; df != NULL; df = df->next ) { + if( df->flow_flags & JDF_FLOW_TYPE_CTL ) continue; if(consume_repo){ - coutput(" if( NULL != this_task->data._f_%s.source_repo_entry ) {\n" - " data_repo_entry_used_once( this_task->data._f_%s.source_repo, this_task->data._f_%s.source_repo_entry->ht_item.key );\n" - " }\n", - dl->varname, - dl->varname, dl->varname); + // TODO: This is not correct, only one dep should be released (not dump_parametrized_flow_loop_if_parametrized) + string_arena_t *sa = string_arena_new(128); + dump_parametrized_flow_loop_if_parametrized(df, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + string_arena_t *osa = string_arena_new(64); + + + coutput("%s if( NULL != this_task->data._f_%s%s.source_repo_entry ) {\n" + "%s data_repo_entry_used_once( this_task->data._f_%s%s.source_repo, this_task->data._f_%s%s.source_repo_entry->ht_item.key );\n" + "%s }\n", + INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df), + INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df), + INDENTATION_IF_PARAMETRIZED(df)); + + string_arena_free(osa); + + string_arena_init(sa); + dump_parametrized_flow_loop_end_if_parametrized(df, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + string_arena_free(sa); } if(release_inputs){ - if( dl->flow_flags & (JDF_FLOW_TYPE_READ | JDF_FLOW_TYPE_WRITE) ) { - coutput(" if( NULL != this_task->data._f_%s.data_in ) {\n" - " PARSEC_DATA_COPY_RELEASE(this_task->data._f_%s.data_in);\n" - " }\n", - dl->varname, dl->varname); + if( df->flow_flags & (JDF_FLOW_TYPE_READ | JDF_FLOW_TYPE_WRITE) ) { + // TODO: This is not correct, only one dep should be released (not dump_parametrized_flow_loop_if_parametrized) + string_arena_t *sa = string_arena_new(128); + dump_parametrized_flow_loop_if_parametrized(df, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + string_arena_t *osa = string_arena_new(64); + + coutput("%s if( NULL != this_task->data._f_%s%s.data_in ) {\n" + "%s PARSEC_DATA_COPY_RELEASE(this_task->data._f_%s%s.data_in);\n" + "%s }\n", + INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df), + INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df), + INDENTATION_IF_PARAMETRIZED(df)); + + string_arena_free(osa); + + string_arena_init(sa); + dump_parametrized_flow_loop_end_if_parametrized(df, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + string_arena_free(sa); } } (void)jdf; /* just to keep the compilers happy regarding the goto to an empty statement */ @@ -7870,6 +7904,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_t *sa1 = string_arena_new(64); string_arena_t *sa2 = string_arena_new(64); string_arena_t *sa_ontask = string_arena_new(64); + string_arena_t *osa = string_arena_new(64); string_arena_t *sa_coutput = string_arena_new(1024); string_arena_t *sa_deps = string_arena_new(1024); string_arena_t *sa_datatype = string_arena_new(1024); @@ -7946,6 +7981,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, flowtomem = 0; depnb = 0; last_datatype_idx = -1; + string_arena_init(osa); string_arena_init(sa_coutput); string_arena_init(sa_deps); string_arena_init(sa_datatype); @@ -7959,9 +7995,14 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_init(sa_type_r); nb_open_ldef = 0; + + dump_parametrized_flow_loop_if_parametrized(fl, " ", sa_coutput); + string_arena_add_string(sa_coutput, - " data.data = this_task->data._f_%s.data_out;\n", - fl->varname); + "%s data.data = this_task->data._f_%s%s.data_out;\n", + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl)); + + dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa_coutput); for(dl = fl->deps; dl != NULL; dl = dl->next) { if( !(dl->dep_flags & flow_type) ) continue; @@ -8259,6 +8300,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_free(sa_ontask); string_arena_free(sa1); string_arena_free(sa2); + string_arena_free(osa); string_arena_free(sa_coutput); string_arena_free(sa_deps); string_arena_free(sa_datatype); From 0cc8f92a9c3282dc6fb77f550b9aa0e3df42b0a9 Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 13 Oct 2022 16:11:47 -0400 Subject: [PATCH 022/157] add various offset to flows when parametrized --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 94 +++++++++++++++------- 1 file changed, 65 insertions(+), 29 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 6f8b32db4..14e30c5a5 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5676,6 +5676,10 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, sa = string_arena_new(64); sa2 = string_arena_new(64); + string_arena_t *osa; + osa = string_arena_new(64); + string_arena_init(osa); + info.sa = sa2; info.prefix = ""; info.suffix = ""; @@ -5722,9 +5726,9 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, spaces, flow->varname, flow->flow_index, dl->dep_index, string_arena_get_string(sa) ); string_arena_init(sa); - coutput("%s if( NULL == (chunk = this_task->data._f_%s.data_in) ) {\n" + coutput("%s if( NULL == (chunk = this_task->data._f_%s%s.data_in) ) {\n" "%s /* No data set up by predecessor on this task input flow */\n", - spaces, flow->varname, + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), spaces); /* Function calls */ @@ -5744,9 +5748,9 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, jdf_generate_code_reshape_input_from_dep(jdf, f, flow, dl, spaces); coutput("%s ACQUIRE_FLOW(this_task, \"%s\", &%s_%s, \"%s\", target_locals, chunk);\n" - "%s this_task->data._f_%s.data_out = chunk;\n", + "%s this_task->data._f_%s%s.data_out = chunk;\n", spaces, flow->varname, jdf_basename, call->func_or_mem, call->var, - spaces, flow->varname); + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); } else { @@ -5767,9 +5771,9 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, jdf_generate_code_reshape_input_from_desc(jdf, f, flow, dl, spaces); - coutput("%s this_task->data._f_%s.data_out = chunk;\n" + coutput("%s this_task->data._f_%s%s.data_out = chunk;\n" "%s PARSEC_OBJ_RETAIN(chunk);\n", - spaces, flow->varname, + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), spaces); } @@ -5796,10 +5800,10 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, coutput("%s chunk = parsec_arena_get_copy(%s->arena, %s, target_device, %s->opaque_dtt);\n" "%s chunk->original->owner_device = target_device;\n" - "%s this_task->data._f_%s.data_out = chunk;\n", + "%s this_task->data._f_%s%s.data_out = chunk;\n", spaces, string_arena_get_string(sa), string_arena_get_string(sa2), string_arena_get_string(sa), spaces, - spaces, flow->varname); + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); string_arena_free(info.sa); } @@ -5834,6 +5838,8 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, spaces, JDF_OBJECT_ONAME( flow ), spaces); } + + string_arena_free(osa); string_arena_free(sa); string_arena_free(sa2); } @@ -5941,21 +5947,39 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, char* condition[] = {" if( %s ) {\n", " else if( %s ) {\n"}; if( JDF_FLOW_TYPE_CTL & flow->flow_flags ) { + string_arena_t *sa; + sa = string_arena_new(64); + string_arena_init(sa); + dump_parametrized_flow_loop_if_parametrized(flow, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + coutput(" /* %s is a control flow */\n" - " this_task->data._f_%s.data_in = NULL;\n" - " this_task->data._f_%s.data_out = NULL;\n" - " this_task->data._f_%s.source_repo = NULL;\n" - " this_task->data._f_%s.source_repo_entry = NULL;\n", - flow->varname, - flow->varname, + "%s this_task->data._f_%s%s.data_in = NULL;\n" + "%s this_task->data._f_%s%s.data_out = NULL;\n" + "%s this_task->data._f_%s%s.source_repo = NULL;\n" + "%s this_task->data._f_%s%s.source_repo_entry = NULL;\n", flow->varname, - flow->varname, - flow->varname); + INDENTATION_IF_PARAMETRIZED(flow), flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(sa, flow), + INDENTATION_IF_PARAMETRIZED(flow), flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(sa, flow), + INDENTATION_IF_PARAMETRIZED(flow), flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(sa, flow), + INDENTATION_IF_PARAMETRIZED(flow), flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(sa, flow)); + + string_arena_init(sa); + dump_parametrized_flow_loop_end_if_parametrized(flow, " ", sa); + coutput("%s", string_arena_get_string(sa)); + string_arena_free(sa); + return; } + string_arena_t *osa; + osa = string_arena_new(64); + dump_parametrized_flow_loop_if_parametrized(flow, "\n\n ", osa); + coutput("%s", string_arena_get_string(osa)); + coutput("\n" - "if(! this_task->data._f_%s.fulfill ){ /* Flow %s */\n", flow->varname, flow->varname); + "if(! this_task->data._f_%s%s.fulfill ){ /* Flow %s */\n", flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), flow->varname); coutput(" consumed_repo = NULL;\n" " consumed_entry_key = 0;\n" @@ -5969,9 +5993,9 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, } } if( !has_output_deps ) { - coutput("\n this_task->data._f_%s.data_out = NULL; /* input only */\n", flow->varname); + coutput("\n this_task->data._f_%s%s.data_out = NULL; /* input only */\n", flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); } else { - coutput("\n this_task->data._f_%s.data_out = NULL; /* By default, if nothing matches */\n", flow->varname); + coutput("\n this_task->data._f_%s%s.data_out = NULL; /* By default, if nothing matches */\n", flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); } sa = string_arena_new(64); @@ -6058,30 +6082,34 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, } } done_with_input: - coutput(" this_task->data._f_%s.data_in = chunk;\n" - " this_task->data._f_%s.source_repo = consumed_repo;\n" - " this_task->data._f_%s.source_repo_entry = consumed_entry;\n", - flow->varname, - flow->varname, - flow->varname); + coutput(" this_task->data._f_%s%s.data_in = chunk;\n" + " this_task->data._f_%s%s.source_repo = consumed_repo;\n" + " this_task->data._f_%s%s.source_repo_entry = consumed_entry;\n", + flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); if( !(f->flags & JDF_FUNCTION_FLAG_NO_SUCCESSORS) ) { /* If we have consume from our repo, we clean up the repo entry for that flow, * so we don't have old stuff during release_deps_of when we will set up outputs * on our repo as a predecessor. */ - coutput(" if( this_task->data._f_%s.source_repo_entry == this_task->repo_entry ){\n" + coutput(" if( this_task->data._f_%s%s.source_repo_entry == this_task->repo_entry ){\n" " /* in case we have consume from this task repo entry for the flow,\n" " * it is cleaned up, avoiding having old stuff during release_deps_of\n" " */\n" " this_task->repo_entry->data[%d] = NULL;\n" " }\n", - flow->varname, + flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), flow->flow_index); } - coutput(" this_task->data._f_%s.fulfill = 1;\n" + coutput(" this_task->data._f_%s%s.fulfill = 1;\n" "}\n\n", - flow->varname);/* coutput("if(! this_task->data._f_%s.fulfill ){\n", flow->varname);*/ + flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow));/* coutput("if(! this_task->data._f_%s.fulfill ){\n", flow->varname);*/ + + string_arena_init(osa); + dump_parametrized_flow_loop_end_if_parametrized(flow, " ", osa); + coutput("%s", string_arena_get_string(osa)); string_arena_free(sa); if( NULL != sa2 ) @@ -6535,9 +6563,15 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, if( !(fl->flow_flags & JDF_FLOW_IS_OUT) ) continue; } skip_condition = 0; /* Assume we have a valid not-yet-optimized condition */ + + //string_arena *sa_parametrized_flow = string_arena_new(256); + //string_arena_init(sa_parametrized_flow); + string_arena_add_string(sa_coutput, "if( (*flow_mask) & 0x%xU ) { /* Flow %s */\n", (type == JDF_DEP_FLOW_OUT ? fl->flow_dep_mask_out : (1U << fl->flow_index)), fl->varname); + dump_parametrized_flow_loop_if_parametrized(fl, " ", sa_coutput); + last_datatype_idx = -1; continue_dependencies = 1; string_arena_init(sa_deps); @@ -6614,6 +6648,8 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, } JDF_CODE_DATATYPE_DUMP(sa_coutput, current_mask, sa_cond, sa_datatype, skip_condition); + dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa_coutput); + string_arena_add_string(sa_coutput, "} /* (flow_mask & 0x%xU) */\n", (type == JDF_DEP_FLOW_OUT ? fl->flow_dep_mask_out : (1U << fl->flow_index))); } From 9fdd33e536569143f696a4fb9243627067003cc1 Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 13 Oct 2022 20:04:50 -0400 Subject: [PATCH 023/157] add parametrized reference to data (still some left to do) --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 79 ++++++++++++------- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 2 +- 2 files changed, 51 insertions(+), 30 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 14e30c5a5..44b90b663 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -583,7 +583,7 @@ char * dump_expr(void **elem, void *arg) * dump_parametrized_flow_loop: * dumps the loop preceding a block that needs an iterator for the parametrized flow */ -void dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_name, const char *indent, void *arg) +void dump_parametrized_flow_loop(const jdf_dataflow_t *flow, const char *iterator_name, const char *indent, void *arg) { //expr_info_t* expr_info = (expr_info_t*)arg; jdf_dataflow_t *f = (jdf_dataflow_t*)flow; @@ -637,7 +637,7 @@ void dump_parametrized_flow_loop(jdf_dataflow_t *flow, const char *iterator_name * dump_parametrized_flow_loop_end: * dumps the loop end corresponding to the loop preceding a block that needs an iterator for the parametrized flow */ -void dump_parametrized_flow_loop_end(jdf_dataflow_t *flow, const char *indent, void *arg) +void dump_parametrized_flow_loop_end(const jdf_dataflow_t *flow, const char *indent, void *arg) { jdf_dataflow_t *f = (jdf_dataflow_t*)flow; string_arena_t *sa = arg; @@ -652,7 +652,7 @@ void dump_parametrized_flow_loop_end(jdf_dataflow_t *flow, const char *indent, v * dumps the loop preceding a block that needs an iterator for the parametrized flow if the flow is parametrized * dumps nothing otherwise */ -void dump_parametrized_flow_loop_if_parametrized(jdf_dataflow_t *flow, const char *indent, void *arg) +void dump_parametrized_flow_loop_if_parametrized(const jdf_dataflow_t *flow, const char *indent, void *arg) { if(FLOW_IS_PARAMETRIZED(flow)) { dump_parametrized_flow_loop(flow, flow->local_variables->alias, indent, arg); @@ -664,7 +664,7 @@ void dump_parametrized_flow_loop_if_parametrized(jdf_dataflow_t *flow, const cha * dumps the loop end corresponding to the loop preceding a block that needs an iterator for the parametrized flow if the flow is parametrized * dumps nothing otherwise */ -void dump_parametrized_flow_loop_end_if_parametrized(jdf_dataflow_t *flow, const char *indent, void *arg) +void dump_parametrized_flow_loop_end_if_parametrized(const jdf_dataflow_t *flow, const char *indent, void *arg) { if(FLOW_IS_PARAMETRIZED(flow)) { dump_parametrized_flow_loop_end(flow, indent, arg); @@ -880,9 +880,9 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) string_arena_t *osa = string_arena_new(32); string_arena_add_string(sa, - "%s _f_%s%s = this_task->data._f_%s.data_%s;\n", + "%s _f_%s%s = this_task->data._f_%s%s.data_%s;\n", INDENTATION_IF_PARAMETRIZED(f), varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), - varname, where); + varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), where); string_arena_add_string(sa, "%s %s%s = PARSEC_DATA_COPY_GET_PTR(_f_%s%s);\n", @@ -5605,14 +5605,18 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * (void)pred_var; /*final_check = case predecessor has set up stuff on our data */ + string_arena_t *osa; + osa = string_arena_new(64); + string_arena_init(osa); + if( final_check ){ - coutput("%s consumed_repo = this_task->data._f_%s.source_repo;\n" - "%s consumed_entry = this_task->data._f_%s.source_repo_entry;\n" - "%s consumed_entry_key = this_task->data._f_%s.source_repo_entry->ht_item.key;\n", - spaces, flow->varname, - spaces, flow->varname, - spaces, flow->varname); + coutput("%s consumed_repo = this_task->data._f_%s%s.source_repo;\n" + "%s consumed_entry = this_task->data._f_%s%s.source_repo_entry;\n" + "%s consumed_entry_key = this_task->data._f_%s%s.source_repo_entry->ht_item.key;\n", + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); /* Is this current task repo or predecessor repo? Different flow index */ coutput("%s if( (reshape_entry != NULL) && (reshape_entry->data[%d] != NULL) ){\n" @@ -5621,10 +5625,10 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * spaces, flow->flow_index, spaces, spaces, flow->flow_index); - coutput("%s assert( (this_task->data._f_%s.source_repo == reshape_repo)\n" - "%s && (this_task->data._f_%s.source_repo_entry == reshape_entry));\n", - spaces, flow->varname, - spaces, flow->varname); + coutput("%s assert( (this_task->data._f_%s%s.source_repo == reshape_repo)\n" + "%s && (this_task->data._f_%s%s.source_repo_entry == reshape_entry));\n", + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); coutput("%s }else{\n" "%s /* Reshape promise set up on input by predecessor is the predecesssor task repo */\n" "%s consumed_flow_index = %d;\n" @@ -5661,6 +5665,8 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * spaces, pred_flow->flow_index, spaces); } + + string_arena_free(osa); } static void @@ -5829,12 +5835,12 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, /* Code to create & fulfill a reshape promise locally in case this input dependency is typed */ jdf_generate_code_reshape_input_from_dep(jdf, f, flow, dl, spaces); - coutput("%s this_task->data._f_%s.data_out = parsec_data_get_copy(chunk->original, target_device);\n" + coutput("%s this_task->data._f_%s%s.data_out = parsec_data_get_copy(chunk->original, target_device);\n" "#if defined(PARSEC_PROF_GRAPHER) && defined(PARSEC_PROF_TRACE)\n" "%s parsec_prof_grapher_data_input(chunk->original, (parsec_task_t*)this_task, &%s, 0);\n" "#endif\n" "%s }\n", - spaces, flow->varname, + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), spaces, JDF_OBJECT_ONAME( flow ), spaces); } @@ -7372,19 +7378,34 @@ jdf_generate_code_complete_hook(const jdf_t *jdf, /** * The data_out might be NULL if we don't forward anything. */ - coutput(" if ( NULL != this_task->data._f_%s.data_out ) {\n" + + string_arena_t *osa = string_arena_new(128); + + dump_parametrized_flow_loop_if_parametrized(fl, " ", osa); + coutput("%s", string_arena_get_string(osa)); + + coutput("%s if ( NULL != this_task->data._f_%s%s.data_out ) {\n" "#if defined(PARSEC_DEBUG_NOISIER)\n" - " char tmp[128];\n" + "%s char tmp[128];\n" "#endif\n" - " this_task->data._f_%s.data_out->version++; /* %s */\n" - " PARSEC_DEBUG_VERBOSE(10, parsec_debug_output,\n" - " \"Complete hook of %%s: change Data copy %%p to version %%d at %%s:%%d\",\n" - " parsec_task_snprintf(tmp, 128, (parsec_task_t*)(this_task)),\n" - " this_task->data._f_%s.data_out, this_task->data._f_%s.data_out->version, __FILE__, __LINE__);\n" - " }\n", - fl->varname, - fl->varname, fl->varname, - fl->varname, fl->varname ); + "%s this_task->data._f_%s%s.data_out->version++; /* %s */\n" + "%s PARSEC_DEBUG_VERBOSE(10, parsec_debug_output,\n" + "%s \"Complete hook of %%s: change Data copy %%p to version %%d at %%s:%%d\",\n" + "%s parsec_task_snprintf(tmp, 128, (parsec_task_t*)(this_task)),\n" + "%s this_task->data._f_%s%s.data_out, this_task->data._f_%s%s.data_out->version, __FILE__, __LINE__);\n" + "%s }\n", + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + INDENTATION_IF_PARAMETRIZED(fl), + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), fl->varname, + INDENTATION_IF_PARAMETRIZED(fl), INDENTATION_IF_PARAMETRIZED(fl), INDENTATION_IF_PARAMETRIZED(fl), INDENTATION_IF_PARAMETRIZED(fl), + fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + INDENTATION_IF_PARAMETRIZED(fl)); + + string_arena_init(osa); + dump_parametrized_flow_loop_end_if_parametrized(fl, " ", osa); + coutput("%s", string_arena_get_string(osa)); + + string_arena_free(osa); } } diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 4abef872e..816def1ce 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -41,7 +41,7 @@ typedef char *(*dumper_function_t)(void **elt, void *arg); * function used by the DUMP_ARRAY_OFFSET_IF_PARAMETRIZED* macros. Do not use directly. */ static inline char* -util_dump_array_offset_if_parametrized(string_arena_t *sa, jdf_dataflow_t *flow) +util_dump_array_offset_if_parametrized(string_arena_t *sa, const jdf_dataflow_t *flow) { // reinit sa string_arena_init(sa); From ea064cc0a9f5a1d48a0025d3b314f36c4734bbdd Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 14 Oct 2022 11:45:01 -0400 Subject: [PATCH 024/157] add the remaining _f_FLOW modification for parametrized flows to work in the test application --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 44b90b663..5c576fcab 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6132,6 +6132,7 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, const jdf_dataflow_t *flow) { string_arena_t *sa, *sa2; + string_arena_t *osa; string_arena_t *sa_arena, *sa_tmp_type_src, *sa_tmp_type_dst; string_arena_t *sa_type_src, *sa_displ_src, *sa_count_src; string_arena_t *sa_type_dst, *sa_displ_dst, *sa_count_dst; @@ -6144,6 +6145,7 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, sa = string_arena_new(64); sa2 = string_arena_new(64); + osa = string_arena_new(16); sa_tmp_type_src = string_arena_new(64); sa_tmp_type_dst = string_arena_new(64); @@ -6235,10 +6237,10 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, } coutput("%s data_t_desc = data_of_%s(%s);\n" - "%s if( (NULL != this_task->data._f_%s.data_out) && (this_task->data._f_%s.data_out->original != data_t_desc) ) {\n" + "%s if( (NULL != this_task->data._f_%s%s.data_out) && (this_task->data._f_%s%s.data_out->original != data_t_desc) ) {\n" "%s /* Writting back using remote_type */;\n" "%s parsec_dep_data_description_t data;\n" - "%s data.data = this_task->data._f_%s.data_out;\n" + "%s data.data = this_task->data._f_%s%s.data_out;\n" "%s data.local.arena = %s;\n" "%s data.local.src_datatype = %s;\n" "%s data.local.src_count = %s;\n" @@ -6251,13 +6253,13 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, "%s parsec_remote_dep_memcpy(es,\n" "%s this_task->taskpool,\n" "%s parsec_data_get_copy(data_of_%s(%s), 0),\n" - "%s this_task->data._f_%s.data_out, &data);\n" + "%s this_task->data._f_%s%s.data_out, &data);\n" "%s }\n", spaces, call->func_or_mem, string_arena_get_string(sa), - spaces, flow->varname, flow->varname, + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), spaces, spaces, - spaces, flow->varname, + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), spaces, string_arena_get_string(sa_arena), spaces, string_arena_get_string(sa_type_src), spaces, string_arena_get_string(sa_count_src), @@ -6270,7 +6272,7 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, spaces, spaces, spaces, call->func_or_mem, string_arena_get_string(sa), - spaces, flow->varname, + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), spaces); coutput("#if defined(PARSEC_PROF_GRAPHER) && defined(PARSEC_PROF_TRACE)\n" @@ -6281,6 +6283,7 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, string_arena_free(sa); string_arena_free(sa2); + string_arena_free(osa); string_arena_free(sa_arena); string_arena_free(sa_tmp_type_src); string_arena_free(sa_tmp_type_dst); @@ -7763,7 +7766,7 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, continue; /* This local define was alredy issued above as part of the call */ } string_arena_add_string(sa_open, "%s%s {\n" - "%s%s int %s;\n", + "%s%s int %s; // TODO\n", prefix, indent(nbopen), prefix, indent(nbopen), ld->alias); nbopen++; From badc97627ef671337b7526c6519e31bf7676b407 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 14 Oct 2022 12:00:20 -0400 Subject: [PATCH 025/157] correct the last needed parametrized data references (NOT TESTED) --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 73 +++++++++++++++------- 1 file changed, 51 insertions(+), 22 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 5c576fcab..f2e1d6761 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -899,7 +899,8 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) static char *dump_data_copy_init_for_inline_function(void **elem, void *arg) { init_from_data_info_t *info = (init_from_data_info_t*)arg; - string_arena_t *sa = info->sa; + string_arena_t *sa = info->sa, + *osa = string_arena_new(32); const char *where = info->where; jdf_dataflow_t *f = (jdf_dataflow_t*)elem; char *varname = f->varname; @@ -909,12 +910,22 @@ static char *dump_data_copy_init_for_inline_function(void **elem, void *arg) } string_arena_init(sa); + + // dump a loop if parametrized + dump_parametrized_flow_loop_if_parametrized(f, " ", sa); + string_arena_add_string(sa, - " parsec_data_copy_t *_f_%s = this_task->data._f_%s.data_%s;\n" - " (void)_f_%s;", - varname, f->varname, where, - varname + "%s parsec_data_copy_t *_f_%s = this_task->data._f_%s%s.data_%s;\n" + "%s (void)_f_%s;", + INDENTATION_IF_PARAMETRIZED(f), varname, f->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), where, + INDENTATION_IF_PARAMETRIZED(f), varname ); + + // dump the end of the loop if parametrized + dump_parametrized_flow_loop_end_if_parametrized(f, " ", sa); + + string_arena_free(osa); + return string_arena_get_string(sa); } @@ -5860,7 +5871,7 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ const char *spaces) { int dataindex; - string_arena_t *sa, *sa_arena, *sa_datatype, *sa_count ; + string_arena_t *sa, *sa_arena, *sa_datatype, *sa_count, *osa ; expr_info_t info = EMPTY_EXPR_INFO; if( (NULL != call) && (NULL != call->var) ) { @@ -5885,6 +5896,7 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ } sa = string_arena_new(64); + osa = string_arena_new(64); info.sa = sa; info.prefix = ""; @@ -5911,18 +5923,18 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ coutput("%s /* Flow %s [%d] dependency [%d] pure output data */\n", spaces, flow->varname, flow->flow_index, dl->dep_index); - coutput("%s if( NULL == (chunk = this_task->data._f_%s.data_in) ) {\n" + coutput("%s if( NULL == (chunk = this_task->data._f_%s%s.data_in) ) {\n" "%s /* No data set up by predecessor */\n", - spaces, flow->varname, + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), spaces); coutput("%s chunk = parsec_arena_get_copy(%s->arena, %s, target_device, %s);\n" "%s chunk->original->owner_device = target_device;\n", spaces, string_arena_get_string(sa_arena), string_arena_get_string(sa_count), string_arena_get_string(sa_datatype), spaces); - coutput("%s this_task->data._f_%s.data_out = chunk;\n" + coutput("%s this_task->data._f_%s%s.data_out = chunk;\n" "%s }\n", - spaces, flow->varname, + spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), spaces); #if defined(PARSEC_DEBUG_NOISIER) || defined(PARSEC_DEBUG_PARANOID) @@ -5937,6 +5949,7 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ #endif string_arena_free(sa); + string_arena_free(osa); string_arena_free(sa_arena); string_arena_free(sa_datatype); string_arena_free(sa_count); @@ -6854,7 +6867,7 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, const char *dyldtype; const char *device; const char *weight; - string_arena_t *sa, *sa2, *sa3; + string_arena_t *sa, *sa2, *sa3, *osa; assignment_info_t ai; init_from_data_info_t ai2; jdf_dataflow_t *fl; @@ -6874,6 +6887,7 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, sa = string_arena_new(64); sa2 = string_arena_new(64); sa3 = string_arena_new(64); + osa = string_arena_new(64); ai.sa = sa2; ai.holder = "this_task->locals."; @@ -6934,10 +6948,10 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, if(fl->flow_flags & JDF_FLOW_TYPE_CTL) continue; /* control flow, nothing to store */ - coutput(" data_repo_entry_t *e%s = this_task->data._f_%s.source_repo_entry;\n" + coutput(" data_repo_entry_t *e%s = this_task->data._f_%s%s.source_repo_entry;\n" " if( (NULL != e%s) && (e%s->sim_exec_date > this_task->sim_exec_date) )\n" " this_task->sim_exec_date = e%s->sim_exec_date;\n", - fl->varname, fl->varname, + fl->varname, fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), fl->varname, fl->varname, fl->varname); } @@ -6949,6 +6963,8 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, " }\n" "#endif\n"); + + jdf_generate_code_cache_awareness_update(jdf, f); coutput("#if defined(PARSEC_DEBUG_NOISIER)\n" @@ -7183,6 +7199,7 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, string_arena_free(sa); string_arena_free(sa2); string_arena_free(sa3); + string_arena_free(osa); } static void jdf_generate_code_hook(const jdf_t *jdf, @@ -7191,13 +7208,15 @@ static void jdf_generate_code_hook(const jdf_t *jdf, const char *name) { jdf_def_list_t* type_property; - string_arena_t *sa, *sa2; + string_arena_t *sa, *sa2, *osa; assignment_info_t ai; init_from_data_info_t ai2; jdf_dataflow_t *fl; int di; char* output; + osa = string_arena_new(32); + jdf_find_property(body->properties, "type", &type_property); if(NULL != type_property) { if(JDF_VAR != type_property->expr->op) { @@ -7270,12 +7289,23 @@ static void jdf_generate_code_hook(const jdf_t *jdf, if(fl->flow_flags & JDF_FLOW_TYPE_CTL) continue; /* control flow, nothing to store */ - coutput(" data_repo_entry_t *e%s = this_task->data._f_%s.source_repo_entry;\n" - " if( (NULL != e%s) && (e%s->sim_exec_date > this_task->sim_exec_date) )\n" - " this_task->sim_exec_date = e%s->sim_exec_date;\n", - fl->varname, fl->varname, - fl->varname, fl->varname, - fl->varname); + string_arena_t *sa = string_arena_new(64); + dump_parametrized_flow_loop_if_parametrized(fl, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + coutput("%s data_repo_entry_t *e%s = this_task->data._f_%s%s.source_repo_entry;\n" + "%s if( (NULL != e%s) && (e%s->sim_exec_date > this_task->sim_exec_date) )\n" + "%s this_task->sim_exec_date = e%s->sim_exec_date;\n", + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, fl->varname, + INDENTATION_IF_PARAMETRIZED(fl), fl->varname); + + string_arena_init(sa); + + dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + string_arena_free(sa); } coutput(" if( this_task->task_class->sim_cost_fct != NULL ) {\n" " this_task->sim_exec_date += this_task->task_class->sim_cost_fct(this_task);\n" @@ -7297,7 +7327,6 @@ static void jdf_generate_code_hook(const jdf_t *jdf, (fl->flow_flags & JDF_FLOW_TYPE_WRITE) ) { string_arena_t *sa = string_arena_new(64); - string_arena_t *osa = string_arena_new(16); dump_parametrized_flow_loop_if_parametrized(fl, " ", sa); coutput("%s", string_arena_get_string(sa)); @@ -7318,7 +7347,6 @@ static void jdf_generate_code_hook(const jdf_t *jdf, coutput("%s", string_arena_get_string(sa)); string_arena_free(sa); - string_arena_free(osa); } } @@ -7340,6 +7368,7 @@ static void jdf_generate_code_hook(const jdf_t *jdf, string_arena_free(sa); string_arena_free(sa2); + string_arena_free(osa); hook_end_block: if( NULL != type_property) From 6160d5e17e94c8d6ff2e20f10f5a2aae42a813e6 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 14 Oct 2022 13:57:50 -0400 Subject: [PATCH 026/157] probably dont need this loop --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index f2e1d6761..42d635ecf 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5871,7 +5871,7 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ const char *spaces) { int dataindex; - string_arena_t *sa, *sa_arena, *sa_datatype, *sa_count, *osa ; + string_arena_t *sa, *sa_arena, *sa_datatype, *sa_count, *osa, *sa_loop ; expr_info_t info = EMPTY_EXPR_INFO; if( (NULL != call) && (NULL != call->var) ) { @@ -5906,6 +5906,7 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ sa_arena = string_arena_new(64); sa_datatype = string_arena_new(64); sa_count = string_arena_new(64); + sa_loop = string_arena_new(64); /* This is the case of a pure output data. There's no reshaping. New datacopy should be directly * allocated using the correct arena/datatype. */ @@ -5923,10 +5924,19 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ coutput("%s /* Flow %s [%d] dependency [%d] pure output data */\n", spaces, flow->varname, flow->flow_index, dl->dep_index); + + // a priori, the loop should already be generated when entering jdf_generate_code_call_init_output + // dump_parametrized_flow_loop_if_parametrized(flow, " ", sa_loop); + // coutput("%s", string_arena_get_string(sa_loop)); + coutput("%s if( NULL == (chunk = this_task->data._f_%s%s.data_in) ) {\n" "%s /* No data set up by predecessor */\n", spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), spaces); + + // string_arena_init(sa_loop); + // dump_parametrized_flow_loop_end_if_parametrized(flow, " ", sa_loop); + // coutput("%s", string_arena_get_string(sa_loop)); coutput("%s chunk = parsec_arena_get_copy(%s->arena, %s, target_device, %s);\n" "%s chunk->original->owner_device = target_device;\n", From 86dba4a6de7b971c270c20d143e1afef75f1d948 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 14 Oct 2022 14:37:21 -0400 Subject: [PATCH 027/157] init the parametrized data flow at the right place --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 54 +++++++++++++--------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 42d635ecf..e3b6093d4 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -3165,25 +3165,19 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr // Generate the code to initialize the parametrized flow variables - for(jdf_dataflow_t *fl=f->dataflow; NULL != fl; fl=fl->next) { - if( NULL != fl->local_variables ) { // If is parametrized - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(32); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "max parametrized dataflow"; - - jdf_expr_t *variable = jdf_expr_lv_first(fl->local_variables); - assert(variable->op == JDF_RANGE); - jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; - - coutput(" this_task->data._f_%s = alloca(sizeof(parsec_data_pair_t)*((%s)+1));\n", - fl->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); - coutput(" assert( NULL != this_task->data._f_%s );\n", fl->varname); - coutput(" memset(this_task->data._f_%s, 0, sizeof(parsec_data_pair_t)*((%s)+1));\n", - fl->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); - } - } + // for(jdf_dataflow_t *fl=f->dataflow; NULL != fl; fl=fl->next) { + // if( NULL != fl->local_variables ) { // If is parametrized + // expr_info_t expr_info = EMPTY_EXPR_INFO; + // expr_info.sa = string_arena_new(32); + // expr_info.prefix = ""; + // expr_info.suffix = ""; + // expr_info.assignments = "max parametrized dataflow"; + + // jdf_expr_t *variable = jdf_expr_lv_first(fl->local_variables); + // assert(variable->op == JDF_RANGE); + // jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; + // } + // } for(vl = f->locals; vl != NULL; vl = vl->next) coutput(" int %s = this_task->locals.%s.value; /* retrieve value saved during the last iteration */\n", vl->name, vl->name); @@ -3319,10 +3313,28 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr struct jdf_dataflow *dataflow = f->dataflow; for(idx = 0; NULL != dataflow; idx++, dataflow = dataflow->next ) { - if(FLOW_IS_PARAMETRIZED(dataflow)) { + // If the flow is parametrized, the data is an "array" of data + if(FLOW_IS_PARAMETRIZED(dataflow)) + { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(32); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "max parametrized dataflow"; + + jdf_expr_t *variable = jdf_expr_lv_first(dataflow->local_variables); + assert(variable->op == JDF_RANGE); + jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; + + coutput("%s new_task->data._f_%s = alloca(sizeof(parsec_data_pair_t)*((%s)+1));\n", + indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); + coutput("%s assert( NULL != new_task->data._f_%s );\n", indent(nesting), dataflow->varname); + coutput("%s memset(new_task->data._f_%s, 0, sizeof(parsec_data_pair_t)*((%s)+1));\n", + indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); + nesting++; } - + string_arena_t *osa = string_arena_new(16); string_arena_t *sa = string_arena_new(256); From 02fb7cf6fc73f1f1655476e1654895cdab2b39ba Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 14 Oct 2022 15:00:55 -0400 Subject: [PATCH 028/157] add a comment before the loop for parametrized flows --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index e3b6093d4..36b5b2a15 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -605,9 +605,10 @@ void dump_parametrized_flow_loop(const jdf_dataflow_t *flow, const char *iterato jdf_expr_t *to = variable->jdf_ta2; jdf_expr_t *step = variable->jdf_ta3; - string_arena_add_string(sa, "%sfor(int %s=%s;", + string_arena_add_string(sa, "%s// Iterating over the parametrized flow %s\n%sfor(int %s=%s;", indent, - iterator_name, + f->varname, + indent, iterator_name, dump_expr((void**)from, &expr_info)); string_arena_add_string(sa, "%s<=%s;", iterator_name, @@ -6016,7 +6017,7 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, string_arena_t *osa; osa = string_arena_new(64); - dump_parametrized_flow_loop_if_parametrized(flow, "\n\n ", osa); + dump_parametrized_flow_loop_if_parametrized(flow, " ", osa); coutput("%s", string_arena_get_string(osa)); coutput("\n" From 43e95ea8656db875e22bc28ed74489348be1caa3 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 14 Oct 2022 16:19:35 -0400 Subject: [PATCH 029/157] discard variable if flow level (jdf_dump_context_assignment) --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 8 +++++++ .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 36b5b2a15..6a2f241ff 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7658,6 +7658,7 @@ static void jdf_generate_code_release_deps(const jdf_t *jdf, const jdf_function_ "\n"); } +// TODO: not finished yet (parametrized flows wont work) static char *jdf_dump_context_assignment(string_arena_t *sa_open, const jdf_t *jdf, const jdf_function_entry_t *sourcef, @@ -7817,6 +7818,13 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, call_ld = jdf_expr_lv_next(call->local_defs, call_ld); continue; /* This local define was alredy issued above as part of the call */ } + if( variable_is_flow_level_util(flow, ld) ) + { + string_arena_add_string(sa_open, "%s%s// skipping local %s because belongs to the flow level\n", + prefix, indent(nbopen), ld->alias); + + continue; + } string_arena_add_string(sa_open, "%s%s {\n" "%s%s int %s; // TODO\n", prefix, indent(nbopen), diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 816def1ce..9444e4c55 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -53,6 +53,27 @@ util_dump_array_offset_if_parametrized(string_arena_t *sa, const jdf_dataflow_t return string_arena_get_string(sa); } +/** + * VARIABLE_IS_FLOW_LEVEL + * Tells whether a variable is a flow level variable or not. + * @param [IN] var: the variable to test. + * @param [IN] flow: the flow to test. + * + * @return a boolean value. + */ +#define VARIABLE_IS_FLOW_LEVEL(flow, var) \ + variable_is_flow_level_util(flow, var) + +static inline int variable_is_flow_level_util(const jdf_dataflow_t *flow, const jdf_expr_t *var) +{ + for(jdf_expr_t *flow_variable=flow->local_variables; flow_variable!=NULL; flow_variable=flow_variable->next) { + if (strcmp(flow_variable->alias, var->alias) == 0) { + return 1; + } + } + + return 0; +} /** * UTIL_DUMP_LIST_FIELD: From 3b53007a3871712cd42623a50429e715787a6f26 Mon Sep 17 00:00:00 2001 From: cflinto Date: Sun, 16 Oct 2022 18:41:21 -0400 Subject: [PATCH 030/157] add TODOs --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 6a2f241ff..89ec20f40 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1902,12 +1902,16 @@ static void jdf_generate_range_min_without_fn(const jdf_t *jdf, const jdf_expr_t for(ld = jdf_expr_lv_first(expr->local_variables); NULL != ld; ld = jdf_expr_lv_next(expr->local_variables, ld)) { assert(ld->ldef_index != -1); if( JDF_RANGE == ld->op ) - coutput(" { /* New scope for local definition '%s' */ \n" - " int %s = %s;\n" - " %s->ldef[%d].value = %s;\n", - ld->alias, - ld->alias, dump_expr((void**)ld->jdf_ta1, &info), - asname, ld->ldef_index, ld->alias); + // TODO: how should we handle this if the variable is at the flow scope? + //if(!VARIABLE_IS_FLOW_LEVEL(flow, ld)) + { + coutput(" { /* New scope for local definition '%s' */ \n" + " int %s = %s;\n" + " %s->ldef[%d].value = %s;\n", + ld->alias, + ld->alias, dump_expr((void**)ld->jdf_ta1, &info), + asname, ld->ldef_index, ld->alias); + } else coutput(" { /* New scope for local definition '%s' */ \n" " int %s = %s;\n" @@ -4304,7 +4308,7 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f "static const parsec_task_class_t %s = {\n" " .name = \"%s\",\n" " .task_class_id = %d,\n" - " .nb_flows = %d,\n" + " .nb_flows = %d,\n" // TODO change nb_flows when parametrized " .nb_parameters = %d,\n" " .nb_locals = %d,\n" " .task_class_type = PARSEC_TASK_CLASS_TYPE_PTG,\n", From 9e8c5f9604d6cc1b668f1578951b0958f26e96b4 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 17 Oct 2022 14:23:32 -0400 Subject: [PATCH 031/157] move allocation of the flow data array to the right place + changed the RELEASE_DEP_OUTPUT macro --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 71 +++++++++++++--------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 89ec20f40..e1864806a 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1795,14 +1795,16 @@ static void jdf_generate_structure(jdf_t *jdf) coutput("/* Release dependencies output macro */\n" "#if defined(PARSEC_DEBUG_NOISIER)\n" - "#define RELEASE_DEP_OUTPUT(ES, DEPO, TASKO, DEPI, TASKI, RSRC, RDST, DATA)\\\n" + "#define RELEASE_DEP_OUTPUT(ES, DEPO, OFFSETO, TASKO, DEPI, OFFSETI, TASKI, RSRC, RDST, DATA)\\\n" " do { \\\n" " char tmp1[128], tmp2[128]; (void)tmp1; (void)tmp2;\\\n" - " PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, \"thread %%d VP %%d explore deps from %%s:%%s to %%s:%%s (from rank %%d to %%d) base ptr %%p\",\\\n" + " PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, \"thread %d VP %d explore deps from %s:%s to %s:%s (from rank %d to %d) base ptr %p\",\\\n" " (NULL != (ES) ? (ES)->th_id : -1), (NULL != (ES) ? (ES)->virtual_process->vp_id : -1),\\\n" - " DEPO, parsec_task_snprintf(tmp1, 128, (parsec_task_t*)(TASKO)),\\\n" - " DEPI, parsec_task_snprintf(tmp2, 128, (parsec_task_t*)(TASKI)), (RSRC), (RDST), (DATA));\\\n" - " } while(0)\n" + " DEPO, OFFSETO, parsec_task_snprintf(tmp1, 128, (parsec_task_t*)(TASKO)),\\\n" + " DEPI, OFFSETI, parsec_task_snprintf(tmp2, 128, (parsec_task_t*)(TASKI)), (RSRC), (RDST), (DATA));\\\n" + " } while(0)\\\n" + "#define RELEASE_DEP_OUTPUT(ES, DEPO, TASKO, DEPI, TASKI, RSRC, RDST, DATA)\\\n" + " RELEASE_DEP_OUTPUT(ES, DEPO, \"\", TASKO, DEPI, \"\", TASKI, RSRC, RDST, DATA)\\\n" "#define ACQUIRE_FLOW(TASKI, DEPI, FUNO, DEPO, LOCALS, PTR)\\\n" " do { \\\n" " char tmp1[128], tmp2[128]; (void)tmp1; (void)tmp2;\\\n" @@ -1814,6 +1816,7 @@ static void jdf_generate_structure(jdf_t *jdf) "#define RELEASE_DEP_OUTPUT(ES, DEPO, TASKO, DEPI, TASKI, RSRC, RDST, DATA)\n" "#define ACQUIRE_FLOW(TASKI, DEPI, TASKO, DEPO, LOCALS, PTR)\n" "#endif\n"); + string_arena_free(sa1); string_arena_free(sa2); } @@ -3317,34 +3320,16 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr { struct jdf_dataflow *dataflow = f->dataflow; for(idx = 0; NULL != dataflow; idx++, dataflow = dataflow->next ) { - - // If the flow is parametrized, the data is an "array" of data - if(FLOW_IS_PARAMETRIZED(dataflow)) - { - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(32); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "max parametrized dataflow"; - - jdf_expr_t *variable = jdf_expr_lv_first(dataflow->local_variables); - assert(variable->op == JDF_RANGE); - jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; - - coutput("%s new_task->data._f_%s = alloca(sizeof(parsec_data_pair_t)*((%s)+1));\n", - indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); - coutput("%s assert( NULL != new_task->data._f_%s );\n", indent(nesting), dataflow->varname); - coutput("%s memset(new_task->data._f_%s, 0, sizeof(parsec_data_pair_t)*((%s)+1));\n", - indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); - - nesting++; - } - string_arena_t *osa = string_arena_new(16); string_arena_t *sa = string_arena_new(256); dump_parametrized_flow_loop_if_parametrized(dataflow, indent(nesting), sa); coutput("%s", string_arena_get_string(sa)); + + // increase nesting if parametrized + if( FLOW_IS_PARAMETRIZED(dataflow) ) { + nesting++; + } coutput("%s new_task->data._f_%s%s.source_repo_entry = NULL;\n" "%s new_task->data._f_%s%s.source_repo = NULL;\n" @@ -3968,6 +3953,35 @@ static void jdf_generate_internal_init(const jdf_t *jdf, const jdf_function_entr coutput(" this_task->status = PARSEC_TASK_STATUS_COMPLETE;\n"); } + // If the flow is parametrized, the data is an "array" of data + jdf_dataflow_t *dataflow = f->dataflow; + if(dataflow && FLOW_IS_PARAMETRIZED(dataflow)) + { + string_arena_t *osa = string_arena_new(16); + string_arena_t *sa = string_arena_new(256); + + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(32); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "max parametrized dataflow"; + + jdf_expr_t *variable = jdf_expr_lv_first(dataflow->local_variables); + assert(variable->op == JDF_RANGE); + jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; + + coutput("\n%s this_task->data._f_%s = alloca(sizeof(parsec_data_pair_t)*((%s)+1));\n", + indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); + coutput("%s assert( NULL != this_task->data._f_%s );\n", indent(nesting), dataflow->varname); + coutput("%s memset(this_task->data._f_%s, 0, sizeof(parsec_data_pair_t)*((%s)+1));\n", + indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); + + string_arena_free(sa); + string_arena_free(osa); + + nesting--; + } + string_arena_free(sa1); string_arena_free(sa2); coutput("\n PARSEC_AYU_REGISTER_TASK(&%s_%s);\n", jdf_basename, f->fname); @@ -3976,6 +3990,7 @@ static void jdf_generate_internal_init(const jdf_t *jdf, const jdf_function_entr if( f->user_defines & JDF_FUNCTION_HAS_UD_DEPENDENCIES_FUNS ) { coutput(" PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, \"Allocating dependencies array for %s (user-defined allocator)\\n\");\n", fname); + // TODO: if the flow is parametrized: need to be smarter coutput(" __parsec_tp->super.super.dependencies_array[%d] = %s(__parsec_tp);\n", f->task_class_id, jdf_property_get_function(f->properties, JDF_PROP_UD_ALLOC_DEPS_FN_NAME, NULL)); } else { From 7b5cb338fc7d7a098478fb19015580d80484f45e Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 17 Oct 2022 14:50:10 -0400 Subject: [PATCH 032/157] make it actually compile --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 52 +++++++++++++--------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index e1864806a..e164fd5ba 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1794,28 +1794,36 @@ static void jdf_generate_structure(jdf_t *jdf) } coutput("/* Release dependencies output macro */\n" - "#if defined(PARSEC_DEBUG_NOISIER)\n" - "#define RELEASE_DEP_OUTPUT(ES, DEPO, OFFSETO, TASKO, DEPI, OFFSETI, TASKI, RSRC, RDST, DATA)\\\n" - " do { \\\n" - " char tmp1[128], tmp2[128]; (void)tmp1; (void)tmp2;\\\n" - " PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, \"thread %d VP %d explore deps from %s:%s to %s:%s (from rank %d to %d) base ptr %p\",\\\n" - " (NULL != (ES) ? (ES)->th_id : -1), (NULL != (ES) ? (ES)->virtual_process->vp_id : -1),\\\n" - " DEPO, OFFSETO, parsec_task_snprintf(tmp1, 128, (parsec_task_t*)(TASKO)),\\\n" - " DEPI, OFFSETI, parsec_task_snprintf(tmp2, 128, (parsec_task_t*)(TASKI)), (RSRC), (RDST), (DATA));\\\n" - " } while(0)\\\n" - "#define RELEASE_DEP_OUTPUT(ES, DEPO, TASKO, DEPI, TASKI, RSRC, RDST, DATA)\\\n" - " RELEASE_DEP_OUTPUT(ES, DEPO, \"\", TASKO, DEPI, \"\", TASKI, RSRC, RDST, DATA)\\\n" - "#define ACQUIRE_FLOW(TASKI, DEPI, FUNO, DEPO, LOCALS, PTR)\\\n" - " do { \\\n" - " char tmp1[128], tmp2[128]; (void)tmp1; (void)tmp2;\\\n" - " PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, \"task %%s acquires flow %%s from %%s %%s data ptr %%p\",\\\n" - " parsec_task_snprintf(tmp1, 128, (parsec_task_t*)(TASKI)), (DEPI),\\\n" - " (DEPO), parsec_snprintf_assignments(tmp2, 128, (FUNO), (parsec_assignment_t*)(LOCALS)), (PTR));\\\n" - " } while(0)\n" - "#else\n" - "#define RELEASE_DEP_OUTPUT(ES, DEPO, TASKO, DEPI, TASKI, RSRC, RDST, DATA)\n" - "#define ACQUIRE_FLOW(TASKI, DEPI, TASKO, DEPO, LOCALS, PTR)\n" - "#endif\n"); + "#if defined(PARSEC_DEBUG_NOISIER)\n" + "// for parametrized flow\n" + "#define RELEASE_DEP_OUTPUT_PARAMETRIZED(ES, DEPO, OFFSETO, TASKO, DEPI, OFFSETI, TASKI, RSRC, RDST, DATA)\\\n" + "do { \\\n" + " char tmp1[128], tmp2[128]; (void)tmp1; (void)tmp2;\\\n" + " PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, \"thread %%d VP %%d explore deps from %%s:%%s to %%s:%%s (from rank %%d to %%d) base ptr %%p\",\\\n" + " (NULL != (ES) ? (ES)->th_id : -1), (NULL != (ES) ? (ES)->virtual_process->vp_id : -1),\\\n" + " DEPO, OFFSETO, parsec_task_snprintf(tmp1, 128, (parsec_task_t*)(TASKO)),\\\n" + " DEPI, OFFSETI, parsec_task_snprintf(tmp2, 128, (parsec_task_t*)(TASKI)), (RSRC), (RDST), (DATA));\\\n" + "} while(0)\n" + "// for non-parametrized flow\n" + "#define RELEASE_DEP_OUTPUT(ES, DEPO, TASKO, DEPI, TASKI, RSRC, RDST, DATA)\\\n" + "do { \\\n" + " char tmp1[128], tmp2[128]; (void)tmp1; (void)tmp2;\\\n" + " PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, \"thread %%d VP %%d explore deps from %%s:%%s to %%s:%%s (from rank %%d to %%d) base ptr %%p\",\\\n" + " (NULL != (ES) ? (ES)->th_id : -1), (NULL != (ES) ? (ES)->virtual_process->vp_id : -1),\\\n" + " DEPO, parsec_task_snprintf(tmp1, 128, (parsec_task_t*)(TASKO)),\\\n" + " DEPI, parsec_task_snprintf(tmp2, 128, (parsec_task_t*)(TASKI)), (RSRC), (RDST), (DATA));\\\n" + "} while(0)\n" + "#define ACQUIRE_FLOW(TASKI, DEPI, FUNO, DEPO, LOCALS, PTR)\\\n" + "do { \\\n" + " char tmp1[128], tmp2[128]; (void)tmp1; (void)tmp2;\\\n" + " PARSEC_DEBUG_VERBOSE(20, parsec_debug_output, \"task %%s acquires flow %%s from %%s %%s data ptr %%p\",\\\n" + " parsec_task_snprintf(tmp1, 128, (parsec_task_t*)(TASKI)), (DEPI),\\\n" + " (DEPO), parsec_snprintf_assignments(tmp2, 128, (FUNO), (parsec_assignment_t*)(LOCALS)), (PTR));\\\n" + "} while(0)\n" + "#else\n" + "#define RELEASE_DEP_OUTPUT(ES, DEPO, TASKO, DEPI, TASKI, RSRC, RDST, DATA)\n" + "#define ACQUIRE_FLOW(TASKI, DEPI, TASKO, DEPO, LOCALS, PTR)\n" + "#endif\n"); string_arena_free(sa1); string_arena_free(sa2); From 24afda587acbf973f697edea766b2b4b0a4089b4 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 18 Oct 2022 10:38:06 -0400 Subject: [PATCH 033/157] add flag to enable parametrized flows --- CMakeLists.txt | 2 + parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 2 +- parsec/interfaces/ptg/ptg-compiler/parsec.y | 49 +++------------------ 3 files changed, 8 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fc094ff7..e1a4c9743 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -157,6 +157,8 @@ option(PARSEC_DIST_PRIORITIES "Favor the communications that unlock the most prioritary tasks" ON) option(PARSEC_DIST_COLLECTIVES "Use optimized asynchronous operations where collective communication pattern is detected" ON) +option(PARSEC_ALLOW_PARAMETRIZED_FLOWS + "Enables parametrized flows" OFF) set (PARSEC_DIST_SHORT_LIMIT 1 CACHE STRING "Use the short protocol (no flow control) for messages smaller than the limit in KB. Performs better if smaller than the MTU") diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index e164fd5ba..0675da699 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -4868,7 +4868,7 @@ static void jdf_generate_constructor( const jdf_t* jdf ) string_arena_get_string(jdf->termdet_init_line), jdf_basename, jdf_basename, string_arena_get_string(sa1)); - +// TODO use uintX_t instead of uint8 if MAX_DEP_IN_COUNT or MAX_DEP_OUT > 8 ? (in the task structure) /* Prepare the functions */ coutput(" for( i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" " __parsec_tp->super.super.task_classes_array[i] = tc = malloc(sizeof(parsec_task_class_t));\n" diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 46945d16a..8183a0ceb 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -954,30 +954,6 @@ dataflow: optional_flow_flags VAR flow_specifier dependencies { named_expr } } -/* -jdf_dep_t *d = new(jdf_dep_t); - jdf_expr_t *expr; - jdf_expr_t *expr_remote; - jdf_expr_t *expr_data; - jdf_def_list_t* property = $4; - jdf_def_list_t* property_remote = $4; - jdf_def_list_t* property_data = $4; - - d->local_defs = $2; -*/ - -/* -property: VAR ASSIGNMENT expr_simple - { - jdf_def_list_t* assign = new(jdf_def_list_t); - assign->next = NULL; - assign->name = strdup($1); - assign->expr = $3; - JDF_OBJECT_LINENO(assign) = JDF_OBJECT_LINENO($3); - $$ = assign; - } -*/ - jdf_flow_specifier_t *flow_specifier = $3; jdf_dataflow_t *flow = new(jdf_dataflow_t); @@ -987,26 +963,6 @@ property: VAR ASSIGNMENT expr_simple flow->array_offset = flow_specifier->array_offset; flow->deps = $4; -/* - // add the dataflow bound variables to each part of each dependency - for(jdf_dep_t *dep = flow->deps; dep != NULL; dep = dep->next) { - jdf_def_list_t *def = dep->local_defs; - - // variables defined in the whole dataflow - jdf_expr_t *dataflow_defs = flow_specifier->expr; - - // add them to the current dependency - add_locals_to_dep(dep, dataflow_defs); - } -*/ - -/* - // add the dataflow bound variables to each dependency - for(jdf_dep_t *dep = flow->deps; dep != NULL; dep = dep->next) { - add_defs_to_flow(flow, flow_specifier->expr); - } -*/ - $$ = flow; if( NULL == $4) { JDF_OBJECT_LINENO($$) = current_lineno; @@ -1048,6 +1004,11 @@ array_offset_or_nothing: array_offset array_offset: PROPERTIES_ON expr_simple PROPERTIES_OFF { +#ifndef PARSEC_ALLOW_PARAMETRIZED_FLOWS + jdf_fatal(current_lineno, "Flow cannot be parametrized. Set the PARSEC_ALLOW_PARAMETRIZED_FLOWS flag to enable them.\n"); + YYERROR; +#endif // PARSEC_ALLOW_PARAMETRIZED_FLOWS + $$ = $2; } /*| From 675eb785686e551cef44ee2d21aa77b2ff3a8da8 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 18 Oct 2022 10:43:50 -0400 Subject: [PATCH 034/157] clean --- parsec/interfaces/ptg/ptg-compiler/parsec.y | 213 +------------------- 1 file changed, 2 insertions(+), 211 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 8183a0ceb..9013a3144 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -115,216 +115,6 @@ jdf_create_properties_list( const char* name, return property; } - -// // used structures: -// struct jdf_dep { -// struct jdf_object_t super; -// jdf_dep_t *next; -// struct jdf_expr *local_defs; /**< named ranges can specify sets of deps from this single dep */ -// struct jdf_guarded_call *guard; /**< there can be conditions and ternaries to produce the calls */ -// jdf_datatransfer_type_t datatype_local; /**< type reshaping */ -// jdf_datatransfer_type_t datatype_remote; /**< type for packing & sending to a remote */ -// jdf_datatransfer_type_t datatype_data; /**< type applied to the data collection when reading or writing */ -// jdf_dep_flags_t dep_flags; /**< flags (see JDF_DEP_* above) */ -// uint8_t dep_index; /**< the index of the dependency in the context of the function */ -// uint8_t dep_datatype_index; /**< the smallest index of all dependencies -// * sharing a common remote datatype. */ -// }; - -// typedef enum { JDF_GUARD_UNCONDITIONAL, -// JDF_GUARD_BINARY, -// JDF_GUARD_TERNARY } jdf_guard_type_t; - -// typedef struct jdf_guarded_call { -// struct jdf_object_t super; -// jdf_guard_type_t guard_type; -// struct jdf_expr *guard; -// struct jdf_def_list *properties; -// struct jdf_call *calltrue; -// struct jdf_call *callfalse; -// } jdf_guarded_call_t; - -// typedef struct jdf_call { -// struct jdf_object_t super; -// struct jdf_expr *local_defs; /**< Each call can have some local indicies, allowing to define sets of deps */ -// char *var; /**< If func_or_mem is a function, var is the name of the flow on that function */ -// struct jdf_expr *array_offset; /**< Offset required if var is an array */ -// char *func_or_mem; /**< string of the function (task class) or data collection referred to in this call */ -// struct jdf_expr *parameters; /**< list of parameters for that task class / data collection */ -// } jdf_call_t; - - -// typedef enum { JDF_EQUAL, -// JDF_NOTEQUAL, -// JDF_AND, -// JDF_OR, -// JDF_XOR, -// JDF_LESS, -// JDF_LEQ, -// JDF_MORE, -// JDF_MEQ, -// JDF_NOT, -// JDF_PLUS, -// JDF_MINUS, -// JDF_TIMES, -// JDF_DIV, -// JDF_MODULO, -// JDF_SHL, -// JDF_SHR, -// JDF_RANGE, -// JDF_TERNARY, -// JDF_VAR, -// JDF_STRING, -// JDF_CST, -// JDF_C_CODE -// } jdf_expr_operand_t; - -// #define JDF_OP_IS_UNARY(op) ( (op) == JDF_NOT ) -// #define JDF_OP_IS_TERNARY(op) ( (op) == JDF_TERNARY ) -// #define JDF_OP_IS_CST(op) ( (op) == JDF_CST ) -// #define JDF_OP_IS_STRING(op) ( (op) == JDF_STRING ) -// #define JDF_OP_IS_VAR(op) ( (op) == JDF_VAR ) -// #define JDF_OP_IS_C_CODE(op) ( (op) == JDF_C_CODE ) -// #define JDF_OP_IS_BINARY(op) ( !( JDF_OP_IS_UNARY(op) || \ -// JDF_OP_IS_TERNARY(op) || \ -// JDF_OP_IS_CST(op) || \ -// JDF_OP_IS_VAR(op) || \ -// JDF_OP_IS_C_CODE(op)) ) - -// typedef struct jdf_expr { -// struct jdf_object_t super; -// struct jdf_expr *next; -// struct jdf_expr *next_inline; -// struct jdf_expr *local_variables; /**< the list of named local variables that are defined with -// * a named range and are used to define this expression */ -// jdf_expr_operand_t op; -// char *protected_by; /**< if non NULL the function definition if protected by this #define */ -// char *alias; /**< if alias != NULL, this expression defines a local variable named alias */ -// int ldef_index; /**< if alias != NULL, the local variable is stored in ldef[ldef_index] */ -// int scope; /**< if alias != NULL, scope is the scope of that definition -// * (this is used internally by the parser to compute how many definitions to -// * remove; this is not used outside the parser) */ -// union { -// struct { -// struct jdf_expr *arg1; -// struct jdf_expr *arg2; -// struct jdf_expr *arg3; -// } ternary; -// struct { -// struct jdf_expr *arg1; -// struct jdf_expr *arg2; -// } binary; -// struct { -// struct jdf_expr *arg; -// } unary; -// char *varname; -// struct { -// int type; -// union{ -// struct { -// char *code; -// int lineno; -// char *fname; -// jdf_function_entry_t *function_context; -// } c_code; -// int32_t int32_cstval; -// int64_t int64_cstval; -// float float_cstval; -// double double_cstval; -// } w; -// } v; -// } u; -// } jdf_expr_t; - -/* -static void add_local_to_expr(jdf_expr_t *expr, jdf_expr_t *local) -{ - if(expr->) -} -*/ - -static void add_local_to_call( jdf_call_t *call, jdf_expr_t *local ) -{ - jdf_expr_t *l = call->local_defs; - - jdf_expr_t *newdef = new(jdf_expr_t); - memcpy( newdef, local, sizeof(jdf_expr_t) ); - newdef->next = call->local_defs; - call->local_defs = newdef; - - printf( "Adding local %s to call %s\n", local->alias, call->func_or_mem ); - - //add_local_to_expr( call->parameters, local ); -} - -static void add_local_to_guarded_call(jdf_guarded_call_t *call, jdf_expr_t *variable) -{ - jdf_expr_t *e; - jdf_def_list_t *def; - - if(call->guard_type == JDF_GUARD_UNCONDITIONAL) { - add_local_to_call(call->calltrue, variable); -/* - jdf_expr_t *newdef = new(jdf_expr_t); - newdef->op = JDF_VAR; - newdef->u.varname = strdup(variable->alias); - newdef->next = call->local_defs; - call->local_defs = newdef; -*/ - } - else if(call->guard_type == JDF_GUARD_BINARY) { - add_local_to_call(call->calltrue, variable); - //add_local_to_call(call->callfalse, variable); - } - else if(call->guard_type == JDF_GUARD_TERNARY) { - add_local_to_call(call->calltrue, variable); - add_local_to_call(call->callfalse, variable); - } - - printf("Adding local %s to guarded call %s\n", variable->alias, call->calltrue->func_or_mem); -} - -static void add_locals_to_dep(jdf_dep_t *dep, jdf_expr_t *variables) -{ -/* -// each variable that is defined in the dataflow: - while( dataflow_defs != NULL ) { - jdf_def_list_t *newdef = new(jdf_def_list_t); - newdef->name = strdup(dataflow_defs->alias); - printf("added def %s to flow %s\n", newdef->name, flow->varname); - newdef->next = def; - def = newdef; - dataflow_defs = dataflow_defs->next; - } - - dep->local_defs = def; -*/ - - - jdf_expr_t *v; - - // for each variable to add - for(v = variables; NULL != v; v = v->next) { - jdf_expr_t *def = dep->local_defs; - - // add the current local to te guarded call - add_local_to_guarded_call(dep->guard, v); - - // then inside the dep structure - jdf_expr_t *newdef = new(jdf_expr_t); - memcpy( newdef, v, sizeof(jdf_expr_t) ); - newdef->next = dep->local_defs; - dep->local_defs = newdef; - - printf( "Adding local %s to dep %p\n", v->alias, dep ); - - /*newdef->op = JDF_VAR; - newdef->u.v.varname = strdup(v->alias); - newdef->next = def; - dep->local_defs = newdef;*/ - } -} - static jdf_data_entry_t* jdf_find_or_create_data(jdf_t* jdf, const char* dname) { jdf_data_entry_t* data = jdf->data; @@ -1005,7 +795,8 @@ array_offset_or_nothing: array_offset array_offset: PROPERTIES_ON expr_simple PROPERTIES_OFF { #ifndef PARSEC_ALLOW_PARAMETRIZED_FLOWS - jdf_fatal(current_lineno, "Flow cannot be parametrized. Set the PARSEC_ALLOW_PARAMETRIZED_FLOWS flag to enable them.\n"); + jdf_fatal(current_lineno, "Flow cannot be parametrized (line %d). Set the PARSEC_ALLOW_PARAMETRIZED_FLOWS flag to enable them.\n", + JDF_OBJECT_LINENO($2)); YYERROR; #endif // PARSEC_ALLOW_PARAMETRIZED_FLOWS From 87ce65e878a633f51131a52d5ddef4f8ea5f8bae Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 18 Oct 2022 11:37:44 -0400 Subject: [PATCH 035/157] add #cmakedefine in parsec_options.h.in --- CMakeLists.txt | 2 +- parsec/include/parsec/parsec_options.h.in | 1 + parsec/interfaces/ptg/ptg-compiler/parsec.y | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e1a4c9743..6069c29af 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -158,7 +158,7 @@ option(PARSEC_DIST_PRIORITIES option(PARSEC_DIST_COLLECTIVES "Use optimized asynchronous operations where collective communication pattern is detected" ON) option(PARSEC_ALLOW_PARAMETRIZED_FLOWS - "Enables parametrized flows" OFF) + "Enable parametrized flows" OFF) set (PARSEC_DIST_SHORT_LIMIT 1 CACHE STRING "Use the short protocol (no flow control) for messages smaller than the limit in KB. Performs better if smaller than the MTU") diff --git a/parsec/include/parsec/parsec_options.h.in b/parsec/include/parsec/parsec_options.h.in index efed86686..6bc324597 100644 --- a/parsec/include/parsec/parsec_options.h.in +++ b/parsec/include/parsec/parsec_options.h.in @@ -74,6 +74,7 @@ #cmakedefine PARSEC_DIST_THREAD #cmakedefine PARSEC_DIST_PRIORITIES #cmakedefine PARSEC_DIST_COLLECTIVES +#cmakedefine PARSEC_ALLOW_PARAMETRIZED_FLOWS #define PARSEC_DIST_SHORT_LIMIT @PARSEC_DIST_SHORT_LIMIT@ /* GPU Support */ diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 9013a3144..701b8b530 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -794,11 +794,11 @@ array_offset_or_nothing: array_offset array_offset: PROPERTIES_ON expr_simple PROPERTIES_OFF { -#ifndef PARSEC_ALLOW_PARAMETRIZED_FLOWS +#if !defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) jdf_fatal(current_lineno, "Flow cannot be parametrized (line %d). Set the PARSEC_ALLOW_PARAMETRIZED_FLOWS flag to enable them.\n", JDF_OBJECT_LINENO($2)); YYERROR; -#endif // PARSEC_ALLOW_PARAMETRIZED_FLOWS +#endif $$ = $2; } From e51a040d0a7d518f5d5ba680b5931be54231229c Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 18 Oct 2022 15:58:29 -0400 Subject: [PATCH 036/157] change some behaviors when PARSEC_ALLOW_PARAMETRIZED_FLOWS is defined --- .../parsec/parsec_description_structures.h | 7 ++++ parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 42 ++++++++++++++++--- 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/parsec/include/parsec/parsec_description_structures.h b/parsec/include/parsec/parsec_description_structures.h index e25c7d46f..33811e8bb 100644 --- a/parsec/include/parsec/parsec_description_structures.h +++ b/parsec/include/parsec/parsec_description_structures.h @@ -96,8 +96,15 @@ struct parsec_flow_s { uint8_t flow_index; /**< The input index of the flow. This index is used * while computing the mask. */ parsec_dependency_t flow_datatype_mask; /**< The bitmask of dep_datatype_index of all deps */ + +// if parametrized flows, we need to be able to modify dep indices +#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) + parsec_dep_t *dep_in[MAX_DEP_IN_COUNT]; + parsec_dep_t *dep_out[MAX_DEP_OUT_COUNT]; +#else parsec_dep_t const *dep_in[MAX_DEP_IN_COUNT]; parsec_dep_t const *dep_out[MAX_DEP_OUT_COUNT]; +#endif }; /** diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 0675da699..4bb5bd3a0 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1635,7 +1635,12 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) for(fl = f->dataflow; fl != NULL; fl = fl->next) { rc = asprintf(&JDF_OBJECT_ONAME( fl ), "flow_of_%s_%s_for_%s", jdf_basename, f->fname, fl->varname); assert(rc != -1); - coutput("static const parsec_flow_t %s;\n", + coutput("static%s parsec_flow_t %s;\n", +#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) + "", +#else + " const", +#endif JDF_OBJECT_ONAME( fl )); } } @@ -1969,12 +1974,17 @@ static void jdf_generate_range_min(const jdf_t *jdf, const jdf_function_entry_t " return __parsec_ret;\n" "}\n"); - coutput("static const parsec_expr_t %s = {\n" + coutput("static%s parsec_expr_t %s = {\n" " .op = PARSEC_EXPR_OP_INLINE,\n" " .u_expr.v_func = { .type = %s, /* PARSEC_RETURN_TYPE_INT32 */\n" " .func = { .inline_func_int32 = (parsec_expr_op_int32_inline_func_t)%s_fct }\n" " }\n" "};\n", +#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) + "", +#else + " const", +#endif fn_name, enum_type_name(0), fn_name); } @@ -2032,12 +2042,17 @@ static void jdf_generate_range_max(const jdf_t *jdf, const jdf_function_entry_t " return __parsec_ret;\n" "}\n"); - coutput("static const parsec_expr_t %s = {\n" + coutput("static%s parsec_expr_t %s = {\n" " .op = PARSEC_EXPR_OP_INLINE,\n" " .u_expr.v_func = { .type = %s, /* PARSEC_RETURN_TYPE_INT32 */\n" " .func = { .inline_func_int32 = (parsec_expr_op_int32_inline_func_t)%s_fct }\n" " }\n" "};\n", +#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) + "", +#else + " const", +#endif fn_name, enum_type_name(0), fn_name); string_arena_free(sa); @@ -2090,12 +2105,17 @@ static void jdf_generate_range_increment(const jdf_t *jdf, const jdf_function_en " return __parsec_ret;\n" "}\n"); - coutput("static const parsec_expr_t %s = {\n" + coutput("static%s parsec_expr_t %s = {\n" " .op = PARSEC_EXPR_OP_INLINE,\n" " .u_expr.v_func = { .type = %s, /* PARSEC_RETURN_TYPE_INT32 */\n" " .func = { .inline_func_int32 = (parsec_expr_op_int32_inline_func_t)%s_fct }\n" " }\n" "};\n", +#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) + "", +#else + " const", +#endif fn_name, enum_type_name(0), fn_name); string_arena_free(sa); @@ -2704,9 +2724,14 @@ static int jdf_generate_dependency( const jdf_t *jdf, jdf_dataflow_t *flow, jdf_ dump_expr((void**)dep->guard->guard, &info); } string_arena_add_string(sa, - "static const parsec_dep_t %s = {\n" + "static%s parsec_dep_t %s = {\n" " .cond = %s, /* %s%s */\n" " .ctl_gather_nb = %s,\n", +#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) + "", +#else + " const", +#endif JDF_OBJECT_ONAME(call), condname, (call == dep->guard->calltrue ? "" : "!"), string_arena_get_string(sa3), string_arena_get_string(sa2)); @@ -2893,7 +2918,7 @@ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* deps_out, MAX_DEP_OUT_COUNT, deps_out); } string_arena_add_string(sa, - "\nstatic const parsec_flow_t %s = {\n" + "\nstatic%s parsec_flow_t %s = {\n" " .name = \"%s\",\n" " .sym_type = %s,\n" " .flow_flags = %s,\n" @@ -2902,6 +2927,11 @@ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* " .dep_in = { %s },\n" " .dep_out = { %s }\n" "};\n\n", +#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) + "", +#else + " const", +#endif JDF_OBJECT_ONAME(flow), flow->varname, sym_type, From 2fc931a11b31a29f539e60f251372aafc1ef8748 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 19 Oct 2022 11:05:13 -0400 Subject: [PATCH 037/157] add base to debug print a task class --- parsec/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/parsec/CMakeLists.txt b/parsec/CMakeLists.txt index 46a815729..281d505f4 100644 --- a/parsec/CMakeLists.txt +++ b/parsec/CMakeLists.txt @@ -122,7 +122,8 @@ set(SOURCES maxheap.c hbbuffer.c datarepo.c - termdet.c) + termdet.c + task_class.c) if( PARSEC_PROF_TRACE ) list(APPEND SOURCES dictionary.c) endif( PARSEC_PROF_TRACE ) From bfbb78f2665110a707d365c394cff7c754174f4a Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 19 Oct 2022 11:06:14 -0400 Subject: [PATCH 038/157] add forgotten files --- parsec/task_class.c | 13 +++++++++++++ parsec/task_class.h | 15 +++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 parsec/task_class.c create mode 100644 parsec/task_class.h diff --git a/parsec/task_class.c b/parsec/task_class.c new file mode 100644 index 000000000..88f6239bc --- /dev/null +++ b/parsec/task_class.c @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2012-2019 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + */ + +#include "parsec/task_class.h" + + +void parsec_debug_dump_task_class_exec(parsec_task_class_t *tc) +{ + +} diff --git a/parsec/task_class.h b/parsec/task_class.h new file mode 100644 index 000000000..a0b13554b --- /dev/null +++ b/parsec/task_class.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2012-2019 The University of Tennessee and The University + * of Tennessee Research Foundation. All rights + * reserved. + */ + +#ifndef PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED +#define PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED + +#include "parsec/parsec_config.h" +#include "parsec_internal.h" + +void parsec_debug_dump_task_class_exec(parsec_task_class_t *tc); + +#endif /* PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED */ From 27be8cfbc0e0fdcad44e00b508e6bf8fefcd3fcc Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 19 Oct 2022 11:53:22 -0400 Subject: [PATCH 039/157] implement parsec_debug_dump_task_class_at_exec --- parsec/CMakeLists.txt | 1 + parsec/include/parsec.h | 1 + parsec/task_class.c | 142 +++++++++++++++++++++++++++++++++++++++- parsec/task_class.h | 2 +- 4 files changed, 144 insertions(+), 2 deletions(-) diff --git a/parsec/CMakeLists.txt b/parsec/CMakeLists.txt index 281d505f4..a3a893906 100644 --- a/parsec/CMakeLists.txt +++ b/parsec/CMakeLists.txt @@ -303,6 +303,7 @@ if( BUILD_PARSEC ) ${CMAKE_CURRENT_SOURCE_DIR}/bindthread.h ${CMAKE_CURRENT_SOURCE_DIR}/parsec_comm_engine.h ${CMAKE_CURRENT_SOURCE_DIR}/include/parsec/deprecated.h + ${CMAKE_CURRENT_SOURCE_DIR}/task_class.h DESTINATION ${PARSEC_INSTALL_INCLUDEDIR}/parsec) install(FILES diff --git a/parsec/include/parsec.h b/parsec/include/parsec.h index fecf4521a..a6db5732b 100644 --- a/parsec/include/parsec.h +++ b/parsec/include/parsec.h @@ -14,6 +14,7 @@ #include "parsec/datatype.h" #include "parsec/scheduling.h" #include "parsec/utils/debug.h" +#include "parsec/task_class.h" #include "parsec/interfaces/interface.h" #include "parsec/interfaces/dtd/insert_function.h" diff --git a/parsec/task_class.c b/parsec/task_class.c index 88f6239bc..df6009711 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -7,7 +7,147 @@ #include "parsec/task_class.h" -void parsec_debug_dump_task_class_exec(parsec_task_class_t *tc) +// Reminder: definitions: + +// /** +// * @brief Opaque structure representing a Task Class +// */ +// typedef struct parsec_task_class_s parsec_task_class_t; + +// typedef struct parsec_flow_s parsec_flow_t; +// typedef struct parsec_dep_s parsec_dep_t; + +// struct parsec_task_class_s { +// const char *name; + +// uint16_t flags; +// uint8_t task_class_id; /**< index in the dependency and in the function array */ + +// uint8_t nb_flows; +// uint8_t nb_parameters; +// uint8_t nb_locals; + +// uint8_t task_class_type; + +// parsec_dependency_t dependencies_goal; +// const parsec_symbol_t *params[MAX_LOCAL_COUNT]; +// const parsec_symbol_t *locals[MAX_LOCAL_COUNT]; +// const parsec_flow_t *in[MAX_PARAM_COUNT]; +// const parsec_flow_t *out[MAX_PARAM_COUNT]; +// const parsec_expr_t *priority; +// const parsec_property_t *properties; /**< {NULL, NULL} terminated array of properties holding all function-specific properties expressions */ + +// parsec_data_ref_fn_t *initial_data; /**< Populates an array of data references, of maximal size MAX_PARAM_COUNT */ +// parsec_data_ref_fn_t *final_data; /**< Populates an array of data references, of maximal size MAX_PARAM_COUNT */ +// parsec_data_ref_fn_t *data_affinity; /**< Populates an array of data references, of size 1 */ +// parsec_key_fn_t *key_functions; +// parsec_functionkey_fn_t *make_key; +// parsec_printtask_fn_t *task_snprintf; +// #if defined(PARSEC_SIM) +// parsec_sim_cost_fct_t *sim_cost_fct; +// #endif +// parsec_datatype_lookup_t *get_datatype; +// parsec_hook_t *prepare_input; +// const __parsec_chore_t *incarnations; +// parsec_hook_t *prepare_output; + +// parsec_find_dependency_fn_t *find_deps; +// parsec_update_dependency_fn_t *update_deps; + +// parsec_traverse_function_t *iterate_successors; +// parsec_traverse_function_t *iterate_predecessors; +// parsec_release_deps_t *release_deps; +// parsec_hook_t *complete_execution; +// parsec_new_task_function_t *new_task; +// parsec_hook_t *release_task; +// parsec_hook_t *fini; +// }; + + +// struct parsec_flow_s { +// char *name; +// uint8_t sym_type; +// uint8_t flow_flags; +// uint8_t flow_index; /**< The input index of the flow. This index is used +// * while computing the mask. */ +// parsec_dependency_t flow_datatype_mask; /**< The bitmask of dep_datatype_index of all deps */ + +// // if parametrized flows, we need to be able to modify dep indices +// #if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) +// parsec_dep_t *dep_in[MAX_DEP_IN_COUNT]; +// parsec_dep_t *dep_out[MAX_DEP_OUT_COUNT]; +// #else +// parsec_dep_t const *dep_in[MAX_DEP_IN_COUNT]; +// parsec_dep_t const *dep_out[MAX_DEP_OUT_COUNT]; +// #endif +// }; + +// struct parsec_dep_s { +// parsec_expr_t const *cond; /**< The runtime-evaluable condition on this dependency */ +// parsec_expr_t const *ctl_gather_nb; /**< In case of control gather, the runtime-evaluable number of controls to expect */ +// uint8_t task_class_id; /**< Index of the target parsec function in the object function array */ +// uint8_t dep_index; /**< Output index of the dependency. This is used to store the flow +// * before transfering it to the successors. */ +// uint8_t dep_datatype_index; /**< Index of the output datatype. */ +// parsec_flow_t const *flow; /**< Pointer to the flow pointed to/from this dependency */ +// parsec_flow_t const *belongs_to; /**< The flow this dependency belongs tp */ +// parsec_data_lookup_func_t direct_data; /**< Lookup the data associated with this dep, if (and only if) +// * this dep is a direct memory access */ +// }; + + + + + + +/* Prints the task class information (for debugging purposes) + * It will print the basic task information, its flows and their deps + */ +void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) { + int i, j, k; + parsec_flow_t *flow; + parsec_dep_t *dep; + + parsec_debug_verbose(1, parsec_debug_output, "###### PRINTING TASK CLASS %s ######", tc->name); + + parsec_debug_verbose(1, parsec_debug_output, "Task Class %s (%p) has %d flows, %d parameters, %d locals", + tc->name, (void*)tc, tc->nb_flows, tc->nb_parameters, tc->nb_locals); + for(i = 0; i < tc->nb_flows; i++) { + flow = (parsec_flow_t*)tc->in[i]; + if(flow) + { + parsec_debug_verbose(1, parsec_debug_output, " Flow %s (%p) is an input flow", + flow->name, (void*)flow); + for(j = 0; j < MAX_DEP_IN_COUNT && flow->dep_in[j]; j++) { + dep = (parsec_dep_t*)flow->dep_in[j]; + if(!dep) + { + continue; + } + parsec_debug_verbose(1, parsec_debug_output, " Dep %p is an input dep that takes data from dep %d of flow %s (id=%d) of task class %d" + " with datatype %d", + (void*)dep, dep->dep_index, dep->flow ? dep->flow->name : "[NULL flow]", dep->flow ? dep->flow->flow_index : -1, + dep->task_class_id, dep->dep_datatype_index); + } + } + flow = (parsec_flow_t*)tc->out[i]; + if(flow) + { + parsec_debug_verbose(1, parsec_debug_output, " Flow %s (%p) is an output flow", + flow->name, (void*)flow); + for(j = 0; j < MAX_DEP_OUT_COUNT && flow->dep_out[j]; j++) { + dep = (parsec_dep_t*)flow->dep_out[j]; + if(!dep) + { + continue; + } + parsec_debug_verbose(1, parsec_debug_output, " Dep %p is an input dep that sends data to dep %d of flow %s (id=%d) of task class %d" + " with datatype %d", + (void*)dep, dep->dep_index, dep->flow ? dep->flow->name : "[NULL flow]", dep->flow ? dep->flow->flow_index : -1, + dep->task_class_id, dep->dep_datatype_index); + } + } + } } diff --git a/parsec/task_class.h b/parsec/task_class.h index a0b13554b..c387205fb 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -10,6 +10,6 @@ #include "parsec/parsec_config.h" #include "parsec_internal.h" -void parsec_debug_dump_task_class_exec(parsec_task_class_t *tc); +void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc); #endif /* PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED */ From 0b1d70ebecf5688422e55fef014b17b7e5837d67 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 19 Oct 2022 14:06:08 -0400 Subject: [PATCH 040/157] change the formatting --- parsec/task_class.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index df6009711..a02930587 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -126,10 +126,19 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) { continue; } - parsec_debug_verbose(1, parsec_debug_output, " Dep %p is an input dep that takes data from dep %d of flow %s (id=%d) of task class %d" - " with datatype %d", - (void*)dep, dep->dep_index, dep->flow ? dep->flow->name : "[NULL flow]", dep->flow ? dep->flow->flow_index : -1, - dep->task_class_id, dep->dep_datatype_index); + if(dep->flow) + { + parsec_debug_verbose(1, parsec_debug_output, " Dep %d is an input dep that receives data from dep %d of flow %s (id=%d) of task class %d", + j, dep->dep_index, dep->flow->name, dep->flow->flow_index, + dep->task_class_id); + } + else + { + parsec_debug_verbose(1, parsec_debug_output, " Dep %d is an input dep that receives data from no one", + j); + } + parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", + dep->dep_datatype_index, (void*)dep->direct_data); } } flow = (parsec_flow_t*)tc->out[i]; @@ -143,10 +152,11 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) { continue; } - parsec_debug_verbose(1, parsec_debug_output, " Dep %p is an input dep that sends data to dep %d of flow %s (id=%d) of task class %d" - " with datatype %d", - (void*)dep, dep->dep_index, dep->flow ? dep->flow->name : "[NULL flow]", dep->flow ? dep->flow->flow_index : -1, - dep->task_class_id, dep->dep_datatype_index); + parsec_debug_verbose(1, parsec_debug_output, " Dep %d is an output dep that sends data to dep %d of flow %s (id=%d) of task class %d", + j, dep->dep_index, dep->flow ? dep->flow->name : "[NULL flow]", dep->flow ? dep->flow->flow_index : -1, + dep->task_class_id); + parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", + dep->dep_datatype_index, (void*)dep->direct_data); } } } From deaf991a4851ea7dcfd31e9087a42396cadcf7d4 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 19 Oct 2022 14:28:28 -0400 Subject: [PATCH 041/157] improve the formatting --- parsec/task_class.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index a02930587..7d80a752e 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -118,7 +118,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) flow = (parsec_flow_t*)tc->in[i]; if(flow) { - parsec_debug_verbose(1, parsec_debug_output, " Flow %s (%p) is an input flow", + parsec_debug_verbose(1, parsec_debug_output, " Input of flow %s (%p)", flow->name, (void*)flow); for(j = 0; j < MAX_DEP_IN_COUNT && flow->dep_in[j]; j++) { dep = (parsec_dep_t*)flow->dep_in[j]; @@ -128,23 +128,25 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) } if(dep->flow) { - parsec_debug_verbose(1, parsec_debug_output, " Dep %d is an input dep that receives data from dep %d of flow %s (id=%d) of task class %d", - j, dep->dep_index, dep->flow->name, dep->flow->flow_index, + parsec_debug_verbose(1, parsec_debug_output, " Input dep %d of flow %s is an input dep that receives data from dep %d of flow %s (id=%d) of task class %d", + j, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, dep->task_class_id); } else { - parsec_debug_verbose(1, parsec_debug_output, " Dep %d is an input dep that receives data from no one", - j); + parsec_debug_verbose(1, parsec_debug_output, " Input dep %d of flow %s is an input dep that receives data from no one", + j, flow->name); } parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", dep->dep_datatype_index, (void*)dep->direct_data); } } + } + for(i = 0; i < tc->nb_flows; i++) { flow = (parsec_flow_t*)tc->out[i]; if(flow) { - parsec_debug_verbose(1, parsec_debug_output, " Flow %s (%p) is an output flow", + parsec_debug_verbose(1, parsec_debug_output, " Output of flow %s (%p)", flow->name, (void*)flow); for(j = 0; j < MAX_DEP_OUT_COUNT && flow->dep_out[j]; j++) { dep = (parsec_dep_t*)flow->dep_out[j]; @@ -152,9 +154,22 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) { continue; } - parsec_debug_verbose(1, parsec_debug_output, " Dep %d is an output dep that sends data to dep %d of flow %s (id=%d) of task class %d", - j, dep->dep_index, dep->flow ? dep->flow->name : "[NULL flow]", dep->flow ? dep->flow->flow_index : -1, - dep->task_class_id); + // parsec_debug_verbose(1, parsec_debug_output, " Dep %d is an output dep that sends data to dep %d of flow %s (id=%d) of task class %d", + // j, dep->dep_index, dep->flow ? dep->flow->name : "[NULL flow]", dep->flow ? dep->flow->flow_index : -1, + // dep->task_class_id); + // parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", + // dep->dep_datatype_index, (void*)dep->direct_data); + if(dep->flow) + { + parsec_debug_verbose(1, parsec_debug_output, " Output dep %d of flow %s is an output dep that sends data to dep %d of flow %s (id=%d) of task class %d", + j, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, + dep->task_class_id); + } + else + { + parsec_debug_verbose(1, parsec_debug_output, " Output dep %d of flow %s is an output dep that sends data to no one", + j, flow->name); + } parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", dep->dep_datatype_index, (void*)dep->direct_data); } From a36a09826d3475652f8aedfd78c3579bc68ec013 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 19 Oct 2022 14:50:41 -0400 Subject: [PATCH 042/157] remove comment --- parsec/task_class.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index 7d80a752e..7ce9d42e7 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -154,11 +154,6 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) { continue; } - // parsec_debug_verbose(1, parsec_debug_output, " Dep %d is an output dep that sends data to dep %d of flow %s (id=%d) of task class %d", - // j, dep->dep_index, dep->flow ? dep->flow->name : "[NULL flow]", dep->flow ? dep->flow->flow_index : -1, - // dep->task_class_id); - // parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", - // dep->dep_datatype_index, (void*)dep->direct_data); if(dep->flow) { parsec_debug_verbose(1, parsec_debug_output, " Output dep %d of flow %s is an output dep that sends data to dep %d of flow %s (id=%d) of task class %d", From d33d02fd4f137e196c848e941a75b8ddfd931117 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 19 Oct 2022 15:55:57 -0400 Subject: [PATCH 043/157] better handle the format of parsec_debug_dump_task_class_at_exec when the data come from a data collection --- parsec/task_class.c | 28 ++++++++++++++++++++++------ parsec/task_class.h | 1 + 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index 7ce9d42e7..68add2367 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -126,7 +126,13 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) { continue; } - if(dep->flow) + + if( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ) { + parsec_debug_verbose(1, parsec_debug_output, " Input dep %d of flow %s comes directly from the data collection", + j, flow->name); + + } + else if(dep->flow) { parsec_debug_verbose(1, parsec_debug_output, " Input dep %d of flow %s is an input dep that receives data from dep %d of flow %s (id=%d) of task class %d", j, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, @@ -134,8 +140,10 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) } else { - parsec_debug_verbose(1, parsec_debug_output, " Input dep %d of flow %s is an input dep that receives data from no one", - j, flow->name); + //assert(0); // If flow is NULL, should be handled in if(PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id) + parsec_debug_verbose(1, parsec_debug_output, " ## WARNING ## , parsec_debug_dump_task_class_at_exec does not know this type of dependency"); + //parsec_debug_verbose(1, parsec_debug_output, " Input dep %d of flow %s is an input dep that receives data from no one", + // j, flow->name); } parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", dep->dep_datatype_index, (void*)dep->direct_data); @@ -154,7 +162,13 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) { continue; } - if(dep->flow) + + if( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ) { + parsec_debug_verbose(1, parsec_debug_output, " Output dep %d of flow %s goes directly to the data collection", + j, flow->name); + + } + else if(dep->flow) { parsec_debug_verbose(1, parsec_debug_output, " Output dep %d of flow %s is an output dep that sends data to dep %d of flow %s (id=%d) of task class %d", j, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, @@ -162,8 +176,10 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) } else { - parsec_debug_verbose(1, parsec_debug_output, " Output dep %d of flow %s is an output dep that sends data to no one", - j, flow->name); + //assert(0); // If flow is NULL, should be handled in if(PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id) + parsec_debug_verbose(1, parsec_debug_output, " ## WARNING ## , parsec_debug_dump_task_class_at_exec does not know this type of dependency"); + //parsec_debug_verbose(1, parsec_debug_output, " Output dep %d of flow %s is an output dep that sends data to no one", + // j, flow->name); } parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", dep->dep_datatype_index, (void*)dep->direct_data); diff --git a/parsec/task_class.h b/parsec/task_class.h index c387205fb..f40861b7e 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -8,6 +8,7 @@ #define PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED #include "parsec/parsec_config.h" +#include "parsec/interfaces/interface.h" #include "parsec_internal.h" void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc); From 44eeb9bed266af402c0157f5479f7785e9e98e7d Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 20 Oct 2022 12:22:49 -0400 Subject: [PATCH 044/157] improve the logic in parsec_debug_dump_task_class_at_exec --- parsec/parsec.c | 5 ++++ parsec/task_class.c | 69 +++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/parsec/parsec.c b/parsec/parsec.c index 186330f6c..792b827b6 100644 --- a/parsec/parsec.c +++ b/parsec/parsec.c @@ -1386,10 +1386,15 @@ parsec_check_IN_dependencies_with_mask(const parsec_taskpool_t *tp, continue; /* doesn't match */ /* the condition triggered let's check if it's for a data */ } /* otherwise we have an input flow without a condition, it MUST be final */ + /* + TODO: George, Thomas, please review the new code that replaces this: if( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ) { active = (1 << flow->flow_index); } break; + */ + active = (1 << flow->flow_index); + assert( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ); } } } diff --git a/parsec/task_class.c b/parsec/task_class.c index 68add2367..9bfc6d6d5 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -98,7 +98,14 @@ - +bool parsec_helper_flow_is_in_flow_array(parsec_flow_t const *flow, parsec_flow_t const *flow_array[], int flow_array_size) { + for (int i = 0; i < flow_array_size; i++) { + if (flow == flow_array[i]) { + return true; + } + } + return false; +} /* Prints the task class information (for debugging purposes) * It will print the basic task information, its flows and their deps @@ -106,14 +113,72 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) { int i, j, k; + int flow_in_out, dep_in_out; parsec_flow_t *flow; parsec_dep_t *dep; + // flows can appear twice in a task class (if both in and out) + parsec_flow_t *treated_flows[MAX_PARAM_COUNT]; + int treated_flows_size = 0;; + parsec_debug_verbose(1, parsec_debug_output, "###### PRINTING TASK CLASS %s ######", tc->name); parsec_debug_verbose(1, parsec_debug_output, "Task Class %s (%p) has %d flows, %d parameters, %d locals", tc->name, (void*)tc, tc->nb_flows, tc->nb_parameters, tc->nb_locals); + for(i = 0; i < tc->nb_flows; i++) { + for(flow_in_out=0;flow_in_out<2;++flow_in_out) + { + flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]); + + if(parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { + continue; + } + + if(flow) + { + parsec_debug_verbose(1, parsec_debug_output, " flow %s (%p)", + flow->name, (void*)flow); + for(dep_in_out=0;dep_in_out<2;++dep_in_out) + { + for(j = 0; j < (dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); j++) { + dep = (parsec_dep_t*)(dep_in_out?flow->dep_out[j]:flow->dep_in[j]); + if(!dep) + { + continue; + } + + if( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ) { + parsec_debug_verbose(1, parsec_debug_output, " %s dep %d of flow %s linked with data collection", + dep_in_out?"output":"input", j, flow->name); + + } + else if(dep->flow) + { + parsec_debug_verbose(1, parsec_debug_output, " %s dep %d of flow %s is a dep that is linked to dep %d of flow %s (id=%d) of task class %d", + dep_in_out?"output":"input", j, flow->name, dep->dep_index, dep->flow->name, + dep->flow->flow_index, dep->task_class_id); + } + else + { + parsec_debug_verbose(1, parsec_debug_output, " ## WARNING ## , parsec_debug_dump_task_class_at_exec does not know this type of dependency"); + continue; + } + parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", + dep->dep_datatype_index, (void*)dep->direct_data); + } + } + + treated_flows[treated_flows_size] = flow; + ++treated_flows_size; + } + } + } + + assert(tc->nb_flows == treated_flows_size); + + +/* for(i = 0; i < tc->nb_flows; i++) { flow = (parsec_flow_t*)tc->in[i]; if(flow) @@ -185,5 +250,5 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) dep->dep_datatype_index, (void*)dep->direct_data); } } - } + }*/ } From 77bc64e7ab69c67e0798ce8a427d4228fe7bee1f Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 20 Oct 2022 13:02:20 -0400 Subject: [PATCH 045/157] separate the assert from the dump --- parsec/task_class.c | 88 ++++++++++++--------------------------------- parsec/task_class.h | 1 + 2 files changed, 23 insertions(+), 66 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index 9bfc6d6d5..1734ded49 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -174,81 +174,37 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) } } } +} - assert(tc->nb_flows == treated_flows_size); +/* Checks if the task class is valid (for debugging purposes) + */ +void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) +{ + int i, j, k; + int flow_in_out, dep_in_out; + parsec_flow_t *flow; + parsec_dep_t *dep; + // flows can appear twice in a task class (if both in and out) + parsec_flow_t *treated_flows[MAX_PARAM_COUNT]; + int treated_flows_size = 0;; -/* for(i = 0; i < tc->nb_flows; i++) { - flow = (parsec_flow_t*)tc->in[i]; - if(flow) + for(flow_in_out=0;flow_in_out<2;++flow_in_out) { - parsec_debug_verbose(1, parsec_debug_output, " Input of flow %s (%p)", - flow->name, (void*)flow); - for(j = 0; j < MAX_DEP_IN_COUNT && flow->dep_in[j]; j++) { - dep = (parsec_dep_t*)flow->dep_in[j]; - if(!dep) - { - continue; - } + flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]); - if( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ) { - parsec_debug_verbose(1, parsec_debug_output, " Input dep %d of flow %s comes directly from the data collection", - j, flow->name); + if(parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { + continue; + } - } - else if(dep->flow) - { - parsec_debug_verbose(1, parsec_debug_output, " Input dep %d of flow %s is an input dep that receives data from dep %d of flow %s (id=%d) of task class %d", - j, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, - dep->task_class_id); - } - else - { - //assert(0); // If flow is NULL, should be handled in if(PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id) - parsec_debug_verbose(1, parsec_debug_output, " ## WARNING ## , parsec_debug_dump_task_class_at_exec does not know this type of dependency"); - //parsec_debug_verbose(1, parsec_debug_output, " Input dep %d of flow %s is an input dep that receives data from no one", - // j, flow->name); - } - parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", - dep->dep_datatype_index, (void*)dep->direct_data); + if(flow) + { + treated_flows[treated_flows_size] = flow; + ++treated_flows_size; } } } - for(i = 0; i < tc->nb_flows; i++) { - flow = (parsec_flow_t*)tc->out[i]; - if(flow) - { - parsec_debug_verbose(1, parsec_debug_output, " Output of flow %s (%p)", - flow->name, (void*)flow); - for(j = 0; j < MAX_DEP_OUT_COUNT && flow->dep_out[j]; j++) { - dep = (parsec_dep_t*)flow->dep_out[j]; - if(!dep) - { - continue; - } - - if( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ) { - parsec_debug_verbose(1, parsec_debug_output, " Output dep %d of flow %s goes directly to the data collection", - j, flow->name); - } - else if(dep->flow) - { - parsec_debug_verbose(1, parsec_debug_output, " Output dep %d of flow %s is an output dep that sends data to dep %d of flow %s (id=%d) of task class %d", - j, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, - dep->task_class_id); - } - else - { - //assert(0); // If flow is NULL, should be handled in if(PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id) - parsec_debug_verbose(1, parsec_debug_output, " ## WARNING ## , parsec_debug_dump_task_class_at_exec does not know this type of dependency"); - //parsec_debug_verbose(1, parsec_debug_output, " Output dep %d of flow %s is an output dep that sends data to no one", - // j, flow->name); - } - parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", - dep->dep_datatype_index, (void*)dep->direct_data); - } - } - }*/ + assert(tc->nb_flows == treated_flows_size); } diff --git a/parsec/task_class.h b/parsec/task_class.h index f40861b7e..cacc8407a 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -12,5 +12,6 @@ #include "parsec_internal.h" void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc); +void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); #endif /* PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED */ From db3fd8ccbe8166c4627163e2e16839f994ab9232 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 21 Oct 2022 18:00:16 -0400 Subject: [PATCH 046/157] make parsec_helper_flow_is_in_flow_array public, add a new check for sanity, + various changes --- .../parsec/parsec_description_structures.h | 9 ++++ parsec/task_class.c | 52 ++++++++++++------- parsec/task_class.h | 3 ++ 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/parsec/include/parsec/parsec_description_structures.h b/parsec/include/parsec/parsec_description_structures.h index 33811e8bb..621b785d9 100644 --- a/parsec/include/parsec/parsec_description_structures.h +++ b/parsec/include/parsec/parsec_description_structures.h @@ -15,6 +15,9 @@ BEGIN_C_DECLS typedef struct parsec_assignment_s parsec_assignment_t; typedef struct parsec_expr_s parsec_expr_t; typedef struct parsec_flow_s parsec_flow_t; +#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) +typedef struct parsec_parametrized_flow_s parsec_parametrized_flow_t; // to store information about parametrized flows +#endif typedef struct parsec_dep_s parsec_dep_t; typedef struct parsec_symbol_s parsec_symbol_t; @@ -107,6 +110,12 @@ struct parsec_flow_s { #endif }; +#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) +struct parsec_parametrized_flow_s { + int test; +}; +#endif + /** * Dependencies */ diff --git a/parsec/task_class.c b/parsec/task_class.c index 1734ded49..d49363ecd 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -98,7 +98,7 @@ -bool parsec_helper_flow_is_in_flow_array(parsec_flow_t const *flow, parsec_flow_t const *flow_array[], int flow_array_size) { +bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_t *flow_array[], int flow_array_size) { for (int i = 0; i < flow_array_size; i++) { if (flow == flow_array[i]) { return true; @@ -119,26 +119,22 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) // flows can appear twice in a task class (if both in and out) parsec_flow_t *treated_flows[MAX_PARAM_COUNT]; - int treated_flows_size = 0;; + int treated_flows_size = 0; parsec_debug_verbose(1, parsec_debug_output, "###### PRINTING TASK CLASS %s ######", tc->name); parsec_debug_verbose(1, parsec_debug_output, "Task Class %s (%p) has %d flows, %d parameters, %d locals", tc->name, (void*)tc, tc->nb_flows, tc->nb_parameters, tc->nb_locals); - for(i = 0; i < tc->nb_flows; i++) { + for(i = 0; i < MAX_PARAM_COUNT; i++) { for(flow_in_out=0;flow_in_out<2;++flow_in_out) { flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]); - if(parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { - continue; - } - - if(flow) + if(flow && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { - parsec_debug_verbose(1, parsec_debug_output, " flow %s (%p)", - flow->name, (void*)flow); + parsec_debug_verbose(1, parsec_debug_output, " flow %s (addr=%p, id=%d, flow_datatype_mask=%p, flow_flags=%p)", + flow->name, (void*)flow, flow->flow_index, (void*)flow->flow_datatype_mask, (void*)flow->flow_flags); for(dep_in_out=0;dep_in_out<2;++dep_in_out) { for(j = 0; j < (dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); j++) { @@ -164,8 +160,8 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) parsec_debug_verbose(1, parsec_debug_output, " ## WARNING ## , parsec_debug_dump_task_class_at_exec does not know this type of dependency"); continue; } - parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p", - dep->dep_datatype_index, (void*)dep->direct_data); + parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p, dep_datatype_index=%d, dep_index=%d, task_class_id=%d", + dep->dep_datatype_index, (void*)dep->direct_data, dep->dep_datatype_index, dep->dep_index, dep->task_class_id); } } @@ -189,22 +185,42 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) parsec_flow_t *treated_flows[MAX_PARAM_COUNT]; int treated_flows_size = 0;; - for(i = 0; i < tc->nb_flows; i++) { + for(i = 0; i < MAX_PARAM_COUNT; i++) { for(flow_in_out=0;flow_in_out<2;++flow_in_out) { flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]); - if(parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { - continue; - } - - if(flow) + if(flow && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { + // TODO ? Is there anything to assert? + treated_flows[treated_flows_size] = flow; ++treated_flows_size; } } } + // Check the coherency of the flow flags + for(i = 0; i < MAX_PARAM_COUNT; i++) { + flow = tc->out[i]; + + if(!flow) + { + break; + } + + // For each output dep of the flow ... + for(j = 0; j < (dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); j++) { + dep = flow->dep_out[j]; + if(!dep) + { + break; + } + + // All out dependencies should be in the flow datatype mask + assert((1<dep_index) & flow->flow_datatype_mask); + } + } + assert(tc->nb_flows == treated_flows_size); } diff --git a/parsec/task_class.h b/parsec/task_class.h index cacc8407a..d4ed44649 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -11,6 +11,9 @@ #include "parsec/interfaces/interface.h" #include "parsec_internal.h" +// flow_array should be const, but it creates a warning in the generated code +bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_t *flow_array[], int flow_array_size); + void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc); void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); From 4150f703e62f8967038e1e244400950ca7c51337 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 21 Oct 2022 18:27:52 -0400 Subject: [PATCH 047/157] add parsec_helper_copy_flow utility --- parsec/task_class.c | 39 ++++++++++++++++++++++++++++++++++----- parsec/task_class.h | 3 +++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index d49363ecd..df82af669 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -112,7 +112,7 @@ bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_ */ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) { - int i, j, k; + int i, j; int flow_in_out, dep_in_out; parsec_flow_t *flow; parsec_dep_t *dep; @@ -134,7 +134,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) if(flow && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { parsec_debug_verbose(1, parsec_debug_output, " flow %s (addr=%p, id=%d, flow_datatype_mask=%p, flow_flags=%p)", - flow->name, (void*)flow, flow->flow_index, (void*)flow->flow_datatype_mask, (void*)flow->flow_flags); + flow->name, (void*)flow, flow->flow_index, flow->flow_datatype_mask, flow->flow_flags); for(dep_in_out=0;dep_in_out<2;++dep_in_out) { for(j = 0; j < (dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); j++) { @@ -145,13 +145,13 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) } if( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ) { - parsec_debug_verbose(1, parsec_debug_output, " %s dep %d of flow %s linked with data collection", + parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s linked with data collection", dep_in_out?"output":"input", j, flow->name); } else if(dep->flow) { - parsec_debug_verbose(1, parsec_debug_output, " %s dep %d of flow %s is a dep that is linked to dep %d of flow %s (id=%d) of task class %d", + parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s is a dep that is linked to dep %d of flow %s (id=%d) of task class %d", dep_in_out?"output":"input", j, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, dep->task_class_id); } @@ -176,7 +176,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) */ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) { - int i, j, k; + int i, j; int flow_in_out, dep_in_out; parsec_flow_t *flow; parsec_dep_t *dep; @@ -224,3 +224,32 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) assert(tc->nb_flows == treated_flows_size); } + +parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t * flow) +{ + int flow_in_out; + + parsec_flow_t *new_flow = (parsec_flow_t*)malloc(sizeof(parsec_flow_t)); + assert(new_flow); + memcpy(new_flow, flow, sizeof(parsec_flow_t)); + + // Copy the dependencies + int i; + for(flow_in_out=0;flow_in_out<2;++flow_in_out) { + for(i = 0; i < MAX_DEP_IN_COUNT; i++) { + parsec_dep_t *dep = (parsec_dep_t*)(flow_in_out?new_flow->dep_out[i]:new_flow->dep_in[i]); + + if(!dep) + { + break; + } + + parsec_dep_t *new_dep = (parsec_dep_t*)malloc(sizeof(parsec_dep_t)); + assert(new_dep); + memcpy(new_dep, dep, sizeof(parsec_dep_t)); + (flow_in_out?new_flow->dep_out:new_flow->dep_in)[i] = new_dep; + } + } + + return new_flow; +} diff --git a/parsec/task_class.h b/parsec/task_class.h index d4ed44649..c889af0ac 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -17,4 +17,7 @@ bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc); void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); +// Copy a flow (including its deps) and returns a pointer to the new flow +parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t * flow); + #endif /* PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED */ From 781113d8d9604ad73101e9053dfb209d1866282c Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 24 Oct 2022 14:40:56 -0400 Subject: [PATCH 048/157] add various helper functions --- parsec/task_class.c | 273 +++++++++++++++++++++++++++++++++++++------- parsec/task_class.h | 3 + 2 files changed, 234 insertions(+), 42 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index df82af669..cf4e4cdfe 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -6,7 +6,6 @@ #include "parsec/task_class.h" - // Reminder: definitions: // /** @@ -63,7 +62,6 @@ // parsec_hook_t *fini; // }; - // struct parsec_flow_s { // char *name; // uint8_t sym_type; @@ -95,16 +93,192 @@ // * this dep is a direct memory access */ // }; +bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_t *flow_array[], int flow_array_size) +{ + for (int i = 0; i < flow_array_size; i++) + { + if (flow == flow_array[i]) + { + return true; + } + } + return false; +} + +/** __parsec_LBM_shift_all_flow_reference_after + * + * Shift all the flows after "pivot_flow" by "shift" + * + */ +void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_flow, int shift) +{ + int i, j, k; + int flow_in_out, dep_in_out; + int pivot_index; + parsec_flow_t *flow; + parsec_dep_t *dep; + // use an array to keep track of the flows we already treated + parsec_flow_t *treated_flows[MAX_PARAM_COUNT]; + int treated_flows_size = 0; + // Increase the IDs of every flow that is greater than the ID of pivot_flow + for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) + { + for (i = 0; i < MAX_PARAM_COUNT; i++) + { + flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); + if (parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) + { + continue; + } -bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_t *flow_array[], int flow_array_size) { - for (int i = 0; i < flow_array_size; i++) { - if (flow == flow_array[i]) { - return true; + if (flow) + { + if (flow->flow_index > pivot_flow->flow_index) + { + flow->flow_index += shift; + } + + treated_flows[treated_flows_size] = flow; + ++treated_flows_size; + } + else + { + break; + } } } - return false; + + /* We perform the shift on both the in and out flows of the task class + * The pivot flow can have different indices in the in and out arrays + * + * Note: We displace all the flows following the pivot flow in the in and out array + * But this is just for convience, to get the parametrized subflows next to each other + */ + for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) + { + + // Look for the pivot flow + pivot_index = -1; + for (i = 0; i < MAX_PARAM_COUNT; i++) + { + flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); + + if (!flow) + { + break; + } + + if (flow == pivot_flow) + { + pivot_index = i; + break; + } + } + + // If the pivot was not found in this flow_in_out, skip the shift + if (pivot_index == -1) + { + continue; + } + + // Find the last non-null flow + for (i = pivot_index; i < MAX_PARAM_COUNT; i++) + { + flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); + + if (!flow) + { + break; + } + } + int last_flow_index = i - 1; + + // Shift all the flows after the pivot + for (i = last_flow_index; i > pivot_index; i--) + { + flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); + + assert(flow); // We should not have a NULL flow here + // assert(flow->flow_index == i); // The flow index can acutally be anything + assert(i + shift < MAX_PARAM_COUNT); // We should not overflow the array + + // Shift the flow + (flow_in_out ? tc->out : tc->in)[i + shift] = flow; + } + } +} + +void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep_t *pivot_dep, int shift) +{ + int pivot_dep_index; + + // Look for the pivot dep + pivot_dep_index = -1; + for (int i = 0; i < dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT; i++) + { + parsec_dep_t *dep = (parsec_dep_t *)(dep_in_out ? flow->dep_out[i] : flow->dep_in[i]); + + if (!dep) + { + break; + } + + if (dep == pivot_dep) + { + pivot_dep_index = i; + break; + } + } + + // If the pivot was not found in this flow_in_out, skip the shift + if (pivot_dep_index == -1) + { + return; + } + + assert((dep_in_out ? flow->dep_out[pivot_dep_index] : flow->dep_in[pivot_dep_index]) == pivot_dep); // From there, the pivot dep should be in the array + + // Find the last non-null dep + int last_dep_index; + for (last_dep_index = pivot_dep_index + 1; last_dep_index < dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT; ++last_dep_index) + { + parsec_dep_t *dep = (parsec_dep_t *)(dep_in_out ? flow->dep_out[last_dep_index] : flow->dep_in[last_dep_index]); + + if (!dep) + { + break; + } + } + last_dep_index--; + + // Shift all the deps after the pivot + for (int i = last_dep_index; i > pivot_dep_index; i--) + { + parsec_dep_t *dep = (parsec_dep_t *)(dep_in_out ? flow->dep_out[i] : flow->dep_in[i]); + + assert(dep); // We should not have a NULL dep here + // assert(dep->dep_index == i); // The dep index can acutally be anything + assert(i + shift < dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); // We should not overflow the array + + dep->dep_index += shift; + + // Shift the dep + (dep_in_out ? flow->dep_out : flow->dep_in)[i + shift] = dep; + } + + // Also shift the flow's flow_datatype_mask + if(dep_in_out) + { + // If output dep + // Goal: 000xxxxx -> 0xxxx11x (if shift=1 and pivot_dep_index=1) + // (add 1's in between) + parsec_dependency_t unshifted_values = flow->flow_datatype_mask & ((1<flow_datatype_mask >> (pivot_dep_index + 1)) << (pivot_dep_index + 1 + shift); + parsec_dependency_t in_between = ((1<<(shift+1))-1) << pivot_dep_index; + flow->flow_datatype_mask = unshifted_values | shifted_values | in_between; + } } /* Prints the task class information (for debugging purposes) @@ -124,36 +298,38 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) parsec_debug_verbose(1, parsec_debug_output, "###### PRINTING TASK CLASS %s ######", tc->name); parsec_debug_verbose(1, parsec_debug_output, "Task Class %s (%p) has %d flows, %d parameters, %d locals", - tc->name, (void*)tc, tc->nb_flows, tc->nb_parameters, tc->nb_locals); + tc->name, (void *)tc, tc->nb_flows, tc->nb_parameters, tc->nb_locals); - for(i = 0; i < MAX_PARAM_COUNT; i++) { - for(flow_in_out=0;flow_in_out<2;++flow_in_out) + for (i = 0; i < MAX_PARAM_COUNT; i++) + { + for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) { - flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]); + flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); - if(flow && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) + if (flow && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { parsec_debug_verbose(1, parsec_debug_output, " flow %s (addr=%p, id=%d, flow_datatype_mask=%p, flow_flags=%p)", - flow->name, (void*)flow, flow->flow_index, flow->flow_datatype_mask, flow->flow_flags); - for(dep_in_out=0;dep_in_out<2;++dep_in_out) + flow->name, (void *)flow, flow->flow_index, flow->flow_datatype_mask, flow->flow_flags); + for (dep_in_out = 0; dep_in_out < 2; ++dep_in_out) { - for(j = 0; j < (dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); j++) { - dep = (parsec_dep_t*)(dep_in_out?flow->dep_out[j]:flow->dep_in[j]); - if(!dep) + for (j = 0; j < (dep_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) + { + dep = (parsec_dep_t *)(dep_in_out ? flow->dep_out[j] : flow->dep_in[j]); + if (!dep) { continue; } - if( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ) { + if (PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id) + { parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s linked with data collection", - dep_in_out?"output":"input", j, flow->name); - + dep_in_out ? "output" : "input", j, flow->name); } - else if(dep->flow) + else if (dep->flow) { parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s is a dep that is linked to dep %d of flow %s (id=%d) of task class %d", - dep_in_out?"output":"input", j, flow->name, dep->dep_index, dep->flow->name, - dep->flow->flow_index, dep->task_class_id); + dep_in_out ? "output" : "input", j, flow->name, dep->dep_index, dep->flow->name, + dep->flow->flow_index, dep->task_class_id); } else { @@ -161,7 +337,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) continue; } parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p, dep_datatype_index=%d, dep_index=%d, task_class_id=%d", - dep->dep_datatype_index, (void*)dep->direct_data, dep->dep_datatype_index, dep->dep_index, dep->task_class_id); + dep->dep_datatype_index, (void *)dep->direct_data, dep->dep_datatype_index, dep->dep_index, dep->task_class_id); } } @@ -183,14 +359,15 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) // flows can appear twice in a task class (if both in and out) parsec_flow_t *treated_flows[MAX_PARAM_COUNT]; - int treated_flows_size = 0;; + int treated_flows_size = 0; - for(i = 0; i < MAX_PARAM_COUNT; i++) { - for(flow_in_out=0;flow_in_out<2;++flow_in_out) + for (i = 0; i < MAX_PARAM_COUNT; i++) + { + for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) { - flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]); + flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); - if(flow && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) + if (flow && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { // TODO ? Is there anything to assert? @@ -201,55 +378,67 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) } // Check the coherency of the flow flags - for(i = 0; i < MAX_PARAM_COUNT; i++) { + for (i = 0; i < MAX_PARAM_COUNT; i++) + { flow = tc->out[i]; - if(!flow) + if (!flow) { break; } // For each output dep of the flow ... - for(j = 0; j < (dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); j++) { + for (j = 0; j < (dep_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) + { dep = flow->dep_out[j]; - if(!dep) + if (!dep) { break; } // All out dependencies should be in the flow datatype mask - assert((1<dep_index) & flow->flow_datatype_mask); + assert((1 << dep->dep_index) & flow->flow_datatype_mask); } } assert(tc->nb_flows == treated_flows_size); } -parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t * flow) +parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow) { int flow_in_out; - parsec_flow_t *new_flow = (parsec_flow_t*)malloc(sizeof(parsec_flow_t)); + parsec_flow_t *new_flow = (parsec_flow_t *)malloc(sizeof(parsec_flow_t)); assert(new_flow); memcpy(new_flow, flow, sizeof(parsec_flow_t)); // Copy the dependencies int i; - for(flow_in_out=0;flow_in_out<2;++flow_in_out) { - for(i = 0; i < MAX_DEP_IN_COUNT; i++) { - parsec_dep_t *dep = (parsec_dep_t*)(flow_in_out?new_flow->dep_out[i]:new_flow->dep_in[i]); + for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) + { + for (i = 0; i < flow_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT; i++) + { + parsec_dep_t *dep = (parsec_dep_t *)(flow_in_out ? new_flow->dep_out[i] : new_flow->dep_in[i]); - if(!dep) + if (!dep) { break; } - parsec_dep_t *new_dep = (parsec_dep_t*)malloc(sizeof(parsec_dep_t)); + parsec_dep_t *new_dep = (parsec_dep_t *)malloc(sizeof(parsec_dep_t)); assert(new_dep); memcpy(new_dep, dep, sizeof(parsec_dep_t)); - (flow_in_out?new_flow->dep_out:new_flow->dep_in)[i] = new_dep; + (flow_in_out ? new_flow->dep_out : new_flow->dep_in)[i] = new_dep; } } return new_flow; } + +parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep) +{ + parsec_dep_t *new_dep = (parsec_dep_t *)malloc(sizeof(parsec_dep_t)); + assert(new_dep); + memcpy(new_dep, dep, sizeof(parsec_dep_t)); + return new_dep; +} diff --git a/parsec/task_class.h b/parsec/task_class.h index c889af0ac..fde6613aa 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -11,6 +11,8 @@ #include "parsec/interfaces/interface.h" #include "parsec_internal.h" +void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_flow, int shift); +void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep_t *pivot_dep, int shift); // flow_array should be const, but it creates a warning in the generated code bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_t *flow_array[], int flow_array_size); @@ -19,5 +21,6 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); // Copy a flow (including its deps) and returns a pointer to the new flow parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t * flow); +parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep); #endif /* PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED */ From 38c279d90a94168a6a50b7683a267a4aad01e2b6 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 24 Oct 2022 14:52:05 -0400 Subject: [PATCH 049/157] improve the formatting of parsec_debug_dump_task_class_at_exec --- parsec/task_class.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index cf4e4cdfe..dee64d8f9 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -297,7 +297,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) parsec_debug_verbose(1, parsec_debug_output, "###### PRINTING TASK CLASS %s ######", tc->name); - parsec_debug_verbose(1, parsec_debug_output, "Task Class %s (%p) has %d flows, %d parameters, %d locals", + parsec_debug_verbose(1, parsec_debug_output, "## Task Class %s (%p) has %d flows, %d parameters, %d locals", tc->name, (void *)tc, tc->nb_flows, tc->nb_parameters, tc->nb_locals); for (i = 0; i < MAX_PARAM_COUNT; i++) @@ -308,7 +308,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) if (flow && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { - parsec_debug_verbose(1, parsec_debug_output, " flow %s (addr=%p, id=%d, flow_datatype_mask=%p, flow_flags=%p)", + parsec_debug_verbose(1, parsec_debug_output, " RW flow %s (addr=%p, id=%d, flow_datatype_mask=%p, flow_flags=%p)", flow->name, (void *)flow, flow->flow_index, flow->flow_datatype_mask, flow->flow_flags); for (dep_in_out = 0; dep_in_out < 2; ++dep_in_out) { @@ -322,21 +322,21 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) if (PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id) { - parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s linked with data collection", - dep_in_out ? "output" : "input", j, flow->name); + parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s linked with data collection", + dep_in_out ? "->" : "<-", j, flow->name); } else if (dep->flow) { - parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s is a dep that is linked to dep %d of flow %s (id=%d) of task class %d", - dep_in_out ? "output" : "input", j, flow->name, dep->dep_index, dep->flow->name, + parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s is a dep that is linked to dep %d of flow %s (id=%d) of task class %d", + dep_in_out ? "->" : "<-", j, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, dep->task_class_id); } else { - parsec_debug_verbose(1, parsec_debug_output, " ## WARNING ## , parsec_debug_dump_task_class_at_exec does not know this type of dependency"); + parsec_debug_verbose(1, parsec_debug_output, "## WARNING ## , parsec_debug_dump_task_class_at_exec does not know this type of dependency"); continue; } - parsec_debug_verbose(1, parsec_debug_output, " datatype=%d, direct_data=%p, dep_datatype_index=%d, dep_index=%d, task_class_id=%d", + parsec_debug_verbose(1, parsec_debug_output, "\t\tdatatype=%d\tdirect_data=%p\tdep_datatype_index=%d\tdep_index=%d\ttask_class_id=%d", dep->dep_datatype_index, (void *)dep->direct_data, dep->dep_datatype_index, dep->dep_index, dep->task_class_id); } } From f57ccdbbcd4874aca5953bf56c096b5a986e2770 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 24 Oct 2022 14:58:17 -0400 Subject: [PATCH 050/157] correct spaces --- parsec/task_class.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index dee64d8f9..24ce239cd 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -322,12 +322,12 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) if (PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id) { - parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s linked with data collection", + parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s linked with data collection", dep_in_out ? "->" : "<-", j, flow->name); } else if (dep->flow) { - parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s is a dep that is linked to dep %d of flow %s (id=%d) of task class %d", + parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s is a dep that is linked to dep %d of flow %s (id=%d) of task class %d", dep_in_out ? "->" : "<-", j, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, dep->task_class_id); } From a49ff8db424783b5188c222ec5e7d0fcd68b7f51 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 26 Oct 2022 10:34:58 -0400 Subject: [PATCH 051/157] add assert to ensure that iterate_predecessors is not called if the flow is parametrized --- parsec/include/parsec/parsec_description_structures.h | 6 ------ parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 10 +++++++++- parsec/parsec.c | 5 ++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/parsec/include/parsec/parsec_description_structures.h b/parsec/include/parsec/parsec_description_structures.h index 621b785d9..2fcf4e2d3 100644 --- a/parsec/include/parsec/parsec_description_structures.h +++ b/parsec/include/parsec/parsec_description_structures.h @@ -100,14 +100,8 @@ struct parsec_flow_s { * while computing the mask. */ parsec_dependency_t flow_datatype_mask; /**< The bitmask of dep_datatype_index of all deps */ -// if parametrized flows, we need to be able to modify dep indices -#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) parsec_dep_t *dep_in[MAX_DEP_IN_COUNT]; parsec_dep_t *dep_out[MAX_DEP_OUT_COUNT]; -#else - parsec_dep_t const *dep_in[MAX_DEP_IN_COUNT]; - parsec_dep_t const *dep_out[MAX_DEP_OUT_COUNT]; -#endif }; #if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 4bb5bd3a0..b2468bd84 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -4008,7 +4008,7 @@ static void jdf_generate_internal_init(const jdf_t *jdf, const jdf_function_entr assert(variable->op == JDF_RANGE); jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; - coutput("\n%s this_task->data._f_%s = alloca(sizeof(parsec_data_pair_t)*((%s)+1));\n", + coutput("\n%s this_task->data._f_%s = malloc(sizeof(parsec_data_pair_t)*((%s)+1));\n", indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); coutput("%s assert( NULL != this_task->data._f_%s );\n", indent(nesting), dataflow->varname); coutput("%s memset(this_task->data._f_%s, 0, sizeof(parsec_data_pair_t)*((%s)+1));\n", @@ -8135,6 +8135,14 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, parsec_get_name(jdf, f, "parsec_assignment_t"), parsec_get_name(jdf, f, "parsec_assignment_t"), UTIL_DUMP_LIST(sa1, f->locals, next, dump_local_assignments, &ai, "", " ", "\n", "\n")); + + // If parametrized flows, this won't work on iterate_predecessors +#if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) + if(FLOW_IS_PARAMETRIZED(f->dataflow)) + { + coutput(" assert(0); // %s is parametrized, parsec does not handle iterate_predecessors of parametrized flows yet\n", name); + } +#endif /* defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) */ coutput(" data_repo_t *successor_repo; parsec_key_t successor_repo_key;"); diff --git a/parsec/parsec.c b/parsec/parsec.c index 792b827b6..e2a6c250d 100644 --- a/parsec/parsec.c +++ b/parsec/parsec.c @@ -1386,15 +1386,14 @@ parsec_check_IN_dependencies_with_mask(const parsec_taskpool_t *tp, continue; /* doesn't match */ /* the condition triggered let's check if it's for a data */ } /* otherwise we have an input flow without a condition, it MUST be final */ - /* - TODO: George, Thomas, please review the new code that replaces this: if( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ) { active = (1 << flow->flow_index); } break; - */ + /* active = (1 << flow->flow_index); assert( PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id ); + */ } } } From 3d33869d749d5339b07e71ea8d1e6272754681cc Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 27 Oct 2022 12:38:31 -0400 Subject: [PATCH 052/157] change syntax + correct bug in jdf_assign_ldef_index --- parsec/interfaces/ptg/ptg-compiler/jdf.c | 9 ++-- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 23 ++++++++++ parsec/interfaces/ptg/ptg-compiler/parsec.y | 50 ++++++++++++++------- 3 files changed, 61 insertions(+), 21 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.c b/parsec/interfaces/ptg/ptg-compiler/jdf.c index 801cce04a..00194b8ba 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.c @@ -1745,6 +1745,7 @@ int jdf_assign_ldef_index(jdf_function_entry_t *f) * If they appear in the locals, they need to have a unique position * If they appear in the dataflow, each dep can re-use the locals of another dep * each call can re-use the locals of another call + * With parametrized flows, they can also appear in the dataflow. */ DO_DEBUG_VERBOSE(2, ({fprintf(stderr, "Indexing task class %s\n", f->fname);}) ); @@ -1770,7 +1771,7 @@ int jdf_assign_ldef_index(jdf_function_entry_t *f) if( ld->ldef_index == -1 ) { ld->ldef_index = nb_ldef_for_flows; nb_ldef_for_flows++; - DO_DEBUG_VERBOSE(2, ({ fprintf(stderr, " Flow for %s, flow %p: ldef %s is at %d\n", fl->varname, fl, ld->alias, ld->ldef_index); }) ); // TODO check + DO_DEBUG_VERBOSE(2, ({ fprintf(stderr, " Flow for %s, flow %p: ldef %s is at %d\n", fl->varname, fl, ld->alias, ld->ldef_index); }) ); } } @@ -1786,10 +1787,10 @@ int jdf_assign_ldef_index(jdf_function_entry_t *f) } } + nb_ldef_for_calls = nb_ldef_for_deps; switch( dep->guard->guard_type ) { case JDF_GUARD_UNCONDITIONAL: case JDF_GUARD_BINARY: - nb_ldef_for_calls = nb_ldef_for_deps; for(ld = dep->guard->calltrue->local_defs; NULL != ld; ld = ld->next) { assert(NULL != ld->alias); if( ld->ldef_index == -1 ) { @@ -1800,7 +1801,6 @@ int jdf_assign_ldef_index(jdf_function_entry_t *f) } break; case JDF_GUARD_TERNARY: - nb_ldef_for_calls = nb_ldef_for_deps; for(ld = dep->guard->calltrue->local_defs; NULL != ld; ld = ld->next) { assert(NULL != ld->alias); if( ld->ldef_index == -1 ) { @@ -1809,7 +1809,6 @@ int jdf_assign_ldef_index(jdf_function_entry_t *f) DO_DEBUG_VERBOSE(2, ({ fprintf(stderr, " Flow for %s, dep %d, calltrue: ldef %s is at %d\n", fl->varname, depi, ld->alias, ld->ldef_index); }) ); } } - nb_ldef_for_calls = nb_ldef_for_deps; for(ld = dep->guard->callfalse->local_defs; NULL != ld; ld = ld->next) { assert(NULL != ld->alias); if( ld->ldef_index == -1 ) { @@ -1825,6 +1824,8 @@ int jdf_assign_ldef_index(jdf_function_entry_t *f) if( nb_ldef_for_calls > f->nb_max_local_def ) f->nb_max_local_def = nb_ldef_for_calls; } + if( nb_ldef_for_flows > f->nb_max_local_def ) + f->nb_max_local_def = nb_ldef_for_flows; } return 0; } diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index b2468bd84..2671ae67c 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -8137,6 +8137,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, dump_local_assignments, &ai, "", " ", "\n", "\n")); // If parametrized flows, this won't work on iterate_predecessors + // TODO: probably not f->dataflow but some other flow should be checked #if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) if(FLOW_IS_PARAMETRIZED(f->dataflow)) { @@ -8325,6 +8326,28 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, " return;\n", JDF_OBJECT_ONAME(dl->guard->calltrue)); +/* + if(dl->guard->guard_type == JDF_GUARD_TERNARY && NULL != dl->guard->callfalse) { + dump_parametrized_flow_loop_if_parametrized(dl->guard->callfalse, indent(nb_open_ldef), sa_coutput); + if(FLOW_IS_PARAMETRIZED(dl->guard->callfalse)) { + nb_open_ldef++; + } + } + if(NULL != dl->guard->calltrue) + { + dump_parametrized_flow_loop_if_parametrized(dl->guard->calltrue, indent(nb_open_ldef), sa_coutput); + if(FLOW_IS_PARAMETRIZED(dl->guard->calltrue)) { + nb_open_ldef++; + } + } +*/ +/* + dump_parametrized_flow_loop_if_parametrized(f->dataflow, indent(nb_open_ldef), sa_coutput); + if(FLOW_IS_PARAMETRIZED(f->dataflow)) { + nb_open_ldef++; + } +*/ + if( NULL != dl->local_defs ) { jdf_expr_t *ld; for(ld = jdf_expr_lv_first(dl->local_defs); ld != NULL; ld = jdf_expr_lv_next(dl->local_defs, ld)) { diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 701b8b530..3aca4a20c 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -650,18 +650,18 @@ simulation_cost: | { $$ = NULL; } ; -partitioning: COLON VAR array_offset_or_nothing OPEN_PAR expr_list CLOSE_PAR +partitioning: COLON VAR { named_expr_push_scope(); } array_offset_or_nothing OPEN_PAR expr_list CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); int nbparams; c->var = NULL; - c->array_offset = $3; + c->array_offset = $4; c->func_or_mem = $2; data = jdf_find_or_create_data(¤t_jdf, $2); - c->parameters = $5; - JDF_COUNT_LIST_ENTRIES($5, jdf_expr_t, next, nbparams); + c->parameters = $6; + JDF_COUNT_LIST_ENTRIES($6, jdf_expr_t, next, nbparams); if( data->nbparams != -1 ) { if( data->nbparams != nbparams ) { jdf_fatal(current_lineno, "Data %s used with %d parameters at line %d while used with %d parameters line %d\n", @@ -672,7 +672,8 @@ partitioning: COLON VAR array_offset_or_nothing OPEN_PAR expr_list CLOSE_PAR data->nbparams = nbparams; } $$ = c; - JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($5); + JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($6); + named_expr_pop_scope(); } /* | COLON VAR PROPERTIES_ON expr_simple PROPERTIES_OFF OPEN_PAR expr_list_range CLOSE_PAR @@ -711,11 +712,11 @@ PROPERTIES_ON { named_expr_push_scope(); } named_expr_list PROPERTIES_OFF expr_s } */ -flow_specifier: array_offset PROPERTIES_ON { named_expr_push_scope(); } named_expr_list PROPERTIES_OFF +flow_specifier: { named_expr_push_scope(); } array_offset { jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); - f->array_offset = $1; - f->variables = $4; + f->array_offset = $2; + f->variables = $2; $$ = f; //named_expr_pop_scope(); @@ -789,10 +790,12 @@ array_offset_or_nothing: array_offset { $$ = $1; } - | { $$ = NULL; } + | { + $$ = NULL; + } ; -array_offset: PROPERTIES_ON expr_simple PROPERTIES_OFF +array_offset: PROPERTIES_ON named_expr_list PROPERTIES_OFF { #if !defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) jdf_fatal(current_lineno, "Flow cannot be parametrized (line %d). Set the PARSEC_ALLOW_PARAMETRIZED_FLOWS flag to enable them.\n", @@ -830,6 +833,8 @@ dependency: ARROW named_expr guarded_call properties jdf_def_list_t* property_data = $4; d->local_defs = $2; + // Add the local definitions of the previous scope (the iterator of the parametrized flow if any) + expr = jdf_find_property($4, "type", &property); expr_remote = jdf_find_property($4, "type_remote", &property_remote); @@ -977,6 +982,16 @@ call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_rang c->var = $2; c->array_offset = $3; c->local_defs = $1; + if(c->local_defs) { + // concatenate c->array_offset and ->local_defs + jdf_expr_t *e; + for(e = c->local_defs; e->next; e = e->next); + e->next = c->array_offset; + } + else + { + c->local_defs = c->array_offset; + } c->func_or_mem = $4; c->parameters = $6; $$ = c; @@ -984,22 +999,22 @@ call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_rang assert( 0 != JDF_OBJECT_LINENO($$) ); named_expr_pop_scope(); } - | VAR OPEN_PAR expr_list_range CLOSE_PAR + | VAR { named_expr_push_scope(); } array_offset_or_nothing OPEN_PAR expr_list_range CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); int nbparams; c->var = NULL; - c->array_offset = NULL; + c->array_offset = $3; c->func_or_mem = $1; - c->parameters = $3; - c->local_defs = NULL; - JDF_OBJECT_LINENO(c) = JDF_OBJECT_LINENO($3); + c->parameters = $5; + c->local_defs = c->array_offset; + JDF_OBJECT_LINENO(c) = JDF_OBJECT_LINENO($5); $$ = c; assert( 0 != JDF_OBJECT_LINENO($$) ); data = jdf_find_or_create_data(¤t_jdf, $1); - JDF_COUNT_LIST_ENTRIES($3, jdf_expr_t, next, nbparams); + JDF_COUNT_LIST_ENTRIES($5, jdf_expr_t, next, nbparams); if( data->nbparams != -1 ) { if( data->nbparams != nbparams ) { jdf_fatal(current_lineno, "Data %s used with %d parameters at line %d while used with %d parameters line %d\n", @@ -1009,7 +1024,8 @@ call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_rang } else { data->nbparams = nbparams; } - JDF_OBJECT_LINENO(data) = JDF_OBJECT_LINENO($3); + JDF_OBJECT_LINENO(data) = JDF_OBJECT_LINENO($5); + named_expr_pop_scope(); } | DATA_NEW { From 4fd2b23c7ec2431bff758d7fec3cf75a9372150d Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 27 Oct 2022 14:06:52 -0400 Subject: [PATCH 053/157] merge array_offset and dataflow variables --- parsec/interfaces/ptg/ptg-compiler/jdf.h | 2 -- parsec/interfaces/ptg/ptg-compiler/parsec.y | 3 --- 2 files changed, 5 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.h b/parsec/interfaces/ptg/ptg-compiler/jdf.h index f8af76d8b..f12c1be69 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.h @@ -270,7 +270,6 @@ typedef struct jdf_def_list { typedef struct jdf_flow_specifier { struct jdf_object_t super; - struct jdf_expr *array_offset; struct jdf_expr *variables; } jdf_flow_specifier_t; @@ -291,7 +290,6 @@ struct jdf_dataflow { jdf_dataflow_t *next; struct jdf_expr *local_variables; /**< flows can specify a range */ char *varname; - struct jdf_expr *array_offset; struct jdf_dep *deps; uint8_t flow_index; uint32_t flow_dep_mask_out; diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 3aca4a20c..b88a66925 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -715,7 +715,6 @@ PROPERTIES_ON { named_expr_push_scope(); } named_expr_list PROPERTIES_OFF expr_s flow_specifier: { named_expr_push_scope(); } array_offset { jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); - f->array_offset = $2; f->variables = $2; $$ = f; @@ -724,7 +723,6 @@ flow_specifier: { named_expr_push_scope(); } array_offset | { jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); - f->array_offset = NULL; f->variables = NULL; $$ = f; @@ -751,7 +749,6 @@ dataflow: optional_flow_flags VAR flow_specifier dependencies { named_expr flow->flow_flags = $1; flow->varname = $2; flow->local_variables = flow_specifier->variables; - flow->array_offset = flow_specifier->array_offset; flow->deps = $4; $$ = flow; From 75533bc4919f7da0603d19acd59496240b320e46 Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 27 Oct 2022 14:41:42 -0400 Subject: [PATCH 054/157] add a special range for parametrized flow ranges expr --- parsec/interfaces/ptg/ptg-compiler/jdf.h | 1 + parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 4 ++-- parsec/interfaces/ptg/ptg-compiler/parsec.y | 11 +++++++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.h b/parsec/interfaces/ptg/ptg-compiler/jdf.h index f12c1be69..173892237 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.h @@ -386,6 +386,7 @@ typedef enum { JDF_EQUAL, JDF_SHL, JDF_SHR, JDF_RANGE, + JDF_PARAMETRIZED_FLOW_RANGE, JDF_TERNARY, JDF_VAR, JDF_STRING, diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 2671ae67c..5d8d443ec 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -594,7 +594,7 @@ void dump_parametrized_flow_loop(const jdf_dataflow_t *flow, const char *iterato // Generate the ranges jdf_expr_t *variable=f->local_variables; if(NULL != variable) { - if(variable->op == JDF_RANGE) { + if(variable->op == JDF_PARAMETRIZED_FLOW_RANGE) { expr_info_t expr_info = EMPTY_EXPR_INFO; expr_info.sa = string_arena_new(64); expr_info.prefix = ""; @@ -4005,7 +4005,7 @@ static void jdf_generate_internal_init(const jdf_t *jdf, const jdf_function_entr expr_info.assignments = "max parametrized dataflow"; jdf_expr_t *variable = jdf_expr_lv_first(dataflow->local_variables); - assert(variable->op == JDF_RANGE); + assert(variable->op == JDF_PARAMETRIZED_FLOW_RANGE); jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; coutput("\n%s this_task->data._f_%s = malloc(sizeof(parsec_data_pair_t)*((%s)+1));\n", diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index b88a66925..fb59be228 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -716,6 +716,17 @@ flow_specifier: { named_expr_push_scope(); } array_offset { jdf_flow_specifier_t *f = new(jdf_flow_specifier_t); f->variables = $2; + if( NULL != f->variables->next ) { + // We can only handle parametrized flow with one variable + jdf_fatal(current_lineno, "Flow %s cannot have more than one variable\n", f->variables->alias); + YYERROR; + } + if( JDF_RANGE != f->variables->op ) { + // Parametrized flows must have a range + jdf_fatal(current_lineno, "Flow %s must be a range\n", f->variables->alias); + YYERROR; + } + f->variables->op = JDF_PARAMETRIZED_FLOW_RANGE; // Ranges in parametrized flows are treated differently $$ = f; //named_expr_pop_scope(); From 65e5d6e1e185d80bb3b26707d07df376d876a895 Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 27 Oct 2022 15:23:23 -0400 Subject: [PATCH 055/157] add sanity checks and task class dumps in jdf_generate_constructor --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 5d8d443ec..0921ebb41 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -4913,6 +4913,10 @@ static void jdf_generate_constructor( const jdf_t* jdf ) " tc->incarnations = (__parsec_chore_t*)malloc(2 * sizeof(__parsec_chore_t));\n" " memcpy((__parsec_chore_t*)tc->incarnations, (void*)__parsec_generic_startup.incarnations, 2 * sizeof(__parsec_chore_t));\n" " tc->release_task = parsec_release_task_to_mempool_and_count_as_runtime_tasks;\n" + "\n" + "#if defined(PARSEC_DEBUG_PARANOID)\n" + " parsec_check_sanity_of_task_class(tc);\n" + "#endif\n" " }\n", jdf_basename, jdf_basename); @@ -5004,6 +5008,16 @@ static void jdf_generate_constructor( const jdf_t* jdf ) coutput(" __parsec_tp->super.super.startup_hook = (parsec_startup_fn_t)%s_startup;\n" " (void)parsec_taskpool_reserve_id((parsec_taskpool_t*)__parsec_tp);\n" + "\n\n" + "#if defined(PARSEC_DEBUG_PARANOID)\n" + " // use parsec_debug_dump_task_class_at_exec(tc); on each task class\n" + " parsec_debug_verbose(1, parsec_debug_output, \"############ Task classes before update ############\\n\");\n" + " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" + " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" + " parsec_debug_dump_task_class_at_exec(tc);\n" + " parsec_check_sanity_of_task_class(tc);\n" + " }\n" + "#endif\n" "}\n\n", jdf_basename); From 0c2131600a67a7e40ab8a654117c555a594343d3 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 28 Oct 2022 10:19:58 -0400 Subject: [PATCH 056/157] add the parametrized flow declaration --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 101 ++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 0921ebb41..05c3b7009 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1635,15 +1635,29 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) for(fl = f->dataflow; fl != NULL; fl = fl->next) { rc = asprintf(&JDF_OBJECT_ONAME( fl ), "flow_of_%s_%s_for_%s", jdf_basename, f->fname, fl->varname); assert(rc != -1); - coutput("static%s parsec_flow_t %s;\n", + coutput("static%s parsec_flow_t %s;%s\n", #if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) "", #else " const", #endif - JDF_OBJECT_ONAME( fl )); + JDF_OBJECT_ONAME( fl ), + // Add a comment to make it clear that the flow is parametrized + FLOW_IS_PARAMETRIZED(fl) ? " /* Parametrized flow, will not be used in the execution, but at init time to set up the parametrized specializations */" : ""); } } + coutput("// Declaration of parametrized flow specializations (if any):\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + + coutput("parsec_flow_t *flow_of_%s_%s_for_parametrized_%s;\n", + jdf_basename, f->fname, df->varname); + } + } + } + + coutput("\n\n"); (void)rc; } @@ -5059,6 +5073,89 @@ static void jdf_generate_new_function( const jdf_t* jdf ) "%s", UTIL_DUMP_LIST(sa1, jdf->globals, next, dump_globals_init, sa2, "", " ", "\n", "\n")); + coutput( + "\n" + " // Rework the structure to handle parametrized flows\n" + "\n" + " int i, j;\n" + " /* update the dependency IDs in case of parametrized flows */\n" + " /* The general idea is: */\n" + " /* (A) If a dependency refers to a parametrized flow, it should be divided into N dependencies, */\n" + " /* With each dependency referring to the corresponding flow and having the corresponding cond */\n" + " /* E.g. the jdf: DATA_FROM -> DATA_TO[i+j*SIZE] MyFunc(...) */\n" + " /* should translate into : */\n" + " /* -> ((i+j*SIZE)==0) ? DATA_TO[0] SuccFunc(...) */\n" + " /* -> ((i+j*SIZE)==1) ? DATA_TO[1] SuccFunc(...) */\n" + " /**/\n" + " /* (B) On the other side, if a flow is parametrized: */\n" + " /* It should be divided into N flows, the deps of which should be correctly linked with the corresponding generated dep in (A) */\n" + " /* E.g. the jdf: DATA_TO[it=0...N-1] <- DATA_FROM PredFunc(it%%SIZE, it/size, ...) */\n" + " /* should translate into : */\n" + " /* DATA_TO[0] <- DATA_FROM PredFunc(0, 0, ...) */\n" + " /* DATA_TO[1] <- DATA_FROM PredFunc(1, 0, ...) */\n" + " /* ... */\n" + " /* DATA_TO[SIZE] <- DATA_FROM PredFunc(0, 1, ...) */\n" + " /* DATA_TO[SIZE+1] ... */\n" + " /**/\n" + " /* We refer to (A) as referrer and to (B) as parametrized flow. */\n\n" + ); + + // TODO: delete the following lines when the code is ready +/* + coutput( + " // list of parametrized flows\n" + ); + + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "parametrized flow range"; + + //jdf_expr_t *from = variable->jdf_ta1; + jdf_expr_t *to = df->local_variables->jdf_ta2; + //jdf_expr_t *step = variable->jdf_ta3; + + coutput(" parsec_flow_t *new_flow_for_task_%s_parametrized_flow_%s[(%s)+1];\n", + f->fname, df->varname, dump_expr((void**)to, &expr_info)); + } + } + } + + coutput("\n"); +*/ + + coutput(" // Allocate parametrized flows\n"); + + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "parametrized flow range"; + + //jdf_expr_t *from = variable->jdf_ta1; + jdf_expr_t *to = df->local_variables->jdf_ta2; + //jdf_expr_t *step = variable->jdf_ta3; + + coutput(" flow_of_%s_%s_for_parametrized_%s = alloca(sizeof(parsec_flow_t) * ((%s)+1));\n", + jdf_basename, f->fname, df->varname, dump_expr((void**)to, &expr_info)); + } + } + } + + coutput("\n"); + + /*parsec_flow_t *new_flow_for_task_1_parametrized_flow_GRID_CD_in[((conservatives_number * directions_number) - 1)+1]; + // list of referrers + parsec_dep_t *new_dep_task_0_parametrized_flow_INITIAL_GRID_dep_1_out[((conservatives_number * directions_number) - 1)+1];*/ + + for(jdf_function_entry_t *f = jdf->functions; f != NULL; f = f->next) { coutput(" PARSEC_AYU_REGISTER_TASK(&%s_%s);\n", jdf_basename, f->fname); From 8dc61df36a5225665dc3ac6f2d98e8a6866e3899 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 28 Oct 2022 11:57:12 -0400 Subject: [PATCH 057/157] duplicate parametrized flows in the structure --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 183 +++++++++++++++--- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 68 ++++++- parsec/task_class.c | 13 +- parsec/task_class.h | 2 +- 4 files changed, 230 insertions(+), 36 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 05c3b7009..de6666751 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -590,6 +590,7 @@ void dump_parametrized_flow_loop(const jdf_dataflow_t *flow, const char *iterato string_arena_t *sa = arg; if(f == NULL ) return; + assert(FLOW_IS_PARAMETRIZED(f)); // Generate the ranges jdf_expr_t *variable=f->local_variables; @@ -644,6 +645,7 @@ void dump_parametrized_flow_loop_end(const jdf_dataflow_t *flow, const char *ind string_arena_t *sa = arg; if(f == NULL ) return; + assert(FLOW_IS_PARAMETRIZED(f)); string_arena_add_string(sa, "%s}\n", indent); } @@ -656,7 +658,7 @@ void dump_parametrized_flow_loop_end(const jdf_dataflow_t *flow, const char *ind void dump_parametrized_flow_loop_if_parametrized(const jdf_dataflow_t *flow, const char *indent, void *arg) { if(FLOW_IS_PARAMETRIZED(flow)) { - dump_parametrized_flow_loop(flow, flow->local_variables->alias, indent, arg); + dump_parametrized_flow_loop(flow, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(flow), indent, arg); } } @@ -1646,13 +1648,15 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) FLOW_IS_PARAMETRIZED(fl) ? " /* Parametrized flow, will not be used in the execution, but at init time to set up the parametrized specializations */" : ""); } } - coutput("// Declaration of parametrized flow specializations (if any):\n"); - for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { + if(JDF_ANY_FLOW_IS_PARAMETRIZED(jdf)) { + coutput("// Declaration of parametrized flow specializations:\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { - coutput("parsec_flow_t *flow_of_%s_%s_for_parametrized_%s;\n", - jdf_basename, f->fname, df->varname); + coutput("parsec_flow_t *flow_of_%s_%s_for_parametrized_%s;\n", + jdf_basename, f->fname, df->varname); + } } } } @@ -5046,6 +5050,8 @@ static void jdf_generate_new_function( const jdf_t* jdf ) sa1 = string_arena_new(64); sa2 = string_arena_new(64); + string_arena_t *sa = string_arena_new(64); + coutput("%s\n", UTIL_DUMP_LIST_FIELD( sa1, jdf->globals, next, name, dump_string, NULL, "", "#undef ", "\n", "\n")); @@ -5128,32 +5134,155 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); */ - coutput(" // Allocate parametrized flows\n"); - - for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(64); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "parametrized flow range"; + if(JDF_ANY_FLOW_IS_PARAMETRIZED(jdf)) + { - //jdf_expr_t *from = variable->jdf_ta1; - jdf_expr_t *to = df->local_variables->jdf_ta2; - //jdf_expr_t *step = variable->jdf_ta3; + coutput(" // Allocate parametrized flows\n"); + // Set the parametrized flows upper bounds + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "parametrized flow range"; + + //jdf_expr_t *from = variable->jdf_ta1; + jdf_expr_t *to = df->local_variables->jdf_ta2; + //jdf_expr_t *step = variable->jdf_ta3; + + coutput(" const int nb_specializations_flow_of_%s_%s_for_parametrized_%s = (%s)+1;\n", + jdf_basename, f->fname, df->varname, dump_expr((void**)to, &expr_info)); + } + } + } + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "parametrized flow range"; + + //jdf_expr_t *from = variable->jdf_ta1; + jdf_expr_t *to = df->local_variables->jdf_ta2; + //jdf_expr_t *step = variable->jdf_ta3; + + coutput(" flow_of_%s_%s_for_parametrized_%s = alloca(sizeof(parsec_flow_t) * nb_specializations_flow_of_%s_%s_for_parametrized_%s);\n", + jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); + } + } + } + coutput("\n"); + coutput(" // Unroll all the parametrized flows\n"); + + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" {\n"); + coutput(" // Parametrized flow %s of task class %s\n\n", df->varname, f->fname); + + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n\n", f->task_class_id); + coutput( + " // Shift the flows that are after the parametrized flow\n" + " parsec_shift_all_flows_after(tc, &flow_of_%s_%s_for_%s, nb_specializations_flow_of_%s_%s_for_parametrized_%s-1);\n" + "\n", + jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname + );//GET_PARAMETRIZED_FLOW_ITERATOR_NAME + coutput( + " // Unroll the parametrized flow to generate each specialized flow\n" + ); + + string_arena_init(sa); + dump_parametrized_flow_loop(df, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), " ", sa); + coutput("%s", string_arena_get_string(sa)); - coutput(" flow_of_%s_%s_for_parametrized_%s = alloca(sizeof(parsec_flow_t) * ((%s)+1));\n", - jdf_basename, f->fname, df->varname, dump_expr((void**)to, &expr_info)); + coutput( + " parsec_helper_copy_flow(&flow_of_%s_%s_for_parametrized_%s[%s], &flow_of_%s_%s_for_%s);\n" + " flow_of_%s_%s_for_parametrized_%s[%s].flow_index = %s;\n", + jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) + ); + + string_arena_init(sa); + dump_parametrized_flow_loop_end(df, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + coutput( + "\n" + ); + + coutput( + " // Insert the new flows in the task class\n" + " for(int flow_in_out=0;flow_in_out<2;++flow_in_out) {\n" + " bool pivot_reached = false;\n" + " int %s = 0;\n" + " for(i = 0; i < MAX_PARAM_COUNT && %s < nb_specializations_flow_of_%s_%s_for_parametrized_%s; i++) {\n" + " parsec_flow_t *flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]);\n" + " if(!flow && !pivot_reached) {\n" + " break;\n" + " }\n" + " if(flow == &flow_of_%s_%s_for_%s) {\n" + " pivot_reached = true;\n" + " assert(i+nb_specializations_flow_of_%s_%s_for_parametrized_%s < MAX_PARAM_COUNT);\n" + " }\n" + " if(pivot_reached)\n" + " {\n" + " // Insert the new specialized flow\n" + " (flow_in_out?tc->out:tc->in)[i] = &flow_of_%s_%s_for_parametrized_%s[flow_of_%s_%s_for_%s.flow_index+%s];\n" + " ++%s;\n" + " }\n" + " }\n" + " }\n", + GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) + ); + coutput( + " // Update the mask of each flow\n" + " /*for(i = 0; i < MAX_PARAM_COUNT; i++) {\n" + " parsec_flow_t *flow = tc->out[i];\n" + " if(!flow) {\n" + " break;\n" + " }\n" + " flow->flow_datatype_mask = 1 << flow->flow_index; // TODO verify (related to in/out)\n" + " }*/\n" + " // Update nb_flows\n" + " tc->nb_flows += nb_specializations_flow_of_%s_%s_for_parametrized_%s-1;\n", + jdf_basename, f->fname, df->varname + ); + + coutput(" }\n"); + } } } - } - coutput("\n"); + coutput("\n"); - /*parsec_flow_t *new_flow_for_task_1_parametrized_flow_GRID_CD_in[((conservatives_number * directions_number) - 1)+1]; - // list of referrers - parsec_dep_t *new_dep_task_0_parametrized_flow_INITIAL_GRID_dep_1_out[((conservatives_number * directions_number) - 1)+1];*/ + coutput( + "#if defined(PARSEC_DEBUG_PARANOID)\n" + " // use parsec_debug_dump_task_class_at_exec(tc); on each task class\n" + " parsec_debug_verbose(1, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(1, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(1, parsec_debug_output, \"############ Task classes after update ############\");\n" + " parsec_debug_verbose(1, parsec_debug_output, \"##\");\n" + " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" + " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" + " parsec_debug_dump_task_class_at_exec(tc);" + " parsec_check_sanity_of_task_class(tc);\n" + " }\n" + "#endif\n" + ); + + } + coutput("\n"); for(jdf_function_entry_t *f = jdf->functions; f != NULL; f = f->next) { diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 9444e4c55..d74d6fe83 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -5,6 +5,7 @@ typedef char *(*dumper_function_t)(void **elt, void *arg); + /** * FLOW_IS_PARAMETRIZED: * Tells whether a flow is parametrized or not. @@ -15,6 +16,23 @@ typedef char *(*dumper_function_t)(void **elt, void *arg); #define FLOW_IS_PARAMETRIZED(flow) \ ((flow)->local_variables != NULL) +/** + * GET_PARAMETRIZED_FLOW_ITERATOR_NAME + * @param flow: the flow from which to get the iterator + * + * Returns a string, the name of the iterator + */ +#define GET_PARAMETRIZED_FLOW_ITERATOR_NAME(flow) \ + get_parametrized_flow_iterator_name(flow) + +static inline char *get_parametrized_flow_iterator_name(jdf_dataflow_t *flow) +{ + assert(FLOW_IS_PARAMETRIZED(flow)); + assert(flow->local_variables->next == NULL); // only one iterator for parametrized flows + + return flow->local_variables->alias; +} + /** * INDENTATION_IF_PARAMETRIZED: * Returns an indentation string if the flow is parametrized. @@ -47,7 +65,7 @@ util_dump_array_offset_if_parametrized(string_arena_t *sa, const jdf_dataflow_t string_arena_init(sa); if (FLOW_IS_PARAMETRIZED(flow)) { - string_arena_add_string(sa, "[%s]", flow->local_variables->alias); + string_arena_add_string(sa, "[%s]", get_parametrized_flow_iterator_name(flow)); } return string_arena_get_string(sa); @@ -75,6 +93,54 @@ static inline int variable_is_flow_level_util(const jdf_dataflow_t *flow, const return 0; } +/** + * JDF_ANY_FLOW_IS_PARAMETRIZED: + * Tells whether any flow is parametrized or not. + * Used to avoid code overloading if no paramtrized flow is present. + * @param [IN] jdf: the jdf to test. + * + * @return a boolean value. + */ +#define JDF_ANY_FLOW_IS_PARAMETRIZED(jdf) \ + jdf_any_flow_is_parametrized_util(jdf) + +static inline int jdf_any_flow_is_parametrized_util(const jdf_t *jdf) +{ + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + return 1; + } + } + } + + return 0; +} + +/** + * TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED: + * Tells whether any flow is parametrized or not. + * + * @param [IN] tc: the task class to test. + * + * @return a boolean value. + */ +#define TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(tc) \ + task_class_any_flow_is_parametrized_util(tc) + +static inline int task_class_any_flow_is_parametrized_util(const jdf_function_entry_t *tc) +{ + for( jdf_dataflow_t* df = tc->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + return 1; + } + } + + return 0; +} + + + /** * UTIL_DUMP_LIST_FIELD: * Iterate over the elements of a list, transforming each field element in a string using a parameter function, diff --git a/parsec/task_class.c b/parsec/task_class.c index 24ce239cd..56220622d 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -404,13 +404,12 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) assert(tc->nb_flows == treated_flows_size); } -parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow) +parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *flow_from) { int flow_in_out; - parsec_flow_t *new_flow = (parsec_flow_t *)malloc(sizeof(parsec_flow_t)); - assert(new_flow); - memcpy(new_flow, flow, sizeof(parsec_flow_t)); + assert(flow_to); + memcpy(flow_to, flow_from, sizeof(parsec_flow_t)); // Copy the dependencies int i; @@ -418,7 +417,7 @@ parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow) { for (i = 0; i < flow_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT; i++) { - parsec_dep_t *dep = (parsec_dep_t *)(flow_in_out ? new_flow->dep_out[i] : new_flow->dep_in[i]); + parsec_dep_t *dep = (parsec_dep_t *)(flow_in_out ? flow_to->dep_out[i] : flow_to->dep_in[i]); if (!dep) { @@ -428,11 +427,11 @@ parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow) parsec_dep_t *new_dep = (parsec_dep_t *)malloc(sizeof(parsec_dep_t)); assert(new_dep); memcpy(new_dep, dep, sizeof(parsec_dep_t)); - (flow_in_out ? new_flow->dep_out : new_flow->dep_in)[i] = new_dep; + (flow_in_out ? flow_to->dep_out : flow_to->dep_in)[i] = new_dep; } } - return new_flow; + return flow_to; } parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep) diff --git a/parsec/task_class.h b/parsec/task_class.h index fde6613aa..7878fdbed 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -20,7 +20,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc); void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); // Copy a flow (including its deps) and returns a pointer to the new flow -parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t * flow); +parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *flow_from); parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep); #endif /* PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED */ From c007ded54ba5591978bfb3b0f86c9b7cfbbda306 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 28 Oct 2022 13:50:43 -0400 Subject: [PATCH 058/157] replace MAX_PARAM_COUNT with MAX_DATAFLOWS_PER_TASK and add some code generation in the dep unrolling --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 118 +++++++++++++++++++-- parsec/parsec_internal.h | 4 +- parsec/task_class.c | 24 ++--- 3 files changed, 121 insertions(+), 25 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index de6666751..4517a67af 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1508,9 +1508,9 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) nb_locals, parsec_get_name(NULL, f, "parsec_assignment_t")); string_arena_add_string(sa, - "#if MAX_PARAM_COUNT < %d /* total number of flows for task %s */\n" - " #error Too many flows (%d out of MAX_PARAM_COUNT) for task %s\n" - "#endif /* MAX_PARAM_COUNT */\n", + "#if MAX_DATAFLOWS_PER_TASK < %d /* total number of flows for task %s */\n" + " #error Too many flows (%d out of MAX_DATAFLOWS_PER_TASK) for task %s\n" + "#endif /* MAX_DATAFLOWS_PER_TASK */\n", nb_flows, f->fname, nb_flows, f->fname); string_arena_add_string(sa, "typedef struct %s {\n" "%s" @@ -4455,12 +4455,12 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f out_flows += !!(fl->flow_flags & JDF_FLOW_TYPE_WRITE); } string_arena_add_string(sa, - "#if MAX_PARAM_COUNT < %d /* number of read flows of %s */\n" + "#if MAX_DATAFLOWS_PER_TASK < %d /* number of read flows of %s */\n" " #error Too many read flows for task %s\n" - "#endif /* MAX_PARAM_COUNT */\n" - "#if MAX_PARAM_COUNT < %d /* number of write flows of %s */\n" + "#endif /* MAX_DATAFLOWS_PER_TASK */\n" + "#if MAX_DATAFLOWS_PER_TASK < %d /* number of write flows of %s */\n" " #error Too many write flows for task %s\n" - "#endif /* MAX_PARAM_COUNT */\n", + "#endif /* MAX_DATAFLOWS_PER_TASK */\n", in_flows, f->fname, f->fname, out_flows, f->fname, f->fname); } @@ -5176,6 +5176,23 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } coutput("\n"); + + coutput(" // Store parametrized flows in a table for convenience\n"); + coutput(" parsec_flow_t const *parametrized_flows[MAX_DATAFLOWS_PER_TASK] = {\n"); + int nb_parametrized_flows = 0; + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" &flow_of_%s_%s_for_%s,\n", jdf_basename, f->fname, df->varname); + ++ nb_parametrized_flows; + } + } + } + coutput(" NULL\n };\n"); + coutput(" const int nb_parametrized_flows = %d;\n", nb_parametrized_flows); + + coutput("\n"); + coutput(" // Unroll all the parametrized flows\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { @@ -5221,14 +5238,14 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " for(int flow_in_out=0;flow_in_out<2;++flow_in_out) {\n" " bool pivot_reached = false;\n" " int %s = 0;\n" - " for(i = 0; i < MAX_PARAM_COUNT && %s < nb_specializations_flow_of_%s_%s_for_parametrized_%s; i++) {\n" + " for(i = 0; i < MAX_DATAFLOWS_PER_TASK && %s < nb_specializations_flow_of_%s_%s_for_parametrized_%s; i++) {\n" " parsec_flow_t *flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]);\n" " if(!flow && !pivot_reached) {\n" " break;\n" " }\n" " if(flow == &flow_of_%s_%s_for_%s) {\n" " pivot_reached = true;\n" - " assert(i+nb_specializations_flow_of_%s_%s_for_parametrized_%s < MAX_PARAM_COUNT);\n" + " assert(i+nb_specializations_flow_of_%s_%s_for_parametrized_%s < MAX_DATAFLOWS_PER_TASK);\n" " }\n" " if(pivot_reached)\n" " {\n" @@ -5247,7 +5264,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) ); coutput( " // Update the mask of each flow\n" - " /*for(i = 0; i < MAX_PARAM_COUNT; i++) {\n" + " /*for(i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) {\n" " parsec_flow_t *flow = tc->out[i];\n" " if(!flow) {\n" " break;\n" @@ -5264,6 +5281,84 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } + coutput("\n"); + + coutput(" // Then unroll all the relevant referrer's deps\n"); + // The deps that refer to a parametrized flow are too hard to find at compile time + /*for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next ) { + if( FLOW_IS_PARAMETRIZED(dep->) ) { + if( NULL != dep->referrer->parametrized ) {*/ + + +/* + int tcid, flid, depid; + for( tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++ ) { + parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid]; + + for(int flow_in_out=0;flow_in_out<2;++flow_in_out) { + for( flid=0; flid < MAX_DATAFLOWS_PER_TASK; flid++ ) { + parsec_flow_t *flow = (parsec_flow_t*)(flow_in_out?tc->out[flid]:tc->in[flid]); + if(!flow) { + break; + } + for( depid = 0; depid < flow_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT; ++depid ) { + parsec_dep_t *dep = (parsec_dep_t*)(flow_in_out?flow->dep_out[depid]:flow->dep_in[depid]); + if(!dep) { + break; + } + // If the target flow is a parametrized flow + if(parsec_helper_flow_is_in_flow_array(dep->flow, parametrized_flows, nb_parametrized_flows)) { + // Shift the deps that are after dep (which references the parametrized flow) + parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_parametrized_flow_GRID_CD-1); + // Now that we have space for the new deps, create them making sure they respect the pattern given in (A) + for(int cd=0;cd<=((conservatives_number * directions_number) - 1);cd+=1) { + parsec_dep_t *new_dep = parsec_helper_copy_dep(dep); + assert(NULL != new_dep); + // Compute the pointer to the target parametrized flow specialization and the target expr_cond + parsec_flow_t *target_parametrized_flow = NULL; + parsec_expr_t *target_expr_cond = NULL; + switch(dep->task_class_id) + { + case 1: // task class 0 (LBM_STEP) + switch(dep->flow->flow_index) + { + case 0: // parametrized flow 0 (GRID_CD) of task class 1 (LBM_STEP) + target_parametrized_flow = new_flow_for_task_1_parametrized_flow_GRID_CD_in[cd]; + target_expr_cond = expr_of_parametrized_cond_for_flow_of_LBM_FillGrid_for_INITIAL_GRID_dep1_atline_298_iftrue[cd]; + break; + default: + parsec_debug_verbose(10, parsec_debug_output, "Warning: dep %d of flow %s of task %d references flow %s of task %d which is not parametrized", + depid, dep->flow->name, flid, dep->flow->name, dep->task_class_id); + break; + } + break; + default: + parsec_debug_verbose(10, parsec_debug_output, "Warning: dep %d of flow %s of task %d references task class %d, which has no parametrized flow.", + depid, dep->flow->name, flid, dep->task_class_id); + break; + } + assert(target_parametrized_flow); + assert(target_expr_cond); + new_dep->flow = target_parametrized_flow; + new_dep->cond = target_expr_cond; // TODO ! + // new_dep->ctl_gather_nb = ; // TODO + new_dep->dep_index += cd; + new_dep->dep_datatype_index += cd; // TODO maybe modify? + //assert(new_dep->direct_data != NULL); + // Insert the new dep + (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep; + } + } + } + } + } + } + +*/ + + coutput("\n"); coutput( @@ -5280,7 +5375,8 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " }\n" "#endif\n" ); - + + coutput("\n"); } coutput("\n"); diff --git a/parsec/parsec_internal.h b/parsec/parsec_internal.h index 3beb1310f..3cdd11fcb 100644 --- a/parsec/parsec_internal.h +++ b/parsec/parsec_internal.h @@ -405,8 +405,8 @@ struct parsec_task_class_s { parsec_dependency_t dependencies_goal; const parsec_symbol_t *params[MAX_LOCAL_COUNT]; const parsec_symbol_t *locals[MAX_LOCAL_COUNT]; - const parsec_flow_t *in[MAX_PARAM_COUNT]; - const parsec_flow_t *out[MAX_PARAM_COUNT]; + const parsec_flow_t *in[MAX_DATAFLOWS_PER_TASK]; + const parsec_flow_t *out[MAX_DATAFLOWS_PER_TASK]; const parsec_expr_t *priority; const parsec_property_t *properties; /**< {NULL, NULL} terminated array of properties holding all function-specific properties expressions */ diff --git a/parsec/task_class.c b/parsec/task_class.c index 56220622d..6105a2b60 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -31,8 +31,8 @@ // parsec_dependency_t dependencies_goal; // const parsec_symbol_t *params[MAX_LOCAL_COUNT]; // const parsec_symbol_t *locals[MAX_LOCAL_COUNT]; -// const parsec_flow_t *in[MAX_PARAM_COUNT]; -// const parsec_flow_t *out[MAX_PARAM_COUNT]; +// const parsec_flow_t *in[MAX_DATAFLOWS_PER_TASK]; +// const parsec_flow_t *out[MAX_DATAFLOWS_PER_TASK]; // const parsec_expr_t *priority; // const parsec_property_t *properties; /**< {NULL, NULL} terminated array of properties holding all function-specific properties expressions */ @@ -119,13 +119,13 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_ parsec_dep_t *dep; // use an array to keep track of the flows we already treated - parsec_flow_t *treated_flows[MAX_PARAM_COUNT]; + parsec_flow_t *treated_flows[MAX_DATAFLOWS_PER_TASK]; int treated_flows_size = 0; // Increase the IDs of every flow that is greater than the ID of pivot_flow for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) { - for (i = 0; i < MAX_PARAM_COUNT; i++) + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); if (parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) @@ -161,7 +161,7 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_ // Look for the pivot flow pivot_index = -1; - for (i = 0; i < MAX_PARAM_COUNT; i++) + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); @@ -184,7 +184,7 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_ } // Find the last non-null flow - for (i = pivot_index; i < MAX_PARAM_COUNT; i++) + for (i = pivot_index; i < MAX_DATAFLOWS_PER_TASK; i++) { flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); @@ -202,7 +202,7 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_ assert(flow); // We should not have a NULL flow here // assert(flow->flow_index == i); // The flow index can acutally be anything - assert(i + shift < MAX_PARAM_COUNT); // We should not overflow the array + assert(i + shift < MAX_DATAFLOWS_PER_TASK); // We should not overflow the array // Shift the flow (flow_in_out ? tc->out : tc->in)[i + shift] = flow; @@ -292,7 +292,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) parsec_dep_t *dep; // flows can appear twice in a task class (if both in and out) - parsec_flow_t *treated_flows[MAX_PARAM_COUNT]; + parsec_flow_t *treated_flows[MAX_DATAFLOWS_PER_TASK]; int treated_flows_size = 0; parsec_debug_verbose(1, parsec_debug_output, "###### PRINTING TASK CLASS %s ######", tc->name); @@ -300,7 +300,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) parsec_debug_verbose(1, parsec_debug_output, "## Task Class %s (%p) has %d flows, %d parameters, %d locals", tc->name, (void *)tc, tc->nb_flows, tc->nb_parameters, tc->nb_locals); - for (i = 0; i < MAX_PARAM_COUNT; i++) + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) { @@ -358,10 +358,10 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) parsec_dep_t *dep; // flows can appear twice in a task class (if both in and out) - parsec_flow_t *treated_flows[MAX_PARAM_COUNT]; + parsec_flow_t *treated_flows[MAX_DATAFLOWS_PER_TASK]; int treated_flows_size = 0; - for (i = 0; i < MAX_PARAM_COUNT; i++) + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) { @@ -378,7 +378,7 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) } // Check the coherency of the flow flags - for (i = 0; i < MAX_PARAM_COUNT; i++) + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { flow = tc->out[i]; From 7b4b933d697f5fd9a1fa7bb9d90751e55a21c251 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 28 Oct 2022 16:42:16 -0400 Subject: [PATCH 059/157] beginning of the handling of dep duplication --- parsec/interfaces/ptg/ptg-compiler/jdf.h | 2 +- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 294 ++++++++++++------ .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 2 +- parsec/interfaces/ptg/ptg-compiler/parsec.y | 16 +- 4 files changed, 210 insertions(+), 104 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.h b/parsec/interfaces/ptg/ptg-compiler/jdf.h index 173892237..9a993f217 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.h @@ -344,7 +344,7 @@ typedef struct jdf_call { struct jdf_object_t super; struct jdf_expr *local_defs; /**< Each call can have some local indicies, allowing to define sets of deps */ char *var; /**< If func_or_mem is a function, var is the name of the flow on that function */ - struct jdf_expr *array_offset; /**< Offset required if var is an array */ + struct jdf_expr *parametrized_offset; /**< Offset required if var is an array */ char *func_or_mem; /**< string of the function (task class) or data collection referred to in this call */ struct jdf_expr *parameters; /**< list of parameters for that task class / data collection */ } jdf_call_t; diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 4517a67af..fa5148036 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5024,13 +5024,14 @@ static void jdf_generate_constructor( const jdf_t* jdf ) coutput(" __parsec_tp->super.super.repo_array = %s;\n", (NULL != jdf->functions) ? "__parsec_tp->repositories" : "NULL"); +// TODO use uintX_t instead of uint8 if MAX_DEP_IN_COUNT or MAX_DEP_OUT > 8 ? (in the task structure) coutput(" __parsec_tp->super.super.startup_hook = (parsec_startup_fn_t)%s_startup;\n" " (void)parsec_taskpool_reserve_id((parsec_taskpool_t*)__parsec_tp);\n" "\n\n" "#if defined(PARSEC_DEBUG_PARANOID)\n" " // use parsec_debug_dump_task_class_at_exec(tc); on each task class\n" " parsec_debug_verbose(1, parsec_debug_output, \"############ Task classes before update ############\\n\");\n" - " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" + " for( uint32_t i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" " parsec_debug_dump_task_class_at_exec(tc);\n" " parsec_check_sanity_of_task_class(tc);\n" @@ -5079,32 +5080,34 @@ static void jdf_generate_new_function( const jdf_t* jdf ) "%s", UTIL_DUMP_LIST(sa1, jdf->globals, next, dump_globals_init, sa2, "", " ", "\n", "\n")); - coutput( - "\n" - " // Rework the structure to handle parametrized flows\n" - "\n" - " int i, j;\n" - " /* update the dependency IDs in case of parametrized flows */\n" - " /* The general idea is: */\n" - " /* (A) If a dependency refers to a parametrized flow, it should be divided into N dependencies, */\n" - " /* With each dependency referring to the corresponding flow and having the corresponding cond */\n" - " /* E.g. the jdf: DATA_FROM -> DATA_TO[i+j*SIZE] MyFunc(...) */\n" - " /* should translate into : */\n" - " /* -> ((i+j*SIZE)==0) ? DATA_TO[0] SuccFunc(...) */\n" - " /* -> ((i+j*SIZE)==1) ? DATA_TO[1] SuccFunc(...) */\n" - " /**/\n" - " /* (B) On the other side, if a flow is parametrized: */\n" - " /* It should be divided into N flows, the deps of which should be correctly linked with the corresponding generated dep in (A) */\n" - " /* E.g. the jdf: DATA_TO[it=0...N-1] <- DATA_FROM PredFunc(it%%SIZE, it/size, ...) */\n" - " /* should translate into : */\n" - " /* DATA_TO[0] <- DATA_FROM PredFunc(0, 0, ...) */\n" - " /* DATA_TO[1] <- DATA_FROM PredFunc(1, 0, ...) */\n" - " /* ... */\n" - " /* DATA_TO[SIZE] <- DATA_FROM PredFunc(0, 1, ...) */\n" - " /* DATA_TO[SIZE+1] ... */\n" - " /**/\n" - " /* We refer to (A) as referrer and to (B) as parametrized flow. */\n\n" - ); + if(JDF_ANY_FLOW_IS_PARAMETRIZED(jdf)) + { + coutput( + "\n" + " // Rework the structure to handle parametrized flows\n" + "\n" + " int i, j;\n" + " /* update the dependency IDs in case of parametrized flows */\n" + " /* The general idea is: */\n" + " /* (A) If a dependency refers to a parametrized flow, it should be divided into N dependencies, */\n" + " /* With each dependency referring to the corresponding flow and having the corresponding cond */\n" + " /* E.g. the jdf: DATA_FROM -> DATA_TO[i+j*SIZE] MyFunc(...) */\n" + " /* should translate into : */\n" + " /* -> ((i+j*SIZE)==0) ? DATA_TO[0] SuccFunc(...) */\n" + " /* -> ((i+j*SIZE)==1) ? DATA_TO[1] SuccFunc(...) */\n" + " /**/\n" + " /* (B) On the other side, if a flow is parametrized: */\n" + " /* It should be divided into N flows, the deps of which should be correctly linked with the corresponding generated dep in (A) */\n" + " /* E.g. the jdf: DATA_TO[it=0...N-1] <- DATA_FROM PredFunc(it%%SIZE, it/size, ...) */\n" + " /* should translate into : */\n" + " /* DATA_TO[0] <- DATA_FROM PredFunc(0, 0, ...) */\n" + " /* DATA_TO[1] <- DATA_FROM PredFunc(1, 0, ...) */\n" + " /* ... */\n" + " /* DATA_TO[SIZE] <- DATA_FROM PredFunc(0, 1, ...) */\n" + " /* DATA_TO[SIZE+1] ... */\n" + " /**/\n" + " /* We refer to (A) as referrer and to (B) as parametrized flow. */\n\n" + ); // TODO: delete the following lines when the code is ready /* @@ -5134,9 +5137,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); */ - if(JDF_ANY_FLOW_IS_PARAMETRIZED(jdf)) - { - coutput(" // Allocate parametrized flows\n"); // Set the parametrized flows upper bounds for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { @@ -5177,6 +5177,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } coutput("\n"); + // TODO delete parametrized_flows when not needed anymore! coutput(" // Store parametrized flows in a table for convenience\n"); coutput(" parsec_flow_t const *parametrized_flows[MAX_DATAFLOWS_PER_TASK] = {\n"); int nb_parametrized_flows = 0; @@ -5192,7 +5193,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" const int nb_parametrized_flows = %d;\n", nb_parametrized_flows); coutput("\n"); - + coutput(" // Unroll all the parametrized flows\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { @@ -5284,6 +5285,104 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); coutput(" // Then unroll all the relevant referrer's deps\n"); + int depid; + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + if( NULL !=call->parametrized_offset ) + { + // Then the dep refers to a parametrized flow + + coutput(" {\n"); + coutput(" // %s of %s dep %d of flow %s of task class %s refers to a parametrized flow\n", + target_call?"callfalse":"calltrue", + (dep->dep_flags & JDF_DEP_FLOW_IN)?"input":"output", + dep->dep_index, df->varname, f->fname); + coutput("\n"); + + coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", + jdf_basename, f->fname, df->varname); + coutput(" parsec_dep_t *dep = &%s_dep%d_atline_%d%s;\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + coutput(" int flow_in_out = %d;\n", (dep->dep_flags & JDF_DEP_FLOW_IN)?0:1); + + coutput("\n"); + + coutput( + " // Shift the deps that are after dep (which references the parametrized flow)\n" + " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_flow_of_%s_%s_for_parametrized_%s-1);\n", + jdf_basename, call->func_or_mem, call->var + ); + + coutput(" }\n"); + } +/* + // In the following generated code, dep refers to a parametrized flow + coutput( + " // Shift the deps that are after dep (which references the parametrized flow)\n" + " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_parametrized_flow_GRID_CD-1);\n" + " // Now that we have space for the new deps, create them making sure they respect the pattern given in (A)\n" + " for(int cd=0;cd<=((conservatives_number * directions_number) - 1);cd+=1) {\n" + " parsec_dep_t *new_dep = parsec_helper_copy_dep(dep);\n" + " assert(NULL != new_dep);\n" + " // Compute the pointer to the target parametrized flow specialization and the target expr_cond\n" + " parsec_expr_t *target_expr_cond = NULL;\n" + " parsec_flow_t *target_parametrized_flow = NULL;\n" + " switch(dep->task_class_id)\n" + " {\n" + " case 1: // task class 0 (LBM_STEP)\n" + " switch(dep->flow->flow_index)\n" + " {\n" + " case 0: // parametrized flow 0 (GRID_CD) of task class 1 (LBM_STEP)\n" + " target_parametrized_flow = new_flow_for_task_1_parametrized_flow_GRID_CD_in[cd];\n" + " break;\n" + " default:\n" + " parsec_debug_verbose(10, parsec_debug_output, \"Warning: dep %%d of flow %%s of task %%d references flow %%s of task %%d which is not parametrized\",\n" + " depid, dep->flow->name, flid, dep->flow->name, dep->task_class_id);\n" + " break;\n" + " }\n" + " break;\n" + " default:\n" + " parsec_debug_verbose(10, parsec_debug_output, \"Warning: dep %%d of flow %%s of task %%d references task class %%d, which has no parametrized flow.\",\n" + " depid, dep->flow->name, flid, dep->task_class_id);\n" + " break;\n" + " }\n" + " assert(target_parametrized_flow);\n" + " assert(target_expr_cond);\n" + " new_dep->flow = target_parametrized_flow;\n" + " new_dep->cond = target_expr_cond; // TODO !\n" + " // new_dep->ctl_gather_nb = ; // TODO\n" + " new_dep->dep_index += cd;\n" + " new_dep->dep_datatype_index += cd; // TODO maybe modify?\n" + " //assert(new_dep->direct_data != NULL);\n" + " // Insert the new dep\n" + " (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep;\n" + " }\n" + ); +*/ + + + + + + } + } + } + } + + // The deps that refer to a parametrized flow are too hard to find at compile time /*for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { @@ -5291,71 +5390,78 @@ static void jdf_generate_new_function( const jdf_t* jdf ) if( FLOW_IS_PARAMETRIZED(dep->) ) { if( NULL != dep->referrer->parametrized ) {*/ - /* - int tcid, flid, depid; - for( tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++ ) { - parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid]; - - for(int flow_in_out=0;flow_in_out<2;++flow_in_out) { - for( flid=0; flid < MAX_DATAFLOWS_PER_TASK; flid++ ) { - parsec_flow_t *flow = (parsec_flow_t*)(flow_in_out?tc->out[flid]:tc->in[flid]); - if(!flow) { - break; - } - for( depid = 0; depid < flow_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT; ++depid ) { - parsec_dep_t *dep = (parsec_dep_t*)(flow_in_out?flow->dep_out[depid]:flow->dep_in[depid]); - if(!dep) { - break; - } - // If the target flow is a parametrized flow - if(parsec_helper_flow_is_in_flow_array(dep->flow, parametrized_flows, nb_parametrized_flows)) { - // Shift the deps that are after dep (which references the parametrized flow) - parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_parametrized_flow_GRID_CD-1); - // Now that we have space for the new deps, create them making sure they respect the pattern given in (A) - for(int cd=0;cd<=((conservatives_number * directions_number) - 1);cd+=1) { - parsec_dep_t *new_dep = parsec_helper_copy_dep(dep); - assert(NULL != new_dep); - // Compute the pointer to the target parametrized flow specialization and the target expr_cond - parsec_flow_t *target_parametrized_flow = NULL; - parsec_expr_t *target_expr_cond = NULL; - switch(dep->task_class_id) - { - case 1: // task class 0 (LBM_STEP) - switch(dep->flow->flow_index) - { - case 0: // parametrized flow 0 (GRID_CD) of task class 1 (LBM_STEP) - target_parametrized_flow = new_flow_for_task_1_parametrized_flow_GRID_CD_in[cd]; - target_expr_cond = expr_of_parametrized_cond_for_flow_of_LBM_FillGrid_for_INITIAL_GRID_dep1_atline_298_iftrue[cd]; - break; - default: - parsec_debug_verbose(10, parsec_debug_output, "Warning: dep %d of flow %s of task %d references flow %s of task %d which is not parametrized", - depid, dep->flow->name, flid, dep->flow->name, dep->task_class_id); - break; - } - break; - default: - parsec_debug_verbose(10, parsec_debug_output, "Warning: dep %d of flow %s of task %d references task class %d, which has no parametrized flow.", - depid, dep->flow->name, flid, dep->task_class_id); - break; - } - assert(target_parametrized_flow); - assert(target_expr_cond); - new_dep->flow = target_parametrized_flow; - new_dep->cond = target_expr_cond; // TODO ! - // new_dep->ctl_gather_nb = ; // TODO - new_dep->dep_index += cd; - new_dep->dep_datatype_index += cd; // TODO maybe modify? - //assert(new_dep->direct_data != NULL); - // Insert the new dep - (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep; - } - } - } - } - } - } + coutput( + " int tcid, flid, depid;\n" + " for( tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++ ) {\n" + " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid];\n" + "\n" + " for(int flow_in_out=0;flow_in_out<2;++flow_in_out) {\n" + " for( flid=0; flid < MAX_DATAFLOWS_PER_TASK; flid++ ) {\n" + " parsec_flow_t *flow = (parsec_flow_t*)(flow_in_out?tc->out[flid]:tc->in[flid]);\n" + " if(!flow) {\n" + " break;\n" + " }\n" + " for( depid = 0; depid < flow_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT; ++depid ) {\n" + " parsec_dep_t *dep = (parsec_dep_t*)(flow_in_out?flow->dep_out[depid]:flow->dep_in[depid]);\n" + " if(!dep) {\n" + " break;\n" + " }\n" + " // If the target flow is a parametrized flow\n" + " if(parsec_helper_flow_is_in_flow_array(dep->flow, parametrized_flows, nb_parametrized_flows)) {\n" + ); + + // In the following generated code, dep refers to a parametrized flow + coutput( + " // Shift the deps that are after dep (which references the parametrized flow)\n" + " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_parametrized_flow_GRID_CD-1);\n" + " // Now that we have space for the new deps, create them making sure they respect the pattern given in (A)\n" + " for(int cd=0;cd<=((conservatives_number * directions_number) - 1);cd+=1) {\n" + " parsec_dep_t *new_dep = parsec_helper_copy_dep(dep);\n" + " assert(NULL != new_dep);\n" + " // Compute the pointer to the target parametrized flow specialization and the target expr_cond\n" + " parsec_expr_t *target_expr_cond = NULL;\n" + " parsec_flow_t *target_parametrized_flow = NULL;\n" + " switch(dep->task_class_id)\n" + " {\n" + " case 1: // task class 0 (LBM_STEP)\n" + " switch(dep->flow->flow_index)\n" + " {\n" + " case 0: // parametrized flow 0 (GRID_CD) of task class 1 (LBM_STEP)\n" + " target_parametrized_flow = new_flow_for_task_1_parametrized_flow_GRID_CD_in[cd];\n" + " break;\n" + " default:\n" + " parsec_debug_verbose(10, parsec_debug_output, \"Warning: dep %%d of flow %%s of task %%d references flow %%s of task %%d which is not parametrized\",\n" + " depid, dep->flow->name, flid, dep->flow->name, dep->task_class_id);\n" + " break;\n" + " }\n" + " break;\n" + " default:\n" + " parsec_debug_verbose(10, parsec_debug_output, \"Warning: dep %%d of flow %%s of task %%d references task class %%d, which has no parametrized flow.\",\n" + " depid, dep->flow->name, flid, dep->task_class_id);\n" + " break;\n" + " }\n" + " assert(target_parametrized_flow);\n" + " assert(target_expr_cond);\n" + " new_dep->flow = target_parametrized_flow;\n" + " new_dep->cond = target_expr_cond; // TODO !\n" + " // new_dep->ctl_gather_nb = ; // TODO\n" + " new_dep->dep_index += cd;\n" + " new_dep->dep_datatype_index += cd; // TODO maybe modify?\n" + " //assert(new_dep->direct_data != NULL);\n" + " // Insert the new dep\n" + " (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep;\n" + " }\n" + ); + // Close the brackets + coutput( + " }\n" + " }\n" + " }\n" + " }\n" + " }\n" + ); */ diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index d74d6fe83..615781338 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -25,7 +25,7 @@ typedef char *(*dumper_function_t)(void **elt, void *arg); #define GET_PARAMETRIZED_FLOW_ITERATOR_NAME(flow) \ get_parametrized_flow_iterator_name(flow) -static inline char *get_parametrized_flow_iterator_name(jdf_dataflow_t *flow) +static inline char *get_parametrized_flow_iterator_name(jdf_dataflow_t const *flow) { assert(FLOW_IS_PARAMETRIZED(flow)); assert(flow->local_variables->next == NULL); // only one iterator for parametrized flows diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index fb59be228..9fa10e501 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -657,7 +657,7 @@ partitioning: COLON VAR { named_expr_push_scope(); } array_offset_or_nothing O int nbparams; c->var = NULL; - c->array_offset = $4; + c->parametrized_offset = $4; c->func_or_mem = $2; data = jdf_find_or_create_data(¤t_jdf, $2); c->parameters = $6; @@ -988,17 +988,17 @@ call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_rang { jdf_call_t *c = new(jdf_call_t); c->var = $2; - c->array_offset = $3; + c->parametrized_offset = $3; c->local_defs = $1; if(c->local_defs) { // concatenate c->array_offset and ->local_defs jdf_expr_t *e; for(e = c->local_defs; e->next; e = e->next); - e->next = c->array_offset; + e->next = c->parametrized_offset; } else { - c->local_defs = c->array_offset; + c->local_defs = c->parametrized_offset; } c->func_or_mem = $4; c->parameters = $6; @@ -1014,10 +1014,10 @@ call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_rang int nbparams; c->var = NULL; - c->array_offset = $3; + c->parametrized_offset = $3; c->func_or_mem = $1; c->parameters = $5; - c->local_defs = c->array_offset; + c->local_defs = c->parametrized_offset; JDF_OBJECT_LINENO(c) = JDF_OBJECT_LINENO($5); $$ = c; assert( 0 != JDF_OBJECT_LINENO($$) ); @@ -1039,7 +1039,7 @@ call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_rang { jdf_call_t *c = new(jdf_call_t); c->var = NULL; - c->array_offset = NULL; + c->parametrized_offset = NULL; c->local_defs = NULL; c->func_or_mem = strdup(PARSEC_WRITE_MAGIC_NAME); c->parameters = NULL; @@ -1050,7 +1050,7 @@ call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_rang { jdf_call_t *c = new(jdf_call_t); c->var = NULL; - c->array_offset = NULL; + c->parametrized_offset = NULL; c->local_defs = NULL; c->func_or_mem = strdup(PARSEC_NULL_MAGIC_NAME); c->parameters = NULL; From 3ac3a4c7c4b4781e4e0f2f8dcbd16ad59cb623bb Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 28 Oct 2022 17:29:01 -0400 Subject: [PATCH 060/157] add declaration of referrer deps --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 65 +++++++++++++++++++++- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index fa5148036..10e791e0b 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1649,6 +1649,7 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) } } if(JDF_ANY_FLOW_IS_PARAMETRIZED(jdf)) { + int depid; coutput("// Declaration of parametrized flow specializations:\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { @@ -1659,6 +1660,35 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) } } } + + coutput("// Declaration of the parametrized flows referrers\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + if( NULL !=call->parametrized_offset ) + { + // Then the dep refers to a parametrized flow + + coutput("parsec_dep_t *%s_referrer_dep%d_atline_%d%s;\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + jdf_basename, call->func_or_mem, call->var); + } + } + } + } + } } coutput("\n\n"); @@ -5082,6 +5112,8 @@ static void jdf_generate_new_function( const jdf_t* jdf ) if(JDF_ANY_FLOW_IS_PARAMETRIZED(jdf)) { + int depid; + coutput( "\n" " // Rework the structure to handle parametrized flows\n" @@ -5139,6 +5171,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" // Allocate parametrized flows\n"); // Set the parametrized flows upper bounds + coutput(" // Upper bounds\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { @@ -5157,6 +5190,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } } + coutput(" // Parametrized flows\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { @@ -5170,11 +5204,39 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_expr_t *to = df->local_variables->jdf_ta2; //jdf_expr_t *step = variable->jdf_ta3; - coutput(" flow_of_%s_%s_for_parametrized_%s = alloca(sizeof(parsec_flow_t) * nb_specializations_flow_of_%s_%s_for_parametrized_%s);\n", + coutput(" flow_of_%s_%s_for_parametrized_%s = malloc(sizeof(parsec_flow_t) * nb_specializations_flow_of_%s_%s_for_parametrized_%s);\n", jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); } } } + coutput(" // Referrers\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + if( NULL !=call->parametrized_offset ) + { + // Then the dep refers to a parametrized flow + + coutput(" %s_referrer_dep%d_atline_%d%s = malloc(sizeof(parsec_dep_t) * nb_specializations_flow_of_%s_%s_for_parametrized_%s);\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + jdf_basename, call->func_or_mem, call->var); + } + } + } + } + } coutput("\n"); // TODO delete parametrized_flows when not needed anymore! @@ -5285,7 +5347,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); coutput(" // Then unroll all the relevant referrer's deps\n"); - int depid; for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { depid=1; From a009021f6976eb7954aac4f21e5f1f9b96dc2ccc Mon Sep 17 00:00:00 2001 From: cflinto Date: Sat, 29 Oct 2022 14:04:22 -0400 Subject: [PATCH 061/157] generate presentable code for parametrized flows and their referrers --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 54 +++++++++++++++++++++- parsec/task_class.c | 14 +++--- parsec/task_class.h | 2 +- 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 10e791e0b..5d9120c37 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5313,7 +5313,8 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " if(pivot_reached)\n" " {\n" " // Insert the new specialized flow\n" - " (flow_in_out?tc->out:tc->in)[i] = &flow_of_%s_%s_for_parametrized_%s[flow_of_%s_%s_for_%s.flow_index+%s];\n" + " //(flow_in_out?tc->out:tc->in)[i] = &flow_of_%s_%s_for_parametrized_%s[flow_of_%s_%s_for_%s.flow_index+%s];\n" + " (flow_in_out?tc->out:tc->in)[i] = &flow_of_%s_%s_for_parametrized_%s[%s];\n" " ++%s;\n" " }\n" " }\n" @@ -5323,6 +5324,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) ); coutput( @@ -5378,6 +5380,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); coutput(" int flow_in_out = %d;\n", (dep->dep_flags & JDF_DEP_FLOW_IN)?0:1); + coutput(" int depid=dep->dep_index;\n"); coutput("\n"); @@ -5387,7 +5390,54 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_basename, call->func_or_mem, call->var ); + coutput(" for( int %s=0;%sparametrized_offset->alias, + call->parametrized_offset->alias, + jdf_basename, call->func_or_mem, call->var, + call->parametrized_offset->alias + ); + + coutput( + " parsec_dep_t *dep_specialization = &%s_referrer_dep%d_atline_%d%s[%s];\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + call->parametrized_offset->alias + ); + + coutput(" dep_specialization = parsec_helper_copy_dep(dep_specialization, dep);\n"); + + coutput( + " dep_specialization->flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n", + jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias + ); + coutput( + " dep_specialization->dep_index += %s;\n", + call->parametrized_offset->alias + ); + + coutput( + " (flow_in_out?flow->dep_out:flow->dep_in)[depid+%s] = dep_specialization;\n", + call->parametrized_offset->alias + ); + + coutput(" }\n"); coutput(" }\n"); + + // coutput( + // " parsec_dep_t *new_dep = parsec_helper_copy_dep(dep);\n" + // " assert(NULL != new_dep);\n" + // " new_dep->flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n" + // " //new_dep->cond = target_expr_cond; // TODO !\n" + // " // new_dep->ctl_gather_nb = ; // TODO\n" + // " new_dep->dep_index += %s;\n" + // " //new_dep->dep_datatype_index += cd; // TODO maybe modify?\n" + // " //assert(new_dep->direct_data != NULL);\n" + // " // Insert the new dep\n" + // " (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep;\n", + // jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, + // call->parametrized_offset->alias + //); } /* // In the following generated code, dep refers to a parametrized flow @@ -5537,7 +5587,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " parsec_debug_verbose(1, parsec_debug_output, \"##\");\n" " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" - " parsec_debug_dump_task_class_at_exec(tc);" + " parsec_debug_dump_task_class_at_exec(tc);\n" " parsec_check_sanity_of_task_class(tc);\n" " }\n" "#endif\n" diff --git a/parsec/task_class.c b/parsec/task_class.c index 6105a2b60..fc02f2148 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -268,6 +268,7 @@ void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep (dep_in_out ? flow->dep_out : flow->dep_in)[i + shift] = dep; } + /* // The datatype_mask should stay the same, as we do not add any datatype // Also shift the flow's flow_datatype_mask if(dep_in_out) { @@ -279,6 +280,7 @@ void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep parsec_dependency_t in_between = ((1<<(shift+1))-1) << pivot_dep_index; flow->flow_datatype_mask = unshifted_values | shifted_values | in_between; } + */ } /* Prints the task class information (for debugging purposes) @@ -397,7 +399,7 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) } // All out dependencies should be in the flow datatype mask - assert((1 << dep->dep_index) & flow->flow_datatype_mask); + assert((1 << dep->dep_datatype_index) & flow->flow_datatype_mask); } } @@ -434,10 +436,10 @@ parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *fl return flow_to; } -parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep) +parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_from) { - parsec_dep_t *new_dep = (parsec_dep_t *)malloc(sizeof(parsec_dep_t)); - assert(new_dep); - memcpy(new_dep, dep, sizeof(parsec_dep_t)); - return new_dep; + //parsec_dep_t *new_dep = (parsec_dep_t *)malloc(sizeof(parsec_dep_t)); + assert(dep_to); + memcpy(dep_to, dep_from, sizeof(parsec_dep_t)); + return dep_to; } diff --git a/parsec/task_class.h b/parsec/task_class.h index 7878fdbed..3cb0cb169 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -21,6 +21,6 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); // Copy a flow (including its deps) and returns a pointer to the new flow parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *flow_from); -parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep); +parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_from); #endif /* PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED */ From 2493d80f382f8c9a63603f459e89004735d116c4 Mon Sep 17 00:00:00 2001 From: cflinto Date: Sun, 30 Oct 2022 01:17:51 -0400 Subject: [PATCH 062/157] modify expr_of_cond_for_flow_* if call refers to a parametrized flow --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 42 ++++++++++++++++++--- parsec/interfaces/ptg/ptg-compiler/parsec.y | 21 +++++++++++ 2 files changed, 58 insertions(+), 5 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 5d9120c37..38691bfe5 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1682,8 +1682,7 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) coutput("parsec_dep_t *%s_referrer_dep%d_atline_%d%s;\n", JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", - jdf_basename, call->func_or_mem, call->var); + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); } } } @@ -2843,6 +2842,39 @@ static int jdf_generate_dependency( const jdf_t *jdf, jdf_dataflow_t *flow, jdf_ return ret; } +static inline jdf_expr_t *jdf_create_parametrized_referrer_expr_cond(jdf_expr_t *cond, jdf_expr_t *iterator, jdf_expr_t *parametrized_expr) +{ + // goal: cond -> (iterator == expr) && cond + + jdf_expr_t *iterator_new = malloc(sizeof(jdf_expr_t)); + memcpy(iterator_new, iterator, sizeof(jdf_expr_t)); + iterator_new->op = JDF_VAR; + iterator_new->jdf_var = strdup(iterator->alias); + + jdf_expr_t *equal_expr = malloc(sizeof(jdf_expr_t)); + memcpy(equal_expr, cond, sizeof(jdf_expr_t)); + equal_expr->op = JDF_EQUAL; + equal_expr->jdf_ba1 = iterator_new; + equal_expr->jdf_ba2 = parametrized_expr; + + jdf_expr_t *and_expr = malloc(sizeof(jdf_expr_t)); + memcpy(and_expr, cond, sizeof(jdf_expr_t)); // copy to have the same jdf_obj parameters + and_expr->op = JDF_AND; + and_expr->jdf_ba1 = equal_expr; + and_expr->jdf_ba2 = cond; + + return and_expr; +} + +static inline jdf_expr_t *jdf_create_parametrized_referrer_expr_cond_if_parametrized(jdf_call_t *call, jdf_expr_t *cond) +{ + if (NULL == call->parametrized_offset) { + return cond; + } + + return jdf_create_parametrized_referrer_expr_cond(cond, call->parametrized_offset, call->parametrized_offset); +} + static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* f, jdf_dataflow_t *flow, const char *prefix, int *has_control_gather ) @@ -2898,7 +2930,7 @@ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* sprintf(sep, ",\n "); } else if( dl->guard->guard_type == JDF_GUARD_BINARY ) { sprintf(condname, "expr_of_cond_for_%s", JDF_OBJECT_ONAME(dl)); - jdf_generate_expression(jdf, f, dl->guard->guard, condname); + jdf_generate_expression(jdf, f, jdf_create_parametrized_referrer_expr_cond_if_parametrized(dl->guard->calltrue, dl->guard->guard), condname); sprintf(condname, "&expr_of_cond_for_%s", JDF_OBJECT_ONAME(dl)); indepnorange = jdf_generate_dependency(jdf, flow, dl, dl->guard->calltrue, JDF_OBJECT_ONAME(dl), condname, f) && indepnorange; @@ -2909,7 +2941,7 @@ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* sprintf(depname, "%s_iftrue", JDF_OBJECT_ONAME(dl)); sprintf(condname, "expr_of_cond_for_%s", depname); - jdf_generate_expression(jdf, f, dl->guard->guard, condname); + jdf_generate_expression(jdf, f, jdf_create_parametrized_referrer_expr_cond_if_parametrized(dl->guard->calltrue, dl->guard->guard), condname); sprintf(condname, "&expr_of_cond_for_%s", depname); indepnorange = jdf_generate_dependency(jdf, flow, dl, dl->guard->calltrue, depname, condname, f) && indepnorange; string_arena_add_string(psa, "%s&%s", sep, depname); @@ -2919,7 +2951,7 @@ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* sprintf(condname, "expr_of_cond_for_%s", depname); not.op = JDF_NOT; not.jdf_ua = dl->guard->guard; - jdf_generate_expression(jdf, f, ¬, condname); + jdf_generate_expression(jdf, f, jdf_create_parametrized_referrer_expr_cond_if_parametrized(dl->guard->callfalse, ¬), condname); sprintf(condname, "&expr_of_cond_for_%s", depname); indepnorange = jdf_generate_dependency(jdf, flow, dl, dl->guard->callfalse, depname, condname, f) && indepnorange; string_arena_add_string(psa, "%s&%s", sep, depname); diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 9fa10e501..e284147b4 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -954,6 +954,7 @@ guarded_call: call jdf_guarded_call_t *g = new(jdf_guarded_call_t); g->guard_type = JDF_GUARD_UNCONDITIONAL; g->guard = NULL; + //g->guard = ($1->calltrue->parametrized_offset); // NULL if not a referrer of a parametrized flow g->calltrue = $1; g->callfalse = NULL; $$ = g; @@ -967,6 +968,26 @@ guarded_call: call g->guard = $1; g->calltrue = $3; g->callfalse = NULL; + /*if(g->calltrue->parametrized_offset) // wrong approach, we work in jdf2c to fix the parametrized conds + { + // goal: cond -> (iterator == expr) && cond + + jdf_expr_t *iterator = malloc(sizeof(jdf_expr)); + memcpy(iterator, g->calltrue->parametrized_offset, sizeof(jdf_expr)); + iterator->op = JDF_CST; + + jdf_expr_t *equal_expr = malloc(sizeof(jdf_expr)); + equal_expr->op = JDF_EQ; + equal_expr->jdf_ba1 = iterator; + equal_expr->jdf_ba2 = g->calltrue->parametrized_offset->jdf_ba1; + + jdf_expr_t *and_expr = malloc(sizeof(jdf_expr)); + and_expr->op = JDF_AND; + and_expr->jdf_ba1 = equal_expr; + and_expr->jdf_ba2 = $1; + + g->guard = and_expr; + }*/ $$ = g; assert( 0 != JDF_OBJECT_LINENO($1) ); JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($1); From 9943128d454cb4a5ad1a4380d02abd121a77be69 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 1 Nov 2022 15:23:13 -0400 Subject: [PATCH 063/157] attempt to dump parametrized iterators for referrers --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 83 ++++++++++++++++++++- parsec/interfaces/ptg/ptg-compiler/parsec.y | 46 +++++++++--- 2 files changed, 118 insertions(+), 11 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 38691bfe5..acd6c514f 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -579,6 +579,45 @@ char * dump_expr(void **elem, void *arg) return string_arena_get_string(sa); } +char *dump_referrer_iterator(const jdf_function_entry_t *f, void *arg, jdf_expr_t *e, const char *name) +{ + string_arena_t *sa = arg; + + if(f == NULL ) + { + assert(0); + } + + jdf_call_t *call; + for(jdf_dataflow_t *flow = f->dataflow; NULL != flow; flow = flow->next) { + for(jdf_dep_t *dep = flow->deps; NULL != dep; dep = dep->next) { + jdf_guarded_call_t *guard = dep->guard; + switch(guard->guard_type) { + case JDF_GUARD_TERNARY: + call = guard->callfalse; + //assert( NULL != JDF_OBJECT_ONAME(call) ); + if(call->parametrized_offset) { + string_arena_add_string(sa, " int %s = locals->ldef[%d].value; (void) %s;\n", + call->parametrized_offset->alias, call->parametrized_offset->ldef_index, call->parametrized_offset->alias); + } + case JDF_GUARD_BINARY: + case JDF_GUARD_UNCONDITIONAL: + call = guard->calltrue; + //assert( NULL != JDF_OBJECT_ONAME(call) ); + if(call->parametrized_offset) { + string_arena_add_string(sa, " int %s = locals->ldef[%d].value; (void) %s;\n", + call->parametrized_offset->alias, call->parametrized_offset->ldef_index, call->parametrized_offset->alias); + } + break; + default: + assert(0); + } + } + } + + return string_arena_get_string(sa); +} + /** * dump_parametrized_flow_loop: * dumps the loop preceding a block that needs an iterator for the parametrized flow @@ -1929,10 +1968,23 @@ jdf_generate_function_without_expression(const jdf_t *jdf, coutput("%s\n", UTIL_DUMP_LIST(sa2, f->locals, next, dump_local_assignments, &ai, "", " ", "\n", "\n")); + ai.holder = ""; coutput("%s\n", UTIL_DUMP_LIST(sa2, f->locals, next, dump_local_used_in_expr, &ai, "", " (void)", ";\n", ";")); + + string_arena_init(sa); + + // Iterate over every referrer dep + coutput("%s", dump_referrer_iterator(f, sa, e, name)); + //coutput("//there\n"); + string_arena_init(sa); + + // print name, suffix and rettype + //printf("name: %s, suffix: %s, rettype: %s\n", name, suffix, rettype); + + coutput("\n"); } info.sa = sa; @@ -2007,12 +2059,35 @@ static void jdf_generate_range_min(const jdf_t *jdf, const jdf_function_entry_t " int32_t __parsec_ret;\n", fn_name, jdf_basename, parsec_get_name(jdf, f, "parsec_assignment_t")); + // Declare the parametrized variables + /*for(jdf_dataflow_t *flow = f->dataflow; NULL != flow; flow = flow->next) { + for(jdf_expr_t *it=f->dataflow->local_variables; NULL != it; it = it->next) { + coutput(" int %s = locals->ldef[%d].value;\n", it->alias, it->ldef_index); + } + } + for(jdf_dataflow_t *flow = f->dataflow; NULL != flow; flow = flow->next) { + for(jdf_expr_t *it=f->dataflow->local_variables; NULL != it; it = it->next) { + coutput(" (void) %s;\n", it->alias); + } + }*/ + + ai.sa = sa; ai.holder = "locals->"; ai.expr = expr; coutput("%s\n", UTIL_DUMP_LIST(sa2, f->locals, next, dump_local_assignments, &ai, "", " ", "\n", "\n")); + + string_arena_init(sa); + + // Iterate over every referrer dep + coutput("%s", dump_referrer_iterator(f, sa, expr, fn_name)); + //coutput("//here\n"); + string_arena_init(sa); + + coutput("\n"); + string_arena_free(sa); string_arena_free(sa2); @@ -8407,6 +8482,12 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, } } + // Iterate if the flow is parametrized + dump_parametrized_flow_loop_if_parametrized(flow, " ", sa_open); + if(FLOW_IS_PARAMETRIZED(flow)) { + ++nbopen; + } + for(vl = targetf->locals, i = 0; vl != NULL; vl = vl->next, i++) { for(el = call->parameters, nl = targetf->parameters; @@ -8724,7 +8805,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, // If parametrized flows, this won't work on iterate_predecessors // TODO: probably not f->dataflow but some other flow should be checked #if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) - if(FLOW_IS_PARAMETRIZED(f->dataflow)) + if(FLOW_IS_PARAMETRIZED(f->dataflow) && flow_type == JDF_DEP_FLOW_IN) { coutput(" assert(0); // %s is parametrized, parsec does not handle iterate_predecessors of parametrized flows yet\n", name); } diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index e284147b4..bf5503943 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -305,7 +305,7 @@ process_datatype(jdf_datatransfer_type_t *datatype, %type named_expr %type named_expr_list %type array_offset -%type array_offset_or_nothing +%type named_array_offset_or_nothing %type dependencies %type dependency %type guarded_call @@ -650,7 +650,7 @@ simulation_cost: | { $$ = NULL; } ; -partitioning: COLON VAR { named_expr_push_scope(); } array_offset_or_nothing OPEN_PAR expr_list CLOSE_PAR +partitioning: COLON VAR { named_expr_push_scope(); } named_array_offset_or_nothing OPEN_PAR expr_list CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); @@ -794,7 +794,7 @@ named_expr_list: VAR ASSIGNMENT expr_range } ; -array_offset_or_nothing: array_offset +named_array_offset_or_nothing: array_offset { $$ = $1; } @@ -1005,13 +1005,40 @@ guarded_call: call } ; -call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_range CLOSE_PAR +call: named_expr VAR named_array_offset_or_nothing VAR OPEN_PAR expr_list_range CLOSE_PAR { jdf_call_t *c = new(jdf_call_t); c->var = $2; c->parametrized_offset = $3; - c->local_defs = $1; - if(c->local_defs) { + c->local_defs = $3?$3:$1; // If we want local_defs to contain the parametrized_offset, we need to indicate $3 and not $1 + + /*if($1 != NULL && $3 != NULL) + { // create a new separated parametrized_offset + jdf_expr_t *new_expr = malloc(sizeof(jdf_expr_t)); + memcpy(new_expr, c->parametrized_offset, sizeof(jdf_expr_t)); + new_expr->next = NULL; + c->parametrized_offset = new_expr; + }*/ + + // print infos + printf("call: %s\n", $2); + printf(" parametrized_offset: %s\n", (c->parametrized_offset)?(c->parametrized_offset->alias):""); + printf(" local_defs: "); + for(jdf_expr_t *e = c->local_defs; e != NULL; e = e->next) + { + printf("%s, ", e->alias); + } + printf("\n"); + /*if(c->local_defs) // Normally, $3 should already contain the local_defs of $1 because we pushed them in the same scope + { + assert(c->local_defs->next == NULL); // Only one variable is allowed in the referrer's offset + c->local_defs->next = $1; + } + else + { + c->local_defs = $1; + }*/ + /*if(c->local_defs) { // concatenate c->array_offset and ->local_defs jdf_expr_t *e; for(e = c->local_defs; e->next; e = e->next); @@ -1020,7 +1047,7 @@ call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_rang else { c->local_defs = c->parametrized_offset; - } + }*/ c->func_or_mem = $4; c->parameters = $6; $$ = c; @@ -1028,17 +1055,16 @@ call: named_expr VAR array_offset_or_nothing VAR OPEN_PAR expr_list_rang assert( 0 != JDF_OBJECT_LINENO($$) ); named_expr_pop_scope(); } - | VAR { named_expr_push_scope(); } array_offset_or_nothing OPEN_PAR expr_list_range CLOSE_PAR + | VAR { named_expr_push_scope(); } named_array_offset_or_nothing OPEN_PAR expr_list_range CLOSE_PAR { jdf_data_entry_t* data; jdf_call_t *c = new(jdf_call_t); int nbparams; c->var = NULL; - c->parametrized_offset = $3; + c->parametrized_offset = c->local_defs = $3; c->func_or_mem = $1; c->parameters = $5; - c->local_defs = c->parametrized_offset; JDF_OBJECT_LINENO(c) = JDF_OBJECT_LINENO($5); $$ = c; assert( 0 != JDF_OBJECT_LINENO($$) ); From 19c3cb37a2a17ee69f4cd27bb6b5d3002f81214c Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 1 Nov 2022 16:53:19 -0400 Subject: [PATCH 064/157] remove every attempt to do custom conds --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 14 ++++++++------ parsec/interfaces/ptg/ptg-compiler/parsec.y | 11 +++++++++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index acd6c514f..22edcb541 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1977,7 +1977,7 @@ jdf_generate_function_without_expression(const jdf_t *jdf, string_arena_init(sa); // Iterate over every referrer dep - coutput("%s", dump_referrer_iterator(f, sa, e, name)); + //coutput("%s", dump_referrer_iterator(f, sa, e, name)); //coutput("//there\n"); string_arena_init(sa); @@ -2082,7 +2082,7 @@ static void jdf_generate_range_min(const jdf_t *jdf, const jdf_function_entry_t string_arena_init(sa); // Iterate over every referrer dep - coutput("%s", dump_referrer_iterator(f, sa, expr, fn_name)); + //coutput("%s", dump_referrer_iterator(f, sa, expr, fn_name)); //coutput("//here\n"); string_arena_init(sa); @@ -2941,6 +2941,7 @@ static inline jdf_expr_t *jdf_create_parametrized_referrer_expr_cond(jdf_expr_t return and_expr; } +/* static inline jdf_expr_t *jdf_create_parametrized_referrer_expr_cond_if_parametrized(jdf_call_t *call, jdf_expr_t *cond) { if (NULL == call->parametrized_offset) { @@ -2949,6 +2950,7 @@ static inline jdf_expr_t *jdf_create_parametrized_referrer_expr_cond_if_parametr return jdf_create_parametrized_referrer_expr_cond(cond, call->parametrized_offset, call->parametrized_offset); } +*/ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* f, jdf_dataflow_t *flow, const char *prefix, @@ -3005,7 +3007,7 @@ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* sprintf(sep, ",\n "); } else if( dl->guard->guard_type == JDF_GUARD_BINARY ) { sprintf(condname, "expr_of_cond_for_%s", JDF_OBJECT_ONAME(dl)); - jdf_generate_expression(jdf, f, jdf_create_parametrized_referrer_expr_cond_if_parametrized(dl->guard->calltrue, dl->guard->guard), condname); + jdf_generate_expression(jdf, f, dl->guard->guard, condname); sprintf(condname, "&expr_of_cond_for_%s", JDF_OBJECT_ONAME(dl)); indepnorange = jdf_generate_dependency(jdf, flow, dl, dl->guard->calltrue, JDF_OBJECT_ONAME(dl), condname, f) && indepnorange; @@ -3016,7 +3018,7 @@ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* sprintf(depname, "%s_iftrue", JDF_OBJECT_ONAME(dl)); sprintf(condname, "expr_of_cond_for_%s", depname); - jdf_generate_expression(jdf, f, jdf_create_parametrized_referrer_expr_cond_if_parametrized(dl->guard->calltrue, dl->guard->guard), condname); + jdf_generate_expression(jdf, f, dl->guard->guard, condname); sprintf(condname, "&expr_of_cond_for_%s", depname); indepnorange = jdf_generate_dependency(jdf, flow, dl, dl->guard->calltrue, depname, condname, f) && indepnorange; string_arena_add_string(psa, "%s&%s", sep, depname); @@ -3026,7 +3028,7 @@ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* sprintf(condname, "expr_of_cond_for_%s", depname); not.op = JDF_NOT; not.jdf_ua = dl->guard->guard; - jdf_generate_expression(jdf, f, jdf_create_parametrized_referrer_expr_cond_if_parametrized(dl->guard->callfalse, ¬), condname); + jdf_generate_expression(jdf, f, ¬, condname); sprintf(condname, "&expr_of_cond_for_%s", depname); indepnorange = jdf_generate_dependency(jdf, flow, dl, dl->guard->callfalse, depname, condname, f) && indepnorange; string_arena_add_string(psa, "%s&%s", sep, depname); @@ -8807,7 +8809,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, #if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) if(FLOW_IS_PARAMETRIZED(f->dataflow) && flow_type == JDF_DEP_FLOW_IN) { - coutput(" assert(0); // %s is parametrized, parsec does not handle iterate_predecessors of parametrized flows yet\n", name); + coutput(" parsec_fatal(\"%s is parametrized, parsec does not handle iterate_predecessors of parametrized flows yes\");\n", name); } #endif /* defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) */ diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index bf5503943..5d78d14bc 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -803,6 +803,17 @@ named_array_offset_or_nothing: array_offset } ; +/* +array_offset_or_nothing: array_offset + { + $$ = $1; + } + | { + $$ = NULL; + } + ; +*/ + array_offset: PROPERTIES_ON named_expr_list PROPERTIES_OFF { #if !defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) From 38829a5c14002a2c48bd415d852fb3bbe67e19dc Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 1 Nov 2022 19:13:49 -0400 Subject: [PATCH 065/157] skeleton to get flow indices for parametrized flows --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 22edcb541..9bde78a44 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -4514,6 +4514,11 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f sprintf(prefix, "%s_%s", jdf_basename, f->fname); jdf_generate_function_incarnation_list(jdf, f, sa, prefix); + string_arena_add_string(sa, "typedef struct parsec_%s_task_class_s {\n", JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, " parsec_task_class_t super;\n"); + string_arena_add_string(sa, " int flow_GRID_CD_offset;\n"); + string_arena_add_string(sa, "} parsec_%s_task_class_t;\n", JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, "static const parsec_task_class_t %s = {\n" " .name = \"%s\",\n" @@ -4754,6 +4759,12 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "};\n"); + string_arena_add_string(sa, "static const parsec_%s_task_class_t spec_%s = {\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, " .super = %s,\n", JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, " .flow_GRID_CD_offset = -1\n"); + string_arena_add_string(sa, "};\n"); + + coutput("%s\n\n", string_arena_get_string(sa)); string_arena_free(sa2); From ce714c187768d32f5d34b0870793b68180472d49 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 1 Nov 2022 19:47:16 -0400 Subject: [PATCH 066/157] completed the structure for parametrized flow offsets --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 41 +++++++++++++++++----- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 9bde78a44..c1cedc883 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -4514,11 +4514,6 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f sprintf(prefix, "%s_%s", jdf_basename, f->fname); jdf_generate_function_incarnation_list(jdf, f, sa, prefix); - string_arena_add_string(sa, "typedef struct parsec_%s_task_class_s {\n", JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, " parsec_task_class_t super;\n"); - string_arena_add_string(sa, " int flow_GRID_CD_offset;\n"); - string_arena_add_string(sa, "} parsec_%s_task_class_t;\n", JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, "static const parsec_task_class_t %s = {\n" " .name = \"%s\",\n" @@ -4759,10 +4754,40 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "};\n"); + + string_arena_add_string(sa, "\ntypedef struct parsec_%s_task_class_s {\n", JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, " parsec_task_class_t super;\n"); + + string_arena_add_string(sa, " // Debug field to ensure we do not access out of bounds flows\n#if defined(PARSEC_DEBUG_NOISIER)\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " int nb_specializations_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + } + } + string_arena_add_string(sa, "#endif\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " int offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + } + } + string_arena_add_string(sa, "} parsec_%s_task_class_t;\n\n", JDF_OBJECT_ONAME(f)); + + string_arena_add_string(sa, "static const parsec_%s_task_class_t spec_%s = {\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, " .super = %s,\n", JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, " .flow_GRID_CD_offset = -1\n"); - string_arena_add_string(sa, "};\n"); + string_arena_add_string(sa, " .super = %s", JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, "\n#if defined(PARSEC_DEBUG_NOISIER)\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " , .nb_specializations_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + } + } + string_arena_add_string(sa, "#endif\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " , .offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + } + } + string_arena_add_string(sa, "\n};\n\n"); coutput("%s\n\n", string_arena_get_string(sa)); From 9a5505312c64f161bbb6ff55a03bbff8b2d2af0b Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 1 Nov 2022 20:24:46 -0400 Subject: [PATCH 067/157] move declarations of parametrized stuff inside parsec_X_new --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 83 +++++++++++----------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index c1cedc883..e554b6ae1 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1687,47 +1687,6 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) FLOW_IS_PARAMETRIZED(fl) ? " /* Parametrized flow, will not be used in the execution, but at init time to set up the parametrized specializations */" : ""); } } - if(JDF_ANY_FLOW_IS_PARAMETRIZED(jdf)) { - int depid; - coutput("// Declaration of parametrized flow specializations:\n"); - for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { - - coutput("parsec_flow_t *flow_of_%s_%s_for_parametrized_%s;\n", - jdf_basename, f->fname, df->varname); - } - } - } - - coutput("// Declaration of the parametrized flows referrers\n"); - for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - depid=1; - for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { - for( int target_call=0; target_call<2; ++target_call ) { - assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); - if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) - { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY - continue; - } - jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; - assert(call); - - if( NULL !=call->parametrized_offset ) - { - // Then the dep refers to a parametrized flow - - coutput("parsec_dep_t *%s_referrer_dep%d_atline_%d%s;\n", - JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - } - } - } - } - } - } coutput("\n\n"); (void)rc; @@ -5314,7 +5273,47 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); */ - coutput(" // Allocate parametrized flows\n"); + coutput(" // Declarations\n\n"); + + coutput(" // Declaration of parametrized flow specializations:\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + + coutput(" parsec_flow_t *flow_of_%s_%s_for_parametrized_%s;\n", + jdf_basename, f->fname, df->varname); + } + } + } + + coutput(" // Declaration of the parametrized flows referrers\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + if( NULL !=call->parametrized_offset ) + { + // Then the dep refers to a parametrized flow + + coutput(" parsec_dep_t *%s_referrer_dep%d_atline_%d%s;\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + } + } + } + } + } + // Set the parametrized flows upper bounds coutput(" // Upper bounds\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { From 768a50861ea564e587f307ff189d2a7a5992ced7 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 2 Nov 2022 09:49:11 -0400 Subject: [PATCH 068/157] set number of specializations + ensure that at least one flow is parametrized before creating spec_FLOW --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 73 +++++++++++++--------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index e554b6ae1..4fa8e0396 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -4713,41 +4713,45 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "};\n"); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { + string_arena_add_string(sa, "\ntypedef struct parsec_%s_task_class_s {\n", JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, " parsec_task_class_t super;\n"); - string_arena_add_string(sa, "\ntypedef struct parsec_%s_task_class_s {\n", JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, " parsec_task_class_t super;\n"); - - string_arena_add_string(sa, " // Debug field to ensure we do not access out of bounds flows\n#if defined(PARSEC_DEBUG_NOISIER)\n"); - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " int nb_specializations_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " // Debug field to ensure we do not access out of bounds flows\n#if defined(PARSEC_DEBUG_NOISIER)\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " int nb_specializations_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + } } - } - string_arena_add_string(sa, "#endif\n"); - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " int offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, "#endif\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " int offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + } } - } - string_arena_add_string(sa, "} parsec_%s_task_class_t;\n\n", JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, "} parsec_%s_task_class_t;\n\n", JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, "static const parsec_%s_task_class_t spec_%s = {\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, " .super = %s", JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, "\n#if defined(PARSEC_DEBUG_NOISIER)\n"); - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " , .nb_specializations_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, "static parsec_%s_task_class_t spec_%s = {\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, " .super = %s", JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, "\n#if defined(PARSEC_DEBUG_NOISIER)\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " , .nb_specializations_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + } } - } - string_arena_add_string(sa, "#endif\n"); - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " , .offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, "#endif\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " , .offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + } } + string_arena_add_string(sa, "\n};"); + } - string_arena_add_string(sa, "\n};\n\n"); + coutput("\n\n"); coutput("%s\n\n", string_arena_get_string(sa)); @@ -5383,8 +5387,21 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } coutput("\n"); + coutput(" // Set the number of specializations\n"); + coutput("#if defined(PARSEC_DEBUG_NOISIER)\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" spec_LBM_LBM_STEP.nb_specializations_flow_of_%s_%s_for_%s = nb_specializations_flow_of_%s_%s_for_parametrized_%s;\n", + jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); + } + } + } + coutput("#endif\n"); + coutput("\n"); + // TODO delete parametrized_flows when not needed anymore! - coutput(" // Store parametrized flows in a table for convenience\n"); + coutput("/* // Store parametrized flows in a table for convenience\n"); coutput(" parsec_flow_t const *parametrized_flows[MAX_DATAFLOWS_PER_TASK] = {\n"); int nb_parametrized_flows = 0; for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { @@ -5395,7 +5412,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } } - coutput(" NULL\n };\n"); + coutput(" NULL\n };*/\n"); coutput(" const int nb_parametrized_flows = %d;\n", nb_parametrized_flows); coutput("\n"); From d4b6e53af6300f6d90673168d942ca1952b8bccc Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 2 Nov 2022 10:02:09 -0400 Subject: [PATCH 069/157] set parametrized flow offsets at runtime --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 4fa8e0396..75efc8f5d 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -4727,7 +4727,8 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " int offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " int out_offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + //string_arena_add_string(sa, " int in_offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } } string_arena_add_string(sa, "} parsec_%s_task_class_t;\n\n", JDF_OBJECT_ONAME(f)); @@ -4744,7 +4745,8 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " , .offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " , .out_offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + //string_arena_add_string(sa, " , .in_offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); } } string_arena_add_string(sa, "\n};"); @@ -5392,8 +5394,8 @@ static void jdf_generate_new_function( const jdf_t* jdf ) for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - coutput(" spec_LBM_LBM_STEP.nb_specializations_flow_of_%s_%s_for_%s = nb_specializations_flow_of_%s_%s_for_parametrized_%s;\n", - jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); + coutput(" spec_%s.nb_specializations_flow_of_%s_%s_for_%s = nb_specializations_flow_of_%s_%s_for_parametrized_%s;\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); } } } @@ -5469,6 +5471,9 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " }\n" " if(flow == &flow_of_%s_%s_for_%s) {\n" " pivot_reached = true;\n" + " if(flow_in_out) {\n" + " spec_%s.out_offset_flow_of_%s_%s_for_%s = i;\n" + " }\n" " assert(i+nb_specializations_flow_of_%s_%s_for_parametrized_%s < MAX_DATAFLOWS_PER_TASK);\n" " }\n" " if(pivot_reached)\n" @@ -5483,6 +5488,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), From 5893e7c8e8854910d1041f0dc11e4d1eae1cc397 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 2 Nov 2022 19:10:44 -0400 Subject: [PATCH 070/157] first version of a proper parametrized call in iterate_successors --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 414 +++++++++++------- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 27 +- parsec/task_class.c | 85 ++++ parsec/task_class.h | 4 + 4 files changed, 366 insertions(+), 164 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 75efc8f5d..83bf2d7f0 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1574,6 +1574,8 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) jdf_basename, f->fname, jdf_basename, f->fname, parsec_get_name(NULL, f, "task_t")); + + string_arena_free(sa_locals); string_arena_free(sa_data); return string_arena_get_string(sa); @@ -1663,12 +1665,96 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) string_arena_t *sa2 = string_arena_new(64); int rc; + // If has any parametrized flow + if(JDF_ANY_FLOW_IS_PARAMETRIZED(jdf)) { + /*for(f = jdf->functions; f != NULL; f = f->next) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput("typedef struct parsec_%s_%s_task_class_s parsec_%s_%s_task_class_t;\n", jdf_basename, f->fname, jdf_basename, f->fname); + } + } + } + for(f = jdf->functions; f != NULL; f = f->next) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput("struct parsec_%s_%s_task_class_s;\n", jdf_basename, f->fname); + } + } + }*/ + + for(f = jdf->functions; f != NULL; f = f->next) { + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { + coutput("\ntypedef struct parsec_%s_%s_task_class_s {\n", jdf_basename, f->fname); + coutput(" parsec_task_class_t super;\n"); + + // First parametrized flows: + coutput(" // Local parametrized flows of %s\n#if defined(PARSEC_DEBUG_NOISIER)\n", f->fname); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" int nb_specializations_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + } + } + coutput("#endif\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" int out_offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + } + } + + // Then the referrers + coutput(" // Local referrers of %s\n", f->fname); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + int depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + if( NULL != call->parametrized_offset ) + { + // Then the dep refers to a parametrized flow + + coutput(" int out_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + + // We also keep track of the flow that id that contains the referrer + coutput(" int out_flow_id_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + } + } + } + } + coutput("} parsec_%s_%s_task_class_t;\n\n", jdf_basename, f->fname); + } + } + } + coutput("/** Predeclarations of the parsec_task_class_t */\n"); for(f = jdf->functions; f != NULL; f = f->next) { rc = asprintf(&JDF_OBJECT_ONAME( f ), "%s_%s", jdf_basename, f->fname); assert(rc != -1); coutput("static const parsec_task_class_t %s;\n", JDF_OBJECT_ONAME( f )); } + + // If has any parametrized flow + if(JDF_ANY_FLOW_IS_PARAMETRIZED(jdf)) { + coutput("/** Predeclarations of the parametrized spec_TASK_TYPES */\n"); + for(f = jdf->functions; f != NULL; f = f->next) { + coutput("static parsec_%s_task_class_t spec_%s;\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); + } + } + string_arena_free(sa); string_arena_free(sa2); coutput("/** Predeclarations of the parameters */\n"); @@ -4713,42 +4799,60 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "};\n"); - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { - string_arena_add_string(sa, "\ntypedef struct parsec_%s_task_class_s {\n", JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, " parsec_task_class_t super;\n"); + string_arena_add_string(sa, "static parsec_%s_task_class_t spec_%s = {\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, " .super = %s", JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, " // Debug field to ensure we do not access out of bounds flows\n#if defined(PARSEC_DEBUG_NOISIER)\n"); + // First parametrized flows: + string_arena_add_string(sa, " // Local parametrized flows of %s\n", f->fname); + string_arena_add_string(sa, "#if defined(PARSEC_DEBUG_NOISIER)\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " int nb_specializations_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " , .nb_specializations_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); } } string_arena_add_string(sa, "#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " int out_offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); - //string_arena_add_string(sa, " int in_offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " , .out_offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); } } - string_arena_add_string(sa, "} parsec_%s_task_class_t;\n\n", JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, "static parsec_%s_task_class_t spec_%s = {\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, " .super = %s", JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, "\n#if defined(PARSEC_DEBUG_NOISIER)\n"); - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " , .nb_specializations_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); - } - } - string_arena_add_string(sa, "#endif\n"); + // Then the referrers + string_arena_add_string(sa, " // Local referrers of %s\n", f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " , .out_offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); - //string_arena_add_string(sa, " , .in_offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + int depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + if( NULL != call->parametrized_offset ) + { + string_arena_add_string(sa, " , .out_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + string_arena_add_string(sa, " , .out_flow_id_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + } + } } } + + + string_arena_add_string(sa, "\n};"); } @@ -5306,7 +5410,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; assert(call); - if( NULL !=call->parametrized_offset ) + if( NULL != call->parametrized_offset ) { // Then the dep refers to a parametrized flow @@ -5373,7 +5477,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; assert(call); - if( NULL !=call->parametrized_offset ) + if( NULL != call->parametrized_offset ) { // Then the dep refers to a parametrized flow @@ -5459,6 +5563,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) "\n" ); + coutput( " // Insert the new flows in the task class\n" " for(int flow_in_out=0;flow_in_out<2;++flow_in_out) {\n" @@ -5471,9 +5576,10 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " }\n" " if(flow == &flow_of_%s_%s_for_%s) {\n" " pivot_reached = true;\n" - " if(flow_in_out) {\n" - " spec_%s.out_offset_flow_of_%s_%s_for_%s = i;\n" - " }\n" +// out_offset_flow_of_%s_%s_for_%s will be computed after all the shifts have been computed, just to be certain that no future shift will change the value +// " if(flow_in_out) {\n" +// " spec_%s.out_offset_flow_of_%s_%s_for_%s = i;\n" +// " }\n" " assert(i+nb_specializations_flow_of_%s_%s_for_parametrized_%s < MAX_DATAFLOWS_PER_TASK);\n" " }\n" " if(pivot_reached)\n" @@ -5488,7 +5594,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + //JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), @@ -5529,7 +5635,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; assert(call); - if( NULL !=call->parametrized_offset ) + if( NULL != call->parametrized_offset ) { // Then the dep refers to a parametrized flow @@ -5549,6 +5655,15 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" int flow_in_out = %d;\n", (dep->dep_flags & JDF_DEP_FLOW_IN)?0:1); coutput(" int depid=dep->dep_index;\n"); + +// spec_%s_%s.offset_%s%s will be computed after all the shifts have been computed, just to be certain that no future shift will change the value + /* + coutput("\n"); + coutput(" spec_%s_%s.offset_%s%s = parsec_helper_get_dep_index(flow, dep, flow_in_out);\n", + jdf_basename, f->fname, JDF_OBJECT_ONAME(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "");*/ + coutput("\n"); coutput( @@ -5606,142 +5721,75 @@ static void jdf_generate_new_function( const jdf_t* jdf ) // call->parametrized_offset->alias //); } -/* - // In the following generated code, dep refers to a parametrized flow - coutput( - " // Shift the deps that are after dep (which references the parametrized flow)\n" - " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_parametrized_flow_GRID_CD-1);\n" - " // Now that we have space for the new deps, create them making sure they respect the pattern given in (A)\n" - " for(int cd=0;cd<=((conservatives_number * directions_number) - 1);cd+=1) {\n" - " parsec_dep_t *new_dep = parsec_helper_copy_dep(dep);\n" - " assert(NULL != new_dep);\n" - " // Compute the pointer to the target parametrized flow specialization and the target expr_cond\n" - " parsec_expr_t *target_expr_cond = NULL;\n" - " parsec_flow_t *target_parametrized_flow = NULL;\n" - " switch(dep->task_class_id)\n" - " {\n" - " case 1: // task class 0 (LBM_STEP)\n" - " switch(dep->flow->flow_index)\n" - " {\n" - " case 0: // parametrized flow 0 (GRID_CD) of task class 1 (LBM_STEP)\n" - " target_parametrized_flow = new_flow_for_task_1_parametrized_flow_GRID_CD_in[cd];\n" - " break;\n" - " default:\n" - " parsec_debug_verbose(10, parsec_debug_output, \"Warning: dep %%d of flow %%s of task %%d references flow %%s of task %%d which is not parametrized\",\n" - " depid, dep->flow->name, flid, dep->flow->name, dep->task_class_id);\n" - " break;\n" - " }\n" - " break;\n" - " default:\n" - " parsec_debug_verbose(10, parsec_debug_output, \"Warning: dep %%d of flow %%s of task %%d references task class %%d, which has no parametrized flow.\",\n" - " depid, dep->flow->name, flid, dep->task_class_id);\n" - " break;\n" - " }\n" - " assert(target_parametrized_flow);\n" - " assert(target_expr_cond);\n" - " new_dep->flow = target_parametrized_flow;\n" - " new_dep->cond = target_expr_cond; // TODO !\n" - " // new_dep->ctl_gather_nb = ; // TODO\n" - " new_dep->dep_index += cd;\n" - " new_dep->dep_datatype_index += cd; // TODO maybe modify?\n" - " //assert(new_dep->direct_data != NULL);\n" - " // Insert the new dep\n" - " (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep;\n" - " }\n" - ); -*/ - - - - - } } } } - // The deps that refer to a parametrized flow are too hard to find at compile time - /*for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + coutput(" // Finally, set the correct indices for the parametrized flows and the referrers\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" { // Parametrized flow %s of task class %s\n", df->varname, f->fname); + //coutput(" parsec_task_class_t *tc = &parsec_%s_%s;\n", jdf_basename, f->fname); + //coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_parametrized_%s[0];\n", jdf_basename, f->fname, df->varname); + //coutput(" spec_%s.out_offset_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out);\n" + // JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname,); + + // For the moment, do not set this, I think it is not needed + coutput(" spec_%s.out_offset_flow_of_%s_%s_for_%s = -1;\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput(" }\n"); + } + } + } + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next ) { - if( FLOW_IS_PARAMETRIZED(dep->) ) { - if( NULL != dep->referrer->parametrized ) {*/ + depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); -/* - coutput( - " int tcid, flid, depid;\n" - " for( tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++ ) {\n" - " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid];\n" - "\n" - " for(int flow_in_out=0;flow_in_out<2;++flow_in_out) {\n" - " for( flid=0; flid < MAX_DATAFLOWS_PER_TASK; flid++ ) {\n" - " parsec_flow_t *flow = (parsec_flow_t*)(flow_in_out?tc->out[flid]:tc->in[flid]);\n" - " if(!flow) {\n" - " break;\n" - " }\n" - " for( depid = 0; depid < flow_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT; ++depid ) {\n" - " parsec_dep_t *dep = (parsec_dep_t*)(flow_in_out?flow->dep_out[depid]:flow->dep_in[depid]);\n" - " if(!dep) {\n" - " break;\n" - " }\n" - " // If the target flow is a parametrized flow\n" - " if(parsec_helper_flow_is_in_flow_array(dep->flow, parametrized_flows, nb_parametrized_flows)) {\n" - ); + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } - // In the following generated code, dep refers to a parametrized flow - coutput( - " // Shift the deps that are after dep (which references the parametrized flow)\n" - " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_parametrized_flow_GRID_CD-1);\n" - " // Now that we have space for the new deps, create them making sure they respect the pattern given in (A)\n" - " for(int cd=0;cd<=((conservatives_number * directions_number) - 1);cd+=1) {\n" - " parsec_dep_t *new_dep = parsec_helper_copy_dep(dep);\n" - " assert(NULL != new_dep);\n" - " // Compute the pointer to the target parametrized flow specialization and the target expr_cond\n" - " parsec_expr_t *target_expr_cond = NULL;\n" - " parsec_flow_t *target_parametrized_flow = NULL;\n" - " switch(dep->task_class_id)\n" - " {\n" - " case 1: // task class 0 (LBM_STEP)\n" - " switch(dep->flow->flow_index)\n" - " {\n" - " case 0: // parametrized flow 0 (GRID_CD) of task class 1 (LBM_STEP)\n" - " target_parametrized_flow = new_flow_for_task_1_parametrized_flow_GRID_CD_in[cd];\n" - " break;\n" - " default:\n" - " parsec_debug_verbose(10, parsec_debug_output, \"Warning: dep %%d of flow %%s of task %%d references flow %%s of task %%d which is not parametrized\",\n" - " depid, dep->flow->name, flid, dep->flow->name, dep->task_class_id);\n" - " break;\n" - " }\n" - " break;\n" - " default:\n" - " parsec_debug_verbose(10, parsec_debug_output, \"Warning: dep %%d of flow %%s of task %%d references task class %%d, which has no parametrized flow.\",\n" - " depid, dep->flow->name, flid, dep->task_class_id);\n" - " break;\n" - " }\n" - " assert(target_parametrized_flow);\n" - " assert(target_expr_cond);\n" - " new_dep->flow = target_parametrized_flow;\n" - " new_dep->cond = target_expr_cond; // TODO !\n" - " // new_dep->ctl_gather_nb = ; // TODO\n" - " new_dep->dep_index += cd;\n" - " new_dep->dep_datatype_index += cd; // TODO maybe modify?\n" - " //assert(new_dep->direct_data != NULL);\n" - " // Insert the new dep\n" - " (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep;\n" - " }\n" - ); + if( NULL != call->parametrized_offset ) + { - // Close the brackets - coutput( - " }\n" - " }\n" - " }\n" - " }\n" - " }\n" - ); -*/ + coutput(" { // Parametrized referrer %s of task class %s\n", df->varname, f->fname); + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n", f->task_class_id); + coutput(" parsec_dep_t *dep = %s_referrer_dep%d_atline_%d%s;\n\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + assert(!FLOW_IS_PARAMETRIZED(df)); // If the flow is parametrized, + + coutput(" spec_%s.out_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, dep, 1);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + coutput(" spec_%s.out_flow_id_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_flow_index_that_contains_dep(tc, dep, 1);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + coutput(" }\n"); + } + } + } + } + } coutput("\n"); @@ -9046,11 +9094,27 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_add_string(sa_datatype," }\n"); string_arena_init(sa_ontask); - string_arena_add_string(sa_ontask, - "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, &%s, &data, rank_src, rank_dst, vpid_dst," - " successor_repo, successor_repo_key, ontask_arg) )\n" - " return;\n", - JDF_OBJECT_ONAME(dl->guard->calltrue)); + if(NULL != dl->guard->calltrue->parametrized_offset) + { + jdf_call_t *call = dl->guard->calltrue; + string_arena_add_string(sa_ontask, + "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_offset_flow_of_%s_%s_for_%s+%s]" + "->dep_out[spec_%s_%s.out_flow_id_of_%s+%s]" + ", &data, rank_src, rank_dst, vpid_dst," + " successor_repo, successor_repo_key, ontask_arg) )\n" + " return;\n", + jdf_basename, call->func_or_mem, jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + } + else + { + string_arena_add_string(sa_ontask, + "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, &%s, &data, rank_src, rank_dst, vpid_dst," + " successor_repo, successor_repo_key, ontask_arg) )\n" + " return;\n", + JDF_OBJECT_ONAME(dl->guard->calltrue)); + } /* if(dl->guard->guard_type == JDF_GUARD_TERNARY && NULL != dl->guard->callfalse) { @@ -9156,11 +9220,27 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, depnb++; string_arena_init(sa_ontask); - string_arena_add_string(sa_ontask, + if(NULL != dl->guard->callfalse->parametrized_offset) + { + jdf_call_t *call = dl->guard->callfalse; + string_arena_add_string(sa_ontask, + "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, " + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_offset_flow_of_%s_%s_for_%s+%s]" + "->dep_out[spec_%s_%s.out_flow_id_of_%s+%s]" + ", &data, rank_src, rank_dst, vpid_dst," + " successor_repo, successor_repo_key, ontask_arg) )\n" + " return;\n", + jdf_basename, call->func_or_mem, jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + } + else + { + string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, &%s, &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", JDF_OBJECT_ONAME(dl->guard->callfalse)); + } if( NULL != dl->guard->callfalse->var ) { string_arena_add_string(sa_deps, @@ -9177,11 +9257,27 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, } else { depnb++; string_arena_init(sa_ontask); - string_arena_add_string(sa_ontask, + if(NULL != dl->guard->callfalse->parametrized_offset) + { + jdf_call_t *call = dl->guard->callfalse; + string_arena_add_string(sa_ontask, + "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, " + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_offset_flow_of_%s_%s_for_%s+%s]" + "->dep_out[spec_%s_%s.out_flow_id_of_%s+%s]" + ", &data, rank_src, rank_dst, vpid_dst," + " successor_repo, successor_repo_key, ontask_arg) )\n" + " return;\n", + jdf_basename, call->func_or_mem, jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + } + else + { + string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, &%s, &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", JDF_OBJECT_ONAME(dl->guard->callfalse)); + } if( NULL != dl->guard->callfalse->var ) { flowempty = 0; diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 615781338..054aea73d 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -118,22 +118,39 @@ static inline int jdf_any_flow_is_parametrized_util(const jdf_t *jdf) } /** - * TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED: - * Tells whether any flow is parametrized or not. + * TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER: + * Tells whether any flow is parametrized or if one of the deps is a referrer. * * @param [IN] tc: the task class to test. * * @return a boolean value. */ -#define TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(tc) \ - task_class_any_flow_is_parametrized_util(tc) +#define TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(tc) \ + task_class_any_flow_is_parametrized_or_referrer_util(tc) -static inline int task_class_any_flow_is_parametrized_util(const jdf_function_entry_t *tc) +static inline int task_class_any_flow_is_parametrized_or_referrer_util(const jdf_function_entry_t *tc) { for( jdf_dataflow_t* df = tc->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { return 1; } + + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next ) { + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + if( NULL !=call->parametrized_offset ) + { + return 1; + } + } + } } return 0; diff --git a/parsec/task_class.c b/parsec/task_class.c index fc02f2148..368130ad6 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -443,3 +443,88 @@ parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_f memcpy(dep_to, dep_from, sizeof(parsec_dep_t)); return dep_to; } + +int parsec_helper_dep_is_in_flow(parsec_flow_t *flow, parsec_dep_t *dep) +{ + int i; + for (i = 0; i < MAX_DEP_IN_COUNT; i++) + { + parsec_dep_t *_dep = flow->dep_in[i]; + if(!dep) + { + break; + } + if (dep == _dep) + { + return 1; + } + } + + for (i = 0; i < MAX_DEP_OUT_COUNT; i++) + { + parsec_dep_t *_dep = flow->dep_out[i]; + if(!dep) + { + break; + } + if (dep == _dep) + { + return 1; + } + } + + return 0; +} + +int parsec_helper_get_dep_index(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out) +{ + int i; + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) + { + parsec_flow_t *flow = (parsec_flow_t *)(in_out ? tc->out[i] : tc->in[i]); + if (!flow) + { + break; + } + + if (parsec_helper_dep_is_in_flow(flow, dep)) + { + for(int j = 0; j < (in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) + { + parsec_dep_t *_dep = (parsec_dep_t *)(in_out ? flow->dep_out[j] : flow->dep_in[j]); + if(!_dep) + { + break; + } + if(_dep == dep) + { + return j; + } + } + } + } + + return -1; +} + +int parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out) +{ + int i; + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) + { + parsec_flow_t *flow = (in_out ? tc->out[i] : tc->in[i]); + + if (!flow) + { + break; + } + + if (parsec_helper_dep_is_in_flow(flow, dep)) + { + return i; + } + } + + assert(0); + return -1; +} diff --git a/parsec/task_class.h b/parsec/task_class.h index 3cb0cb169..e80893e34 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -23,4 +23,8 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *flow_from); parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_from); +int parsec_helper_dep_is_in_flow(parsec_flow_t *flow, parsec_dep_t *dep); +int parsec_helper_get_dep_index(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out); +int parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out); + #endif /* PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED */ From 03f54132b2ad800f39e6692dd4c8da6acde6be68 Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 3 Nov 2022 09:53:53 -0400 Subject: [PATCH 071/157] correct generated code --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 83bf2d7f0..06cd0770d 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -9099,12 +9099,12 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, jdf_call_t *call = dl->guard->calltrue; string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_offset_flow_of_%s_%s_for_%s+%s]" - "->dep_out[spec_%s_%s.out_flow_id_of_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_id_of_%s]" + "->dep_out[spec_%s_%s.out_offset_%s+%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", - jdf_basename, call->func_or_mem, jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); } else @@ -9225,12 +9225,12 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, jdf_call_t *call = dl->guard->callfalse; string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_offset_flow_of_%s_%s_for_%s+%s]" - "->dep_out[spec_%s_%s.out_flow_id_of_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_id_of_%s]" + "->dep_out[spec_%s_%s.out_offset_%s+%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", - jdf_basename, call->func_or_mem, jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); } else @@ -9262,12 +9262,12 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, jdf_call_t *call = dl->guard->callfalse; string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_offset_flow_of_%s_%s_for_%s+%s]" - "->dep_out[spec_%s_%s.out_flow_id_of_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_id_of_%s]" + "->dep_out[spec_%s_%s.out_offset_%s+%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", - jdf_basename, call->func_or_mem, jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); } else From 429ce6c1740451aaecc6ded3737feb514560e84e Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 3 Nov 2022 11:31:57 -0400 Subject: [PATCH 072/157] correct the parsec_fatal for when iterate_predecessors is called with smt parametrized --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 5 +- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 57 +++++++++++++------ 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 06cd0770d..57e31e7c5 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -8911,11 +8911,10 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, dump_local_assignments, &ai, "", " ", "\n", "\n")); // If parametrized flows, this won't work on iterate_predecessors - // TODO: probably not f->dataflow but some other flow should be checked #if defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) - if(FLOW_IS_PARAMETRIZED(f->dataflow) && flow_type == JDF_DEP_FLOW_IN) + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f) && (flow_type & JDF_DEP_FLOW_IN)) { - coutput(" parsec_fatal(\"%s is parametrized, parsec does not handle iterate_predecessors of parametrized flows yes\");\n", name); + coutput(" parsec_fatal(\"%s is parametrized, parsec does not handle iterate_predecessors of parametrized flows yet\");\n", name); } #endif /* defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) */ diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 054aea73d..867f5606e 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -117,6 +117,44 @@ static inline int jdf_any_flow_is_parametrized_util(const jdf_t *jdf) return 0; } +/** + * FLOW_IS_PARAMETRIZED_OR_ANY_DEP_IS_REFERRER + * + * Tells whether a flow is parametrized or not, or if any of its dependencies is a referrer. + * + * @param [IN] flow: the flow to test. + * + * @return a boolean value. + */ +#define FLOW_IS_PARAMETRIZED_OR_ANY_DEP_IS_REFERRER(flow) \ + flow_is_parametrized_or_any_dep_is_referrer_util(flow) + +static inline int flow_is_parametrized_or_any_dep_is_referrer_util(const jdf_dataflow_t *flow) +{ + if (FLOW_IS_PARAMETRIZED(flow)) { + return 1; + } + + for( jdf_dep_t *dep = flow->deps; NULL != dep; dep = dep->next ) { + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + if( NULL != call->parametrized_offset ) + { + return 1; + } + } + } + + return 0; +} + /** * TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER: * Tells whether any flow is parametrized or if one of the deps is a referrer. @@ -131,26 +169,9 @@ static inline int jdf_any_flow_is_parametrized_util(const jdf_t *jdf) static inline int task_class_any_flow_is_parametrized_or_referrer_util(const jdf_function_entry_t *tc) { for( jdf_dataflow_t* df = tc->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { + if( FLOW_IS_PARAMETRIZED_OR_ANY_DEP_IS_REFERRER(df) ) { return 1; } - - for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next ) { - for( int target_call=0; target_call<2; ++target_call ) { - assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); - if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) - { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY - continue; - } - jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; - assert(call); - - if( NULL !=call->parametrized_offset ) - { - return 1; - } - } - } } return 0; From d27bd572f2354a0f8c2c6da8b010fe2468f52176 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 4 Nov 2022 13:44:35 -0400 Subject: [PATCH 073/157] shift the goal + move the parametrized data malloc --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 77 +++++++++------------- parsec/task_class.c | 2 + 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 57e31e7c5..a692fca5a 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -3410,22 +3410,6 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr fname, parsec_get_name(jdf, f, "task_t"), parsec_get_name(jdf, f, "task_t"), jdf_basename, jdf_basename); - - - // Generate the code to initialize the parametrized flow variables - // for(jdf_dataflow_t *fl=f->dataflow; NULL != fl; fl=fl->next) { - // if( NULL != fl->local_variables ) { // If is parametrized - // expr_info_t expr_info = EMPTY_EXPR_INFO; - // expr_info.sa = string_arena_new(32); - // expr_info.prefix = ""; - // expr_info.suffix = ""; - // expr_info.assignments = "max parametrized dataflow"; - - // jdf_expr_t *variable = jdf_expr_lv_first(fl->local_variables); - // assert(variable->op == JDF_RANGE); - // jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; - // } - // } for(vl = f->locals; vl != NULL; vl = vl->next) coutput(" int %s = this_task->locals.%s.value; /* retrieve value saved during the last iteration */\n", vl->name, vl->name); @@ -3562,6 +3546,25 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr for(idx = 0; NULL != dataflow; idx++, dataflow = dataflow->next ) { string_arena_t *osa = string_arena_new(16); + + if( FLOW_IS_PARAMETRIZED(dataflow) ) { + expr_info_t expr_info = EMPTY_EXPR_INFO;coutput("coucou\n"); + expr_info.sa = string_arena_new(32); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "max parametrized dataflow"; + + jdf_expr_t *variable = jdf_expr_lv_first(dataflow->local_variables); + assert(variable->op == JDF_PARAMETRIZED_FLOW_RANGE); + jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; + + coutput("\n%s this_task->data._f_%s = malloc(sizeof(parsec_data_pair_t)*((%s)+1));\n", + indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); + coutput("%s assert( NULL != this_task->data._f_%s );\n", indent(nesting), dataflow->varname); + coutput("%s memset(this_task->data._f_%s, 0, sizeof(parsec_data_pair_t)*((%s)+1));\n", + indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); + } + string_arena_t *sa = string_arena_new(256); dump_parametrized_flow_loop_if_parametrized(dataflow, indent(nesting), sa); coutput("%s", string_arena_get_string(sa)); @@ -4193,35 +4196,6 @@ static void jdf_generate_internal_init(const jdf_t *jdf, const jdf_function_entr coutput(" this_task->status = PARSEC_TASK_STATUS_COMPLETE;\n"); } - // If the flow is parametrized, the data is an "array" of data - jdf_dataflow_t *dataflow = f->dataflow; - if(dataflow && FLOW_IS_PARAMETRIZED(dataflow)) - { - string_arena_t *osa = string_arena_new(16); - string_arena_t *sa = string_arena_new(256); - - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(32); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "max parametrized dataflow"; - - jdf_expr_t *variable = jdf_expr_lv_first(dataflow->local_variables); - assert(variable->op == JDF_PARAMETRIZED_FLOW_RANGE); - jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; - - coutput("\n%s this_task->data._f_%s = malloc(sizeof(parsec_data_pair_t)*((%s)+1));\n", - indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); - coutput("%s assert( NULL != this_task->data._f_%s );\n", indent(nesting), dataflow->varname); - coutput("%s memset(this_task->data._f_%s, 0, sizeof(parsec_data_pair_t)*((%s)+1));\n", - indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); - - string_arena_free(sa); - string_arena_free(osa); - - nesting--; - } - string_arena_free(sa1); string_arena_free(sa2); coutput("\n PARSEC_AYU_REGISTER_TASK(&%s_%s);\n", jdf_basename, f->fname); @@ -5580,6 +5554,18 @@ static void jdf_generate_new_function( const jdf_t* jdf ) // " if(flow_in_out) {\n" // " spec_%s.out_offset_flow_of_%s_%s_for_%s = i;\n" // " }\n" + " // Update the goal of the task class\n" + " if(flow_in_out == 0)\n" + " {\n" + " // If is input, shift the proper values in the goal\n" + " // Idea: 00abcxyz -> abcccxyz (if shift=2 (i.e. nb_specializations=3) and pivot index = 3)\n" + " // (c=1 necessarily)\n" + " int shift = nb_specializations_flow_of_%s_%s_for_parametrized_%s-1;\n" + " parsec_dependency_t unshifted_values = tc->dependencies_goal & ((1<dependencies_goal >> (i + 1)) << (i + 1 + shift);\n" + " parsec_dependency_t in_between = ((1<<(shift+1))-1) << i;\n" + " tc->dependencies_goal = unshifted_values | shifted_values | in_between;\n" + " }\n" " assert(i+nb_specializations_flow_of_%s_%s_for_parametrized_%s < MAX_DATAFLOWS_PER_TASK);\n" " }\n" " if(pivot_reached)\n" @@ -5596,6 +5582,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_basename, f->fname, df->varname, //JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) diff --git a/parsec/task_class.c b/parsec/task_class.c index 368130ad6..837dd46b8 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -302,6 +302,8 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) parsec_debug_verbose(1, parsec_debug_output, "## Task Class %s (%p) has %d flows, %d parameters, %d locals", tc->name, (void *)tc, tc->nb_flows, tc->nb_parameters, tc->nb_locals); + parsec_debug_verbose(1, parsec_debug_output, "## dependencies_goal = %x\n", tc->dependencies_goal); + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) From 3a8ce275177d96b06331be68a05bc62614d51029 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 4 Nov 2022 13:45:07 -0400 Subject: [PATCH 074/157] add comment --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 1 + 1 file changed, 1 insertion(+) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index a692fca5a..a303ddc35 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -3558,6 +3558,7 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr assert(variable->op == JDF_PARAMETRIZED_FLOW_RANGE); jdf_expr_t *max_parametrized_flow = variable->jdf_ta2; + // TODO test coutput("\n%s this_task->data._f_%s = malloc(sizeof(parsec_data_pair_t)*((%s)+1));\n", indent(nesting), dataflow->varname, dump_expr((void**)max_parametrized_flow, &expr_info)); coutput("%s assert( NULL != this_task->data._f_%s );\n", indent(nesting), dataflow->varname); From bae83f7dbb08a4018b1adc26dc36a3fd9fa13235 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 4 Nov 2022 15:41:35 -0400 Subject: [PATCH 075/157] change predeclarations for parametrized tasks --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 27 +++++++++++++++++-- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 22 +++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index a303ddc35..8b3c29242 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1525,7 +1525,8 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) else { // Parametrized flow // Becomes an array of data pairs - string_arena_add_string(sa_data, " parsec_data_pair_t *_f_%s;\n", df->varname); + string_arena_add_string(sa_data, " //parsec_data_pair_t *_f_%s;\n", df->varname); + nb_flows--; // This flow will be stored in the unused space of the array } } } @@ -1559,6 +1560,19 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) string_arena_get_string(sa_data), nb_flows, parsec_get_name(NULL, f, "data_t")); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + string_arena_add_string(sa, "typedef struct %s {\n" + " %s super;\n", + parsec_get_name(NULL, f, "parametrized_data_s"), + parsec_get_name(NULL, f, "data_t")); + for(jdf_dataflow_t *df = f->dataflow; df != NULL; df = df->next) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " parsec_data_pair_t *_f_%s;\n", df->varname); + } + } + string_arena_add_string(sa, "} %s;\n\n", + parsec_get_name(NULL, f, "parametrized_data_t")); + } string_arena_add_string(sa, "typedef struct %s {\n" " PARSEC_MINIMAL_EXECUTION_CONTEXT\n" "#if defined(PARSEC_PROF_TRACE)\n" @@ -1574,7 +1588,16 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) jdf_basename, f->fname, jdf_basename, f->fname, parsec_get_name(NULL, f, "task_t")); - + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + string_arena_add_string(sa, "typedef struct %s {\n" + " %s super;\n" + " %s parametrized_data;\n" + "} %s;\n\n", + parsec_get_name(NULL, f, "parametrized_task_s"), + parsec_get_name(NULL, f, "task_t"), + parsec_get_name(NULL, f, "parametrized_data_t"), + parsec_get_name(NULL, f, "parametrized_task_t")); + } string_arena_free(sa_locals); string_arena_free(sa_data); diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 867f5606e..0d7f341df 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -177,6 +177,28 @@ static inline int task_class_any_flow_is_parametrized_or_referrer_util(const jdf return 0; } +/** + * TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED + * Tells whether any flow is parametrized + * + * @param [IN] tc: the task class to test. + * + * @return a boolean value. + */ +#define TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(tc) \ + task_class_any_flow_is_parametrized_util(tc) + +static inline int task_class_any_flow_is_parametrized_util(const jdf_function_entry_t *tc) +{ + for( jdf_dataflow_t* df = tc->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + return 1; + } + } + + return 0; +} + /** From 1e56652ed89a63cf306e56400a791f9b15ecca1a Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 4 Nov 2022 16:13:48 -0400 Subject: [PATCH 076/157] rename the generated names in spec_X --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 68 +++++++++++++++------- 1 file changed, 47 insertions(+), 21 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 8b3c29242..71a611273 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1525,8 +1525,10 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) else { // Parametrized flow // Becomes an array of data pairs - string_arena_add_string(sa_data, " //parsec_data_pair_t *_f_%s;\n", df->varname); - nb_flows--; // This flow will be stored in the unused space of the array + + string_arena_add_string(sa_data, " parsec_data_pair_t *_f_%s;\n", df->varname); + /*string_arena_add_string(sa_data, " //parsec_data_pair_t *_f_%s;\n", df->varname); + nb_flows--; // This flow will be stored in the unused space of the array*/ } } } @@ -1560,7 +1562,7 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) string_arena_get_string(sa_data), nb_flows, parsec_get_name(NULL, f, "data_t")); - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + /*if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { string_arena_add_string(sa, "typedef struct %s {\n" " %s super;\n", parsec_get_name(NULL, f, "parametrized_data_s"), @@ -1572,7 +1574,7 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) } string_arena_add_string(sa, "} %s;\n\n", parsec_get_name(NULL, f, "parametrized_data_t")); - } + }*/ string_arena_add_string(sa, "typedef struct %s {\n" " PARSEC_MINIMAL_EXECUTION_CONTEXT\n" "#if defined(PARSEC_PROF_TRACE)\n" @@ -1588,7 +1590,7 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) jdf_basename, f->fname, jdf_basename, f->fname, parsec_get_name(NULL, f, "task_t")); - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + /*if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { string_arena_add_string(sa, "typedef struct %s {\n" " %s super;\n" " %s parametrized_data;\n" @@ -1597,7 +1599,7 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) parsec_get_name(NULL, f, "task_t"), parsec_get_name(NULL, f, "parametrized_data_t"), parsec_get_name(NULL, f, "parametrized_task_t")); - } + }*/ string_arena_free(sa_locals); string_arena_free(sa_data); @@ -1720,7 +1722,8 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) coutput("#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - coutput(" int out_offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + coutput(" int out_dep_offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + coutput(" int out_offset_dep_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } } @@ -1742,14 +1745,14 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) { // Then the dep refers to a parametrized flow - coutput(" int out_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + coutput(" int out_dep_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); // We also keep track of the flow that id that contains the referrer - coutput(" int out_flow_id_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + coutput(" int out_flow_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse @@ -4813,7 +4816,9 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " , .out_offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " , .out_dep_offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + // store the offset for every output dep of this parametrized flow + string_arena_add_string(sa, " , .out_offset_dep_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); } } @@ -4834,12 +4839,12 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f if( NULL != call->parametrized_offset ) { - string_arena_add_string(sa, " , .out_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", + string_arena_add_string(sa, " , .out_dep_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - string_arena_add_string(sa, " , .out_flow_id_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", + string_arena_add_string(sa, " , .out_flow_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse @@ -5749,7 +5754,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) // JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname,); // For the moment, do not set this, I think it is not needed - coutput(" spec_%s.out_offset_flow_of_%s_%s_for_%s = -1;\n", + coutput(" spec_%s.out_dep_offset_flow_of_%s_%s_for_%s = -1;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" }\n"); } @@ -5785,12 +5790,12 @@ static void jdf_generate_new_function( const jdf_t* jdf ) assert(!FLOW_IS_PARAMETRIZED(df)); // If the flow is parametrized, - coutput(" spec_%s.out_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, dep, 1);\n", + coutput(" spec_%s.out_dep_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, dep, 1);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - coutput(" spec_%s.out_flow_id_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_flow_index_that_contains_dep(tc, dep, 1);\n", + coutput(" spec_%s.out_flow_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_flow_index_that_contains_dep(tc, dep, 1);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse @@ -9107,10 +9112,31 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, if(NULL != dl->guard->calltrue->parametrized_offset) { jdf_call_t *call = dl->guard->calltrue; + // if call is parametrized + string_arena_add_string(sa_ontask, + "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s]" + "->dep_out[spec_%s_%s.out_dep_offset_%s+%s]" + ", &data, rank_src, rank_dst, vpid_dst," + " successor_repo, successor_repo_key, ontask_arg) )\n" + " return;\n", + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + // if flow is parametrized + string_arena_add_string(sa_ontask, + "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s]" + "->dep_out[spec_%s_%s.out_dep_offset_%s+%s]" + ", &data, rank_src, rank_dst, vpid_dst," + " successor_repo, successor_repo_key, ontask_arg) )\n" + " return;\n", + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + // if both flow and call are parametrized string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_id_of_%s]" - "->dep_out[spec_%s_%s.out_offset_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s]" + "->dep_out[spec_%s_%s.out_dep_offset_%s+%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", @@ -9235,8 +9261,8 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, jdf_call_t *call = dl->guard->callfalse; string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_id_of_%s]" - "->dep_out[spec_%s_%s.out_offset_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s]" + "->dep_out[spec_%s_%s.out_dep_offset_%s+%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", @@ -9272,8 +9298,8 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, jdf_call_t *call = dl->guard->callfalse; string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_id_of_%s]" - "->dep_out[spec_%s_%s.out_offset_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s]" + "->dep_out[spec_%s_%s.out_dep_offset_%s+%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", From b2b1b4c0abee7c8fb4ad719bfa3fb8b31f13f06d Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 4 Nov 2022 16:52:18 -0400 Subject: [PATCH 077/157] use dump_flow_offset_for_iterate_successors and dump_dep_offset_for_iterate_successors --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 69 +++++++++++++++------- 1 file changed, 48 insertions(+), 21 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 71a611273..fd97f78e3 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -8859,6 +8859,28 @@ static void jdf_check_relatives( jdf_function_entry_t *f, jdf_dep_flags_t flow_t string_arena_init((SA_DATATYPE)); \ } +char *dump_flow_offset_for_iterate_successors(string_arena_t *sa, jdf_function_entry_t *f, jdf_call_t *call) +{ + string_arena_init(sa); + + //spec_%s_%s.out_flow_offset_of_%s] + string_arena_add_string(sa, "spec_%s_%s.out_flow_offset_of_%s", + jdf_basename, f->fname, JDF_OBJECT_ONAME(call)); + + return string_arena_get_string(sa); +} + +char *dump_dep_offset_for_iterate_successors(string_arena_t *sa, jdf_function_entry_t *f, jdf_call_t *call) +{ + string_arena_init(sa); + + //spec_%s_%s.out_dep_offset_%s+%s + string_arena_add_string(sa, "spec_%s_%s.out_dep_offset_%s+%s", + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + + return string_arena_get_string(sa); +} + static void jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, const jdf_function_entry_t *f, @@ -8896,6 +8918,9 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_t *sa_tmp_type_r = string_arena_new(256); string_arena_t *sa_temp_r = string_arena_new(1024); + string_arena_t *sa_flow_offset = string_arena_new(64); + string_arena_t *sa_dep_offset = string_arena_new(64); + int depnb, last_datatype_idx; assignment_info_t ai; expr_info_t info = EMPTY_EXPR_INFO; @@ -9115,33 +9140,33 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, // if call is parametrized string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s]" - "->dep_out[spec_%s_%s.out_dep_offset_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[%s]" + "->dep_out[%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); - // if flow is parametrized + dump_flow_offset_for_iterate_successors(sa_flow_offset, f, call), + dump_dep_offset_for_iterate_successors(sa_dep_offset, f, call)); + /*// if flow is parametrized string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s]" - "->dep_out[spec_%s_%s.out_dep_offset_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s + %s]" + "->dep_out[spec_%s_%s.out_dep_offset_%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), smt, + jdf_basename, f->fname, JDF_OBJECT_ONAME(call)); // if both flow and call are parametrized string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s]" - "->dep_out[spec_%s_%s.out_dep_offset_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s + %s]" + "->dep_out[spec_%s_%s.out_dep_offset_%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), smt, + jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias);*/ } else { @@ -9261,13 +9286,13 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, jdf_call_t *call = dl->guard->callfalse; string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s]" - "->dep_out[spec_%s_%s.out_dep_offset_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[%s]" + "->dep_out[%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + dump_flow_offset_for_iterate_successors(sa_flow_offset, f, call), + dump_dep_offset_for_iterate_successors(sa_dep_offset, f, call)); } else { @@ -9298,13 +9323,13 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, jdf_call_t *call = dl->guard->callfalse; string_arena_add_string(sa_ontask, "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s]" - "->dep_out[spec_%s_%s.out_dep_offset_%s+%s]" + "(const parsec_task_t *)this_task, this_task->task_class->out[%s]" + "->dep_out[%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" " return;\n", - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + dump_flow_offset_for_iterate_successors(sa_flow_offset, f, call), + dump_dep_offset_for_iterate_successors(sa_dep_offset, f, call)); } else { @@ -9390,6 +9415,8 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_free(sa_tmp_type_r); string_arena_free(sa_temp_r); + string_arena_free(sa_flow_offset); + string_arena_free(sa_dep_offset); } /** From 643b409f7a32f37f0d3bcb7ee5601fd4861fb251 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 4 Nov 2022 16:55:59 -0400 Subject: [PATCH 078/157] remove annoying printfs and comments --- parsec/interfaces/ptg/ptg-compiler/parsec.y | 49 --------------------- 1 file changed, 49 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/parsec.y b/parsec/interfaces/ptg/ptg-compiler/parsec.y index 5d78d14bc..aa22a6e06 100644 --- a/parsec/interfaces/ptg/ptg-compiler/parsec.y +++ b/parsec/interfaces/ptg/ptg-compiler/parsec.y @@ -578,11 +578,6 @@ function: VAR OPEN_PAR param_list CLOSE_PAR properties local_variables sim e->priority = $10; e->bodies = $11; -/* - for(jdf_expr_t *el = e->locals; NULL != el; el = el->next) { - printf("%s has a local named %s\n", e->fname, el->jdf_var); - }*/ - jdf_link_params_and_locals(e); /* link params and locals */ jdf_assign_ldef_index(e); /* find the datatype indexes */ @@ -675,14 +670,6 @@ partitioning: COLON VAR { named_expr_push_scope(); } named_array_offset_or_not JDF_OBJECT_LINENO($$) = JDF_OBJECT_LINENO($6); named_expr_pop_scope(); } - /* - | COLON VAR PROPERTIES_ON expr_simple PROPERTIES_OFF OPEN_PAR expr_list_range CLOSE_PAR - { - printf("coucou ! %s, %s\n", $2, $4); - } - - | PROPERTIES_ON expr_list PROPERTIES_OFF - { printf("coucou\n"); }*/ ; dataflow_list: dataflow dataflow_list @@ -1023,42 +1010,6 @@ call: named_expr VAR named_array_offset_or_nothing VAR OPEN_PAR expr_lis c->parametrized_offset = $3; c->local_defs = $3?$3:$1; // If we want local_defs to contain the parametrized_offset, we need to indicate $3 and not $1 - /*if($1 != NULL && $3 != NULL) - { // create a new separated parametrized_offset - jdf_expr_t *new_expr = malloc(sizeof(jdf_expr_t)); - memcpy(new_expr, c->parametrized_offset, sizeof(jdf_expr_t)); - new_expr->next = NULL; - c->parametrized_offset = new_expr; - }*/ - - // print infos - printf("call: %s\n", $2); - printf(" parametrized_offset: %s\n", (c->parametrized_offset)?(c->parametrized_offset->alias):""); - printf(" local_defs: "); - for(jdf_expr_t *e = c->local_defs; e != NULL; e = e->next) - { - printf("%s, ", e->alias); - } - printf("\n"); - /*if(c->local_defs) // Normally, $3 should already contain the local_defs of $1 because we pushed them in the same scope - { - assert(c->local_defs->next == NULL); // Only one variable is allowed in the referrer's offset - c->local_defs->next = $1; - } - else - { - c->local_defs = $1; - }*/ - /*if(c->local_defs) { - // concatenate c->array_offset and ->local_defs - jdf_expr_t *e; - for(e = c->local_defs; e->next; e = e->next); - e->next = c->parametrized_offset; - } - else - { - c->local_defs = c->parametrized_offset; - }*/ c->func_or_mem = $4; c->parameters = $6; $$ = c; From 3f6ec3d0823c4196f4f8e6a0127cb2ad953007d8 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 4 Nov 2022 18:24:27 -0400 Subject: [PATCH 079/157] add class declaration --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 24 +++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index fd97f78e3..82d5fa2f6 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1526,9 +1526,9 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) { // Parametrized flow // Becomes an array of data pairs - string_arena_add_string(sa_data, " parsec_data_pair_t *_f_%s;\n", df->varname); - /*string_arena_add_string(sa_data, " //parsec_data_pair_t *_f_%s;\n", df->varname); - nb_flows--; // This flow will be stored in the unused space of the array*/ + //string_arena_add_string(sa_data, " parsec_data_pair_t *_f_%s;\n", df->varname); + string_arena_add_string(sa_data, " //parsec_data_pair_t *_f_%s;\n", df->varname); + nb_flows--; // This flow will be stored in the unused space of the array } } } @@ -1562,7 +1562,7 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) string_arena_get_string(sa_data), nb_flows, parsec_get_name(NULL, f, "data_t")); - /*if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { string_arena_add_string(sa, "typedef struct %s {\n" " %s super;\n", parsec_get_name(NULL, f, "parametrized_data_s"), @@ -1574,7 +1574,7 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) } string_arena_add_string(sa, "} %s;\n\n", parsec_get_name(NULL, f, "parametrized_data_t")); - }*/ + } string_arena_add_string(sa, "typedef struct %s {\n" " PARSEC_MINIMAL_EXECUTION_CONTEXT\n" "#if defined(PARSEC_PROF_TRACE)\n" @@ -1590,7 +1590,7 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) jdf_basename, f->fname, jdf_basename, f->fname, parsec_get_name(NULL, f, "task_t")); - /*if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { string_arena_add_string(sa, "typedef struct %s {\n" " %s super;\n" " %s parametrized_data;\n" @@ -1599,7 +1599,17 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) parsec_get_name(NULL, f, "task_t"), parsec_get_name(NULL, f, "parametrized_data_t"), parsec_get_name(NULL, f, "parametrized_task_t")); - }*/ + + string_arena_add_string(sa, + "PARSEC_OBJ_CLASS_DECLARATION(%s);\n" + "PARSEC_OBJ_CLASS_INSTANCE(%s, %s,\n" + " __parsec_LBM_LBM_STEP_constructor, NULL);\n\n", + parsec_get_name(NULL, f, "parametrized_data_t"), + parsec_get_name(NULL, f, "parametrized_task_t"), + parsec_get_name(NULL, f, "data_t"), + parsec_get_name(NULL, f, "constructor") + ); + } string_arena_free(sa_locals); string_arena_free(sa_data); From 389a019394750037454a7715aa3c5e0b5f66fa93 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 7 Nov 2022 11:13:05 -0500 Subject: [PATCH 080/157] used generic name for task classes --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 56 ++++++++++++---------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 82d5fa2f6..f08bbfb8f 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -233,6 +233,11 @@ parsec_get_name(const jdf_t *jdf, const jdf_function_entry_t *f, char* fmt, ...) return tmp; } +static char *parsec_get_task_type_name(const jdf_t *jdf, const jdf_function_entry_t *f) +{ + return parsec_get_name(jdf, f, TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)?"parametrized_task_t":"task_t"); +} + /** * Returns true if the function has any valid data output (not control). * Otherwise, returns false. @@ -1590,10 +1595,10 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) jdf_basename, f->fname, jdf_basename, f->fname, parsec_get_name(NULL, f, "task_t")); - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + /*if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { string_arena_add_string(sa, "typedef struct %s {\n" " %s super;\n" - " %s parametrized_data;\n" + " %s data;\n" "} %s;\n\n", parsec_get_name(NULL, f, "parametrized_task_s"), parsec_get_name(NULL, f, "task_t"), @@ -1603,13 +1608,14 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) string_arena_add_string(sa, "PARSEC_OBJ_CLASS_DECLARATION(%s);\n" "PARSEC_OBJ_CLASS_INSTANCE(%s, %s,\n" - " __parsec_LBM_LBM_STEP_constructor, NULL);\n\n", - parsec_get_name(NULL, f, "parametrized_data_t"), - parsec_get_name(NULL, f, "parametrized_task_t"), - parsec_get_name(NULL, f, "data_t"), - parsec_get_name(NULL, f, "constructor") + " %s, NULL);\n\n", + parsec_get_name(NULL, f, "task_t"), + parsec_get_name(NULL, f, "task_t"), + "parsec_list_item_t", + //parsec_get_name(NULL, f, "constructor") + "NULL" ); - } + }*/ string_arena_free(sa_locals); string_arena_free(sa_data); @@ -2410,7 +2416,7 @@ static void jdf_generate_affinity( const jdf_t *jdf, const jdf_function_entry_t " parsec_data_ref_t *ref)\n" "{\n" " const __parsec_%s_internal_taskpool_t *__parsec_tp = (const __parsec_%s_internal_taskpool_t*)this_task->taskpool;\n", - name, parsec_get_name(jdf, f, "task_t"), + name, parsec_get_task_type_name(jdf, f), jdf_basename, jdf_basename); info.sa = sa5; @@ -3443,8 +3449,8 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr " size_t total_nb_tasks = 0;\n" " parsec_list_item_t* pready_ring[context->nb_vp];\n" " int restore_context = 0;\n", - fname, parsec_get_name(jdf, f, "task_t"), - parsec_get_name(jdf, f, "task_t"), + fname, parsec_get_task_type_name(jdf, f), + parsec_get_task_type_name(jdf, f), jdf_basename, jdf_basename); for(vl = f->locals; vl != NULL; vl = vl->next) @@ -3551,7 +3557,7 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr indent(nesting), indent(nesting), indent(nesting), - indent(nesting), parsec_get_name(jdf, f, "task_t"), + indent(nesting), parsec_get_task_type_name(jdf, f), indent(nesting)); JDF_COUNT_LIST_ENTRIES(f->locals, jdf_variable_list_t, next, nb_locals); @@ -3912,7 +3918,7 @@ static void jdf_generate_internal_init(const jdf_t *jdf, const jdf_function_entr need_min_max ? "min-max" : "-", need_to_count_tasks ? "count-tasks" : "-", need_to_iterate ? "iterate" : "-", - fname, parsec_get_name(jdf, f, "task_t"), + fname, parsec_get_task_type_name(jdf, f), jdf_basename, jdf_basename); if(need_to_count_tasks) { @@ -4345,7 +4351,7 @@ static void jdf_generate_simulation_cost_fct(const jdf_t *jdf, const jdf_functio " const parsec_taskpool_t *__parsec_tp = (const parsec_taskpool_t*)this_task->taskpool;\n" "%s" " (void)__parsec_tp;\n", - prefix, parsec_get_name(jdf, f, "task_t"), + prefix, parsec_get_task_type_name(jdf, f), UTIL_DUMP_LIST(sa1, f->locals, next, dump_local_assignments, &ai, "", " ", "\n", "\n")); @@ -7435,7 +7441,7 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, " const __parsec_%s_internal_taskpool_t *__parsec_tp = (__parsec_%s_internal_taskpool_t *)this_task->taskpool;\n" " (void)__parsec_tp; (void)es; (void)this_task; (void)data;\n" "%s", - name, parsec_get_name(jdf, f, "task_t"), + name, parsec_get_task_type_name(jdf, f), jdf_basename, jdf_basename, UTIL_DUMP_LIST(sa, f->locals, next, dump_local_assignments, &ai, "", " ", "\n", "\n")); @@ -7632,7 +7638,7 @@ jdf_generate_code_data_lookup(const jdf_t *jdf, " (void)consumed_flow_index;\n" " (void)chunk; (void)data; (void)ret;\n" "%s", - name, parsec_get_name(jdf, f, "task_t"), + name, parsec_get_task_type_name(jdf, f), jdf_basename, jdf_basename, UTIL_DUMP_LIST(sa, f->locals, next, dump_local_assignments, &ai, "", " ", "\n", "\n")); @@ -7796,7 +7802,7 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, jdf_basename, f->fname, dyldtype, jdf_basename, f->fname, - parsec_get_name(jdf, f, "task_t"), parsec_get_name(jdf, f, "task_t"), + parsec_get_task_type_name(jdf, f), parsec_get_task_type_name(jdf, f), jdf_basename, jdf_basename, jdf_basename, f->fname, string_arena_get_string( sa3 )); @@ -7901,7 +7907,7 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, " %s\n" " (void)es; (void)__parsec_tp;\n" "\n", - name, type_property->expr->jdf_var, parsec_get_name(jdf, f, "task_t"), + name, type_property->expr->jdf_var, parsec_get_task_type_name(jdf, f), jdf_basename, jdf_basename, string_arena_get_string( sa3 )); @@ -8126,10 +8132,10 @@ static void jdf_generate_code_hook(const jdf_t *jdf, if(NULL == type_property) coutput("static int %s(parsec_execution_stream_t *es, %s *this_task)\n", - name, parsec_get_name(jdf, f, "task_t")); + name, parsec_get_task_type_name(jdf, f)); else coutput("static int %s_%s(parsec_execution_stream_t *es, %s *this_task)\n", - name, type_property->expr->jdf_var, parsec_get_name(jdf, f, "task_t")); + name, type_property->expr->jdf_var, parsec_get_task_type_name(jdf, f)); coutput("{\n" " __parsec_%s_internal_taskpool_t *__parsec_tp = (__parsec_%s_internal_taskpool_t *)this_task->taskpool;\n" @@ -8271,7 +8277,7 @@ jdf_generate_code_complete_hook(const jdf_t *jdf, " %s" "#endif /* defined(DISTRIBUTED) */\n" " (void)es; (void)__parsec_tp;\n", - name, parsec_get_name(jdf, f, "task_t"), + name, parsec_get_task_type_name(jdf, f), jdf_basename, jdf_basename, UTIL_DUMP_LIST(sa, f->locals, next, dump_local_assignments, &ai, "", " ", "\n", "\n")); @@ -8430,7 +8436,7 @@ static void jdf_generate_code_release_deps(const jdf_t *jdf, const jdf_function_ " arg.ready_lists = alloca(sizeof(parsec_task_t *) * es->virtual_process->parsec_context->nb_vp);\n" " for( __vp_id = 0; __vp_id < es->virtual_process->parsec_context->nb_vp; arg.ready_lists[__vp_id++] = NULL );\n" " (void)__parsec_tp; (void)deps;\n", - name, parsec_get_name(jdf, f, "task_t"), + name, parsec_get_task_type_name(jdf, f), jdf_basename, jdf_basename); jdf_generate_code_free_hash_table_entry(jdf, f, 1/*consume_repo*/, 0/*release_inputs*/); @@ -8561,7 +8567,9 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, nbopen = 0; string_arena_add_string(sa_open, "%s%s%s* ncc = (%s*)&%s;\n", - prefix, indent(nbopen), parsec_get_name(jdf, targetf, "task_t"), parsec_get_name(jdf, targetf, "task_t"), var); + prefix, indent(nbopen), + parsec_get_task_type_name(jdf, targetf), + parsec_get_task_type_name(jdf, targetf), var); string_arena_add_string(sa_open, "%s%s%s.task_class = __parsec_tp->super.super.task_classes_array[%s_%s.task_class_id];\n", prefix, indent(nbopen), var, jdf_basename, targetf->fname); @@ -8955,7 +8963,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, " int vpid_dst = -1, rank_src = 0, rank_dst = 0;\n" "%s" " (void)rank_src; (void)rank_dst; (void)__parsec_tp; (void)vpid_dst;\n", - name, parsec_get_name(jdf, f, "task_t"), + name, parsec_get_task_type_name(jdf, f), jdf_basename, jdf_basename, parsec_get_name(jdf, f, "parsec_assignment_t"), parsec_get_name(jdf, f, "parsec_assignment_t"), UTIL_DUMP_LIST(sa1, f->locals, next, From eac2ee4dd6ef0b5a1a131fd8c4218a3faa3051c0 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 7 Nov 2022 11:18:43 -0500 Subject: [PATCH 081/157] rename unused to dynamic if parametrized --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index f08bbfb8f..f049557b5 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1561,13 +1561,14 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) nb_flows, f->fname, nb_flows, f->fname); string_arena_add_string(sa, "typedef struct %s {\n" "%s" - " parsec_data_pair_t unused[MAX_LOCAL_COUNT-%d];\n" + " parsec_data_pair_t %s[MAX_LOCAL_COUNT-%d];\n" "} %s;\n\n", parsec_get_name(NULL, f, "data_s"), string_arena_get_string(sa_data), + TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f) ? "dynamic" : "unused", nb_flows, parsec_get_name(NULL, f, "data_t")); - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + /*if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { string_arena_add_string(sa, "typedef struct %s {\n" " %s super;\n", parsec_get_name(NULL, f, "parametrized_data_s"), @@ -1579,7 +1580,7 @@ static inline char* jdf_generate_task_typedef(void **elt, void* arg) } string_arena_add_string(sa, "} %s;\n\n", parsec_get_name(NULL, f, "parametrized_data_t")); - } + }*/ string_arena_add_string(sa, "typedef struct %s {\n" " PARSEC_MINIMAL_EXECUTION_CONTEXT\n" "#if defined(PARSEC_PROF_TRACE)\n" From 51e611d7769c3e9e26a334d5e57265920e96255f Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 7 Nov 2022 11:41:53 -0500 Subject: [PATCH 082/157] macro to access parametrized offset --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index f049557b5..fd1dfcfe1 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -235,7 +235,8 @@ parsec_get_name(const jdf_t *jdf, const jdf_function_entry_t *f, char* fmt, ...) static char *parsec_get_task_type_name(const jdf_t *jdf, const jdf_function_entry_t *f) { - return parsec_get_name(jdf, f, TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)?"parametrized_task_t":"task_t"); + //return parsec_get_name(jdf, f, TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)?"parametrized_task_t":"task_t"); + return parsec_get_name(jdf, f, "task_t"); } /** @@ -1921,6 +1922,16 @@ static void jdf_generate_structure(jdf_t *jdf) coutput("/* Globals */\n%s\n", string_arena_get_string(sa1)); } + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput("#define parametrized__f_%s(it) (dynamic[(spec_%s.out_dep_offset_flow_of_%s_%s_for_%s)+(it)])\n", + f->fname, + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + } + } + } + coutput("static inline int parsec_imin(int a, int b) { return (a <= b) ? a : b; };\n\n" "static inline int parsec_imax(int a, int b) { return (a >= b) ? a : b; };\n\n"); @@ -9015,7 +9026,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, nb_open_ldef = 0; - dump_parametrized_flow_loop_if_parametrized(fl, " ", sa_coutput); + dump_parametrized_flow_loop_if_parametrized(fl, " ", sa_coutput); // TODO: this is completely wrong, this should be inside the whole loop string_arena_add_string(sa_coutput, "%s data.data = this_task->data._f_%s%s.data_out;\n", From f5bc7d08de9802dd0ab9186f61626441e11cebed Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 7 Nov 2022 13:11:08 -0500 Subject: [PATCH 083/157] change the data access if the flow is parametrized --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 180 +++++++++--------- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 20 ++ 2 files changed, 111 insertions(+), 89 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index fd1dfcfe1..d70369db5 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -926,11 +926,12 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) dump_parametrized_flow_loop_if_parametrized(f, " ", sa); string_arena_t *osa = string_arena_new(32); + string_arena_t *osa2 = string_arena_new(32); string_arena_add_string(sa, - "%s _f_%s%s = this_task->data._f_%s%s.data_%s;\n", + "%s _f_%s%s = this_task->data.%s.data_%s;\n", INDENTATION_IF_PARAMETRIZED(f), varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), - varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), where); + DUMP_DATA_FIELD_NAME_IN_TASK(osa2, f, f->varname), where); string_arena_add_string(sa, "%s %s%s = PARSEC_DATA_COPY_GET_PTR(_f_%s%s);\n", @@ -938,6 +939,7 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f)); string_arena_free(osa); + string_arena_free(osa2); dump_parametrized_flow_loop_end_if_parametrized(f, " ", sa); @@ -963,9 +965,9 @@ static char *dump_data_copy_init_for_inline_function(void **elem, void *arg) dump_parametrized_flow_loop_if_parametrized(f, " ", sa); string_arena_add_string(sa, - "%s parsec_data_copy_t *_f_%s = this_task->data._f_%s%s.data_%s;\n" + "%s parsec_data_copy_t *_f_%s = this_task->data.%s.data_%s;\n" "%s (void)_f_%s;", - INDENTATION_IF_PARAMETRIZED(f), varname, f->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), where, + INDENTATION_IF_PARAMETRIZED(f), DUMP_DATA_FIELD_NAME_IN_TASK(osa, f, f->varname), where, INDENTATION_IF_PARAMETRIZED(f), varname ); @@ -1925,8 +1927,8 @@ static void jdf_generate_structure(jdf_t *jdf) for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - coutput("#define parametrized__f_%s(it) (dynamic[(spec_%s.out_dep_offset_flow_of_%s_%s_for_%s)+(it)])\n", - f->fname, + coutput("#define parametrized__f_%s(it) dynamic[(spec_%s.out_dep_offset_flow_of_%s_%s_for_%s)+(it)]\n", + df->varname, JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); } } @@ -3629,16 +3631,16 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr nesting++; } - coutput("%s new_task->data._f_%s%s.source_repo_entry = NULL;\n" - "%s new_task->data._f_%s%s.source_repo = NULL;\n" - "%s new_task->data._f_%s%s.data_in = NULL;\n" - "%s new_task->data._f_%s%s.data_out = NULL;\n" - "%s new_task->data._f_%s%s.fulfill = 0;\n", - indent(nesting), dataflow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, dataflow), - indent(nesting), dataflow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, dataflow), - indent(nesting), dataflow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, dataflow), - indent(nesting), dataflow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, dataflow), - indent(nesting), dataflow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, dataflow)); + coutput("%s new_task->data.%s.source_repo_entry = NULL;\n" + "%s new_task->data.%s.source_repo = NULL;\n" + "%s new_task->data.%s.data_in = NULL;\n" + "%s new_task->data.%s.data_out = NULL;\n" + "%s new_task->data.%s.fulfill = 0;\n", + indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow, dataflow->varname), + indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow, dataflow->varname), + indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow, dataflow->varname), + indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow, dataflow->varname), + indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow, dataflow->varname)); string_arena_init(sa); dump_parametrized_flow_loop_end_if_parametrized(dataflow, indent(nesting), sa); @@ -6504,12 +6506,12 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * if( final_check ){ - coutput("%s consumed_repo = this_task->data._f_%s%s.source_repo;\n" - "%s consumed_entry = this_task->data._f_%s%s.source_repo_entry;\n" - "%s consumed_entry_key = this_task->data._f_%s%s.source_repo_entry->ht_item.key;\n", - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); + coutput("%s consumed_repo = this_task->data.%s.source_repo;\n" + "%s consumed_entry = this_task->data.%s.source_repo_entry;\n" + "%s consumed_entry_key = this_task->data.%s.source_repo_entry->ht_item.key;\n", + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); /* Is this current task repo or predecessor repo? Different flow index */ coutput("%s if( (reshape_entry != NULL) && (reshape_entry->data[%d] != NULL) ){\n" @@ -6518,10 +6520,10 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * spaces, flow->flow_index, spaces, spaces, flow->flow_index); - coutput("%s assert( (this_task->data._f_%s%s.source_repo == reshape_repo)\n" - "%s && (this_task->data._f_%s%s.source_repo_entry == reshape_entry));\n", - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); + coutput("%s assert( (this_task->data.%s.source_repo == reshape_repo)\n" + "%s && (this_task->data.%s.source_repo_entry == reshape_entry));\n", + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); coutput("%s }else{\n" "%s /* Reshape promise set up on input by predecessor is the predecesssor task repo */\n" "%s consumed_flow_index = %d;\n" @@ -6625,9 +6627,9 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, spaces, flow->varname, flow->flow_index, dl->dep_index, string_arena_get_string(sa) ); string_arena_init(sa); - coutput("%s if( NULL == (chunk = this_task->data._f_%s%s.data_in) ) {\n" + coutput("%s if( NULL == (chunk = this_task->data.%s.data_in) ) {\n" "%s /* No data set up by predecessor on this task input flow */\n", - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), spaces); /* Function calls */ @@ -6647,9 +6649,9 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, jdf_generate_code_reshape_input_from_dep(jdf, f, flow, dl, spaces); coutput("%s ACQUIRE_FLOW(this_task, \"%s\", &%s_%s, \"%s\", target_locals, chunk);\n" - "%s this_task->data._f_%s%s.data_out = chunk;\n", + "%s this_task->data.%s.data_out = chunk;\n", spaces, flow->varname, jdf_basename, call->func_or_mem, call->var, - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); } else { @@ -6670,9 +6672,9 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, jdf_generate_code_reshape_input_from_desc(jdf, f, flow, dl, spaces); - coutput("%s this_task->data._f_%s%s.data_out = chunk;\n" + coutput("%s this_task->data.%s.data_out = chunk;\n" "%s PARSEC_OBJ_RETAIN(chunk);\n", - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), spaces); } @@ -6699,10 +6701,10 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, coutput("%s chunk = parsec_arena_get_copy(%s->arena, %s, target_device, %s->opaque_dtt);\n" "%s chunk->original->owner_device = target_device;\n" - "%s this_task->data._f_%s%s.data_out = chunk;\n", + "%s this_task->data.%s.data_out = chunk;\n", spaces, string_arena_get_string(sa), string_arena_get_string(sa2), string_arena_get_string(sa), spaces, - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); string_arena_free(info.sa); } @@ -6728,12 +6730,12 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, /* Code to create & fulfill a reshape promise locally in case this input dependency is typed */ jdf_generate_code_reshape_input_from_dep(jdf, f, flow, dl, spaces); - coutput("%s this_task->data._f_%s%s.data_out = parsec_data_get_copy(chunk->original, target_device);\n" + coutput("%s this_task->data.%s.data_out = parsec_data_get_copy(chunk->original, target_device);\n" "#if defined(PARSEC_PROF_GRAPHER) && defined(PARSEC_PROF_TRACE)\n" "%s parsec_prof_grapher_data_input(chunk->original, (parsec_task_t*)this_task, &%s, 0);\n" "#endif\n" "%s }\n", - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), spaces, JDF_OBJECT_ONAME( flow ), spaces); } @@ -6811,9 +6813,9 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ // dump_parametrized_flow_loop_if_parametrized(flow, " ", sa_loop); // coutput("%s", string_arena_get_string(sa_loop)); - coutput("%s if( NULL == (chunk = this_task->data._f_%s%s.data_in) ) {\n" + coutput("%s if( NULL == (chunk = this_task->data.%s.data_in) ) {\n" "%s /* No data set up by predecessor */\n", - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), spaces); // string_arena_init(sa_loop); @@ -6824,9 +6826,9 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ "%s chunk->original->owner_device = target_device;\n", spaces, string_arena_get_string(sa_arena), string_arena_get_string(sa_count), string_arena_get_string(sa_datatype), spaces); - coutput("%s this_task->data._f_%s%s.data_out = chunk;\n" + coutput("%s this_task->data.%s.data_out = chunk;\n" "%s }\n", - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), spaces); #if defined(PARSEC_DEBUG_NOISIER) || defined(PARSEC_DEBUG_PARANOID) @@ -6866,15 +6868,15 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, coutput(" /* %s is a control flow */\n" - "%s this_task->data._f_%s%s.data_in = NULL;\n" - "%s this_task->data._f_%s%s.data_out = NULL;\n" - "%s this_task->data._f_%s%s.source_repo = NULL;\n" - "%s this_task->data._f_%s%s.source_repo_entry = NULL;\n", + "%s this_task->data.%s.data_in = NULL;\n" + "%s this_task->data.%s.data_out = NULL;\n" + "%s this_task->data.%s.source_repo = NULL;\n" + "%s this_task->data.%s.source_repo_entry = NULL;\n", flow->varname, - INDENTATION_IF_PARAMETRIZED(flow), flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(sa, flow), - INDENTATION_IF_PARAMETRIZED(flow), flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(sa, flow), - INDENTATION_IF_PARAMETRIZED(flow), flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(sa, flow), - INDENTATION_IF_PARAMETRIZED(flow), flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(sa, flow)); + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow, flow->varname), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow, flow->varname), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow, flow->varname), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow, flow->varname)); string_arena_init(sa); dump_parametrized_flow_loop_end_if_parametrized(flow, " ", sa); @@ -6890,7 +6892,7 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, coutput("%s", string_arena_get_string(osa)); coutput("\n" - "if(! this_task->data._f_%s%s.fulfill ){ /* Flow %s */\n", flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), flow->varname); + "if(! this_task->data.%s.fulfill ){ /* Flow %s */\n", DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), flow->varname); coutput(" consumed_repo = NULL;\n" " consumed_entry_key = 0;\n" @@ -6904,9 +6906,9 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, } } if( !has_output_deps ) { - coutput("\n this_task->data._f_%s%s.data_out = NULL; /* input only */\n", flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); + coutput("\n this_task->data.%s.data_out = NULL; /* input only */\n", DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); } else { - coutput("\n this_task->data._f_%s%s.data_out = NULL; /* By default, if nothing matches */\n", flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); + coutput("\n this_task->data.%s.data_out = NULL; /* By default, if nothing matches */\n", DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); } sa = string_arena_new(64); @@ -6993,29 +6995,29 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, } } done_with_input: - coutput(" this_task->data._f_%s%s.data_in = chunk;\n" - " this_task->data._f_%s%s.source_repo = consumed_repo;\n" - " this_task->data._f_%s%s.source_repo_entry = consumed_entry;\n", - flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), - flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), - flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow)); + coutput(" this_task->data.%s.data_in = chunk;\n" + " this_task->data.%s.source_repo = consumed_repo;\n" + " this_task->data.%s.source_repo_entry = consumed_entry;\n", + DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); if( !(f->flags & JDF_FUNCTION_FLAG_NO_SUCCESSORS) ) { /* If we have consume from our repo, we clean up the repo entry for that flow, * so we don't have old stuff during release_deps_of when we will set up outputs * on our repo as a predecessor. */ - coutput(" if( this_task->data._f_%s%s.source_repo_entry == this_task->repo_entry ){\n" + coutput(" if( this_task->data.%s.source_repo_entry == this_task->repo_entry ){\n" " /* in case we have consume from this task repo entry for the flow,\n" " * it is cleaned up, avoiding having old stuff during release_deps_of\n" " */\n" " this_task->repo_entry->data[%d] = NULL;\n" " }\n", - flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), flow->flow_index); } - coutput(" this_task->data._f_%s%s.fulfill = 1;\n" + coutput(" this_task->data.%s.fulfill = 1;\n" "}\n\n", - flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow));/* coutput("if(! this_task->data._f_%s.fulfill ){\n", flow->varname);*/ + DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname));/* coutput("if(! this_task->data._f_%s.fulfill ){\n", flow->varname);*/ string_arena_init(osa); @@ -7142,10 +7144,10 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, } coutput("%s data_t_desc = data_of_%s(%s);\n" - "%s if( (NULL != this_task->data._f_%s%s.data_out) && (this_task->data._f_%s%s.data_out->original != data_t_desc) ) {\n" + "%s if( (NULL != this_task->data.%s.data_out) && (this_task->data.%s.data_out->original != data_t_desc) ) {\n" "%s /* Writting back using remote_type */;\n" "%s parsec_dep_data_description_t data;\n" - "%s data.data = this_task->data._f_%s%s.data_out;\n" + "%s data.data = this_task->data.%s.data_out;\n" "%s data.local.arena = %s;\n" "%s data.local.src_datatype = %s;\n" "%s data.local.src_count = %s;\n" @@ -7158,13 +7160,13 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, "%s parsec_remote_dep_memcpy(es,\n" "%s this_task->taskpool,\n" "%s parsec_data_get_copy(data_of_%s(%s), 0),\n" - "%s this_task->data._f_%s%s.data_out, &data);\n" + "%s this_task->data.%s.data_out, &data);\n" "%s }\n", spaces, call->func_or_mem, string_arena_get_string(sa), - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), spaces, spaces, - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), spaces, string_arena_get_string(sa_arena), spaces, string_arena_get_string(sa_type_src), spaces, string_arena_get_string(sa_count_src), @@ -7177,7 +7179,7 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, spaces, spaces, spaces, call->func_or_mem, string_arena_get_string(sa), - spaces, flow->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), spaces); coutput("#if defined(PARSEC_PROF_GRAPHER) && defined(PARSEC_PROF_TRACE)\n" @@ -7331,8 +7333,8 @@ static void jdf_generate_code_cache_awareness_update(const jdf_t *jdf, const jdf dump_parametrized_flow_loop_if_parametrized(df, " ", sa); //dump_parametrized_flow_loop(df, df->local_variables->alias, " ", sa); - string_arena_add_string(sa, "%s cache_buf_referenced(es->closest_cache, %s%s);\n", - INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df)); + string_arena_add_string(sa, "%s cache_buf_referenced(es->closest_cache, %s);\n", + INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname)); dump_parametrized_flow_loop_end_if_parametrized(df, " ", sa); //string_arena_add_string(sa, " }\n"); @@ -7840,10 +7842,10 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, if(fl->flow_flags & JDF_FLOW_TYPE_CTL) continue; /* control flow, nothing to store */ - coutput(" data_repo_entry_t *e%s = this_task->data._f_%s%s.source_repo_entry;\n" + coutput(" data_repo_entry_t *e%s = this_task->data.%s.source_repo_entry;\n" " if( (NULL != e%s) && (e%s->sim_exec_date > this_task->sim_exec_date) )\n" " this_task->sim_exec_date = e%s->sim_exec_date;\n", - fl->varname, fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + fl->varname, DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), fl->varname, fl->varname, fl->varname); } @@ -8185,10 +8187,10 @@ static void jdf_generate_code_hook(const jdf_t *jdf, dump_parametrized_flow_loop_if_parametrized(fl, " ", sa); coutput("%s", string_arena_get_string(sa)); - coutput("%s data_repo_entry_t *e%s = this_task->data._f_%s%s.source_repo_entry;\n" + coutput("%s data_repo_entry_t *e%s = this_task->data.%s.source_repo_entry;\n" "%s if( (NULL != e%s) && (e%s->sim_exec_date > this_task->sim_exec_date) )\n" "%s this_task->sim_exec_date = e%s->sim_exec_date;\n", - INDENTATION_IF_PARAMETRIZED(fl), fl->varname, fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), INDENTATION_IF_PARAMETRIZED(fl), fl->varname, fl->varname, INDENTATION_IF_PARAMETRIZED(fl), fl->varname); @@ -8308,21 +8310,21 @@ jdf_generate_code_complete_hook(const jdf_t *jdf, dump_parametrized_flow_loop_if_parametrized(fl, " ", osa); coutput("%s", string_arena_get_string(osa)); - coutput("%s if ( NULL != this_task->data._f_%s%s.data_out ) {\n" + coutput("%s if ( NULL != this_task->data.%s.data_out ) {\n" "#if defined(PARSEC_DEBUG_NOISIER)\n" "%s char tmp[128];\n" "#endif\n" - "%s this_task->data._f_%s%s.data_out->version++; /* %s */\n" + "%s this_task->data.%s.data_out->version++; /* %s */\n" "%s PARSEC_DEBUG_VERBOSE(10, parsec_debug_output,\n" "%s \"Complete hook of %%s: change Data copy %%p to version %%d at %%s:%%d\",\n" "%s parsec_task_snprintf(tmp, 128, (parsec_task_t*)(this_task)),\n" - "%s this_task->data._f_%s%s.data_out, this_task->data._f_%s%s.data_out->version, __FILE__, __LINE__);\n" + "%s this_task->data.%s.data_out, this_task->data.%s.data_out->version, __FILE__, __LINE__);\n" "%s }\n", - INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + INDENTATION_IF_PARAMETRIZED(fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), INDENTATION_IF_PARAMETRIZED(fl), - INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), fl->varname, + INDENTATION_IF_PARAMETRIZED(fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), fl->varname, INDENTATION_IF_PARAMETRIZED(fl), INDENTATION_IF_PARAMETRIZED(fl), INDENTATION_IF_PARAMETRIZED(fl), INDENTATION_IF_PARAMETRIZED(fl), - fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl), + DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), INDENTATION_IF_PARAMETRIZED(fl)); string_arena_init(osa); @@ -8383,11 +8385,11 @@ static void jdf_generate_code_free_hash_table_entry(const jdf_t *jdf, const jdf_ string_arena_t *osa = string_arena_new(64); - coutput("%s if( NULL != this_task->data._f_%s%s.source_repo_entry ) {\n" - "%s data_repo_entry_used_once( this_task->data._f_%s%s.source_repo, this_task->data._f_%s%s.source_repo_entry->ht_item.key );\n" + coutput("%s if( NULL != this_task->data.%s.source_repo_entry ) {\n" + "%s data_repo_entry_used_once( this_task->data.%s.source_repo, this_task->data.%s.source_repo_entry->ht_item.key );\n" "%s }\n", - INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df), - INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df), + INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname), + INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname), INDENTATION_IF_PARAMETRIZED(df)); string_arena_free(osa); @@ -8407,11 +8409,11 @@ static void jdf_generate_code_free_hash_table_entry(const jdf_t *jdf, const jdf_ string_arena_t *osa = string_arena_new(64); - coutput("%s if( NULL != this_task->data._f_%s%s.data_in ) {\n" - "%s PARSEC_DATA_COPY_RELEASE(this_task->data._f_%s%s.data_in);\n" + coutput("%s if( NULL != this_task->data.%s.data_in ) {\n" + "%s PARSEC_DATA_COPY_RELEASE(this_task->data.%s.data_in);\n" "%s }\n", - INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df), - INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df), + INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname), + INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname), INDENTATION_IF_PARAMETRIZED(df)); string_arena_free(osa); @@ -9029,8 +9031,8 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, dump_parametrized_flow_loop_if_parametrized(fl, " ", sa_coutput); // TODO: this is completely wrong, this should be inside the whole loop string_arena_add_string(sa_coutput, - "%s data.data = this_task->data._f_%s%s.data_out;\n", - INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, fl)); + "%s data.data = this_task->data.%s.data_out;\n", + INDENTATION_IF_PARAMETRIZED(fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname)); dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa_coutput); diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 0d7f341df..dae4fca0c 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -71,6 +71,26 @@ util_dump_array_offset_if_parametrized(string_arena_t *sa, const jdf_dataflow_t return string_arena_get_string(sa); } +/** + * @brief Dumps the proper access to the data, wether the flow is parametrized or not + * + */ +#define DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow, basename)\ + util_dump_data_field_name_in_task(sa, flow, basename) + +static inline char *util_dump_data_field_name_in_task(string_arena_t *sa, const jdf_dataflow_t *flow, const char *basename) +{ + string_arena_init(sa); + + if( FLOW_IS_PARAMETRIZED(flow) ) { + string_arena_add_string(sa, "parametrized__f_%s(%s)", flow->varname, get_parametrized_flow_iterator_name(flow)); + } else { + string_arena_add_string(sa, "_f_%s", flow->varname); + } + + return string_arena_get_string(sa); +} + /** * VARIABLE_IS_FLOW_LEVEL * Tells whether a variable is a flow level variable or not. From 568adae0c6fb0db77a196c255de3a2bdc480c5c4 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 7 Nov 2022 13:16:01 -0500 Subject: [PATCH 084/157] correct error --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index d70369db5..6a0d0c61b 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7333,8 +7333,8 @@ static void jdf_generate_code_cache_awareness_update(const jdf_t *jdf, const jdf dump_parametrized_flow_loop_if_parametrized(df, " ", sa); //dump_parametrized_flow_loop(df, df->local_variables->alias, " ", sa); - string_arena_add_string(sa, "%s cache_buf_referenced(es->closest_cache, %s);\n", - INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname)); + string_arena_add_string(sa, "%s cache_buf_referenced(es->closest_cache, _f_%s%s);\n", + INDENTATION_IF_PARAMETRIZED(df), df->varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, df)); dump_parametrized_flow_loop_end_if_parametrized(df, " ", sa); //string_arena_add_string(sa, " }\n"); From 689ad6f09c073fb5e8ac18ce10aed8005ee11ae2 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 7 Nov 2022 13:39:34 -0500 Subject: [PATCH 085/157] move the iterator of iterate_successors_of_PARAMETRIZED_FLOW to a higher level --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 34 +++++----------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 6a0d0c61b..b5c32d150 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -8639,10 +8639,10 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, } // Iterate if the flow is parametrized - dump_parametrized_flow_loop_if_parametrized(flow, " ", sa_open); + /*dump_parametrized_flow_loop_if_parametrized(flow, " ", sa_open); if(FLOW_IS_PARAMETRIZED(flow)) { ++nbopen; - } + }*/ for(vl = targetf->locals, i = 0; vl != NULL; vl = vl->next, i++) { @@ -9028,14 +9028,16 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, nb_open_ldef = 0; - dump_parametrized_flow_loop_if_parametrized(fl, " ", sa_coutput); // TODO: this is completely wrong, this should be inside the whole loop + dump_parametrized_flow_loop_if_parametrized(fl, " ", sa_coutput); + if(FLOW_IS_PARAMETRIZED(fl)) + { + nb_open_ldef++; + } string_arena_add_string(sa_coutput, "%s data.data = this_task->data.%s.data_out;\n", INDENTATION_IF_PARAMETRIZED(fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname)); - dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa_coutput); - for(dl = fl->deps; dl != NULL; dl = dl->next) { if( !(dl->dep_flags & flow_type) ) continue; /* Special case for the arena definition for WRITE-only flows */ @@ -9209,28 +9211,6 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, JDF_OBJECT_ONAME(dl->guard->calltrue)); } -/* - if(dl->guard->guard_type == JDF_GUARD_TERNARY && NULL != dl->guard->callfalse) { - dump_parametrized_flow_loop_if_parametrized(dl->guard->callfalse, indent(nb_open_ldef), sa_coutput); - if(FLOW_IS_PARAMETRIZED(dl->guard->callfalse)) { - nb_open_ldef++; - } - } - if(NULL != dl->guard->calltrue) - { - dump_parametrized_flow_loop_if_parametrized(dl->guard->calltrue, indent(nb_open_ldef), sa_coutput); - if(FLOW_IS_PARAMETRIZED(dl->guard->calltrue)) { - nb_open_ldef++; - } - } -*/ -/* - dump_parametrized_flow_loop_if_parametrized(f->dataflow, indent(nb_open_ldef), sa_coutput); - if(FLOW_IS_PARAMETRIZED(f->dataflow)) { - nb_open_ldef++; - } -*/ - if( NULL != dl->local_defs ) { jdf_expr_t *ld; for(ld = jdf_expr_lv_first(dl->local_defs); ld != NULL; ld = jdf_expr_lv_next(dl->local_defs, ld)) { From 21015fdb92dbe4db59f638d246f7568944ff9d83 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 7 Nov 2022 16:44:22 -0500 Subject: [PATCH 086/157] create the constructores for the tasks --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 117 ++++++++++++++++++++- 1 file changed, 112 insertions(+), 5 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index b5c32d150..1b062e54f 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -3716,6 +3716,81 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr "}\n\n"); } +jdf_generate_task_constructor(jdf_t *jdf, jdf_function_entry_t *f) +{ + /*coutput( + "int %s(const parsec_task_t* task)\n" + "{\n" + " %s *spec_task = (%s*)task;\n" + " const __parsec_%s_internal_taskpool_t *__parsec_tp = (const __parsec_%s_internal_taskpool_t *)task->taskpool;\n" + , parsec_get_name(NULL, f, "constructor"), + parsec_get_name(jdf, f, "task_t"), parsec_get_name(jdf, f, "task_t"), + jdf_basename, jdf_basename); + + string_arena_t *sa = string_arena_new(64); + + coutput(" int specializations_num = 0;\n"); + + for(jdf_dataflow_t *flow = f->dataflow; NULL != flow; flow = flow->next) { + if( FLOW_IS_PARAMETRIZED(flow) ) { + coutput(" specializations_num += %s;\n", jdf_expr_print(sa, flow->expr)); + + string_arena_init(sa); + dump_parametrized_flow_loop(flow, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(flow), " ", sa); + coutput("%s", string_arena_get_string(sa)); + + coutput(" // ...\n"); + + string_arena_init(sa); + dump_parametrized_flow_loop_end(flow, " ", sa); + coutput("%s", string_arena_get_string(sa)); + } + } + + coutput(" memset(spec_task->data.dynamic, 0, sizeof(parsec_data_pair_t) * MAX_LOCAL_COUNT);\n"); + + string_arena_free(sa); + +/* +string_arena_init(sa); + dump_parametrized_flow_loop(df, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), " ", sa); + + // First parametrized flows: + string_arena_add_string(sa, " // Local parametrized flows of %s\n", f->fname); + string_arena_add_string(sa, "#if defined(PARSEC_DEBUG_NOISIER)\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " , .nb_specializations_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + } + } + string_arena_add_string(sa, "#endif\n"); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + string_arena_add_string(sa, " , .out_dep_offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + // store the offset for every output dep of this parametrized flow + string_arena_add_string(sa, " , .out_offset_dep_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + } + } + +*/ + + + + + // simple version: + coutput( + "int %s(const parsec_task_t** task)\n" + "{\n" + " %s *spec_task = (%s*)(*task);\n", + parsec_get_name(NULL, f, "constructor"), + parsec_get_name(jdf, f, "task_t"), parsec_get_name(jdf, f, "task_t"), + jdf_basename, jdf_basename); + + coutput(" memset(spec_task->data.dynamic, 0, sizeof(parsec_data_pair_t) * MAX_LOCAL_COUNT);\n"); + + coutput( "}\n"); +} + /* structure to handle the correspondence between local variables and function parameters */ typedef struct jdf_l2p_s { const jdf_variable_list_t *vl; @@ -4806,6 +4881,28 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, " .release_task = &%s,\n", prefix); } + + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + string_arena_add_string(sa, " .new_task = &%s,\n", parsec_get_name(NULL, f, "constructor")); + + /*string_arena_add_string(sa, + "PARSEC_OBJ_CLASS_DECLARATION(%s);\n" + "PARSEC_OBJ_CLASS_INSTANCE(%s, %s,\n" + " %s, NULL);\n\n", + parsec_get_name(NULL, f, "task_t"), + parsec_get_name(NULL, f, "task_t"), + "parsec_list_item_t", + //parsec_get_name(NULL, f, "constructor") + "NULL" + );*/ + } + else + { + string_arena_add_string(sa, " .new_task = NULL,\n"); + } + + //.new_task = (parsec_task_new_t*)new_task_of_%s_%s, + if( NULL != f->simcost ) { sprintf(prefix, "simulation_cost_of_%s_%s", jdf_basename, f->fname); jdf_generate_simulation_cost_fct(jdf, f, prefix); @@ -4828,6 +4925,10 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f jdf_generate_startup_tasks(jdf, f, jdf_property_get_function(f->properties, JDF_PROP_UD_STARTUP_TASKS_FN_NAME, NULL)); } + if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f) ) { + jdf_generate_task_constructor(jdf, f); + } + string_arena_add_string(sa, "};\n"); if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) @@ -9390,11 +9491,17 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, } else if( 1 == flowempty ) { coutput(" /* Flow of data %s has only OUTPUT dependencies to Memory */\n", fl->varname); } else { - coutput(" if( action_mask & 0x%x ) { /* Flow of data %s [%d] */\n" - "%s" - " }\n", - (flow_type & JDF_DEP_FLOW_OUT) ? fl->flow_dep_mask_out : fl->flow_dep_mask_in/*mask*/, fl->varname, fl->flow_index, - string_arena_get_string(sa_coutput)/*IFBODY*/); + /*if(FLOW_IS_PARAMETRIZED(fl)) { + + } + else*/ + { + coutput(" if( action_mask & 0x%x ) { /* Flow of data %s [%d] */\n" + "%s" + " }\n", + (flow_type & JDF_DEP_FLOW_OUT) ? fl->flow_dep_mask_out : fl->flow_dep_mask_in/*mask*/, fl->varname, fl->flow_index, + string_arena_get_string(sa_coutput)/*IFBODY*/); + } } } coutput(" (void)data;(void)nc;(void)es;(void)ontask;(void)ontask_arg;(void)rank_dst;(void)action_mask;\n"); From ff9b807678b9d59bacc7abafd1563a0b4bde5846 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 7 Nov 2022 17:27:32 -0500 Subject: [PATCH 087/157] definition of simple constructor, need work to merge with the modifications of George --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 37 +++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 1b062e54f..2ebe787be 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -3777,6 +3777,34 @@ string_arena_init(sa); +/* +TODO: framework suggested by Thomas: + +int __parsec_LBM_LBM_STEP_constructor(parsec_task_t *task) { + // initialize the fields above the base object on which the task derives +} + +PARSEC_OBJ_DECLARE(__parsec_LBM_LBM_STEP_task_t); +PARSEC_OBJ_CLASS_INSTANCE(__parsec_LBM_LBM_STEP_task_t, parsec_list_item_t, + __parsec_LBM_LBM_STEP_constructor, NULL); + +void __parsec_LBM_LBM_new_task(parsec_task_t **task) +{ + __parsec_LBM_LBM_STEP_task_t *n = PARSEC_OBJ_NEW(__parsec_LBM_LBM_STEP_task_t); + *task = &n->super; +} + +parsec_taskpool_t *LBM_new(...) +{ + parsec_taskpool_t *lbm_tp = malloc(...); + ... + lbm_tp->new_task = __parsec_LBM_LBM_new_task; + ... + return lbm_tp; +} +*/ + + // simple version: coutput( "int %s(const parsec_task_t** task)\n" @@ -3786,7 +3814,14 @@ string_arena_init(sa); parsec_get_name(jdf, f, "task_t"), parsec_get_name(jdf, f, "task_t"), jdf_basename, jdf_basename); - coutput(" memset(spec_task->data.dynamic, 0, sizeof(parsec_data_pair_t) * MAX_LOCAL_COUNT);\n"); + int non_parametrized_count = 0; + for(jdf_dataflow_t *flow = f->dataflow; NULL != flow; flow = flow->next) { + if( !FLOW_IS_PARAMETRIZED(flow) ) { + non_parametrized_count++; + } + } + + coutput(" memset(spec_task->data.dynamic, 0, sizeof(parsec_data_pair_t) * (MAX_LOCAL_COUNT-%d));\n", non_parametrized_count); coutput( "}\n"); } From 251ea379351f5345a421ff61677848a73c321aac Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 8 Nov 2022 10:26:05 -0500 Subject: [PATCH 088/157] add custom name to parametrized flows --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 2ebe787be..ec9973dc3 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -4969,7 +4969,7 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { string_arena_add_string(sa, "static parsec_%s_task_class_t spec_%s = {\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); - string_arena_add_string(sa, " .super = %s", JDF_OBJECT_ONAME(f)); + string_arena_add_string(sa, " .super = %s\n", JDF_OBJECT_ONAME(f)); // First parametrized flows: string_arena_add_string(sa, " // Local parametrized flows of %s\n", f->fname); @@ -5718,10 +5718,15 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput( " parsec_helper_copy_flow(&flow_of_%s_%s_for_parametrized_%s[%s], &flow_of_%s_%s_for_%s);\n" - " flow_of_%s_%s_for_parametrized_%s[%s].flow_index = %s;\n", + " flow_of_%s_%s_for_parametrized_%s[%s].flow_index = %s;\n" + " char specialized_flow_name[64];\n" + " sprintf(specialized_flow_name, \"%s_%s_%%d\", %s);\n" + " flow_of_%s_%s_for_parametrized_%s[%s].name = strdup(specialized_flow_name);\n", jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, - jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) + jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) ); string_arena_init(sa); @@ -6540,6 +6545,7 @@ jdf_generate_code_reshape_input_from_dep(const jdf_t *jdf, * Format: type = XX type_remote = ... -> pack XX unpack XX * */ coutput("%s data.data = NULL;\n", spaces); + coutput("%s assert(consumed_entry);\n", spaces); coutput("%s data.data_future = (parsec_datacopy_future_t*)consumed_entry->data[consumed_flow_index];\n", spaces); From 5fd4f7fd306fc6ce547210889468c4fa4f8a3f8f Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 8 Nov 2022 12:08:32 -0500 Subject: [PATCH 089/157] correct dynamic data offet --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 104 ++++++++++++--------- 1 file changed, 61 insertions(+), 43 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index ec9973dc3..dc9bce36d 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1743,7 +1743,8 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { coutput(" int out_dep_offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); - coutput(" int out_offset_dep_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + coutput(" int out_flow_offset_dep_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + coutput(" int data_dynamic_offset_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } } @@ -1927,7 +1928,7 @@ static void jdf_generate_structure(jdf_t *jdf) for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - coutput("#define parametrized__f_%s(it) dynamic[(spec_%s.out_dep_offset_flow_of_%s_%s_for_%s)+(it)]\n", + coutput("#define parametrized__f_%s(it) dynamic[(spec_%s.data_dynamic_offset_%s_%s_for_%s)+(it)]\n", df->varname, JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); } @@ -4984,7 +4985,8 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f if( FLOW_IS_PARAMETRIZED(df) ) { string_arena_add_string(sa, " , .out_dep_offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); // store the offset for every output dep of this parametrized flow - string_arena_add_string(sa, " , .out_offset_dep_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " , .out_flow_offset_dep_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " , .data_dynamic_offset_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); } } @@ -5916,18 +5918,28 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" // Finally, set the correct indices for the parametrized flows and the referrers\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { - coutput(" { // Parametrized flow %s of task class %s\n", df->varname, f->fname); - //coutput(" parsec_task_class_t *tc = &parsec_%s_%s;\n", jdf_basename, f->fname); - //coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_parametrized_%s[0];\n", jdf_basename, f->fname, df->varname); - //coutput(" spec_%s.out_offset_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out);\n" - // JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname,); - - // For the moment, do not set this, I think it is not needed - coutput(" spec_%s.out_dep_offset_flow_of_%s_%s_for_%s = -1;\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); - coutput(" }\n"); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { + coutput(" int current_data_offset_for_%s_%s = 0;\n", jdf_basename, f->fname); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" { // Parametrized flow %s of task class %s\n", df->varname, f->fname); + //coutput(" parsec_task_class_t *tc = &parsec_%s_%s;\n", jdf_basename, f->fname); + //coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_parametrized_%s[0];\n", jdf_basename, f->fname, df->varname); + //coutput(" spec_%s.out_offset_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out);\n" + // JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname,); + + // For the moment, do not set this, I think it is not needed + coutput(" spec_%s.out_dep_offset_flow_of_%s_%s_for_%s = -1;\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput("\n"); + + coutput(" spec_%s.data_dynamic_offset_%s_%s_for_%s = current_data_offset_for_%s_%s;\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname); + coutput(" current_data_offset_for_%s_%s += nb_specializations_flow_of_%s_%s_for_parametrized_%s;\n", + jdf_basename, f->fname, jdf_basename, f->fname, df->varname); + coutput(" }\n"); + } } } } @@ -6794,6 +6806,10 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, "%s this_task->data.%s.data_out = chunk;\n", spaces, flow->varname, jdf_basename, call->func_or_mem, call->var, spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + if(FLOW_IS_PARAMETRIZED(flow)) { + coutput("%s parsec_debug_verbose(1, parsec_debug_output, \"%s = %%d\", %s);\n", + spaces, get_parametrized_flow_iterator_name(flow), get_parametrized_flow_iterator_name(flow)); + } } else { @@ -7034,12 +7050,12 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, coutput("%s", string_arena_get_string(osa)); coutput("\n" - "if(! this_task->data.%s.fulfill ){ /* Flow %s */\n", DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), flow->varname); + "%sif(! this_task->data.%s.fulfill ){ /* Flow %s */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), flow->varname); - coutput(" consumed_repo = NULL;\n" - " consumed_entry_key = 0;\n" - " consumed_entry = NULL;\n" - " chunk = NULL;\n"); + coutput("%s consumed_repo = NULL;\n" + "%s consumed_entry_key = 0;\n" + "%s consumed_entry = NULL;\n" + "%s chunk = NULL;\n", INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow)); for(dl = flow->deps; dl != NULL; dl = dl->next) { if ( dl->dep_flags & JDF_DEP_FLOW_OUT ) { @@ -7048,9 +7064,9 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, } } if( !has_output_deps ) { - coutput("\n this_task->data.%s.data_out = NULL; /* input only */\n", DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + coutput("\n%s this_task->data.%s.data_out = NULL; /* input only */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); } else { - coutput("\n this_task->data.%s.data_out = NULL; /* By default, if nothing matches */\n", DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + coutput("\n%s this_task->data.%s.data_out = NULL; /* By default, if nothing matches */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); } sa = string_arena_new(64); @@ -7070,22 +7086,22 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, case JDF_GUARD_UNCONDITIONAL: if( 0 != cond_index ) coutput(" else {\n"); jdf_generate_code_call_initialization( jdf, dl->guard->calltrue, f, flow, dl, - (0 != cond_index ? " " : "") ); + FLOW_IS_PARAMETRIZED(flow)?((0 != cond_index ? " " : " ")):((0 != cond_index ? " " : "")) ); if( 0 != cond_index ) coutput(" }\n"); goto done_with_input; case JDF_GUARD_BINARY: coutput( (0 == cond_index ? condition[0] : condition[1]), dump_expr((void**)dl->guard->guard, &info)); - jdf_generate_code_call_initialization( jdf, dl->guard->calltrue, f, flow, dl, " " ); + jdf_generate_code_call_initialization( jdf, dl->guard->calltrue, f, flow, dl, FLOW_IS_PARAMETRIZED(flow)?" ":" " ); coutput(" }\n"); cond_index++; break; case JDF_GUARD_TERNARY: coutput( (0 == cond_index ? condition[0] : condition[1]), dump_expr((void**)dl->guard->guard, &info)); - jdf_generate_code_call_initialization( jdf, dl->guard->calltrue, f, flow, dl, " " ); + jdf_generate_code_call_initialization( jdf, dl->guard->calltrue, f, flow, dl, FLOW_IS_PARAMETRIZED(flow)?" ":" " ); coutput(" } else {\n"); - jdf_generate_code_call_initialization( jdf, dl->guard->callfalse, f, flow, dl, " " ); + jdf_generate_code_call_initialization( jdf, dl->guard->callfalse, f, flow, dl, FLOW_IS_PARAMETRIZED(flow)?" ":" " ); coutput(" }\n"); goto done_with_input; } @@ -7137,29 +7153,31 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, } } done_with_input: - coutput(" this_task->data.%s.data_in = chunk;\n" - " this_task->data.%s.source_repo = consumed_repo;\n" - " this_task->data.%s.source_repo_entry = consumed_entry;\n", - DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), - DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), - DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + coutput("%s this_task->data.%s.data_in = chunk;\n" + "%s this_task->data.%s.source_repo = consumed_repo;\n" + "%s this_task->data.%s.source_repo_entry = consumed_entry;\n", + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); if( !(f->flags & JDF_FUNCTION_FLAG_NO_SUCCESSORS) ) { /* If we have consume from our repo, we clean up the repo entry for that flow, * so we don't have old stuff during release_deps_of when we will set up outputs * on our repo as a predecessor. */ - coutput(" if( this_task->data.%s.source_repo_entry == this_task->repo_entry ){\n" - " /* in case we have consume from this task repo entry for the flow,\n" - " * it is cleaned up, avoiding having old stuff during release_deps_of\n" - " */\n" - " this_task->repo_entry->data[%d] = NULL;\n" - " }\n", - DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), - flow->flow_index); - } - coutput(" this_task->data.%s.fulfill = 1;\n" + coutput("%s if( this_task->data.%s.source_repo_entry == this_task->repo_entry ){\n" + "%s /* in case we have consume from this task repo entry for the flow,\n" + "%s * it is cleaned up, avoiding having old stuff during release_deps_of\n" + "%s */\n" + "%s this_task->repo_entry->data[%d] = NULL;\n" + "%s }\n", + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), + flow->flow_index, + INDENTATION_IF_PARAMETRIZED(flow)); + } + coutput("%s this_task->data.%s.fulfill = 1;\n" "}\n\n", - DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname));/* coutput("if(! this_task->data._f_%s.fulfill ){\n", flow->varname);*/ + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname));/* coutput("if(! this_task->data._f_%s.fulfill ){\n", flow->varname);*/ string_arena_init(osa); From 67233dadae89e414b377fc2da3488ea4eb4fc04a Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 8 Nov 2022 14:50:08 -0500 Subject: [PATCH 090/157] properly declare the gpu tasks (the target flow is NOT working yet) --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 90 +++++++++++++++++----- 1 file changed, 72 insertions(+), 18 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index dc9bce36d..95ce0d26c 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -8147,16 +8147,53 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, /* Dump the dataflow */ coutput(" gpu_task->pushout = 0;\n"); + + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + coutput(" int current_flow_id=0;\n"); + } + + int parametrized_flow_has_been_encountered = 0; + + string_arena_t *sa_di = string_arena_new(64); for(fl = f->dataflow, di = 0; fl != NULL; fl = fl->next, di++) { - coutput(" gpu_task->flow[%d] = &%s;\n", - di, JDF_OBJECT_ONAME( fl )); + coutput(" // Dataflow %s\n", fl->varname); + + if(FLOW_IS_PARAMETRIZED(fl)) { + // If this flow is parametrized, all the following ones will have a dynamic id + parametrized_flow_has_been_encountered = 1; + } + + string_arena_init(sa_di); + if( parametrized_flow_has_been_encountered ) { + // We use the current_flow_id variable because we cannot compute di at compile time + string_arena_add_string(sa_di, "current_flow_id", di); + } else { + string_arena_add_string(sa_di, "%d", di); + } + const char *di_str = string_arena_get_string(sa_di); + + if(FLOW_IS_PARAMETRIZED(fl)) { + string_arena_t *sa = string_arena_new(64); + dump_parametrized_flow_loop(fl, get_parametrized_flow_iterator_name(fl), " ", sa); + coutput("%s", string_arena_get_string(sa)); + string_arena_free(sa); + } + + if( FLOW_IS_PARAMETRIZED(fl) ) { + coutput("%s gpu_task->flow[%s] = NULL;\n", + INDENTATION_IF_PARAMETRIZED(fl), di_str); + }else{ + coutput("%s gpu_task->flow[%s] = &%s;\n", + INDENTATION_IF_PARAMETRIZED(fl), di_str, JDF_OBJECT_ONAME( fl )); + } sprintf(sa->ptr, "%s.dc", fl->varname); jdf_find_property(body->properties, sa->ptr, &desc_property); if(desc_property == NULL){ - coutput(" gpu_task->flow_dc[%d] = NULL;\n", di); + coutput("%s gpu_task->flow_dc[%s] = NULL;\n", INDENTATION_IF_PARAMETRIZED(fl), di_str); }else{ - coutput(" gpu_task->flow_dc[%d] = (parsec_data_collection_t *)%s;\n", di, + coutput("%s gpu_task->flow_dc[%s] = (parsec_data_collection_t *)%s;\n", + INDENTATION_IF_PARAMETRIZED(fl), di_str, dump_expr((void**)desc_property->expr, &info)); } @@ -8169,16 +8206,16 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, fl->varname, JDF_OBJECT_LINENO(fl)); exit(-1); } - coutput(" gpu_task->flow_nb_elts[%d] = 0;\n", di); + coutput("%s gpu_task->flow_nb_elts[%s] = 0;\n", INDENTATION_IF_PARAMETRIZED(fl), di_str); }else{ if(size_property == NULL){ - coutput(" gpu_task->flow_nb_elts[%d] = gpu_task->ec->data[%d].data_in->original->nb_elts;\n", di, di); + coutput("%s gpu_task->flow_nb_elts[%s] = gpu_task->ec->data[%s].data_in->original->nb_elts;\n", INDENTATION_IF_PARAMETRIZED(fl), di_str, di_str); }else{ - coutput(" gpu_task->flow_nb_elts[%d] = %s;\n", - di, dump_expr((void**)size_property->expr, &info)); + coutput("%s gpu_task->flow_nb_elts[%s] = %s;\n", + INDENTATION_IF_PARAMETRIZED(fl), di_str, dump_expr((void**)size_property->expr, &info)); if( (stage_in_property == NULL) || ( stage_out_property == NULL )){ - coutput(" assert(gpu_task->ec->data[%d].data_in->original->nb_elts <= %s);\n", - di, dump_expr((void**)size_property->expr, &info)); + coutput("%s assert(gpu_task->ec->data[%s].data_in->original->nb_elts <= %s);\n", + INDENTATION_IF_PARAMETRIZED(fl), di_str, dump_expr((void**)size_property->expr, &info)); } } @@ -8208,33 +8245,33 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, switch( dl->guard->guard_type ) { case JDF_GUARD_UNCONDITIONAL: if(testtrue) { - coutput(" gpu_task->pushout |= (1 << %d);\n", di); + coutput(" gpu_task->pushout |= (1 << %s);\n", di_str); goto nextflow; } break; case JDF_GUARD_BINARY: if(testtrue) { coutput(" if( %s ) {\n" - " gpu_task->pushout |= (1 << %d);\n" + " gpu_task->pushout |= (1 << %s);\n" " }", - dump_expr((void**)dl->guard->guard, &info), di); + dump_expr((void**)dl->guard->guard, &info), di_str); } break; case JDF_GUARD_TERNARY: if( testtrue ) { if( testfalse ) { - coutput(" gpu_task->pushout |= (1 << %d);\n", di); + coutput(" gpu_task->pushout |= (1 << %s);\n", di_str); } else { coutput(" if( %s ) {\n" - " gpu_task->pushout |= (1 << %d);\n" + " gpu_task->pushout |= (1 << %s);\n" " }\n", - dump_expr((void**)dl->guard->guard, &info), di); + dump_expr((void**)dl->guard->guard, &info), di_str); } } else if ( testfalse ) { coutput(" if( !(%s) ) {\n" - " gpu_task->pushout |= (1 << %d);\n" + " gpu_task->pushout |= (1 << %s);\n" " }\n", - dump_expr((void**)dl->guard->guard, &info), di); + dump_expr((void**)dl->guard->guard, &info), di_str); } break; } @@ -8242,7 +8279,24 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, nextflow: ; } + + if(FLOW_IS_PARAMETRIZED(fl)) { + coutput(" current_flow_id++;\n"); + + string_arena_t *sa = string_arena_new(64); + dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa); + coutput("%s", string_arena_get_string(sa)); + string_arena_free(sa); + } } + + /*if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + coutput(" assert(this_task->task_class->nb_flows > 0);\n"); + coutput(" memcpy(gpu_task->flow, this_task->task_class->flow, sizeof(parsec_flow_t) * this_task->task_class->nb_flows);\n"); + }*/ + + string_arena_free(sa_di); + string_arena_free(info.sa); coutput(" parsec_device_load[dev_index] += gpu_task->load;\n" From 3f90d9232e693603ec10c87e13bf9440a7808e4c Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 8 Nov 2022 16:59:47 -0500 Subject: [PATCH 091/157] set in_flow_offset_of_ + renamings --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 110 ++++++++++++++------- parsec/parsec_internal.h | 2 +- parsec/task_class.c | 27 ++++- parsec/task_class.h | 7 +- 4 files changed, 104 insertions(+), 42 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 95ce0d26c..4a535b264 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1736,15 +1736,16 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) coutput(" // Local parametrized flows of %s\n#if defined(PARSEC_DEBUG_NOISIER)\n", f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - coutput(" int nb_specializations_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + coutput(" int nb_specializations_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } } coutput("#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - coutput(" int out_dep_offset_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); - coutput(" int out_flow_offset_dep_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); - coutput(" int data_dynamic_offset_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + coutput(" int in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + coutput(" int out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + coutput(" int out_dep_offset_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + coutput(" int data_dynamic_offset_of_parametrized_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } } @@ -1766,14 +1767,14 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) { // Then the dep refers to a parametrized flow - coutput(" int out_dep_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + coutput(" int out_dep_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); // We also keep track of the flow that id that contains the referrer - coutput(" int out_flow_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + coutput(" int out_flow_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse @@ -1928,7 +1929,7 @@ static void jdf_generate_structure(jdf_t *jdf) for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - coutput("#define parametrized__f_%s(it) dynamic[(spec_%s.data_dynamic_offset_%s_%s_for_%s)+(it)]\n", + coutput("#define parametrized__f_%s(it) dynamic[(spec_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s)+(it)]\n", df->varname, JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); } @@ -4977,16 +4978,17 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "#if defined(PARSEC_DEBUG_NOISIER)\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " , .nb_specializations_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " , .nb_specializations_of_parametrized_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); } } string_arena_add_string(sa, "#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " , .out_dep_offset_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " , .out_dep_offset_of_parametrized_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); // store the offset for every output dep of this parametrized flow - string_arena_add_string(sa, " , .out_flow_offset_dep_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); - string_arena_add_string(sa, " , .data_dynamic_offset_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); + string_arena_add_string(sa, " , .in_flow_offset_of_parametrized_%s = -1\n", JDF_OBJECT_ONAME(df)); + string_arena_add_string(sa, " , .out_flow_offset_of_parametrized_%s = -1\n", JDF_OBJECT_ONAME(df)); + string_arena_add_string(sa, " , .data_dynamic_offset_of_parametrized_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); } } @@ -5007,12 +5009,12 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f if( NULL != call->parametrized_offset ) { - string_arena_add_string(sa, " , .out_dep_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", + string_arena_add_string(sa, " , .out_dep_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - string_arena_add_string(sa, " , .out_flow_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", + string_arena_add_string(sa, " , .out_flow_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse @@ -5319,7 +5321,7 @@ static void jdf_generate_constructor( const jdf_t* jdf ) " __parsec_tp->super.super.dependencies_array = (void **)\n" " calloc(__parsec_tp->super.super.nb_task_classes, sizeof(void*));\n" " /* Twice the size to hold the startup tasks function_t */\n" - " __parsec_tp->super.super.task_classes_array = (const parsec_task_class_t**)\n" + " __parsec_tp->super.super.task_classes_array = (parsec_task_class_t**)\n" " calloc((2 * PARSEC_%s_NB_TASK_CLASSES + 1), sizeof(parsec_task_class_t*));\n" " __parsec_tp->super.super.tdm.module->taskpool_addto_runtime_actions(&__parsec_tp->super.super, PARSEC_%s_NB_TASK_CLASSES); /* for the startup tasks */\n" " __parsec_tp->super.super.taskpool_type = PARSEC_TASKPOOL_TYPE_PTG;\n" @@ -5610,7 +5612,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_expr_t *to = df->local_variables->jdf_ta2; //jdf_expr_t *step = variable->jdf_ta3; - coutput(" const int nb_specializations_flow_of_%s_%s_for_parametrized_%s = (%s)+1;\n", + coutput(" const int nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s = (%s)+1;\n", jdf_basename, f->fname, df->varname, dump_expr((void**)to, &expr_info)); } } @@ -5629,7 +5631,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_expr_t *to = df->local_variables->jdf_ta2; //jdf_expr_t *step = variable->jdf_ta3; - coutput(" flow_of_%s_%s_for_parametrized_%s = malloc(sizeof(parsec_flow_t) * nb_specializations_flow_of_%s_%s_for_parametrized_%s);\n", + coutput(" flow_of_%s_%s_for_parametrized_%s = malloc(sizeof(parsec_flow_t) * nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s);\n", jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); } } @@ -5652,7 +5654,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) { // Then the dep refers to a parametrized flow - coutput(" %s_referrer_dep%d_atline_%d%s = malloc(sizeof(parsec_dep_t) * nb_specializations_flow_of_%s_%s_for_parametrized_%s);\n", + coutput(" %s_referrer_dep%d_atline_%d%s = malloc(sizeof(parsec_dep_t) * nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s);\n", JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", @@ -5669,7 +5671,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - coutput(" spec_%s.nb_specializations_flow_of_%s_%s_for_%s = nb_specializations_flow_of_%s_%s_for_parametrized_%s;\n", + coutput(" spec_%s.nb_specializations_of_parametrized_flow_of_%s_%s_for_%s = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); } } @@ -5705,7 +5707,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n\n", f->task_class_id); coutput( " // Shift the flows that are after the parametrized flow\n" - " parsec_shift_all_flows_after(tc, &flow_of_%s_%s_for_%s, nb_specializations_flow_of_%s_%s_for_parametrized_%s-1);\n" + " parsec_shift_all_flows_after(tc, &flow_of_%s_%s_for_%s, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n" "\n", jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname @@ -5745,7 +5747,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " for(int flow_in_out=0;flow_in_out<2;++flow_in_out) {\n" " bool pivot_reached = false;\n" " int %s = 0;\n" - " for(i = 0; i < MAX_DATAFLOWS_PER_TASK && %s < nb_specializations_flow_of_%s_%s_for_parametrized_%s; i++) {\n" + " for(i = 0; i < MAX_DATAFLOWS_PER_TASK && %s < nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s; i++) {\n" " parsec_flow_t *flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]);\n" " if(!flow && !pivot_reached) {\n" " break;\n" @@ -5762,13 +5764,13 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " // If is input, shift the proper values in the goal\n" " // Idea: 00abcxyz -> abcccxyz (if shift=2 (i.e. nb_specializations=3) and pivot index = 3)\n" " // (c=1 necessarily)\n" - " int shift = nb_specializations_flow_of_%s_%s_for_parametrized_%s-1;\n" + " int shift = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1;\n" " parsec_dependency_t unshifted_values = tc->dependencies_goal & ((1<dependencies_goal >> (i + 1)) << (i + 1 + shift);\n" " parsec_dependency_t in_between = ((1<<(shift+1))-1) << i;\n" " tc->dependencies_goal = unshifted_values | shifted_values | in_between;\n" " }\n" - " assert(i+nb_specializations_flow_of_%s_%s_for_parametrized_%s < MAX_DATAFLOWS_PER_TASK);\n" + " assert(i+nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s < MAX_DATAFLOWS_PER_TASK);\n" " }\n" " if(pivot_reached)\n" " {\n" @@ -5799,7 +5801,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " flow->flow_datatype_mask = 1 << flow->flow_index; // TODO verify (related to in/out)\n" " }*/\n" " // Update nb_flows\n" - " tc->nb_flows += nb_specializations_flow_of_%s_%s_for_parametrized_%s-1;\n", + " tc->nb_flows += nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1;\n", jdf_basename, f->fname, df->varname ); @@ -5857,11 +5859,11 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput( " // Shift the deps that are after dep (which references the parametrized flow)\n" - " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_flow_of_%s_%s_for_parametrized_%s-1);\n", + " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n", jdf_basename, call->func_or_mem, call->var ); - coutput(" for( int %s=0;%sparametrized_offset->alias, call->parametrized_offset->alias, jdf_basename, call->func_or_mem, call->var, @@ -5929,15 +5931,42 @@ static void jdf_generate_new_function( const jdf_t* jdf ) //coutput(" spec_%s.out_offset_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out);\n" // JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname,); - // For the moment, do not set this, I think it is not needed - coutput(" spec_%s.out_dep_offset_flow_of_%s_%s_for_%s = -1;\n", + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n\n", f->task_class_id); + + coutput("#if defined(PARSEC_DEBUG_NOISIER)\n"); + coutput(" spec_%s.nb_specializations_of_parametrized_flow_of_%s_%s_for_%s = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname); + coutput("#endif\n"); + + coutput(" spec_%s.in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); + coutput(" spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s = -1;\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput(" spec_%s.out_dep_offset_of_parametrized_flow_of_%s_%s_for_%s = -1;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput("\n"); - coutput(" spec_%s.data_dynamic_offset_%s_%s_for_%s = current_data_offset_for_%s_%s;\n", + coutput(" spec_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s = current_data_offset_for_%s_%s;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname); - coutput(" current_data_offset_for_%s_%s += nb_specializations_flow_of_%s_%s_for_parametrized_%s;\n", + coutput(" current_data_offset_for_%s_%s += nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", jdf_basename, f->fname, jdf_basename, f->fname, df->varname); + + + coutput("#if defined(PARSEC_DEBUG_NOISIER)\n"); + coutput(" assert(spec_%s.nb_specializations_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput("#endif\n"); + coutput(" assert(spec_%s.in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput(" assert(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput(" assert(spec_%s.out_dep_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput(" assert(spec_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput(" }\n"); } } @@ -5973,12 +6002,12 @@ static void jdf_generate_new_function( const jdf_t* jdf ) assert(!FLOW_IS_PARAMETRIZED(df)); // If the flow is parametrized, - coutput(" spec_%s.out_dep_offset_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, dep, 1);\n", + coutput(" spec_%s.out_dep_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, dep, 1);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - coutput(" spec_%s.out_flow_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_flow_index_that_contains_dep(tc, dep, 1);\n", + coutput(" spec_%s.out_flow_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_flow_index_that_contains_dep(tc, dep, 1);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse @@ -8149,6 +8178,7 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, coutput(" gpu_task->pushout = 0;\n"); if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + // We need this variable if at least on flow is parametrized coutput(" int current_flow_id=0;\n"); } @@ -8180,8 +8210,18 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, } if( FLOW_IS_PARAMETRIZED(fl) ) { - coutput("%s gpu_task->flow[%s] = NULL;\n", - INDENTATION_IF_PARAMETRIZED(fl), di_str); + // If the flow is out (note: we use either in or out, this is our only way of getting a parametrized_flow) + if( JDF_FLOW_IS_OUT & fl->flow_flags ) { + coutput("%s gpu_task->flow[%s] = this_task->task_class->out[spec_%s_%s.out_flow_offset_of_parametrized_%s + %s];\n", + INDENTATION_IF_PARAMETRIZED(fl), di_str, + jdf_basename, f->fname, JDF_OBJECT_ONAME(fl), get_parametrized_flow_iterator_name(fl)); + } + else + { + coutput("%s gpu_task->flow[%s] = this_task->task_class->in[spec_%s_%s.in_flow_offset_of_parametrized_%s + %s];\n", + INDENTATION_IF_PARAMETRIZED(fl), di_str, + jdf_basename, f->fname, JDF_OBJECT_ONAME(fl), get_parametrized_flow_iterator_name(fl)); + } }else{ coutput("%s gpu_task->flow[%s] = &%s;\n", INDENTATION_IF_PARAMETRIZED(fl), di_str, JDF_OBJECT_ONAME( fl )); @@ -9110,7 +9150,7 @@ char *dump_flow_offset_for_iterate_successors(string_arena_t *sa, jdf_function_e string_arena_init(sa); //spec_%s_%s.out_flow_offset_of_%s] - string_arena_add_string(sa, "spec_%s_%s.out_flow_offset_of_%s", + string_arena_add_string(sa, "spec_%s_%s.out_flow_offset_of_referrer_%s", jdf_basename, f->fname, JDF_OBJECT_ONAME(call)); return string_arena_get_string(sa); @@ -9121,7 +9161,7 @@ char *dump_dep_offset_for_iterate_successors(string_arena_t *sa, jdf_function_en string_arena_init(sa); //spec_%s_%s.out_dep_offset_%s+%s - string_arena_add_string(sa, "spec_%s_%s.out_dep_offset_%s+%s", + string_arena_add_string(sa, "spec_%s_%s.out_dep_offset_of_referrer_%s+%s", jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); return string_arena_get_string(sa); diff --git a/parsec/parsec_internal.h b/parsec/parsec_internal.h index 3cdd11fcb..6472c6c70 100644 --- a/parsec/parsec_internal.h +++ b/parsec/parsec_internal.h @@ -144,7 +144,7 @@ struct parsec_taskpool_s { parsec_context_t* context; /**< The PaRSEC context on which this taskpool was enqueued */ parsec_termdet_monitor_t tdm; /**< Termination detection structures and pointer to module */ parsec_startup_fn_t startup_hook; /**< Pointer to the function that generates initial tasks */ - const parsec_task_class_t** task_classes_array; /**< Array of task classes that build this DAG */ + parsec_task_class_t** task_classes_array; /**< Array of task classes that build this DAG */ #if defined(PARSEC_PROF_TRACE) const int* profiling_array; /**< Array of profiling keys to start/stop each of the task classes * The array is indexed on the same index as task_classes_array */ diff --git a/parsec/task_class.c b/parsec/task_class.c index 837dd46b8..83180de5a 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -446,7 +446,7 @@ parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_f return dep_to; } -int parsec_helper_dep_is_in_flow(parsec_flow_t *flow, parsec_dep_t *dep) +int parsec_helper_dep_is_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep) { int i; for (i = 0; i < MAX_DEP_IN_COUNT; i++) @@ -478,7 +478,7 @@ int parsec_helper_dep_is_in_flow(parsec_flow_t *flow, parsec_dep_t *dep) return 0; } -int parsec_helper_get_dep_index(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out) +int parsec_helper_get_dep_index(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out) { int i; for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) @@ -509,7 +509,7 @@ int parsec_helper_get_dep_index(parsec_task_class_t *tc, parsec_dep_t *dep, int return -1; } -int parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out) +int parsec_helper_get_flow_index_that_contains_dep(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out) { int i; for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) @@ -530,3 +530,24 @@ int parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, pars assert(0); return -1; } + +int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flow_t *flow, int in_out) +{ + int i; + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) + { + parsec_flow_t *_flow = (in_out ? tc->out[i] : tc->in[i]); + + if (!flow) + { + break; + } + + if (flow == _flow) + { + return i; + } + } + + return -1; +} diff --git a/parsec/task_class.h b/parsec/task_class.h index e80893e34..e23da975d 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -23,8 +23,9 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *flow_from); parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_from); -int parsec_helper_dep_is_in_flow(parsec_flow_t *flow, parsec_dep_t *dep); -int parsec_helper_get_dep_index(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out); -int parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out); +int parsec_helper_dep_is_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep); +int parsec_helper_get_dep_index(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out); +int parsec_helper_get_flow_index_that_contains_dep(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out); +int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flow_t *flow, int in_out); #endif /* PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED */ From 833cdf9f81c79e07165e0a07c61da37f9dd58130 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 8 Nov 2022 17:10:38 -0500 Subject: [PATCH 092/157] add all the necessary spec_X for parametrized flows --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 4a535b264..f91ae21bd 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1744,7 +1744,6 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) if( FLOW_IS_PARAMETRIZED(df) ) { coutput(" int in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); coutput(" int out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); - coutput(" int out_dep_offset_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); coutput(" int data_dynamic_offset_of_parametrized_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } } @@ -4984,7 +4983,6 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - string_arena_add_string(sa, " , .out_dep_offset_of_parametrized_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); // store the offset for every output dep of this parametrized flow string_arena_add_string(sa, " , .in_flow_offset_of_parametrized_%s = -1\n", JDF_OBJECT_ONAME(df)); string_arena_add_string(sa, " , .out_flow_offset_of_parametrized_%s = -1\n", JDF_OBJECT_ONAME(df)); @@ -5942,10 +5940,8 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" spec_%s.in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 0);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); - coutput(" spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s = -1;\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); - coutput(" spec_%s.out_dep_offset_of_parametrized_flow_of_%s_%s_for_%s = -1;\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput(" spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 1);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); coutput("\n"); coutput(" spec_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s = current_data_offset_for_%s_%s;\n", @@ -5962,8 +5958,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" assert(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); - coutput(" assert(spec_%s.out_dep_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" assert(spec_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s >= 0);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); From 1cb8634efecefb022190fca6d57794de27fdffe0 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 8 Nov 2022 23:06:32 -0500 Subject: [PATCH 093/157] add a check to ensure the dependencies in the jdf are correct --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 75 ++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index f91ae21bd..d7e73f944 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6815,6 +6815,81 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); + if(FLOW_IS_PARAMETRIZED(flow)) { + // Check that the jdf dependencies are correct + coutput("\n#if defined(PARSEC_DEBUG_PARANOID)\n"); + for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { + coutput("#define %s %s%s\n", vl->name, targetf->fname, vl->name); + } + + + // Search in targetf all the dependencies (referrers) that point to me (parametrized flow) + for(jdf_dataflow_t *target_flow = targetf->dataflow; target_flow != NULL; target_flow = target_flow->next) { + int dep_index = 0; + for(jdf_dep_t *target_dep = target_flow->deps; NULL != target_dep; target_dep = target_dep->next, ++dep_index) { + jdf_guarded_call_t *guard = target_dep->guard; + switch(guard->guard_type) { + case JDF_GUARD_TERNARY: + call = guard->callfalse; + if(call->parametrized_offset && 0 == strcmp(call->var, flow->varname) && 0 == strcmp(call->func_or_mem, f->fname)) { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "expr info of referrer"; + + //jdf_expr_t *from = variable->jdf_ta1; + //jdf_expr_t *to = df->local_variables->jdf_ta2; + //jdf_expr_t *step = variable->jdf_ta3; + + //coutput(" const int nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s = (%s)+1;\n", + // jdf_basename, f->fname, df->varname, dump_expr((void**)to, &expr_info)); + + coutput( + "%s // callfalse dependency %d of flow %s of function %s\n" + "%s if(%s != %s) {\n" + "%s parsec_fatal(\"!!!\");\n" + "%s }\n", + spaces, dep_index, target_flow->varname, targetf->fname, + spaces, dump_expr((void**)call->parametrized_offset, &info), + get_parametrized_flow_iterator_name(flow), + spaces, + spaces); + } + case JDF_GUARD_BINARY: + case JDF_GUARD_UNCONDITIONAL: + call = guard->calltrue; + if(call->parametrized_offset && 0 == strcmp(call->var, flow->varname) && 0 == strcmp(call->func_or_mem, f->fname)) { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "expr info of referrer"; + + coutput( + "%s // calltrue dependency %d of flow %s of function %s\n" + "%s if(%s != %s) {\n" + "%s parsec_fatal(\"!!!\");\n" + "%s }\n", + spaces, dep_index, target_flow->varname, targetf->fname, + spaces, dump_expr((void**)call->parametrized_offset, &info), + get_parametrized_flow_iterator_name(flow), + spaces, + spaces); + } + break; + default: + assert(0); + } + } + } + + for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { + coutput("#undef %s\n", vl->name); + } + coutput("#endif // PARSEC_DEBUG_PARANOID\n\n"); + } + /* Code to fulfill a reshape promise set up by predecessor if there's one */ jdf_generate_code_consume_predecessor_setup(jdf, call, f, flow, From aab671f55219c569275e62990b357577ea589404 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 8 Nov 2022 23:56:07 -0500 Subject: [PATCH 094/157] move the jdf checks in jdf_generate_code_data_lookup + remove various warnings --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 282 +++++++++--------- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 6 +- 2 files changed, 150 insertions(+), 138 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index d7e73f944..c51a58bfa 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -931,7 +931,7 @@ static char *dump_data_initialization_from_data_array(void **elem, void *arg) string_arena_add_string(sa, "%s _f_%s%s = this_task->data.%s.data_%s;\n", INDENTATION_IF_PARAMETRIZED(f), varname, DUMP_ARRAY_OFFSET_IF_PARAMETRIZED(osa, f), - DUMP_DATA_FIELD_NAME_IN_TASK(osa2, f, f->varname), where); + DUMP_DATA_FIELD_NAME_IN_TASK(osa2, f), where); string_arena_add_string(sa, "%s %s%s = PARSEC_DATA_COPY_GET_PTR(_f_%s%s);\n", @@ -967,7 +967,7 @@ static char *dump_data_copy_init_for_inline_function(void **elem, void *arg) string_arena_add_string(sa, "%s parsec_data_copy_t *_f_%s = this_task->data.%s.data_%s;\n" "%s (void)_f_%s;", - INDENTATION_IF_PARAMETRIZED(f), DUMP_DATA_FIELD_NAME_IN_TASK(osa, f, f->varname), where, + INDENTATION_IF_PARAMETRIZED(f), DUMP_DATA_FIELD_NAME_IN_TASK(osa, f), where, INDENTATION_IF_PARAMETRIZED(f), varname ); @@ -3637,11 +3637,11 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr "%s new_task->data.%s.data_in = NULL;\n" "%s new_task->data.%s.data_out = NULL;\n" "%s new_task->data.%s.fulfill = 0;\n", - indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow, dataflow->varname), - indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow, dataflow->varname), - indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow, dataflow->varname), - indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow, dataflow->varname), - indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow, dataflow->varname)); + indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow), + indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow), + indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow), + indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow), + indent(nesting), DUMP_DATA_FIELD_NAME_IN_TASK(osa, dataflow)); string_arena_init(sa); dump_parametrized_flow_loop_end_if_parametrized(dataflow, indent(nesting), sa); @@ -3717,7 +3717,7 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr "}\n\n"); } -jdf_generate_task_constructor(jdf_t *jdf, jdf_function_entry_t *f) +void jdf_generate_task_constructor(jdf_t *jdf, jdf_function_entry_t *f) { /*coutput( "int %s(const parsec_task_t* task)\n" @@ -3812,8 +3812,7 @@ parsec_taskpool_t *LBM_new(...) "{\n" " %s *spec_task = (%s*)(*task);\n", parsec_get_name(NULL, f, "constructor"), - parsec_get_name(jdf, f, "task_t"), parsec_get_name(jdf, f, "task_t"), - jdf_basename, jdf_basename); + parsec_get_name(jdf, f, "task_t"), parsec_get_name(jdf, f, "task_t")); int non_parametrized_count = 0; for(jdf_dataflow_t *flow = f->dataflow; NULL != flow; flow = flow->next) { @@ -5619,16 +5618,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(64); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "parametrized flow range"; - - //jdf_expr_t *from = variable->jdf_ta1; - jdf_expr_t *to = df->local_variables->jdf_ta2; - //jdf_expr_t *step = variable->jdf_ta3; - coutput(" flow_of_%s_%s_for_parametrized_%s = malloc(sizeof(parsec_flow_t) * nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s);\n", jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); } @@ -6686,9 +6675,9 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * coutput("%s consumed_repo = this_task->data.%s.source_repo;\n" "%s consumed_entry = this_task->data.%s.source_repo_entry;\n" "%s consumed_entry_key = this_task->data.%s.source_repo_entry->ht_item.key;\n", - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow)); /* Is this current task repo or predecessor repo? Different flow index */ coutput("%s if( (reshape_entry != NULL) && (reshape_entry->data[%d] != NULL) ){\n" @@ -6699,8 +6688,8 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * spaces, flow->flow_index); coutput("%s assert( (this_task->data.%s.source_repo == reshape_repo)\n" "%s && (this_task->data.%s.source_repo_entry == reshape_entry));\n", - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow)); coutput("%s }else{\n" "%s /* Reshape promise set up on input by predecessor is the predecesssor task repo */\n" "%s consumed_flow_index = %d;\n" @@ -6806,7 +6795,7 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, coutput("%s if( NULL == (chunk = this_task->data.%s.data_in) ) {\n" "%s /* No data set up by predecessor on this task input flow */\n", - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), spaces); /* Function calls */ @@ -6815,81 +6804,6 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); - if(FLOW_IS_PARAMETRIZED(flow)) { - // Check that the jdf dependencies are correct - coutput("\n#if defined(PARSEC_DEBUG_PARANOID)\n"); - for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { - coutput("#define %s %s%s\n", vl->name, targetf->fname, vl->name); - } - - - // Search in targetf all the dependencies (referrers) that point to me (parametrized flow) - for(jdf_dataflow_t *target_flow = targetf->dataflow; target_flow != NULL; target_flow = target_flow->next) { - int dep_index = 0; - for(jdf_dep_t *target_dep = target_flow->deps; NULL != target_dep; target_dep = target_dep->next, ++dep_index) { - jdf_guarded_call_t *guard = target_dep->guard; - switch(guard->guard_type) { - case JDF_GUARD_TERNARY: - call = guard->callfalse; - if(call->parametrized_offset && 0 == strcmp(call->var, flow->varname) && 0 == strcmp(call->func_or_mem, f->fname)) { - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(64); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "expr info of referrer"; - - //jdf_expr_t *from = variable->jdf_ta1; - //jdf_expr_t *to = df->local_variables->jdf_ta2; - //jdf_expr_t *step = variable->jdf_ta3; - - //coutput(" const int nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s = (%s)+1;\n", - // jdf_basename, f->fname, df->varname, dump_expr((void**)to, &expr_info)); - - coutput( - "%s // callfalse dependency %d of flow %s of function %s\n" - "%s if(%s != %s) {\n" - "%s parsec_fatal(\"!!!\");\n" - "%s }\n", - spaces, dep_index, target_flow->varname, targetf->fname, - spaces, dump_expr((void**)call->parametrized_offset, &info), - get_parametrized_flow_iterator_name(flow), - spaces, - spaces); - } - case JDF_GUARD_BINARY: - case JDF_GUARD_UNCONDITIONAL: - call = guard->calltrue; - if(call->parametrized_offset && 0 == strcmp(call->var, flow->varname) && 0 == strcmp(call->func_or_mem, f->fname)) { - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(64); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "expr info of referrer"; - - coutput( - "%s // calltrue dependency %d of flow %s of function %s\n" - "%s if(%s != %s) {\n" - "%s parsec_fatal(\"!!!\");\n" - "%s }\n", - spaces, dep_index, target_flow->varname, targetf->fname, - spaces, dump_expr((void**)call->parametrized_offset, &info), - get_parametrized_flow_iterator_name(flow), - spaces, - spaces); - } - break; - default: - assert(0); - } - } - } - - for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { - coutput("#undef %s\n", vl->name); - } - coutput("#endif // PARSEC_DEBUG_PARANOID\n\n"); - } - /* Code to fulfill a reshape promise set up by predecessor if there's one */ jdf_generate_code_consume_predecessor_setup(jdf, call, f, flow, @@ -6903,7 +6817,7 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, coutput("%s ACQUIRE_FLOW(this_task, \"%s\", &%s_%s, \"%s\", target_locals, chunk);\n" "%s this_task->data.%s.data_out = chunk;\n", spaces, flow->varname, jdf_basename, call->func_or_mem, call->var, - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow)); if(FLOW_IS_PARAMETRIZED(flow)) { coutput("%s parsec_debug_verbose(1, parsec_debug_output, \"%s = %%d\", %s);\n", spaces, get_parametrized_flow_iterator_name(flow), get_parametrized_flow_iterator_name(flow)); @@ -6930,7 +6844,7 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, coutput("%s this_task->data.%s.data_out = chunk;\n" "%s PARSEC_OBJ_RETAIN(chunk);\n", - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), spaces); } @@ -6960,7 +6874,7 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, "%s this_task->data.%s.data_out = chunk;\n", spaces, string_arena_get_string(sa), string_arena_get_string(sa2), string_arena_get_string(sa), spaces, - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow)); string_arena_free(info.sa); } @@ -6991,7 +6905,7 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, "%s parsec_prof_grapher_data_input(chunk->original, (parsec_task_t*)this_task, &%s, 0);\n" "#endif\n" "%s }\n", - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), spaces, JDF_OBJECT_ONAME( flow ), spaces); } @@ -7071,7 +6985,7 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ coutput("%s if( NULL == (chunk = this_task->data.%s.data_in) ) {\n" "%s /* No data set up by predecessor */\n", - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), spaces); // string_arena_init(sa_loop); @@ -7084,7 +6998,7 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ spaces); coutput("%s this_task->data.%s.data_out = chunk;\n" "%s }\n", - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), spaces); #if defined(PARSEC_DEBUG_NOISIER) || defined(PARSEC_DEBUG_PARANOID) @@ -7129,10 +7043,10 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, "%s this_task->data.%s.source_repo = NULL;\n" "%s this_task->data.%s.source_repo_entry = NULL;\n", flow->varname, - INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow, flow->varname), - INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow, flow->varname), - INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow, flow->varname), - INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow, flow->varname)); + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow)); string_arena_init(sa); dump_parametrized_flow_loop_end_if_parametrized(flow, " ", sa); @@ -7148,7 +7062,7 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, coutput("%s", string_arena_get_string(osa)); coutput("\n" - "%sif(! this_task->data.%s.fulfill ){ /* Flow %s */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), flow->varname); + "%sif(! this_task->data.%s.fulfill ){ /* Flow %s */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), flow->varname); coutput("%s consumed_repo = NULL;\n" "%s consumed_entry_key = 0;\n" @@ -7162,9 +7076,9 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, } } if( !has_output_deps ) { - coutput("\n%s this_task->data.%s.data_out = NULL; /* input only */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + coutput("\n%s this_task->data.%s.data_out = NULL; /* input only */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow)); } else { - coutput("\n%s this_task->data.%s.data_out = NULL; /* By default, if nothing matches */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + coutput("\n%s this_task->data.%s.data_out = NULL; /* By default, if nothing matches */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow)); } sa = string_arena_new(64); @@ -7254,9 +7168,9 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, coutput("%s this_task->data.%s.data_in = chunk;\n" "%s this_task->data.%s.source_repo = consumed_repo;\n" "%s this_task->data.%s.source_repo_entry = consumed_entry;\n", - INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), - INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), - INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname)); + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow)); if( !(f->flags & JDF_FUNCTION_FLAG_NO_SUCCESSORS) ) { /* If we have consume from our repo, we clean up the repo entry for that flow, * so we don't have old stuff during release_deps_of when we will set up outputs @@ -7268,14 +7182,14 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, "%s */\n" "%s this_task->repo_entry->data[%d] = NULL;\n" "%s }\n", - INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), flow->flow_index, INDENTATION_IF_PARAMETRIZED(flow)); } coutput("%s this_task->data.%s.fulfill = 1;\n" "}\n\n", - INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname));/* coutput("if(! this_task->data._f_%s.fulfill ){\n", flow->varname);*/ + INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow));/* coutput("if(! this_task->data._f_%s.fulfill ){\n", flow->varname);*/ string_arena_init(osa); @@ -7421,10 +7335,10 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, "%s this_task->data.%s.data_out, &data);\n" "%s }\n", spaces, call->func_or_mem, string_arena_get_string(sa), - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), spaces, spaces, - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), spaces, string_arena_get_string(sa_arena), spaces, string_arena_get_string(sa_type_src), spaces, string_arena_get_string(sa_count_src), @@ -7437,7 +7351,7 @@ static void jdf_generate_code_call_final_write(const jdf_t *jdf, spaces, spaces, spaces, call->func_or_mem, string_arena_get_string(sa), - spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow, flow->varname), + spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), spaces); coutput("#if defined(PARSEC_PROF_GRAPHER) && defined(PARSEC_PROF_TRACE)\n" @@ -7886,6 +7800,8 @@ jdf_generate_code_data_lookup(const jdf_t *jdf, assignment_info_t ai; jdf_dataflow_t *fl; + char spaces[] = ""; + sa = string_arena_new(64); sa2 = string_arena_new(64); @@ -7917,6 +7833,102 @@ jdf_generate_code_data_lookup(const jdf_t *jdf, UTIL_DUMP_LIST(sa, f->dataflow, next, dump_data_declaration, sa2, "", "", "", ""); + + + // Check that the jdf dependencies are correct + for( jdf_dataflow_t* flow = f->dataflow; flow != NULL; flow = flow->next ) { + if(!FLOW_IS_PARAMETRIZED(flow)) { + continue; + } + + coutput(" /* check the dependencies for %s */\n", flow->varname); + coutput("#if defined(PARSEC_DEBUG_PARANOID)\n"); + + + // Search in targetf all the dependencies (referrers) that point to me (parametrized flow) + for(jdf_function_entry_t *targetf = jdf->functions; targetf != NULL; targetf = targetf->next) { + for(jdf_dataflow_t *target_flow = targetf->dataflow; target_flow != NULL; target_flow = target_flow->next) { + int dep_index = 0; + for(jdf_dep_t *target_dep = target_flow->deps; NULL != target_dep; target_dep = target_dep->next, ++dep_index) { + jdf_guarded_call_t *guard = target_dep->guard; + jdf_call_t *call; + switch(guard->guard_type) { + case JDF_GUARD_TERNARY: + call = guard->callfalse; + if(call->parametrized_offset && 0 == strcmp(call->var, flow->varname) && 0 == strcmp(call->func_or_mem, f->fname)) { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "expr info of referrer"; + + for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { + coutput("#define %s %s%s\n", vl->name, targetf->fname, vl->name); + } + + coutput("%s *target_locals = (%s*)&generic_locals;\n", + parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); + coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); + + coutput( + "%s // callfalse dependency %d of flow %s of function %s\n" + "%s if(%s != %s) {\n" + "%s parsec_fatal(\"!!!\");\n" + "%s }\n", + spaces, dep_index, target_flow->varname, targetf->fname, + spaces, dump_expr((void**)call->parametrized_offset, &expr_info), + get_parametrized_flow_iterator_name(flow), + spaces, + spaces); + + for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { + coutput("#undef %s\n", vl->name); + } + } + case JDF_GUARD_BINARY: + case JDF_GUARD_UNCONDITIONAL: + call = guard->calltrue; + if(call->parametrized_offset && 0 == strcmp(call->var, flow->varname) && 0 == strcmp(call->func_or_mem, f->fname)) { + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "expr info of referrer"; + + for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { + coutput("#define %s %s%s\n", vl->name, targetf->fname, vl->name); + } + + coutput("%s *target_locals = (%s*)&generic_locals;\n", + parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); + coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); + + coutput( + "%s // calltrue dependency %d of flow %s of function %s\n" + "%s if(%s != %s) {\n" + "%s parsec_fatal(\"!!!\");\n" + "%s }\n", + spaces, dep_index, target_flow->varname, targetf->fname, + spaces, dump_expr((void**)call->parametrized_offset, &expr_info), + get_parametrized_flow_iterator_name(flow), + spaces, + spaces); + + for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { + coutput("#undef %s\n", vl->name); + } + } + break; + default: + assert(0); + } + } + } + } + coutput("#endif // PARSEC_DEBUG_PARANOID\n\n"); + } + + /* We need to set up +1 as usage limit because we are creating it during datalookup *ONLY* when it hasn't been * advanced by the predecessor. @@ -8103,7 +8115,7 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, coutput(" data_repo_entry_t *e%s = this_task->data.%s.source_repo_entry;\n" " if( (NULL != e%s) && (e%s->sim_exec_date > this_task->sim_exec_date) )\n" " this_task->sim_exec_date = e%s->sim_exec_date;\n", - fl->varname, DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), + fl->varname, DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl), fl->varname, fl->varname, fl->varname); } @@ -8265,7 +8277,7 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, string_arena_init(sa_di); if( parametrized_flow_has_been_encountered ) { // We use the current_flow_id variable because we cannot compute di at compile time - string_arena_add_string(sa_di, "current_flow_id", di); + string_arena_add_string(sa_di, "current_flow_id"); } else { string_arena_add_string(sa_di, "%d", di); } @@ -8513,7 +8525,7 @@ static void jdf_generate_code_hook(const jdf_t *jdf, coutput("%s data_repo_entry_t *e%s = this_task->data.%s.source_repo_entry;\n" "%s if( (NULL != e%s) && (e%s->sim_exec_date > this_task->sim_exec_date) )\n" "%s this_task->sim_exec_date = e%s->sim_exec_date;\n", - INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), + INDENTATION_IF_PARAMETRIZED(fl), fl->varname, DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl), INDENTATION_IF_PARAMETRIZED(fl), fl->varname, fl->varname, INDENTATION_IF_PARAMETRIZED(fl), fl->varname); @@ -8643,11 +8655,11 @@ jdf_generate_code_complete_hook(const jdf_t *jdf, "%s parsec_task_snprintf(tmp, 128, (parsec_task_t*)(this_task)),\n" "%s this_task->data.%s.data_out, this_task->data.%s.data_out->version, __FILE__, __LINE__);\n" "%s }\n", - INDENTATION_IF_PARAMETRIZED(fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), + INDENTATION_IF_PARAMETRIZED(fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl), INDENTATION_IF_PARAMETRIZED(fl), - INDENTATION_IF_PARAMETRIZED(fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), fl->varname, + INDENTATION_IF_PARAMETRIZED(fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl), fl->varname, INDENTATION_IF_PARAMETRIZED(fl), INDENTATION_IF_PARAMETRIZED(fl), INDENTATION_IF_PARAMETRIZED(fl), INDENTATION_IF_PARAMETRIZED(fl), - DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname), + DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl), INDENTATION_IF_PARAMETRIZED(fl)); string_arena_init(osa); @@ -8711,8 +8723,8 @@ static void jdf_generate_code_free_hash_table_entry(const jdf_t *jdf, const jdf_ coutput("%s if( NULL != this_task->data.%s.source_repo_entry ) {\n" "%s data_repo_entry_used_once( this_task->data.%s.source_repo, this_task->data.%s.source_repo_entry->ht_item.key );\n" "%s }\n", - INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname), - INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname), + INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df), + INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df), INDENTATION_IF_PARAMETRIZED(df)); string_arena_free(osa); @@ -8735,8 +8747,8 @@ static void jdf_generate_code_free_hash_table_entry(const jdf_t *jdf, const jdf_ coutput("%s if( NULL != this_task->data.%s.data_in ) {\n" "%s PARSEC_DATA_COPY_RELEASE(this_task->data.%s.data_in);\n" "%s }\n", - INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname), - INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df, df->varname), + INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df), + INDENTATION_IF_PARAMETRIZED(df), DUMP_DATA_FIELD_NAME_IN_TASK(osa, df), INDENTATION_IF_PARAMETRIZED(df)); string_arena_free(osa); @@ -9214,7 +9226,7 @@ static void jdf_check_relatives( jdf_function_entry_t *f, jdf_dep_flags_t flow_t string_arena_init((SA_DATATYPE)); \ } -char *dump_flow_offset_for_iterate_successors(string_arena_t *sa, jdf_function_entry_t *f, jdf_call_t *call) +char *dump_flow_offset_for_iterate_successors(string_arena_t *sa, const jdf_function_entry_t *f, const jdf_call_t *call) { string_arena_init(sa); @@ -9225,7 +9237,7 @@ char *dump_flow_offset_for_iterate_successors(string_arena_t *sa, jdf_function_e return string_arena_get_string(sa); } -char *dump_dep_offset_for_iterate_successors(string_arena_t *sa, jdf_function_entry_t *f, jdf_call_t *call) +char *dump_dep_offset_for_iterate_successors(string_arena_t *sa, const jdf_function_entry_t *f, const jdf_call_t *call) { string_arena_init(sa); @@ -9359,7 +9371,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_add_string(sa_coutput, "%s data.data = this_task->data.%s.data_out;\n", - INDENTATION_IF_PARAMETRIZED(fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl, fl->varname)); + INDENTATION_IF_PARAMETRIZED(fl), DUMP_DATA_FIELD_NAME_IN_TASK(osa, fl)); for(dl = fl->deps; dl != NULL; dl = dl->next) { if( !(dl->dep_flags & flow_type) ) continue; diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index dae4fca0c..dd34e277a 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -75,10 +75,10 @@ util_dump_array_offset_if_parametrized(string_arena_t *sa, const jdf_dataflow_t * @brief Dumps the proper access to the data, wether the flow is parametrized or not * */ -#define DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow, basename)\ - util_dump_data_field_name_in_task(sa, flow, basename) +#define DUMP_DATA_FIELD_NAME_IN_TASK(sa, flow)\ + util_dump_data_field_name_in_task(sa, flow) -static inline char *util_dump_data_field_name_in_task(string_arena_t *sa, const jdf_dataflow_t *flow, const char *basename) +static inline char *util_dump_data_field_name_in_task(string_arena_t *sa, const jdf_dataflow_t *flow) { string_arena_init(sa); From 53767660cd399e7ebaeff9bb167396c08bf6d5bd Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 9 Nov 2022 16:11:20 -0500 Subject: [PATCH 095/157] proper parsec_fatal if the dependency of a parametrized flow is incoherent --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 274 +++++++++++++++------ 1 file changed, 195 insertions(+), 79 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index c51a58bfa..20296b957 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7791,6 +7791,176 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, string_arena_free(sa_temp); } +static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, jdf_function_entry_t *sourcef, jdf_dataflow_t *source_flow, int dep_index, jdf_call_t *source_call, + jdf_function_entry_t *targetf, jdf_dataflow_t *target_flow, jdf_call_t *target_call, int is_calltrue) +{ + string_arena_t *sa = string_arena_new(64); + + char spaces[] = ""; + + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = "expr info of referrer"; + + coutput("%s // call%s of dep %d of flow %s of task class %s\n", spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname); + coutput("%s {\n", spaces); + + string_arena_init(sa); + coutput("%s %s *target_locals = (%s*)&generic_locals;\n", + spaces, parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); + //coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); + for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { + // Get the function parameter if it is one + const jdf_expr_t *el; + jdf_expr_t *params = source_call->parameters; + jdf_param_list_t *pl; + for(el = params, pl = targetf->parameters; pl != NULL; el = el->next, pl = pl->next) { + if( NULL == el ) { /* Badly formulated call */ + string_arena_t *sa_caller, *sa_callee; + expr_info_t caller = EMPTY_EXPR_INFO; + + sa_caller = string_arena_new(64); + sa_callee = string_arena_new(64); + + caller.sa = sa; + caller.prefix = ""; + caller.suffix = ""; + caller.assignments = ""; + + string_arena_init(sa); + UTIL_DUMP_LIST_FIELD(sa_callee, targetf->parameters, next, name, + dump_string, sa, + "(", "", ", ", ")"); + string_arena_init(sa); + UTIL_DUMP_LIST(sa_caller, params, next, + dump_expr, (void*)&caller, + "(", "", ", ", ")"); + fprintf(stderr, "%s.jdf:%d Badly formulated call %s%s instead of %s%s\n", + jdf_basename, source_call->super.lineno, + targetf->fname, string_arena_get_string(sa_caller), + targetf->fname, string_arena_get_string(sa_callee)); + exit(-1); + } + assert( el != NULL ); + if(!strcmp(pl->name, vl->name)) + break; + } + + expr_info_t infodst; + infodst.sa = sa; + infodst.prefix = targetf->fname; + infodst.suffix = ""; + infodst.assignments = "target_locals"; + expr_info_t infosrc; + infosrc.sa = sa; + infosrc.prefix = ""; + infosrc.suffix = ""; + infosrc.assignments = "&this_task->locals"; + + if( NULL == pl ) { + /* It is a value. Let's dump it's expression in the destination context */ + string_arena_init(sa); + coutput(" %sconst int %s%s = %s; (void)%s%s;\n", + (spaces), targetf->fname, vl->name, dump_expr((void**)vl->expr, &infodst), targetf->fname, vl->name); + } else { + /* It is a parameter. Let's dump it's expression in the source context */ + assert(el != NULL); + string_arena_init(sa); + coutput(" %sconst int %s%s = %s; (void)%s%s;\n", + (spaces), targetf->fname, vl->name, dump_expr((void**)el, &infosrc), targetf->fname, vl->name); + } + } + + for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { + coutput("#define %s %s%s\n", vl->name, targetf->fname, vl->name); + } + + coutput( + "%s // call%s dependency %d of flow %s of function %s\n" + "%s if(%s != %s) {\n" + "%s parsec_fatal(\"A dependency between a parametrized flow and its referrer is incoherent.\"\n" + "%s \"If %s = %%d, yet %s != %%d\"\n" + "%s \"The parametrized flow is %s of task class %s.\"\n" + "%s \"The referrer is call%s of dep %d of flow %s of task class %s.\",\n" + "%s %s, %s);\n" + "%s }\n", + spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname, + spaces, dump_expr((void**)target_call->parametrized_offset, &expr_info), get_parametrized_flow_iterator_name(source_flow), + spaces, + spaces, get_parametrized_flow_iterator_name(source_flow), dump_expr((void**)target_call->parametrized_offset, &expr_info), + spaces, source_flow->varname, sourcef->fname, + spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname, + spaces, get_parametrized_flow_iterator_name(source_flow), get_parametrized_flow_iterator_name(source_flow), + spaces); + + + for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { + coutput("#undef %s\n", vl->name); + } + + coutput("%s }\n", spaces); +} + +static void jdf_generate_check_parametrized_link(const jdf_t *jdf, jdf_function_entry_t *sourcef, jdf_dataflow_t *source_flow, jdf_call_t *source_call) +{ + for(jdf_function_entry_t *targetf = jdf->functions; targetf != NULL; targetf = targetf->next) { + if(strcmp(targetf->fname, source_call->func_or_mem) != 0) + continue; + for(jdf_dataflow_t *target_flow = targetf->dataflow; target_flow != NULL; target_flow = target_flow->next) { + if(strcmp(target_flow->varname, source_call->var) != 0) + continue; + + int dep_index = 0; + for(jdf_dep_t *target_dep = target_flow->deps; NULL != target_dep; target_dep = target_dep->next, ++dep_index) { + jdf_guarded_call_t *guard = target_dep->guard; + jdf_call_t *target_call; + switch(guard->guard_type) { + case JDF_GUARD_TERNARY: + target_call = guard->callfalse; + if(target_call->parametrized_offset && 0 == strcmp(target_call->var, source_flow->varname) && 0 == strcmp(target_call->func_or_mem, sourcef->fname)) { + jdf_generate_check_for_one_call_to_call_link(jdf, sourcef, source_flow, dep_index, source_call, targetf, target_flow, target_call, 0); + } + case JDF_GUARD_BINARY: + case JDF_GUARD_UNCONDITIONAL: + target_call = guard->calltrue; + if(target_call->parametrized_offset && 0 == strcmp(target_call->var, source_flow->varname) && 0 == strcmp(target_call->func_or_mem, sourcef->fname)) { + jdf_generate_check_for_one_call_to_call_link(jdf, sourcef, source_flow, dep_index, source_call, targetf, target_flow, target_call, 1); + } + break; + default: + assert(0); + } + } + } + } + /*jdf_function_entry_t *targetf = find_target_function(jdf, target_call->func_or_mem); + for(jdf_dataflow_t *target_flow = targetf->dataflow; target_flow != NULL; target_flow = target_flow->next) { + int dep_index = 0; + for(jdf_dep_t *target_dep = target_flow->deps; NULL != target_dep; target_dep = target_dep->next, ++dep_index) { + jdf_guarded_call_t *guard = target_dep->guard; + jdf_call_t *target_call; + switch(guard->guard_type) { + case JDF_GUARD_TERNARY: + target_call = guard->callfalse; + if(target_call->parametrized_offset && 0 == strcmp(target_call->var, source_flow->varname) && 0 == strcmp(target_call->func_or_mem, sourcef->fname)) { + jdf_generate_check_for_one_call_to_call_link(jdf, sourcef, source_flow, dep_index, source_call, targetf, target_flow, target_call, 0); + } + case JDF_GUARD_BINARY: + case JDF_GUARD_UNCONDITIONAL: + target_call = guard->calltrue; + if(target_call->parametrized_offset && 0 == strcmp(target_call->var, source_flow->varname) && 0 == strcmp(target_call->func_or_mem, sourcef->fname)) { + jdf_generate_check_for_one_call_to_call_link(jdf, sourcef, source_flow, dep_index, source_call, targetf, target_flow, target_call, 1); + } + break; + default: + assert(0); + } + } + }*/ +} + static void jdf_generate_code_data_lookup(const jdf_t *jdf, const jdf_function_entry_t *f, @@ -7800,8 +7970,6 @@ jdf_generate_code_data_lookup(const jdf_t *jdf, assignment_info_t ai; jdf_dataflow_t *fl; - char spaces[] = ""; - sa = string_arena_new(64); sa2 = string_arena_new(64); @@ -7843,88 +8011,36 @@ jdf_generate_code_data_lookup(const jdf_t *jdf, coutput(" /* check the dependencies for %s */\n", flow->varname); coutput("#if defined(PARSEC_DEBUG_PARANOID)\n"); + coutput("// All the referrers to the parametrized flow %s of task class %s:\n", flow->varname, f->fname); + + string_arena_t *sa_loop = string_arena_new(64); + dump_parametrized_flow_loop(flow, get_parametrized_flow_iterator_name(flow), "", sa_loop); + coutput("%s", string_arena_get_string(sa_loop)); // Search in targetf all the dependencies (referrers) that point to me (parametrized flow) - for(jdf_function_entry_t *targetf = jdf->functions; targetf != NULL; targetf = targetf->next) { - for(jdf_dataflow_t *target_flow = targetf->dataflow; target_flow != NULL; target_flow = target_flow->next) { - int dep_index = 0; - for(jdf_dep_t *target_dep = target_flow->deps; NULL != target_dep; target_dep = target_dep->next, ++dep_index) { - jdf_guarded_call_t *guard = target_dep->guard; - jdf_call_t *call; - switch(guard->guard_type) { - case JDF_GUARD_TERNARY: - call = guard->callfalse; - if(call->parametrized_offset && 0 == strcmp(call->var, flow->varname) && 0 == strcmp(call->func_or_mem, f->fname)) { - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(64); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "expr info of referrer"; - - for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { - coutput("#define %s %s%s\n", vl->name, targetf->fname, vl->name); - } - - coutput("%s *target_locals = (%s*)&generic_locals;\n", - parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); - coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); - - coutput( - "%s // callfalse dependency %d of flow %s of function %s\n" - "%s if(%s != %s) {\n" - "%s parsec_fatal(\"!!!\");\n" - "%s }\n", - spaces, dep_index, target_flow->varname, targetf->fname, - spaces, dump_expr((void**)call->parametrized_offset, &expr_info), - get_parametrized_flow_iterator_name(flow), - spaces, - spaces); - - for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { - coutput("#undef %s\n", vl->name); - } - } - case JDF_GUARD_BINARY: - case JDF_GUARD_UNCONDITIONAL: - call = guard->calltrue; - if(call->parametrized_offset && 0 == strcmp(call->var, flow->varname) && 0 == strcmp(call->func_or_mem, f->fname)) { - expr_info_t expr_info = EMPTY_EXPR_INFO; - expr_info.sa = string_arena_new(64); - expr_info.prefix = ""; - expr_info.suffix = ""; - expr_info.assignments = "expr info of referrer"; - - for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { - coutput("#define %s %s%s\n", vl->name, targetf->fname, vl->name); - } - - coutput("%s *target_locals = (%s*)&generic_locals;\n", - parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); - coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); - - coutput( - "%s // calltrue dependency %d of flow %s of function %s\n" - "%s if(%s != %s) {\n" - "%s parsec_fatal(\"!!!\");\n" - "%s }\n", - spaces, dep_index, target_flow->varname, targetf->fname, - spaces, dump_expr((void**)call->parametrized_offset, &expr_info), - get_parametrized_flow_iterator_name(flow), - spaces, - spaces); - - for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { - coutput("#undef %s\n", vl->name); - } - } - break; - default: - assert(0); - } - } + for(jdf_dep_t *dep = flow->deps; NULL != dep; dep = dep->next) { + jdf_guarded_call_t *guard = dep->guard; + jdf_call_t *call; + switch(guard->guard_type) { + case JDF_GUARD_TERNARY: + call = guard->callfalse; + jdf_generate_check_parametrized_link(jdf, f, flow, call); + case JDF_GUARD_BINARY: + case JDF_GUARD_UNCONDITIONAL: + call = guard->calltrue; + jdf_generate_check_parametrized_link(jdf, f, flow, call); + break; + default: + assert(0); } } + + string_arena_init(sa_loop); + dump_parametrized_flow_loop_end(flow, "", sa_loop); + coutput("%s", string_arena_get_string(sa_loop)); + string_arena_free(sa_loop); + coutput("#endif // PARSEC_DEBUG_PARANOID\n\n"); } From c3dd75e793e9b9c110b6ab74624990e1d71a0a03 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 9 Nov 2022 16:47:13 -0500 Subject: [PATCH 096/157] cleanup --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 65 ++++++---------------- 1 file changed, 18 insertions(+), 47 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 20296b957..b0c845f66 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -585,7 +585,8 @@ char * dump_expr(void **elem, void *arg) return string_arena_get_string(sa); } -char *dump_referrer_iterator(const jdf_function_entry_t *f, void *arg, jdf_expr_t *e, const char *name) +// TODO: remove, now handle automatically in the variable stack +char *dump_referrer_iterator(const jdf_function_entry_t *f, void *arg) { string_arena_t *sa = arg; @@ -606,6 +607,7 @@ char *dump_referrer_iterator(const jdf_function_entry_t *f, void *arg, jdf_expr_ string_arena_add_string(sa, " int %s = locals->ldef[%d].value; (void) %s;\n", call->parametrized_offset->alias, call->parametrized_offset->ldef_index, call->parametrized_offset->alias); } + __attribute__ ((fallthrough)); case JDF_GUARD_BINARY: case JDF_GUARD_UNCONDITIONAL: call = guard->calltrue; @@ -967,7 +969,7 @@ static char *dump_data_copy_init_for_inline_function(void **elem, void *arg) string_arena_add_string(sa, "%s parsec_data_copy_t *_f_%s = this_task->data.%s.data_%s;\n" "%s (void)_f_%s;", - INDENTATION_IF_PARAMETRIZED(f), DUMP_DATA_FIELD_NAME_IN_TASK(osa, f), where, + INDENTATION_IF_PARAMETRIZED(f), varname, DUMP_DATA_FIELD_NAME_IN_TASK(osa, f), where, INDENTATION_IF_PARAMETRIZED(f), varname ); @@ -983,7 +985,7 @@ static char *dump_data_copy_init_for_inline_function(void **elem, void *arg) * dump_dataflow_varname: * Takes the pointer to a flow *f, and print the varname */ -static char *dump_dataflow_varname(void **elem, void *_) +char *dump_dataflow_varname(void **elem, void *_) { (void)_; jdf_dataflow_t *f = (jdf_dataflow_t *)elem; @@ -3717,7 +3719,7 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr "}\n\n"); } -void jdf_generate_task_constructor(jdf_t *jdf, jdf_function_entry_t *f) +void jdf_generate_task_constructor(const jdf_t *jdf, jdf_function_entry_t *f) { /*coutput( "int %s(const parsec_task_t* task)\n" @@ -3751,7 +3753,7 @@ void jdf_generate_task_constructor(jdf_t *jdf, jdf_function_entry_t *f) coutput(" memset(spec_task->data.dynamic, 0, sizeof(parsec_data_pair_t) * MAX_LOCAL_COUNT);\n"); string_arena_free(sa); - +*/ /* string_arena_init(sa); dump_parametrized_flow_loop(df, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), " ", sa); @@ -6925,7 +6927,7 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ const char *spaces) { int dataindex; - string_arena_t *sa, *sa_arena, *sa_datatype, *sa_count, *osa, *sa_loop ; + string_arena_t *sa, *sa_arena, *sa_datatype, *sa_count, *osa ; expr_info_t info = EMPTY_EXPR_INFO; if( (NULL != call) && (NULL != call->var) ) { @@ -6960,7 +6962,6 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ sa_arena = string_arena_new(64); sa_datatype = string_arena_new(64); sa_count = string_arena_new(64); - sa_loop = string_arena_new(64); /* This is the case of a pure output data. There's no reshaping. New datacopy should be directly * allocated using the correct arena/datatype. */ @@ -6978,19 +6979,10 @@ static void jdf_generate_code_call_init_output(const jdf_t *jdf, const jdf_call_ coutput("%s /* Flow %s [%d] dependency [%d] pure output data */\n", spaces, flow->varname, flow->flow_index, dl->dep_index); - - // a priori, the loop should already be generated when entering jdf_generate_code_call_init_output - // dump_parametrized_flow_loop_if_parametrized(flow, " ", sa_loop); - // coutput("%s", string_arena_get_string(sa_loop)); - coutput("%s if( NULL == (chunk = this_task->data.%s.data_in) ) {\n" "%s /* No data set up by predecessor */\n", spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), spaces); - - // string_arena_init(sa_loop); - // dump_parametrized_flow_loop_end_if_parametrized(flow, " ", sa_loop); - // coutput("%s", string_arena_get_string(sa_loop)); coutput("%s chunk = parsec_arena_get_copy(%s->arena, %s, target_device, %s);\n" "%s chunk->original->owner_device = target_device;\n", @@ -7791,8 +7783,8 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, string_arena_free(sa_temp); } -static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, jdf_function_entry_t *sourcef, jdf_dataflow_t *source_flow, int dep_index, jdf_call_t *source_call, - jdf_function_entry_t *targetf, jdf_dataflow_t *target_flow, jdf_call_t *target_call, int is_calltrue) +static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const jdf_function_entry_t *sourcef, const jdf_dataflow_t *source_flow, int dep_index, const jdf_call_t *source_call, + const jdf_function_entry_t *targetf, const jdf_dataflow_t *target_flow, const jdf_call_t *target_call, int is_calltrue) { string_arena_t *sa = string_arena_new(64); @@ -7877,13 +7869,14 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, jdf_f coutput("#define %s %s%s\n", vl->name, targetf->fname, vl->name); } + // dump the parsec_fatal if an incoherency is detected coutput( "%s // call%s dependency %d of flow %s of function %s\n" "%s if(%s != %s) {\n" - "%s parsec_fatal(\"A dependency between a parametrized flow and its referrer is incoherent.\"\n" - "%s \"If %s = %%d, yet %s != %%d\"\n" - "%s \"The parametrized flow is %s of task class %s.\"\n" - "%s \"The referrer is call%s of dep %d of flow %s of task class %s.\",\n" + "%s parsec_fatal(\"A dependency between a parametrized flow and its referrer is incoherent.\\n\"\n" + "%s \"If %s = %%d, %s != %%d\\n\"\n" + "%s \"The parametrized flow is %s of task class %s.\\n\"\n" + "%s \"The referrer is call%s of dep %d of flow %s of task class %s.\\n\",\n" "%s %s, %s);\n" "%s }\n", spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname, @@ -7903,7 +7896,7 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, jdf_f coutput("%s }\n", spaces); } -static void jdf_generate_check_parametrized_link(const jdf_t *jdf, jdf_function_entry_t *sourcef, jdf_dataflow_t *source_flow, jdf_call_t *source_call) +static void jdf_generate_check_parametrized_link(const jdf_t *jdf, const jdf_function_entry_t *sourcef, const jdf_dataflow_t *source_flow, const jdf_call_t *source_call) { for(jdf_function_entry_t *targetf = jdf->functions; targetf != NULL; targetf = targetf->next) { if(strcmp(targetf->fname, source_call->func_or_mem) != 0) @@ -7922,6 +7915,7 @@ static void jdf_generate_check_parametrized_link(const jdf_t *jdf, jdf_function_ if(target_call->parametrized_offset && 0 == strcmp(target_call->var, source_flow->varname) && 0 == strcmp(target_call->func_or_mem, sourcef->fname)) { jdf_generate_check_for_one_call_to_call_link(jdf, sourcef, source_flow, dep_index, source_call, targetf, target_flow, target_call, 0); } + __attribute__ ((fallthrough)); case JDF_GUARD_BINARY: case JDF_GUARD_UNCONDITIONAL: target_call = guard->calltrue; @@ -7935,30 +7929,6 @@ static void jdf_generate_check_parametrized_link(const jdf_t *jdf, jdf_function_ } } } - /*jdf_function_entry_t *targetf = find_target_function(jdf, target_call->func_or_mem); - for(jdf_dataflow_t *target_flow = targetf->dataflow; target_flow != NULL; target_flow = target_flow->next) { - int dep_index = 0; - for(jdf_dep_t *target_dep = target_flow->deps; NULL != target_dep; target_dep = target_dep->next, ++dep_index) { - jdf_guarded_call_t *guard = target_dep->guard; - jdf_call_t *target_call; - switch(guard->guard_type) { - case JDF_GUARD_TERNARY: - target_call = guard->callfalse; - if(target_call->parametrized_offset && 0 == strcmp(target_call->var, source_flow->varname) && 0 == strcmp(target_call->func_or_mem, sourcef->fname)) { - jdf_generate_check_for_one_call_to_call_link(jdf, sourcef, source_flow, dep_index, source_call, targetf, target_flow, target_call, 0); - } - case JDF_GUARD_BINARY: - case JDF_GUARD_UNCONDITIONAL: - target_call = guard->calltrue; - if(target_call->parametrized_offset && 0 == strcmp(target_call->var, source_flow->varname) && 0 == strcmp(target_call->func_or_mem, sourcef->fname)) { - jdf_generate_check_for_one_call_to_call_link(jdf, sourcef, source_flow, dep_index, source_call, targetf, target_flow, target_call, 1); - } - break; - default: - assert(0); - } - } - }*/ } static void @@ -8026,6 +7996,7 @@ jdf_generate_code_data_lookup(const jdf_t *jdf, case JDF_GUARD_TERNARY: call = guard->callfalse; jdf_generate_check_parametrized_link(jdf, f, flow, call); + __attribute__ ((fallthrough)); case JDF_GUARD_BINARY: case JDF_GUARD_UNCONDITIONAL: call = guard->calltrue; From e35f7505e0fc50f54eb0a0e709ec2355e27a0c40 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 11 Nov 2022 11:22:47 -0500 Subject: [PATCH 097/157] dont even declare irrelevant specs, finish iterate_predecessors immediately in the case of a parametrized flow, add asserts --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index b0c845f66..ef58eeac8 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1755,6 +1755,11 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { int depid=1; for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } + for( int target_call=0; target_call<2; ++target_call ) { assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) @@ -4997,6 +5002,11 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { int depid=1; for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } + for( int target_call=0; target_call<2; ++target_call ) { assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) @@ -5985,7 +5995,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - assert(!FLOW_IS_PARAMETRIZED(df)); // If the flow is parametrized, + //assert(!FLOW_IS_PARAMETRIZED(df)); // If the flow is parametrized, // Commenting this because a referrer can be parametrized as well?? coutput(" spec_%s.out_dep_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, dep, 1);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, @@ -5997,6 +6007,18 @@ static void jdf_generate_new_function( const jdf_t* jdf ) depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + + coutput("\n"); + coutput(" assert(spec_%s.out_dep_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + coutput(" assert(spec_%s.out_flow_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); coutput(" }\n"); } } @@ -9410,6 +9432,8 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f) && (flow_type & JDF_DEP_FLOW_IN)) { coutput(" parsec_fatal(\"%s is parametrized, parsec does not handle iterate_predecessors of parametrized flows yet\");\n", name); + coutput("}\n"); + return; } #endif /* defined(PARSEC_ALLOW_PARAMETRIZED_FLOWS) */ From 1709826601b94c8e64629dc9801ac9a49a5233c2 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 16 Nov 2022 13:58:14 -0500 Subject: [PATCH 098/157] lower MAX_DEP_IN_COUNT and MAX_DEP_OUT_COUNT to 20 (else crashes), change spec_ names to make them more explicit and avoid errors, make and example work with parametrized+autoreferrer flow --- parsec/include/parsec/parsec_config_bottom.h | 6 +- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 462 +++++++++++++------ parsec/task_class.c | 36 +- parsec/task_class.h | 2 +- 4 files changed, 329 insertions(+), 177 deletions(-) diff --git a/parsec/include/parsec/parsec_config_bottom.h b/parsec/include/parsec/parsec_config_bottom.h index 0e73930e9..50fc6fb23 100644 --- a/parsec/include/parsec/parsec_config_bottom.h +++ b/parsec/include/parsec/parsec_config_bottom.h @@ -157,13 +157,13 @@ typedef int32_t parsec_dependency_t; * runtime. */ -#define MAX_DATAFLOWS_PER_TASK 16 +#define MAX_DATAFLOWS_PER_TASK 64 #define MAX_LOCAL_COUNT 20 #define MAX_PARAM_COUNT 20 -#define MAX_DEP_IN_COUNT 24 -#define MAX_DEP_OUT_COUNT 24 +#define MAX_DEP_IN_COUNT 20 +#define MAX_DEP_OUT_COUNT 20 #define MAX_TASK_STRLEN 128 diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index ef58eeac8..15222f565 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1773,15 +1773,15 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) { // Then the dep refers to a parametrized flow - coutput(" int out_dep_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", - jdf_basename, f->fname, df->varname, + coutput(" int out_dep_offset_of_referrer%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); // We also keep track of the flow that id that contains the referrer - coutput(" int out_flow_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", - jdf_basename, f->fname, df->varname, + coutput(" int out_flow_offset_of_referrer%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); @@ -1789,6 +1789,44 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) } } } + + // Then the dep offsets to every non-parametrized flow + coutput(" // Dep offsets of non-referrers of %s\n", f->fname); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + int depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } + + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + // If the target is NOT parametrized + if( NULL == call->parametrized_offset ) + { + coutput(" int out_dep_offset_of%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + /*coutput(" int out_flow_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "");*/ + } + } + } + } + coutput("} parsec_%s_%s_task_class_t;\n\n", jdf_basename, f->fname); } } @@ -4996,7 +5034,6 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f } } - // Then the referrers string_arena_add_string(sa, " // Local referrers of %s\n", f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { @@ -5018,13 +5055,13 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f if( NULL != call->parametrized_offset ) { - string_arena_add_string(sa, " , .out_dep_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", - jdf_basename, f->fname, df->varname, + string_arena_add_string(sa, " , .out_dep_offset_of_referrer%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", + FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - string_arena_add_string(sa, " , .out_flow_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", - jdf_basename, f->fname, df->varname, + string_arena_add_string(sa, " , .out_flow_offset_of_referrer%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", + FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); @@ -5034,6 +5071,46 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f } + // Then the dep offsets to every non-parametrized flow + string_arena_add_string(sa, " // Dep offsets of non-referrers of %s\n", f->fname); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + int depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } + + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + // If the target is NOT parametrized + if( NULL == call->parametrized_offset ) + { + string_arena_add_string(sa, " , .out_dep_offset_of%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", + FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + /*string_arena_add_string(sa, " , .out_flow_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = -1\n", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "");*/ + } + } + } + } + } + string_arena_add_string(sa, "\n};"); @@ -5816,100 +5893,114 @@ static void jdf_generate_new_function( const jdf_t* jdf ) for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { depid=1; for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { - for( int target_call=0; target_call<2; ++target_call ) { - assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); - if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) - { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY - continue; + for( int dep_in_out=0 ; dep_in_out < 2 ; dep_in_out++ ) { + if( (dep_in_out==0 && !(dep->dep_flags & JDF_DEP_FLOW_IN)) + || ((dep_in_out==1 && !(dep->dep_flags & JDF_DEP_FLOW_OUT))) ) { + // If the dep is not an input, skip dep_in_out=0, and if the dep is not an output, skip dep_in_out=1 + continue; } - jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; - assert(call); - - if( NULL != call->parametrized_offset ) - { - // Then the dep refers to a parametrized flow - - coutput(" {\n"); - coutput(" // %s of %s dep %d of flow %s of task class %s refers to a parametrized flow\n", - target_call?"callfalse":"calltrue", - (dep->dep_flags & JDF_DEP_FLOW_IN)?"input":"output", - dep->dep_index, df->varname, f->fname); - coutput("\n"); - - coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", - jdf_basename, f->fname, df->varname); - coutput(" parsec_dep_t *dep = &%s_dep%d_atline_%d%s;\n", - JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - coutput(" int flow_in_out = %d;\n", (dep->dep_flags & JDF_DEP_FLOW_IN)?0:1); - coutput(" int depid=dep->dep_index;\n"); + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + if( NULL != call->parametrized_offset ) + { + // Then the dep refers to a parametrized flow -// spec_%s_%s.offset_%s%s will be computed after all the shifts have been computed, just to be certain that no future shift will change the value - /* - coutput("\n"); - coutput(" spec_%s_%s.offset_%s%s = parsec_helper_get_dep_index(flow, dep, flow_in_out);\n", - jdf_basename, f->fname, JDF_OBJECT_ONAME(dep), + coutput(" {\n"); + coutput(" // %s of %s dep %d of flow %s of task class %s refers to a parametrized flow\n", + target_call?"callfalse":"calltrue", + dep_in_out?"input":"output", + dep->dep_index, df->varname, f->fname); + coutput("\n"); + + coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", + jdf_basename, f->fname, df->varname); + coutput(" parsec_dep_t *dep = &%s_dep%d_atline_%d%s;\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "");*/ - - coutput("\n"); - - coutput( - " // Shift the deps that are after dep (which references the parametrized flow)\n" - " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n", - jdf_basename, call->func_or_mem, call->var - ); - - coutput(" for( int %s=0;%sparametrized_offset->alias, - call->parametrized_offset->alias, - jdf_basename, call->func_or_mem, call->var, - call->parametrized_offset->alias - ); - - coutput( - " parsec_dep_t *dep_specialization = &%s_referrer_dep%d_atline_%d%s[%s];\n", - JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", - call->parametrized_offset->alias - ); - - coutput(" dep_specialization = parsec_helper_copy_dep(dep_specialization, dep);\n"); - - coutput( - " dep_specialization->flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n", - jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias - ); - coutput( - " dep_specialization->dep_index += %s;\n", - call->parametrized_offset->alias - ); + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + coutput(" int flow_in_out = %d;\n", dep_in_out); + coutput(" int depid=dep->dep_index;\n"); - coutput( - " (flow_in_out?flow->dep_out:flow->dep_in)[depid+%s] = dep_specialization;\n", - call->parametrized_offset->alias - ); - - coutput(" }\n"); - coutput(" }\n"); - // coutput( - // " parsec_dep_t *new_dep = parsec_helper_copy_dep(dep);\n" - // " assert(NULL != new_dep);\n" - // " new_dep->flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n" - // " //new_dep->cond = target_expr_cond; // TODO !\n" - // " // new_dep->ctl_gather_nb = ; // TODO\n" - // " new_dep->dep_index += %s;\n" - // " //new_dep->dep_datatype_index += cd; // TODO maybe modify?\n" - // " //assert(new_dep->direct_data != NULL);\n" - // " // Insert the new dep\n" - // " (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep;\n", - // jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, - // call->parametrized_offset->alias - //); + // spec_%s_%s.offset_%s%s will be computed after all the shifts have been computed, just to be certain that no future shift will change the value + /* + coutput("\n"); + coutput(" spec_%s_%s.offset_%s%s = parsec_helper_get_dep_index(flow, dep, flow_in_out);\n", + jdf_basename, f->fname, JDF_OBJECT_ONAME(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "");*/ + + coutput("\n"); + + coutput( + " // Shift the deps that are after dep (which references the parametrized flow)\n" + " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n", + jdf_basename, call->func_or_mem, call->var + ); + + coutput(" for( int %s=0;%sparametrized_offset->alias, + call->parametrized_offset->alias, + jdf_basename, call->func_or_mem, call->var, + call->parametrized_offset->alias + ); + + coutput( + " parsec_dep_t *dep_specialization = &%s_referrer_dep%d_atline_%d%s[%s];\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + call->parametrized_offset->alias + ); + + coutput(" dep_specialization = parsec_helper_copy_dep(dep_specialization, dep);\n"); + + coutput( + " dep_specialization->flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n", + jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias + ); + coutput( + " dep_specialization->dep_index += %s;\n", + call->parametrized_offset->alias + ); + + coutput( + " (flow_in_out?flow->dep_out:flow->dep_in)[depid+%s] = dep_specialization;\n", + call->parametrized_offset->alias + ); + + + coutput( + " assert(depid+%s < %s);\n", + call->parametrized_offset->alias, + (dep_in_out)?"MAX_DEP_OUT_COUNT":"MAX_DEP_IN_COUNT" + ); + + coutput(" }\n"); + coutput(" }\n"); + + // coutput( + // " parsec_dep_t *new_dep = parsec_helper_copy_dep(dep);\n" + // " assert(NULL != new_dep);\n" + // " new_dep->flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n" + // " //new_dep->cond = target_expr_cond; // TODO !\n" + // " // new_dep->ctl_gather_nb = ; // TODO\n" + // " new_dep->dep_index += %s;\n" + // " //new_dep->dep_datatype_index += cd; // TODO maybe modify?\n" + // " //assert(new_dep->direct_data != NULL);\n" + // " // Insert the new dep\n" + // " (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep;\n", + // jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, + // call->parametrized_offset->alias + //); + } } } } @@ -5949,8 +6040,54 @@ static void jdf_generate_new_function( const jdf_t* jdf ) JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname); coutput(" current_data_offset_for_%s_%s += nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", jdf_basename, f->fname, jdf_basename, f->fname, df->varname); + + + depid=1; + for(jdf_dep_t *dep=df->deps; NULL != dep; dep = dep->next, ++depid) { + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } + + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + /*coutput(" spec_%s.out_flow_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_%s, 1);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + jdf_basename, f->fname, df->varname);*/ + + coutput(" spec_%s.out_dep_offset_of%s%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, &flow_of_%s_%s_for_%s_dep%d_atline_%d%s, 1);\n", + JDF_OBJECT_ONAME(f), + call->parametrized_offset != NULL?"_referrer":"", FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + + /*coutput(" spec_%s.out_dep_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = ;\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "");*/ + } + } + // Now output asserts: + coutput("#if defined(PARSEC_DEBUG_NOISIER)\n"); coutput(" assert(spec_%s.nb_specializations_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); @@ -5962,6 +6099,40 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" assert(spec_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s >= 0);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput("\n"); + + // For each dep of a parametrized flow: + depid=1; + for(jdf_dep_t *dep=df->deps; NULL != dep; dep = dep->next, ++depid) { + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } + + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + /*coutput(" assert(spec_%s.out_flow_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "");*/ + coutput(" assert(spec_%s.out_dep_offset_of%s%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s >= 0);\n", + JDF_OBJECT_ONAME(f), + call->parametrized_offset != NULL?"_referrer":"", FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + } + } + coutput(" }\n"); } } @@ -5997,25 +6168,25 @@ static void jdf_generate_new_function( const jdf_t* jdf ) //assert(!FLOW_IS_PARAMETRIZED(df)); // If the flow is parametrized, // Commenting this because a referrer can be parametrized as well?? - coutput(" spec_%s.out_dep_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, dep, 1);\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + coutput(" spec_%s.out_dep_offset_of_referrer%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, dep, 1);\n", + JDF_OBJECT_ONAME(f), FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - coutput(" spec_%s.out_flow_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_flow_index_that_contains_dep(tc, dep, 1);\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + coutput(" spec_%s.out_flow_offset_of_referrer%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_flow_index_that_contains_dep(tc, dep, 1);\n", + JDF_OBJECT_ONAME(f), FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); coutput("\n"); - coutput(" assert(spec_%s.out_dep_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s >= 0);\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + coutput(" assert(spec_%s.out_dep_offset_of_referrer%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s >= 0);\n", + JDF_OBJECT_ONAME(f), FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - coutput(" assert(spec_%s.out_flow_offset_of_referrer_flow_of_%s_%s_for_%s_dep%d_atline_%d%s >= 0);\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + coutput(" assert(spec_%s.out_flow_offset_of_referrer%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s >= 0);\n", + JDF_OBJECT_ONAME(f), FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", jdf_basename, f->fname, df->varname, depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); @@ -9063,7 +9234,7 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, continue; /* This local define was already issued as part of the dep */ } string_arena_add_string(sa_open, "%s%s int %s;\n", prefix, indent(nbopen), ld->alias); - if(JDF_RANGE == ld->op) { + if(JDF_RANGE == ld->op || JDF_PARAMETRIZED_FLOW_RANGE == ld->op) { string_arena_add_string(sa_open, "%s%sfor( %s = %s;", prefix, indent(nbopen), ld->alias, dump_expr((void**)ld->jdf_ta1, &local_info)); @@ -9153,7 +9324,7 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, prefix, indent(nbopen), prefix, indent(nbopen), ld->alias); nbopen++; - if(JDF_RANGE == ld->op) { + if(JDF_RANGE == ld->op || JDF_PARAMETRIZED_FLOW_RANGE == ld->op) { string_arena_add_string(sa_open, "%s%s for( %s = %s;", prefix, indent(nbopen), ld->alias, dump_expr((void**)ld->jdf_ta1, &local_info)); @@ -9335,24 +9506,35 @@ static void jdf_check_relatives( jdf_function_entry_t *f, jdf_dep_flags_t flow_t string_arena_init((SA_DATATYPE)); \ } -char *dump_flow_offset_for_iterate_successors(string_arena_t *sa, const jdf_function_entry_t *f, const jdf_call_t *call) +char *dump_flow_offset_for_iterate_successors(string_arena_t *sa, const jdf_function_entry_t *f, const jdf_dataflow_t *flow, const jdf_call_t *call) { string_arena_init(sa); - //spec_%s_%s.out_flow_offset_of_%s] - string_arena_add_string(sa, "spec_%s_%s.out_flow_offset_of_referrer_%s", - jdf_basename, f->fname, JDF_OBJECT_ONAME(call)); + // TODO: if flow can be computed at compile time (i.e. no parametrized flow declared before him) + + /*if(FLOW_IS_PARAMETRIZED(flow)) + { + string_arena_add_string(sa, "spec_%s_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s+%s", + jdf_basename, f->fname, jdf_basename, f->fname, flow->varname, + get_parametrized_flow_iterator_name(flow)); + } + else*/ + { + string_arena_add_string(sa, "spec_%s_%s.out_flow_offset_of%s%s_%s", + jdf_basename, f->fname, call->parametrized_offset!=NULL?"_referrer":"", FLOW_IS_PARAMETRIZED(flow)?"_parametrized":"", JDF_OBJECT_ONAME(call)); + } return string_arena_get_string(sa); } -char *dump_dep_offset_for_iterate_successors(string_arena_t *sa, const jdf_function_entry_t *f, const jdf_call_t *call) +char *dump_dep_offset_for_iterate_successors(string_arena_t *sa, const jdf_function_entry_t *f, const jdf_dataflow_t *flow, const jdf_call_t *call) { string_arena_init(sa); - //spec_%s_%s.out_dep_offset_%s+%s - string_arena_add_string(sa, "spec_%s_%s.out_dep_offset_of_referrer_%s+%s", - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + // If the call is a referrer to a parametrized flow: + string_arena_add_string(sa, "spec_%s_%s.out_dep_offset_of%s%s_%s+%s", + jdf_basename, f->fname, call->parametrized_offset != NULL?"_referrer":"", FLOW_IS_PARAMETRIZED(flow)?"_parametrized":"", JDF_OBJECT_ONAME(call), call->parametrized_offset->alias); + return string_arena_get_string(sa); } @@ -9614,7 +9796,9 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_add_string(sa_datatype," }\n"); string_arena_init(sa_ontask); + if(NULL != dl->guard->calltrue->parametrized_offset) + //if(NULL != dl->guard->calltrue->parametrized_offset || FLOW_IS_PARAMETRIZED(fl)) { jdf_call_t *call = dl->guard->calltrue; // if call is parametrized @@ -9624,29 +9808,9 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, "->dep_out[%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" - " return;\n", - dump_flow_offset_for_iterate_successors(sa_flow_offset, f, call), - dump_dep_offset_for_iterate_successors(sa_dep_offset, f, call)); - /*// if flow is parametrized - string_arena_add_string(sa_ontask, - "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s + %s]" - "->dep_out[spec_%s_%s.out_dep_offset_%s]" - ", &data, rank_src, rank_dst, vpid_dst," - " successor_repo, successor_repo_key, ontask_arg) )\n" - " return;\n", - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), smt, - jdf_basename, f->fname, JDF_OBJECT_ONAME(call)); - // if both flow and call are parametrized - string_arena_add_string(sa_ontask, - "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " - "(const parsec_task_t *)this_task, this_task->task_class->out[spec_%s_%s.out_flow_offset_of_%s + %s]" - "->dep_out[spec_%s_%s.out_dep_offset_%s]" - ", &data, rank_src, rank_dst, vpid_dst," - " successor_repo, successor_repo_key, ontask_arg) )\n" - " return;\n", - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), smt, - jdf_basename, f->fname, JDF_OBJECT_ONAME(call), call->parametrized_offset->alias);*/ + " return; // here\n", + dump_flow_offset_for_iterate_successors(sa_flow_offset, f, fl, call), + dump_dep_offset_for_iterate_successors(sa_dep_offset, f, fl, call)); } else { @@ -9663,7 +9827,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, assert(NULL != ld->alias); assert(-1 != ld->ldef_index); string_arena_add_string(sa_coutput, "%s int %s;\n", indent(nb_open_ldef), ld->alias); - if(JDF_RANGE == ld->op) { + if(JDF_RANGE == ld->op || JDF_PARAMETRIZED_FLOW_RANGE == ld->op) { string_arena_add_string(sa_coutput, "%s for( %s = %s;", indent(nb_open_ldef), ld->alias, dump_expr((void**)ld->jdf_ta1, &info)); @@ -9739,18 +9903,20 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, depnb++; string_arena_init(sa_ontask); + if(NULL != dl->guard->callfalse->parametrized_offset) + //if(NULL != dl->guard->callfalse->parametrized_offset || FLOW_IS_PARAMETRIZED(fl)) { jdf_call_t *call = dl->guard->callfalse; string_arena_add_string(sa_ontask, - "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, " + "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " "(const parsec_task_t *)this_task, this_task->task_class->out[%s]" "->dep_out[%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" - " return;\n", - dump_flow_offset_for_iterate_successors(sa_flow_offset, f, call), - dump_dep_offset_for_iterate_successors(sa_dep_offset, f, call)); + " return; // there\n", + dump_flow_offset_for_iterate_successors(sa_flow_offset, f, fl, call), + dump_dep_offset_for_iterate_successors(sa_dep_offset, f, fl, call)); } else { @@ -9776,18 +9942,20 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, } else { depnb++; string_arena_init(sa_ontask); + if(NULL != dl->guard->callfalse->parametrized_offset) + //if(NULL != dl->guard->callfalse->parametrized_offset || FLOW_IS_PARAMETRIZED(fl)) { jdf_call_t *call = dl->guard->callfalse; string_arena_add_string(sa_ontask, - "if( PARSEC_ITERATE_STOP == ontask(es, &nc, (const parsec_task_t *)this_task, " + "if( PARSEC_ITERATE_STOP == ontask(es, &nc, " "(const parsec_task_t *)this_task, this_task->task_class->out[%s]" "->dep_out[%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" - " return;\n", - dump_flow_offset_for_iterate_successors(sa_flow_offset, f, call), - dump_dep_offset_for_iterate_successors(sa_dep_offset, f, call)); + " return; // zhere\n", + dump_flow_offset_for_iterate_successors(sa_flow_offset, f, fl, call), + dump_dep_offset_for_iterate_successors(sa_dep_offset, f, fl, call)); } else { diff --git a/parsec/task_class.c b/parsec/task_class.c index 83180de5a..edbab4623 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -428,10 +428,11 @@ parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *fl break; } - parsec_dep_t *new_dep = (parsec_dep_t *)malloc(sizeof(parsec_dep_t)); + // Not copying the dep should be fine: + /*parsec_dep_t *new_dep = (parsec_dep_t *)malloc(sizeof(parsec_dep_t)); assert(new_dep); memcpy(new_dep, dep, sizeof(parsec_dep_t)); - (flow_in_out ? flow_to->dep_out : flow_to->dep_in)[i] = new_dep; + (flow_in_out ? flow_to->dep_out : flow_to->dep_in)[i] = new_dep;*/ } } @@ -446,35 +447,16 @@ parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_f return dep_to; } -int parsec_helper_dep_is_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep) +int parsec_helper_dep_is_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep, int in_out) { int i; - for (i = 0; i < MAX_DEP_IN_COUNT; i++) + for (i = 0; i < (in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); i++) { - parsec_dep_t *_dep = flow->dep_in[i]; - if(!dep) - { - break; - } - if (dep == _dep) + if (dep == (in_out ? flow->dep_out[i] : flow->dep_in[i])) { return 1; } } - - for (i = 0; i < MAX_DEP_OUT_COUNT; i++) - { - parsec_dep_t *_dep = flow->dep_out[i]; - if(!dep) - { - break; - } - if (dep == _dep) - { - return 1; - } - } - return 0; } @@ -489,7 +471,7 @@ int parsec_helper_get_dep_index(const parsec_task_class_t *tc, const parsec_dep_ break; } - if (parsec_helper_dep_is_in_flow(flow, dep)) + if (parsec_helper_dep_is_in_flow(flow, dep, in_out)) { for(int j = 0; j < (in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) { @@ -506,6 +488,7 @@ int parsec_helper_get_dep_index(const parsec_task_class_t *tc, const parsec_dep_ } } + assert(0); return -1; } @@ -521,7 +504,7 @@ int parsec_helper_get_flow_index_that_contains_dep(const parsec_task_class_t *tc break; } - if (parsec_helper_dep_is_in_flow(flow, dep)) + if (parsec_helper_dep_is_in_flow(flow, dep, in_out)) { return i; } @@ -549,5 +532,6 @@ int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flo } } + assert(0); return -1; } diff --git a/parsec/task_class.h b/parsec/task_class.h index e23da975d..99bbd3ff7 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -23,7 +23,7 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *flow_from); parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_from); -int parsec_helper_dep_is_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep); +int parsec_helper_dep_is_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep, int in_out); int parsec_helper_get_dep_index(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out); int parsec_helper_get_flow_index_that_contains_dep(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out); int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flow_t *flow, int in_out); From 151b4758653c55d1789a59984960f46de845ae18 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 16 Nov 2022 20:41:56 -0500 Subject: [PATCH 099/157] partial implementation of parametrized referrers inside parametrized flows --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 43 ++++++++++++++++++---- parsec/task_class.c | 22 +++++------ 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 15222f565..981a22e52 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5798,13 +5798,13 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput( " parsec_helper_copy_flow(&flow_of_%s_%s_for_parametrized_%s[%s], &flow_of_%s_%s_for_%s);\n" - " flow_of_%s_%s_for_parametrized_%s[%s].flow_index = %s;\n" + " flow_of_%s_%s_for_parametrized_%s[%s].flow_index = flow_of_%s_%s_for_%s.flow_index + %s;\n" " char specialized_flow_name[64];\n" " sprintf(specialized_flow_name, \"%s_%s_%%d\", %s);\n" " flow_of_%s_%s_for_parametrized_%s[%s].name = strdup(specialized_flow_name);\n", jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, - jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) ); @@ -6040,6 +6040,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname); coutput(" current_data_offset_for_%s_%s += nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", jdf_basename, f->fname, jdf_basename, f->fname, df->varname); + coutput("\n"); depid=1; @@ -6085,6 +6086,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } + coutput("\n"); // Now output asserts: @@ -6158,13 +6160,40 @@ static void jdf_generate_new_function( const jdf_t* jdf ) if( NULL != call->parametrized_offset ) { - coutput(" { // Parametrized referrer %s of task class %s\n", df->varname, f->fname); coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n", f->task_class_id); - coutput(" parsec_dep_t *dep = %s_referrer_dep%d_atline_%d%s;\n\n", - JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + + + + if(FLOW_IS_PARAMETRIZED(df)) + { + coutput(" parsec_dep_t *dep = &flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n\n", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + } + else + { + coutput(" parsec_dep_t *dep = %s_referrer_dep%d_atline_%d%s;\n\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + } + /*if(FLOW_IS_PARAMETRIZED(df)) + { + coutput(" parsec_dep_t *dep = %s_referrer_dep%d_atline_%d%s;\n\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + } + else + { + coutput(" parsec_dep_t *dep = %s_referrer_dep%d_atline_%d%s;\n\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + }*/ //assert(!FLOW_IS_PARAMETRIZED(df)); // If the flow is parametrized, // Commenting this because a referrer can be parametrized as well?? diff --git a/parsec/task_class.c b/parsec/task_class.c index edbab4623..b202c35c2 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -112,11 +112,10 @@ bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_ */ void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_flow, int shift) { - int i, j, k; - int flow_in_out, dep_in_out; + int i; + int flow_in_out; int pivot_index; parsec_flow_t *flow; - parsec_dep_t *dep; // use an array to keep track of the flows we already treated parsec_flow_t *treated_flows[MAX_DATAFLOWS_PER_TASK]; @@ -216,7 +215,7 @@ void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep // Look for the pivot dep pivot_dep_index = -1; - for (int i = 0; i < dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT; i++) + for (int i = 0; i < (dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); i++) { parsec_dep_t *dep = (parsec_dep_t *)(dep_in_out ? flow->dep_out[i] : flow->dep_in[i]); @@ -242,7 +241,7 @@ void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep // Find the last non-null dep int last_dep_index; - for (last_dep_index = pivot_dep_index + 1; last_dep_index < dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT; ++last_dep_index) + for (last_dep_index = pivot_dep_index + 1; last_dep_index < (dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); ++last_dep_index) { parsec_dep_t *dep = (parsec_dep_t *)(dep_in_out ? flow->dep_out[last_dep_index] : flow->dep_in[last_dep_index]); @@ -260,7 +259,7 @@ void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep assert(dep); // We should not have a NULL dep here // assert(dep->dep_index == i); // The dep index can acutally be anything - assert(i + shift < dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); // We should not overflow the array + assert(i + shift < (dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT)); // We should not overflow the array dep->dep_index += shift; @@ -358,7 +357,6 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) { int i, j; int flow_in_out, dep_in_out; - parsec_flow_t *flow; parsec_dep_t *dep; // flows can appear twice in a task class (if both in and out) @@ -369,7 +367,7 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) { for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) { - flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); + const parsec_flow_t *flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); if (flow && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) { @@ -384,7 +382,7 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) // Check the coherency of the flow flags for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { - flow = tc->out[i]; + const parsec_flow_t *flow = tc->out[i]; if (!flow) { @@ -419,7 +417,7 @@ parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *fl int i; for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) { - for (i = 0; i < flow_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT; i++) + for (i = 0; i < (flow_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); i++) { parsec_dep_t *dep = (parsec_dep_t *)(flow_in_out ? flow_to->dep_out[i] : flow_to->dep_in[i]); @@ -497,7 +495,7 @@ int parsec_helper_get_flow_index_that_contains_dep(const parsec_task_class_t *tc int i; for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { - parsec_flow_t *flow = (in_out ? tc->out[i] : tc->in[i]); + const parsec_flow_t *flow = (in_out ? tc->out[i] : tc->in[i]); if (!flow) { @@ -519,7 +517,7 @@ int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flo int i; for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { - parsec_flow_t *_flow = (in_out ? tc->out[i] : tc->in[i]); + const parsec_flow_t *_flow = (in_out ? tc->out[i] : tc->in[i]); if (!flow) { From 3eeb876d3b2016e42cd6c1a1392733c0d8f598c2 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 16 Nov 2022 23:16:39 -0500 Subject: [PATCH 100/157] unroll referrers before parametrized flows, bug not solved --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 313 +++++++++++++-------- 1 file changed, 188 insertions(+), 125 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 981a22e52..34850c857 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5730,11 +5730,25 @@ static void jdf_generate_new_function( const jdf_t* jdf ) { // Then the dep refers to a parametrized flow - coutput(" %s_referrer_dep%d_atline_%d%s = malloc(sizeof(parsec_dep_t) * nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s);\n", - JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", - jdf_basename, call->func_or_mem, call->var); + if(!FLOW_IS_PARAMETRIZED(df)) + { + coutput(" %s_referrer_dep%d_atline_%d%s = malloc(sizeof(parsec_dep_t) * nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s);\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + jdf_basename, call->func_or_mem, call->var); + } + else + { + coutput(" %s_referrer_dep%d_atline_%d%s = malloc(sizeof(parsec_dep_t) * " + "nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s * " + "nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s);\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + jdf_basename, call->func_or_mem, call->var, + jdf_basename, f->fname, df->varname); + } } } } @@ -5772,6 +5786,175 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); + coutput(" // Unroll all the referrer's deps\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + for( int dep_in_out=0 ; dep_in_out < 2 ; dep_in_out++ ) { + if( (dep_in_out==0 && !(dep->dep_flags & JDF_DEP_FLOW_IN)) + || ((dep_in_out==1 && !(dep->dep_flags & JDF_DEP_FLOW_OUT))) ) { + // If the dep is not an input, skip dep_in_out=0, and if the dep is not an output, skip dep_in_out=1 + continue; + } + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + if( NULL != call->parametrized_offset ) + { + // Then the dep refers to a parametrized flow + + coutput(" {\n"); + coutput(" // %s of %s dep %d of flow %s of task class %s refers to a parametrized flow\n", + target_call?"callfalse":"calltrue", + dep_in_out?"input":"output", + dep->dep_index, df->varname, f->fname); + coutput("\n"); + + coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", + jdf_basename, f->fname, df->varname); + coutput(" parsec_dep_t *dep = &%s_dep%d_atline_%d%s;\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + coutput(" int flow_in_out = %d;\n", dep_in_out); + coutput(" int depid=dep->dep_index;\n"); + + + // spec_%s_%s.offset_%s%s will be computed after all the shifts have been computed, just to be certain that no future shift will change the value + /* + coutput("\n"); + coutput(" spec_%s_%s.offset_%s%s = parsec_helper_get_dep_index(flow, dep, flow_in_out);\n", + jdf_basename, f->fname, JDF_OBJECT_ONAME(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "");*/ + + coutput("\n"); + + coutput( + " // Shift the deps that are after dep (which references the parametrized flow)\n" + " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n", + jdf_basename, call->func_or_mem, call->var + ); + + // Get iterator strings + string_arena_t *sa_it_name = string_arena_new(16); + string_arena_t *sa_it2_name = string_arena_new(16); // second iterator in case of referrer inside a parametrized flow + string_arena_add_string(sa_it_name, "%s", call->parametrized_offset->alias); + if(FLOW_IS_PARAMETRIZED(df)) + { + string_arena_add_string(sa_it2_name, "%s", df->local_variables->alias); + if(strcmp(string_arena_get_string(sa_it_name), string_arena_get_string(sa_it2_name)) == 0) { + string_arena_add_string(sa_it2_name, "_2"); // avoid name clash + } + } + + coutput(" for( int %s=0;%sfunc_or_mem, call->var, + string_arena_get_string(sa_it_name) + ); + + if(!FLOW_IS_PARAMETRIZED(df)) + { + coutput( + " parsec_dep_t *dep_specialization = &%s_referrer_dep%d_atline_%d%s[%s];\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + string_arena_get_string(sa_it_name) + ); + } + else + { + coutput(" for( int %s=0;%sfname, df->varname, + string_arena_get_string(sa_it2_name) + ); + + coutput( + " parsec_dep_t *dep_specialization = &%s_referrer_dep%d_atline_%d%s[%s+%s*nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s];\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + string_arena_get_string(sa_it_name), string_arena_get_string(sa_it2_name), + jdf_basename, call->func_or_mem, call->var + ); + } + + coutput(" dep_specialization = parsec_helper_copy_dep(dep_specialization, dep);\n"); + + coutput( + " dep_specialization->flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n", + jdf_basename, call->func_or_mem, call->var, string_arena_get_string(sa_it_name) + ); + coutput( + " dep_specialization->dep_index += %s;\n", + string_arena_get_string(sa_it_name) + ); + + if(FLOW_IS_PARAMETRIZED(df)) + { + coutput( + " dep_specialization->belongs_to = &flow_of_%s_%s_for_parametrized_%s[%s];\n", + jdf_basename, f->fname, df->varname, string_arena_get_string(sa_it_name) + ); + } + + coutput( + " (flow_in_out?flow->dep_out:flow->dep_in)[depid+%s] = dep_specialization;\n", + string_arena_get_string(sa_it_name) + ); + + + coutput( + " assert(depid+%s < %s);\n", + string_arena_get_string(sa_it_name), + (dep_in_out)?"MAX_DEP_OUT_COUNT":"MAX_DEP_IN_COUNT" + ); + + if(FLOW_IS_PARAMETRIZED(df)) + { + coutput(" }\n"); + } + coutput(" }\n"); + coutput(" }\n"); + + string_arena_free(sa_it_name); + string_arena_free(sa_it2_name); + + + // coutput( + // " parsec_dep_t *new_dep = parsec_helper_copy_dep(dep);\n" + // " assert(NULL != new_dep);\n" + // " new_dep->flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n" + // " //new_dep->cond = target_expr_cond; // TODO !\n" + // " // new_dep->ctl_gather_nb = ; // TODO\n" + // " new_dep->dep_index += %s;\n" + // " //new_dep->dep_datatype_index += cd; // TODO maybe modify?\n" + // " //assert(new_dep->direct_data != NULL);\n" + // " // Insert the new dep\n" + // " (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep;\n", + // jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, + // call->parametrized_offset->alias + //); + } + } + } + } + } + } + + coutput("\n"); coutput(" // Unroll all the parametrized flows\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { @@ -5888,126 +6071,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); - coutput(" // Then unroll all the relevant referrer's deps\n"); - for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - depid=1; - for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { - for( int dep_in_out=0 ; dep_in_out < 2 ; dep_in_out++ ) { - if( (dep_in_out==0 && !(dep->dep_flags & JDF_DEP_FLOW_IN)) - || ((dep_in_out==1 && !(dep->dep_flags & JDF_DEP_FLOW_OUT))) ) { - // If the dep is not an input, skip dep_in_out=0, and if the dep is not an output, skip dep_in_out=1 - continue; - } - for( int target_call=0; target_call<2; ++target_call ) { - assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); - if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) - { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY - continue; - } - jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; - assert(call); - - if( NULL != call->parametrized_offset ) - { - // Then the dep refers to a parametrized flow - - coutput(" {\n"); - coutput(" // %s of %s dep %d of flow %s of task class %s refers to a parametrized flow\n", - target_call?"callfalse":"calltrue", - dep_in_out?"input":"output", - dep->dep_index, df->varname, f->fname); - coutput("\n"); - - coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", - jdf_basename, f->fname, df->varname); - coutput(" parsec_dep_t *dep = &%s_dep%d_atline_%d%s;\n", - JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - coutput(" int flow_in_out = %d;\n", dep_in_out); - coutput(" int depid=dep->dep_index;\n"); - - - // spec_%s_%s.offset_%s%s will be computed after all the shifts have been computed, just to be certain that no future shift will change the value - /* - coutput("\n"); - coutput(" spec_%s_%s.offset_%s%s = parsec_helper_get_dep_index(flow, dep, flow_in_out);\n", - jdf_basename, f->fname, JDF_OBJECT_ONAME(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "");*/ - - coutput("\n"); - - coutput( - " // Shift the deps that are after dep (which references the parametrized flow)\n" - " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n", - jdf_basename, call->func_or_mem, call->var - ); - - coutput(" for( int %s=0;%sparametrized_offset->alias, - call->parametrized_offset->alias, - jdf_basename, call->func_or_mem, call->var, - call->parametrized_offset->alias - ); - - coutput( - " parsec_dep_t *dep_specialization = &%s_referrer_dep%d_atline_%d%s[%s];\n", - JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", - call->parametrized_offset->alias - ); - - coutput(" dep_specialization = parsec_helper_copy_dep(dep_specialization, dep);\n"); - - coutput( - " dep_specialization->flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n", - jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias - ); - coutput( - " dep_specialization->dep_index += %s;\n", - call->parametrized_offset->alias - ); - - coutput( - " (flow_in_out?flow->dep_out:flow->dep_in)[depid+%s] = dep_specialization;\n", - call->parametrized_offset->alias - ); - - - coutput( - " assert(depid+%s < %s);\n", - call->parametrized_offset->alias, - (dep_in_out)?"MAX_DEP_OUT_COUNT":"MAX_DEP_IN_COUNT" - ); - - coutput(" }\n"); - coutput(" }\n"); - - // coutput( - // " parsec_dep_t *new_dep = parsec_helper_copy_dep(dep);\n" - // " assert(NULL != new_dep);\n" - // " new_dep->flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n" - // " //new_dep->cond = target_expr_cond; // TODO !\n" - // " // new_dep->ctl_gather_nb = ; // TODO\n" - // " new_dep->dep_index += %s;\n" - // " //new_dep->dep_datatype_index += cd; // TODO maybe modify?\n" - // " //assert(new_dep->direct_data != NULL);\n" - // " // Insert the new dep\n" - // " (flow_in_out?flow->dep_out:flow->dep_in)[depid+cd] = new_dep;\n", - // jdf_basename, call->func_or_mem, call->var, call->parametrized_offset->alias, - // call->parametrized_offset->alias - //); - } - } - } - } - } - } - - coutput(" // Finally, set the correct indices for the parametrized flows and the referrers\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) From c6549c711d86068121113431eb838b76a030ffbf Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 18 Nov 2022 15:03:06 -0500 Subject: [PATCH 101/157] make the parametrized link sanity check work better with broadcasts + emphasize a problem in the setting of source_repo --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 138 +++++++++++++++++---- 1 file changed, 116 insertions(+), 22 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 34850c857..ee7f90df1 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7456,12 +7456,23 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, coutput("%s if( this_task->data.%s.source_repo_entry == this_task->repo_entry ){\n" "%s /* in case we have consume from this task repo entry for the flow,\n" "%s * it is cleaned up, avoiding having old stuff during release_deps_of\n" - "%s */\n" - "%s this_task->repo_entry->data[%d] = NULL;\n" - "%s }\n", + "%s */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), - INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), - flow->flow_index, + INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow)); + if(!TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { // If no flow is parametrized, the flow index will not be altered + coutput("%s this_task->repo_entry->data[%d] = NULL;\n", INDENTATION_IF_PARAMETRIZED(flow), + flow->flow_index); + // TODO this seems wrong, this_task->repo_entry->data has a size of 1, but flow->flow_index can be > 1 + } + else + { + // It is also definitely wrong if the flow is parametrized, since the flow index can change at runtime + coutput("%s // this_task->repo_entry->data[%d] = NULL;\n", INDENTATION_IF_PARAMETRIZED(flow), + flow->flow_index); + coutput("%s assert(0);\n", INDENTATION_IF_PARAMETRIZED(flow)); + } + coutput("%s }\n", INDENTATION_IF_PARAMETRIZED(flow)); } coutput("%s this_task->data.%s.fulfill = 1;\n" @@ -8150,34 +8161,117 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const } } + int nb_opened_call_locals = 0; + int any_local_is_ranged = 0; + + // add the relevant call variables: + jdf_call_t *dl = target_call; + if( NULL != dl->local_defs ) { + jdf_expr_t *ld; + for(ld = jdf_expr_lv_first(dl->local_defs); ld != NULL; ld = jdf_expr_lv_next(dl->local_defs, ld)) { + + assert(NULL != ld->alias); + assert(-1 != ld->ldef_index); + + if(JDF_RANGE == ld->op || JDF_PARAMETRIZED_FLOW_RANGE == ld->op) + { + any_local_is_ranged = 1; + } + + if(strcmp(ld->alias, get_parametrized_flow_iterator_name(source_flow))==0) + { // skip the local that is the parametrized iterator (already handled in the outer loop) + continue; + } + + expr_info_t expr_info = EMPTY_EXPR_INFO; + expr_info.sa = string_arena_new(64); + expr_info.prefix = ""; + expr_info.suffix = ""; + expr_info.assignments = ""; + + coutput("%s int %s;\n", spaces, ld->alias); + if(JDF_RANGE == ld->op || JDF_PARAMETRIZED_FLOW_RANGE == ld->op) { + coutput( + "%s for( %s = %s;", + spaces, ld->alias, dump_expr((void**)ld->jdf_ta1, &expr_info)); + coutput("%s <= %s; %s+=", + ld->alias, dump_expr((void**)ld->jdf_ta2, &expr_info), ld->alias); + coutput("%s) {\n", + dump_expr((void**)ld->jdf_ta3, &expr_info), + spaces); + ++nb_opened_call_locals; + } else { + coutput( + "%s %s = %s;\n", + spaces, ld->alias, dump_expr((void**)ld, &expr_info)); + } + } + } + for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { coutput("#define %s %s%s\n", vl->name, targetf->fname, vl->name); } // dump the parsec_fatal if an incoherency is detected - coutput( - "%s // call%s dependency %d of flow %s of function %s\n" - "%s if(%s != %s) {\n" - "%s parsec_fatal(\"A dependency between a parametrized flow and its referrer is incoherent.\\n\"\n" - "%s \"If %s = %%d, %s != %%d\\n\"\n" - "%s \"The parametrized flow is %s of task class %s.\\n\"\n" - "%s \"The referrer is call%s of dep %d of flow %s of task class %s.\\n\",\n" - "%s %s, %s);\n" - "%s }\n", - spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname, - spaces, dump_expr((void**)target_call->parametrized_offset, &expr_info), get_parametrized_flow_iterator_name(source_flow), - spaces, - spaces, get_parametrized_flow_iterator_name(source_flow), dump_expr((void**)target_call->parametrized_offset, &expr_info), - spaces, source_flow->varname, sourcef->fname, - spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname, - spaces, get_parametrized_flow_iterator_name(source_flow), get_parametrized_flow_iterator_name(source_flow), - spaces); + coutput("%s // call%s dependency %d of flow %s of function %s\n", + spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname); + if(any_local_is_ranged) + { + coutput("%s // Ensure that we stay in the bounds;\n", spaces); + + for(int comparator=0;comparator<2;comparator++) { + coutput( + "%s if((%s) %s (%s)) {\n" + "%s parsec_fatal(\"A dependency between a parametrized flow and its referrer is incoherent.\\n\"\n" + "%s \"If %s = %%d, %s != %%d\\n\"\n" + "%s \"The parametrized flow is %s of task class %s.\\n\"\n" + "%s \"The referrer is call%s of dep %d of flow %s of task class %s.\\n\",\n" + "%s %s, %s);\n" + "%s }\n", + spaces, + // lower or upper bound, depending on the comparator + dump_expr((void**)(comparator?source_flow->local_variables->jdf_ta1:source_flow->local_variables->jdf_ta2), &expr_info), + comparator?">":"<", get_parametrized_flow_iterator_name(source_flow), + spaces, + spaces, get_parametrized_flow_iterator_name(source_flow), dump_expr((void**)target_call->parametrized_offset, &expr_info), + spaces, source_flow->varname, sourcef->fname, + spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname, + spaces, get_parametrized_flow_iterator_name(source_flow), get_parametrized_flow_iterator_name(source_flow), + spaces); + } + } + else + { + coutput("%s // Since no local is ranged, we can assume an exact equality);\n", spaces); + + coutput( + "%s if((%s) != (%s)) {\n" + "%s parsec_fatal(\"A dependency between a parametrized flow and its referrer is incoherent.\\n\"\n" + "%s \"If %s = %%d, %s != %%d\\n\"\n" + "%s \"The parametrized flow is %s of task class %s.\\n\"\n" + "%s \"The referrer is call%s of dep %d of flow %s of task class %s.\\n\",\n" + "%s %s, %s);\n" + "%s }\n", + spaces, dump_expr((void**)target_call->parametrized_offset, &expr_info), get_parametrized_flow_iterator_name(source_flow), + spaces, + spaces, get_parametrized_flow_iterator_name(source_flow), dump_expr((void**)target_call->parametrized_offset, &expr_info), + spaces, source_flow->varname, sourcef->fname, + spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname, + spaces, get_parametrized_flow_iterator_name(source_flow), get_parametrized_flow_iterator_name(source_flow), + spaces); + } for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { coutput("#undef %s\n", vl->name); } + // close opened calls: + while(nb_opened_call_locals > 0) { + coutput("%s }\n", spaces); + --nb_opened_call_locals; + } + coutput("%s }\n", spaces); } From 2632a0824cd8d88ad32aebbf88dd92b92c7765d7 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 18 Nov 2022 15:17:17 -0500 Subject: [PATCH 102/157] improve the print --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index ee7f90df1..2f90db4b5 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -8223,7 +8223,7 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const coutput( "%s if((%s) %s (%s)) {\n" "%s parsec_fatal(\"A dependency between a parametrized flow and its referrer is incoherent.\\n\"\n" - "%s \"If %s = %%d, %s != %%d\\n\"\n" + "%s \"If %s = %%d, %s !%s %%d\\n\"\n" "%s \"The parametrized flow is %s of task class %s.\\n\"\n" "%s \"The referrer is call%s of dep %d of flow %s of task class %s.\\n\",\n" "%s %s, %s);\n" @@ -8231,9 +8231,9 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const spaces, // lower or upper bound, depending on the comparator dump_expr((void**)(comparator?source_flow->local_variables->jdf_ta1:source_flow->local_variables->jdf_ta2), &expr_info), - comparator?">":"<", get_parametrized_flow_iterator_name(source_flow), + comparator?">":"<", target_call->local_defs->alias, spaces, - spaces, get_parametrized_flow_iterator_name(source_flow), dump_expr((void**)target_call->parametrized_offset, &expr_info), + spaces, get_parametrized_flow_iterator_name(source_flow), dump_expr((void**)target_call->parametrized_offset, &expr_info), comparator?">":"<", spaces, source_flow->varname, sourcef->fname, spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname, spaces, get_parametrized_flow_iterator_name(source_flow), get_parametrized_flow_iterator_name(source_flow), From 256f1aac97691995a97ea81931b72b3383f121ef Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 18 Nov 2022 22:41:29 -0500 Subject: [PATCH 103/157] first unroll flows, then deps, make it work for referrers of parametrized flows --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 348 ++++++++++++--------- parsec/task_class.c | 1 + 2 files changed, 198 insertions(+), 151 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 2f90db4b5..9839435c7 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1369,6 +1369,15 @@ static jdf_function_entry_t *find_target_function(const jdf_t *jdf, const char * return targetf; } +static jdf_dataflow_t *find_target_flow(const jdf_t *jdf, const jdf_function_entry_t *f, const char *name) +{ + jdf_dataflow_t *target_flow; + for(target_flow = f->dataflow; target_flow != NULL; target_flow = target_flow->next) + if( !strcmp(target_flow->varname, name) ) + break; + return target_flow; +} + /** * Find the output flow corresponding to a particular input flow. This function * returns the flow and not a particular dependency. @@ -5786,6 +5795,122 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); + coutput(" // Unroll all the parametrized flows\n"); + + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" {\n"); + coutput(" // Parametrized flow %s of task class %s\n\n", df->varname, f->fname); + + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n\n", f->task_class_id); + coutput( + " // Shift the flows that are after the parametrized flow\n" + " parsec_shift_all_flows_after(tc, &flow_of_%s_%s_for_%s, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n" + "\n", + jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname + );//GET_PARAMETRIZED_FLOW_ITERATOR_NAME + coutput( + " // Unroll the parametrized flow to generate each specialized flow\n" + ); + + string_arena_init(sa); + dump_parametrized_flow_loop(df, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), " ", sa); + coutput("%s", string_arena_get_string(sa)); + + coutput( + " parsec_helper_copy_flow(&flow_of_%s_%s_for_parametrized_%s[%s], &flow_of_%s_%s_for_%s);\n" + " flow_of_%s_%s_for_parametrized_%s[%s].flow_index = flow_of_%s_%s_for_%s.flow_index + %s;\n" + " char specialized_flow_name[64];\n" + " //sprintf(specialized_flow_name, \"%s_%s_%%d\", %s); // modifying the name causes find_target_flow to fail!\n" + " flow_of_%s_%s_for_parametrized_%s[%s].name = strdup(specialized_flow_name);\n", + jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) + ); + + string_arena_init(sa); + dump_parametrized_flow_loop_end(df, " ", sa); + coutput("%s", string_arena_get_string(sa)); + + coutput( + "\n" + ); + + + coutput( + " // Insert the new flows in the task class\n" + " for(int flow_in_out=0;flow_in_out<2;++flow_in_out) {\n" + " bool pivot_reached = false;\n" + " int %s = 0;\n" + " for(i = 0; i < MAX_DATAFLOWS_PER_TASK && %s < nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s; i++) {\n" + " parsec_flow_t *flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]);\n" + " if(!flow && !pivot_reached) {\n" + " break;\n" + " }\n" + " if(flow == &flow_of_%s_%s_for_%s) {\n" + " pivot_reached = true;\n" +// out_offset_flow_of_%s_%s_for_%s will be computed after all the shifts have been computed, just to be certain that no future shift will change the value +// " if(flow_in_out) {\n" +// " spec_%s.out_offset_flow_of_%s_%s_for_%s = i;\n" +// " }\n" + " // Update the goal of the task class\n" + " if(flow_in_out == 0)\n" + " {\n" + " // If is input, shift the proper values in the goal\n" + " // Idea: 00abcxyz -> abcccxyz (if shift=2 (i.e. nb_specializations=3) and pivot index = 3)\n" + " // (c=1 necessarily)\n" + " int shift = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1;\n" + " parsec_dependency_t unshifted_values = tc->dependencies_goal & ((1<dependencies_goal >> (i + 1)) << (i + 1 + shift);\n" + " parsec_dependency_t in_between = ((1<<(shift+1))-1) << i;\n" + " tc->dependencies_goal = unshifted_values | shifted_values | in_between;\n" + " }\n" + " assert(i+nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s < MAX_DATAFLOWS_PER_TASK);\n" + " }\n" + " if(pivot_reached)\n" + " {\n" + " // Insert the new specialized flow\n" + " //(flow_in_out?tc->out:tc->in)[i] = &flow_of_%s_%s_for_parametrized_%s[flow_of_%s_%s_for_%s.flow_index+%s];\n" + " (flow_in_out?tc->out:tc->in)[i] = &flow_of_%s_%s_for_parametrized_%s[%s];\n" + " ++%s;\n" + " }\n" + " }\n" + " }\n", + GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname, + //JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), + GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) + ); + coutput( + " // Update the mask of each flow\n" + " /*for(i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) {\n" + " parsec_flow_t *flow = tc->out[i];\n" + " if(!flow) {\n" + " break;\n" + " }\n" + " flow->flow_datatype_mask = 1 << flow->flow_index; // TODO verify (related to in/out)\n" + " }*/\n" + " // Update nb_flows\n" + " tc->nb_flows += nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1;\n", + jdf_basename, f->fname, df->varname + ); + + coutput(" }\n"); + } + } + } + + coutput("\n"); + coutput(" // Unroll all the referrer's deps\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { @@ -5813,12 +5938,10 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" {\n"); coutput(" // %s of %s dep %d of flow %s of task class %s refers to a parametrized flow\n", target_call?"callfalse":"calltrue", - dep_in_out?"input":"output", + dep_in_out?"output":"input", dep->dep_index, df->varname, f->fname); coutput("\n"); - coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", - jdf_basename, f->fname, df->varname); coutput(" parsec_dep_t *dep = &%s_dep%d_atline_%d%s;\n", JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse @@ -5837,12 +5960,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); - coutput( - " // Shift the deps that are after dep (which references the parametrized flow)\n" - " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n", - jdf_basename, call->func_or_mem, call->var - ); - // Get iterator strings string_arena_t *sa_it_name = string_arena_new(16); string_arena_t *sa_it2_name = string_arena_new(16); // second iterator in case of referrer inside a parametrized flow @@ -5854,6 +5971,36 @@ static void jdf_generate_new_function( const jdf_t* jdf ) string_arena_add_string(sa_it2_name, "_2"); // avoid name clash } } + + + if(FLOW_IS_PARAMETRIZED(df)) + { + coutput(" for( int %s=0;%sfname, df->varname, + string_arena_get_string(sa_it2_name) + ); + } + + jdf_function_entry_t *targetf = find_target_function(jdf, call->func_or_mem); + jdf_dataflow_t *target_flow = find_target_flow(jdf, targetf, call->var); + assert(targetf && target_flow); + if(FLOW_IS_PARAMETRIZED(df) && FLOW_IS_PARAMETRIZED(target_flow)) + { + coutput("\n parsec_flow_t *flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n", + jdf_basename, f->fname, df->varname, string_arena_get_string(sa_it2_name)); + } + else + { + coutput("\n parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", + jdf_basename, f->fname, df->varname); + } + coutput( + " // Shift the deps that are after dep (which references the parametrized flow)\n" + " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n\n", + jdf_basename, call->func_or_mem, call->var + ); coutput(" for( int %s=0;%sfunc_or_mem, call->var, string_arena_get_string(sa_it_name) ); - + if(!FLOW_IS_PARAMETRIZED(df)) { coutput( @@ -5874,13 +6021,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } else { - coutput(" for( int %s=0;%sfname, df->varname, - string_arena_get_string(sa_it2_name) - ); - coutput( " parsec_dep_t *dep_specialization = &%s_referrer_dep%d_atline_%d%s[%s+%s*nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s];\n", JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), @@ -5954,121 +6094,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } - coutput("\n"); - coutput(" // Unroll all the parametrized flows\n"); - - for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - if( FLOW_IS_PARAMETRIZED(df) ) { - coutput(" {\n"); - coutput(" // Parametrized flow %s of task class %s\n\n", df->varname, f->fname); - - coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n\n", f->task_class_id); - coutput( - " // Shift the flows that are after the parametrized flow\n" - " parsec_shift_all_flows_after(tc, &flow_of_%s_%s_for_%s, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n" - "\n", - jdf_basename, f->fname, df->varname, - jdf_basename, f->fname, df->varname - );//GET_PARAMETRIZED_FLOW_ITERATOR_NAME - coutput( - " // Unroll the parametrized flow to generate each specialized flow\n" - ); - - string_arena_init(sa); - dump_parametrized_flow_loop(df, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), " ", sa); - coutput("%s", string_arena_get_string(sa)); - - coutput( - " parsec_helper_copy_flow(&flow_of_%s_%s_for_parametrized_%s[%s], &flow_of_%s_%s_for_%s);\n" - " flow_of_%s_%s_for_parametrized_%s[%s].flow_index = flow_of_%s_%s_for_%s.flow_index + %s;\n" - " char specialized_flow_name[64];\n" - " sprintf(specialized_flow_name, \"%s_%s_%%d\", %s);\n" - " flow_of_%s_%s_for_parametrized_%s[%s].name = strdup(specialized_flow_name);\n", - jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), - jdf_basename, f->fname, df->varname, - jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), - df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), - jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) - ); - - string_arena_init(sa); - dump_parametrized_flow_loop_end(df, " ", sa); - coutput("%s", string_arena_get_string(sa)); - - coutput( - "\n" - ); - - - coutput( - " // Insert the new flows in the task class\n" - " for(int flow_in_out=0;flow_in_out<2;++flow_in_out) {\n" - " bool pivot_reached = false;\n" - " int %s = 0;\n" - " for(i = 0; i < MAX_DATAFLOWS_PER_TASK && %s < nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s; i++) {\n" - " parsec_flow_t *flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]);\n" - " if(!flow && !pivot_reached) {\n" - " break;\n" - " }\n" - " if(flow == &flow_of_%s_%s_for_%s) {\n" - " pivot_reached = true;\n" -// out_offset_flow_of_%s_%s_for_%s will be computed after all the shifts have been computed, just to be certain that no future shift will change the value -// " if(flow_in_out) {\n" -// " spec_%s.out_offset_flow_of_%s_%s_for_%s = i;\n" -// " }\n" - " // Update the goal of the task class\n" - " if(flow_in_out == 0)\n" - " {\n" - " // If is input, shift the proper values in the goal\n" - " // Idea: 00abcxyz -> abcccxyz (if shift=2 (i.e. nb_specializations=3) and pivot index = 3)\n" - " // (c=1 necessarily)\n" - " int shift = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1;\n" - " parsec_dependency_t unshifted_values = tc->dependencies_goal & ((1<dependencies_goal >> (i + 1)) << (i + 1 + shift);\n" - " parsec_dependency_t in_between = ((1<<(shift+1))-1) << i;\n" - " tc->dependencies_goal = unshifted_values | shifted_values | in_between;\n" - " }\n" - " assert(i+nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s < MAX_DATAFLOWS_PER_TASK);\n" - " }\n" - " if(pivot_reached)\n" - " {\n" - " // Insert the new specialized flow\n" - " //(flow_in_out?tc->out:tc->in)[i] = &flow_of_%s_%s_for_parametrized_%s[flow_of_%s_%s_for_%s.flow_index+%s];\n" - " (flow_in_out?tc->out:tc->in)[i] = &flow_of_%s_%s_for_parametrized_%s[%s];\n" - " ++%s;\n" - " }\n" - " }\n" - " }\n", - GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), - GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, - jdf_basename, f->fname, df->varname, - //JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, - jdf_basename, f->fname, df->varname, - jdf_basename, f->fname, df->varname, - jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), - jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), - GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df) - ); - coutput( - " // Update the mask of each flow\n" - " /*for(i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) {\n" - " parsec_flow_t *flow = tc->out[i];\n" - " if(!flow) {\n" - " break;\n" - " }\n" - " flow->flow_datatype_mask = 1 << flow->flow_index; // TODO verify (related to in/out)\n" - " }*/\n" - " // Update nb_flows\n" - " tc->nb_flows += nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1;\n", - jdf_basename, f->fname, df->varname - ); - - coutput(" }\n"); - } - } - } - coutput("\n"); coutput(" // Finally, set the correct indices for the parametrized flows and the referrers\n"); @@ -6129,17 +6154,37 @@ static void jdf_generate_new_function( const jdf_t* jdf ) (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", jdf_basename, f->fname, df->varname);*/ - coutput(" spec_%s.out_dep_offset_of%s%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, &flow_of_%s_%s_for_%s_dep%d_atline_%d%s, 1);\n", - JDF_OBJECT_ONAME(f), - call->parametrized_offset != NULL?"_referrer":"", FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", - jdf_basename, f->fname, df->varname, - depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", - jdf_basename, f->fname, df->varname, - depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + jdf_function_entry_t *targetf = find_target_function(jdf, call->func_or_mem); + jdf_dataflow_t *target_flow = find_target_flow(jdf, targetf, call->var); + if(!FLOW_IS_PARAMETRIZED(target_flow)) + { // Referrer to a non-parametrized flow + coutput(" spec_%s.out_dep_offset_of%s%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = parsec_helper_get_dep_index(tc, &flow_of_%s_%s_for_%s_dep%d_atline_%d%s, 1);\n", + JDF_OBJECT_ONAME(f), + call->parametrized_offset != NULL?"_referrer":"", FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + } + else + { // Referrer to a parametrized flow + coutput(" spec_%s.out_dep_offset_of%s%s_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = " + "parsec_helper_get_dep_index(tc, &%s_referrer_dep%d_atline_%d%s[0], 1);\n", + JDF_OBJECT_ONAME(f), + call->parametrized_offset != NULL?"_referrer":"", FLOW_IS_PARAMETRIZED(df)?"_parametrized":"", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : "" + ); + } /*coutput(" spec_%s.out_dep_offset_of_flow_of_%s_%s_for_%s_dep%d_atline_%d%s = ;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, @@ -6227,8 +6272,10 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n", f->task_class_id); - - if(FLOW_IS_PARAMETRIZED(df)) + jdf_function_entry_t *targetf = find_target_function(jdf, call->func_or_mem); + jdf_dataflow_t *target_flow = find_target_flow(jdf, targetf, call->var); + assert(targetf && target_flow); + if(FLOW_IS_PARAMETRIZED(df) && !FLOW_IS_PARAMETRIZED(target_flow)) { coutput(" parsec_dep_t *dep = &flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n\n", jdf_basename, f->fname, df->varname, @@ -6238,10 +6285,10 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } else { - coutput(" parsec_dep_t *dep = %s_referrer_dep%d_atline_%d%s;\n\n", - JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + coutput(" parsec_dep_t *dep = &%s_referrer_dep%d_atline_%d%s[0];\n\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); } /*if(FLOW_IS_PARAMETRIZED(df)) { @@ -8197,8 +8244,7 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const coutput("%s <= %s; %s+=", ld->alias, dump_expr((void**)ld->jdf_ta2, &expr_info), ld->alias); coutput("%s) {\n", - dump_expr((void**)ld->jdf_ta3, &expr_info), - spaces); + dump_expr((void**)ld->jdf_ta3, &expr_info)); ++nb_opened_call_locals; } else { coutput( diff --git a/parsec/task_class.c b/parsec/task_class.c index b202c35c2..1434b4c8e 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -234,6 +234,7 @@ void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep // If the pivot was not found in this flow_in_out, skip the shift if (pivot_dep_index == -1) { + assert(0); return; } From ad3acca15815cfa973b3822785a0e877eeeeb19d Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 21 Nov 2022 14:53:18 -0500 Subject: [PATCH 104/157] do not change the name of parametrized flows --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 9839435c7..f0f52b9a0 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5822,9 +5822,9 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput( " parsec_helper_copy_flow(&flow_of_%s_%s_for_parametrized_%s[%s], &flow_of_%s_%s_for_%s);\n" " flow_of_%s_%s_for_parametrized_%s[%s].flow_index = flow_of_%s_%s_for_%s.flow_index + %s;\n" - " char specialized_flow_name[64];\n" + " //char specialized_flow_name[64];\n" " //sprintf(specialized_flow_name, \"%s_%s_%%d\", %s); // modifying the name causes find_target_flow to fail!\n" - " flow_of_%s_%s_for_parametrized_%s[%s].name = strdup(specialized_flow_name);\n", + " //flow_of_%s_%s_for_parametrized_%s[%s].name = strdup(specialized_flow_name);\n", jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), jdf_basename, f->fname, df->varname, GET_PARAMETRIZED_FLOW_ITERATOR_NAME(df), From 1cdcc0c955d6474d36ce2e268ba0f635fbc00626 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 21 Nov 2022 15:15:01 -0500 Subject: [PATCH 105/157] increase debug verbose level for printing the iterator value --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index f0f52b9a0..8efb7d5f0 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5542,7 +5542,7 @@ static void jdf_generate_constructor( const jdf_t* jdf ) "\n\n" "#if defined(PARSEC_DEBUG_PARANOID)\n" " // use parsec_debug_dump_task_class_at_exec(tc); on each task class\n" - " parsec_debug_verbose(1, parsec_debug_output, \"############ Task classes before update ############\\n\");\n" + " parsec_debug_verbose(10, parsec_debug_output, \"############ Task classes before update ############\\n\");\n" " for( uint32_t i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" " parsec_debug_dump_task_class_at_exec(tc);\n" From c2c4a34850ea0a7329fe4c9a16e58ca3c6ed1ea2 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 21 Nov 2022 15:23:25 -0500 Subject: [PATCH 106/157] fix the debug messages --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 8efb7d5f0..426de3360 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6341,10 +6341,10 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput( "#if defined(PARSEC_DEBUG_PARANOID)\n" " // use parsec_debug_dump_task_class_at_exec(tc); on each task class\n" - " parsec_debug_verbose(1, parsec_debug_output, \"##\");\n" - " parsec_debug_verbose(1, parsec_debug_output, \"##\");\n" - " parsec_debug_verbose(1, parsec_debug_output, \"############ Task classes after update ############\");\n" - " parsec_debug_verbose(1, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(10, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(10, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(10, parsec_debug_output, \"############ Task classes after update ############\");\n" + " parsec_debug_verbose(10, parsec_debug_output, \"##\");\n" " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" " parsec_debug_dump_task_class_at_exec(tc);\n" @@ -7153,8 +7153,10 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, spaces, flow->varname, jdf_basename, call->func_or_mem, call->var, spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow)); if(FLOW_IS_PARAMETRIZED(flow)) { - coutput("%s parsec_debug_verbose(1, parsec_debug_output, \"%s = %%d\", %s);\n", + coutput("#if defined(PARSEC_DEBUG_NOISIER)\n"); + coutput("%s parsec_debug_verbose(10, parsec_debug_output, \"%s = %%d\", %s);\n", spaces, get_parametrized_flow_iterator_name(flow), get_parametrized_flow_iterator_name(flow)); + coutput("#endif\n"); } } From 09d098271376063aa7ab12744140481fba1d33cd Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 23 Nov 2022 11:54:21 -0500 Subject: [PATCH 107/157] find the depid instead of taking a static (usually false) id --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 3 ++- parsec/task_class.c | 28 ++++++++++++---------- parsec/task_class.h | 1 + 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 426de3360..fec293e35 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5947,7 +5947,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) // If ternary, add _iftrue or _iffalse (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); coutput(" int flow_in_out = %d;\n", dep_in_out); - coutput(" int depid=dep->dep_index;\n"); // spec_%s_%s.offset_%s%s will be computed after all the shifts have been computed, just to be certain that no future shift will change the value @@ -5996,6 +5995,8 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } + coutput(" int depid=parsec_helper_get_dep_index_in_flow(flow, dep, flow_in_out);\n"); + coutput( " // Shift the deps that are after dep (which references the parametrized flow)\n" " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n\n", diff --git a/parsec/task_class.c b/parsec/task_class.c index 1434b4c8e..e74d3c96e 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -302,7 +302,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) parsec_debug_verbose(1, parsec_debug_output, "## Task Class %s (%p) has %d flows, %d parameters, %d locals", tc->name, (void *)tc, tc->nb_flows, tc->nb_parameters, tc->nb_locals); - parsec_debug_verbose(1, parsec_debug_output, "## dependencies_goal = %x\n", tc->dependencies_goal); + parsec_debug_verbose(1, parsec_debug_output, "## dependencies_goal = %x", tc->dependencies_goal); for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { @@ -459,6 +459,19 @@ int parsec_helper_dep_is_in_flow(const parsec_flow_t *flow, const parsec_dep_t * return 0; } +int parsec_helper_get_dep_index_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep, int in_out) +{ + int i; + for (i = 0; i < (in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); i++) + { + if (dep == (in_out ? flow->dep_out[i] : flow->dep_in[i])) + { + return i; + } + } + return -1; +} + int parsec_helper_get_dep_index(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out) { int i; @@ -472,18 +485,7 @@ int parsec_helper_get_dep_index(const parsec_task_class_t *tc, const parsec_dep_ if (parsec_helper_dep_is_in_flow(flow, dep, in_out)) { - for(int j = 0; j < (in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) - { - parsec_dep_t *_dep = (parsec_dep_t *)(in_out ? flow->dep_out[j] : flow->dep_in[j]); - if(!_dep) - { - break; - } - if(_dep == dep) - { - return j; - } - } + return parsec_helper_get_dep_index_in_flow(flow, dep, in_out); } } diff --git a/parsec/task_class.h b/parsec/task_class.h index 99bbd3ff7..d06a9ca5f 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -24,6 +24,7 @@ parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *fl parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_from); int parsec_helper_dep_is_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep, int in_out); +int parsec_helper_get_dep_index_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep, int in_out); int parsec_helper_get_dep_index(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out); int parsec_helper_get_flow_index_that_contains_dep(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out); int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flow_t *flow, int in_out); From c8447ea71edea0407f7140119709982a8c6f68e9 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 23 Nov 2022 13:36:22 -0500 Subject: [PATCH 108/157] add flow iterator in iterate_successors --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index fec293e35..535003de0 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -9747,13 +9747,15 @@ char *dump_flow_offset_for_iterate_successors(string_arena_t *sa, const jdf_func // TODO: if flow can be computed at compile time (i.e. no parametrized flow declared before him) - /*if(FLOW_IS_PARAMETRIZED(flow)) + //jdf_function_entry_t *tarfetf = find_target_function(jdf, call->func_or_mem); + //jdf_flow_t *referred_flow = jdf_get_flow_by_name(f, call->flow); + if(FLOW_IS_PARAMETRIZED(flow)) { - string_arena_add_string(sa, "spec_%s_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s+%s", - jdf_basename, f->fname, jdf_basename, f->fname, flow->varname, + string_arena_add_string(sa, "spec_%s_%s.out_flow_offset_of%s%s_%s+%s", + jdf_basename, f->fname, call->parametrized_offset!=NULL?"_referrer":"", FLOW_IS_PARAMETRIZED(flow)?"_parametrized":"", JDF_OBJECT_ONAME(call), get_parametrized_flow_iterator_name(flow)); } - else*/ + else { string_arena_add_string(sa, "spec_%s_%s.out_flow_offset_of%s%s_%s", jdf_basename, f->fname, call->parametrized_offset!=NULL?"_referrer":"", FLOW_IS_PARAMETRIZED(flow)?"_parametrized":"", JDF_OBJECT_ONAME(call)); From 13b43a6819cbbfc5ded0c9e66d0a5f866b98ee9d Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 28 Nov 2022 16:28:53 -0500 Subject: [PATCH 109/157] use a pseudo loop for unrolling the parametrized flows + first failed attempt to give a proper unique dep_index --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 173 ++++++++++++++++++--- parsec/task_class.c | 158 ++++++++++++++++++- parsec/task_class.h | 14 +- 3 files changed, 314 insertions(+), 31 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 535003de0..733ddb9ca 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5791,13 +5791,145 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } coutput(" NULL\n };*/\n"); + coutput("\n"); + + // Declare local arrays to simplify the future parametrization of flows coutput(" const int nb_parametrized_flows = %d;\n", nb_parametrized_flows); + // Number of specializations of each parametrized flow + coutput(" const int nb_specializations_of_parametrized_flows[] = {\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s,\n", jdf_basename, f->fname, df->varname); + } + } + } + coutput(" 0\n };\n"); + // Task class of each parametrized flow + coutput(" parsec_task_class_t *task_class_of_parametrized_flows[] = {\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" __parsec_tp->super.super.task_classes_array[%d],\n", f->task_class_id); + } + } + } + coutput(" NULL\n };\n"); + // Specialization array of each parametrized flow + coutput(" parsec_flow_t *specialization_array_of_parametrized_flows[] = {\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" &flow_of_%s_%s_for_parametrized_%s[0],\n", jdf_basename, f->fname, df->varname); + } + } + } + coutput(" NULL\n };\n"); + // Base flow of each parametrized flow (the base jdf generated one which will be replaced with each specialization) + coutput(" const parsec_flow_t *base_flow_of_parametrized_flows[] = {\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + coutput(" &flow_of_%s_%s_for_%s,\n", jdf_basename, f->fname, df->varname); + } + } + } + coutput(" NULL\n };\n"); coutput("\n"); + + coutput(" // Unroll all the parametrized flows\n"); + coutput(" for( int parametrized_flow_id=0; parametrized_flow_idfunctions; NULL != f; f = f->next ) { + + coutput(" parsec_task_class_t *tc = (parsec_task_class_t*)task_class_of_parametrized_flows[parametrized_flow_id];\n"); + coutput(" const int nb_specializations_of_current_flow = nb_specializations_of_parametrized_flows[parametrized_flow_id];\n"); + coutput(" parsec_flow_t *specialization_array_of_current_flow = specialization_array_of_parametrized_flows[parametrized_flow_id];\n"); + coutput(" const parsec_flow_t *base_flow_of_current_flow = base_flow_of_parametrized_flows[parametrized_flow_id];\n"); + coutput( + " // Shift the flows that are after the parametrized flow\n" + " parsec_shift_all_flows_after(tc, base_flow_of_current_flow, 0, nb_specializations_of_current_flow-1); // in\n" + " parsec_shift_all_flows_after(tc, base_flow_of_current_flow, 1, nb_specializations_of_current_flow-1); // out\n" + "\n" + ); + coutput( + " // Unroll the parametrized flow to generate each specialized flow\n" + ); + + coutput(" for( int parametrized_iterator=0; parametrized_iteratorflow_index + parametrized_iterator;\n" + " //char specialized_flow_name[64];\n" + //" //sprintf(specialized_flow_name, \"%s_%s_%%d\", parametrized_iterator); // modifying the name causes find_target_flow to fail!\n" + " //specialization_array_of_current_flow[parametrized_iterator].name = strdup(specialized_flow_name);\n" + ); + + coutput(" }\n"); + + coutput( + "\n" + ); + + + coutput( + " // Insert the new flows in the task class\n" + " for(int flow_in_out=0;flow_in_out<2;++flow_in_out) {\n" + " bool pivot_reached = false;\n" + " int parametrized_iterator = 0;\n" + " for(i = 0; i < MAX_DATAFLOWS_PER_TASK && parametrized_iterator < nb_specializations_of_current_flow; i++) {\n" + " parsec_flow_t *flow = (parsec_flow_t*)(flow_in_out?tc->out[i]:tc->in[i]);\n" + " if(!flow && !pivot_reached) {\n" + " break;\n" + " }\n" + " if(flow == base_flow_of_current_flow) {\n" + " pivot_reached = true;\n" + " // Update the goal of the task class\n" + " if(flow_in_out == 0)\n" + " {\n" + " // If is input, shift the proper values in the goal\n" + " // Idea: 00abcxyz -> abcccxyz (if shift=2 (i.e. nb_specializations=3) and pivot index = 3)\n" + " int shift = nb_specializations_of_current_flow-1;\n" + " parsec_dependency_t unshifted_values = tc->dependencies_goal & ((1<dependencies_goal >> (i + 1)) << (i + 1 + shift);\n" + " parsec_dependency_t in_between = ((1<<(shift+1))-1) << i;\n" + " tc->dependencies_goal = unshifted_values | shifted_values | in_between;\n" + " }\n" + " assert(i+nb_specializations_of_current_flow < MAX_DATAFLOWS_PER_TASK);\n" + " }\n" + " if(pivot_reached)\n" + " {\n" + " // Insert the new specialized flow\n" + " //(flow_in_out?tc->out:tc->in)[i] = &specialization_array_of_current_flow[base_flow_of_current_flow.flow_index+parametrized_iterator];\n" + " (flow_in_out?tc->out:tc->in)[i] = &specialization_array_of_current_flow[parametrized_iterator];\n" + " ++parametrized_iterator;\n" + " }\n" + " }\n" + " assert(pivot_reached);\n" + " }\n" + " // Update nb_flows\n" + " tc->nb_flows += nb_specializations_of_current_flow-1;\n" + ); + // coutput( + // // " // Update the mask of each flow\n" + // // " for(i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) {\n" + // // " parsec_flow_t *flow = tc->out[i];\n" + // // " if(!flow) {\n" + // // " break;\n" + // // " }\n" + // // " flow->flow_datatype_mask = 1 << flow->flow_index; // TODO verify (related to in/out)\n" + // // " }\n" + // " // Update nb_flows\n" + // " tc->nb_flows += nb_specializations_of_current_flow-1;\n" + // ); + + + coutput(" }\n"); + + /*for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { coutput(" {\n"); @@ -5810,7 +5942,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) "\n", jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname - );//GET_PARAMETRIZED_FLOW_ITERATOR_NAME + ); coutput( " // Unroll the parametrized flow to generate each specialized flow\n" ); @@ -5862,7 +5994,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " {\n" " // If is input, shift the proper values in the goal\n" " // Idea: 00abcxyz -> abcccxyz (if shift=2 (i.e. nb_specializations=3) and pivot index = 3)\n" - " // (c=1 necessarily)\n" " int shift = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1;\n" " parsec_dependency_t unshifted_values = tc->dependencies_goal & ((1<dependencies_goal >> (i + 1)) << (i + 1 + shift);\n" @@ -5892,13 +6023,13 @@ static void jdf_generate_new_function( const jdf_t* jdf ) ); coutput( " // Update the mask of each flow\n" - " /*for(i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) {\n" - " parsec_flow_t *flow = tc->out[i];\n" - " if(!flow) {\n" - " break;\n" - " }\n" - " flow->flow_datatype_mask = 1 << flow->flow_index; // TODO verify (related to in/out)\n" - " }*/\n" + // " for(i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) {\n" + // " parsec_flow_t *flow = tc->out[i];\n" + // " if(!flow) {\n" + // " break;\n" + // " }\n" + // " flow->flow_datatype_mask = 1 << flow->flow_index; // TODO verify (related to in/out)\n" + // " }\n" " // Update nb_flows\n" " tc->nb_flows += nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1;\n", jdf_basename, f->fname, df->varname @@ -5907,7 +6038,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" }\n"); } } - } + }*/ coutput("\n"); @@ -5942,6 +6073,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) dep->dep_index, df->varname, f->fname); coutput("\n"); + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n\n", f->task_class_id); coutput(" parsec_dep_t *dep = &%s_dep%d_atline_%d%s;\n", JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), // If ternary, add _iftrue or _iffalse @@ -5999,7 +6131,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput( " // Shift the deps that are after dep (which references the parametrized flow)\n" - " parsec_shift_all_deps_after(flow, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n\n", + " parsec_shift_all_deps_after_and_update_tc(tc, flow, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n\n", jdf_basename, call->func_or_mem, call->var ); @@ -6043,13 +6175,16 @@ static void jdf_generate_new_function( const jdf_t* jdf ) string_arena_get_string(sa_it_name) ); - if(FLOW_IS_PARAMETRIZED(df)) - { - coutput( - " dep_specialization->belongs_to = &flow_of_%s_%s_for_parametrized_%s[%s];\n", - jdf_basename, f->fname, df->varname, string_arena_get_string(sa_it_name) - ); - } + // if(FLOW_IS_PARAMETRIZED(df)) + // { + // coutput( + // " dep_specialization->belongs_to = &flow_of_%s_%s_for_parametrized_%s[%s];\n", + // jdf_basename, f->fname, df->varname, string_arena_get_string(sa_it2_name) + // ); + // } + coutput( + " dep_specialization->belongs_to = flow;\n" + ); coutput( " (flow_in_out?flow->dep_out:flow->dep_in)[depid+%s] = dep_specialization;\n", diff --git a/parsec/task_class.c b/parsec/task_class.c index e74d3c96e..eafcbf550 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -105,22 +105,112 @@ bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_ return false; } +bool parsec_helper_dep_is_in_flow_array(const parsec_dep_t *dep, parsec_dep_t *dep_array[], int dep_array_size) +{ + for (int i = 0; i < dep_array_size; i++) + { + if (dep == dep_array[i]) + { + return true; + } + } + return false; +} + /** __parsec_LBM_shift_all_flow_reference_after * * Shift all the flows after "pivot_flow" by "shift" + * If in_out==0, shift the input flows, otherwise shift the output flows * */ -void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_flow, int shift) +void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t *pivot_flow, int in_out, int shift) { - int i; + int i, j; int flow_in_out; int pivot_index; + int last_flow_index; parsec_flow_t *flow; + parsec_dep_t *dep; // use an array to keep track of the flows we already treated parsec_flow_t *treated_flows[MAX_DATAFLOWS_PER_TASK]; int treated_flows_size = 0; + // Determine which array should be used (in or out) depending on in_out + //parsec_flow_t **flow_array = (parsec_flow_t **) ((in_out) ? (tc->out) : (tc->in)); + const int max_dep_count = (in_out) ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT; + parsec_dep_t **dep_array; + + // find the pivot flow + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; ++i) + { + if(pivot_flow == ((in_out) ? (tc->out) : (tc->in))[i]) + break; // pivot flow found + if(!((in_out) ? (tc->out) : (tc->in))[i]) + return; // pivot not found + } + if(pivot_flow == ((in_out) ? (tc->out) : (tc->in))[i]) + { + pivot_index = i; + + // - Update all the dep_index > pivot_index + // - find last_flow_index (needed for performing the actual shift at the end) + for (i = pivot_index + 1; i < MAX_DATAFLOWS_PER_TASK; i++) + { + flow = ((in_out) ? (tc->out) : (tc->in))[i]; + if(!flow) + break; // end of the array + + dep_array = (in_out) ? flow->dep_out : flow->dep_in; + + for(j=0; jdep_index > pivot_index) + dep->dep_index += shift*(i-pivot_index); + } + if(!flow) + break; // end of the array + } + last_flow_index = i - 1; + + // - Shift the flows + // - Update the flow_index of the flows + for (i = last_flow_index; i >= pivot_index; i--) + { + flow = ((in_out) ? (tc->out) : (tc->in))[i]; + ((in_out) ? (tc->out) : (tc->in))[i+shift] = flow; + flow->flow_index += shift; + } + } + +/* + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) + { + if(pivot_flow == tc->in[i]) + break; + } + //if(i < MAX_DATAFLOWS_PER_TASK) { + for(;iin[i]->dep[j]->dep_index += shift; + } + } + //} +*/ + + + + + + + +/* // Increase the IDs of every flow that is greater than the ID of pivot_flow for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) { @@ -154,7 +244,7 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_ * * Note: We displace all the flows following the pivot flow in the in and out array * But this is just for convience, to get the parametrized subflows next to each other - */ + *//* for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) { @@ -206,11 +296,12 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_ // Shift the flow (flow_in_out ? tc->out : tc->in)[i + shift] = flow; } - } + }*/ } -void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep_t *pivot_dep, int shift) +void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int shift) { + /* int pivot_dep_index; // Look for the pivot dep @@ -267,6 +358,38 @@ void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep // Shift the dep (dep_in_out ? flow->dep_out : flow->dep_in)[i + shift] = dep; } +*/ + + + // keep track of the deps that have been treated + parsec_dep_t *treated_deps[MAX_DEP_IN_COUNT + MAX_DEP_OUT_COUNT]; + int treated_deps_size = 0; + + for(int in_out=0;in_out<2;++in_out) + { + for(int flid=0; flidout[flid] : tc->in[flid]); + if(!fl) + break; + + int pivot_dep_dep_index = pivot_dep->dep_index; + for (int depid = 0; depid < (in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); depid++) + { + parsec_dep_t *dep = (parsec_dep_t *)(in_out ? fl->dep_out[depid] : fl->dep_in[depid]); + + if (!dep) + break; + + if (dep->dep_index > pivot_dep_dep_index && !parsec_helper_dep_is_in_flow_array(dep, treated_deps, treated_deps_size)) + { + dep->dep_index += shift; + treated_deps[treated_deps_size++] = dep; + } + } + } + } + /* // The datatype_mask should stay the same, as we do not add any datatype // Also shift the flow's flow_datatype_mask @@ -331,7 +454,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) } else if (dep->flow) { - parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s is a dep that is linked to dep %d of flow %s (id=%d) of task class %d", + parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s is has dep_id=%d and goes to flow %s (id=%d) of task class %d", dep_in_out ? "->" : "<-", j, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, dep->task_class_id); } @@ -380,6 +503,24 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) } } + // for each flow and each dep, check that: + // - belongs_to and flow : != 0xdeadbeef and != NULL + for(int in_out=0; in_out<2; ++in_out) { + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) + { + parsec_flow_t *flow = (parsec_flow_t *)(in_out ? tc->out[i] : tc->in[i]); + if(!flow) continue; + for(int j=0;j<(in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT);++j) { + dep = (parsec_dep_t *)(in_out ? flow->dep_out[j] : flow->dep_in[j]); + if(!dep) continue; + assert(dep->belongs_to != (void*)0xdeadbeef); + assert(dep->belongs_to != NULL); + assert(dep->flow != (void*)0xdeadbeef); + assert(dep->flow != NULL || dep->task_class_id == PARSEC_LOCAL_DATA_TASK_CLASS_ID); + } + } + } + // Check the coherency of the flow flags for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { @@ -407,7 +548,7 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) assert(tc->nb_flows == treated_flows_size); } -parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *flow_from) +parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, const parsec_flow_t *flow_from) { int flow_in_out; @@ -438,7 +579,7 @@ parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *fl return flow_to; } -parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_from) +parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, const parsec_dep_t * dep_from) { //parsec_dep_t *new_dep = (parsec_dep_t *)malloc(sizeof(parsec_dep_t)); assert(dep_to); @@ -469,6 +610,7 @@ int parsec_helper_get_dep_index_in_flow(const parsec_flow_t *flow, const parsec_ return i; } } + assert(0); return -1; } diff --git a/parsec/task_class.h b/parsec/task_class.h index d06a9ca5f..ddffe3b6f 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -11,17 +11,23 @@ #include "parsec/interfaces/interface.h" #include "parsec_internal.h" -void parsec_shift_all_flows_after(parsec_task_class_t *tc, parsec_flow_t *pivot_flow, int shift); -void parsec_shift_all_deps_after(parsec_flow_t *flow, int dep_in_out, parsec_dep_t *pivot_dep, int shift); +// The shift functions creates spaces in the relevant arrays +void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t *pivot_flow, int in_out, int shift); +void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int shift); + +// in all flows fl (fl!=flow), increase deps by shift +//void parsec_update_dep_index_in_other_flows(parsec_task_class_t *tc, parsec_flow_t *flow, int dep_in_out, int dep_index, int shift); + // flow_array should be const, but it creates a warning in the generated code bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_t *flow_array[], int flow_array_size); +bool parsec_helper_dep_is_in_flow_array(const parsec_dep_t *dep, parsec_dep_t *dep_array[], int dep_array_size); void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc); void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); // Copy a flow (including its deps) and returns a pointer to the new flow -parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, parsec_flow_t *flow_from); -parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, parsec_dep_t * dep_from); +parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, const parsec_flow_t *flow_from); +parsec_dep_t *parsec_helper_copy_dep(parsec_dep_t * dep_to, const parsec_dep_t * dep_from); int parsec_helper_dep_is_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep, int in_out); int parsec_helper_get_dep_index_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep, int in_out); From 611bed576d62c809ba5ed522f91b90cc91cd757f Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 30 Nov 2022 11:29:34 -0500 Subject: [PATCH 110/157] the dep_id are properly set but not the masks --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 140 ++++++++++++++++++++- parsec/task_class.c | 21 ++-- parsec/task_class.h | 2 +- 3 files changed, 145 insertions(+), 18 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 733ddb9ca..dcc1fbcab 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5866,6 +5866,21 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " //char specialized_flow_name[64];\n" //" //sprintf(specialized_flow_name, \"%s_%s_%%d\", parametrized_iterator); // modifying the name causes find_target_flow to fail!\n" " //specialization_array_of_current_flow[parametrized_iterator].name = strdup(specialized_flow_name);\n" + "\n" + " // Keep the dep_index of each dep of each specialized flow\n" + " /*for( int j=0; jdep_index += parametrized_iterator;\n" + " }\n" + " for( int j=0; jdep_index += parametrized_iterator;\n" + " }\n" + " }*/\n" ); coutput(" }\n"); @@ -5929,6 +5944,21 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" }\n"); + coutput( + "#if defined(PARSEC_DEBUG_PARANOID)\n" + " // use parsec_debug_dump_task_class_at_exec(tc); on each task class\n" + " parsec_debug_verbose(2, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(2, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(2, parsec_debug_output, \"############ Task classes after unrolling parametrized flows ############\");\n" + " parsec_debug_verbose(2, parsec_debug_output, \"##\");\n" + " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" + " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" + " parsec_debug_dump_task_class_at_exec(tc);\n" + " parsec_check_sanity_of_task_class(tc);\n" + " }\n" + "#endif\n" + ); + /*for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { @@ -6131,7 +6161,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput( " // Shift the deps that are after dep (which references the parametrized flow)\n" - " parsec_shift_all_deps_after_and_update_tc(tc, flow, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n\n", + " parsec_shift_all_deps_after_and_update_tc(tc, flow, dep, flow_in_out, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n\n", jdf_basename, call->func_or_mem, call->var ); @@ -6232,7 +6262,105 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); - coutput(" // Finally, set the correct indices for the parametrized flows and the referrers\n"); + coutput( + "#if defined(PARSEC_DEBUG_PARANOID)\n" + " // use parsec_debug_dump_task_class_at_exec(tc); on each task class\n" + " parsec_debug_verbose(2, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(2, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(2, parsec_debug_output, \"############ Task classes after unrolling referrers ############\");\n" + " parsec_debug_verbose(2, parsec_debug_output, \"##\");\n" + " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" + " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" + " parsec_debug_dump_task_class_at_exec(tc);\n" + " parsec_check_sanity_of_task_class(tc);\n" + " }\n" + "#endif\n" + ); + + + coutput(" // at this point, all the parametrized flows have been created, but the structure can have some incoherencies:\n"); + coutput(" // - when a parametrized flow is unrolled, the deps are not copied in memory\n"); + coutput(" // - the dep_index is not correct (there can be duplicates in a task class)\n"); + coutput(" // The next block of code will fix these issues\n"); + coutput(" {\n"); + + + coutput(" // First, ensure that there is no duplicate pointer\n"); + + coutput(" for(int tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++) {\n"); + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid];\n"); + coutput(" parsec_dep_t *found_deps[MAX_DEP_IN_COUNT*MAX_DATAFLOWS_PER_TASK];\n"); + coutput(" int found_deps_count = 0; // unique found input deps\n"); + coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); + coutput(" parsec_flow_t *flow = tc->in[flow_id];\n"); + coutput(" if(NULL == flow) break;\n"); + coutput(" for(int depid = 0; depid < MAX_DEP_IN_COUNT; depid++) {\n"); + coutput(" parsec_dep_t *dep = flow->dep_in[depid];\n"); + coutput(" if(NULL == dep) break;\n"); + coutput(" if(parsec_helper_dep_is_in_flow_array(dep, found_deps, found_deps_count)) {\n"); + coutput(" // duplicate: create a new dep and copy the content\n"); + coutput(" dep = parsec_helper_copy_dep(malloc(sizeof(parsec_dep_t)), dep);\n"); + coutput(" flow->dep_in[depid] = dep;\n"); + coutput(" }\n"); + coutput(" assert(found_deps_count < MAX_DEP_IN_COUNT*MAX_DATAFLOWS_PER_TASK);\n"); + coutput(" found_deps[found_deps_count++] = dep;\n"); + coutput(" }\n"); + coutput(" }\n"); + coutput(" found_deps_count = 0; // unique found output deps\n"); + coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); + coutput(" parsec_flow_t *flow = tc->out[flow_id];\n"); + coutput(" if(NULL == flow) break;\n"); + coutput(" for(int depid = 0; depid < MAX_DEP_OUT_COUNT; depid++) {\n"); + coutput(" parsec_dep_t *dep = flow->dep_out[depid];\n"); + coutput(" if(NULL == dep) break;\n"); + coutput(" if(parsec_helper_dep_is_in_flow_array(dep, found_deps, found_deps_count)) {\n"); + coutput(" // duplicate: create a new dep and copy the content\n"); + coutput(" dep = parsec_helper_copy_dep(malloc(sizeof(parsec_dep_t)), dep);\n"); + coutput(" flow->dep_out[depid] = dep;\n"); + coutput(" }\n"); + coutput(" assert(found_deps_count < MAX_DEP_OUT_COUNT*MAX_DATAFLOWS_PER_TASK);\n"); + coutput(" found_deps[found_deps_count++] = dep;\n"); + coutput(" }\n"); + coutput(" }\n"); + coutput(" }\n"); + + coutput(" // Second, fix the dep_indexes\n"); + coutput(" // We know that the dep_indexes are ascending inside a flow and between flows, which make removing duplicates easier\n"); + + coutput(" for(int int_out = 0; int_out < 2; int_out++) {\n"); + coutput(" for(int tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++) {\n"); + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid];\n"); + coutput(" int current_max_dep_id = 0; // Max dep_id of this task_class\n"); + coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++, ++current_max_dep_id) {\n"); + coutput(" parsec_flow_t *flow = (int_out?tc->out:tc->in)[flow_id];\n"); + coutput(" if(NULL == flow) break;\n"); + coutput(" for(int depid = 0; depid < (int_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); depid++) {\n"); + coutput(" parsec_dep_t *dep = (int_out?flow->dep_out:flow->dep_in)[depid];\n"); + coutput(" if(NULL == dep) break;\n"); + coutput(" int current_dep_index = dep->dep_index;\n"); + coutput(" if(current_dep_index < current_max_dep_id) {\n"); + coutput(" // dep_index is not correct: set all the corresponding dep_index to current_max_dep_id\n"); + coutput(" for(; dep && dep->dep_index == current_dep_index; ++depid, dep = (int_out?flow->dep_out:flow->dep_in)[depid]) {\n"); + coutput(" dep->dep_index = current_max_dep_id;\n"); + coutput(" }\n"); + coutput(" --depid; // we went one step too far\n"); + coutput(" ++current_max_dep_id;\n"); + coutput(" }\n"); + coutput(" else {\n"); + coutput(" current_max_dep_id = current_dep_index;\n"); + coutput(" }\n"); + coutput(" }\n"); + coutput(" }\n"); + coutput(" }\n"); + coutput(" }\n"); + + + //coutput(" for(int tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++) {\n"); + + coutput(" }\n"); + + + coutput(" // Finally, retrieve the correct indices for the parametrized flows and the referrers\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { @@ -6477,10 +6605,10 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput( "#if defined(PARSEC_DEBUG_PARANOID)\n" " // use parsec_debug_dump_task_class_at_exec(tc); on each task class\n" - " parsec_debug_verbose(10, parsec_debug_output, \"##\");\n" - " parsec_debug_verbose(10, parsec_debug_output, \"##\");\n" - " parsec_debug_verbose(10, parsec_debug_output, \"############ Task classes after update ############\");\n" - " parsec_debug_verbose(10, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(2, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(2, parsec_debug_output, \"##\");\n" + " parsec_debug_verbose(2, parsec_debug_output, \"############ Task classes after update ############\");\n" + " parsec_debug_verbose(2, parsec_debug_output, \"##\");\n" " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" " parsec_debug_dump_task_class_at_exec(tc);\n" diff --git a/parsec/task_class.c b/parsec/task_class.c index eafcbf550..74d03998b 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -153,7 +153,7 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * { pivot_index = i; - // - Update all the dep_index > pivot_index + // - Update all the dep_index > pivot_index (MODIFICATION: DONT TO THIS) // - find last_flow_index (needed for performing the actual shift at the end) for (i = pivot_index + 1; i < MAX_DATAFLOWS_PER_TASK; i++) { @@ -169,8 +169,8 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * if(!dep) break; // no more dep - if(dep->dep_index > pivot_index) - dep->dep_index += shift*(i-pivot_index); + // if(dep->dep_index > pivot_index) // MODIFICATION: DONT TO THIS + // dep->dep_index += shift*(i-pivot_index); } if(!flow) break; // end of the array @@ -299,9 +299,8 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * }*/ } -void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int shift) +void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int dep_in_out, int shift) { - /* int pivot_dep_index; // Look for the pivot dep @@ -358,9 +357,9 @@ void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_f // Shift the dep (dep_in_out ? flow->dep_out : flow->dep_in)[i + shift] = dep; } -*/ +/* // keep track of the deps that have been treated parsec_dep_t *treated_deps[MAX_DEP_IN_COUNT + MAX_DEP_OUT_COUNT]; int treated_deps_size = 0; @@ -389,7 +388,7 @@ void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_f } } } - +*/ /* // The datatype_mask should stay the same, as we do not add any datatype // Also shift the flow's flow_datatype_mask @@ -449,13 +448,13 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) if (PARSEC_LOCAL_DATA_TASK_CLASS_ID == dep->task_class_id) { - parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s linked with data collection", - dep_in_out ? "->" : "<-", j, flow->name); + parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] (addr=%p) of flow %s linked with data collection", + dep_in_out ? "->" : "<-", j, dep, flow->name); } else if (dep->flow) { - parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] of flow %s is has dep_id=%d and goes to flow %s (id=%d) of task class %d", - dep_in_out ? "->" : "<-", j, flow->name, dep->dep_index, dep->flow->name, + parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] (addr=%p) of flow %s is has dep_id=%d and goes to flow %s (id=%d) of task class %d", + dep_in_out ? "->" : "<-", j, dep, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, dep->task_class_id); } else diff --git a/parsec/task_class.h b/parsec/task_class.h index ddffe3b6f..18180735f 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -13,7 +13,7 @@ // The shift functions creates spaces in the relevant arrays void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t *pivot_flow, int in_out, int shift); -void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int shift); +void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int dep_in_out, int shift); // in all flows fl (fl!=flow), increase deps by shift //void parsec_update_dep_index_in_other_flows(parsec_task_class_t *tc, parsec_flow_t *flow, int dep_in_out, int dep_index, int shift); From e1f11448214a7076a31614499fb586f636d5034e Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 30 Nov 2022 11:59:08 -0500 Subject: [PATCH 111/157] create field to store action masks --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 42 +++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index dcc1fbcab..b9f46c5da 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1743,7 +1743,24 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) coutput("\ntypedef struct parsec_%s_%s_task_class_s {\n", jdf_basename, f->fname); coutput(" parsec_task_class_t super;\n"); - // First parametrized flows: + // Masks: + // If any flow/dep is parametrized/referrer, all the action masks have to be dynamically computed + coutput(" // Action masks of %s\n", f->fname); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + int depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } + + coutput(" uint32_t action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d;\n", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep)); + } + } + + // Parametrized flows: coutput(" // Local parametrized flows of %s\n#if defined(PARSEC_DEBUG_NOISIER)\n", f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { @@ -1759,7 +1776,7 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) } } - // Then the referrers + // Referrers coutput(" // Local referrers of %s\n", f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { int depid=1; @@ -5025,7 +5042,24 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "static parsec_%s_task_class_t spec_%s = {\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); string_arena_add_string(sa, " .super = %s\n", JDF_OBJECT_ONAME(f)); - // First parametrized flows: + // Masks: + // If any flow/dep is parametrized/referrer, all the action masks have to be dynamically computed + string_arena_add_string(sa, " // Action masks of %s\n", f->fname); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + int depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } + + string_arena_add_string(sa, " , .action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d = 0x0\n", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep)); + } + } + + // Parametrized flows: string_arena_add_string(sa, " // Local parametrized flows of %s\n", f->fname); string_arena_add_string(sa, "#if defined(PARSEC_DEBUG_NOISIER)\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { @@ -5043,7 +5077,7 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f } } - // Then the referrers + // Referrers string_arena_add_string(sa, " // Local referrers of %s\n", f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { int depid=1; From 4d7dadadbaa57a10f810ffcc94aedea6867a4b50 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 30 Nov 2022 12:47:01 -0500 Subject: [PATCH 112/157] set the action masks --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 85 ++++++++++++++++++++-- 1 file changed, 80 insertions(+), 5 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index b9f46c5da..39b7d87e3 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6550,6 +6550,11 @@ static void jdf_generate_new_function( const jdf_t* jdf ) for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { depid=1; for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } + for( int target_call=0; target_call<2; ++target_call ) { assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) @@ -6559,11 +6564,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; assert(call); - if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) - { // We only need the out indices - continue; - } - if( NULL != call->parametrized_offset ) { coutput(" { // Parametrized referrer %s of task class %s\n", df->varname, f->fname); @@ -6634,6 +6634,81 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } + coutput(" // Update masks for task classes that need them\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + depid=1; + for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + { // We only need the out indices + continue; + } + + coutput(" { // Output dep %d of %s_%s\n", depid, f->fname, df->varname); + coutput(" parsec_dep_t *dep;\n"); + coutput(" int specializations_number;\n"); + for( int target_call=0; target_call<2; ++target_call ) { + assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); + if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) + { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY + continue; + } + jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; + assert(call); + + if(dep->guard->guard_type==JDF_GUARD_TERNARY) { + coutput(" // call%s\n", target_call?"false":"true"); + } + + if( NULL != call->parametrized_offset ) + { + jdf_function_entry_t *targetf = find_target_function(jdf, call->func_or_mem); + jdf_dataflow_t *target_flow = find_target_flow(jdf, targetf, call->var); + assert(targetf && target_flow); + if(FLOW_IS_PARAMETRIZED(df) && !FLOW_IS_PARAMETRIZED(target_flow)) + { + coutput(" dep = &flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + } + else + { + coutput(" dep = &%s_referrer_dep%d_atline_%d%s[0];\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + } + + coutput(" specializations_number = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", + jdf_basename, targetf->fname, target_flow->varname); + + coutput(" // Parametrized call: multiple set bits\n"); + coutput(" spec_%s.action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d |= ((1<<(specializations_number+1))-1)<<(dep->dep_index);\n", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep)); + } + else + { + coutput(" dep = &%s_dep%d_atline_%d%s;\n", + JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), + // If ternary, add _iftrue or _iffalse + (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); + coutput(" spec_%s.action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d |= 1<<(dep->dep_index);\n", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, df->varname, + depid, JDF_OBJECT_LINENO(dep)); + } + } + coutput(" }\n"); + } + } + } + } + coutput("\n"); coutput( From 815c696c1a558125ddc17f0f6d8dc27f3a07136e Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 30 Nov 2022 15:26:45 -0500 Subject: [PATCH 113/157] maybe its useless to store a mask for output deps --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 39b7d87e3..19e32adae 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1743,6 +1743,7 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) coutput("\ntypedef struct parsec_%s_%s_task_class_s {\n", jdf_basename, f->fname); coutput(" parsec_task_class_t super;\n"); +/* // Masks: // If any flow/dep is parametrized/referrer, all the action masks have to be dynamically computed coutput(" // Action masks of %s\n", f->fname); @@ -1759,6 +1760,7 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) depid, JDF_OBJECT_LINENO(dep)); } } +*/ // Parametrized flows: coutput(" // Local parametrized flows of %s\n#if defined(PARSEC_DEBUG_NOISIER)\n", f->fname); @@ -5042,6 +5044,7 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "static parsec_%s_task_class_t spec_%s = {\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); string_arena_add_string(sa, " .super = %s\n", JDF_OBJECT_ONAME(f)); +/* // Masks: // If any flow/dep is parametrized/referrer, all the action masks have to be dynamically computed string_arena_add_string(sa, " // Action masks of %s\n", f->fname); @@ -5058,6 +5061,7 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f depid, JDF_OBJECT_LINENO(dep)); } } +*/ // Parametrized flows: string_arena_add_string(sa, " // Local parametrized flows of %s\n", f->fname); @@ -6634,6 +6638,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } +/* // Apparently it's not output dep_index that needs a mask, but the input flow coutput(" // Update masks for task classes that need them\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { @@ -6708,6 +6713,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } } +*/ coutput("\n"); @@ -10455,6 +10461,21 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, } } + +/* +// Get iterator strings +string_arena_t *sa_action_mask = string_arena_new(16); // second iterator in case of referrer inside a parametrized flow +string_arena_add_string(sa_action_mask, "0x%x", (1U << dl->dep_index)); +if(FLOW_IS_PARAMETRIZED(df)) +{ + string_arena_add_string(sa_it2_name, "%s", df->local_variables->alias); + if(strcmp(string_arena_get_string(sa_it_name), string_arena_get_string(sa_it2_name)) == 0) { + string_arena_add_string(sa_it2_name, "_2"); // avoid name clash + } +} +*/ + + switch( dl->guard->guard_type ) { case JDF_GUARD_UNCONDITIONAL: if( NULL != dl->guard->calltrue->var) { From 96183f4fb1195946efca7455dc3f8f7f95fcf296 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 30 Nov 2022 16:26:34 -0500 Subject: [PATCH 114/157] use proper dataflow masks --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 124 ++++++++++++++------- 1 file changed, 82 insertions(+), 42 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 19e32adae..6461af754 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1743,24 +1743,26 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) coutput("\ntypedef struct parsec_%s_%s_task_class_s {\n", jdf_basename, f->fname); coutput(" parsec_task_class_t super;\n"); -/* // Masks: // If any flow/dep is parametrized/referrer, all the action masks have to be dynamically computed coutput(" // Action masks of %s\n", f->fname); - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - int depid=1; - for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { - if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) - { // We only need the out indices - continue; - } + // for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + // int depid=1; + // for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + // if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + // { // We only need the out indices + // continue; + // } - coutput(" uint32_t action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d;\n", - jdf_basename, f->fname, df->varname, - depid, JDF_OBJECT_LINENO(dep)); - } + // coutput(" uint32_t action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d;\n", + // jdf_basename, f->fname, df->varname, + // depid, JDF_OBJECT_LINENO(dep)); + // } + // } + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + coutput(" uint32_t action_mask_of_flow_of_%s_%s_for_%s;\n", + jdf_basename, f->fname, df->varname); } -*/ // Parametrized flows: coutput(" // Local parametrized flows of %s\n#if defined(PARSEC_DEBUG_NOISIER)\n", f->fname); @@ -5044,24 +5046,27 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, "static parsec_%s_task_class_t spec_%s = {\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); string_arena_add_string(sa, " .super = %s\n", JDF_OBJECT_ONAME(f)); -/* // Masks: // If any flow/dep is parametrized/referrer, all the action masks have to be dynamically computed string_arena_add_string(sa, " // Action masks of %s\n", f->fname); - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - int depid=1; - for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { - if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) - { // We only need the out indices - continue; - } + // for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + // int depid=1; + // for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { + // if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) + // { // We only need the out indices + // continue; + // } - string_arena_add_string(sa, " , .action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d = 0x0\n", - jdf_basename, f->fname, df->varname, - depid, JDF_OBJECT_LINENO(dep)); - } + // string_arena_add_string(sa, " , .action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d = 0x0\n", + // jdf_basename, f->fname, df->varname, + // depid, JDF_OBJECT_LINENO(dep)); + // } + // } + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + string_arena_add_string(sa, " , .action_mask_of_flow_of_%s_%s_for_%s = 0x0\n", + jdf_basename, f->fname, df->varname); } -*/ + // Parametrized flows: string_arena_add_string(sa, " // Local parametrized flows of %s\n", f->fname); @@ -6714,6 +6719,39 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } */ + coutput(" // Update masks for task classes that need them\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { + coutput(" { // task class %s\n", f->fname); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + coutput(" { // Flow %s of task class %s\n", df->varname, f->fname); + + if(FLOW_IS_PARAMETRIZED(df)) + { + // get the first parametrized specialization + coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_parametrized_%s[0];\n", + jdf_basename, f->fname, df->varname); + coutput(" int specializations_number = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", + jdf_basename, f->fname, df->varname); + coutput(" spec_%s.action_mask_of_flow_of_%s_%s_for_%s = ((1<<(specializations_number+1))-1)<flow_index;\n", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, df->varname); + } + else + { + coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", + jdf_basename, f->fname, df->varname); + coutput(" spec_%s.action_mask_of_flow_of_%s_%s_for_%s = 1<flow_index;\n", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, df->varname); + } + coutput(" }\n"); + } + coutput(" }\n"); + } + } + + coutput("\n"); @@ -10460,20 +10498,6 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, } } } - - -/* -// Get iterator strings -string_arena_t *sa_action_mask = string_arena_new(16); // second iterator in case of referrer inside a parametrized flow -string_arena_add_string(sa_action_mask, "0x%x", (1U << dl->dep_index)); -if(FLOW_IS_PARAMETRIZED(df)) -{ - string_arena_add_string(sa_it2_name, "%s", df->local_variables->alias); - if(strcmp(string_arena_get_string(sa_it_name), string_arena_get_string(sa_it2_name)) == 0) { - string_arena_add_string(sa_it2_name, "_2"); // avoid name clash - } -} -*/ switch( dl->guard->guard_type ) { @@ -10634,15 +10658,31 @@ if(FLOW_IS_PARAMETRIZED(df)) } else if( 1 == flowempty ) { coutput(" /* Flow of data %s has only OUTPUT dependencies to Memory */\n", fl->varname); } else { + + // Get the action mask for this flow as a string + string_arena_t *sa_action_mask = string_arena_new(128); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { + // dynamic masks if any flow/dep is parametrized + string_arena_add_string(sa_action_mask, "spec_%s.action_mask_of_flow_of_%s_%s_for_%s", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, fl->varname); + } + else + { + // static masks if no parametrization in this task class + string_arena_add_string(sa_action_mask, "0x%x", (flow_type & JDF_DEP_FLOW_OUT) ? fl->flow_dep_mask_out : fl->flow_dep_mask_in/*mask*/); + } + + /*if(FLOW_IS_PARAMETRIZED(fl)) { } else*/ { - coutput(" if( action_mask & 0x%x ) { /* Flow of data %s [%d] */\n" + coutput(" if( action_mask & %s ) { /* Flow of data %s [%d] */\n" "%s" " }\n", - (flow_type & JDF_DEP_FLOW_OUT) ? fl->flow_dep_mask_out : fl->flow_dep_mask_in/*mask*/, fl->varname, fl->flow_index, + string_arena_get_string(sa_action_mask), fl->varname, fl->flow_index, string_arena_get_string(sa_coutput)/*IFBODY*/); } } From aadbe607b16801eb95bb22911cd14b35e3ec6c4c Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 30 Nov 2022 18:10:23 -0500 Subject: [PATCH 115/157] fix bug, not flow_index is correct --- parsec/task_class.c | 2 +- tests/dsl/ptg/choice/choice2.jdf | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index 74d03998b..02559c8f7 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -179,7 +179,7 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * // - Shift the flows // - Update the flow_index of the flows - for (i = last_flow_index; i >= pivot_index; i--) + for (i = last_flow_index; i > pivot_index; i--) { flow = ((in_out) ? (tc->out) : (tc->in))[i]; ((in_out) ? (tc->out) : (tc->in))[i+shift] = flow; diff --git a/tests/dsl/ptg/choice/choice2.jdf b/tests/dsl/ptg/choice/choice2.jdf index e9c25d2f1..8807a561f 100644 --- a/tests/dsl/ptg/choice/choice2.jdf +++ b/tests/dsl/ptg/choice/choice2.jdf @@ -19,7 +19,7 @@ RW D <- D Selector(k, k) -> %{ return (k < NT) && idecision(pos) == 1; %} ? D TA(k, k) -> %{ return (k < NT) && idecision(pos) == 2; %} ? D TB(k, k) RW C <- decision( pos ) [type_remote=DECISION] - -> A LChoice( k, 0 .. P-1 ) [type_remote=DECISION] + -> A2 LChoice( k, 0 .. P-1 ) [type_remote=DECISION] BODY { @@ -71,7 +71,7 @@ first = %{ : decision( k*P + p ) -READ A <- C GenChoice( k ) [type_remote=DECISION] +READ A2 <- C GenChoice( k ) [type_remote=DECISION] RW C <- decision( k*P + p ) [type_remote=DECISION] -> decision( k*P + p ) [type_remote=DECISION] CTL ct <- (k > 0) ? ct LChoice(k-1, P) From c768d80a56ea31c696683e5affa4b34c2c15aaf7 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 30 Nov 2022 18:24:17 -0500 Subject: [PATCH 116/157] flows can no more be shifted twice --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 3 +- parsec/task_class.c | 89 ++++++++++++---------- parsec/task_class.h | 2 +- 3 files changed, 51 insertions(+), 43 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 6461af754..6922ab143 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5893,8 +5893,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" const parsec_flow_t *base_flow_of_current_flow = base_flow_of_parametrized_flows[parametrized_flow_id];\n"); coutput( " // Shift the flows that are after the parametrized flow\n" - " parsec_shift_all_flows_after(tc, base_flow_of_current_flow, 0, nb_specializations_of_current_flow-1); // in\n" - " parsec_shift_all_flows_after(tc, base_flow_of_current_flow, 1, nb_specializations_of_current_flow-1); // out\n" + " parsec_shift_all_flows_after(tc, base_flow_of_current_flow, nb_specializations_of_current_flow-1);\n" "\n" ); coutput( diff --git a/parsec/task_class.c b/parsec/task_class.c index 02559c8f7..1249fb24e 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -123,7 +123,7 @@ bool parsec_helper_dep_is_in_flow_array(const parsec_dep_t *dep, parsec_dep_t *d * If in_out==0, shift the input flows, otherwise shift the output flows * */ -void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t *pivot_flow, int in_out, int shift) +void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t *pivot_flow, int shift) { int i, j; int flow_in_out; @@ -133,57 +133,66 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * parsec_dep_t *dep; // use an array to keep track of the flows we already treated - parsec_flow_t *treated_flows[MAX_DATAFLOWS_PER_TASK]; - int treated_flows_size = 0; + parsec_flow_t *shifted_flows[MAX_DATAFLOWS_PER_TASK]; + int shifted_flows_size = 0; // Determine which array should be used (in or out) depending on in_out //parsec_flow_t **flow_array = (parsec_flow_t **) ((in_out) ? (tc->out) : (tc->in)); - const int max_dep_count = (in_out) ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT; parsec_dep_t **dep_array; - // find the pivot flow - for (i = 0; i < MAX_DATAFLOWS_PER_TASK; ++i) - { - if(pivot_flow == ((in_out) ? (tc->out) : (tc->in))[i]) - break; // pivot flow found - if(!((in_out) ? (tc->out) : (tc->in))[i]) - return; // pivot not found - } - if(pivot_flow == ((in_out) ? (tc->out) : (tc->in))[i]) - { - pivot_index = i; + // The flows will be shifted both in th "in" and "out" arrays + for (int in_out = 0; in_out < 2; ++in_out) { + const int max_dep_count = (in_out) ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT; - // - Update all the dep_index > pivot_index (MODIFICATION: DONT TO THIS) - // - find last_flow_index (needed for performing the actual shift at the end) - for (i = pivot_index + 1; i < MAX_DATAFLOWS_PER_TASK; i++) + // find the pivot flow + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; ++i) { - flow = ((in_out) ? (tc->out) : (tc->in))[i]; - if(!flow) - break; // end of the array - - dep_array = (in_out) ? flow->dep_out : flow->dep_in; + if(pivot_flow == ((in_out) ? (tc->out) : (tc->in))[i]) + break; // pivot flow found + if(!((in_out) ? (tc->out) : (tc->in))[i]) + return; // pivot not found + } + if(pivot_flow == ((in_out) ? (tc->out) : (tc->in))[i]) + { + pivot_index = i; - for(j=0; j pivot_index (MODIFICATION: DONT TO THIS) + // - find last_flow_index (needed for performing the actual shift at the end) + for (i = pivot_index + 1; i < MAX_DATAFLOWS_PER_TASK; i++) { - dep = dep_array[j]; + flow = ((in_out) ? (tc->out) : (tc->in))[i]; + if(!flow) + break; // end of the array + + dep_array = (in_out) ? flow->dep_out : flow->dep_in; - if(!dep) - break; // no more dep - // if(dep->dep_index > pivot_index) // MODIFICATION: DONT TO THIS - // dep->dep_index += shift*(i-pivot_index); + for(j=0; jdep_index > pivot_index) // MODIFICATION: DONT TO THIS + // dep->dep_index += shift*(i-pivot_index); + } + if(!flow) + break; // end of the array } - if(!flow) - break; // end of the array - } - last_flow_index = i - 1; + last_flow_index = i - 1; - // - Shift the flows - // - Update the flow_index of the flows - for (i = last_flow_index; i > pivot_index; i--) - { - flow = ((in_out) ? (tc->out) : (tc->in))[i]; - ((in_out) ? (tc->out) : (tc->in))[i+shift] = flow; - flow->flow_index += shift; + // - Shift the flows + // - Update the flow_index of the flows + for (i = last_flow_index; i > pivot_index; i--) + { + flow = ((in_out) ? (tc->out) : (tc->in))[i]; + ((in_out) ? (tc->out) : (tc->in))[i+shift] = flow; + if(!parsec_helper_flow_is_in_flow_array(flow, shifted_flows, shifted_flows_size)) + { + flow->flow_index += shift; + shifted_flows[shifted_flows_size] = flow; + shifted_flows_size++; + } + } } } diff --git a/parsec/task_class.h b/parsec/task_class.h index 18180735f..89f818bd6 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -12,7 +12,7 @@ #include "parsec_internal.h" // The shift functions creates spaces in the relevant arrays -void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t *pivot_flow, int in_out, int shift); +void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t *pivot_flow, int shift); void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int dep_in_out, int shift); // in all flows fl (fl!=flow), increase deps by shift From 77980922d94fbbddb79c7ee4794b8e05d51eef8b Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 6 Feb 2023 14:23:56 +0100 Subject: [PATCH 117/157] correct the part to set a unique dep_id per task class --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 23 +++++++++++----------- parsec/task_class.c | 2 +- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 6922ab143..523753bdd 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6328,11 +6328,11 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" // First, ensure that there is no duplicate pointer\n"); - + coutput("#if defined(PARSEC_DEBUG_PARANOID)\n"); coutput(" for(int tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++) {\n"); coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid];\n"); coutput(" parsec_dep_t *found_deps[MAX_DEP_IN_COUNT*MAX_DATAFLOWS_PER_TASK];\n"); - coutput(" int found_deps_count = 0; // unique found input deps\n"); + coutput(" int found_deps_count = 0; // unique found INPUT deps\n"); coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); coutput(" parsec_flow_t *flow = tc->in[flow_id];\n"); coutput(" if(NULL == flow) break;\n"); @@ -6348,7 +6348,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" found_deps[found_deps_count++] = dep;\n"); coutput(" }\n"); coutput(" }\n"); - coutput(" found_deps_count = 0; // unique found output deps\n"); + coutput(" found_deps_count = 0; // unique found OUTPUT deps\n"); coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); coutput(" parsec_flow_t *flow = tc->out[flow_id];\n"); coutput(" if(NULL == flow) break;\n"); @@ -6365,15 +6365,16 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" }\n"); coutput(" }\n"); coutput(" }\n"); + coutput("#endif\n"); + coutput("\n"); coutput(" // Second, fix the dep_indexes\n"); - coutput(" // We know that the dep_indexes are ascending inside a flow and between flows, which make removing duplicates easier\n"); - + coutput(" // We want to make sure that the dep_indexes are unique per task class\n"); coutput(" for(int int_out = 0; int_out < 2; int_out++) {\n"); coutput(" for(int tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++) {\n"); coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid];\n"); coutput(" int current_max_dep_id = 0; // Max dep_id of this task_class\n"); - coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++, ++current_max_dep_id) {\n"); + coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); coutput(" parsec_flow_t *flow = (int_out?tc->out:tc->in)[flow_id];\n"); coutput(" if(NULL == flow) break;\n"); coutput(" for(int depid = 0; depid < (int_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); depid++) {\n"); @@ -6381,14 +6382,12 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" if(NULL == dep) break;\n"); coutput(" int current_dep_index = dep->dep_index;\n"); coutput(" if(current_dep_index < current_max_dep_id) {\n"); - coutput(" // dep_index is not correct: set all the corresponding dep_index to current_max_dep_id\n"); - coutput(" for(; dep && dep->dep_index == current_dep_index; ++depid, dep = (int_out?flow->dep_out:flow->dep_in)[depid]) {\n"); + coutput(" // dep_index is not unique: set all the corresponding dep_index to current_max_dep_id + 1\n"); + coutput(" current_max_dep_id++;\n"); + coutput(" for(; dep && dep->dep_index == current_dep_index; dep = (int_out?flow->dep_out:flow->dep_in)[depid]) {\n"); coutput(" dep->dep_index = current_max_dep_id;\n"); coutput(" }\n"); - coutput(" --depid; // we went one step too far\n"); - coutput(" ++current_max_dep_id;\n"); - coutput(" }\n"); - coutput(" else {\n"); + coutput(" } else {\n"); coutput(" current_max_dep_id = current_dep_index;\n"); coutput(" }\n"); coutput(" }\n"); diff --git a/parsec/task_class.c b/parsec/task_class.c index 1249fb24e..199755947 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -462,7 +462,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) } else if (dep->flow) { - parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] (addr=%p) of flow %s is has dep_id=%d and goes to flow %s (id=%d) of task class %d", + parsec_debug_verbose(1, parsec_debug_output, " %s dep [%d] (addr=%p) of flow %s has dep_id=%d and goes to flow %s (id=%d) of task class %d", dep_in_out ? "->" : "<-", j, dep, flow->name, dep->dep_index, dep->flow->name, dep->flow->flow_index, dep->task_class_id); } From 0adf2a1253e5baac2ebfbcb7a15dbec0c140e4fa Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 6 Feb 2023 15:15:16 +0100 Subject: [PATCH 118/157] correct the fixing of the dep_index --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 29 ++++++++++++++-------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 523753bdd..8b749bab5 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6369,28 +6369,37 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); coutput(" // Second, fix the dep_indexes\n"); - coutput(" // We want to make sure that the dep_indexes are unique per task class\n"); + coutput(" // We want to make sure that the dep_indexes are unique per task class, except for the ternaries where duplicates are mandatory\n"); + coutput(" // The idea of the algorithm is to compute the proper lifting for each flow (i.e.: current_max_dep_id_task_class - current_min_dep_id_flow)\n"); coutput(" for(int int_out = 0; int_out < 2; int_out++) {\n"); coutput(" for(int tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++) {\n"); coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid];\n"); - coutput(" int current_max_dep_id = 0; // Max dep_id of this task_class\n"); + coutput(" int current_max_dep_id_task_class = 0; // Max dep_id of this task class\n"); coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); coutput(" parsec_flow_t *flow = (int_out?tc->out:tc->in)[flow_id];\n"); + coutput(" // We look for the min and max, because we need them to compute the exact lifting\n"); + coutput(" int current_min_dep_id_flow = INT_MAX; // Min dep_id of this flow\n"); + coutput(" int current_max_dep_id_flow = 0; // Max dep_id of this flow\n\n"); coutput(" if(NULL == flow) break;\n"); + coutput(" // First compute the max dep_id of this flow\n"); coutput(" for(int depid = 0; depid < (int_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); depid++) {\n"); coutput(" parsec_dep_t *dep = (int_out?flow->dep_out:flow->dep_in)[depid];\n"); coutput(" if(NULL == dep) break;\n"); coutput(" int current_dep_index = dep->dep_index;\n"); - coutput(" if(current_dep_index < current_max_dep_id) {\n"); - coutput(" // dep_index is not unique: set all the corresponding dep_index to current_max_dep_id + 1\n"); - coutput(" current_max_dep_id++;\n"); - coutput(" for(; dep && dep->dep_index == current_dep_index; dep = (int_out?flow->dep_out:flow->dep_in)[depid]) {\n"); - coutput(" dep->dep_index = current_max_dep_id;\n"); - coutput(" }\n"); - coutput(" } else {\n"); - coutput(" current_max_dep_id = current_dep_index;\n"); + coutput(" if(current_dep_index > current_max_dep_id_flow) {\n"); + coutput(" current_max_dep_id_flow = current_dep_index;\n"); coutput(" }\n"); + coutput(" if(current_dep_index < current_min_dep_id_flow) {\n"); + coutput(" current_min_dep_id_flow = current_dep_index;\n"); + coutput(" }\n"); + coutput(" }\n"); + coutput(" // Secondly, increase each dep_id of this flow by current_max_dep_id_task_class+1\n"); + coutput(" for(int depid = 0; depid < (int_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); depid++) {\n"); + coutput(" parsec_dep_t *dep = (int_out?flow->dep_out:flow->dep_in)[depid];\n"); + coutput(" if(NULL == dep) break;\n"); + coutput(" dep->dep_index += current_max_dep_id_task_class - current_min_dep_id_flow;\n"); coutput(" }\n"); + coutput(" current_max_dep_id_task_class += current_max_dep_id_flow-current_min_dep_id_flow+1;\n"); coutput(" }\n"); coutput(" }\n"); coutput(" }\n"); From a8f378749ce55c4ed4dd33903da1d87ec990bf54 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 6 Feb 2023 19:05:13 +0100 Subject: [PATCH 119/157] solve the problem where an ABC flow placed before a parametrized flow crashed --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 8b749bab5..9e2df915b 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -3680,7 +3680,7 @@ static void jdf_generate_startup_tasks(const jdf_t *jdf, const jdf_function_entr if( FLOW_IS_PARAMETRIZED(dataflow) ) { - expr_info_t expr_info = EMPTY_EXPR_INFO;coutput("coucou\n"); + expr_info_t expr_info = EMPTY_EXPR_INFO; expr_info.sa = string_arena_new(32); expr_info.prefix = ""; expr_info.suffix = ""; @@ -9891,8 +9891,15 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, dep_ld = jdf_expr_lv_next(dep->local_defs, dep_ld); continue; /* This local define was already issued as part of the dep */ } - string_arena_add_string(sa_open, "%s%s int %s;\n", prefix, indent(nbopen), ld->alias); - if(JDF_RANGE == ld->op || JDF_PARAMETRIZED_FLOW_RANGE == ld->op) { + if(JDF_PARAMETRIZED_FLOW_RANGE != ld->op) + { // The range is handled in an upper-level loop in iterate_successors + string_arena_add_string(sa_open, "%s%s int %s;\n", prefix, indent(nbopen), ld->alias); + } + else + { + string_arena_add_string(sa_open, "%s%s // do not declare %s, it is a parametrized flow range\n", prefix, indent(nbopen), ld->alias); + } + if(JDF_RANGE == ld->op/* || JDF_PARAMETRIZED_FLOW_RANGE == ld->op*/) { string_arena_add_string(sa_open, "%s%sfor( %s = %s;", prefix, indent(nbopen), ld->alias, dump_expr((void**)ld->jdf_ta1, &local_info)); @@ -9904,9 +9911,19 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, prefix, indent(nbopen), ld->ldef_index, ld->alias); nbopen++; } else { - string_arena_add_string(sa_open, + if(JDF_PARAMETRIZED_FLOW_RANGE == ld->op) + { + // We do not iterate over the parametrized flow because it is already being looped on in iterate_successors + string_arena_add_string(sa_open, + "%s%s "JDF2C_NAMESPACE"_tmp_locals.ldef[%d].value = %s;\n", + prefix, indent(nbopen), ld->ldef_index, ld->alias); + } + else + { + string_arena_add_string(sa_open, "%s%s "JDF2C_NAMESPACE"_tmp_locals.ldef[%d].value = %s = %s;\n", prefix, indent(nbopen), ld->ldef_index, ld->alias, dump_expr((void**)ld, &local_info)); + } } } } From 0ac6b67da4f8201e4d228eb3fa403560ebe628fc Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 6 Feb 2023 19:37:26 +0100 Subject: [PATCH 120/157] correct parametrized flow masks --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 9e2df915b..c96b10c85 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6740,7 +6740,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_basename, f->fname, df->varname); coutput(" int specializations_number = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", jdf_basename, f->fname, df->varname); - coutput(" spec_%s.action_mask_of_flow_of_%s_%s_for_%s = ((1<<(specializations_number+1))-1)<flow_index;\n", + coutput(" spec_%s.action_mask_of_flow_of_%s_%s_for_%s = ((1<<(specializations_number))-1)<flow_index;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); } From 440bacf8fe7f2382a7611e773de7ce90c097fad4 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 7 Feb 2023 18:37:31 +0100 Subject: [PATCH 121/157] use a dynamic task_class-level dynamic action_mask --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 30 ++++++++++++++++-- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 31 +++++++++++++------ 2 files changed, 50 insertions(+), 11 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index c96b10c85..dd5f94c04 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1763,6 +1763,9 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) coutput(" uint32_t action_mask_of_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } + // action_mask for the entire task class + coutput(" uint32_t action_mask_of_flow_of_%s_%s;\n", + jdf_basename, f->fname); // Parametrized flows: coutput(" // Local parametrized flows of %s\n#if defined(PARSEC_DEBUG_NOISIER)\n", f->fname); @@ -5066,6 +5069,8 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f string_arena_add_string(sa, " , .action_mask_of_flow_of_%s_%s_for_%s = 0x0\n", jdf_basename, f->fname, df->varname); } + string_arena_add_string(sa, " , .action_mask_of_flow_of_%s_%s = 0x0\n", + jdf_basename, f->fname); // Parametrized flows: @@ -6730,6 +6735,9 @@ static void jdf_generate_new_function( const jdf_t* jdf ) for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { coutput(" { // task class %s\n", f->fname); + + coutput(" // spec_%s.action_mask_of_flow_of_%s_%s = 0; // should already be set to 0\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { coutput(" { // Flow %s of task class %s\n", df->varname, f->fname); @@ -6752,8 +6760,12 @@ static void jdf_generate_new_function( const jdf_t* jdf ) JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); } + coutput(" spec_%s.action_mask_of_flow_of_%s_%s |= spec_%s.action_mask_of_flow_of_%s_%s_for_%s; // should already be set to 0\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" }\n"); } + coutput(" }\n"); } } @@ -8293,17 +8305,31 @@ static void jdf_generate_code_call_release_dependencies(const jdf_t *jdf, jdf_dataflow_t* dl; (void)jdf; + char complete_mask_str[92]; + for( dl = function->dataflow; dl != NULL; dl = dl->next ) { complete_mask |= dl->flow_dep_mask_out; } + + // if the task class has any parametrized flow is referrer, the mask can not be computed at compile time + if(0)//TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(function)) + { + snprintf(complete_mask_str, 92, "spec_%s.action_mask_of_flow_of_%s_%s", + JDF_OBJECT_ONAME(function), jdf_basename, function->fname); + } + else + { + snprintf(complete_mask_str, 92, "0x%x", complete_mask); + } + coutput(" release_deps_of_%s_%s(es, %s,\n" " PARSEC_ACTION_RELEASE_REMOTE_DEPS |\n" " PARSEC_ACTION_RELEASE_LOCAL_DEPS |\n" " PARSEC_ACTION_RELEASE_LOCAL_REFS |\n" " PARSEC_ACTION_RESHAPE_ON_RELEASE |\n" - " 0x%x, /* mask of all dep_index */ \n" + " %s, /* mask of all dep_index */ \n" " NULL);\n", - jdf_basename, function->fname, context_name, complete_mask); + jdf_basename, function->fname, context_name, complete_mask_str); } /** diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index dd34e277a..22751e5bb 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -138,23 +138,19 @@ static inline int jdf_any_flow_is_parametrized_util(const jdf_t *jdf) } /** - * FLOW_IS_PARAMETRIZED_OR_ANY_DEP_IS_REFERRER + * FLOW_ANY_DEP_IS_REFERRER * - * Tells whether a flow is parametrized or not, or if any of its dependencies is a referrer. + * Tells whether any dependency of a flow is a referrer. * * @param [IN] flow: the flow to test. * * @return a boolean value. */ -#define FLOW_IS_PARAMETRIZED_OR_ANY_DEP_IS_REFERRER(flow) \ - flow_is_parametrized_or_any_dep_is_referrer_util(flow) +#define FLOW_ANY_DEP_IS_REFERRER(flow) \ + flow_any_dep_is_referrer_util(flow) -static inline int flow_is_parametrized_or_any_dep_is_referrer_util(const jdf_dataflow_t *flow) +static inline int flow_any_dep_is_referrer_util(const jdf_dataflow_t *flow) { - if (FLOW_IS_PARAMETRIZED(flow)) { - return 1; - } - for( jdf_dep_t *dep = flow->deps; NULL != dep; dep = dep->next ) { for( int target_call=0; target_call<2; ++target_call ) { assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); @@ -175,6 +171,23 @@ static inline int flow_is_parametrized_or_any_dep_is_referrer_util(const jdf_dat return 0; } +/** + * FLOW_IS_PARAMETRIZED_OR_ANY_DEP_IS_REFERRER + * + * Tells whether a flow is parametrized or not, or if any of its dependencies is a referrer. + * + * @param [IN] flow: the flow to test. + * + * @return a boolean value. + */ +#define FLOW_IS_PARAMETRIZED_OR_ANY_DEP_IS_REFERRER(flow) \ + flow_is_parametrized_or_any_dep_is_referrer_util(flow) + +static inline int flow_is_parametrized_or_any_dep_is_referrer_util(const jdf_dataflow_t *flow) +{ + return FLOW_IS_PARAMETRIZED(flow) || FLOW_ANY_DEP_IS_REFERRER(flow); +} + /** * TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER: * Tells whether any flow is parametrized or if one of the deps is a referrer. From 9ea0e213f82424b4b81e4a7bed9bf4a929eabe84 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 8 Feb 2023 18:45:00 +0100 Subject: [PATCH 122/157] rework action_masks, there is something wrong --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 244 ++++++++++----------- parsec/task_class.c | 32 +-- parsec/task_class.h | 2 +- 3 files changed, 133 insertions(+), 145 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index dd5f94c04..1750931d8 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1746,25 +1746,12 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) // Masks: // If any flow/dep is parametrized/referrer, all the action masks have to be dynamically computed coutput(" // Action masks of %s\n", f->fname); - // for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - // int depid=1; - // for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { - // if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) - // { // We only need the out indices - // continue; - // } - - // coutput(" uint32_t action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d;\n", - // jdf_basename, f->fname, df->varname, - // depid, JDF_OBJECT_LINENO(dep)); - // } - // } for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - coutput(" uint32_t action_mask_of_flow_of_%s_%s_for_%s;\n", + coutput(" uint32_t dep_mask_out_of_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } // action_mask for the entire task class - coutput(" uint32_t action_mask_of_flow_of_%s_%s;\n", + coutput(" uint32_t dep_mask_out_of_flow_of_%s_%s;\n", jdf_basename, f->fname); // Parametrized flows: @@ -5052,24 +5039,11 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f // Masks: // If any flow/dep is parametrized/referrer, all the action masks have to be dynamically computed string_arena_add_string(sa, " // Action masks of %s\n", f->fname); - // for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - // int depid=1; - // for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { - // if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) - // { // We only need the out indices - // continue; - // } - - // string_arena_add_string(sa, " , .action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d = 0x0\n", - // jdf_basename, f->fname, df->varname, - // depid, JDF_OBJECT_LINENO(dep)); - // } - // } for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - string_arena_add_string(sa, " , .action_mask_of_flow_of_%s_%s_for_%s = 0x0\n", + string_arena_add_string(sa, " , .dep_mask_out_of_flow_of_%s_%s_for_%s = 0x0\n", jdf_basename, f->fname, df->varname); } - string_arena_add_string(sa, " , .action_mask_of_flow_of_%s_%s = 0x0\n", + string_arena_add_string(sa, " , .dep_mask_out_of_flow_of_%s_%s = 0x0\n", jdf_basename, f->fname); @@ -5493,7 +5467,7 @@ static void jdf_generate_constructor( const jdf_t* jdf ) " tc->release_task = parsec_release_task_to_mempool_and_count_as_runtime_tasks;\n" "\n" "#if defined(PARSEC_DEBUG_PARANOID)\n" - " parsec_check_sanity_of_task_class(tc);\n" + " parsec_check_sanity_of_task_class(tc, true);\n" "#endif\n" " }\n", jdf_basename, @@ -5594,7 +5568,7 @@ static void jdf_generate_constructor( const jdf_t* jdf ) " for( uint32_t i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" " parsec_debug_dump_task_class_at_exec(tc);\n" - " parsec_check_sanity_of_task_class(tc);\n" + " parsec_check_sanity_of_task_class(tc, true);\n" " }\n" "#endif\n" "}\n\n", @@ -6001,7 +5975,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" " parsec_debug_dump_task_class_at_exec(tc);\n" - " parsec_check_sanity_of_task_class(tc);\n" + " parsec_check_sanity_of_task_class(tc, false);\n" " }\n" "#endif\n" ); @@ -6319,7 +6293,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" " parsec_debug_dump_task_class_at_exec(tc);\n" - " parsec_check_sanity_of_task_class(tc);\n" + " parsec_check_sanity_of_task_class(tc, false);\n" " }\n" "#endif\n" ); @@ -6373,22 +6347,42 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("#endif\n"); coutput("\n"); + coutput(" /*// (set the flow_datatype_mask's of out flows to zero)\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) + { + if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) + { + coutput(" { // %s\n", f->fname); + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n", f->task_class_id); + coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); + coutput(" parsec_flow_t *flow = tc->out[flow_id];\n"); + coutput(" if(NULL == flow) break;\n"); + coutput(" flow->flow_datatype_mask = 0;\n"); + coutput(" }\n"); + coutput(" }\n"); + } + } + coutput("*/\n"); + + coutput(" // Second, fix the dep_indexes\n"); coutput(" // We want to make sure that the dep_indexes are unique per task class, except for the ternaries where duplicates are mandatory\n"); coutput(" // The idea of the algorithm is to compute the proper lifting for each flow (i.e.: current_max_dep_id_task_class - current_min_dep_id_flow)\n"); - coutput(" for(int int_out = 0; int_out < 2; int_out++) {\n"); + coutput(" for(int in_out = 0; in_out < 2; in_out++) {\n"); coutput(" for(int tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++) {\n"); coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid];\n"); coutput(" int current_max_dep_id_task_class = 0; // Max dep_id of this task class\n"); coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); - coutput(" parsec_flow_t *flow = (int_out?tc->out:tc->in)[flow_id];\n"); + coutput(" parsec_flow_t *flow = (in_out?tc->out:tc->in)[flow_id];\n"); + coutput(" //if(in_out == 1)\n"); + coutput(" // flow->flow_datatype_mask = 0;\n"); coutput(" // We look for the min and max, because we need them to compute the exact lifting\n"); coutput(" int current_min_dep_id_flow = INT_MAX; // Min dep_id of this flow\n"); coutput(" int current_max_dep_id_flow = 0; // Max dep_id of this flow\n\n"); coutput(" if(NULL == flow) break;\n"); coutput(" // First compute the max dep_id of this flow\n"); - coutput(" for(int depid = 0; depid < (int_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); depid++) {\n"); - coutput(" parsec_dep_t *dep = (int_out?flow->dep_out:flow->dep_in)[depid];\n"); + coutput(" for(int depid = 0; depid < (in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); depid++) {\n"); + coutput(" parsec_dep_t *dep = (in_out?flow->dep_out:flow->dep_in)[depid];\n"); coutput(" if(NULL == dep) break;\n"); coutput(" int current_dep_index = dep->dep_index;\n"); coutput(" if(current_dep_index > current_max_dep_id_flow) {\n"); @@ -6399,10 +6393,12 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" }\n"); coutput(" }\n"); coutput(" // Secondly, increase each dep_id of this flow by current_max_dep_id_task_class+1\n"); - coutput(" for(int depid = 0; depid < (int_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); depid++) {\n"); - coutput(" parsec_dep_t *dep = (int_out?flow->dep_out:flow->dep_in)[depid];\n"); + coutput(" for(int depid = 0; depid < (in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); depid++) {\n"); + coutput(" parsec_dep_t *dep = (in_out?flow->dep_out:flow->dep_in)[depid];\n"); coutput(" if(NULL == dep) break;\n"); coutput(" dep->dep_index += current_max_dep_id_task_class - current_min_dep_id_flow;\n"); + coutput(" //if(in_out==1)\n"); + coutput(" // flow->flow_datatype_mask |= 1<dep_index; // keep the flow_datatype_mask up-to-date\n"); coutput(" }\n"); coutput(" current_max_dep_id_task_class += current_max_dep_id_flow-current_min_dep_id_flow+1;\n"); coutput(" }\n"); @@ -6655,88 +6651,13 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } -/* // Apparently it's not output dep_index that needs a mask, but the input flow - coutput(" // Update masks for task classes that need them\n"); - for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { - if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { - for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - depid=1; - for( jdf_dep_t *dep = df->deps; NULL != dep; dep = dep->next, depid++ ) { - if((dep->dep_flags & JDF_DEP_FLOW_OUT) == 0) - { // We only need the out indices - continue; - } - - coutput(" { // Output dep %d of %s_%s\n", depid, f->fname, df->varname); - coutput(" parsec_dep_t *dep;\n"); - coutput(" int specializations_number;\n"); - for( int target_call=0; target_call<2; ++target_call ) { - assert(dep->guard->guard_type==JDF_GUARD_UNCONDITIONAL || dep->guard->guard_type==JDF_GUARD_BINARY || dep->guard->guard_type==JDF_GUARD_TERNARY); - if(dep->guard->guard_type!=JDF_GUARD_TERNARY && target_call==1) - { // callfalse is only relevant for JDF_GUARD_UNCONDITIONAL and JDF_GUARD_BINARY - continue; - } - jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; - assert(call); - - if(dep->guard->guard_type==JDF_GUARD_TERNARY) { - coutput(" // call%s\n", target_call?"false":"true"); - } - - if( NULL != call->parametrized_offset ) - { - jdf_function_entry_t *targetf = find_target_function(jdf, call->func_or_mem); - jdf_dataflow_t *target_flow = find_target_flow(jdf, targetf, call->var); - assert(targetf && target_flow); - if(FLOW_IS_PARAMETRIZED(df) && !FLOW_IS_PARAMETRIZED(target_flow)) - { - coutput(" dep = &flow_of_%s_%s_for_%s_dep%d_atline_%d%s;\n", - jdf_basename, f->fname, df->varname, - depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - } - else - { - coutput(" dep = &%s_referrer_dep%d_atline_%d%s[0];\n", - JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - } - - coutput(" specializations_number = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", - jdf_basename, targetf->fname, target_flow->varname); - - coutput(" // Parametrized call: multiple set bits\n"); - coutput(" spec_%s.action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d |= ((1<<(specializations_number+1))-1)<<(dep->dep_index);\n", - JDF_OBJECT_ONAME(f), - jdf_basename, f->fname, df->varname, - depid, JDF_OBJECT_LINENO(dep)); - } - else - { - coutput(" dep = &%s_dep%d_atline_%d%s;\n", - JDF_OBJECT_ONAME(df), depid, JDF_OBJECT_LINENO(dep), - // If ternary, add _iftrue or _iffalse - (dep->guard->guard_type==JDF_GUARD_TERNARY) ? ((target_call)?"_iffalse":"_iftrue") : ""); - coutput(" spec_%s.action_mask_of_flow_of_%s_%s_for_%s_dep%d_atline_%d |= 1<<(dep->dep_index);\n", - JDF_OBJECT_ONAME(f), - jdf_basename, f->fname, df->varname, - depid, JDF_OBJECT_LINENO(dep)); - } - } - coutput(" }\n"); - } - } - } - } -*/ + // Apparently it's not output dep_index that needs a mask, but the input flow coutput(" // Update masks for task classes that need them\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { coutput(" { // task class %s\n", f->fname); - coutput(" // spec_%s.action_mask_of_flow_of_%s_%s = 0; // should already be set to 0\n", + coutput(" // spec_%s.dep_mask_out_of_flow_of_%s_%s = 0; // should already be set to 0\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { coutput(" { // Flow %s of task class %s\n", df->varname, f->fname); @@ -6748,7 +6669,10 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_basename, f->fname, df->varname); coutput(" int specializations_number = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", jdf_basename, f->fname, df->varname); - coutput(" spec_%s.action_mask_of_flow_of_%s_%s_for_%s = ((1<<(specializations_number))-1)<flow_index;\n", + coutput(" spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s = ((1<<(specializations_number))-1)<flow_index;\n", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, df->varname); + coutput(" //spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s = flow->flow_datatype_mask;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); } @@ -6756,13 +6680,15 @@ static void jdf_generate_new_function( const jdf_t* jdf ) { coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); - coutput(" spec_%s.action_mask_of_flow_of_%s_%s_for_%s = 1<flow_index;\n", + coutput(" spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s = 1<flow_index;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); } - coutput(" spec_%s.action_mask_of_flow_of_%s_%s |= spec_%s.action_mask_of_flow_of_%s_%s_for_%s; // should already be set to 0\n", + coutput(" spec_%s.dep_mask_out_of_flow_of_%s_%s |= spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + coutput(" //flow->flow_datatype_mask = spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s;\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" }\n"); } @@ -6784,7 +6710,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " for( int i = 0; i < __parsec_tp->super.super.nb_task_classes; i++ ) {\n" " parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[i];\n" " parsec_debug_dump_task_class_at_exec(tc);\n" - " parsec_check_sanity_of_task_class(tc);\n" + " parsec_check_sanity_of_task_class(tc, true);\n" " }\n" "#endif\n" ); @@ -8312,9 +8238,9 @@ static void jdf_generate_code_call_release_dependencies(const jdf_t *jdf, } // if the task class has any parametrized flow is referrer, the mask can not be computed at compile time - if(0)//TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(function)) + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(function)) { - snprintf(complete_mask_str, 92, "spec_%s.action_mask_of_flow_of_%s_%s", + snprintf(complete_mask_str, 92, "spec_%s.dep_mask_out_of_flow_of_%s_%s", JDF_OBJECT_ONAME(function), jdf_basename, function->fname); } else @@ -8442,8 +8368,22 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, //string_arena *sa_parametrized_flow = string_arena_new(256); //string_arena_init(sa_parametrized_flow); - string_arena_add_string(sa_coutput, "if( (*flow_mask) & 0x%xU ) { /* Flow %s */\n", - (type == JDF_DEP_FLOW_OUT ? fl->flow_dep_mask_out : (1U << fl->flow_index)), fl->varname); + // Get the action mask for this flow as a string + string_arena_t *sa_action_mask = string_arena_new(128); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { + // dynamic masks if any flow/dep is parametrized + string_arena_add_string(sa_action_mask, "spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, fl->varname); + } + else + { + // static masks if no parametrization in this task class + string_arena_add_string(sa_action_mask, "0x%xU", (type == JDF_DEP_FLOW_OUT ? fl->flow_dep_mask_out : (1U << fl->flow_index))); + } + + string_arena_add_string(sa_coutput, "if( (*flow_mask) & %s ) { /* Flow %s */\n", + string_arena_get_string(sa_action_mask), fl->varname); dump_parametrized_flow_loop_if_parametrized(fl, " ", sa_coutput); @@ -8525,8 +8465,10 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa_coutput); - string_arena_add_string(sa_coutput, "} /* (flow_mask & 0x%xU) */\n", - (type == JDF_DEP_FLOW_OUT ? fl->flow_dep_mask_out : (1U << fl->flow_index))); + string_arena_add_string(sa_coutput, "} /* (flow_mask & %s) */\n", + string_arena_get_string(sa_action_mask)); + + string_arena_free(sa_action_mask); } if( type == JDF_DEP_FLOW_IN ) { @@ -10207,6 +10149,23 @@ static void jdf_check_relatives( jdf_function_entry_t *f, jdf_dep_flags_t flow_t string_arena_init((SA_DATATYPE)); \ } +// Version if something is parametrized in the task class (then, we cannot use flow_dep_mask_out) +#define OUTPUT_PREV_DEPS_PARAMETRIZED(MASK_STR, SA_DATATYPE, SA_DEPS) \ + if( strlen(string_arena_get_string((SA_DEPS))) ) { \ + if( strlen(string_arena_get_string((SA_DATATYPE))) ) { \ + string_arena_add_string(sa_coutput, \ + " %s", \ + string_arena_get_string((SA_DATATYPE))); \ + } \ + string_arena_add_string(sa_coutput, \ + " if( action_mask & %s ) {\n" \ + " %s" \ + " }\n", \ + MASK_STR, string_arena_get_string((SA_DEPS))); \ + string_arena_init((SA_DEPS)); \ + string_arena_init((SA_DATATYPE)); \ + } + char *dump_flow_offset_for_iterate_successors(string_arena_t *sa, const jdf_function_entry_t *f, const jdf_dataflow_t *flow, const jdf_call_t *call) { string_arena_init(sa); @@ -10694,8 +10653,26 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, break; } depnb++; + /* Dump the previous dependencies */ - OUTPUT_PREV_DEPS((1U << dl->dep_index), sa_datatype, sa_deps); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) + { + // Get the action mask for this flow as a string + string_arena_t *sa_action_mask = string_arena_new(128); + + string_arena_add_string(sa_action_mask, "spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, fl->varname); + + + OUTPUT_PREV_DEPS_PARAMETRIZED(string_arena_get_string(sa_action_mask), sa_datatype, sa_deps); + + string_arena_free(sa_action_mask); + } + else + { + OUTPUT_PREV_DEPS((1U << dl->dep_index), sa_datatype, sa_deps); + } while(nb_open_ldef > 0) { string_arena_add_string(sa_coutput, "%s }\n", indent(nb_open_ldef)); @@ -10713,14 +10690,14 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_t *sa_action_mask = string_arena_new(128); if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { // dynamic masks if any flow/dep is parametrized - string_arena_add_string(sa_action_mask, "spec_%s.action_mask_of_flow_of_%s_%s_for_%s", + string_arena_add_string(sa_action_mask, "spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, fl->varname); } else { // static masks if no parametrization in this task class - string_arena_add_string(sa_action_mask, "0x%x", (flow_type & JDF_DEP_FLOW_OUT) ? fl->flow_dep_mask_out : fl->flow_dep_mask_in/*mask*/); + string_arena_add_string(sa_action_mask, "0x%xU", (flow_type & JDF_DEP_FLOW_OUT) ? fl->flow_dep_mask_out : fl->flow_dep_mask_in/*mask*/); } @@ -10735,6 +10712,13 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_get_string(sa_action_mask), fl->varname, fl->flow_index, string_arena_get_string(sa_coutput)/*IFBODY*/); } + /*if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { + coutput(" assert(spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s == 0x%x);\n", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, fl->varname, + fl->flow_dep_mask_in); + }*/ + string_arena_free(sa_action_mask); } } coutput(" (void)data;(void)nc;(void)es;(void)ontask;(void)ontask_arg;(void)rank_dst;(void)action_mask;\n"); diff --git a/parsec/task_class.c b/parsec/task_class.c index 199755947..c059e70a0 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -485,7 +485,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) /* Checks if the task class is valid (for debugging purposes) */ -void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) +void parsec_check_sanity_of_task_class(parsec_task_class_t *tc, bool check_dep_index) { int i, j; int flow_in_out, dep_in_out; @@ -530,26 +530,30 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc) } // Check the coherency of the flow flags - for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) + if(check_dep_index) { - const parsec_flow_t *flow = tc->out[i]; - - if (!flow) + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { - break; - } + const parsec_flow_t *flow = tc->out[i]; - // For each output dep of the flow ... - for (j = 0; j < (dep_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) - { - dep = flow->dep_out[j]; - if (!dep) + if (!flow) { break; } - // All out dependencies should be in the flow datatype mask - assert((1 << dep->dep_datatype_index) & flow->flow_datatype_mask); + // For each output dep of the flow ... + for (j = 0; j < (dep_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) + { + dep = flow->dep_out[j]; + if (!dep) + { + break; + } + + // All out dependencies should be in the flow datatype mask + assert((1 << dep->dep_datatype_index) & flow->flow_datatype_mask); + //assert((1 << dep->dep_index) & flow->flow_datatype_mask); + } } } diff --git a/parsec/task_class.h b/parsec/task_class.h index 89f818bd6..366378fd0 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -23,7 +23,7 @@ bool parsec_helper_flow_is_in_flow_array(const parsec_flow_t *flow, parsec_flow_ bool parsec_helper_dep_is_in_flow_array(const parsec_dep_t *dep, parsec_dep_t *dep_array[], int dep_array_size); void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc); -void parsec_check_sanity_of_task_class(parsec_task_class_t *tc); +void parsec_check_sanity_of_task_class(parsec_task_class_t *tc, bool check_dep_index); // Copy a flow (including its deps) and returns a pointer to the new flow parsec_flow_t *parsec_helper_copy_flow(parsec_flow_t *flow_to, const parsec_flow_t *flow_from); From 68600e9a1d88cff73dc82dc71c7f025b50f76c26 Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 9 Feb 2023 17:38:15 +0100 Subject: [PATCH 123/157] keep the dep_datatype_index up-to-date as well --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 1750931d8..5c3445330 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5893,6 +5893,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " parsec_dep_t *dep = specialization_array_of_current_flow[parametrized_iterator].dep_in[j];\n" " if(!dep) break;\n" " dep->dep_index += parametrized_iterator;\n" + " dep->dep_datatype_index += parametrized_iterator;\n" " }\n" " for( int j=0; jdep_index += parametrized_iterator;\n" + " dep->dep_datatype_index += parametrized_iterator;\n" " }\n" " }*/\n" ); @@ -6374,8 +6376,8 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" int current_max_dep_id_task_class = 0; // Max dep_id of this task class\n"); coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); coutput(" parsec_flow_t *flow = (in_out?tc->out:tc->in)[flow_id];\n"); - coutput(" //if(in_out == 1)\n"); - coutput(" // flow->flow_datatype_mask = 0;\n"); + coutput(" if(in_out == 1)\n"); + coutput(" flow->flow_datatype_mask = 0;\n"); coutput(" // We look for the min and max, because we need them to compute the exact lifting\n"); coutput(" int current_min_dep_id_flow = INT_MAX; // Min dep_id of this flow\n"); coutput(" int current_max_dep_id_flow = 0; // Max dep_id of this flow\n\n"); @@ -6397,8 +6399,9 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" parsec_dep_t *dep = (in_out?flow->dep_out:flow->dep_in)[depid];\n"); coutput(" if(NULL == dep) break;\n"); coutput(" dep->dep_index += current_max_dep_id_task_class - current_min_dep_id_flow;\n"); - coutput(" //if(in_out==1)\n"); - coutput(" // flow->flow_datatype_mask |= 1<dep_index; // keep the flow_datatype_mask up-to-date\n"); + coutput(" dep->dep_datatype_index += current_max_dep_id_task_class - current_min_dep_id_flow;\n"); + coutput(" if(in_out==1)\n"); + coutput(" flow->flow_datatype_mask |= 1<dep_index; // keep the flow_datatype_mask up-to-date\n"); coutput(" }\n"); coutput(" current_max_dep_id_task_class += current_max_dep_id_flow-current_min_dep_id_flow+1;\n"); coutput(" }\n"); @@ -8457,7 +8460,7 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, } /* update the mask before the next dump */ - current_mask |= (type == JDF_DEP_FLOW_OUT ? (1U << dl->dep_index) : (1U << fl->flow_index)); + current_mask |= (type == JDF_DEP_FLOW_OUT ? (1U << dl->dep_index) : (1U << fl->flow_index)); // TODO if( !continue_dependencies ) break; } From c85219e5ee387d31e29886e9acac674cc4aa2903 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 10 Feb 2023 12:09:53 +0100 Subject: [PATCH 124/157] start using a variable to get the flow_id --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 99 ++++++++++++------- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 22 +++++ 2 files changed, 87 insertions(+), 34 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 5c3445330..07d42c48b 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7365,9 +7365,30 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * (void)pred_var; /*final_check = case predecessor has set up stuff on our data */ - string_arena_t *osa; - osa = string_arena_new(64); + string_arena_t *osa = string_arena_new(64); + string_arena_t *sa_consumed_flow_index = string_arena_new(256); + string_arena_t *sa_pred_consumed_flow_index = string_arena_new(256); string_arena_init(osa); + string_arena_init(sa_consumed_flow_index); + string_arena_init(sa_pred_consumed_flow_index); + + + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) + { + DUMP_FLOW_ID_VARIABLE(sa_pred_consumed_flow_index, jdf_basename, pred_f, pred_flow); + } + else + { + string_arena_add_string(sa_pred_consumed_flow_index, "%d", pred_flow->flow_index); + } + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) + { + DUMP_FLOW_ID_VARIABLE(sa_consumed_flow_index, jdf_basename, f, flow); + } + else + { + string_arena_add_string(sa_consumed_flow_index, "%d", flow->flow_index); + } if( final_check ){ @@ -7379,54 +7400,56 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow)); /* Is this current task repo or predecessor repo? Different flow index */ - coutput("%s if( (reshape_entry != NULL) && (reshape_entry->data[%d] != NULL) ){\n" + coutput("%s if( (reshape_entry != NULL) && (reshape_entry->data[%s] != NULL) ){\n" "%s /* Reshape promise set up on input by predecessor is on this task repo */\n" - "%s consumed_flow_index = %d;\n", - spaces, flow->flow_index, + "%s consumed_flow_index = %s;\n", + spaces, string_arena_get_string(sa_consumed_flow_index), spaces, - spaces, flow->flow_index); + spaces, string_arena_get_string(sa_consumed_flow_index)); coutput("%s assert( (this_task->data.%s.source_repo == reshape_repo)\n" "%s && (this_task->data.%s.source_repo_entry == reshape_entry));\n", spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), spaces, DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow)); coutput("%s }else{\n" "%s /* Reshape promise set up on input by predecessor is the predecesssor task repo */\n" - "%s consumed_flow_index = %d;\n" + "%s consumed_flow_index = %s;\n" "%s }\n", spaces, spaces, - spaces, pred_flow->flow_index, + spaces, string_arena_get_string(sa_pred_consumed_flow_index), spaces); }else{ - coutput("%s if( (reshape_entry != NULL) && (reshape_entry->data[%d] != NULL) ){\n" + coutput("%s if( (reshape_entry != NULL) && (reshape_entry->data[%s] != NULL) ){\n" "%s /* Reshape promise set up on this task repo by predecessor */\n" "%s consumed_repo = reshape_repo;\n" "%s consumed_entry = reshape_entry;\n" "%s consumed_entry_key = reshape_entry_key;\n" - "%s consumed_flow_index = %d;\n", - spaces, flow->flow_index, + "%s consumed_flow_index = %s;\n", + spaces, string_arena_get_string(sa_consumed_flow_index), spaces, spaces, spaces, spaces, - spaces, flow->flow_index); + spaces, string_arena_get_string(sa_consumed_flow_index)); coutput("%s }else{\n" "%s /* Consume from predecessor's repo */\n" "%s consumed_repo = %s_repo;\n" "%s consumed_entry_key = %s((const parsec_taskpool_t*)__parsec_tp, (const parsec_assignment_t*)target_locals) ;\n" "%s consumed_entry = data_repo_lookup_entry( consumed_repo, consumed_entry_key );\n" - "%s consumed_flow_index = %d;\n" + "%s consumed_flow_index = %s;\n" "%s }\n", spaces, spaces, spaces, pred_name, spaces, jdf_property_get_string(pred_f->properties, JDF_PROP_UD_MAKE_KEY_FN_NAME, NULL), spaces, - spaces, pred_flow->flow_index, + spaces, string_arena_get_string(sa_pred_consumed_flow_index), spaces); } string_arena_free(osa); + string_arena_free(sa_consumed_flow_index); + string_arena_free(sa_pred_consumed_flow_index); } static void @@ -8266,12 +8289,12 @@ static void jdf_generate_code_call_release_dependencies(const jdf_t *jdf, * allows us to delay the code generation in order to merge together multiple deps * using the same datatype, count and displacement. */ -#define JDF_CODE_DATATYPE_DUMP(SA_WHERE, MASK, SA_COND, SA_DATATYPE, SKIP_COND) \ +#define JDF_CODE_DATATYPE_DUMP(SA_WHERE, MASK, MASK_STR, SA_COND, SA_DATATYPE, SKIP_COND) \ do { \ if( strlen(string_arena_get_string((SA_DATATYPE))) ) { \ string_arena_add_string((SA_WHERE), \ - " if( ((*flow_mask) & 0x%xU)", \ - (MASK)); \ + " if( ((*flow_mask) & %s)", \ + (MASK_STR)); \ if( strlen(string_arena_get_string((SA_COND))) ) { \ if( !(SKIP_COND) ) { \ string_arena_add_string((SA_WHERE), \ @@ -8285,10 +8308,10 @@ static void jdf_generate_code_call_release_dependencies(const jdf_t *jdf, (SKIP_COND) = 0; \ string_arena_add_string((SA_WHERE), \ "%s" \ - " (*flow_mask) &= ~0x%xU;\n" \ + " (*flow_mask) &= ~%s;\n" \ " return PARSEC_HOOK_RETURN_NEXT;\n", \ string_arena_get_string((SA_DATATYPE)), \ - (MASK)); \ + (MASK_STR)); \ string_arena_add_string((SA_WHERE), " }\n"); \ if( strlen(string_arena_get_string((SA_COND))) ) { \ string_arena_init((SA_COND)); \ @@ -8299,6 +8322,7 @@ static void jdf_generate_code_call_release_dependencies(const jdf_t *jdf, } while(0) +// TODO: needs to be changed for parametrized flows (the masks won't work) static void jdf_generate_code_datatype_lookup(const jdf_t *jdf, const jdf_function_entry_t *f, @@ -8308,19 +8332,20 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, assignment_info_t ai; jdf_dataflow_t *fl; jdf_dep_t *dl; - string_arena_t *sa_coutput = string_arena_new(1024); - string_arena_t *sa_deps = string_arena_new(1024); - string_arena_t *sa_datatype = string_arena_new(1024); - string_arena_t *sa_arena = string_arena_new(256); - string_arena_t *sa_tmp_arena = string_arena_new(256); - string_arena_t *sa_count = string_arena_new(256); - string_arena_t *sa_tmp_count = string_arena_new(256); - string_arena_t *sa_displ = string_arena_new(256); - string_arena_t *sa_tmp_displ = string_arena_new(256); - string_arena_t *sa_type = string_arena_new(256); - string_arena_t *sa_tmp_type = string_arena_new(256); - string_arena_t *sa_cond = string_arena_new(256); - string_arena_t *sa_temp = string_arena_new(256); + string_arena_t *sa_coutput = string_arena_new(1024); + string_arena_t *sa_deps = string_arena_new(1024); + string_arena_t *sa_datatype = string_arena_new(1024); + string_arena_t *sa_arena = string_arena_new(256); + string_arena_t *sa_tmp_arena = string_arena_new(256); + string_arena_t *sa_count = string_arena_new(256); + string_arena_t *sa_tmp_count = string_arena_new(256); + string_arena_t *sa_displ = string_arena_new(256); + string_arena_t *sa_tmp_displ = string_arena_new(256); + string_arena_t *sa_type = string_arena_new(256); + string_arena_t *sa_tmp_type = string_arena_new(256); + string_arena_t *sa_cond = string_arena_new(256); + string_arena_t *sa_temp = string_arena_new(256); + string_arena_t *sa_current_mask = string_arena_new(256); int last_datatype_idx, continue_dependencies, type, skip_condition, generate_exit_label = 0; uint32_t current_mask = 0; @@ -8399,13 +8424,16 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, string_arena_init(sa_displ); string_arena_init(sa_type); string_arena_init(sa_cond); + string_arena_init(sa_current_mask); for(dl = fl->deps; NULL != dl; dl = dl->next) { if( !(dl->dep_flags & type) ) continue; /* Prepare the memory layout of the output dependency. */ if( last_datatype_idx != dl->dep_datatype_index ) { - JDF_CODE_DATATYPE_DUMP(sa_coutput, current_mask, sa_cond, sa_datatype, skip_condition); + string_arena_init(sa_current_mask); + string_arena_add_string(sa_current_mask, "0x%xU", current_mask); + JDF_CODE_DATATYPE_DUMP(sa_coutput, current_mask, string_arena_get_string(sa_current_mask), sa_cond, sa_datatype, skip_condition); /************************************/ /* REMOTE DATATYPE USED FOR RECV */ /************************************/ @@ -8464,7 +8492,9 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, if( !continue_dependencies ) break; } - JDF_CODE_DATATYPE_DUMP(sa_coutput, current_mask, sa_cond, sa_datatype, skip_condition); + string_arena_init(sa_current_mask); + string_arena_add_string(sa_current_mask, "0x%xU", current_mask); + JDF_CODE_DATATYPE_DUMP(sa_coutput, current_mask, string_arena_get_string(sa_current_mask), sa_cond, sa_datatype, skip_condition); dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa_coutput); @@ -8521,6 +8551,7 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, string_arena_free(sa_tmp_displ); string_arena_free(sa_tmp_type); string_arena_free(sa_temp); + string_arena_free(sa_current_mask); } static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const jdf_function_entry_t *sourcef, const jdf_dataflow_t *source_flow, int dep_index, const jdf_call_t *source_call, diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 22751e5bb..885d5ae53 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -91,6 +91,28 @@ static inline char *util_dump_data_field_name_in_task(string_arena_t *sa, const return string_arena_get_string(sa); } +/** + * @brief Dumps the flow_id's variable (when the task class has a parametrized flow or a referrer) + * + */ +#define DUMP_FLOW_ID_VARIABLE(sa, jdf_basename, function, flow)\ + util_dump_flow_id_variable(sa, jdf_basename, function, flow) + +static inline char *util_dump_flow_id_variable(string_arena_t *sa, const char *jdf_basename, const jdf_function_entry_t *function, const jdf_dataflow_t *flow) +{ + string_arena_init(sa); + + if( FLOW_IS_PARAMETRIZED(flow) ) { + string_arena_add_string(sa, "(spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s+%s)", + JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); + } else { + string_arena_add_string(sa, "(spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s)", + JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname); + } + + return string_arena_get_string(sa); +} + /** * VARIABLE_IS_FLOW_LEVEL * Tells whether a variable is a flow level variable or not. From e5f46be99a2816536aad466185a0b8768c9ce063 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 10 Feb 2023 18:30:10 +0100 Subject: [PATCH 125/157] add the variables for dynamic flow ids + declare the parametrized iterator in jdf_generate_code_call_initialization --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 212 +++++++++++------- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 23 +- 2 files changed, 152 insertions(+), 83 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 07d42c48b..dab79ec4f 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1749,10 +1749,16 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { coutput(" uint32_t dep_mask_out_of_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + if(!FLOW_IS_PARAMETRIZED(df)) + { + coutput(" uint8_t flow_id_of_flow_of_%s_%s_for_%s;\n", + jdf_basename, f->fname, df->varname); + } } // action_mask for the entire task class coutput(" uint32_t dep_mask_out_of_flow_of_%s_%s;\n", jdf_basename, f->fname); + // Parametrized flows: coutput(" // Local parametrized flows of %s\n#if defined(PARSEC_DEBUG_NOISIER)\n", f->fname); @@ -5042,6 +5048,11 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { string_arena_add_string(sa, " , .dep_mask_out_of_flow_of_%s_%s_for_%s = 0x0\n", jdf_basename, f->fname, df->varname); + if(!FLOW_IS_PARAMETRIZED(df)) + { + string_arena_add_string(sa, " , .flow_id_of_flow_of_%s_%s_for_%s = %d\n", + jdf_basename, f->fname, df->varname, df->flow_index); + } } string_arena_add_string(sa, " , .dep_mask_out_of_flow_of_%s_%s = 0x0\n", jdf_basename, f->fname); @@ -6561,6 +6572,16 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } + coutput(" }\n"); + } + else + { + coutput(" { // Non-parametrized flow %s of task class %s\n", df->varname, f->fname); + + coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_%s, 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname); + coutput(" }\n"); } } @@ -6868,25 +6889,25 @@ char *malloc_and_dump_jdf_expr_list(const jdf_expr_t *el) /** Code Generators */ static char *jdf_create_code_assignments_calls(string_arena_t *sa, int spaces, - const jdf_t *jdf, const char *name, const jdf_call_t *call) + const jdf_t *jdf, const char *name, const jdf_call_t *source_call) { const jdf_expr_t *el; expr_info_t infodst = EMPTY_EXPR_INFO, infosrc = EMPTY_EXPR_INFO; string_arena_t *sa2; - jdf_expr_t *params = call->parameters; + jdf_expr_t *params = source_call->parameters; jdf_variable_list_t *vl; jdf_param_list_t *pl; - const jdf_function_entry_t *f; + const jdf_function_entry_t *targetf; - f = find_target_function(jdf, call->func_or_mem); + targetf = find_target_function(jdf, source_call->func_or_mem); - assert(f != NULL); + assert(targetf != NULL); string_arena_init(sa); sa2 = string_arena_new(64); infodst.sa = sa2; - infodst.prefix = f->fname; + infodst.prefix = targetf->fname; infodst.suffix = ""; infodst.assignments = (char*)name; infosrc.sa = sa2; @@ -6894,10 +6915,10 @@ static char *jdf_create_code_assignments_calls(string_arena_t *sa, int spaces, infosrc.suffix = ""; infosrc.assignments = "&this_task->locals"; - for(vl = f->locals; vl != NULL; vl = vl->next) { + for(vl = targetf->locals; vl != NULL; vl = vl->next) { /* Is this definition a parameter or a value? */ /* If it is a parameter, find the corresponding param in the call */ - for(el = params, pl = f->parameters; pl != NULL; el = el->next, pl = pl->next) { + for(el = params, pl = targetf->parameters; pl != NULL; el = el->next, pl = pl->next) { if( NULL == el ) { /* Badly formulated call */ string_arena_t *sa_caller, *sa_callee; expr_info_t caller = EMPTY_EXPR_INFO; @@ -6911,7 +6932,7 @@ static char *jdf_create_code_assignments_calls(string_arena_t *sa, int spaces, caller.assignments = ""; string_arena_init(sa); - UTIL_DUMP_LIST_FIELD(sa_callee, f->parameters, next, name, + UTIL_DUMP_LIST_FIELD(sa_callee, targetf->parameters, next, name, dump_string, sa, "(", "", ", ", ")"); string_arena_init(sa); @@ -6919,14 +6940,14 @@ static char *jdf_create_code_assignments_calls(string_arena_t *sa, int spaces, dump_expr, (void*)&caller, "(", "", ", ", ")"); fprintf(stderr, "%s.jdf:%d Badly formulated call %s%s instead of %s%s\n", - jdf_basename, call->super.lineno, - f->fname, string_arena_get_string(sa_caller), - f->fname, string_arena_get_string(sa_callee)); + jdf_basename, source_call->super.lineno, + targetf->fname, string_arena_get_string(sa_caller), + targetf->fname, string_arena_get_string(sa_callee)); exit(-1); } assert( el != NULL ); if(!strcmp(pl->name, vl->name)) - break; + break; } string_arena_init(sa2); /** @@ -6936,17 +6957,18 @@ static char *jdf_create_code_assignments_calls(string_arena_t *sa, int spaces, * assignment context, including target locals, or the usage of %inline * will be broken. */ + //name_to_dump = (char*)vl->name; if( NULL == pl ) { /* It is a value. Let's dump it's expression in the destination context */ string_arena_add_string(sa, "%sconst int %s%s = %s->%s.value = %s; (void)%s%s;\n", - indent(spaces), f->fname, vl->name, name, vl->name, dump_expr((void**)vl->expr, &infodst), f->fname, vl->name); + indent(spaces), targetf->fname, vl->name, name, vl->name, dump_expr((void**)vl->expr, &infodst), targetf->fname, vl->name); } else { /* It is a parameter. Let's dump it's expression in the source context */ assert(el != NULL); string_arena_add_string(sa, "%sconst int %s%s = %s->%s.value = %s; (void)%s%s;\n", - indent(spaces), f->fname, vl->name, name, vl->name, dump_expr((void**)el, &infosrc), f->fname, vl->name); + indent(spaces), targetf->fname, vl->name, name, vl->name, dump_expr((void**)el, &infosrc), targetf->fname, vl->name); } } @@ -7365,6 +7387,8 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * (void)pred_var; /*final_check = case predecessor has set up stuff on our data */ + expr_info_t expr_info = EMPTY_EXPR_INFO; + string_arena_t *osa = string_arena_new(64); string_arena_t *sa_consumed_flow_index = string_arena_new(256); string_arena_t *sa_pred_consumed_flow_index = string_arena_new(256); @@ -7390,6 +7414,17 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * string_arena_add_string(sa_consumed_flow_index, "%d", flow->flow_index); } +// if(FLOW_IS_PARAMETRIZED(f_pred)) +// { // If the target is parametrized, we need to set the flow index according to the expression +// for(jdf_variable_list_t *vl = pred_f->locals; vl != NULL; vl = vl->next) { +// coutput("#define %s %s%s\n", vl->name, pred_f->fname, vl->name); +// } +// #error remove // TODO +// coutput("%s %s = %s;\n", +// spaces, pred_f->local_defs->alias, +// dump_expr((void**)pred_f->parametrized_offset, &expr_info)); +// } + if( final_check ){ coutput("%s consumed_repo = this_task->data.%s.source_repo;\n" @@ -7447,6 +7482,14 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * spaces); } + // if(FLOW_IS_PARAMETRIZED(f_pred)) + // { // If the target is parametrized, we need to set the flow index according to the expression + // for(jdf_variable_list_t *vl = pred_f->locals; vl != NULL; vl = vl->next) { + // coutput("#undef %s\n", vl->name); + // } + // } + + string_arena_free(osa); string_arena_free(sa_consumed_flow_index); string_arena_free(sa_pred_consumed_flow_index); @@ -7526,6 +7569,13 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); + if(CALL_IS_PARAMETRIZED(call)) + { + // output the value of the iterator + coutput("%s const int %s = %s; (void)%s;\n", + spaces, call->parametrized_offset->alias, dump_expr((void**)call->parametrized_offset, &info), call->parametrized_offset->alias); + } + /* Code to fulfill a reshape promise set up by predecessor if there's one */ jdf_generate_code_consume_predecessor_setup(jdf, call, f, flow, @@ -8570,75 +8620,77 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const coutput("%s // call%s of dep %d of flow %s of task class %s\n", spaces, is_calltrue?"true":"false", dep_index, target_flow->varname, targetf->fname); coutput("%s {\n", spaces); + int nb_opened_call_locals = 0; + int any_local_is_ranged = 0; + string_arena_init(sa); coutput("%s %s *target_locals = (%s*)&generic_locals;\n", spaces, parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); - //coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); - for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { - // Get the function parameter if it is one - const jdf_expr_t *el; - jdf_expr_t *params = source_call->parameters; - jdf_param_list_t *pl; - for(el = params, pl = targetf->parameters; pl != NULL; el = el->next, pl = pl->next) { - if( NULL == el ) { /* Badly formulated call */ - string_arena_t *sa_caller, *sa_callee; - expr_info_t caller = EMPTY_EXPR_INFO; - - sa_caller = string_arena_new(64); - sa_callee = string_arena_new(64); - - caller.sa = sa; - caller.prefix = ""; - caller.suffix = ""; - caller.assignments = ""; - - string_arena_init(sa); - UTIL_DUMP_LIST_FIELD(sa_callee, targetf->parameters, next, name, - dump_string, sa, - "(", "", ", ", ")"); - string_arena_init(sa); - UTIL_DUMP_LIST(sa_caller, params, next, - dump_expr, (void*)&caller, - "(", "", ", ", ")"); - fprintf(stderr, "%s.jdf:%d Badly formulated call %s%s instead of %s%s\n", - jdf_basename, source_call->super.lineno, - targetf->fname, string_arena_get_string(sa_caller), - targetf->fname, string_arena_get_string(sa_callee)); - exit(-1); - } - assert( el != NULL ); - if(!strcmp(pl->name, vl->name)) - break; - } - - expr_info_t infodst; - infodst.sa = sa; - infodst.prefix = targetf->fname; - infodst.suffix = ""; - infodst.assignments = "target_locals"; - expr_info_t infosrc; - infosrc.sa = sa; - infosrc.prefix = ""; - infosrc.suffix = ""; - infosrc.assignments = "&this_task->locals"; + coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", source_call)); + // for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { + // // Get the function parameter if it is one + // const jdf_expr_t *el; + // jdf_expr_t *params = source_call->parameters; + // jdf_param_list_t *pl; + // for(el = params, pl = targetf->parameters; pl != NULL; el = el->next, pl = pl->next) { + // if( NULL == el ) { /* Badly formulated call */ + // string_arena_t *sa_caller, *sa_callee; + // expr_info_t caller = EMPTY_EXPR_INFO; + + // sa_caller = string_arena_new(64); + // sa_callee = string_arena_new(64); + + // caller.sa = sa; + // caller.prefix = ""; + // caller.suffix = ""; + // caller.assignments = ""; + + // string_arena_init(sa); + // UTIL_DUMP_LIST_FIELD(sa_callee, targetf->parameters, next, name, + // dump_string, sa, + // "(", "", ", ", ")"); + // string_arena_init(sa); + // UTIL_DUMP_LIST(sa_caller, params, next, + // dump_expr, (void*)&caller, + // "(", "", ", ", ")"); + // fprintf(stderr, "%s.jdf:%d Badly formulated call %s%s instead of %s%s\n", + // jdf_basename, source_call->super.lineno, + // targetf->fname, string_arena_get_string(sa_caller), + // targetf->fname, string_arena_get_string(sa_callee)); + // exit(-1); + // } + // assert( el != NULL ); + // if(!strcmp(pl->name, vl->name)) + // break; + // } - if( NULL == pl ) { - /* It is a value. Let's dump it's expression in the destination context */ - string_arena_init(sa); - coutput(" %sconst int %s%s = %s; (void)%s%s;\n", - (spaces), targetf->fname, vl->name, dump_expr((void**)vl->expr, &infodst), targetf->fname, vl->name); - } else { - /* It is a parameter. Let's dump it's expression in the source context */ - assert(el != NULL); - string_arena_init(sa); - coutput(" %sconst int %s%s = %s; (void)%s%s;\n", - (spaces), targetf->fname, vl->name, dump_expr((void**)el, &infosrc), targetf->fname, vl->name); - } - } + // expr_info_t infodst; + // infodst.sa = sa; + // infodst.prefix = targetf->fname; + // infodst.suffix = ""; + // infodst.assignments = "target_locals"; + // expr_info_t infosrc; + // infosrc.sa = sa; + // infosrc.prefix = ""; + // infosrc.suffix = ""; + // infosrc.assignments = "&this_task->locals"; + + // if( NULL == pl ) { + // /* It is a value. Let's dump it's expression in the destination context */ + // string_arena_init(sa); + // coutput(" %sconst int %s%s = %s; (void)%s%s;\n", + // (spaces), targetf->fname, vl->name, dump_expr((void**)vl->expr, &infodst), targetf->fname, vl->name); + // } else { + // /* It is a parameter. Let's dump it's expression in the source context */ + // assert(el != NULL); + // string_arena_init(sa); + // coutput(" %sconst int %s%s = %s; (void)%s%s;\n", + // (spaces), targetf->fname, vl->name, dump_expr((void**)el, &infosrc), targetf->fname, vl->name); + // } + // } - int nb_opened_call_locals = 0; - int any_local_is_ranged = 0; + // TODO looks like this is completely useless // add the relevant call variables: jdf_call_t *dl = target_call; if( NULL != dl->local_defs ) { @@ -8671,12 +8723,12 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const spaces, ld->alias, dump_expr((void**)ld->jdf_ta1, &expr_info)); coutput("%s <= %s; %s+=", ld->alias, dump_expr((void**)ld->jdf_ta2, &expr_info), ld->alias); - coutput("%s) {\n", + coutput("%s) /* goes here*/ {\n", dump_expr((void**)ld->jdf_ta3, &expr_info)); ++nb_opened_call_locals; } else { coutput( - "%s %s = %s;\n", + "%s %s = %s; /* goes there*/\n", spaces, ld->alias, dump_expr((void**)ld, &expr_info)); } } diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 885d5ae53..aa753ee97 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -103,10 +103,10 @@ static inline char *util_dump_flow_id_variable(string_arena_t *sa, const char *j string_arena_init(sa); if( FLOW_IS_PARAMETRIZED(flow) ) { - string_arena_add_string(sa, "(spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s+%s)", + string_arena_add_string(sa, "(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s + %s)", JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); } else { - string_arena_add_string(sa, "(spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s)", + string_arena_add_string(sa, "(spec_%s.flow_id_of_flow_of_%s_%s_for_%s)", JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname); } @@ -159,6 +159,23 @@ static inline int jdf_any_flow_is_parametrized_util(const jdf_t *jdf) return 0; } +/** + * CALL_IS_PARAMETRIZED: + * + * Tells whether a call is parametrized or not. + * + * @param [IN] call: the call to test. + * + * @return a boolean value. + */ +#define CALL_IS_PARAMETRIZED(call) \ + call_is_parametrized_util(call) + +static inline int call_is_parametrized_util(const jdf_call_t *call) +{ + return NULL != call->parametrized_offset; +} + /** * FLOW_ANY_DEP_IS_REFERRER * @@ -183,7 +200,7 @@ static inline int flow_any_dep_is_referrer_util(const jdf_dataflow_t *flow) jdf_call_t *call = target_call?dep->guard->callfalse:dep->guard->calltrue; assert(call); - if( NULL != call->parametrized_offset ) + if( CALL_IS_PARAMETRIZED(call) ) { return 1; } From 097d50ff21f34db7b99990a607bf857e99a61452 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 10 Feb 2023 21:27:33 +0100 Subject: [PATCH 126/157] output the value of the iterator --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index dab79ec4f..31ae52a7b 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7665,6 +7665,13 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, spaces, spaces); + if(CALL_IS_PARAMETRIZED(call)) + { + // output the value of the iterator + coutput("%s const int %s = %s; (void)%s;\n", + spaces, call->parametrized_offset->alias, dump_expr((void**)call->parametrized_offset, &info), call->parametrized_offset->alias); + } + /* Code to fulfill a reshape promise set up by predecessor if there's one */ jdf_generate_code_consume_predecessor_setup(jdf, call, f, flow, From be5c9e7c16607ca45a22a1e199f04353bdafd274 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 13 Feb 2023 14:09:15 +0100 Subject: [PATCH 127/157] use dynamic flow id only of the task class has a parametrized flow --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 50 +++++++++++++------ .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 10 ++-- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 31ae52a7b..8aa6f5299 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1749,11 +1749,6 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { coutput(" uint32_t dep_mask_out_of_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); - if(!FLOW_IS_PARAMETRIZED(df)) - { - coutput(" uint8_t flow_id_of_flow_of_%s_%s_for_%s;\n", - jdf_basename, f->fname, df->varname); - } } // action_mask for the entire task class coutput(" uint32_t dep_mask_out_of_flow_of_%s_%s;\n", @@ -1853,6 +1848,15 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) } } + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { + coutput(" // Task class %s has at least one parametrized flow: we need to store the flow id of every flow\n", f->fname); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + coutput(" uint8_t flow_id_of_flow_of_%s_%s_for_%s;\n", + jdf_basename, f->fname, df->varname); + } + } + coutput("} parsec_%s_%s_task_class_t;\n\n", jdf_basename, f->fname); } } @@ -5048,11 +5052,6 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { string_arena_add_string(sa, " , .dep_mask_out_of_flow_of_%s_%s_for_%s = 0x0\n", jdf_basename, f->fname, df->varname); - if(!FLOW_IS_PARAMETRIZED(df)) - { - string_arena_add_string(sa, " , .flow_id_of_flow_of_%s_%s_for_%s = %d\n", - jdf_basename, f->fname, df->varname, df->flow_index); - } } string_arena_add_string(sa, " , .dep_mask_out_of_flow_of_%s_%s = 0x0\n", jdf_basename, f->fname); @@ -5151,8 +5150,16 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f } } } - } + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { + string_arena_add_string(sa, " // Task class %s has at least one parametrized flow: we need to store the flow id of every flow\n", f->fname); + for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { + string_arena_add_string(sa, " , .flow_id_of_flow_of_%s_%s_for_%s = %d\n", + jdf_basename, f->fname, df->varname, df->flow_index); + } + } + } string_arena_add_string(sa, "\n};"); @@ -6572,13 +6579,24 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } + //if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) // We already know that the flow is parametrized + { + coutput(" // dynamic flow id of flow %s of task class %s\n", df->varname, f->fname); + + coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 1);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, + jdf_basename, f->fname, df->varname); + } + coutput(" }\n"); } - else + else if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { - coutput(" { // Non-parametrized flow %s of task class %s\n", df->varname, f->fname); + coutput(" { // flow %s of task class %s\n", df->varname, f->fname); - coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_%s, 0);\n", + coutput(" // dynamic flow id of flow %s of task class %s\n", df->varname, f->fname); + + coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 1);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); @@ -7397,7 +7415,7 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * string_arena_init(sa_pred_consumed_flow_index); - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(pred_f)) { DUMP_FLOW_ID_VARIABLE(sa_pred_consumed_flow_index, jdf_basename, pred_f, pred_flow); } @@ -7405,7 +7423,7 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * { string_arena_add_string(sa_pred_consumed_flow_index, "%d", pred_flow->flow_index); } - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { DUMP_FLOW_ID_VARIABLE(sa_consumed_flow_index, jdf_basename, f, flow); } diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index aa753ee97..a0d3b1a28 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -102,13 +102,13 @@ static inline char *util_dump_flow_id_variable(string_arena_t *sa, const char *j { string_arena_init(sa); - if( FLOW_IS_PARAMETRIZED(flow) ) { - string_arena_add_string(sa, "(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s + %s)", - JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); - } else { + // if( FLOW_IS_PARAMETRIZED(flow) ) { + // string_arena_add_string(sa, "(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s + %s)", + // JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); + // } else { string_arena_add_string(sa, "(spec_%s.flow_id_of_flow_of_%s_%s_for_%s)", JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname); - } + // } return string_arena_get_string(sa); } From cb5408a1e8ac34ba73aaa54115b4d1535d285e15 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 13 Feb 2023 15:03:39 +0100 Subject: [PATCH 128/157] use a mask for each specialization of a parametrized flow + put the parametrized iterator in ncc --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 8aa6f5299..fb22449f1 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -9939,6 +9939,14 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, string_arena_add_string(sa_open, "%s%s%s.task_class = __parsec_tp->super.super.task_classes_array[%s_%s.task_class_id];\n", prefix, indent(nbopen), var, jdf_basename, targetf->fname); + if(FLOW_IS_PARAMETRIZED(flow)) { + // set the iterator + string_arena_add_string(sa_open, "%s%sncc->locals.ldef[%d].value = %s;\n", + prefix, indent(nbopen), + flow->local_variables->ldef_index, + get_parametrized_flow_iterator_name(flow)); + } + nbparam_given = 0; for(el = call->parameters; el != NULL; el = el->next) { nbparam_given++; @@ -10766,14 +10774,17 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, depnb++; /* Dump the previous dependencies */ - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { // Get the action mask for this flow as a string string_arena_t *sa_action_mask = string_arena_new(128); - string_arena_add_string(sa_action_mask, "spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s", - JDF_OBJECT_ONAME(f), - jdf_basename, f->fname, fl->varname); + // The specific bit is 1<<(dynamic flow id)<<(specialization id) + + string_arena_add_string(sa_action_mask, "(1<<(spec_%s_%s.flow_id_of_flow_of_%s_%s_for_%s+%s))", + jdf_basename, f->fname, jdf_basename, f->fname, fl->varname, + FLOW_IS_PARAMETRIZED(fl)?get_parametrized_flow_iterator_name(fl):"0" + ); OUTPUT_PREV_DEPS_PARAMETRIZED(string_arena_get_string(sa_action_mask), sa_datatype, sa_deps); From e62bcee7c07d1c9f532aee8afc0ac57de42c1463 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 13 Feb 2023 16:03:00 +0100 Subject: [PATCH 129/157] rework the make_key function to include the parametrized iterator --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 37 ++++++++++++++++++---- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index fb22449f1..8fb346ac0 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6852,6 +6852,14 @@ static void jdf_generate_hashfunction_for(const jdf_t *jdf, const jdf_function_e idx++; } + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + for(int ldef_index=0;ldef_indexnb_max_local_def;++ldef_index) { + coutput(" const int ldef_%d = assignment->ldef[%d].value;\n", + ldef_index, ldef_index); + coutput(" assert( ldef_%d >= 0 );\n", ldef_index); + } + } + string_arena_init(sa_range_multiplier); for(vl = f->locals; vl != NULL; vl = vl->next) { if( local_is_parameter(f, vl) != NULL ) { @@ -6860,6 +6868,14 @@ static void jdf_generate_hashfunction_for(const jdf_t *jdf, const jdf_function_e } } + // TODO verify that this is optimized away when not needed + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + for(int ldef_index=0;ldef_indexnb_max_local_def;++ldef_index) { + coutput(" __parsec_id += ldef_%d%s;\n", ldef_index, string_arena_get_string(sa_range_multiplier)); + string_arena_add_string(sa_range_multiplier, " * %d", MAX_DATAFLOWS_PER_TASK); // TODO get the true range, MAX_DATAFLOWS_PER_TASK is the maximum possible + } + } + coutput(" (void)__parsec_tp;\n" " return (parsec_key_t)__parsec_id;\n" "}\n"); @@ -9939,12 +9955,21 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, string_arena_add_string(sa_open, "%s%s%s.task_class = __parsec_tp->super.super.task_classes_array[%s_%s.task_class_id];\n", prefix, indent(nbopen), var, jdf_basename, targetf->fname); - if(FLOW_IS_PARAMETRIZED(flow)) { - // set the iterator - string_arena_add_string(sa_open, "%s%sncc->locals.ldef[%d].value = %s;\n", - prefix, indent(nbopen), - flow->local_variables->ldef_index, - get_parametrized_flow_iterator_name(flow)); + // If any flow in this task class is parametrized, we set all the ldef's so that make_key can function even if there is no parametrized offset + + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(targetf)) + { + for(int ldef_index=0;ldef_indexnb_max_local_def;++ldef_index) { + string_arena_add_string(sa_open, "%s%sncc->locals.ldef[%d].value = 0;\n", + prefix, indent(nbopen), ldef_index); + } + if(FLOW_IS_PARAMETRIZED(flow)) { + // set the iterator + string_arena_add_string(sa_open, "%s%sncc->locals.ldef[%d].value = %s;\n", + prefix, indent(nbopen), + flow->local_variables->ldef_index, + get_parametrized_flow_iterator_name(flow)); + } } nbparam_given = 0; From 1227a369d14e83f2f0177a8ff290da7061fb96ac Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 14 Feb 2023 18:13:10 +0100 Subject: [PATCH 130/157] revert make_key to the original version --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 36 ++++++++++--------- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 4 +-- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 8fb346ac0..4644d88be 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6852,13 +6852,14 @@ static void jdf_generate_hashfunction_for(const jdf_t *jdf, const jdf_function_e idx++; } - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { - for(int ldef_index=0;ldef_indexnb_max_local_def;++ldef_index) { - coutput(" const int ldef_%d = assignment->ldef[%d].value;\n", - ldef_index, ldef_index); - coutput(" assert( ldef_%d >= 0 );\n", ldef_index); - } - } + // rubish + // if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + // for(int ldef_index=0;ldef_indexnb_max_local_def;++ldef_index) { + // coutput(" const int ldef_%d = assignment->ldef[%d].value;\n", + // ldef_index, ldef_index); + // coutput(" assert( ldef_%d >= 0 );\n", ldef_index); + // } + // } string_arena_init(sa_range_multiplier); for(vl = f->locals; vl != NULL; vl = vl->next) { @@ -6868,13 +6869,14 @@ static void jdf_generate_hashfunction_for(const jdf_t *jdf, const jdf_function_e } } - // TODO verify that this is optimized away when not needed - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { - for(int ldef_index=0;ldef_indexnb_max_local_def;++ldef_index) { - coutput(" __parsec_id += ldef_%d%s;\n", ldef_index, string_arena_get_string(sa_range_multiplier)); - string_arena_add_string(sa_range_multiplier, " * %d", MAX_DATAFLOWS_PER_TASK); // TODO get the true range, MAX_DATAFLOWS_PER_TASK is the maximum possible - } - } + // rubish + // // TODO verify that this is optimized away when not needed + // if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + // for(int ldef_index=0;ldef_indexnb_max_local_def;++ldef_index) { + // coutput(" __parsec_id += ldef_%d%s;\n", ldef_index, string_arena_get_string(sa_range_multiplier)); + // string_arena_add_string(sa_range_multiplier, " * %d", MAX_DATAFLOWS_PER_TASK); // TODO get the true range, MAX_DATAFLOWS_PER_TASK is the maximum possible + // } + // } coutput(" (void)__parsec_tp;\n" " return (parsec_key_t)__parsec_id;\n" @@ -8764,12 +8766,12 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const spaces, ld->alias, dump_expr((void**)ld->jdf_ta1, &expr_info)); coutput("%s <= %s; %s+=", ld->alias, dump_expr((void**)ld->jdf_ta2, &expr_info), ld->alias); - coutput("%s) /* goes here*/ {\n", + coutput("%s) {\n", dump_expr((void**)ld->jdf_ta3, &expr_info)); ++nb_opened_call_locals; } else { coutput( - "%s %s = %s; /* goes there*/\n", + "%s %s = %s;\n", spaces, ld->alias, dump_expr((void**)ld, &expr_info)); } } @@ -10009,7 +10011,7 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, } else { - string_arena_add_string(sa_open, "%s%s // do not declare %s, it is a parametrized flow range\n", prefix, indent(nbopen), ld->alias); + string_arena_add_string(sa_open, "%s%s // do not declare '%s', it is a parametrized flow range\n", prefix, indent(nbopen), ld->alias); } if(JDF_RANGE == ld->op/* || JDF_PARAMETRIZED_FLOW_RANGE == ld->op*/) { string_arena_add_string(sa_open, diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index a0d3b1a28..7e1c23279 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -106,8 +106,8 @@ static inline char *util_dump_flow_id_variable(string_arena_t *sa, const char *j // string_arena_add_string(sa, "(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s + %s)", // JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); // } else { - string_arena_add_string(sa, "(spec_%s.flow_id_of_flow_of_%s_%s_for_%s)", - JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname); + string_arena_add_string(sa, "(spec_%s.flow_id_of_flow_of_%s_%s_for_%s + %s)", + JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); // } return string_arena_get_string(sa); From e0dbfa5dc5e7e9fb54fb903b7c0aed5173cc5e85 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 14 Feb 2023 18:19:27 +0100 Subject: [PATCH 131/157] complete the previous revert --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 34 +++++++++++++--------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 4644d88be..54d4e4328 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -9959,19 +9959,27 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, // If any flow in this task class is parametrized, we set all the ldef's so that make_key can function even if there is no parametrized offset - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(targetf)) - { - for(int ldef_index=0;ldef_indexnb_max_local_def;++ldef_index) { - string_arena_add_string(sa_open, "%s%sncc->locals.ldef[%d].value = 0;\n", - prefix, indent(nbopen), ldef_index); - } - if(FLOW_IS_PARAMETRIZED(flow)) { - // set the iterator - string_arena_add_string(sa_open, "%s%sncc->locals.ldef[%d].value = %s;\n", - prefix, indent(nbopen), - flow->local_variables->ldef_index, - get_parametrized_flow_iterator_name(flow)); - } + // rubish + // if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(targetf)) + // { + // for(int ldef_index=0;ldef_indexnb_max_local_def;++ldef_index) { + // string_arena_add_string(sa_open, "%s%sncc->locals.ldef[%d].value = 0;\n", + // prefix, indent(nbopen), ldef_index); + // } + // if(FLOW_IS_PARAMETRIZED(flow)) { + // // set the iterator + // string_arena_add_string(sa_open, "%s%sncc->locals.ldef[%d].value = %s;\n", + // prefix, indent(nbopen), + // flow->local_variables->ldef_index, + // get_parametrized_flow_iterator_name(flow)); + // } + // } + if(FLOW_IS_PARAMETRIZED(flow)) { + // set the iterator + string_arena_add_string(sa_open, "%s%sncc->locals.ldef[%d].value = %s;\n", + prefix, indent(nbopen), + flow->local_variables->ldef_index, + get_parametrized_flow_iterator_name(flow)); } nbparam_given = 0; From c7835938bc6d69cfd3e8119c98ebf07cc83918e0 Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 16 Feb 2023 11:38:14 +0100 Subject: [PATCH 132/157] use parametrized flow id if needed in reshaping --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 54d4e4328..fd53462d8 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7240,12 +7240,23 @@ jdf_generate_code_reshape_input_from_desc(const jdf_t *jdf, ".", "local", 1); coutput("%s %s", spaces, string_arena_get_string(sa_datatype)); + // Get the flow id as a string + string_arena_t *sa_flow_index = string_arena_new(128); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { + DUMP_FLOW_ID_VARIABLE(sa_flow_index, jdf_basename, f, flow); + } + else + { + string_arena_add_string(sa_flow_index, "%d", flow->flow_index); + } + /*INLINE RESHAPING WHEN READING FROM MATRIX NEW COPY EACH THREAD*/ coutput("%s data.data_future = NULL;\n", spaces); - coutput("%s if( (ret = parsec_get_copy_reshape_from_desc(es, this_task->taskpool, (parsec_task_t *)this_task, %d, reshape_repo, reshape_entry_key, &data, &chunk)) < 0){\n" + coutput("%s if( (ret = parsec_get_copy_reshape_from_desc(es, this_task->taskpool, (parsec_task_t *)this_task, %s, reshape_repo, reshape_entry_key, &data, &chunk)) < 0){\n" "%s return ret;\n" "%s }\n", - spaces, flow->flow_index, + spaces, string_arena_get_string(sa_flow_index),//flow->flow_index, spaces, spaces); From 137757c51b2494fb10c7842078dc82e0e67ed04d Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 16 Feb 2023 11:46:59 +0100 Subject: [PATCH 133/157] use variable for flow_index in the reshaping from deps --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index fd53462d8..1f25458ea 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7400,10 +7400,21 @@ jdf_generate_code_reshape_input_from_dep(const jdf_t *jdf, ".", "local", 1); coutput("%s %s", spaces, string_arena_get_string(sa_datatype)); - coutput("%s if( (ret = parsec_get_copy_reshape_from_dep(es, this_task->taskpool, (parsec_task_t *)this_task, %d, reshape_repo, reshape_entry_key, &data, &chunk)) < 0){\n" + // Get the flow id as a string + string_arena_t *sa_flow_index = string_arena_new(128); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { + DUMP_FLOW_ID_VARIABLE(sa_flow_index, jdf_basename, f, flow); + } + else + { + string_arena_add_string(sa_flow_index, "%d", flow->flow_index); + } + + coutput("%s if( (ret = parsec_get_copy_reshape_from_dep(es, this_task->taskpool, (parsec_task_t *)this_task, %s, reshape_repo, reshape_entry_key, &data, &chunk)) < 0){\n" "%s return ret;\n" "%s }\n", - spaces, flow->flow_index, + spaces, string_arena_get_string(sa_flow_index), //flow->flow_index, spaces, spaces); From dbdc3383dbdcbd64913baf6a1db955f6e1757d3c Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 16 Feb 2023 13:56:30 +0100 Subject: [PATCH 134/157] correct flow id for affecting repo_entry->data to NULL --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 1f25458ea..5697b74e5 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7260,6 +7260,8 @@ jdf_generate_code_reshape_input_from_desc(const jdf_t *jdf, spaces, spaces); + string_arena_free(sa_flow_index); + string_arena_free(sa); string_arena_free(sa2); @@ -7417,6 +7419,8 @@ jdf_generate_code_reshape_input_from_dep(const jdf_t *jdf, spaces, string_arena_get_string(sa_flow_index), //flow->flow_index, spaces, spaces); + + string_arena_free(sa_flow_index); string_arena_free(sa); string_arena_free(sa2); @@ -8011,19 +8015,23 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, "%s */\n", INDENTATION_IF_PARAMETRIZED(flow), DUMP_DATA_FIELD_NAME_IN_TASK(osa, flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow), INDENTATION_IF_PARAMETRIZED(flow)); - if(!TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) - { // If no flow is parametrized, the flow index will not be altered - coutput("%s this_task->repo_entry->data[%d] = NULL;\n", INDENTATION_IF_PARAMETRIZED(flow), - flow->flow_index); - // TODO this seems wrong, this_task->repo_entry->data has a size of 1, but flow->flow_index can be > 1 + + // Get the flow id as a string + string_arena_t *sa_flow_index = string_arena_new(128); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { + DUMP_FLOW_ID_VARIABLE(sa_flow_index, jdf_basename, f, flow); } else { - // It is also definitely wrong if the flow is parametrized, since the flow index can change at runtime - coutput("%s // this_task->repo_entry->data[%d] = NULL;\n", INDENTATION_IF_PARAMETRIZED(flow), - flow->flow_index); - coutput("%s assert(0);\n", INDENTATION_IF_PARAMETRIZED(flow)); + string_arena_add_string(sa_flow_index, "%d", flow->flow_index); } + + coutput("%s this_task->repo_entry->data[%s] = NULL;\n", INDENTATION_IF_PARAMETRIZED(flow), + string_arena_get_string(sa_flow_index)); + + string_arena_free(sa_flow_index); + coutput("%s }\n", INDENTATION_IF_PARAMETRIZED(flow)); } From dbad205f9c121cc79315787688f120ee9c5e4faf Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 16 Feb 2023 14:28:28 +0100 Subject: [PATCH 135/157] correct the number of flows if parametrized --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 16 +++++++++-- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 28 +++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 5697b74e5..142dd3566 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -4463,15 +4463,27 @@ static void jdf_generate_internal_init(const jdf_t *jdf, const jdf_function_entr } } + string_arena_t *sa_item_num = string_arena_new(128); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { + DUMP_NUMBER_OF_FLOWS_IN_TASK_CLASS(sa_item_num, jdf_basename, f); + } + else + { + string_arena_add_string(sa_item_num, "%d", idx); + } + /* Generate the repo for all tasks classes, they can be used when: * - a predecessor sets up a reshape promised for a datacopy * - the own tasks use it when reshaping a datacopy directly read from desc * No longer only when if( !(f->flags & JDF_FUNCTION_FLAG_NO_SUCCESSORS) ) */ - coutput(" __parsec_tp->repositories[%d] = data_repo_create_nothreadsafe(%s, %s, (parsec_taskpool_t*)__parsec_tp, %d);\n", + coutput(" __parsec_tp->repositories[%d] = data_repo_create_nothreadsafe(%s, %s, (parsec_taskpool_t*)__parsec_tp, %s);\n", f->task_class_id, need_to_count_tasks ? "nb_tasks" : "PARSEC_DEFAULT_DATAREPO_HASH_LENGTH", jdf_property_get_string(f->properties, JDF_PROP_UD_HASH_STRUCT_NAME, NULL), - idx ); + string_arena_get_string(sa_item_num) ); + + string_arena_free(sa_item_num); coutput("%s" " %s (void)__parsec_tp; (void)es;\n", diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 7e1c23279..97d88d372 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -113,6 +113,34 @@ static inline char *util_dump_flow_id_variable(string_arena_t *sa, const char *j return string_arena_get_string(sa); } +/** + * @brief Dumps an expression that gives the number of flows in a task class, including each specialization of a parametrized flow + * + */ +#define DUMP_NUMBER_OF_FLOWS_IN_TASK_CLASS(sa, jdf_basename, function)\ + util_dump_number_of_flows_in_task_class(sa, jdf_basename, function) + +static inline char *util_dump_number_of_flows_in_task_class(string_arena_t *sa, const char *jdf_basename, const jdf_function_entry_t *function) +{ + string_arena_init(sa); + + string_arena_add_string(sa, "("); + + // For each flow + for(jdf_dataflow_t *flow = function->dataflow; flow != NULL; flow = flow->next) { + if( FLOW_IS_PARAMETRIZED(flow) ) { + string_arena_add_string(sa, " + spec_%s.nb_specializations_of_parametrized_flow_of_%s_%s_for_%s", + JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname); + } else { + string_arena_add_string(sa, " + 1"); + } + } + + string_arena_add_string(sa, ")"); + + return string_arena_get_string(sa); +} + /** * VARIABLE_IS_FLOW_LEVEL * Tells whether a variable is a flow level variable or not. From 1193e149912cdac6f90d4b922f3d7bbf0af2c03c Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 17 Feb 2023 16:05:43 +0100 Subject: [PATCH 136/157] use data_dynamic_offset_of_parametrized_ instead of flow_id + only declare in/out masks if the flow is in/out --- parsec/include/parsec/parsec_config_bottom.h | 4 +- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 55 +++++++++++++------ .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 2 +- parsec/task_class.c | 3 +- 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/parsec/include/parsec/parsec_config_bottom.h b/parsec/include/parsec/parsec_config_bottom.h index 50fc6fb23..2978046c1 100644 --- a/parsec/include/parsec/parsec_config_bottom.h +++ b/parsec/include/parsec/parsec_config_bottom.h @@ -162,8 +162,8 @@ typedef int32_t parsec_dependency_t; #define MAX_LOCAL_COUNT 20 #define MAX_PARAM_COUNT 20 -#define MAX_DEP_IN_COUNT 20 -#define MAX_DEP_OUT_COUNT 20 +#define MAX_DEP_IN_COUNT 21 +#define MAX_DEP_OUT_COUNT 21 #define MAX_TASK_STRLEN 128 diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 142dd3566..724e5b3b9 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1765,8 +1765,11 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) coutput("#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { - coutput(" int in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); - coutput(" int out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + // if "in" flow + if(df->flow_flags & JDF_FLOW_TYPE_READ) + coutput(" int in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); + if(df->flow_flags & JDF_FLOW_TYPE_WRITE) + coutput(" int out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); coutput(" int data_dynamic_offset_of_parametrized_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } } @@ -5081,8 +5084,10 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { // store the offset for every output dep of this parametrized flow - string_arena_add_string(sa, " , .in_flow_offset_of_parametrized_%s = -1\n", JDF_OBJECT_ONAME(df)); - string_arena_add_string(sa, " , .out_flow_offset_of_parametrized_%s = -1\n", JDF_OBJECT_ONAME(df)); + if(df->flow_flags & JDF_FLOW_TYPE_READ) + string_arena_add_string(sa, " , .in_flow_offset_of_parametrized_%s = -1\n", JDF_OBJECT_ONAME(df)); + if(df->flow_flags & JDF_FLOW_TYPE_WRITE) + string_arena_add_string(sa, " , .out_flow_offset_of_parametrized_%s = -1\n", JDF_OBJECT_ONAME(df)); string_arena_add_string(sa, " , .data_dynamic_offset_of_parametrized_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); } } @@ -5976,7 +5981,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " ++parametrized_iterator;\n" " }\n" " }\n" - " assert(pivot_reached);\n" + " // assert(pivot_reached); // Actually, the pivot is not reached if READ/WRITE-only\n" " }\n" " // Update nb_flows\n" " tc->nb_flows += nb_specializations_of_current_flow-1;\n" @@ -6406,6 +6411,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" int current_max_dep_id_task_class = 0; // Max dep_id of this task class\n"); coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); coutput(" parsec_flow_t *flow = (in_out?tc->out:tc->in)[flow_id];\n"); + coutput(" if(NULL == flow) break;\n"); coutput(" if(in_out == 1)\n"); coutput(" flow->flow_datatype_mask = 0;\n"); coutput(" // We look for the min and max, because we need them to compute the exact lifting\n"); @@ -6466,10 +6472,20 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_basename, f->fname, df->varname); coutput("#endif\n"); - coutput(" spec_%s.in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 0);\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); - coutput(" spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 1);\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); + if(df->flow_flags & JDF_FLOW_TYPE_READ) + { + coutput(" spec_%s.in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); + coutput(" assert(spec_%s.in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + } + if(df->flow_flags & JDF_FLOW_TYPE_WRITE) + { + coutput(" spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 1);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); + coutput(" assert(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + } coutput("\n"); coutput(" spec_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s = current_data_offset_for_%s_%s;\n", @@ -6550,10 +6566,12 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" assert(spec_%s.nb_specializations_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput("#endif\n"); - coutput(" assert(spec_%s.in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); - coutput(" assert(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", - JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + if(df->flow_flags & JDF_FLOW_TYPE_READ) + coutput(" assert(spec_%s.in_flow_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); + if(df->flow_flags & JDF_FLOW_TYPE_WRITE) + coutput(" assert(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" assert(spec_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s >= 0);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); @@ -6598,6 +6616,9 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 1);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); + + coutput(" assert(spec_%s.flow_id_of_flow_of_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); } coutput(" }\n"); @@ -6611,6 +6632,9 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 1);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); + + coutput(" assert(spec_%s.flow_id_of_flow_of_%s_%s_for_%s >= 0);\n", + JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" }\n"); } @@ -9369,7 +9393,7 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, if( FLOW_IS_PARAMETRIZED(fl) ) { // If the flow is out (note: we use either in or out, this is our only way of getting a parametrized_flow) - if( JDF_FLOW_IS_OUT & fl->flow_flags ) { + if( JDF_FLOW_TYPE_READ & fl->flow_flags ) { coutput("%s gpu_task->flow[%s] = this_task->task_class->out[spec_%s_%s.out_flow_offset_of_parametrized_%s + %s];\n", INDENTATION_IF_PARAMETRIZED(fl), di_str, jdf_basename, f->fname, JDF_OBJECT_ONAME(fl), get_parametrized_flow_iterator_name(fl)); @@ -10857,8 +10881,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_t *sa_action_mask = string_arena_new(128); // The specific bit is 1<<(dynamic flow id)<<(specialization id) - - string_arena_add_string(sa_action_mask, "(1<<(spec_%s_%s.flow_id_of_flow_of_%s_%s_for_%s+%s))", + string_arena_add_string(sa_action_mask, "(1<<(spec_%s_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s+%s))", jdf_basename, f->fname, jdf_basename, f->fname, fl->varname, FLOW_IS_PARAMETRIZED(fl)?get_parametrized_flow_iterator_name(fl):"0" ); diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 97d88d372..9815a14a2 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -106,7 +106,7 @@ static inline char *util_dump_flow_id_variable(string_arena_t *sa, const char *j // string_arena_add_string(sa, "(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s + %s)", // JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); // } else { - string_arena_add_string(sa, "(spec_%s.flow_id_of_flow_of_%s_%s_for_%s + %s)", + string_arena_add_string(sa, "(spec_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s + %s)", JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); // } diff --git a/parsec/task_class.c b/parsec/task_class.c index c059e70a0..33e2bdb3f 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -150,7 +150,7 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * if(pivot_flow == ((in_out) ? (tc->out) : (tc->in))[i]) break; // pivot flow found if(!((in_out) ? (tc->out) : (tc->in))[i]) - return; // pivot not found + break; // pivot not found } if(pivot_flow == ((in_out) ? (tc->out) : (tc->in))[i]) { @@ -687,6 +687,5 @@ int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flo } } - assert(0); return -1; } From 81fe29f3e326689560723d9f36bd9870c88a472c Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 17 Feb 2023 18:06:01 +0100 Subject: [PATCH 137/157] add asserts + function to find a flow_id + switch back to using spec_%s_%s.flow_id_of_flow_of_%s_%s_for_%s --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 18 ++++++++----- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 12 +++++---- parsec/task_class.c | 25 ++++++++++++++++--- parsec/task_class.h | 1 + 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 724e5b3b9..62922a4fd 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5981,7 +5981,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " ++parametrized_iterator;\n" " }\n" " }\n" - " // assert(pivot_reached); // Actually, the pivot is not reached if READ/WRITE-only\n" + " assert(pivot_reached); // Actually, the pivot is not reached if READ/WRITE-only\n" " }\n" " // Update nb_flows\n" " tc->nb_flows += nb_specializations_of_current_flow-1;\n" @@ -6436,6 +6436,12 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" if(NULL == dep) break;\n"); coutput(" dep->dep_index += current_max_dep_id_task_class - current_min_dep_id_flow;\n"); coutput(" dep->dep_datatype_index += current_max_dep_id_task_class - current_min_dep_id_flow;\n"); + coutput("#if defined(PARSEC_DEBUG_PARANOID)\n"); + coutput(" assert(dep->dep_index >= 0);\n"); + coutput(" assert(dep->dep_datatype_index >= 0);\n"); + coutput(" assert(dep->dep_index < (in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT));\n"); + coutput(" assert(dep->dep_datatype_index < (in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT));\n"); + coutput("#endif\n"); coutput(" if(in_out==1)\n"); coutput(" flow->flow_datatype_mask |= 1<dep_index; // keep the flow_datatype_mask up-to-date\n"); coutput(" }\n"); @@ -6613,11 +6619,11 @@ static void jdf_generate_new_function( const jdf_t* jdf ) { coutput(" // dynamic flow id of flow %s of task class %s\n", df->varname, f->fname); - coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 1);\n", + coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index_in_or_out(tc, &flow_of_%s_%s_for_parametrized_%s[0]);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); - coutput(" assert(spec_%s.flow_id_of_flow_of_%s_%s_for_%s >= 0);\n", + coutput(" assert(spec_%s.flow_id_of_flow_of_%s_%s_for_%s >= 0); // nonesense because uint\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); } @@ -6629,11 +6635,11 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" // dynamic flow id of flow %s of task class %s\n", df->varname, f->fname); - coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index(tc, &flow_of_%s_%s_for_parametrized_%s[0], 1);\n", + coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index_in_or_out(tc, &flow_of_%s_%s_for_parametrized_%s[0]);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); - coutput(" assert(spec_%s.flow_id_of_flow_of_%s_%s_for_%s >= 0);\n", + coutput(" assert(spec_%s.flow_id_of_flow_of_%s_%s_for_%s >= 0); // nonesense because uint\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" }\n"); @@ -10881,7 +10887,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_t *sa_action_mask = string_arena_new(128); // The specific bit is 1<<(dynamic flow id)<<(specialization id) - string_arena_add_string(sa_action_mask, "(1<<(spec_%s_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s+%s))", + string_arena_add_string(sa_action_mask, "(1<<(spec_%s_%s.flow_id_of_flow_of_%s_%s_for_%s + %s))", jdf_basename, f->fname, jdf_basename, f->fname, fl->varname, FLOW_IS_PARAMETRIZED(fl)?get_parametrized_flow_iterator_name(fl):"0" ); diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index 9815a14a2..f2b438cc3 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -102,13 +102,15 @@ static inline char *util_dump_flow_id_variable(string_arena_t *sa, const char *j { string_arena_init(sa); - // if( FLOW_IS_PARAMETRIZED(flow) ) { - // string_arena_add_string(sa, "(spec_%s.out_flow_offset_of_parametrized_flow_of_%s_%s_for_%s + %s)", - // JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); - // } else { - string_arena_add_string(sa, "(spec_%s.data_dynamic_offset_of_parametrized_%s_%s_for_%s + %s)", + // if(flow->flow_flags & JDF_FLOW_TYPE_WRITE) + // { + string_arena_add_string(sa, "(spec_%s.flow_id_of_flow_of_%s_%s_for_%s + %s)", JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); // } + // else + // { + // string_arena_add_string(sa, "DUNNO_HOW_TO_GET_ACTION_MASK_FOR_THIS_FLOW"); + // } return string_arena_get_string(sa); } diff --git a/parsec/task_class.c b/parsec/task_class.c index 33e2bdb3f..593de590a 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -544,15 +544,23 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc, bool check_dep_i // For each output dep of the flow ... for (j = 0; j < (dep_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) { - dep = flow->dep_out[j]; + dep = (parsec_dep_t *)(dep_in_out ? flow->dep_out[j] : flow->dep_in[j]); if (!dep) { break; } - // All out dependencies should be in the flow datatype mask - assert((1 << dep->dep_datatype_index) & flow->flow_datatype_mask); - //assert((1 << dep->dep_index) & flow->flow_datatype_mask); + if(dep_in_out == 1) + { + // All out dependencies should be in the flow datatype mask + assert((1 << dep->dep_datatype_index) & flow->flow_datatype_mask); + //assert((1 << dep->dep_index) & flow->flow_datatype_mask); + + // All out dependencies should be mappable in the flow datatype mask + assert(dep->dep_datatype_index < sizeof(flow->flow_datatype_mask) * 8); + } + + assert(dep->dep_index < (dep_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT)); } } } @@ -669,6 +677,14 @@ int parsec_helper_get_flow_index_that_contains_dep(const parsec_task_class_t *tc return -1; } +int parsec_helper_get_flow_index_in_or_out(const parsec_task_class_t *tc, const parsec_flow_t *flow) +{ + int i = parsec_helper_get_flow_index(tc, flow, 1); + i = ((i == -1) ? parsec_helper_get_flow_index(tc, flow, 0) : i); + assert(i != -1); + return i; +} + int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flow_t *flow, int in_out) { int i; @@ -687,5 +703,6 @@ int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flo } } + //assert(0); return -1; } diff --git a/parsec/task_class.h b/parsec/task_class.h index 366378fd0..26659811c 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -33,6 +33,7 @@ int parsec_helper_dep_is_in_flow(const parsec_flow_t *flow, const parsec_dep_t * int parsec_helper_get_dep_index_in_flow(const parsec_flow_t *flow, const parsec_dep_t *dep, int in_out); int parsec_helper_get_dep_index(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out); int parsec_helper_get_flow_index_that_contains_dep(const parsec_task_class_t *tc, const parsec_dep_t *dep, int in_out); +int parsec_helper_get_flow_index_in_or_out(const parsec_task_class_t *tc, const parsec_flow_t *flow); int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flow_t *flow, int in_out); #endif /* PARSEC_TASK_CLASS_H_HAS_BEEN_INCLUDED */ From 26b807ae8f3bdc853e592e3048064635545f7c85 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 20 Feb 2023 10:53:10 +0100 Subject: [PATCH 138/157] change the flow_index affectation so that it works for READ/WRITE-only flows --- parsec/task_class.c | 51 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index 593de590a..fe63b0090 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -127,8 +127,10 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * { int i, j; int flow_in_out; - int pivot_index; - int last_flow_index; + int pivot_index_in, pivot_index_out; + int last_flow_index_in, last_flow_index_out; + int found_pivot_in=0, found_pivot_out=0; + int pivot_flow_index = pivot_flow->flow_index; parsec_flow_t *flow; parsec_dep_t *dep; @@ -154,11 +156,20 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * } if(pivot_flow == ((in_out) ? (tc->out) : (tc->in))[i]) { - pivot_index = i; + if(in_out) + { + found_pivot_out = 1; + pivot_index_out = i; + } + else + { + found_pivot_in = 1; + pivot_index_in = i; + } // - Update all the dep_index > pivot_index (MODIFICATION: DONT TO THIS) // - find last_flow_index (needed for performing the actual shift at the end) - for (i = pivot_index + 1; i < MAX_DATAFLOWS_PER_TASK; i++) + for (i = (in_out?pivot_index_out:pivot_index_in) + 1; i < MAX_DATAFLOWS_PER_TASK; i++) { flow = ((in_out) ? (tc->out) : (tc->in))[i]; if(!flow) @@ -178,8 +189,20 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * if(!flow) break; // end of the array } - last_flow_index = i - 1; + //((in_out) ? last_flow_index_out : last_flow_index_in) = i - 1; + if(in_out) + last_flow_index_out = i - 1; + else + last_flow_index_in = i - 1; + } + } + for(int in_out = 0; in_out < 2; ++in_out) + { + if(in_out&&found_pivot_out || !in_out&&found_pivot_in) + { // The pivot flow was found in this in_out + int pivot_index = (in_out) ? pivot_index_out : pivot_index_in; + int last_flow_index = (in_out) ? last_flow_index_out : last_flow_index_in; // - Shift the flows // - Update the flow_index of the flows for (i = last_flow_index; i > pivot_index; i--) @@ -194,6 +217,24 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * } } } + else + { // The pivot flow was not found in this in_out, so we just update the flow_index + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) + { + flow = ((in_out) ? (tc->out) : (tc->in))[i]; + if(!flow) + break; // end of the array + if(!parsec_helper_flow_is_in_flow_array(flow, shifted_flows, shifted_flows_size)) + { + if(flow->flow_index > pivot_flow_index) + { + flow->flow_index += shift; + } + shifted_flows[shifted_flows_size] = flow; + shifted_flows_size++; + } + } + } } /* From 47bc442a75d4b7b7abf677fd0c63f04f10ce426a Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 20 Feb 2023 12:39:40 +0100 Subject: [PATCH 139/157] update dependencies_goal later --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 47 +++++++++++++--------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 62922a4fd..adaad7493 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -5960,7 +5960,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " }\n" " if(flow == base_flow_of_current_flow) {\n" " pivot_reached = true;\n" - " // Update the goal of the task class\n" + " /*// Update the goal of the task class\n" " if(flow_in_out == 0)\n" " {\n" " // If is input, shift the proper values in the goal\n" @@ -5970,7 +5970,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " parsec_dependency_t shifted_values = (tc->dependencies_goal >> (i + 1)) << (i + 1 + shift);\n" " parsec_dependency_t in_between = ((1<<(shift+1))-1) << i;\n" " tc->dependencies_goal = unshifted_values | shifted_values | in_between;\n" - " }\n" + " }*/\n" " assert(i+nb_specializations_of_current_flow < MAX_DATAFLOWS_PER_TASK);\n" " }\n" " if(pivot_reached)\n" @@ -5981,7 +5981,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) " ++parametrized_iterator;\n" " }\n" " }\n" - " assert(pivot_reached); // Actually, the pivot is not reached if READ/WRITE-only\n" + " // assert(pivot_reached); // Actually, the pivot is not reached if READ/WRITE-only\n" " }\n" " // Update nb_flows\n" " tc->nb_flows += nb_specializations_of_current_flow-1;\n" @@ -6339,6 +6339,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" // at this point, all the parametrized flows have been created, but the structure can have some incoherencies:\n"); coutput(" // - when a parametrized flow is unrolled, the deps are not copied in memory\n"); coutput(" // - the dep_index is not correct (there can be duplicates in a task class)\n"); + coutput(" // - the goal masks are not correct (dependencies_goal and flow_datatype_mask)\n"); coutput(" // The next block of code will fix these issues\n"); coutput(" {\n"); @@ -6384,22 +6385,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("#endif\n"); coutput("\n"); - coutput(" /*// (set the flow_datatype_mask's of out flows to zero)\n"); - for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) - { - if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) - { - coutput(" { // %s\n", f->fname); - coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n", f->task_class_id); - coutput(" for(int flow_id = 0; flow_id < tc->nb_flows && flow_id < MAX_DATAFLOWS_PER_TASK; flow_id++) {\n"); - coutput(" parsec_flow_t *flow = tc->out[flow_id];\n"); - coutput(" if(NULL == flow) break;\n"); - coutput(" flow->flow_datatype_mask = 0;\n"); - coutput(" }\n"); - coutput(" }\n"); - } - } - coutput("*/\n"); coutput(" // Second, fix the dep_indexes\n"); @@ -6456,6 +6441,21 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" }\n"); + coutput("\n"); + coutput(" // Set dependencies_goal to zero for task classes that have parametrized flows\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) + { + if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + { + coutput(" { // %s\n", f->fname); + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n\n", f->task_class_id); + coutput(" tc->dependencies_goal = 0;\n"); + coutput(" }\n"); + } + } + coutput("\n"); + + coutput(" // Finally, retrieve the correct indices for the parametrized flows and the referrers\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) @@ -6741,6 +6741,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { coutput(" { // task class %s\n", f->fname); + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n", f->task_class_id); coutput(" // spec_%s.dep_mask_out_of_flow_of_%s_%s = 0; // should already be set to 0\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { @@ -6775,6 +6776,14 @@ static void jdf_generate_new_function( const jdf_t* jdf ) JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" }\n"); } + + coutput("\n"); + coutput(" // Now, update the dependencies_goal of %s\n", f->fname); + coutput(" for(int i=0; iin[i];\n"); + coutput(" if( NULL == flow ) break;\n"); + coutput(" tc->dependencies_goal |= flow->flow_datatype_mask;\n"); + coutput(" }\n"); coutput(" }\n"); } From ebb81942cc753708053dced95bdde8769a0cf109 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 20 Feb 2023 12:56:37 +0100 Subject: [PATCH 140/157] correction --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index adaad7493..07223fb4e 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6741,7 +6741,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { coutput(" { // task class %s\n", f->fname); - coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n", f->task_class_id); coutput(" // spec_%s.dep_mask_out_of_flow_of_%s_%s = 0; // should already be set to 0\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { @@ -6776,21 +6775,25 @@ static void jdf_generate_new_function( const jdf_t* jdf ) JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" }\n"); } + coutput(" }\n"); + } + } - coutput("\n"); - coutput(" // Now, update the dependencies_goal of %s\n", f->fname); + coutput("\n"); + coutput(" // Update dependencies_goal for task classes that need them\n"); + for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { + if( TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + coutput(" { // task class %s\n", f->fname); + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n", f->task_class_id); coutput(" for(int i=0; iin[i];\n"); coutput(" if( NULL == flow ) break;\n"); - coutput(" tc->dependencies_goal |= flow->flow_datatype_mask;\n"); + coutput(" tc->dependencies_goal |= 1<flow_index;\n"); coutput(" }\n"); - coutput(" }\n"); } } - - coutput("\n"); coutput( From 99d818f9b540a74a255ec3a77ab7365d8c7f4ee7 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 20 Feb 2023 14:07:08 +0100 Subject: [PATCH 141/157] correct parsec_check_sanity_of_task_class --- parsec/task_class.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index fe63b0090..431674920 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -573,35 +573,37 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc, bool check_dep_i // Check the coherency of the flow flags if(check_dep_index) { - for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) - { - const parsec_flow_t *flow = tc->out[i]; - - if (!flow) + for(int in_out=0; in_out<2; ++in_out) { + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { - break; - } + const parsec_flow_t *flow = tc->out[i]; - // For each output dep of the flow ... - for (j = 0; j < (dep_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) - { - dep = (parsec_dep_t *)(dep_in_out ? flow->dep_out[j] : flow->dep_in[j]); - if (!dep) + if (!flow) { break; } - if(dep_in_out == 1) + // For each output dep of the flow ... + for (j = 0; j < (in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) { - // All out dependencies should be in the flow datatype mask - assert((1 << dep->dep_datatype_index) & flow->flow_datatype_mask); - //assert((1 << dep->dep_index) & flow->flow_datatype_mask); + dep = (parsec_dep_t *)(in_out ? flow->dep_out[j] : flow->dep_in[j]); + if (!dep) + { + break; + } - // All out dependencies should be mappable in the flow datatype mask - assert(dep->dep_datatype_index < sizeof(flow->flow_datatype_mask) * 8); - } + if(in_out == 1) + { + // All out dependencies should be in the flow datatype mask + assert((1 << dep->dep_datatype_index) & flow->flow_datatype_mask); + //assert((1 << dep->dep_index) & flow->flow_datatype_mask); + + // All out dependencies should be mappable in the flow datatype mask + assert(dep->dep_datatype_index < sizeof(flow->flow_datatype_mask) * 8); + } - assert(dep->dep_index < (dep_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT)); + assert(dep->dep_index < (in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT)); + } } } } From 676a5f2be733456a1a0c69bf60806bf9b0018bd0 Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 20 Feb 2023 18:38:57 +0100 Subject: [PATCH 142/157] update the parametrized iterator so that it can be used in conditions --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 84 +++++++++++++++++++ .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 18 ++++ 2 files changed, 102 insertions(+) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 07223fb4e..c5824c4f6 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -2149,6 +2149,76 @@ jdf_generate_function_without_expression(const jdf_t *jdf, UTIL_DUMP_LIST(sa2, f->locals, next, dump_local_assignments, &ai, "", " ", "\n", "\n")); + // Add parametrized iterators + char *dumped_iterator_lists[MAX_DATAFLOWS_PER_TASK]; + int dumped_iterator_lists_count = 0; + for( jdf_dataflow_t *df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + if(!STRING_IS_IN(get_parametrized_flow_iterator_name(df), dumped_iterator_lists, dumped_iterator_lists_count)) + { + dumped_iterator_lists[dumped_iterator_lists_count++] = get_parametrized_flow_iterator_name(df); + + coutput(" const int %s = locals->ldef[%d].value;\n", + get_parametrized_flow_iterator_name(df), df->local_variables->ldef_index); + } + else + { + coutput(" // Warning: %s already dumped, ldef_index might be ambiguous\n", + get_parametrized_flow_iterator_name(df)); + + // // output an error in stderr too + fprintf(stderr, "Warning: %s already dumped, ldef_index might be ambiguous\n", + get_parametrized_flow_iterator_name(df)); + } + } + } + + + coutput("#if defined(PARSEC_DEBUG_PARANOID)\n"); + coutput(" // Coherency test:\n"); + dumped_iterator_lists_count = 0; + for( jdf_dataflow_t *df = f->dataflow; NULL != df; df = df->next ) { + if( FLOW_IS_PARAMETRIZED(df) ) { + if(!STRING_IS_IN(get_parametrized_flow_iterator_name(df), dumped_iterator_lists, dumped_iterator_lists_count)) + { + dumped_iterator_lists[dumped_iterator_lists_count++] = get_parametrized_flow_iterator_name(df); + + expr_info_t info = EMPTY_EXPR_INFO; + info.sa = string_arena_new(8); + info.prefix = ""; + info.suffix = ""; + info.assignments = "assignments"; + + coutput(" if( %s < 0 || %s > %s ) {\n", + get_parametrized_flow_iterator_name(df), + get_parametrized_flow_iterator_name(df), + dump_expr((void**)df->local_variables->jdf_ta2, &info)); + + // Verify that the expression is the same for ALL the vlues from min to max + coutput(" // The local variable is out of its range, this can be reasonable if it does not change the result of the expression\n"); + coutput(" for(int %s = 0; %s <= %s; %s++) {\n", + get_parametrized_flow_iterator_name(df), + get_parametrized_flow_iterator_name(df), + dump_expr((void**)df->local_variables->jdf_ta2, &info), + get_parametrized_flow_iterator_name(df)); + coutput(" const int current_%s = %s;\n", + get_parametrized_flow_iterator_name(df), + get_parametrized_flow_iterator_name(df)); + coutput("#define %s current_%s\n", get_parametrized_flow_iterator_name(df), get_parametrized_flow_iterator_name(df)); + coutput(" const int expr_if_iterator_equals_current = %s;\n", dump_expr((void**)e, &info)); + coutput("#undef %s\n", get_parametrized_flow_iterator_name(df)); + coutput(" assert(expr_if_iterator_equals_current == %s);\n", + dump_expr((void**)e, &info)); + coutput(" }\n"); + coutput(" }\n"); + + string_arena_free(info.sa); + } + } + } + coutput("#endif\n"); + + ai.holder = ""; coutput("%s\n", UTIL_DUMP_LIST(sa2, f->locals, next, dump_local_used_in_expr, &ai, @@ -10126,9 +10196,23 @@ static char *jdf_dump_context_assignment(string_arena_t *sa_open, } else { + // string_arena_add_string(sa_open, + // "%s%sncc->locals.ldef[%d].value = %s = %s;\n", + // prefix, indent(nbopen), + // flow->local_variables->ldef_index, + // get_parametrized_flow_iterator_name(flow), dump_expr((void**)ld, &local_info)); string_arena_add_string(sa_open, "%s%s "JDF2C_NAMESPACE"_tmp_locals.ldef[%d].value = %s = %s;\n", prefix, indent(nbopen), ld->ldef_index, ld->alias, dump_expr((void**)ld, &local_info)); + + // If the call is a referrer, keep the ldef up-to-date + if(CALL_IS_PARAMETRIZED(call) && !strcmp(call->parametrized_offset->alias, ld->alias)) + { + string_arena_add_string(sa_open, "%s%sncc->locals.ldef[%d].value = %s;\n", + prefix, indent(nbopen), + ld->ldef_index, + ld->alias); + } } } } diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index f2b438cc3..f4d9a236f 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -302,6 +302,24 @@ static inline int task_class_any_flow_is_parametrized_util(const jdf_function_en } +/** + * STRING_IS_IN: + * Tells whether a string is in a list of strings. + * + */ +#define STRING_IS_IN(string, arr, arr_size) \ + string_is_in_util(string, arr, arr_size) + +static inline int string_is_in_util(const char *string, const char **arr, int arr_size) +{ + for( int i=0; i Date: Mon, 20 Feb 2023 18:44:56 +0100 Subject: [PATCH 143/157] declare the referrer iterators before normal locals so that it can be used in their expressions --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index c5824c4f6..48cd508e4 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -7753,14 +7753,13 @@ jdf_generate_code_call_initialization(const jdf_t *jdf, const jdf_call_t *call, if( call->var != NULL ) { coutput("%s *target_locals = (%s*)&generic_locals;\n", parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); - coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); - if(CALL_IS_PARAMETRIZED(call)) { // output the value of the iterator coutput("%s const int %s = %s; (void)%s;\n", spaces, call->parametrized_offset->alias, dump_expr((void**)call->parametrized_offset, &info), call->parametrized_offset->alias); } + coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", call)); /* Code to fulfill a reshape promise set up by predecessor if there's one */ jdf_generate_code_consume_predecessor_setup(jdf, call, @@ -8822,8 +8821,7 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const string_arena_init(sa); coutput("%s %s *target_locals = (%s*)&generic_locals;\n", - spaces, parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); - coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", source_call)); + spaces, parsec_get_name(jdf, targetf, "parsec_assignment_t"), parsec_get_name(jdf, targetf, "parsec_assignment_t")); // for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { // // Get the function parameter if it is one // const jdf_expr_t *el; @@ -8930,6 +8928,7 @@ static void jdf_generate_check_for_one_call_to_call_link(const jdf_t *jdf, const } } } + coutput("%s", jdf_create_code_assignments_calls(sa, strlen(spaces)+1, jdf, "target_locals", source_call)); for(jdf_variable_list_t *vl = targetf->locals; vl != NULL; vl = vl->next) { coutput("#define %s %s%s\n", vl->name, targetf->fname, vl->name); From 0f119019323962162732aaf9a7c57c34e258c68b Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 22 Feb 2023 11:45:25 +0100 Subject: [PATCH 144/157] correct some mistakes in jdf2c + separate in/out flows in parsec_debug_dump_task_class_at_exec --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 25 +++++++++++++--------- parsec/task_class.c | 14 ++++++------ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 48cd508e4..247379e22 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1876,7 +1876,10 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) if(JDF_ANY_FLOW_IS_PARAMETRIZED(jdf)) { coutput("/** Predeclarations of the parametrized spec_TASK_TYPES */\n"); for(f = jdf->functions; f != NULL; f = f->next) { - coutput("static parsec_%s_task_class_t spec_%s;\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) + { + coutput("static parsec_%s_task_class_t spec_%s;\n", JDF_OBJECT_ONAME(f), JDF_OBJECT_ONAME(f)); + } } } @@ -6530,6 +6533,8 @@ static void jdf_generate_new_function( const jdf_t* jdf ) for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n\n", f->task_class_id); + coutput(" int current_data_offset_for_%s_%s = 0;\n", jdf_basename, f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { @@ -6539,8 +6544,6 @@ static void jdf_generate_new_function( const jdf_t* jdf ) //coutput(" spec_%s.out_offset_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out);\n" // JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname,); - coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n\n", f->task_class_id); - coutput("#if defined(PARSEC_DEBUG_NOISIER)\n"); coutput(" spec_%s.nb_specializations_of_parametrized_flow_of_%s_%s_for_%s = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", JDF_OBJECT_ONAME(f), @@ -6699,17 +6702,17 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" }\n"); } - else if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + else// if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) // we already know that TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED { coutput(" { // flow %s of task class %s\n", df->varname, f->fname); coutput(" // dynamic flow id of flow %s of task class %s\n", df->varname, f->fname); - coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index_in_or_out(tc, &flow_of_%s_%s_for_parametrized_%s[0]);\n", + coutput(" spec_%s.flow_id_of_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index_in_or_out(tc, &flow_of_%s_%s_for_%s);\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); - coutput(" assert(spec_%s.flow_id_of_flow_of_%s_%s_for_%s >= 0); // nonesense because uint\n", + coutput(" // assert(spec_%s.flow_id_of_flow_of_%s_%s_for_%s >= 0); // nonesense because uint\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); coutput(" }\n"); @@ -7528,7 +7531,7 @@ jdf_generate_code_reshape_input_from_dep(const jdf_t *jdf, // Get the flow id as a string string_arena_t *sa_flow_index = string_arena_new(128); - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + if(FLOW_IS_PARAMETRIZED(flow)) { DUMP_FLOW_ID_VARIABLE(sa_flow_index, jdf_basename, f, flow); } @@ -7583,7 +7586,7 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * string_arena_init(sa_pred_consumed_flow_index); - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(pred_f)) + if(FLOW_IS_PARAMETRIZED(pred_flow)) { DUMP_FLOW_ID_VARIABLE(sa_pred_consumed_flow_index, jdf_basename, pred_f, pred_flow); } @@ -7591,7 +7594,7 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * { string_arena_add_string(sa_pred_consumed_flow_index, "%d", pred_flow->flow_index); } - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + if(FLOW_IS_PARAMETRIZED(flow)) { DUMP_FLOW_ID_VARIABLE(sa_consumed_flow_index, jdf_basename, f, flow); } @@ -8141,7 +8144,7 @@ static void jdf_generate_code_flow_initialization(const jdf_t *jdf, // Get the flow id as a string string_arena_t *sa_flow_index = string_arena_new(128); - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) + if(FLOW_IS_PARAMETRIZED(flow)) { DUMP_FLOW_ID_VARIABLE(sa_flow_index, jdf_basename, f, flow); } @@ -9082,6 +9085,7 @@ jdf_generate_code_data_lookup(const jdf_t *jdf, coutput(" /* check the dependencies for %s */\n", flow->varname); coutput("#if defined(PARSEC_DEBUG_PARANOID)\n"); + coutput("/* Commented because these checks are too restrictive\n"); coutput("// All the referrers to the parametrized flow %s of task class %s:\n", flow->varname, f->fname); string_arena_t *sa_loop = string_arena_new(64); @@ -9113,6 +9117,7 @@ jdf_generate_code_data_lookup(const jdf_t *jdf, coutput("%s", string_arena_get_string(sa_loop)); string_arena_free(sa_loop); + coutput("*/\n"); coutput("#endif // PARSEC_DEBUG_PARANOID\n\n"); } diff --git a/parsec/task_class.c b/parsec/task_class.c index 431674920..45b360bba 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -476,17 +476,19 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) parsec_debug_verbose(1, parsec_debug_output, "## dependencies_goal = %x", tc->dependencies_goal); - for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) + for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) { - for (flow_in_out = 0; flow_in_out < 2; ++flow_in_out) + parsec_debug_verbose(1, parsec_debug_output, "## %s flows:", flow_in_out ? "out" : "in"); + for (i = 0; i < MAX_DATAFLOWS_PER_TASK; i++) { flow = (parsec_flow_t *)(flow_in_out ? tc->out[i] : tc->in[i]); - if (flow && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)) + if (flow/* && !parsec_helper_flow_is_in_flow_array(flow, treated_flows, treated_flows_size)*/) { - parsec_debug_verbose(1, parsec_debug_output, " RW flow %s (addr=%p, id=%d, flow_datatype_mask=%p, flow_flags=%p)", + parsec_debug_verbose(1, parsec_debug_output, " X flow %s (addr=%p, id=%d, flow_datatype_mask=%p, flow_flags=%p)", flow->name, (void *)flow, flow->flow_index, flow->flow_datatype_mask, flow->flow_flags); - for (dep_in_out = 0; dep_in_out < 2; ++dep_in_out) + //for (dep_in_out = 0; dep_in_out < 2; ++dep_in_out) + dep_in_out = flow_in_out; { for (j = 0; j < (dep_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); j++) { @@ -596,7 +598,7 @@ void parsec_check_sanity_of_task_class(parsec_task_class_t *tc, bool check_dep_i { // All out dependencies should be in the flow datatype mask assert((1 << dep->dep_datatype_index) & flow->flow_datatype_mask); - //assert((1 << dep->dep_index) & flow->flow_datatype_mask); + // assert((1 << dep->dep_index) & flow->flow_datatype_mask); // All out dependencies should be mappable in the flow datatype mask assert(dep->dep_datatype_index < sizeof(flow->flow_datatype_mask) * 8); From 6ce580322dba75b99c5763eec038effff3cff1f4 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 22 Feb 2023 12:37:57 +0100 Subject: [PATCH 145/157] fix error in parsec_helper_get_flow_index --- parsec/task_class.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/parsec/task_class.c b/parsec/task_class.c index 45b360bba..75c7f3522 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -724,6 +724,19 @@ int parsec_helper_get_flow_index_that_contains_dep(const parsec_task_class_t *tc int parsec_helper_get_flow_index_in_or_out(const parsec_task_class_t *tc, const parsec_flow_t *flow) { + /*int i = parsec_helper_get_flow_index(tc, flow, 1); + if(i != -1) + { + return i; + } + // If the flow was not found, it is a read-only flow, let's affect it a new index + i = parsec_helper_get_flow_index(tc, flow, 0); + assert(i != -1); + // Add the number of out flows to the index to make it unique + int nb_out_flows = parsec_helper_get_flow_index(tc, NULL, 1); + assert(nb_out_flows != -1); + i += nb_out_flows; + return i;*/ int i = parsec_helper_get_flow_index(tc, flow, 1); i = ((i == -1) ? parsec_helper_get_flow_index(tc, flow, 0) : i); assert(i != -1); @@ -737,14 +750,14 @@ int parsec_helper_get_flow_index(const parsec_task_class_t *tc, const parsec_flo { const parsec_flow_t *_flow = (in_out ? tc->out[i] : tc->in[i]); - if (!flow) + if (flow == _flow) { - break; + return i; } - if (flow == _flow) + if (!_flow) { - return i; + break; } } From e84e2becf1632523cc384540727403352d8f569b Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 22 Feb 2023 15:14:58 +0100 Subject: [PATCH 146/157] construct dep_mask_out_of_flow_of_%s_%s_for_%s with dep_index instead of flow_id --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 29 +++++++++++++++------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 247379e22..5a90f1298 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6826,21 +6826,31 @@ static void jdf_generate_new_function( const jdf_t* jdf ) jdf_basename, f->fname, df->varname); coutput(" int specializations_number = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", jdf_basename, f->fname, df->varname); - coutput(" spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s = ((1<<(specializations_number))-1)<flow_index;\n", + /*coutput(" spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s = ((1<<(specializations_number))-1)<flow_index;\n", JDF_OBJECT_ONAME(f), - jdf_basename, f->fname, df->varname); - coutput(" //spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s = flow->flow_datatype_mask;\n", - JDF_OBJECT_ONAME(f), - jdf_basename, f->fname, df->varname); + jdf_basename, f->fname, df->varname);*/ } else { coutput(" parsec_flow_t *flow = &flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); - coutput(" spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s = 1<flow_index;\n", - JDF_OBJECT_ONAME(f), - jdf_basename, f->fname, df->varname); + } + + coutput(" for(int idep=0;idepdep_out[idep];\n"); + coutput(" if(NULL == dep) break;\n"); + coutput(" spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s |= 1<dep_index;\n", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, df->varname); + coutput(" }\n"); + + coutput(" //spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s = flow->flow_datatype_mask;\n", + JDF_OBJECT_ONAME(f), + jdf_basename, f->fname, df->varname); + + coutput(" spec_%s.dep_mask_out_of_flow_of_%s_%s |= spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname); @@ -11018,8 +11028,9 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_t *sa_action_mask = string_arena_new(128); if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(f)) { // dynamic masks if any flow/dep is parametrized - string_arena_add_string(sa_action_mask, "spec_%s.dep_mask_out_of_flow_of_%s_%s_for_%s", + string_arena_add_string(sa_action_mask, "spec_%s.dep_mask_%s_of_flow_of_%s_%s_for_%s", JDF_OBJECT_ONAME(f), + (flow_type & JDF_DEP_FLOW_OUT) ? "out" : "in", jdf_basename, f->fname, fl->varname); } else From 6b355e6c3e761cfc19beb5cf6e26dc1e68d10391 Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 23 Feb 2023 16:55:15 +0100 Subject: [PATCH 147/157] correct brackets in iterate_successors --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 5a90f1298..407bda79d 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -11012,10 +11012,14 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, OUTPUT_PREV_DEPS((1U << dl->dep_index), sa_datatype, sa_deps); } - while(nb_open_ldef > 0) { + while(nb_open_ldef > FLOW_IS_PARAMETRIZED(fl)?1:0) { // If the flow is parametrized, we need to keep the first { (corresponding to the parametrized flow iterator's loop) string_arena_add_string(sa_coutput, "%s }\n", indent(nb_open_ldef)); nb_open_ldef--; } + /*while(nb_open_ldef > 0) { // If the flow is parametrized, we need to keep the first { (corresponding to the parametrized flow iterator's loop) + string_arena_add_string(sa_coutput, "%s }\n", indent(nb_open_ldef)); + nb_open_ldef--; + }*/ } if( (1 == flowempty) && (0 == flowtomem) ) { @@ -11039,6 +11043,11 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, string_arena_add_string(sa_action_mask, "0x%xU", (flow_type & JDF_DEP_FLOW_OUT) ? fl->flow_dep_mask_out : fl->flow_dep_mask_in/*mask*/); } + if(FLOW_IS_PARAMETRIZED(fl)) { + string_arena_add_string(sa_coutput, " } // end of parametrized flow %s\n", fl->varname); + nb_open_ldef--; + } + assert(0 == nb_open_ldef); /*if(FLOW_IS_PARAMETRIZED(fl)) { @@ -11059,6 +11068,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, }*/ string_arena_free(sa_action_mask); } + } coutput(" (void)data;(void)nc;(void)es;(void)ontask;(void)ontask_arg;(void)rank_dst;(void)action_mask;\n"); coutput("}\n\n"); From f5aa87300ea3466a0731e93132b9672a1573e14a Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 2 Mar 2023 13:29:14 +0100 Subject: [PATCH 148/157] open brackets + increase the str size of the mask --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 407bda79d..429a6d676 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6533,6 +6533,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + coutput(" { // task class %s\n", f->fname); coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[%d];\n\n", f->task_class_id); coutput(" int current_data_offset_for_%s_%s = 0;\n", jdf_basename, f->fname); @@ -6718,6 +6719,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" }\n"); } } + coutput(" }\n"); } } for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { @@ -8516,7 +8518,7 @@ static void jdf_generate_code_call_release_dependencies(const jdf_t *jdf, jdf_dataflow_t* dl; (void)jdf; - char complete_mask_str[92]; + char complete_mask_str[256]; for( dl = function->dataflow; dl != NULL; dl = dl->next ) { complete_mask |= dl->flow_dep_mask_out; @@ -8525,12 +8527,12 @@ static void jdf_generate_code_call_release_dependencies(const jdf_t *jdf, // if the task class has any parametrized flow is referrer, the mask can not be computed at compile time if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED_OR_REFERRER(function)) { - snprintf(complete_mask_str, 92, "spec_%s.dep_mask_out_of_flow_of_%s_%s", + snprintf(complete_mask_str, 256, "spec_%s.dep_mask_out_of_flow_of_%s_%s", JDF_OBJECT_ONAME(function), jdf_basename, function->fname); } else { - snprintf(complete_mask_str, 92, "0x%x", complete_mask); + snprintf(complete_mask_str, 256, "0x%x", complete_mask); } coutput(" release_deps_of_%s_%s(es, %s,\n" From f32bf5af975fdf09f36bc77e9913bcd14199b8ca Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 9 Mar 2023 11:35:34 +0100 Subject: [PATCH 149/157] correct flow_id for gpu tasks + correct dump flow id + some minor changes --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 10 ++++---- .../interfaces/ptg/ptg-compiler/jdf2c_utils.h | 23 +++++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 429a6d676..5218448ea 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -2177,7 +2177,7 @@ jdf_generate_function_without_expression(const jdf_t *jdf, } - coutput("#if defined(PARSEC_DEBUG_PARANOID)\n"); + coutput("/*\n // Commented because it gives a lot of errors on valgrind\n #if defined(PARSEC_DEBUG_PARANOID)\n"); coutput(" // Coherency test:\n"); dumped_iterator_lists_count = 0; for( jdf_dataflow_t *df = f->dataflow; NULL != df; df = df->next ) { @@ -2219,7 +2219,7 @@ jdf_generate_function_without_expression(const jdf_t *jdf, } } } - coutput("#endif\n"); + coutput("#endif*/\n"); ai.holder = ""; @@ -7598,7 +7598,7 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * string_arena_init(sa_pred_consumed_flow_index); - if(FLOW_IS_PARAMETRIZED(pred_flow)) + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(pred_f)) { DUMP_FLOW_ID_VARIABLE(sa_pred_consumed_flow_index, jdf_basename, pred_f, pred_flow); } @@ -7606,7 +7606,7 @@ jdf_generate_code_consume_predecessor_setup(const jdf_t *jdf, const jdf_call_t * { string_arena_add_string(sa_pred_consumed_flow_index, "%d", pred_flow->flow_index); } - if(FLOW_IS_PARAMETRIZED(flow)) + if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { DUMP_FLOW_ID_VARIABLE(sa_consumed_flow_index, jdf_basename, f, flow); } @@ -9497,7 +9497,7 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, if( FLOW_IS_PARAMETRIZED(fl) ) { // If the flow is out (note: we use either in or out, this is our only way of getting a parametrized_flow) - if( JDF_FLOW_TYPE_READ & fl->flow_flags ) { + if( JDF_FLOW_TYPE_WRITE & fl->flow_flags ) { coutput("%s gpu_task->flow[%s] = this_task->task_class->out[spec_%s_%s.out_flow_offset_of_parametrized_%s + %s];\n", INDENTATION_IF_PARAMETRIZED(fl), di_str, jdf_basename, f->fname, JDF_OBJECT_ONAME(fl), get_parametrized_flow_iterator_name(fl)); diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h index f4d9a236f..ad4089941 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c_utils.h @@ -102,15 +102,24 @@ static inline char *util_dump_flow_id_variable(string_arena_t *sa, const char *j { string_arena_init(sa); - // if(flow->flow_flags & JDF_FLOW_TYPE_WRITE) - // { + // // if(flow->flow_flags & JDF_FLOW_TYPE_WRITE) + // // { + // string_arena_add_string(sa, "(spec_%s.flow_id_of_flow_of_%s_%s_for_%s + %s)", + // JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); + // // } + // // else + // // { + // // string_arena_add_string(sa, "DUNNO_HOW_TO_GET_ACTION_MASK_FOR_THIS_FLOW"); + // // } + + if( FLOW_IS_PARAMETRIZED(flow) ) { string_arena_add_string(sa, "(spec_%s.flow_id_of_flow_of_%s_%s_for_%s + %s)", JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname, get_parametrized_flow_iterator_name(flow)); - // } - // else - // { - // string_arena_add_string(sa, "DUNNO_HOW_TO_GET_ACTION_MASK_FOR_THIS_FLOW"); - // } + } + else { + string_arena_add_string(sa, "spec_%s.flow_id_of_flow_of_%s_%s_for_%s", + JDF_OBJECT_ONAME(function), jdf_basename, function->fname, flow->varname); + } return string_arena_get_string(sa); } From c6b7d85d6035ba341d04e593d715af2526f413f8 Mon Sep 17 00:00:00 2001 From: cflinto Date: Thu, 9 Mar 2023 16:26:20 +0100 Subject: [PATCH 150/157] correct the filling ot the gpu_task structure --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 62 ++++++++++------------ 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 5218448ea..c34e2fe89 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -9463,27 +9463,35 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, /* Dump the dataflow */ coutput(" gpu_task->pushout = 0;\n"); - if(TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { - // We need this variable if at least on flow is parametrized - coutput(" int current_flow_id=0;\n"); - } - - int parametrized_flow_has_been_encountered = 0; - string_arena_t *sa_di = string_arena_new(64); + string_arena_t *sa_flow = string_arena_new(256); for(fl = f->dataflow, di = 0; fl != NULL; fl = fl->next, di++) { coutput(" // Dataflow %s\n", fl->varname); - if(FLOW_IS_PARAMETRIZED(fl)) { - // If this flow is parametrized, all the following ones will have a dynamic id - parametrized_flow_has_been_encountered = 1; + string_arena_init(sa_flow); + if( FLOW_IS_PARAMETRIZED(fl) ) { + if( JDF_FLOW_TYPE_WRITE & fl->flow_flags ) { + // If the flow is out (note: we use either in or out, this is our only way of getting a parametrized_flow) + string_arena_add_string(sa_flow, "this_task->task_class->out[spec_%s_%s.out_flow_offset_of_parametrized_%s + %s]", + jdf_basename, f->fname, JDF_OBJECT_ONAME(fl), get_parametrized_flow_iterator_name(fl)); + } + else + { + string_arena_add_string(sa_flow, "this_task->task_class->in[spec_%s_%s.in_flow_offset_of_parametrized_%s + %s]", + jdf_basename, f->fname, JDF_OBJECT_ONAME(fl), get_parametrized_flow_iterator_name(fl)); + } + } + else + { + string_arena_add_string(sa_flow, "(&%s)", JDF_OBJECT_ONAME( fl )); } - string_arena_init(sa_di); - if( parametrized_flow_has_been_encountered ) { - // We use the current_flow_id variable because we cannot compute di at compile time - string_arena_add_string(sa_di, "current_flow_id"); + if( FLOW_IS_PARAMETRIZED(fl) || TASK_CLASS_ANY_FLOW_IS_PARAMETRIZED(f)) { + // The flow is parametrized + string_arena_add_string(sa_di, "%s->flow_index", + string_arena_get_string(sa_flow)); } else { + // No parametrized flow, we know di at compile time string_arena_add_string(sa_di, "%d", di); } const char *di_str = string_arena_get_string(sa_di); @@ -9495,23 +9503,8 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, string_arena_free(sa); } - if( FLOW_IS_PARAMETRIZED(fl) ) { - // If the flow is out (note: we use either in or out, this is our only way of getting a parametrized_flow) - if( JDF_FLOW_TYPE_WRITE & fl->flow_flags ) { - coutput("%s gpu_task->flow[%s] = this_task->task_class->out[spec_%s_%s.out_flow_offset_of_parametrized_%s + %s];\n", - INDENTATION_IF_PARAMETRIZED(fl), di_str, - jdf_basename, f->fname, JDF_OBJECT_ONAME(fl), get_parametrized_flow_iterator_name(fl)); - } - else - { - coutput("%s gpu_task->flow[%s] = this_task->task_class->in[spec_%s_%s.in_flow_offset_of_parametrized_%s + %s];\n", - INDENTATION_IF_PARAMETRIZED(fl), di_str, - jdf_basename, f->fname, JDF_OBJECT_ONAME(fl), get_parametrized_flow_iterator_name(fl)); - } - }else{ - coutput("%s gpu_task->flow[%s] = &%s;\n", - INDENTATION_IF_PARAMETRIZED(fl), di_str, JDF_OBJECT_ONAME( fl )); - } + coutput("%s gpu_task->flow[%s] = %s;\n", + INDENTATION_IF_PARAMETRIZED(fl), di_str, string_arena_get_string(sa_flow)); sprintf(sa->ptr, "%s.dc", fl->varname); jdf_find_property(body->properties, sa->ptr, &desc_property); @@ -9533,9 +9526,12 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, exit(-1); } coutput("%s gpu_task->flow_nb_elts[%s] = 0;\n", INDENTATION_IF_PARAMETRIZED(fl), di_str); + coutput("%s ++current_flow_id;\n", INDENTATION_IF_PARAMETRIZED(fl)); }else{ if(size_property == NULL){ - coutput("%s gpu_task->flow_nb_elts[%s] = gpu_task->ec->data[%s].data_in->original->nb_elts;\n", INDENTATION_IF_PARAMETRIZED(fl), di_str, di_str); + coutput("%s // If gpu_task->ec->data[%s].data_in is NULL, then 0 elements\n", INDENTATION_IF_PARAMETRIZED(fl), di_str); + coutput("%s gpu_task->flow_nb_elts[%s] = (gpu_task->ec->data[%s].data_in)?(gpu_task->ec->data[%s].data_in->original->nb_elts):0;\n", + INDENTATION_IF_PARAMETRIZED(fl), di_str, di_str, di_str); }else{ coutput("%s gpu_task->flow_nb_elts[%s] = %s;\n", INDENTATION_IF_PARAMETRIZED(fl), di_str, dump_expr((void**)size_property->expr, &info)); @@ -9607,8 +9603,6 @@ static void jdf_generate_code_hook_cuda(const jdf_t *jdf, } if(FLOW_IS_PARAMETRIZED(fl)) { - coutput(" current_flow_id++;\n"); - string_arena_t *sa = string_arena_new(64); dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa); coutput("%s", string_arena_get_string(sa)); From cce19f88fb7f7ed87c5bbbef1974f5fc850092a6 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 10 Mar 2023 11:22:03 +0100 Subject: [PATCH 151/157] switch to a 64-bit mask for dependencies --- parsec/data_dist/matrix/map_operator.c | 4 +-- parsec/include/parsec/parsec_config_bottom.h | 12 ++++++--- parsec/interfaces/dtd/insert_function.c | 8 +++--- parsec/interfaces/ptg/ptg-compiler/jdf.c | 2 +- parsec/interfaces/ptg/ptg-compiler/jdf.h | 4 +-- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 28 ++++++++++---------- parsec/mca/device/transfer_gpu.c | 6 ++--- parsec/parsec.c | 20 +++++++------- parsec/parsec_internal.h | 6 ++--- parsec/remote_dep.h | 18 ++++++------- parsec/task_class.c | 5 ++-- 11 files changed, 59 insertions(+), 54 deletions(-) diff --git a/parsec/data_dist/matrix/map_operator.c b/parsec/data_dist/matrix/map_operator.c index 204763bab..3297ccd4c 100644 --- a/parsec/data_dist/matrix/map_operator.c +++ b/parsec/data_dist/matrix/map_operator.c @@ -199,7 +199,7 @@ add_task_to_list(parsec_execution_stream_t *es, static void iterate_successors(parsec_execution_stream_t *es, const parsec_task_t *this_task, - uint32_t action_mask, + parsec_dependency_t action_mask, parsec_ontask_function_t *ontask, void *ontask_arg) { @@ -245,7 +245,7 @@ static void iterate_successors(parsec_execution_stream_t *es, static int release_deps(parsec_execution_stream_t *es, parsec_task_t *this_task, - uint32_t action_mask, + parsec_dependency_t action_mask, parsec_remote_deps_t *deps) { parsec_task_t** ready_list; diff --git a/parsec/include/parsec/parsec_config_bottom.h b/parsec/include/parsec/parsec_config_bottom.h index 2978046c1..3f82fd568 100644 --- a/parsec/include/parsec/parsec_config_bottom.h +++ b/parsec/include/parsec/parsec_config_bottom.h @@ -144,12 +144,14 @@ #endif #if defined(PARSEC_SCHED_DEPS_MASK) -typedef int32_t parsec_dependency_t; +//typedef int32_t parsec_dependency_t; +typedef int64_t parsec_dependency_t; #else /** * Should be large enough to support MAX_PARAM_COUNT values. */ -typedef int32_t parsec_dependency_t; +//typedef int32_t parsec_dependency_t; +typedef uint64_t parsec_dependency_t; #endif /* @@ -162,8 +164,10 @@ typedef int32_t parsec_dependency_t; #define MAX_LOCAL_COUNT 20 #define MAX_PARAM_COUNT 20 -#define MAX_DEP_IN_COUNT 21 -#define MAX_DEP_OUT_COUNT 21 +// #define MAX_DEP_IN_COUNT 21 +// #define MAX_DEP_OUT_COUNT 21 +#define MAX_DEP_IN_COUNT 52 +#define MAX_DEP_OUT_COUNT 52 #define MAX_TASK_STRLEN 128 diff --git a/parsec/interfaces/dtd/insert_function.c b/parsec/interfaces/dtd/insert_function.c index 3b6867f24..987c50fae 100644 --- a/parsec/interfaces/dtd/insert_function.c +++ b/parsec/interfaces/dtd/insert_function.c @@ -171,14 +171,14 @@ static int parsec_dtd_tile_new_dc_key_to_string(parsec_data_collection_t *d, par static void parsec_dtd_iterate_successors(parsec_execution_stream_t *es, const parsec_task_t *this_task, - uint32_t action_mask, + parsec_dependency_t action_mask, parsec_ontask_function_t *ontask, void *ontask_arg); static int parsec_dtd_release_deps(parsec_execution_stream_t *, parsec_task_t *, - uint32_t, parsec_remote_deps_t *); + parsec_dependency_t, parsec_remote_deps_t *); static parsec_hook_return_t @@ -1729,7 +1729,7 @@ dtd_release_dep_fct(parsec_execution_stream_t *es, static void parsec_dtd_iterate_successors(parsec_execution_stream_t *es, const parsec_task_t *this_task, - uint32_t action_mask, + parsec_dependency_t action_mask, parsec_ontask_function_t *ontask, void *ontask_arg) { @@ -1765,7 +1765,7 @@ parsec_dtd_iterate_successors(parsec_execution_stream_t *es, static int parsec_dtd_release_deps(parsec_execution_stream_t *es, parsec_task_t *this_task, - uint32_t action_mask, + parsec_dependency_t action_mask, parsec_remote_deps_t *deps) { (void)deps; diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.c b/parsec/interfaces/ptg/ptg-compiler/jdf.c index 00194b8ba..3f40a6bd4 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.c @@ -1524,7 +1524,7 @@ void jdf_dump_function_flows(jdf_function_entry_t* function, int expanded) if( strlen(string_arena_get_string(sa1)) ) string_arena_add_string(sa2, "<%s>", string_arena_get_string(sa1)); - printf("%s: %6s[%1s%1s idx %d, mask 0x%x/0x%x] %2s dep_index %8d dep_dt_index %8d %p <%s %s>\n", function->fname, + printf("%s: %6s[%1s%1s idx %d, mask 0x%lx/0x%lx] %2s dep_index %8d dep_dt_index %8d %p <%s %s>\n", function->fname, flow->varname, (flow->flow_flags & JDF_FLOW_IS_IN ? "R" : " "), (flow->flow_flags & JDF_FLOW_IS_OUT ? "W" : " "), flow->flow_index, flow->flow_dep_mask_in, flow->flow_dep_mask_out, diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf.h b/parsec/interfaces/ptg/ptg-compiler/jdf.h index 9a993f217..9da572d55 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf.h +++ b/parsec/interfaces/ptg/ptg-compiler/jdf.h @@ -292,8 +292,8 @@ struct jdf_dataflow { char *varname; struct jdf_dep *deps; uint8_t flow_index; - uint32_t flow_dep_mask_out; - uint32_t flow_dep_mask_in; + parsec_dependency_t flow_dep_mask_out; + parsec_dependency_t flow_dep_mask_in; }; typedef uint16_t jdf_dep_flags_t; diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index c34e2fe89..ca9f151d8 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1747,11 +1747,11 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) // If any flow/dep is parametrized/referrer, all the action masks have to be dynamically computed coutput(" // Action masks of %s\n", f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { - coutput(" uint32_t dep_mask_out_of_flow_of_%s_%s_for_%s;\n", + coutput(" parsec_dependency_t dep_mask_out_of_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } // action_mask for the entire task class - coutput(" uint32_t dep_mask_out_of_flow_of_%s_%s;\n", + coutput(" parsec_dependency_t dep_mask_out_of_flow_of_%s_%s;\n", jdf_basename, f->fname); @@ -3217,7 +3217,7 @@ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* string_arena_t* flow_flags = string_arena_new(64); string_arena_t *psa; jdf_dep_t *dl; - uint32_t flow_datatype_mask = 0; + parsec_dependency_t flow_datatype_mask = 0; char sep_in[4], sep_out[4]; /* one char more to deal with '\n' special cases (Windows) */ (void)jdf; @@ -3333,7 +3333,7 @@ static int jdf_generate_dataflow( const jdf_t *jdf, const jdf_function_entry_t* " .sym_type = %s,\n" " .flow_flags = %s,\n" " .flow_index = %u,\n" - " .flow_datatype_mask = 0x%x,\n" + " .flow_datatype_mask = 0x%lx,\n" " .dep_in = { %s },\n" " .dep_out = { %s }\n" "};\n\n", @@ -8514,7 +8514,7 @@ static void jdf_generate_code_call_release_dependencies(const jdf_t *jdf, const jdf_function_entry_t *function, const char* context_name) { - uint32_t complete_mask = 0; + parsec_dependency_t complete_mask = 0; jdf_dataflow_t* dl; (void)jdf; @@ -8532,7 +8532,7 @@ static void jdf_generate_code_call_release_dependencies(const jdf_t *jdf, } else { - snprintf(complete_mask_str, 256, "0x%x", complete_mask); + snprintf(complete_mask_str, 256, "0x%lx", complete_mask); } coutput(" release_deps_of_%s_%s(es, %s,\n" @@ -8609,7 +8609,7 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, string_arena_t *sa_current_mask = string_arena_new(256); int last_datatype_idx, continue_dependencies, type, skip_condition, generate_exit_label = 0; - uint32_t current_mask = 0; + parsec_dependency_t current_mask = 0; expr_info_t info = EMPTY_EXPR_INFO; sa = string_arena_new(64); @@ -8624,7 +8624,7 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, ai.holder = "this_task->locals."; ai.expr = NULL; coutput("static int %s(parsec_execution_stream_t *es, const %s *this_task,\n" - " uint32_t* flow_mask, parsec_dep_data_description_t* data)\n" + " parsec_dependency_t* flow_mask, parsec_dep_data_description_t* data)\n" "{\n" " const __parsec_%s_internal_taskpool_t *__parsec_tp = (__parsec_%s_internal_taskpool_t *)this_task->taskpool;\n" " (void)__parsec_tp; (void)es; (void)this_task; (void)data;\n" @@ -8668,7 +8668,7 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, else { // static masks if no parametrization in this task class - string_arena_add_string(sa_action_mask, "0x%xU", (type == JDF_DEP_FLOW_OUT ? fl->flow_dep_mask_out : (1U << fl->flow_index))); + string_arena_add_string(sa_action_mask, "0x%lxU", (type == JDF_DEP_FLOW_OUT ? fl->flow_dep_mask_out : (1U << fl->flow_index))); } string_arena_add_string(sa_coutput, "if( (*flow_mask) & %s ) { /* Flow %s */\n", @@ -8693,7 +8693,7 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, /* Prepare the memory layout of the output dependency. */ if( last_datatype_idx != dl->dep_datatype_index ) { string_arena_init(sa_current_mask); - string_arena_add_string(sa_current_mask, "0x%xU", current_mask); + string_arena_add_string(sa_current_mask, "0x%lxU", current_mask); JDF_CODE_DATATYPE_DUMP(sa_coutput, current_mask, string_arena_get_string(sa_current_mask), sa_cond, sa_datatype, skip_condition); /************************************/ /* REMOTE DATATYPE USED FOR RECV */ @@ -8754,7 +8754,7 @@ jdf_generate_code_datatype_lookup(const jdf_t *jdf, if( !continue_dependencies ) break; } string_arena_init(sa_current_mask); - string_arena_add_string(sa_current_mask, "0x%xU", current_mask); + string_arena_add_string(sa_current_mask, "0x%lxU", current_mask); JDF_CODE_DATATYPE_DUMP(sa_coutput, current_mask, string_arena_get_string(sa_current_mask), sa_cond, sa_datatype, skip_condition); dump_parametrized_flow_loop_end_if_parametrized(fl, " ", sa_coutput); @@ -9966,7 +9966,7 @@ static void jdf_generate_code_free_hash_table_entry(const jdf_t *jdf, const jdf_ static void jdf_generate_code_release_deps(const jdf_t *jdf, const jdf_function_entry_t *f, const char *name) { - coutput("static int %s(parsec_execution_stream_t *es, %s *this_task, uint32_t action_mask, parsec_remote_deps_t *deps)\n" + coutput("static int %s(parsec_execution_stream_t *es, %s *this_task, parsec_dependency_t action_mask, parsec_remote_deps_t *deps)\n" "{\n" "PARSEC_PINS(es, RELEASE_DEPS_BEGIN, (parsec_task_t *)this_task);" "{\n" @@ -10588,7 +10588,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, ai.expr = NULL; coutput("static void\n" "%s(parsec_execution_stream_t *es, const %s *this_task,\n" - " uint32_t action_mask, parsec_ontask_function_t *ontask, void *ontask_arg)\n" + " parsec_dependency_t action_mask, parsec_ontask_function_t *ontask, void *ontask_arg)\n" "{\n" " const __parsec_%s_internal_taskpool_t *__parsec_tp = (const __parsec_%s_internal_taskpool_t*)this_task->taskpool;\n" " parsec_task_t nc; /* generic placeholder for locals */\n" @@ -11036,7 +11036,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, else { // static masks if no parametrization in this task class - string_arena_add_string(sa_action_mask, "0x%xU", (flow_type & JDF_DEP_FLOW_OUT) ? fl->flow_dep_mask_out : fl->flow_dep_mask_in/*mask*/); + string_arena_add_string(sa_action_mask, "0x%lxU", (flow_type & JDF_DEP_FLOW_OUT) ? fl->flow_dep_mask_out : fl->flow_dep_mask_in/*mask*/); } if(FLOW_IS_PARAMETRIZED(fl)) { diff --git a/parsec/mca/device/transfer_gpu.c b/parsec/mca/device/transfer_gpu.c index 1ad93fa9b..fbcb8cc95 100644 --- a/parsec/mca/device/transfer_gpu.c +++ b/parsec/mca/device/transfer_gpu.c @@ -52,7 +52,7 @@ affinity_of_gpu_d2h_task( parsec_gpu_d2h_task_t* this_task, static void iterate_successors_of_gpu_d2h_task( parsec_execution_stream_t* es, const parsec_gpu_d2h_task_t* this_task, - uint32_t action_mask, + parsec_dependency_t action_mask, parsec_ontask_function_t * ontask, void *ontask_arg ) { (void)es; (void)this_task; (void)action_mask; (void)ontask; (void)ontask_arg; @@ -61,7 +61,7 @@ iterate_successors_of_gpu_d2h_task( parsec_execution_stream_t* es, static void iterate_predecessors_of_gpu_d2h_task( parsec_execution_stream_t* es, const parsec_gpu_d2h_task_t* this_task, - uint32_t action_mask, + parsec_dependency_t action_mask, parsec_ontask_function_t * ontask, void *ontask_arg ) { (void)es; (void)this_task; (void)action_mask; (void)ontask; (void)ontask_arg; @@ -70,7 +70,7 @@ iterate_predecessors_of_gpu_d2h_task( parsec_execution_stream_t* es, static int release_deps_of_gpu_d2h_task( parsec_execution_stream_t* es, parsec_gpu_d2h_task_t* this_task, - uint32_t action_mask, + parsec_dependency_t action_mask, parsec_remote_deps_t* deps ) { (void)es; (void)this_task; (void)action_mask; (void)deps; diff --git a/parsec/parsec.c b/parsec/parsec.c index e2a6c250d..1aed713bf 100644 --- a/parsec/parsec.c +++ b/parsec/parsec.c @@ -1583,12 +1583,12 @@ parsec_update_deps_with_counter(parsec_taskpool_t *tp, if( 0 == *deps ) { dep_new_value = parsec_check_IN_dependencies_with_counter(tp, task) - 1; - if( parsec_atomic_cas_int32( deps, 0, dep_new_value ) == 1 ) + if( parsec_atomic_cas_int64( deps, 0, dep_new_value ) == 1 ) dep_cur_value = dep_new_value; else - dep_cur_value = parsec_atomic_fetch_dec_int32( deps ) - 1; + dep_cur_value = parsec_atomic_fetch_dec_int64( deps ) - 1; } else { - dep_cur_value = parsec_atomic_fetch_dec_int32( deps ) - 1; + dep_cur_value = parsec_atomic_fetch_dec_int64( deps ) - 1; } PARSEC_DEBUG_VERBOSE(10, parsec_debug_output, "Activate counter dependency for %s leftover %d (excluding current)", tmp, dep_cur_value); @@ -1630,14 +1630,14 @@ parsec_update_deps_with_counter_count_task(parsec_taskpool_t *tp, if( 0 == *deps ) { dep_new_value = parsec_check_IN_dependencies_with_counter(tp, task) - 1; - if( parsec_atomic_cas_int32( deps, 0, dep_new_value ) == 1 ) { + if( parsec_atomic_cas_int64( deps, 0, dep_new_value ) == 1 ) { dep_cur_value = dep_new_value; tp->tdm.module->taskpool_addto_nb_tasks(tp, 1); } else { - dep_cur_value = parsec_atomic_fetch_dec_int32( deps ) - 1; + dep_cur_value = parsec_atomic_fetch_dec_int64( deps ) - 1; } } else { - dep_cur_value = parsec_atomic_fetch_dec_int32( deps ) - 1; + dep_cur_value = parsec_atomic_fetch_dec_int64( deps ) - 1; } PARSEC_DEBUG_VERBOSE(10, parsec_debug_output, "Activate counter dependency for %s leftover %d (excluding current)", tmp, dep_cur_value); @@ -1702,14 +1702,14 @@ parsec_update_deps_with_mask(parsec_taskpool_t *tp, #endif } - dep_cur_value = parsec_atomic_fetch_or_int32( deps, dep_new_value ) | dep_new_value; + dep_cur_value = parsec_atomic_fetch_or_int64( deps, dep_new_value ) | dep_new_value; #if defined(PARSEC_DEBUG_PARANOID) if( (dep_cur_value & tc->dependencies_goal) == tc->dependencies_goal ) { int success; parsec_dependency_t tmp_mask; tmp_mask = *deps; - success = parsec_atomic_cas_int32(deps, + success = parsec_atomic_cas_int64(deps, tmp_mask, (tmp_mask | PARSEC_DEPENDENCIES_TASK_DONE)); if( !success || (tmp_mask & PARSEC_DEPENDENCIES_TASK_DONE) ) { parsec_fatal("Task %s scheduled twice (second time by %s)!!!", @@ -1768,7 +1768,7 @@ parsec_update_deps_with_mask_count_task(parsec_taskpool_t *tp, #endif } - dep_cur_value = parsec_atomic_fetch_or_int32( deps, dep_new_value ) | dep_new_value; + dep_cur_value = parsec_atomic_fetch_or_int64( deps, dep_new_value ) | dep_new_value; if( (dep_cur_value & (~dep_new_value)) == 0 ) { tp->tdm.module->taskpool_addto_nb_tasks(tp, 1); } else { @@ -1780,7 +1780,7 @@ parsec_update_deps_with_mask_count_task(parsec_taskpool_t *tp, int success; parsec_dependency_t tmp_mask; tmp_mask = *deps; - success = parsec_atomic_cas_int32(deps, + success = parsec_atomic_cas_int64(deps, tmp_mask, (tmp_mask | PARSEC_DEPENDENCIES_TASK_DONE)); if( !success || (tmp_mask & PARSEC_DEPENDENCIES_TASK_DONE) ) { parsec_fatal("Task %s scheduled twice (second time by %s)!!!", diff --git a/parsec/parsec_internal.h b/parsec/parsec_internal.h index 6472c6c70..2638e5690 100644 --- a/parsec/parsec_internal.h +++ b/parsec/parsec_internal.h @@ -238,7 +238,7 @@ typedef enum { typedef int (parsec_release_deps_t)(struct parsec_execution_stream_s*, parsec_task_t*, - uint32_t, + parsec_dependency_t, parsec_remote_deps_t*); #if defined(PARSEC_SIM) typedef int (parsec_sim_cost_fct_t)(const parsec_task_t *task); @@ -260,7 +260,7 @@ typedef parsec_ontask_iterate_t (parsec_ontask_function_t)(struct parsec_executi */ typedef void (parsec_traverse_function_t)(struct parsec_execution_stream_s *, const parsec_task_t *, - uint32_t, + parsec_dependency_t, parsec_ontask_function_t *, void *); @@ -578,7 +578,7 @@ extern int device_delegate_begin, device_delegate_end; * Dependencies management. */ typedef struct { - uint32_t action_mask; + parsec_dependency_t action_mask; uint32_t output_usage; data_repo_entry_t *output_entry; /* Current task repo entry */ data_repo_t *output_repo; /* Current task repo */ diff --git a/parsec/remote_dep.h b/parsec/remote_dep.h index b42699a1d..4e070947c 100644 --- a/parsec/remote_dep.h +++ b/parsec/remote_dep.h @@ -27,15 +27,15 @@ typedef union dep_cmd_u dep_cmd_t; typedef unsigned long remote_dep_datakey_t; -#define PARSEC_ACTION_DEPS_MASK 0x00FFFFFF -#define PARSEC_ACTION_RELEASE_LOCAL_DEPS 0x01000000 -#define PARSEC_ACTION_RELEASE_LOCAL_REFS 0x02000000 -#define PARSEC_ACTION_GET_REPO_ENTRY 0x04000000 -#define PARSEC_ACTION_RESHAPE_ON_RELEASE 0x08000000 -#define PARSEC_ACTION_SEND_INIT_REMOTE_DEPS 0x10000000 -#define PARSEC_ACTION_SEND_REMOTE_DEPS 0x20000000 -#define PARSEC_ACTION_RECV_INIT_REMOTE_DEPS 0x40000000 -#define PARSEC_ACTION_RESHAPE_REMOTE_ON_RELEASE 0x80000000 +#define PARSEC_ACTION_DEPS_MASK 0x00FFFFFFFFFFFFFF +#define PARSEC_ACTION_RELEASE_LOCAL_DEPS 0x0100000000000000 +#define PARSEC_ACTION_RELEASE_LOCAL_REFS 0x0200000000000000 +#define PARSEC_ACTION_GET_REPO_ENTRY 0x0400000000000000 +#define PARSEC_ACTION_RESHAPE_ON_RELEASE 0x0800000000000000 +#define PARSEC_ACTION_SEND_INIT_REMOTE_DEPS 0x1000000000000000 +#define PARSEC_ACTION_SEND_REMOTE_DEPS 0x2000000000000000 +#define PARSEC_ACTION_RECV_INIT_REMOTE_DEPS 0x4000000000000000 +#define PARSEC_ACTION_RESHAPE_REMOTE_ON_RELEASE 0x8000000000000000 #define PARSEC_ACTION_RELEASE_REMOTE_DEPS (PARSEC_ACTION_SEND_INIT_REMOTE_DEPS | PARSEC_ACTION_SEND_REMOTE_DEPS) typedef enum { diff --git a/parsec/task_class.c b/parsec/task_class.c index 75c7f3522..cbdeb6caa 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -126,7 +126,7 @@ bool parsec_helper_dep_is_in_flow_array(const parsec_dep_t *dep, parsec_dep_t *d void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t *pivot_flow, int shift) { int i, j; - int flow_in_out; + //int flow_in_out; int pivot_index_in, pivot_index_out; int last_flow_index_in, last_flow_index_out; int found_pivot_in=0, found_pivot_out=0; @@ -352,6 +352,7 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int dep_in_out, int shift) { int pivot_dep_index; + (void) tc; // Look for the pivot dep pivot_dep_index = -1; @@ -531,7 +532,7 @@ void parsec_debug_dump_task_class_at_exec(parsec_task_class_t *tc) void parsec_check_sanity_of_task_class(parsec_task_class_t *tc, bool check_dep_index) { int i, j; - int flow_in_out, dep_in_out; + int flow_in_out; parsec_dep_t *dep; // flows can appear twice in a task class (if both in and out) From 1697ae6f555ec864b0549f2fbfb5184424f774d0 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 14 Mar 2023 17:52:54 +0100 Subject: [PATCH 152/157] separate dep_index lifting from the dep shift --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 22 ++++++-- parsec/mca/device/device.c | 1 + parsec/task_class.c | 59 +++++++--------------- parsec/task_class.h | 3 +- 4 files changed, 38 insertions(+), 47 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index ca9f151d8..61f5c6941 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6264,7 +6264,22 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } - + jdf_function_entry_t *targetf = find_target_function(jdf, call->func_or_mem); + jdf_dataflow_t *target_flow = find_target_flow(jdf, targetf, call->var); + assert(targetf && target_flow); + + //coutput(" parsec_update_dep_index_after_dep(tc, parsec_flow_t *flow, int dep_in_out, parsec_dep_t *pivot_dep, int shift)") + if(FLOW_IS_PARAMETRIZED(df) && FLOW_IS_PARAMETRIZED(target_flow)) + { + coutput(" parsec_update_dep_index_after_dep(tc, &flow_of_%s_%s_for_parametrized_%s[0], flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s);\n", + jdf_basename, f->fname, df->varname, jdf_basename, call->func_or_mem, call->var); + } + else + { + coutput(" parsec_update_dep_index_after_dep(tc, &flow_of_%s_%s_for_%s, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s);\n", + jdf_basename, f->fname, df->varname, jdf_basename, call->func_or_mem, call->var); + } + if(FLOW_IS_PARAMETRIZED(df)) { coutput(" for( int %s=0;%sfunc_or_mem); - jdf_dataflow_t *target_flow = find_target_flow(jdf, targetf, call->var); - assert(targetf && target_flow); if(FLOW_IS_PARAMETRIZED(df) && FLOW_IS_PARAMETRIZED(target_flow)) { coutput("\n parsec_flow_t *flow = &flow_of_%s_%s_for_parametrized_%s[%s];\n", @@ -6292,7 +6304,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput( " // Shift the deps that are after dep (which references the parametrized flow)\n" - " parsec_shift_all_deps_after_and_update_tc(tc, flow, dep, flow_in_out, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n\n", + " parsec_shift_all_deps_after(tc, flow, dep, flow_in_out, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n\n", jdf_basename, call->func_or_mem, call->var ); diff --git a/parsec/mca/device/device.c b/parsec/mca/device/device.c index a8d7e326d..9836ca8cd 100644 --- a/parsec/mca/device/device.c +++ b/parsec/mca/device/device.c @@ -109,6 +109,7 @@ int parsec_get_best_device( parsec_task_t* this_task, double ratio ) /* If we reach here, we cannot yet decide which device to run on based on the WRITE * constraints, so let's pick the data for a READ flow. */ + if(!this_task->task_class->in[i]) break; data_index = this_task->task_class->in[i]->flow_index; if( this_task->data[data_index].data_in->original->preferred_device > 1 ) { prefer_index = this_task->data[data_index].data_in->original->preferred_device; diff --git a/parsec/task_class.c b/parsec/task_class.c index cbdeb6caa..4f03164f1 100644 --- a/parsec/task_class.c +++ b/parsec/task_class.c @@ -349,8 +349,10 @@ void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t * }*/ } -void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int dep_in_out, int shift) +void parsec_shift_all_deps_after(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int dep_in_out, int shift) { + // Should be rewritten like parsec_update_dep_index_after_dep + int pivot_dep_index; (void) tc; @@ -403,57 +405,32 @@ void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_f // assert(dep->dep_index == i); // The dep index can acutally be anything assert(i + shift < (dep_in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT)); // We should not overflow the array - dep->dep_index += shift; - // Shift the dep (dep_in_out ? flow->dep_out : flow->dep_in)[i + shift] = dep; } +} +void parsec_update_dep_index_after_dep(parsec_task_class_t *tc, parsec_flow_t *flow, int dep_in_out, parsec_dep_t *pivot_dep, int shift) +{ + // This function assumes that the dep_index increases + // parsec_shift_all_deps_after should be rewritten assuming this too -/* - // keep track of the deps that have been treated - parsec_dep_t *treated_deps[MAX_DEP_IN_COUNT + MAX_DEP_OUT_COUNT]; - int treated_deps_size = 0; + int i; + parsec_dep_t *dep; - for(int in_out=0;in_out<2;++in_out) + for (i = 0; i < (dep_in_out ? MAX_DEP_OUT_COUNT : MAX_DEP_IN_COUNT); i++) { - for(int flid=0; fliddep_out[i] : flow->dep_in[i]); + if (!dep) { - parsec_flow_t *fl = (parsec_flow_t *)(in_out ? tc->out[flid] : tc->in[flid]); - if(!fl) - break; - - int pivot_dep_dep_index = pivot_dep->dep_index; - for (int depid = 0; depid < (in_out?MAX_DEP_OUT_COUNT:MAX_DEP_IN_COUNT); depid++) - { - parsec_dep_t *dep = (parsec_dep_t *)(in_out ? fl->dep_out[depid] : fl->dep_in[depid]); - - if (!dep) - break; - - if (dep->dep_index > pivot_dep_dep_index && !parsec_helper_dep_is_in_flow_array(dep, treated_deps, treated_deps_size)) - { - dep->dep_index += shift; - treated_deps[treated_deps_size++] = dep; - } - } + break; } - } -*/ - /* // The datatype_mask should stay the same, as we do not add any datatype - // Also shift the flow's flow_datatype_mask - if(dep_in_out) - { - // If output dep - // Goal: 000xxxxx -> 0xxxx11x (if shift=1 and pivot_dep_index=1) - // (add 1's in between) - parsec_dependency_t unshifted_values = flow->flow_datatype_mask & ((1<flow_datatype_mask >> (pivot_dep_index + 1)) << (pivot_dep_index + 1 + shift); - parsec_dependency_t in_between = ((1<<(shift+1))-1) << pivot_dep_index; - flow->flow_datatype_mask = unshifted_values | shifted_values | in_between; + if (dep->dep_index > pivot_dep->dep_index) + { + dep->dep_index += shift; + } } - */ } /* Prints the task class information (for debugging purposes) diff --git a/parsec/task_class.h b/parsec/task_class.h index 26659811c..83b95acbe 100644 --- a/parsec/task_class.h +++ b/parsec/task_class.h @@ -13,7 +13,8 @@ // The shift functions creates spaces in the relevant arrays void parsec_shift_all_flows_after(parsec_task_class_t *tc, const parsec_flow_t *pivot_flow, int shift); -void parsec_shift_all_deps_after_and_update_tc(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int dep_in_out, int shift); +void parsec_shift_all_deps_after(parsec_task_class_t *tc, parsec_flow_t *flow, parsec_dep_t *pivot_dep, int dep_in_out, int shift); +void parsec_update_dep_index_after_dep(parsec_task_class_t *tc, parsec_flow_t *flow, int dep_in_out, parsec_dep_t *pivot_dep, int shift); // in all flows fl (fl!=flow), increase deps by shift //void parsec_update_dep_index_in_other_flows(parsec_task_class_t *tc, parsec_flow_t *flow, int dep_in_out, int dep_index, int shift); From d952ca2aedd09694e9ab70c879f496ece92bf4b2 Mon Sep 17 00:00:00 2001 From: cflinto Date: Tue, 28 Mar 2023 16:42:02 +0200 Subject: [PATCH 153/157] fix nb of specializations given to parsec_update_dep_index_after_dep --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index 61f5c6941..a27d1225a 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -6271,12 +6271,12 @@ static void jdf_generate_new_function( const jdf_t* jdf ) //coutput(" parsec_update_dep_index_after_dep(tc, parsec_flow_t *flow, int dep_in_out, parsec_dep_t *pivot_dep, int shift)") if(FLOW_IS_PARAMETRIZED(df) && FLOW_IS_PARAMETRIZED(target_flow)) { - coutput(" parsec_update_dep_index_after_dep(tc, &flow_of_%s_%s_for_parametrized_%s[0], flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s);\n", + coutput(" parsec_update_dep_index_after_dep(tc, &flow_of_%s_%s_for_parametrized_%s[0], flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n", jdf_basename, f->fname, df->varname, jdf_basename, call->func_or_mem, call->var); } else { - coutput(" parsec_update_dep_index_after_dep(tc, &flow_of_%s_%s_for_%s, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s);\n", + coutput(" parsec_update_dep_index_after_dep(tc, &flow_of_%s_%s_for_%s, flow_in_out, dep, nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s-1);\n", jdf_basename, f->fname, df->varname, jdf_basename, call->func_or_mem, call->var); } From 92f8ddd71e12f46fed4255c08735211c07c9e448 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 31 Mar 2023 10:27:12 +0200 Subject: [PATCH 154/157] remove trash comments --- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index a27d1225a..b90440196 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -10814,7 +10814,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, "->dep_out[%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" - " return; // here\n", + " return;\n", dump_flow_offset_for_iterate_successors(sa_flow_offset, f, fl, call), dump_dep_offset_for_iterate_successors(sa_dep_offset, f, fl, call)); } @@ -10921,7 +10921,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, "->dep_out[%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" - " return; // there\n", + " return;\n", dump_flow_offset_for_iterate_successors(sa_flow_offset, f, fl, call), dump_dep_offset_for_iterate_successors(sa_dep_offset, f, fl, call)); } @@ -10960,7 +10960,7 @@ jdf_generate_code_iterate_successors_or_predecessors(const jdf_t *jdf, "->dep_out[%s]" ", &data, rank_src, rank_dst, vpid_dst," " successor_repo, successor_repo_key, ontask_arg) )\n" - " return; // zhere\n", + " return;\n", dump_flow_offset_for_iterate_successors(sa_flow_offset, f, fl, call), dump_dep_offset_for_iterate_successors(sa_dep_offset, f, fl, call)); } From 31de4847bc47c9fe64c41b757ffb7ded71e5dbcc Mon Sep 17 00:00:00 2001 From: cflinto Date: Mon, 11 Mar 2024 18:16:09 +0100 Subject: [PATCH 155/157] stop requiring paranoid debug for parametrized flows to work --- CMakeLists.txt | 2 +- parsec/interfaces/ptg/ptg-compiler/jdf2c.c | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6069c29af..11ad18653 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -691,7 +691,7 @@ int main(int argc, char *argv[]) { if (CUDAToolkit_FOUND) message(STATUS "Found CUDA ${CUDAToolkit_VERSION} in ${CUDAToolkit_LIBRARY_DIR}") CMAKE_PUSH_CHECK_STATE() - list(APPEND CMAKE_REQUIRED_LIBRARIES CUDA::cudart) + list(APPEND CMAKE_REQUIRED_LIBRARIES CUDA::cudart) # This adds the wrong version of cudart if there are multiple versions installed if(CUDAToolkit_VERSION VERSION_LESS "4.0") set(PARSEC_HAVE_PEER_DEVICE_MEMORY_ACCESS 0) else() diff --git a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c index b90440196..5a8e09729 100644 --- a/parsec/interfaces/ptg/ptg-compiler/jdf2c.c +++ b/parsec/interfaces/ptg/ptg-compiler/jdf2c.c @@ -1756,13 +1756,13 @@ static void jdf_generate_predeclarations( const jdf_t *jdf ) // Parametrized flows: - coutput(" // Local parametrized flows of %s\n#if defined(PARSEC_DEBUG_NOISIER)\n", f->fname); + coutput(" // Local parametrized flows of %s\n//#if defined(PARSEC_DEBUG_NOISIER) // used in release mode too now\n", f->fname); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { coutput(" int nb_specializations_of_parametrized_flow_of_%s_%s_for_%s;\n", jdf_basename, f->fname, df->varname); } } - coutput("#endif\n"); + coutput("//#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { // if "in" flow @@ -5147,13 +5147,13 @@ static void jdf_generate_one_function( const jdf_t *jdf, jdf_function_entry_t *f // Parametrized flows: string_arena_add_string(sa, " // Local parametrized flows of %s\n", f->fname); - string_arena_add_string(sa, "#if defined(PARSEC_DEBUG_NOISIER)\n"); + string_arena_add_string(sa, "//#if defined(PARSEC_DEBUG_NOISIER) // used in release mode too now\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { string_arena_add_string(sa, " , .nb_specializations_of_parametrized_flow_of_%s_%s_for_%s = -1\n", jdf_basename, f->fname, df->varname); } } - string_arena_add_string(sa, "#endif\n"); + string_arena_add_string(sa, "//#endif\n"); for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { // store the offset for every output dep of this parametrized flow @@ -5896,7 +5896,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput("\n"); coutput(" // Set the number of specializations\n"); - coutput("#if defined(PARSEC_DEBUG_NOISIER)\n"); + coutput("//#if defined(PARSEC_DEBUG_NOISIER) // used in release mode too now\n"); for( jdf_function_entry_t* f = jdf->functions; NULL != f; f = f->next ) { for( jdf_dataflow_t* df = f->dataflow; NULL != df; df = df->next ) { if( FLOW_IS_PARAMETRIZED(df) ) { @@ -5905,7 +5905,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) } } } - coutput("#endif\n"); + coutput("//#endif\n"); coutput("\n"); // TODO delete parametrized_flows when not needed anymore! @@ -6430,7 +6430,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" // First, ensure that there is no duplicate pointer\n"); - coutput("#if defined(PARSEC_DEBUG_PARANOID)\n"); + coutput("//#if defined(PARSEC_DEBUG_PARANOID) // This is not paranoid at all\n"); coutput(" for(int tcid = 0; tcid < __parsec_tp->super.super.nb_task_classes; tcid++) {\n"); coutput(" parsec_task_class_t *tc = __parsec_tp->super.super.task_classes_array[tcid];\n"); coutput(" parsec_dep_t *found_deps[MAX_DEP_IN_COUNT*MAX_DATAFLOWS_PER_TASK];\n"); @@ -6467,7 +6467,7 @@ static void jdf_generate_new_function( const jdf_t* jdf ) coutput(" }\n"); coutput(" }\n"); coutput(" }\n"); - coutput("#endif\n"); + coutput("//#endif\n"); coutput("\n"); @@ -6557,12 +6557,12 @@ static void jdf_generate_new_function( const jdf_t* jdf ) //coutput(" spec_%s.out_offset_flow_of_%s_%s_for_%s = parsec_helper_get_flow_index_that_contains_dep(parsec_task_class_t *tc, parsec_dep_t *dep, int in_out);\n" // JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname,); - coutput("#if defined(PARSEC_DEBUG_NOISIER)\n"); + coutput("//#if defined(PARSEC_DEBUG_NOISIER) // used in release mode too now\n"); coutput(" spec_%s.nb_specializations_of_parametrized_flow_of_%s_%s_for_%s = nb_specializations_of_parametrized_flow_of_%s_%s_for_parametrized_%s;\n", JDF_OBJECT_ONAME(f), jdf_basename, f->fname, df->varname, jdf_basename, f->fname, df->varname); - coutput("#endif\n"); + coutput("//#endif\n"); if(df->flow_flags & JDF_FLOW_TYPE_READ) { From 60a8aca860bfde885ee1e781f7c7498ec7b47203 Mon Sep 17 00:00:00 2001 From: cflinto Date: Wed, 13 Mar 2024 20:09:04 +0100 Subject: [PATCH 156/157] comment a part that glitches with paranoid asserts --- parsec/datarepo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parsec/datarepo.c b/parsec/datarepo.c index 75b300713..a7fd79656 100644 --- a/parsec/datarepo.c +++ b/parsec/datarepo.c @@ -132,9 +132,9 @@ __data_repo_entry_used_once(data_repo_t *repo, parsec_key_t key void __data_repo_entry_addto_usage_limit(data_repo_t *repo, parsec_key_t key, uint32_t usagelmt -#if defined(PARSEC_DEBUG_NOISIER) +// #if defined(PARSEC_DEBUG_NOISIER) // The printfs glitch if this is enabled , const char *tablename, const char *file, int line -#endif +// #endif ) { data_repo_entry_t *e; From 5c5174aec79fd2787c4dca5f2f56a1f9a16f9b96 Mon Sep 17 00:00:00 2001 From: cflinto Date: Fri, 22 Mar 2024 11:04:20 +0100 Subject: [PATCH 157/157] put back the ifdef (the performance tests were done with this) --- parsec/datarepo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parsec/datarepo.c b/parsec/datarepo.c index a7fd79656..d6effc334 100644 --- a/parsec/datarepo.c +++ b/parsec/datarepo.c @@ -132,9 +132,9 @@ __data_repo_entry_used_once(data_repo_t *repo, parsec_key_t key void __data_repo_entry_addto_usage_limit(data_repo_t *repo, parsec_key_t key, uint32_t usagelmt -// #if defined(PARSEC_DEBUG_NOISIER) // The printfs glitch if this is enabled +#if defined(PARSEC_DEBUG_NOISIER) // The printfs glitch if this is enabled , const char *tablename, const char *file, int line -// #endif +#endif ) { data_repo_entry_t *e;