scheduling: optionally create schedules with outermost parallelism
[platform/upstream/isl.git] / isl_scan.c
index c8eba37..64654be 100644 (file)
@@ -7,11 +7,12 @@
  * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
  */
 
+#include <isl_ctx_private.h>
+#include <isl_map_private.h>
 #include "isl_basis_reduction.h"
 #include "isl_scan.h"
-#include "isl_seq.h"
+#include <isl/seq.h>
 #include "isl_tab.h"
-#include <isl_map_private.h>
 
 struct isl_counter {
        struct isl_scan_callback callback;
@@ -78,7 +79,7 @@ static int scan_0D(struct isl_basic_set *bset,
        return callback->add(callback, sample);
 }
 
-/* Look for all integer points in "bset", which is assumed to be unbounded,
+/* Look for all integer points in "bset", which is assumed to be bounded,
  * and call callback->add on each of them.
  *
  * We first compute a reduced basis for the set and then scan
@@ -242,6 +243,33 @@ error:
        return -1;
 }
 
+int isl_basic_set_count_upto(__isl_keep isl_basic_set *bset,
+       isl_int max, isl_int *count)
+{
+       struct isl_counter cnt = { { &increment_counter } };
+
+       if (!bset)
+               return -1;
+
+       isl_int_init(cnt.count);
+       isl_int_init(cnt.max);
+
+       isl_int_set_si(cnt.count, 0);
+       isl_int_set(cnt.max, max);
+       if (isl_basic_set_scan(isl_basic_set_copy(bset), &cnt.callback) < 0 &&
+           isl_int_lt(cnt.count, cnt.max))
+               goto error;
+
+       isl_int_set(*count, cnt.count);
+       isl_int_clear(cnt.max);
+       isl_int_clear(cnt.count);
+
+       return 0;
+error:
+       isl_int_clear(cnt.count);
+       return -1;
+}
+
 int isl_set_count_upto(__isl_keep isl_set *set, isl_int max, isl_int *count)
 {
        struct isl_counter cnt = { { &increment_counter } };