add isl_schedule_node_band_scale_down
authorSven Verdoolaege <skimo@kotnet.org>
Thu, 28 Aug 2014 12:27:30 +0000 (28 14:27 +0200)
committerSven Verdoolaege <skimo@kotnet.org>
Wed, 11 Feb 2015 15:24:58 +0000 (11 16:24 +0100)
Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
doc/user.pod
include/isl/schedule_node.h
isl_schedule_band.c
isl_schedule_band.h
isl_schedule_node.c
isl_schedule_tree.c
isl_schedule_tree.h

index 298a8dd..d65f1b3 100644 (file)
@@ -7515,14 +7515,18 @@ two filter nodes are merged into one.
 These functions insert a new sequence or set node with the given
 filters as children.
 
-The partial schedule of a band node can be scaled using
-the following function.
+The partial schedule of a band node can be scaled (down) using
+the following functions.
 
        #include <isl/schedule_node.h>
        __isl_give isl_schedule_node *
        isl_schedule_node_band_scale(
                __isl_take isl_schedule_node *node,
                __isl_take isl_multi_val *mv);
+       __isl_give isl_schedule_node *
+       isl_schedule_node_band_scale_down(
+               __isl_take isl_schedule_node *node,
+               __isl_take isl_multi_val *mv);
 
 The spaces of the two arguments need to match.
 After scaling, the partial schedule is replaced by its greatest
index 49c3c0c..c9f39aa 100644 (file)
@@ -68,6 +68,8 @@ int isl_options_get_tile_shift_point_loops(isl_ctx *ctx);
 
 __isl_give isl_schedule_node *isl_schedule_node_band_scale(
        __isl_take isl_schedule_node *node, __isl_take isl_multi_val *mv);
+__isl_give isl_schedule_node *isl_schedule_node_band_scale_down(
+       __isl_take isl_schedule_node *node, __isl_take isl_multi_val *mv);
 __isl_give isl_schedule_node *isl_schedule_node_band_tile(
        __isl_take isl_schedule_node *node, __isl_take isl_multi_val *sizes);
 __isl_give isl_schedule_node *isl_schedule_node_band_split(
index 5d18900..aae32f3 100644 (file)
@@ -255,6 +255,28 @@ error:
        return NULL;
 }
 
+/* Divide the partial schedule of "band" by the factors in "mv".
+ * Replace the result by its greatest integer part to ensure
+ * that the schedule is always integral.
+ */
+__isl_give isl_schedule_band *isl_schedule_band_scale_down(
+       __isl_take isl_schedule_band *band, __isl_take isl_multi_val *mv)
+{
+       band = isl_schedule_band_cow(band);
+       if (!band || !mv)
+               goto error;
+       band->mupa = isl_multi_union_pw_aff_scale_down_multi_val(band->mupa,
+                                                               mv);
+       band->mupa = isl_multi_union_pw_aff_floor(band->mupa);
+       if (!band->mupa)
+               return isl_schedule_band_free(band);
+       return band;
+error:
+       isl_schedule_band_free(band);
+       isl_multi_val_free(mv);
+       return NULL;
+}
+
 /* Given the schedule of a band, construct the corresponding
  * schedule for the tile loops based on the given tile sizes
  * and return the result.
index 50f3dd8..1a476e3 100644 (file)
@@ -50,6 +50,8 @@ __isl_give isl_schedule_band *isl_schedule_band_set_permutable(
 
 __isl_give isl_schedule_band *isl_schedule_band_scale(
        __isl_take isl_schedule_band *band, __isl_take isl_multi_val *mv);
+__isl_give isl_schedule_band *isl_schedule_band_scale_down(
+       __isl_take isl_schedule_band *band, __isl_take isl_multi_val *mv);
 __isl_give isl_schedule_band *isl_schedule_band_tile(
        __isl_take isl_schedule_band *band, __isl_take isl_multi_val *sizes);
 __isl_give isl_schedule_band *isl_schedule_band_point(
index 4136735..2feacd6 100644 (file)
@@ -965,6 +965,28 @@ error:
        return NULL;
 }
 
+/* Divide the partial schedule of the band node "node"
+ * by the factors in "mv".
+ */
+__isl_give isl_schedule_node *isl_schedule_node_band_scale_down(
+       __isl_take isl_schedule_node *node, __isl_take isl_multi_val *mv)
+{
+       isl_schedule_tree *tree;
+
+       if (!node || !mv)
+               goto error;
+       if (check_space_multi_val(node, mv) < 0)
+               goto error;
+
+       tree = isl_schedule_node_get_tree(node);
+       tree = isl_schedule_tree_band_scale_down(tree, mv);
+       return isl_schedule_node_graft_tree(node, tree);
+error:
+       isl_multi_val_free(mv);
+       isl_schedule_node_free(node);
+       return NULL;
+}
+
 /* Tile "node" with tile sizes "sizes".
  *
  * The current node is replaced by two nested nodes corresponding
index f818419..5a0858b 100644 (file)
@@ -1068,6 +1068,33 @@ error:
        return NULL;
 }
 
+/* Divide the partial schedule of the band root node of "tree"
+ * by the factors in "mv".
+ */
+__isl_give isl_schedule_tree *isl_schedule_tree_band_scale_down(
+       __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *mv)
+{
+       if (!tree || !mv)
+               goto error;
+       if (tree->type != isl_schedule_node_band)
+               isl_die(isl_schedule_tree_get_ctx(tree), isl_error_invalid,
+                       "not a band node", goto error);
+
+       tree = isl_schedule_tree_cow(tree);
+       if (!tree)
+               goto error;
+
+       tree->band = isl_schedule_band_scale_down(tree->band, mv);
+       if (!tree->band)
+               return isl_schedule_tree_free(tree);
+
+       return tree;
+error:
+       isl_schedule_tree_free(tree);
+       isl_multi_val_free(mv);
+       return NULL;
+}
+
 /* Tile the band root node of "tree" with tile sizes "sizes".
  *
  * We duplicate the band node, change the schedule of one of them
index 9dcd5a2..923d15a 100644 (file)
@@ -106,6 +106,8 @@ __isl_give isl_schedule_tree *isl_schedule_tree_insert_filter(
 
 __isl_give isl_schedule_tree *isl_schedule_tree_band_scale(
        __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *mv);
+__isl_give isl_schedule_tree *isl_schedule_tree_band_scale_down(
+       __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *mv);
 __isl_give isl_schedule_tree *isl_schedule_tree_band_tile(
        __isl_take isl_schedule_tree *tree, __isl_take isl_multi_val *sizes);
 __isl_give isl_schedule_tree *isl_schedule_tree_band_split(