/** * Read a matrix in PolyLib format from input. */ CloogMatrix *cloog_matrix_read_of_size(FILE *input, unsigned n_row, unsigned n_col) { CloogMatrix *M; unsigned int i, j; char line[1024]; char val[1024]; char *p; M = cloog_matrix_alloc(n_row, n_col); if (!M) cloog_die("memory overflow.\n"); for (i = 0; i < n_row; ++i) { int offset; int n; p = next_line(input, line, sizeof(line)); if (!p) cloog_die("Input error.\n"); for (j = 0; j < n_col; ++j) { n = sscanf(p, "%s%n", val, &offset); if (!n) cloog_die("Input error.\n"); cloog_int_read(M->p[i][j], val); p += offset; } } return M; }
static CloogUnionDomain *cloog_union_domain_set_name_nodup(CloogUnionDomain *ud, enum cloog_dim_type type, int index, const char *name) { int i; if (!ud) return ud; if (type != CLOOG_PARAM && type != CLOOG_ITER && type != CLOOG_SCAT) cloog_die("invalid dim type\n"); if (index < 0 || index >= ud->n_name[type]) cloog_die("index out of range\n"); if (!ud->name[type]) { ud->name[type] = XMALLOC(char *, ud->n_name[type]); if (!ud->name[type]) cloog_die("memory overflow.\n"); for (i = 0; i < ud->n_name[type]; ++i) ud->name[type][i] = NULL; }
CloogMatrix *cloog_matrix_read(FILE *input) { unsigned n_row, n_col; char line[1024]; if (!next_line(input, line, sizeof(line))) cloog_die("Input error.\n"); if (sscanf(line, "%u %u", &n_row, &n_col) != 2) cloog_die("Input error.\n"); return cloog_matrix_read_of_size(input, n_row, n_col); }
/** * cloog_block_list_malloc function: * This function allocates the memory space for a CloogBlockList structure and * sets its fields with default values. Then it returns a pointer to the * allocated space. * - November 21th 2005: first version. */ CloogBlockList * cloog_block_list_malloc() { CloogBlockList * blocklist ; /* Memory allocation for the CloogBlock structure. */ blocklist = (CloogBlockList *)malloc(sizeof(CloogBlockList)) ; if (blocklist == NULL) cloog_die("memory overflow.\n"); /* We set the various fields with default values. */ blocklist->block = NULL ; blocklist->next = NULL ; return blocklist ; }
/** * cloog_block_malloc function: * This function allocates the memory space for a CloogBlock structure and * sets its fields with default values. Then it returns a pointer to the * allocated space. * - November 21th 2005: first version. */ CloogBlock *cloog_block_malloc(CloogState *state) { CloogBlock * block ; /* Memory allocation for the CloogBlock structure. */ block = (CloogBlock *)malloc(sizeof(CloogBlock)) ; if (block == NULL) cloog_die("memory overflow.\n"); cloog_block_leak_up(state); /* We set the various fields with default values. */ block->state = state; block->statement = NULL ; block->nb_scaldims = 0 ; block->scaldims = NULL ; block->depth = 0 ; block->references = 1 ; block->usr = NULL; return block ; }
/** * cloog_names_malloc function: * This function allocates the memory space for a CloogNames structure and * sets its fields with default values. Then it returns a pointer to the * allocated space. * - November 21th 2005: first version. */ CloogNames * cloog_names_malloc() { CloogNames * names ; /* Memory allocation for the CloogNames structure. */ names = (CloogNames *)malloc(sizeof(CloogNames)) ; if (names == NULL) cloog_die("memory overflow.\n"); /* We set the various fields with default values. */ names->nb_scalars = 0 ; names->nb_scattering = 0 ; names->nb_iterators = 0 ; names->nb_parameters = 0 ; names->scalars = NULL ; names->scattering = NULL ; names->iterators = NULL ; names->parameters = NULL ; names->references = 1; return names ; }