@@ -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
@@ -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(
@@ -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.
@@ -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(
@@ -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
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
@@ -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(