Пример #1
0
isl_set *nfm_constraint_from_set(isl_ctx *ctx,
		nfm_constraint *constraints)
{
	isl_printer *p;

	assert(ctx);
	assert(constraints);

	IF_DEBUG(fprintf(stdout, "  Transforming a constraint into ISL set.\n"));

	p = isl_printer_to_str(ctx);

	p = isl_printer_print_pw_qpolynomial(p, constraints->constraint);
	char *str = isl_printer_get_str(p);
	IF_DEBUG(fprintf(stdout, "  The input Qpolynomianl constraint: %s\n", str));

	assert(str);

	/* Translate the qpolynomial into a map.  */
	char *set_str = (char *) malloc((strlen(str)+10)*sizeof(char));
	strcpy(set_str, str);
	IF_DEBUG2(fprintf(stdout, "  set_str=%s\n", set_str));
	size_t pos_arrow = strcspn(str, ">");
	set_str[pos_arrow-1] = ' ';
	set_str[pos_arrow] = ':';
	IF_DEBUG2(fprintf(stdout, "  set_str=%s\n", set_str));
	size_t pos_colon = strcspn(&(str[pos_arrow+1]), ":");
	if (strchr(&(str[pos_arrow+1]), ':') != NULL)
	{
		set_str[pos_arrow+1+pos_colon] = ' ';
		IF_DEBUG2(fprintf(stdout, "  set_str=%s\n", set_str));

		if (constraints->eq == 1)
			strcpy(&(set_str[pos_arrow+1+pos_colon]), "  = 0 and ");
		else
			strcpy(&(set_str[pos_arrow+1+pos_colon]), " >= 0 and ");

		IF_DEBUG2(fprintf(stdout, "  set_str=%s\n", set_str));
		strncpy(&(set_str[pos_arrow+pos_colon+10]), &(str[pos_arrow+1+pos_colon+1]), strlen(str) - pos_arrow - pos_colon);
		IF_DEBUG2(fprintf(stdout, "  set_str=%s\n", set_str));
	}
	else
	{
		size_t pos_bracket = strcspn(str, "}");
		set_str[pos_bracket] = ' ';
		if (constraints->eq == 1)
			strcat(&(set_str[pos_bracket]), " = 0 }");
		else
			strcat(&(set_str[pos_bracket]), " >= 0 }");
	}

	IF_DEBUG(fprintf(stdout, "  The Qpolynomial translated into a set is: %s\n", set_str));
	isl_set *set = isl_set_read_from_str(ctx, set_str);

	isl_printer_free(p);

	return set;
}
Пример #2
0
void Data::print(std::ostream & out) const {
  out << "[ " << id;
  if (access != NULL) {
    polygraph->printer = isl_printer_print_map(polygraph->printer, access);
    out << " " << isl_printer_get_str(polygraph->printer);
    polygraph->printer = isl_printer_flush(polygraph->printer);
  }
  out << " ]";
}
Пример #3
0
void Data::toDot(std::ostream & out) const {
  std::ostringstream node;
  node << "ptn_" << this;
  if (access != NULL) {
    polygraph->printer = isl_printer_print_map(polygraph->printer, access);
    out << node.str() << " [label=\"" << id << "\\n" << islToMultiline(isl_printer_get_str(polygraph->printer)) << "\"]" << std::endl;
    polygraph->printer = isl_printer_flush(polygraph->printer); 
  }
  else
    out << node.str() << " [label=\"" << id << "\"]" << std::endl;
}
Пример #4
0
/* Write the code that we have accumulated in the kernel isl_printer to the
 * kernel.cl file.  If the opencl_embed_kernel_code option has been set, print
 * the code as a C string literal.  Start that string literal with an empty
 * line, such that line numbers reported by the OpenCL C compiler match those
 * of the kernel file.
 *
 * Return 0 on success and -1 on failure.
 */
static int opencl_write_kernel_file(struct opencl_info *opencl)
{
	char *raw = isl_printer_get_str(opencl->kprinter);

	if (!raw)
		return -1;

	if (opencl->options->opencl_embed_kernel_code) {
		fprintf(opencl->kernel_c,
			"static const char kernel_code[] = \"\\n\"");
		opencl_print_as_c_string(raw, opencl->kernel_c);
		fprintf(opencl->kernel_c, ";\n");
	} else
		fprintf(opencl->kernel_c, "%s", raw);

	free(raw);

	return 0;
}