diff --git a/include/maestro/i_pool_manager_registry.h b/include/maestro/i_pool_manager_registry.h index 2d952926c5277f728762fa1ca643649da3fd76a3..50591c06810b9f0947726ddd15a454cc5873da77 100644 --- a/include/maestro/i_pool_manager_registry.h +++ b/include/maestro/i_pool_manager_registry.h @@ -325,6 +325,15 @@ mstro_pm_candidates_destroy(mstro_pm_candidates *candidates); +/** If a CDO has is_distributed flag set at the mstro_pm_cdo_registry_entry but + * the cdo handle does not has a distribution defined, + * + * we cook up a default distributed for it, which consists of one piece holding + * all the cdo data */ +mstro_status +mstro_pm_cdo_create_default_dist_layout(mmbLayout *src_layout, mmbLayout **default_layout); + + /** Convert the mapping between two distributed layouts found by mmb_layout_compute_intersection * to a list of candidates (apps, local cdo-ids, offsets, lengths) that satisfy * the requested distribution from a different source distribution. diff --git a/maestro/pool_manager_registry.c b/maestro/pool_manager_registry.c index 1ddae712ff49b7bc7ada575b0e7fca46ad8be661..8f0d33dca7af27c8fd45cb5fdbef30ef220ca06f 100644 --- a/maestro/pool_manager_registry.c +++ b/maestro/pool_manager_registry.c @@ -875,6 +875,50 @@ mstro_pm__mmbLayoutIntersecton_to_candidates( return status; } +/** If a CDO has is_distributed flag set at the mstro_pm_cdo_registry_entry but + * the cdo handle does not has a distribution defined, + * + * we cook up a default distributed for it, which consists of one piece holding + * all the cdo data */ +mstro_status +mstro_pm_cdo_create_default_dist_layout(mmbLayout *src_layout, mmbLayout **default_layout){ + mstro_status status = MSTRO_OK; + + + /*FIXME only support irregular 1D layouts */ + if ((src_layout->type != MMB_IRREGULAR) || (src_layout->n_dims != 1)) { + ERR("FIXME only support now 1D irregular layouts \n"); + return MSTRO_UNIMPL; + } + + size_t *offsets, *sizes; + offsets = (size_t *) malloc(sizeof(size_t) * 1); + sizes = (size_t *) malloc(sizeof(size_t) * 1); + + if ((!offsets) || (!sizes) ) { + ERR("Can not allocate memory for default layout offsets and sizes \n"); + return MSTRO_NOMEM; + } + + offsets[0] = 0; // data starts from the begining + /* get cdo size */ + sizes[0] = 0; // cdo size + for (size_t i = 0; i < src_layout->irregular.n_blocks.d[0]; i++) { + sizes[0] += src_layout->irregular.lengths[i]; // cdo size + } + + + mmbError stat = MMB_OK; + stat = mmb_layout_create_dist_irregular_1d(src_layout->element.size_bytes, + 0, /*index = 0*/ + 1, /* nblocks = 1*/ + offsets, + sizes, + default_layout); + + return (stat == MMB_OK) ? MSTRO_OK : MSTRO_FAIL; +} + static inline mstro_status mstro_pm__find_cdo_with_layout(