@@ -517,6 +517,7 @@ EXTRA_DIST = \
isl_multi_unbind_params_templ.c \
isl_multi_union_add_templ.c \
isl_multi_zero_templ.c \
+ isl_opt_mpa_templ.c \
opt_type.h \
print_templ.c \
print_templ_yaml.c \
@@ -6160,8 +6160,20 @@ NaN if the input is empty.
__isl_take isl_map *map, int pos);
__isl_give isl_pw_aff *isl_map_dim_max(
__isl_take isl_map *map, int pos);
+ __isl_give isl_multi_pw_aff *
+ isl_set_min_multi_pw_aff(
+ __isl_take isl_set *set);
+ __isl_give isl_multi_pw_aff *
+ isl_set_max_multi_pw_aff(
+ __isl_take isl_set *set);
+ __isl_give isl_multi_pw_aff *
+ isl_map_min_multi_pw_aff(
+ __isl_take isl_map *map);
+ __isl_give isl_multi_pw_aff *
+ isl_map_max_multi_pw_aff(
+ __isl_take isl_map *map);
-Compute the minimum or maximum of the given set or output dimension
+Compute the minimum or maximum of the (given) set or output dimension(s)
as a function of the parameters (and input dimensions), but independently
of the other set or output dimensions.
For lexicographic optimization, see L<"Lexicographic Optimization">.
@@ -265,6 +265,10 @@ __isl_give isl_pw_multi_aff *isl_map_lexmin_pw_multi_aff(
__isl_export
__isl_give isl_pw_multi_aff *isl_map_lexmax_pw_multi_aff(
__isl_take isl_map *map);
+__isl_export
+__isl_give isl_multi_pw_aff *isl_map_min_multi_pw_aff(__isl_take isl_map *map);
+__isl_export
+__isl_give isl_multi_pw_aff *isl_map_max_multi_pw_aff(__isl_take isl_map *map);
void isl_basic_map_print_internal(__isl_keep isl_basic_map *bmap,
FILE *out, int indent);
@@ -223,6 +223,10 @@ __isl_give isl_pw_multi_aff *isl_set_lexmin_pw_multi_aff(
__isl_export
__isl_give isl_pw_multi_aff *isl_set_lexmax_pw_multi_aff(
__isl_take isl_set *set);
+__isl_export
+__isl_give isl_multi_pw_aff *isl_set_min_multi_pw_aff(__isl_take isl_set *set);
+__isl_export
+__isl_give isl_multi_pw_aff *isl_set_max_multi_pw_aff(__isl_take isl_set *set);
__isl_export
__isl_give isl_set *isl_basic_set_union(
@@ -6410,6 +6410,50 @@ isl_bool isl_multi_pw_aff_has_non_trivial_domain(
return isl_bool_not(isl_set_plain_is_universe(mpa->u.dom));
}
+#undef BASE
+#define BASE set
+
+#include "isl_opt_mpa_templ.c"
+
+/* Compute the minima of the set dimensions as a function of the
+ * parameters, but independently of the other set dimensions.
+ */
+__isl_give isl_multi_pw_aff *isl_set_min_multi_pw_aff(__isl_take isl_set *set)
+{
+ return set_opt_mpa(set, &isl_set_dim_min);
+}
+
+/* Compute the maxima of the set dimensions as a function of the
+ * parameters, but independently of the other set dimensions.
+ */
+__isl_give isl_multi_pw_aff *isl_set_max_multi_pw_aff(__isl_take isl_set *set)
+{
+ return set_opt_mpa(set, &isl_set_dim_max);
+}
+
+#undef BASE
+#define BASE map
+
+#include "isl_opt_mpa_templ.c"
+
+/* Compute the minima of the output dimensions as a function of the
+ * parameters and input dimensions, but independently of
+ * the other output dimensions.
+ */
+__isl_give isl_multi_pw_aff *isl_map_min_multi_pw_aff(__isl_take isl_map *map)
+{
+ return map_opt_mpa(map, &isl_map_dim_min);
+}
+
+/* Compute the maxima of the output dimensions as a function of the
+ * parameters and input dimensions, but independently of
+ * the other output dimensions.
+ */
+__isl_give isl_multi_pw_aff *isl_map_max_multi_pw_aff(__isl_take isl_map *map)
+{
+ return map_opt_mpa(map, &isl_map_dim_max);
+}
+
/* Scale the elements of "pma" by the corresponding elements of "mv".
*/
__isl_give isl_pw_multi_aff *isl_pw_multi_aff_scale_multi_val(
--- /dev/null
+/*
+ * Copyright 2018 Cerebras Systems
+ *
+ * Use of this software is governed by the MIT license
+ *
+ * Written by Sven Verdoolaege,
+ * Cerebras Systems, 175 S San Antonio Rd, Los Altos, CA, USA
+ */
+
+#undef TYPE
+#define TYPE CAT(isl_,BASE)
+#define xFN(TYPE,NAME) TYPE ## _ ## NAME
+#define FN(TYPE,NAME) xFN(TYPE,NAME)
+
+/* Compute the optima of the set or output dimensions as a function of the
+ * parameters (and input dimensions), but independently of
+ * the other set or output dimensions,
+ * given a function "opt" that computes this optimum
+ * for a single dimension.
+ *
+ * If the resulting multi piecewise affine expression has
+ * an explicit domain, then assign it the parameter domain of the input.
+ * In other cases, the parameter domain is stored in the individual elements.
+ */
+static __isl_give isl_multi_pw_aff *FN(BASE,opt_mpa)(__isl_take TYPE *obj,
+ __isl_give isl_pw_aff *(*opt)(__isl_take TYPE *obj, int pos))
+{
+ int i;
+ isl_size n;
+ isl_multi_pw_aff *mpa;
+
+ mpa = isl_multi_pw_aff_alloc(FN(TYPE,get_space)(obj));
+ n = isl_multi_pw_aff_size(mpa);
+ if (n < 0)
+ mpa = isl_multi_pw_aff_free(mpa);
+ for (i = 0; i < n; ++i) {
+ isl_pw_aff *pa;
+
+ pa = opt(FN(TYPE,copy)(obj), i);
+ mpa = isl_multi_pw_aff_set_pw_aff(mpa, i, pa);
+ }
+ if (isl_multi_pw_aff_has_explicit_domain(mpa)) {
+ isl_set *dom;
+
+ dom = FN(TYPE,params)(FN(TYPE,copy)(obj));
+ mpa = isl_multi_pw_aff_intersect_params(mpa, dom);
+ }
+ FN(TYPE,free)(obj);
+
+ return mpa;
+}