From 42567286c91b96c154ac37891ff7ef404c7159f8 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Wed, 5 Aug 2015 11:55:44 +0200 Subject: [PATCH] add isl_schedule_gist_domain_params This is useful in cases where the schedule tree is constructed incrementally before the final context is known and the domain needs to be simplified with respect to this final context. Signed-off-by: Sven Verdoolaege --- doc/user.pod | 9 +++++++++ include/isl/schedule.h | 2 ++ isl_schedule.c | 30 ++++++++++++++++++++++++++++++ isl_schedule_node.c | 25 +++++++++++++++++++++++++ isl_schedule_node_private.h | 2 ++ 5 files changed, 68 insertions(+) diff --git a/doc/user.pod b/doc/user.pod index 35ece95b..a9a49075 100644 --- a/doc/user.pod +++ b/doc/user.pod @@ -7582,6 +7582,15 @@ redundant. __isl_take isl_schedule *schedule, __isl_take isl_union_set *domain); +The following function can be used to simplify the domain +of a schedule with a domain node as root with respect to the given +parameter domain. + + #include + __isl_give isl_schedule *isl_schedule_gist_domain_params( + __isl_take isl_schedule *schedule, + __isl_take isl_set *context); + The following function resets the user pointers on all parameter and tuple identifiers referenced by the nodes of the given schedule. diff --git a/include/isl/schedule.h b/include/isl/schedule.h index 7a037895..4123288e 100644 --- a/include/isl/schedule.h +++ b/include/isl/schedule.h @@ -121,6 +121,8 @@ __isl_give isl_schedule *isl_schedule_set( __isl_take isl_schedule *schedule1, __isl_take isl_schedule *schedule2); __isl_give isl_schedule *isl_schedule_intersect_domain( __isl_take isl_schedule *schedule, __isl_take isl_union_set *domain); +__isl_give isl_schedule *isl_schedule_gist_domain_params( + __isl_take isl_schedule *schedule, __isl_take isl_set *context); __isl_give isl_schedule *isl_schedule_reset_user( __isl_take isl_schedule *schedule); diff --git a/isl_schedule.c b/isl_schedule.c index 62b45836..76510c8c 100644 --- a/isl_schedule.c +++ b/isl_schedule.c @@ -478,6 +478,36 @@ error: return NULL; } +/* Replace the domain of the schedule "schedule" with the gist + * of the original domain with respect to the parameter domain "context". + */ +__isl_give isl_schedule *isl_schedule_gist_domain_params( + __isl_take isl_schedule *schedule, __isl_take isl_set *context) +{ + enum isl_schedule_node_type root_type; + isl_schedule_node *node; + + if (!schedule || !context) + goto error; + + root_type = isl_schedule_tree_get_type(schedule->root); + if (root_type != isl_schedule_node_domain) + isl_die(isl_schedule_get_ctx(schedule), isl_error_invalid, + "root node must be a domain node", goto error); + + node = isl_schedule_get_root(schedule); + isl_schedule_free(schedule); + node = isl_schedule_node_domain_gist_params(node, context); + schedule = isl_schedule_node_get_schedule(node); + isl_schedule_node_free(node); + + return schedule; +error: + isl_schedule_free(schedule); + isl_set_free(context); + return NULL; +} + /* Return an isl_union_map representation of the schedule. * If we still have access to the schedule tree, then we return * an isl_union_map corresponding to the subtree schedule of the child diff --git a/isl_schedule_node.c b/isl_schedule_node.c index 281d94d8..3272ed15 100644 --- a/isl_schedule_node.c +++ b/isl_schedule_node.c @@ -3418,6 +3418,31 @@ error: return NULL; } +/* Replace the domain of domain node "node" with the gist + * of the original domain with respect to the parameter domain "context". + */ +__isl_give isl_schedule_node *isl_schedule_node_domain_gist_params( + __isl_take isl_schedule_node *node, __isl_take isl_set *context) +{ + isl_union_set *domain; + isl_schedule_tree *tree; + + if (!node || !context) + goto error; + + tree = isl_schedule_tree_copy(node->tree); + domain = isl_schedule_tree_domain_get_domain(node->tree); + domain = isl_union_set_gist_params(domain, context); + tree = isl_schedule_tree_domain_set_domain(tree, domain); + node = isl_schedule_node_graft_tree(node, tree); + + return node; +error: + isl_schedule_node_free(node); + isl_set_free(context); + return NULL; +} + /* Internal data structure for isl_schedule_node_get_subtree_expansion. * "expansions" contains a list of accumulated expansions * for each outer expansion, set or sequence node. The first element diff --git a/isl_schedule_node_private.h b/isl_schedule_node_private.h index e89bcacb..d6c33340 100644 --- a/isl_schedule_node_private.h +++ b/isl_schedule_node_private.h @@ -44,6 +44,8 @@ __isl_give isl_schedule_node *isl_schedule_node_pullback_union_pw_multi_aff( __isl_give isl_schedule_node *isl_schedule_node_domain_intersect_domain( __isl_take isl_schedule_node *node, __isl_take isl_union_set *domain); +__isl_give isl_schedule_node *isl_schedule_node_domain_gist_params( + __isl_take isl_schedule_node *node, __isl_take isl_set *context); __isl_give isl_schedule_node *isl_schedule_node_insert_expansion( __isl_take isl_schedule_node *node, -- 2.11.4.GIT