Пример #1
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;
}
Пример #2
0
/* Merge pairs of consecutive leaves in "leaves" taking into account
 * the intersection of validity and proximity schedule constraints "dep".
 *
 * If a leaf has been merged with the next leaf, then the combination
 * is checked again for merging with the next leaf.
 * That is, if the leaves are A, B and C, then B may not have been
 * merged with C, but after merging A and B, it could still be useful
 * to merge the combination AB with C.
 *
 * Two leaves A and B are merged if there are instances of at least
 * one pair of statements, one statement in A and one B, such that
 * the validity and proximity schedule constraints between them
 * make them suitable for merging according to check_merge.
 *
 * Return the final number of leaves in the sequence, or -1 on error.
 */
static int merge_leaves(int n, struct ppcg_grouping_leaf leaves[n],
	__isl_keep isl_union_map *dep)
{
	int i;
	struct ppcg_merge_leaves_data data;

	for (i = n - 1; i >= 0; --i) {
		isl_union_map *dep_i;
		isl_stat ok;

		if (i + 1 >= n)
			continue;

		dep_i = isl_union_map_copy(dep);
		dep_i = isl_union_map_intersect_domain(dep_i,
				isl_union_set_copy(leaves[i].domain));
		dep_i = isl_union_map_intersect_range(dep_i,
				isl_union_set_copy(leaves[i + 1].domain));
		data.merge = 0;
		data.src = &leaves[i];
		data.dst = &leaves[i + 1];
		ok = isl_union_map_foreach_map(dep_i, &check_merge, &data);
		isl_union_map_free(dep_i);
		if (ok < 0 && !data.merge)
			return -1;
		if (!data.merge)
			continue;
		if (merge_pair(n, leaves, i) < 0)
			return -1;
		--n;
		++i;
	}

	return n;
}
Пример #3
0
/*
 * Output schedules are isl relations that have dims in the order
 * isl_dim_out, isl_dim_in, div, param, const
 */
__isl_give isl_union_map *pluto_schedule(isl_union_set *domains, 
        isl_union_map *dependences, 
        PlutoOptions *options_l)
{
    int i, j, nbands, n_ibands, retval;
    isl_ctx *ctx;
    isl_space *space;

    ctx = isl_union_set_get_ctx(domains);
    space = isl_union_set_get_space(domains);

    // isl_union_set_dump(domains);
    // isl_union_map_dump(dependences);

    options = options_l;

    PlutoProg *prog = pluto_prog_alloc();

    prog->nvar = -1;
    prog->nstmts = isl_union_set_n_set(domains);

    if (prog->nstmts >= 1) {
        prog->stmts = (Stmt **)malloc(prog->nstmts * sizeof(Stmt *));
    }else{
        prog->stmts = NULL;
    }

    for (i=0; i<prog->nstmts; i++) {
        prog->stmts[i] = NULL;
    }

    extract_stmts(domains, prog->stmts);

    for (i=0; i<prog->nstmts; i++) {
        prog->nvar = PLMAX(prog->nvar, prog->stmts[i]->dim);
    }

    if (prog->nstmts >= 1) {
        Stmt *stmt = prog->stmts[0];
        prog->npar = stmt->domain->ncols - stmt->dim - 1;
        prog->params = (char **) malloc(sizeof(char *)*prog->npar);
    }else prog->npar = 0;

    for (i=0; i<prog->npar; i++) {
        prog->params[i] = NULL;
    }

    prog->ndeps = 0;
    isl_union_map_foreach_map(dependences, &isl_map_count, &prog->ndeps);

    prog->deps = (Dep **)malloc(prog->ndeps * sizeof(Dep *));
    for (i=0; i<prog->ndeps; i++) {
        prog->deps[i] = pluto_dep_alloc();
    }
    extract_deps(prog->deps, 0, prog->stmts,
            dependences, OSL_DEPENDENCE_RAW);

    IF_DEBUG(pluto_prog_print(prog););
Пример #4
0
/* Call isl_map_move_dims with the given arguments on each of the maps
 * in "umap" and return the union of the results.
 *
 * This function can only meaningfully be called on a union map
 * where all maps have the same space for both dst_type and src_type.
 * One of these should then be isl_dim_param as otherwise the union map
 * could only contain a single map.
 */
__isl_give isl_union_map *pet_union_map_move_dims(
	__isl_take isl_union_map *umap,
	enum isl_dim_type dst_type, unsigned dst_pos,
	enum isl_dim_type src_type, unsigned src_pos, unsigned n)
{
	isl_space *space;
	struct pet_union_map_move_dims_data data =
		{ dst_type, dst_pos, src_type, src_pos, n };

	space = isl_union_map_get_space(umap);
	if (src_type == isl_dim_param)
		space = isl_space_drop_dims(space, src_type, src_pos, n);
	data.res = isl_union_map_empty(space);
	if (isl_union_map_foreach_map(umap, &map_move_dims, &data) < 0)
		data.res = isl_union_map_free(data.res);

	isl_union_map_free(umap);
	return data.res;
}