From a9ca659de7173cda7046e26bfd2a61b0fa0675f7 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 20 Mar 2012 21:58:40 +0100 Subject: [PATCH] move align_range to schedule.c Signed-off-by: Sven Verdoolaege --- cuda.c | 60 ------------------------------------------------------------ schedule.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ schedule.h | 1 + 3 files changed, 61 insertions(+), 60 deletions(-) diff --git a/cuda.c b/cuda.c index 0e9edc9..0552062 100644 --- a/cuda.c +++ b/cuda.c @@ -4267,66 +4267,6 @@ static void list_select_outer_band(struct cuda_gen *gen, free(info); } -/* Set max_out to the maximal number of output dimensions over - * all maps. - */ -static int update_max_out(__isl_take isl_map *map, void *user) -{ - int *max_out = user; - int n_out = isl_map_dim(map, isl_dim_out); - - if (n_out > *max_out) - *max_out = n_out; - - isl_map_free(map); - return 0; -} - -struct align_range_data { - int max_out; - isl_union_map *res; -}; - -/* Extend the dimension of the range of the given map to data->max_out and - * then add the result to data->res. - */ -static int map_align_range(__isl_take isl_map *map, void *user) -{ - struct align_range_data *data = user; - int i; - isl_space *dim; - isl_map *proj; - int n_out = isl_map_dim(map, isl_dim_out); - - dim = isl_union_map_get_space(data->res); - proj = isl_map_reverse(projection(dim, data->max_out, n_out)); - for (i = n_out; i < data->max_out; ++i) - proj = isl_map_fix_si(proj, isl_dim_out, i, 0); - - map = isl_map_apply_range(map, proj); - - data->res = isl_union_map_add_map(data->res, map); - - return 0; -} - -/* Extend the ranges of the maps in the union map such they all have - * the same dimension. - */ -static __isl_give isl_union_map *align_range(__isl_take isl_union_map *umap) -{ - struct align_range_data data; - - data.max_out = 0; - isl_union_map_foreach_map(umap, &update_max_out, &data.max_out); - - data.res = isl_union_map_empty(isl_union_map_get_space(umap)); - isl_union_map_foreach_map(umap, &map_align_range, &data); - - isl_union_map_free(umap); - return data.res; -} - /* Select the outermost tilable band that (by construction) * has at least one parallel loop. * The starting position of the aligned band is stored in the pair diff --git a/schedule.c b/schedule.c index 3e882d3..3d0a2bf 100644 --- a/schedule.c +++ b/schedule.c @@ -133,3 +133,63 @@ __isl_give isl_set *extend(__isl_take isl_set *set, int dst_len) return isl_set_apply(set, map); } + +/* Set max_out to the maximal number of output dimensions over + * all maps. + */ +static int update_max_out(__isl_take isl_map *map, void *user) +{ + int *max_out = user; + int n_out = isl_map_dim(map, isl_dim_out); + + if (n_out > *max_out) + *max_out = n_out; + + isl_map_free(map); + return 0; +} + +struct align_range_data { + int max_out; + isl_union_map *res; +}; + +/* Extend the dimension of the range of the given map to data->max_out and + * then add the result to data->res. + */ +static int map_align_range(__isl_take isl_map *map, void *user) +{ + struct align_range_data *data = user; + int i; + isl_space *dim; + isl_map *proj; + int n_out = isl_map_dim(map, isl_dim_out); + + dim = isl_union_map_get_space(data->res); + proj = isl_map_reverse(projection(dim, data->max_out, n_out)); + for (i = n_out; i < data->max_out; ++i) + proj = isl_map_fix_si(proj, isl_dim_out, i, 0); + + map = isl_map_apply_range(map, proj); + + data->res = isl_union_map_add_map(data->res, map); + + return 0; +} + +/* Extend the ranges of the maps in the union map such they all have + * the same dimension. + */ +__isl_give isl_union_map *align_range(__isl_take isl_union_map *umap) +{ + struct align_range_data data; + + data.max_out = 0; + isl_union_map_foreach_map(umap, &update_max_out, &data.max_out); + + data.res = isl_union_map_empty(isl_union_map_get_space(umap)); + isl_union_map_foreach_map(umap, &map_align_range, &data); + + isl_union_map_free(umap); + return data.res; +} diff --git a/schedule.h b/schedule.h index 9a419c8..aea0153 100644 --- a/schedule.h +++ b/schedule.h @@ -40,5 +40,6 @@ __isl_give isl_map *project_out(__isl_take isl_space *dim, __isl_give isl_map *projection(__isl_take isl_space *dim, int src_len, int dst_len); __isl_give isl_set *extend(__isl_take isl_set *set, int dst_len); +__isl_give isl_union_map *align_range(__isl_take isl_union_map *umap); #endif -- 2.11.4.GIT