/* Print a list of iterators of type "type" with names "ids" to "p". * Each iterator is assigned the corresponding opencl identifier returned * by the function "opencl_id". * Unlike the equivalent function in the CUDA backend which prints iterators * in reverse order to promote coalescing, this function does not print * iterators in reverse order. The OpenCL backend currently does not take * into account any coalescing considerations. */ static __isl_give isl_printer *print_iterators(__isl_take isl_printer *p, const char *type, __isl_keep isl_id_list *ids, const char *opencl_id) { int i, n; n = isl_id_list_n_id(ids); if (n <= 0) return p; p = isl_printer_start_line(p); p = isl_printer_print_str(p, type); p = isl_printer_print_str(p, " "); for (i = 0; i < n; ++i) { isl_id *id; if (i) p = isl_printer_print_str(p, ", "); id = isl_id_list_get_id(ids, i); p = isl_printer_print_id(p, id); isl_id_free(id); p = isl_printer_print_str(p, " = "); p = isl_printer_print_str(p, opencl_id); p = isl_printer_print_str(p, "("); p = isl_printer_print_int(p, i); p = isl_printer_print_str(p, ")"); } p = isl_printer_print_str(p, ";"); p = isl_printer_end_line(p); return p; }
/* Equate the dimensions of "set" starting at "first" to * freshly created parameters with identifiers "ids". * The number of equated dimensions is equal to the number of elements in "ids". */ static __isl_give isl_set *parametrize(__isl_take isl_set *set, int first, __isl_keep isl_id_list *ids) { int i, n; unsigned nparam; nparam = isl_set_dim(set, isl_dim_param); set = add_params(set, ids); n = isl_id_list_n_id(ids); for (i = 0; i < n; ++i) set = isl_set_equate(set, isl_dim_param, nparam + i, isl_dim_set, first + i); return set; }
/* Add parameters with identifiers "ids" to "set". */ static __isl_give isl_set *add_params(__isl_take isl_set *set, __isl_keep isl_id_list *ids) { int i, n; unsigned nparam; n = isl_id_list_n_id(ids); nparam = isl_set_dim(set, isl_dim_param); set = isl_set_add_dims(set, isl_dim_param, n); for (i = 0; i < n; ++i) { isl_id *id; id = isl_id_list_get_id(ids, i); set = isl_set_set_dim_id(set, isl_dim_param, nparam + i, id); } return set; }
/* Print a list of iterators of type "type" with names "ids" to "out". * Each iterator is assigned one of the cuda identifiers in cuda_dims. * In particular, the last iterator is assigned the x identifier * (the first in the list of cuda identifiers). */ static void print_iterators(FILE *out, const char *type, __isl_keep isl_id_list *ids, const char *cuda_dims[]) { int i, n; n = isl_id_list_n_id(ids); if (n <= 0) return; print_indent(out, 4); fprintf(out, "%s ", type); for (i = 0; i < n; ++i) { isl_id *id; if (i) fprintf(out, ", "); id = isl_id_list_get_id(ids, i); fprintf(out, "%s = %s", isl_id_get_name(id), cuda_dims[n - 1 - i]); isl_id_free(id); } fprintf(out, ";\n"); }