22 #include <unordered_map>
25 #include <glog/logging.h>
27 #include <isl/interface/isl.h>
48 return v.mul(isl::val(v.get_ctx(), i));
60 return v.add(isl::val(v.get_ctx(), i));
68 return v.sub(isl::val(v.get_ctx(), i));
72 return isl::val(v.get_ctx(), i).sub(v);
92 return v.eq(isl::val(v.get_ctx(), i));
120 isl::aff
operator*(isl::aff A, isl::val V);
121 isl::aff
operator*(isl::val V, isl::aff A);
126 isl::aff
operator+(isl::aff A, isl::aff B);
128 isl::aff
operator+(isl::aff A, isl::val v);
129 isl::aff
operator+(isl::val v, isl::aff A);
182 isl::set
operator&(isl::set S1, isl::set S2);
183 isl::union_set
operator&(isl::union_set S1, isl::set S2);
184 isl::union_set
operator&(isl::set S1, isl::union_set S2);
185 isl::union_set
operator&(isl::union_set S1, isl::union_set S2);
190 isl::set
operator&(isl::set S1, isl::point P2);
191 isl::set
operator&(isl::point P1, isl::set S2);
194 return m1.intersect(m2);
204 return uset.extract_set(dim);
208 return umap.extract_map(dim);
220 const std::function<
void(isl::set)>& fun,
221 isl::union_set uset) {
222 uset.foreach_set(fun);
226 const std::function<
void(isl::map)>& fun,
227 isl::union_map umap) {
228 umap.foreach_map(fun);
231 inline isl::union_set
addElement(isl::union_set uset, isl::set set) {
232 return uset.add_set(set);
235 inline isl::union_map
addElement(isl::union_map umap, isl::map map) {
236 return umap.add_map(map);
240 template <
typename Composite>
242 : std::vector<decltype(
243 detail::extractFromUnion(Composite(), isl::space()))> {
249 [&](
Element e) ->
void { this->push_back(e); }, composite);
252 Composite res((*
this)[0]);
253 for (
int i = 1; i < this->size(); ++i) {
262 return id.get_hash();
269 template <
typename T>
271 auto id = t.get_tuple_id(type);
272 t = t.drop_dims(type, from, length);
273 return t.set_tuple_id(type,
id);
277 template <
typename T>
278 isl::multi_val
makeMultiVal(isl::space s,
const std::vector<T>& vals) {
279 isl::multi_val mv = isl::multi_val::zero(s);
280 CHECK_EQ(vals.size(), s.dim(isl::dim_type::set));
281 for (
size_t i = 0; i < vals.size(); ++i) {
282 mv = mv.set_val(i, isl::val(s.get_ctx(), vals[i]));
293 template <
typename IterPair>
295 isl::space paramSpace,
296 const IterPair begin,
297 const IterPair end) {
298 for (
auto it = begin; it != end; ++it) {
299 paramSpace = paramSpace.add_param(it->first);
301 isl::set res(isl::set::universe(paramSpace));
302 for (
auto it = begin; it != end; ++it) {
303 isl::aff a(isl::aff::param_on_domain_space(paramSpace, it->first));
313 template <
typename T>
316 const std::unordered_map<int, T>& paramValues) {
317 CHECK_GE(space.dim(isl::dim_type::param), paramValues.size());
318 auto lspace = isl::local_space(space);
319 auto set = isl::set::universe(space);
320 for (
auto kvp : paramValues) {
321 auto affParam = isl::aff(lspace, isl::dim_type::param, kvp.first);
327 template <
typename T>
330 const std::unordered_map<std::string, T>& paramValues) {
331 CHECK_GE(space.dim(isl::dim_type::param), paramValues.size());
332 std::unordered_map<int, T> aux;
333 for (
auto kvp : paramValues) {
334 auto pos = space.find_dim_by_name(isl::dim_type::param, kvp.first);
335 CHECK_LE(0, pos) <<
"No " << kvp.first <<
" in: " << space;
336 CHECK_EQ(0, aux.count(pos));
337 aux[pos] = kvp.second;
344 template <
typename T>
347 const std::vector<T>& paramValues) {
348 CHECK_EQ(space.dim(isl::dim_type::param), paramValues.size());
349 std::unordered_map<int, T> paramValuesMap;
350 for (
int i = 0; i < paramValues.size(); ++i) {
351 paramValuesMap[i] = paramValues[i];
359 namespace with_exceptions {
365 isl_ctx_free(c->release());
369 typedef std::unique_ptr<ctx, CtxUPtrDeleter>
CtxUPtr;
isl::aff aff
Definition: islpp.h:170
isl::set operator==(isl::aff_set A, int i)
Definition: islpp-inl.h:155
isl::set operator<=(isl::aff_set A, int i)
Definition: islpp-inl.h:115
UnionAsVector(Composite composite)
Definition: islpp.h:246
isl::set makeParameterContext(isl::space paramSpace, const IterPair begin, const IterPair end)
Definition: islpp.h:294
isl::aff operator+(int i, isl::aff A)
Definition: islpp-inl.h:47
void foreachElement(const std::function< void(isl::set)> &fun, isl::union_set uset)
Definition: islpp.h:219
IslCtxOption
Definition: islpp.h:361
aff_set(isl::aff a)
Definition: islpp.h:138
UnionAsVector()
Definition: islpp.h:245
isl::set makeSpecializationSet(isl::space space, const std::unordered_map< int, T > ¶mValues)
Definition: islpp.h:314
decltype(detail::extractFromUnion(Composite(), isl::space())) Element
Definition: islpp.h:244
Composite asUnion()
Definition: islpp.h:251
size_t operator()(const isl::id &id) const
Definition: islpp.h:261
isl::set operator<(isl::aff_set A, int i)
Definition: islpp-inl.h:135
isl::aff operator-(isl::aff A, int i)
Definition: islpp-inl.h:69
std::unique_ptr< ctx, CtxUPtrDeleter > CtxUPtr
Definition: islpp.h:369
isl::set operator&(isl::set S1, isl::set S2)
Definition: islpp-inl.h:194
isl::ctx globalIslCtx(IslCtxOption options=IslCtxOption::Default)
isl::map operator|(isl::map m1, isl::map m2)
Definition: islpp.h:197
int nElement(isl::union_set uset)
Definition: islpp.h:211
isl::aff aff
Definition: islpp.h:137
isl::set operator>=(isl::aff_set A, isl::val v)
Definition: islpp-inl.h:77
void operator()(ctx *c)
Definition: islpp.h:364
isl::multi_val makeMultiVal(isl::space s, const std::vector< T > &vals)
Definition: islpp.h:278
isl::aff operator/(isl::aff A, int i)
Definition: islpp-inl.h:41
isl::aff operator*(int i, isl::aff A)
Definition: islpp-inl.h:23
isl::set operator>(isl::aff_set A, int i)
Definition: islpp-inl.h:99
aff_map(isl::aff a)
Definition: islpp.h:171
bool operator!=(isl::val v, long i)
Definition: islpp.h:103
isl::set extractFromUnion(isl::union_set uset, isl::space dim)
Definition: islpp.h:203
T dropDimsPreserveTuple(T t, isl::dim_type type, int from, int length)
Definition: islpp.h:270
isl::union_set addElement(isl::union_set uset, isl::set set)
Definition: islpp.h:231