Example #1
0
isl_ast_build * ast_gen::set_loop_iterators(isl_ast_build * ast, int count, int parallel_loop)
{
    auto ctx = isl_ast_build_get_ctx(ast);

    isl_id_list * ids = isl_id_list_alloc(ctx, count);

    for(int i = 0; i < count; ++i)
    {
        auto name = string("c") + to_string(i);

        if (verbose<ast_gen>::enabled())
            cout << "Adding iterator: " << name << endl;

        void * data = nullptr;
        if (i == parallel_loop)
        {
            if (verbose<ast_gen>::enabled())
                cout << "(parallel)" << endl;
            data = &m_parallel_loop_id;
        }

        auto id = isl_id_alloc(ctx, name.c_str(), data);

        ids = isl_id_list_add(ids, id);
    }

    ast = isl_ast_build_set_iterators(ast, ids);

    return ast;
}
Example #2
0
/* Construct a unique identifier for a group in "grouping".
 *
 * The name is of the form G_n, with n the first value starting at
 * grouping->group_id that does not result in an identifier
 * that is already in use in the domain of the original schedule
 * constraints.
 */
static isl_id *construct_group_id(struct ppcg_grouping *grouping,
	__isl_take isl_space *space)
{
	isl_ctx *ctx;
	isl_id *id;
	isl_bool empty;
	isl_union_set *domain;

	if (!space)
		return NULL;

	ctx = isl_space_get_ctx(space);
	domain = isl_schedule_constraints_get_domain(grouping->sc);

	do {
		char buffer[20];
		isl_id *id;
		isl_set *set;

		snprintf(buffer, sizeof(buffer), "G_%d", grouping->group_id);
		grouping->group_id++;
		id = isl_id_alloc(ctx, buffer, NULL);
		space = isl_space_set_tuple_id(space, isl_dim_set, id);
		set = isl_union_set_extract_set(domain, isl_space_copy(space));
		empty = isl_set_plain_is_empty(set);
		isl_set_free(set);
	} while (empty >= 0 && !empty);

	if (empty < 0)
		space = isl_space_free(space);

	id = isl_space_get_tuple_id(space, isl_dim_set);

	isl_space_free(space);
	isl_union_set_free(domain);

	return id;
}