isl_band: use isl_union_pw_multi_aff to represent partial schedule
authorSven Verdoolaege <skimo@kotnet.org>
Tue, 20 Mar 2012 13:39:39 +0000 (14:39 +0100)
committerSven Verdoolaege <skimo@kotnet.org>
Sun, 6 May 2012 12:33:06 +0000 (14:33 +0200)
An isl_multi_aff is a more natural representation for the kind of schedules
we are constructing and will make it easier to perform tiling.

Signed-off-by: Sven Verdoolaege <skimo@kotnet.org>
isl_band.c
isl_band_private.h
isl_schedule.c

index 53582f0..7de74f3 100644 (file)
@@ -14,7 +14,7 @@
 
 isl_ctx *isl_band_get_ctx(__isl_keep isl_band *band)
 {
-       return band ? isl_union_map_get_ctx(band->map) : NULL;
+       return band ? isl_union_pw_multi_aff_get_ctx(band->pma) : NULL;
 }
 
 /* We not only increment the reference count of the band,
@@ -46,7 +46,7 @@ void *isl_band_free(__isl_take isl_band *band)
        if (--band->ref > 0)
                return isl_schedule_free(band->schedule);
 
-       isl_union_map_free(band->map);
+       isl_union_pw_multi_aff_free(band->pma);
        isl_band_list_free(band->children);
        free(band->zero);
        free(band);
@@ -98,21 +98,34 @@ int isl_band_member_is_zero_distance(__isl_keep isl_band *band, int pos)
 __isl_give isl_union_map *isl_band_get_prefix_schedule(
        __isl_keep isl_band *band)
 {
-       isl_union_map *prefix;
+       isl_union_set *domain;
+       isl_union_pw_multi_aff *prefix;
        isl_band *a;
 
        if (!band)
                return NULL;
 
-       prefix = isl_union_map_copy(band->map);
-       prefix = isl_union_map_from_domain(isl_union_map_domain(prefix));
+       prefix = isl_union_pw_multi_aff_copy(band->pma);
+       domain = isl_union_pw_multi_aff_domain(prefix);
+       prefix = isl_union_pw_multi_aff_from_domain(domain);
 
        for (a = band->parent; a; a = a->parent) {
-               isl_union_map *partial = isl_union_map_copy(a->map);
-               prefix = isl_union_map_flat_range_product(partial, prefix);
+               isl_union_pw_multi_aff *partial;
+
+               partial = isl_union_pw_multi_aff_copy(a->pma);
+               prefix = isl_union_pw_multi_aff_flat_range_product(partial,
+                                                                  prefix);
        }
 
-       return prefix;
+       return isl_union_map_from_union_pw_multi_aff(prefix);
+}
+
+/* Return the schedule of the band in isolation.
+ */
+__isl_give isl_union_pw_multi_aff *
+isl_band_get_partial_schedule_union_pw_multi_aff(__isl_keep isl_band *band)
+{
+       return band ? isl_union_pw_multi_aff_copy(band->pma) : NULL;
 }
 
 /* Return the schedule of the band in isolation.
@@ -120,40 +133,48 @@ __isl_give isl_union_map *isl_band_get_prefix_schedule(
 __isl_give isl_union_map *isl_band_get_partial_schedule(
        __isl_keep isl_band *band)
 {
-       return band ? isl_union_map_copy(band->map) : NULL;
+       isl_union_pw_multi_aff *sched;
+
+       sched = isl_band_get_partial_schedule_union_pw_multi_aff(band);
+       return isl_union_map_from_union_pw_multi_aff(sched);
 }
 
 /* Return the schedule for the forest underneath the given band.
  */
