Beispiel #1
0
/**
 * @brief Aggregate two osl_generic together (cloning the necessary structures).
 * The parameters are not modified. If two generics are found, only one is kept (like a union).
 *
 * @param gen1 A pointer to the first osl_generic.
 * @param gen2 A pointer to the first osl_generic.
 *
 * @return The aggregation of two osl_generic.
 */
struct osl_generic * substrate_osl_generic_fusion(
        struct osl_generic * gen1,
        struct osl_generic * gen2)
{
    struct osl_generic * res = NULL, *tmp1 = NULL, *tmp2 = NULL;
    struct osl_generic * new_generic = NULL;

    tmp1 = gen1;
    while(tmp1 != NULL)
    {
        tmp2 = substrate_osl_generic_lookup(gen2, tmp1->interface->URI);
        if(tmp2 == NULL)
        {
            osl_generic_add(&res, substrate_osl_generic_nclone(tmp1,1));
        }
        else if(osl_generic_equal(tmp1, tmp2))
        {
            if(strcmp(tmp1->interface->URI,"body") == 0)
            {
                new_generic = osl_generic_malloc();
                new_generic->interface = osl_body_interface();
                new_generic->next = NULL;
                new_generic->data = substrate_osl_body_fusion(tmp1->data,tmp2->data);

                osl_generic_add(&res, new_generic);
            }
            else
            {
                osl_generic_add(&res, substrate_osl_generic_nclone(tmp1,1));
            }
        }
        else
        {
            if(strcmp(tmp1->interface->URI,"body") == 0)
            {
                new_generic = osl_generic_malloc();
                new_generic->interface = osl_body_interface();
                new_generic->next = NULL;
                new_generic->data = substrate_osl_body_fusion(tmp1->data,tmp2->data);

                osl_generic_add(&res, new_generic);
            }
            else
            {
                OSL_warning("Can't fusion the generic structures : don't know how.");
                fprintf(stderr,"URI : %s\n", tmp1->interface->URI);
            }
        }
        tmp1 = tmp1->next;
    }

    return res;
}
Beispiel #2
0
Datei: scop.c Projekt: imenf/clan
/**
 * clan_scop_generate_scatnames function:
 * this function generates a scatnames extension for the scop passed as
 * an argument. Since Clan use a "2d+1" scattering strategy, the
 * scattering dimension names are generated by reusing the original
 * iterator names of the deepest statement and by inserting between those
 * names some beta vector elements (the Xth beta element is called bX).
 * \param[in,out] scop The scop to add a scatnames extension to.
 */
void clan_scop_generate_scatnames(osl_scop_p scop) {
  osl_statement_p current, deepest;
  osl_scatnames_p scatnames;
  osl_strings_p iterators = NULL;
  osl_strings_p names = NULL;
  osl_generic_p extension;
  osl_body_p body = NULL;
  char buffer[CLAN_MAX_STRING];
  int max_depth = -1;
  int i;

  // Find the deepest statement to reuse its original iterators.
  current = scop->statement;
  while (current != NULL) {
    if (current->domain->nb_output_dims > max_depth) {
      max_depth = current->domain->nb_output_dims;
      deepest = current;
      body = (osl_body_p)osl_generic_lookup(deepest->extension, OSL_URI_BODY);
      if (body)
        iterators = body->iterators;
    }
    current = current->next;
  }

  // It there are no scattering dimension, do nothing.
  if (max_depth <= 0)
    return;

  // Create the NULL-terminated list of scattering dimension names.
  names = osl_strings_malloc();
  for (i = 0; i < max_depth; i++) {
    sprintf(buffer, "b%d", i);
    osl_strings_add(names, buffer);
    osl_strings_add(names, iterators->string[i]);
  }
  sprintf(buffer, "b%d", max_depth);
  osl_strings_add(names, buffer);

  // Build the scatnames extension.
  scatnames = osl_scatnames_malloc();
  scatnames->names = names;

  // Build the generic extension and insert it to the extension list.
  extension = osl_generic_malloc();
  extension->interface = osl_scatnames_interface();
  extension->data = scatnames;
  osl_generic_add(&scop->extension, extension);
}
Beispiel #3
0
Datei: scop.c Projekt: imenf/clan
/**
 * clan_scop_generate_clay function:
 * this function generates a clay extension for the scop passed as
 * an argument.
 * \param[in,out] scop   The scop to add a clay extension to.
 * \param[in]     script The clay script.
 */
void clan_scop_generate_clay(osl_scop_p scop, char* script) {
  osl_clay_p clay;
  osl_generic_p extension;

  if ((script != NULL) && (strlen(script) > 0)) {
    // Build the clay extension
    clay = osl_clay_malloc();
    CLAN_strdup(clay->script, script);

    // Build the generic extension and insert it to the extension list.
    extension = osl_generic_malloc();
    extension->interface = osl_clay_interface();
    extension->data = clay;
    osl_generic_add(&scop->extension, extension);
  }
}
Beispiel #4
0
Datei: scop.c Projekt: imenf/clan
/**
 * clan_scop_generate_coordinates function:
 * this function generates a coordinates extension for the scop passed as
 * an argument.
 * \param[in]     name The name of the SCoP original file.
 * \param[in,out] scop The scop to add a scatnames extension to.
 */
void clan_scop_generate_coordinates(osl_scop_p scop, char* name) {
  osl_coordinates_p coordinates;
  osl_generic_p extension;

  // Build the coordinates extension
  coordinates = osl_coordinates_malloc();
  CLAN_strdup(coordinates->name, name);
  coordinates->line_start   = scanner_scop_start + 1;
  coordinates->line_end     = scanner_scop_end;
  coordinates->column_start = 0;
  coordinates->column_end   = 0;
  coordinates->indent = (parser_indent != CLAN_UNDEFINED) ? parser_indent : 0;

  // Build the generic extension and insert it to the extension list.
  extension = osl_generic_malloc();
  extension->interface = osl_coordinates_interface();
  extension->data = coordinates;
  osl_generic_add(&scop->extension, extension);
}