6 #include <cloog/isl/cloog.h>
9 CloogDomain
*cloog_domain_from_isl_set(struct isl_set
*set
)
11 set
= isl_set_detect_equalities(set
);
12 return (CloogDomain
*)set
;
15 CloogScattering
*cloog_scattering_from_isl_map(struct isl_map
*map
)
17 return (CloogScattering
*)map
;
22 * Returns true if each scattering dimension is defined in terms
23 * of the original iterators.
25 int cloog_scattering_fully_specified(CloogScattering
*scattering
,
29 int scattering_dim
= cloog_scattering_dimension(scattering
, domain
);
30 for (i
= 0; i
< scattering
->map
.n
; ++i
)
31 if (scattering
->map
.p
[i
]->n_eq
< scattering_dim
)
37 CloogConstraintSet
*cloog_domain_constraints(CloogDomain
*domain
)
39 assert(domain
->set
.n
== 1);
40 return cloog_constraint_set_from_isl_basic_set(
41 isl_basic_set_copy(domain
->set
.p
[0]));
45 void cloog_domain_print_constraints(FILE *foo
, CloogDomain
*domain
,
49 isl_set_print(&domain
->set
, foo
, 0, ISL_FORMAT_POLYLIB
);
51 assert(domain
->set
.n
== 1);
52 isl_basic_set_print(domain
->set
.p
[0], foo
,
53 0, NULL
, NULL
, ISL_FORMAT_POLYLIB
);
58 void cloog_domain_free(CloogDomain
* domain
)
60 isl_set_free(&domain
->set
);
64 void cloog_scattering_free(CloogScattering
*scatt
)
66 isl_map_free(&scatt
->map
);
70 CloogDomain
* cloog_domain_copy(CloogDomain
* domain
)
72 return cloog_domain_from_isl_set(isl_set_copy(&domain
->set
));
77 * cloog_domain_convex function:
78 * Computes the convex hull of domain.
80 CloogDomain
*cloog_domain_convex(CloogDomain
*domain
)
82 struct isl_set
*set
= &domain
->set
;
83 set
= isl_set_from_basic_set(isl_set_convex_hull(isl_set_copy(set
)));
84 return cloog_domain_from_isl_set(set
);
89 * cloog_domain_simple_convex:
90 * Given a list (union) of polyhedra, this function returns a "simple"
91 * convex hull of this union. In particular, the constraints of the
92 * the returned polyhedron consist of (parametric) lower and upper
93 * bounds on individual variables and constraints that appear in the
96 CloogDomain
*cloog_domain_simple_convex(CloogDomain
*domain
)
98 struct isl_basic_set
*hull
;
99 unsigned dim
= isl_set_n_dim(&domain
->set
);
101 if (cloog_domain_isconvex(domain
))
102 return cloog_domain_copy(domain
);
105 return cloog_domain_convex(domain
);
107 hull
= isl_set_bounded_simple_hull(isl_set_copy(&domain
->set
));
108 return cloog_domain_from_isl_set(isl_set_from_basic_set(hull
));
113 * cloog_domain_simplify function:
114 * Given two polyhedral domains (dom1) and (dom2),
115 * this function finds the largest domain set (or the smallest list
116 * of non-redundant constraints), that when intersected with polyhedral
117 * domain (dom2) equals (dom1)intersect(dom2). The output is a new CloogDomain
118 * structure with a polyhedral domain with the "redundant" constraints removed.
119 * NB: the second domain is required not to be a union.
121 CloogDomain
*cloog_domain_simplify(CloogDomain
*dom1
, CloogDomain
*dom2
)
124 assert(dom2
->set
.n
== 1);
125 set
= isl_set_gist(isl_set_copy(&dom1
->set
),
126 isl_basic_set_copy(dom2
->set
.p
[0]));
127 return cloog_domain_from_isl_set(set
);
132 * cloog_domain_union function:
133 * This function returns a new polyhedral domain which is the union of
134 * two polyhedral domains (dom1) U (dom2).
136 CloogDomain
*cloog_domain_union(CloogDomain
*dom1
, CloogDomain
*dom2
)
139 set
= isl_set_union(isl_set_copy(&dom1
->set
), isl_set_copy(&dom2
->set
));
140 return cloog_domain_from_isl_set(set
);
146 * cloog_domain_intersection function:
147 * This function returns a new polyhedral domain which is the intersection of
148 * two polyhedral domains (dom1) \cap (dom2).
150 CloogDomain
*cloog_domain_intersection(CloogDomain
*dom1
, CloogDomain
*dom2
)
153 set
= isl_set_intersect(isl_set_copy(&dom1
->set
),
154 isl_set_copy(&dom2
->set
));
155 return cloog_domain_from_isl_set(set
);
160 * cloog_domain_difference function:
161 * Returns the set difference domain \ minus.
163 CloogDomain
*cloog_domain_difference(CloogDomain
*domain
, CloogDomain
*minus
)
166 set
= isl_set_subtract(isl_set_copy(&domain
->set
),
167 isl_set_copy(&minus
->set
));
168 return cloog_domain_from_isl_set(set
);
173 * cloog_domain_sort function:
174 * This function topologically sorts (nb_doms) domains. Here (doms) is an
175 * array of pointers to CloogDomains, (nb_doms) is the number of domains,
176 * (level) is the level to consider for partial ordering (nb_par) is the
177 * parameter space dimension, (permut) if not NULL, is an array of (nb_doms)
178 * integers that contains a permutation specification after call in order to
179 * apply the topological sorting.
181 void cloog_domain_sort(CloogDomain
**doms
, unsigned nb_doms
, unsigned level
,
186 unsigned char **follows
;
190 ctx
= doms
[0]->set
.ctx
;
191 for (i
= 0; i
< nb_doms
; i
++)
192 assert(doms
[i
]->set
.n
== 1);
194 follows
= isl_alloc_array(ctx
, unsigned char *, nb_doms
);
196 for (i
= 0; i
< nb_doms
; ++i
) {
197 follows
[i
] = isl_alloc_array(ctx
, unsigned char, nb_doms
);
199 for (j
= 0; j
< nb_doms
; ++j
)
203 for (i
= 1; i
< nb_doms
; ++i
) {
204 for (j
= 0; j
< i
; ++j
) {
205 if (follows
[i
][j
] || follows
[j
][i
])
207 cmp
= isl_basic_set_compare_at(doms
[i
]->set
.p
[0],
208 doms
[j
]->set
.p
[0], level
-1);
213 for (k
= 0; k
< i
; ++k
)
214 follows
[i
][k
] |= follows
[j
][k
];
217 for (k
= 0; k
< i
; ++k
)
218 follows
[k
][i
] |= follows
[k
][j
];
223 for (i
= 0, j
= 0; i
< nb_doms
; j
= (j
+ 1) % nb_doms
) {
224 for (k
= 0; k
< nb_doms
; ++k
)
229 for (k
= 0; k
< nb_doms
; ++k
)
236 for (i
= 0; i
< nb_doms
; ++i
)
243 * Check whether there is or may be any value of dom1 at the given level
244 * that is greater than or equal to a value of dom2 at the same level.
247 * 1 is there is or may be a greater-than pair.
248 * 0 if there is no greater-than pair, but there may be an equal-to pair
249 * -1 if there is definitely no such pair
251 int cloog_domain_follows(CloogDomain
*dom1
, CloogDomain
*dom2
, unsigned level
)
255 follows
= isl_set_follows_at(&dom1
->set
, &dom2
->set
, level
- 1);
256 assert(follows
>= -1);
263 * cloog_domain_empty function:
264 * Returns an empty domain of the same dimensions as template.
266 CloogDomain
*cloog_domain_empty(CloogDomain
*template)
268 return cloog_domain_from_isl_set(isl_set_empty_like(&template->set
));
272 /******************************************************************************
273 * Structure display function *
274 ******************************************************************************/
278 * cloog_domain_print_structure :
279 * this function is a more human-friendly way to display the CloogDomain data
280 * structure, it only shows the constraint system and includes an indentation
281 * level (level) in order to work with others print_structure functions.
283 void cloog_domain_print_structure(FILE *file
, CloogDomain
*domain
, int level
,
289 struct isl_set
*set
= &domain
->set
;
291 /* Go to the right level. */
292 for (i
= 0; i
< level
; i
++)
293 fprintf(file
, "|\t");
296 fprintf(file
, "+-- Null CloogDomain\n");
299 fprintf(file
, "+-- %s\n", name
);
300 prefix
= isl_alloc_array(set
->ctx
, char, 2*(level
+1)+3);
302 for (i
= 0; i
< level
+1; ++i
)
303 memcpy(prefix
+2*i
, "|\t", 2);
304 strcpy(prefix
+2*(level
+1), "[ ");
306 for (i
= 0; i
< set
->n
; ++i
) {
307 isl_basic_set_print(set
->p
[i
], file
, 0, prefix
, suffix
,
308 ISL_FORMAT_POLYLIB_CONSTRAINTS
);
309 prefix
[2*(level
+1)] = '\0';
310 fprintf(file
, "%s\n", prefix
);
311 prefix
[2*(level
+1)] = '[';
317 /******************************************************************************
318 * Memory deallocation function *
319 ******************************************************************************/
323 * cloog_scattering_list_free function:
324 * This function frees the allocated memory for a CloogScatteringList structure.
326 void cloog_scattering_list_free(CloogScatteringList
*list
)
328 while (list
!= NULL
) {
329 CloogScatteringList
*temp
= list
->next
;
330 isl_map_free(&list
->scatt
->map
);
337 /******************************************************************************
339 ******************************************************************************/
343 * cloog_domain_read_context function:
344 * Read parameter domain.
346 CloogDomain
*cloog_domain_read_context(CloogState
*state
, FILE *input
)
348 struct isl_ctx
*ctx
= state
->backend
->ctx
;
349 struct isl_dim
*param_dim
;
350 struct isl_basic_set
*bset
;
351 struct isl_basic_set
*model
;
353 bset
= isl_basic_set_read_from_file(ctx
, input
, 0);
355 param_dim
= isl_dim_set_alloc(ctx
, isl_basic_set_n_dim(bset
), 0);
356 model
= isl_basic_set_empty(param_dim
);
357 bset
= isl_basic_set_from_underlying_set(bset
, model
);
359 return cloog_domain_from_isl_set(isl_set_from_basic_set(bset
));
364 * cloog_domain_from_context
365 * Reinterpret context by turning parameters into variables.
367 CloogDomain
*cloog_domain_from_context(CloogDomain
*context
)
370 struct isl_basic_set
*model
;
371 struct isl_set
*ctx_set
= &context
->set
;
374 dim
= isl_dim_set_alloc(ctx_set
->ctx
, 0, isl_set_n_param(ctx_set
));
375 model
= isl_basic_set_empty(dim
);
376 ctx_set
= isl_set_to_underlying_set(ctx_set
);
377 set
= isl_set_from_underlying_set(ctx_set
, model
);
378 return cloog_domain_from_isl_set(set
);
383 * cloog_domain_union_read function:
384 * This function reads a union of polyhedra into a file (input) and
385 * returns a pointer to a CloogDomain containing the read information.
387 CloogDomain
*cloog_domain_union_read(CloogState
*state
,
388 FILE *input
, int nb_parameters
)
390 struct isl_ctx
*ctx
= state
->backend
->ctx
;
393 set
= isl_set_read_from_file(ctx
, input
, nb_parameters
);
394 return cloog_domain_from_isl_set(set
);
399 * cloog_domain_read_scattering function:
400 * This function reads in a scattering function from the file input.
402 CloogScattering
*cloog_domain_read_scattering(CloogDomain
*domain
, FILE *input
)
404 struct isl_ctx
*ctx
= domain
->set
.ctx
;
406 struct isl_map
*scat
;
407 struct isl_dim
*dims
;
412 nparam
= isl_set_n_param(&domain
->set
);
413 set
= isl_set_read_from_file(ctx
, input
, nparam
);
414 dim
= isl_set_n_dim(&domain
->set
);
415 n_scat
= isl_set_n_dim(set
) - dim
;
416 dims
= isl_dim_alloc(ctx
, nparam
, n_scat
, dim
);
417 scat
= isl_map_from_set(set
, dims
);
418 scat
= isl_map_reverse(scat
);
419 return cloog_scattering_from_isl_map(scat
);
422 /******************************************************************************
423 * CloogMatrix Reading function *
424 ******************************************************************************/
427 * isl_constraint_read_from_matrix:
428 * Convert a single line of a matrix to a isl_constraint.
429 * Returns a pointer to the constraint if successful; NULL otherwise.
431 static struct isl_constraint
*isl_constraint_read_from_matrix(
432 struct isl_dim
*dim
, cloog_int_t
*row
)
434 struct isl_constraint
*constraint
;
436 int nvariables
= isl_dim_size(dim
, isl_dim_set
);
437 int nparam
= isl_dim_size(dim
, isl_dim_param
);
439 if (cloog_int_is_zero(row
[0]))
440 constraint
= isl_equality_alloc(dim
);
442 constraint
= isl_inequality_alloc(dim
);
444 for (j
= 0; j
< nvariables
; ++j
)
445 isl_constraint_set_coefficient(constraint
, isl_dim_out
, j
,
448 for (j
= 0; j
< nparam
; ++j
)
449 isl_constraint_set_coefficient(constraint
, isl_dim_param
, j
,
450 row
[1 + nvariables
+ j
]);
452 isl_constraint_set_constant(constraint
, row
[1 + nvariables
+ nparam
]);
458 * isl_basic_set_read_from_matrix:
459 * Convert matrix to basic_set. The matrix contains nparam parameter columns.
460 * Returns a pointer to the basic_set if successful; NULL otherwise.
462 static struct isl_basic_set
*isl_basic_set_read_from_matrix(struct isl_ctx
*ctx
,
463 CloogMatrix
* matrix
, int nparam
)
466 struct isl_basic_set
*bset
;
468 unsigned nrows
, ncolumns
;
470 nrows
= matrix
->NbRows
;
471 ncolumns
= matrix
->NbColumns
;
472 int nvariables
= ncolumns
- 2 - nparam
;
474 dim
= isl_dim_set_alloc(ctx
, nparam
, nvariables
);
476 bset
= isl_basic_set_universe(isl_dim_copy(dim
));
478 for (i
= 0; i
< nrows
; ++i
) {
479 cloog_int_t
*row
= matrix
->p
[i
];
480 struct isl_constraint
*constraint
=
481 isl_constraint_read_from_matrix(isl_dim_copy(dim
), row
);
482 bset
= isl_basic_set_add_constraint(bset
, constraint
);
491 * cloog_domain_from_cloog_matrix:
492 * Create a CloogDomain containing the constraints described in matrix.
493 * nparam is the number of parameters contained in the domain.
494 * Returns a pointer to the CloogDomain if successful; NULL otherwise.
496 CloogDomain
*cloog_domain_from_cloog_matrix(CloogState
*state
,
497 CloogMatrix
*matrix
, int nparam
)
499 struct isl_ctx
*ctx
= state
->backend
->ctx
;
500 struct isl_basic_set
*bset
;
502 bset
= isl_basic_set_read_from_matrix(ctx
, matrix
, nparam
);
504 return cloog_domain_from_isl_set(isl_set_from_basic_set(bset
));
508 * cloog_scattering_from_cloog_matrix:
509 * Create a CloogScattering containing the constraints described in matrix.
510 * nparam is the number of parameters contained in the domain.
511 * Returns a pointer to the CloogScattering if successful; NULL otherwise.
513 CloogScattering
*cloog_scattering_from_cloog_matrix(CloogState
*state
,
514 CloogMatrix
*matrix
, int nb_scat
, int nb_par
)
516 struct isl_ctx
*ctx
= state
->backend
->ctx
;
517 struct isl_basic_set
*bset
;
518 struct isl_basic_map
*scat
;
519 struct isl_dim
*dims
;
522 bset
= isl_basic_set_read_from_matrix(ctx
, matrix
, nb_par
);
523 dim
= isl_basic_set_n_dim(bset
) - nb_scat
;
524 dims
= isl_dim_alloc(ctx
, nb_par
, nb_scat
, dim
);
526 scat
= isl_basic_map_from_basic_set(bset
, dims
);
527 scat
= isl_basic_map_reverse(scat
);
528 return cloog_scattering_from_isl_map(isl_map_from_basic_map(scat
));
532 /******************************************************************************
533 * Processing functions *
534 ******************************************************************************/
539 * cloog_domain_isempty function:
541 int cloog_domain_isempty(CloogDomain
*domain
)
543 return isl_set_is_empty(&domain
->set
);
548 * cloog_domain_universe function:
549 * This function returns the complete dim-dimensional space.
551 CloogDomain
*cloog_domain_universe(CloogState
*state
, unsigned dim
)
553 struct isl_dim
*dims
;
554 struct isl_basic_set
*bset
;
556 dims
= isl_dim_set_alloc(state
->backend
->ctx
, 0, dim
);
557 bset
= isl_basic_set_universe(dims
);
558 return cloog_domain_from_isl_set(isl_set_from_basic_set(bset
));
563 * cloog_domain_project function:
564 * This function returns the projection of
565 * (domain) on the (level) first dimensions (i.e. outer loops).
567 CloogDomain
*cloog_domain_project(CloogDomain
*domain
, int level
)
569 struct isl_set
*set
= &domain
->set
;
570 set
= isl_set_remove_dims(isl_set_copy(set
),
571 level
, isl_set_n_dim(set
) - level
);
572 return cloog_domain_from_isl_set(set
);
577 * cloog_domain_extend function:
578 * This function returns the (domain) given as input with (dim)
579 * dimensions and (nb_par) parameters.
580 * This function does not free (domain), and returns a new CloogDomain.
582 CloogDomain
*cloog_domain_extend(CloogDomain
*domain
, int dim
)
584 struct isl_set
*set
= &domain
->set
;
585 set
= isl_set_extend(isl_set_copy(set
), isl_set_n_param(set
), dim
);
586 return cloog_domain_from_isl_set(set
);
591 * cloog_domain_never_integral function:
592 * For us, an equality like 3*i -4 = 0 is always false since 4%3 != 0.
593 * There is no need to check for such constraints explicitly for the isl
596 int cloog_domain_never_integral(CloogDomain
* domain
)
598 return isl_set_is_empty(&domain
->set
);
603 * cloog_domain_stride function:
604 * This function finds the stride imposed to unknown with the column number
605 * 'strided_level' in order to be integral. For instance, if we have a
606 * constraint like -i - 2j + 2k = 0, and we consider k, then k can be integral
607 * only if (i + 2j)%2 = 0. Then only if i%2 = 0. Then k imposes a stride 2 to
608 * the unknown i. The function returns the imposed stride in a parameter field.
609 * - domain is the set of constraint we have to consider,
610 * - strided_level is the column number of the unknown for which a stride have
612 * - looking_level is the column number of the unknown that impose a stride to
614 * - stride is the stride that is returned back as a function parameter.
615 * - offset is the value of the constant c if the condition is of the shape
616 * (i + c)%s = 0, s being the stride.
618 void cloog_domain_stride(CloogDomain
*domain
, int strided_level
,
619 cloog_int_t
*stride
, cloog_int_t
*offset
)
621 struct isl_set
*set
= &domain
->set
;
622 isl_set_dim_residue_class(set
, strided_level
- 1, stride
, offset
);
623 if (!isl_int_is_zero(*offset
))
624 isl_int_sub(*offset
, *stride
, *offset
);
630 * cloog_domain_integral_lowerbound function:
631 * This function returns 1 if the lower bound of an iterator (such as its
632 * column rank in the constraint set 'domain' is 'level') is integral,
633 * 0 otherwise. If the lower bound is actually integral, the function fills
634 * the 'lower' field with the lower bound value.
636 int cloog_domain_integral_lowerbound(CloogDomain
*domain
, int level
,
639 return isl_set_fast_dim_has_fixed_lower_bound(&domain
->set
, level
-1, lower
);
644 * cloog_domain_lazy_equal function:
645 * This function returns 1 if the domains given as input are the same, 0 if it
646 * is unable to decide.
648 int cloog_domain_lazy_equal(CloogDomain
*d1
, CloogDomain
*d2
)
650 return isl_set_fast_is_equal(&d1
->set
, &d2
->set
);
655 * cloog_scattering_lazy_block function:
656 * This function returns 1 if the two scattering functions s1 and s2 given
657 * as input are the same (except possibly for the final dimension, where we
658 * allow a difference of 1), assuming that the domains on which this
659 * scatterings are applied are the same.
660 * In fact this function answers the question "can I
661 * safely consider the two domains as only one with two statements (a block) ?".
662 * - s1 and s2 are the two domains to check for blocking,
663 * - scattering is the linked list of all domains,
664 * - scattdims is the total number of scattering dimentions.
666 int cloog_scattering_lazy_block(CloogScattering
*s1
, CloogScattering
*s2
,
667 CloogScatteringList
*scattering
, int scattdims
)
672 struct isl_set
*delta
;
677 n_scat
= isl_map_dim(&s1
->map
, isl_dim_out
);
678 if (n_scat
!= isl_map_dim(&s2
->map
, isl_dim_out
))
681 dim
= isl_dim_copy(s1
->map
.dim
);
682 dim
= isl_dim_domain(dim
);
683 rel
= isl_map_identity(dim
);
684 rel
= isl_map_apply_domain(rel
, isl_map_copy(&s1
->map
));
685 rel
= isl_map_apply_range(rel
, isl_map_copy(&s2
->map
));
686 delta
= isl_map_deltas(rel
);
688 for (i
= 0; i
< n_scat
; ++i
) {
689 fixed
= isl_set_fast_dim_is_fixed(delta
, i
, &cst
);
692 if (i
+1 < n_scat
&& !isl_int_is_zero(cst
))
694 if (!isl_int_is_zero(cst
) && !isl_int_is_one(cst
))
705 * cloog_domain_lazy_disjoint function:
706 * This function returns 1 if the domains given as input are disjoint, 0 if it
707 * is unable to decide.
709 int cloog_domain_lazy_disjoint(CloogDomain
*d1
, CloogDomain
*d2
)
711 return isl_set_fast_is_disjoint(&d1
->set
, &d2
->set
);
716 * cloog_scattering_list_lazy_same function:
717 * This function returns 1 if two domains in the list are the same, 0 if it
718 * is unable to decide.
720 int cloog_scattering_list_lazy_same(CloogScatteringList
*list
)
722 CloogScatteringList
*one
, *other
;
724 for (one
= list
; one
; one
= one
->next
)
725 for (other
= one
->next
; other
; other
= other
->next
)
726 if (isl_map_fast_is_equal(&one
->scatt
->map
,
732 int cloog_domain_dimension(CloogDomain
* domain
)
734 return isl_set_n_dim(&domain
->set
);
737 int cloog_domain_parameter_dimension(CloogDomain
*domain
)
739 return isl_set_n_param(&domain
->set
);
742 int cloog_scattering_dimension(CloogScattering
*scatt
, CloogDomain
*domain
)
744 return isl_map_dim(&scatt
->map
, isl_dim_out
);
747 int cloog_domain_isconvex(CloogDomain
* domain
)
749 return domain
->set
.n
<= 1;
754 * cloog_domain_cut_first function:
755 * This function splits off and returns the first convex set in the
756 * union "domain". The remainder of the union is returned in rest.
757 * The original "domain" itself is destroyed and may not be used
758 * after a call to this function.
760 CloogDomain
*cloog_domain_cut_first(CloogDomain
*domain
, CloogDomain
**rest
)
763 struct isl_basic_set
*first
;
766 first
= isl_set_copy_basic_set(set
);
767 set
= isl_set_drop_basic_set(set
, first
);
768 *rest
= cloog_domain_from_isl_set(set
);
770 return cloog_domain_from_isl_set(isl_set_from_basic_set(first
));
775 * Given a union domain, try to find a simpler representation
776 * using fewer sets in the union.
777 * The original "domain" itself is destroyed and may not be used
778 * after a call to this function.
780 CloogDomain
*cloog_domain_simplify_union(CloogDomain
*domain
)
782 return cloog_domain_from_isl_set(isl_set_coalesce(&domain
->set
));
787 * cloog_scattering_lazy_isscalar function:
788 * this function returns 1 if the scattering dimension 'dimension' in the
789 * scattering 'scatt' is constant.
790 * If value is not NULL, then it is set to the constant value of dimension.
792 int cloog_scattering_lazy_isscalar(CloogScattering
*scatt
, int dimension
,
795 return isl_map_fast_is_fixed(&scatt
->map
, isl_dim_out
, dimension
, value
);
800 * cloog_domain_lazy_isconstant function:
801 * this function returns 1 if the dimension 'dimension' in the
802 * domain 'domain' is constant.
803 * If value is not NULL, then it is set to the constant value of dimension.
805 int cloog_domain_lazy_isconstant(CloogDomain
*domain
, int dimension
)
807 return isl_set_fast_dim_is_fixed(&domain
->set
, dimension
, NULL
);
812 * cloog_scattering_erase_dimension function:
813 * this function returns a CloogDomain structure builds from 'domain' where
814 * we removed the dimension 'dimension' and every constraint involving this
817 CloogScattering
*cloog_scattering_erase_dimension(CloogScattering
*domain
,
821 map
= isl_map_remove(isl_map_copy(&domain
->map
), isl_dim_out
, dimension
, 1);
822 return cloog_scattering_from_isl_map(map
);
827 * Construct and return a dim-dimensional cube, with values ranging
828 * between min and max in each dimension.
830 CloogDomain
*cloog_domain_cube(CloogState
*state
,
831 int dim
, cloog_int_t min
, cloog_int_t max
)
834 struct isl_basic_set
*cube
;
835 struct isl_basic_set
*interval
;
836 struct isl_basic_set_list
*list
;
839 return cloog_domain_universe(state
, dim
);
841 interval
= isl_basic_set_interval(state
->backend
->ctx
, min
, max
);
842 list
= isl_basic_set_list_alloc(state
->backend
->ctx
, dim
);
843 for (i
= 0; i
< dim
; ++i
)
844 list
= isl_basic_set_list_add(list
, isl_basic_set_copy(interval
));
845 isl_basic_set_free(interval
);
846 cube
= isl_basic_set_product(list
);
847 return cloog_domain_from_isl_set(isl_set_from_basic_set(cube
));
852 * cloog_domain_scatter function:
853 * This function add the scattering (scheduling) informations to a domain.
855 CloogDomain
*cloog_domain_scatter(CloogDomain
*domain
, CloogScattering
*scatt
)
859 map
= isl_map_reverse(isl_map_copy(&scatt
->map
));
860 map
= isl_map_intersect_range(map
, &domain
->set
);
861 return cloog_domain_from_isl_set(isl_set_from_map(map
));