-__isl_give isl_union_map *isl_band_get_suffix_schedule(
-       __isl_keep isl_band *band)
+__isl_give isl_union_pw_multi_aff *
+isl_band_get_suffix_schedule_union_pw_multi_aff(__isl_keep isl_band *band)
 {
-       isl_union_map *suffix;
+       isl_union_pw_multi_aff *suffix;
 
        if (!band)
                return NULL;
 
        if (!isl_band_has_children(band)) {
-               suffix = isl_union_map_copy(band->map);
-               suffix = isl_union_map_from_domain(isl_union_map_domain(suffix));
+               isl_union_set *domain;
+
+               suffix = isl_union_pw_multi_aff_copy(band->pma);
+               domain = isl_union_pw_multi_aff_domain(suffix);
+               suffix = isl_union_pw_multi_aff_from_domain(domain);
        } else {
                int i, n;
+               isl_space *space;
                isl_band_list *children;
 
-               suffix = isl_union_map_empty(isl_union_map_get_space(band->map));
+               space = isl_union_pw_multi_aff_get_space(band->pma);
+               suffix = isl_union_pw_multi_aff_empty(space);
                children = isl_band_get_children(band);
                n = isl_band_list_n_band(children);
                for (i = 0; i < n; ++i) {
                        isl_band *child;
-                       isl_union_map *partial_i;
-                       isl_union_map *suffix_i;
+                       isl_union_pw_multi_aff *partial_i;
+                       isl_union_pw_multi_aff *suffix_i;
 
                        child = isl_band_list_get_band(children, i);
-                       partial_i = isl_band_get_partial_schedule(child);
-                       suffix_i = isl_band_get_suffix_schedule(child);
-                       suffix_i = isl_union_map_flat_range_product(partial_i,
-                                                                   suffix_i);
-                       suffix = isl_union_map_union(suffix, suffix_i);
+                       partial_i = isl_band_get_partial_schedule_union_pw_multi_aff(child);
+                       suffix_i = isl_band_get_suffix_schedule_union_pw_multi_aff(child);
+                       suffix_i = isl_union_pw_multi_aff_flat_range_product(
+                                       partial_i, suffix_i);
+                       suffix = isl_union_pw_multi_aff_add(suffix, suffix_i);
 
                        isl_band_free(child);
                }
@@ -163,6 +184,17 @@ __isl_give isl_union_map *isl_band_get_suffix_schedule(
        return suffix;
 }
 
+/* Return the schedule for the forest underneath the given band.
+ */
+__isl_give isl_union_map *isl_band_get_suffix_schedule(
+       __isl_keep isl_band *band)
+{
+       isl_union_pw_multi_aff *suffix;
+
+       suffix = isl_band_get_suffix_schedule_union_pw_multi_aff(band);
+       return isl_union_map_from_union_pw_multi_aff(suffix);
+}
+
 __isl_give isl_printer *isl_printer_print_band(__isl_take isl_printer *p,
        __isl_keep isl_band *band)
 {
index 579ef66..b5e2b08 100644 (file)
@@ -1,17 +1,17 @@
 #ifndef ISL_BAND_PRIVATE_H
 #define ISL_BAND_PRIVATE_H
 
+#include <isl/aff.h>
 #include <isl/band.h>
 #include <isl/list.h>
 #include <isl/schedule.h>
-#include <isl/union_map.h>
 
 /* Information about a band within a schedule.
  *
  * n is the number of scheduling dimensions within the band.
  * zero is an array of length n, indicating whether a scheduling dimension
  *     results in zero dependence distances for the proximity dependences.
- * map is the partial map corresponding to this band.
+ * pma is the partial schedule corresponding to this band.
  * schedule is the schedule that contains this band.
  * parent is the parent of this band (or NULL if the band is a root).
  * children are the children of this band (or NULL if the band is a leaf).
@@ -27,7 +27,7 @@ struct isl_band {
        int n;
        int *zero;
 
-       isl_union_map *map;
+       isl_union_pw_multi_aff *pma;
        isl_schedule *schedule;
        isl_band *parent;
        isl_band_list *children;
index 85c8c17..7c57156 100644 (file)
@@ -2942,24 +2942,24 @@ static __isl_give isl_band *construct_band(__isl_keep isl_schedule *schedule,
        for (j = 0; j < band->n; ++j)
                band->zero[j] = schedule->node[i].zero[start + j];
 
-       band->map = isl_union_map_empty(isl_space_copy(schedule->dim));
+       band->pma = isl_union_pw_multi_aff_empty(isl_space_copy(schedule->dim));
        for (i = 0; i < schedule->n; ++i) {
                isl_multi_aff *ma;
-               isl_map *map;
+               isl_pw_multi_aff *pma;
                unsigned n_out;
 
                if (!active[i])
                        continue;
 
                ma = isl_multi_aff_copy(schedule->node[i].sched);
-               map = isl_map_from_multi_aff(ma);
-               n_out = isl_map_dim(map, isl_dim_out);
-               map = isl_map_project_out(map, isl_dim_out, end, n_out - end);
-               map = isl_map_project_out(map, isl_dim_out, 0, start);
-               band->map = isl_union_map_union(band->map,
-                                               isl_union_map_from_map(map));
+               n_out = isl_multi_aff_dim(ma, isl_dim_out);
+               ma = isl_multi_aff_drop_dims(ma, isl_dim_out, end, n_out - end);
+               ma = isl_multi_aff_drop_dims(ma, isl_dim_out, 0, start);
+               pma = isl_pw_multi_aff_from_multi_aff(ma);
+               band->pma = isl_union_pw_multi_aff_add_pw_multi_aff(band->pma,
+                                                                   pma);
        }
-       if (!band->map)
+       if (!band->pma)
                goto error;
 
        return band;
@@ -3101,7 +3101,7 @@ static __isl_give isl_printer *print_band(__isl_take isl_printer *p,
        isl_band_list *children;
 
        p = isl_printer_start_line(p);
-       p = isl_printer_print_union_map(p, band->map);
+       p = isl_printer_print_union_pw_multi_aff(p, band->pma);
        p = isl_printer_end_line(p);
 
        if (!isl_band_has_children(band))