From bafe9e0dcafa786f534b50c50a8d5765ea9a7133 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Fri, 20 May 2011 18:51:16 +0200 Subject: [PATCH] include stride constraint in saved domains When both the strides and the save_domains options are used, the generated clast takes the strides into account, but the associated domains would not contain any stride information. Include the stride constraint so that the saved domain matches the loop structure. We need to do this in two places, one for the domains on the clast_fors and one for those of clast_user_stmts. For the former, we simply add the stride constraint right before we save the domain. For the latter, we add the stride constraint to the context when recursing in the main code generation algorithm. If the current level is the last level for which to generate code (according to the stop option), then this context domain will end up as the domain of the user statements and will therefore include the stride constraint. Signed-off-by: Sven Verdoolaege --- include/cloog/domain.h | 2 ++ source/isl/domain.c | 20 ++++++++++++++++++++ source/loop.c | 9 ++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/cloog/domain.h b/include/cloog/domain.h index 1b50190..65fda66 100644 --- a/include/cloog/domain.h +++ b/include/cloog/domain.h @@ -134,6 +134,8 @@ int cloog_domain_can_stride(CloogDomain *domain, int level); int cloog_domain_is_otl(CloogDomain *domain, int level); CloogDomain * cloog_domain_stride_lower_bound(CloogDomain *domain, int level, CloogStride *stride); +CloogDomain * cloog_domain_add_stride_constraint(CloogDomain *domain, + CloogStride *stride); int cloog_domain_can_unroll(CloogDomain *domain, int level, cloog_int_t *n, CloogConstraint **lb); CloogDomain * cloog_domain_fixed_offset(CloogDomain *domain, int level, diff --git a/source/isl/domain.c b/source/isl/domain.c index aa4dcee..fce2bb1 100644 --- a/source/isl/domain.c +++ b/source/isl/domain.c @@ -1008,6 +1008,26 @@ CloogDomain *cloog_domain_stride_lower_bound(CloogDomain *domain, int level, } +/* Add stride constraint, if any, to domain. + */ +CloogDomain *cloog_domain_add_stride_constraint(CloogDomain *domain, + CloogStride *stride) +{ + isl_constraint *c; + isl_set *set; + + if (!stride || !stride->constraint) + return domain; + + set = isl_set_from_cloog_domain(domain); + c = isl_constraint_copy(&stride->constraint->isl); + + set = isl_set_add_constraint(set, c); + + return cloog_domain_from_isl_set(set); +} + + /** * cloog_domain_lazy_equal function: * This function returns 1 if the domains given as input are the same, 0 if it diff --git a/source/loop.c b/source/loop.c index 2832782..53f3ab5 100644 --- a/source/loop.c +++ b/source/loop.c @@ -1732,7 +1732,8 @@ static CloogLoop *loop_recurse(CloogLoop *loop, if (level && options->otl) cloog_loop_otl(loop, level); inner = loop->inner; - domain = loop->domain; + domain = cloog_domain_copy(loop->domain); + domain = cloog_domain_add_stride_constraint(domain, loop->stride); into = NULL ; while (inner != NULL) { /* 4b. -ced- recurse for each sub-list of non terminal loops. */ @@ -1759,6 +1760,7 @@ static CloogLoop *loop_recurse(CloogLoop *loop, } } + cloog_domain_free(domain); loop->inner = into; return loop; } @@ -2580,9 +2582,10 @@ static CloogLoop *loop_simplify(CloogLoop *loop, CloogDomain *context, new_block, inner, NULL); /* Only save the domains, if it involves only scattering dimensions. */ - if (options->save_domains && domain_dim <= nb_scattdims) + if (options->save_domains && domain_dim <= nb_scattdims) { + inter = cloog_domain_add_stride_constraint(inter, loop->stride); simplified->unsimplified = inter; - else + } else cloog_domain_free(inter); return(simplified) ; -- 2.11.4.GIT