PIPS
sc_io.c File Reference
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <dirent.h>
#include <sys/stat.h>
#include "linear_assert.h"
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
+ Include dependency graph for sc_io.c:

Go to the source code of this file.

Functions

Psystemesc_read (char *nomfic)
 Psysteme * sc_read(char * nomfic): construit un systeme d'inegalites lineaires a partir d'une representation externe standard; les variables utilisees dans le systeme doivent etre declarees dans la premiere ligne; les inegalites sont separees par des virgules et regroupees entre accolades; les egalites sont converties en paires d'inegalites. More...
 
bool sc_fscan (FILE *f, Psysteme *ps)
 bool sc_fscan(FILE * f, Psysteme * ps): construit un systeme d'inegalites et d'egalites lineaires a partir d'une representation externe standard; More...
 
void sc_dump (Psysteme sc)
 void sc_dump(Psysteme sc): dump to stderr More...
 
void sc_default_dump (Psysteme sc)
 void sc_default_dump(Psysteme sc): dump to stderr More...
 
void sc_print (Psysteme ps, get_variable_name_t nom_var)
 void sc_print() More...
 
void sc_fprint (FILE *fp, Psysteme ps, get_variable_name_t nom_var)
 void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier pointe par 'fp' la representation externe d'un systeme lineaire en nombres entiers, compatible avec la fonction de lecture sc_fscan() More...
 
void sc_fprint_for_sc_fscan (FILE *f, Psysteme sc, char *(*nom_var)(Variable))
 void sc_fprint_for_sc_fscan(FILE *f, Psysteme sc, char * (*nom_var)(Variable)) More...
 
void sc_default_dump_to_files (Psysteme sc, int sc_nb, char *directory_name)
 void sc_default_dump_to_files(Psysteme sc, sc_nb,directory_name): More...
 

Variables

Psysteme ps_yacc
 package sc More...
 
bool syst_syntax_error
 detection des erreurs de syntaxe par sc_gram.y More...
 
FILE * syst_in
 fichier lu par sc_lex.l More...
 

Function Documentation

◆ sc_default_dump()

void sc_default_dump ( Psysteme  sc)

void sc_default_dump(Psysteme sc): dump to stderr

sc_default_dump is now compatible with sc_fscan using default_variable_to_string (stored by LINEAR. see sc_debug.c) may fail in very few cases, because of variable names. DN(5/8/2002)

Definition at line 170 of file sc_io.c.

171 {
172  if(!SC_UNDEFINED_P(sc)) {
173  (void) fprintf(stderr,"#DIMENSION: %d ",sc->dimension);
174  (void) fprintf(stderr,"INEGALITES (%d) ",sc_nbre_inegalites(sc));
175  (void) fprintf(stderr,"EGALITES (%d) ",sc_nbre_egalites(sc));
176  (void) fprintf(stderr,"\nVAR ");
178  (void) fprintf(stderr," {\n");
181  (void) fprintf(stderr," }\n");
182  }
183  else
184  (void) fprintf(stderr, "SC_RN ou SC_EMPTY ou SC_UNDEFINED\n");
185 }
void inegalites_fprint(FILE *, Pcontrainte, char *(*)(Variable))
void egalites_fprint(FILE *, Pcontrainte, char *(*)(Variable))
void base_fprint(FILE *f, Pbase b, get_variable_name_t variable_name)
void base_fprint(FILE * f, Pbase b, char * (*variable_name)()): impression d'une base sur le fichier ...
Definition: io.c:342
char * default_variable_to_string(Variable v)
Definition: sc_debug.c:245
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Pcontrainte inegalites
Definition: sc-local.h:71
Pcontrainte egalites
Definition: sc-local.h:70
Pbase base
Definition: sc-local.h:75
int dimension
Definition: sc-local.h:74

References Ssysteme::base, base_fprint(), default_variable_to_string(), Ssysteme::dimension, Ssysteme::egalites, egalites_fprint(), fprintf(), Ssysteme::inegalites, and inegalites_fprint().

Referenced by build_sc_nredund_2pass_ofl_ctrl(), hyperplane(), internal_sc_feasibility(), sc_feasibility_ofl_ctrl(), sc_simplex_feasibility_ofl_ctrl_fixprec(), sc_strong_normalize2(), and sc_strong_normalize_and_check_feasibility2().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_default_dump_to_files()

void sc_default_dump_to_files ( Psysteme  sc,
int  sc_nb,
char *  directory_name 
)

void sc_default_dump_to_files(Psysteme sc, sc_nb,directory_name):

Suitable for filtering purposes Print the system of constraints into several output files in a directory with names given Each file is 100% compatible with sc_fscan print with name of variables from default_variable_to_string overwrite if files exist DN(10/2/2003)

Definition at line 288 of file sc_io.c.

292 {
293  FILE * f;
294  char fn[512], *filename;
295  int d;
296 
297  filename = "_sc.out";
298  if (directory_name==NULL)
299  directory_name = "SC_OUT_DEFAULT";
300  d = chdir(directory_name);
301  if (d) {
302  mkdir(directory_name,S_IRWXU);
303  d = chdir(directory_name);
304  }
305  assert(d == 0);
306 
307  snprintf(fn,sizeof(fn),"%d%s",sc_nb,filename);
308 
309  if ((f = fopen(fn,"w")) != NULL) {
310  if(!SC_UNDEFINED_P(sc)) {
311  (void) fprintf(f,"#DIMENSION (%d) ",sc->dimension);
312  (void) fprintf(f,"INEGALITES (%d) ",sc_nbre_inegalites(sc));
313  (void) fprintf(f,"EGALITES (%d) ",sc_nbre_egalites(sc));
314  (void) fprintf(f,"\nVAR ");
315 
317  (void) fprintf(f," {\n ");
320  (void) fprintf(f," }\n");
321  }
322  else {
323  (void) fprintf(f, "SC_RN ou SC_EMPTY ou SC_UNDEFINED\n");
324  }
325  fclose(f);
326  } else {
327  fprintf(stderr,"Ouverture du fichier %s impossible\n",fn);
328  }
329  if (chdir("..")) // just to avoid a gcc warning
330  fprintf(stderr, "chdir(\"..\") failed\n");
331 }
#define assert(ex)
Definition: newgen_assert.h:41
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15

References assert, base_fprint(), default_variable_to_string(), egalites_fprint(), f(), fprintf(), and inegalites_fprint().

Referenced by internal_sc_feasibility(), sc_fourier_motzkin_feasibility_ofl_ctrl_timeout_ctrl(), sc_janus_feasibility_ofl_ctrl_timeout_ctrl(), and sc_simplexe_feasibility_ofl_ctrl_timeout_ctrl().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_dump()

void sc_dump ( Psysteme  sc)

void sc_dump(Psysteme sc): dump to stderr

Ancien nom: sc_fprint() (modifie a cause d'un conflit avec une autre fonction sc_fprint d'un profil different)

using variable_debug_name(); lost of original variables' names now compatible with sc_fscan() Better use sc_default_name(Psysteme) DN(5/8/2002)

Definition at line 142 of file sc_io.c.

143 {
144  if(!SC_UNDEFINED_P(sc)) {
145 
146  (void) fprintf(stderr,"#DIMENSION: (%d) ",sc->dimension);
147  (void) fprintf(stderr,"INEGALITES (%d) ",sc_nbre_inegalites(sc));
148  (void) fprintf(stderr,"EGALITES (%d) ",sc_nbre_egalites(sc));
149  //(void) fprintf(stderr,"BASE (%p) ", sc->base);
150  //(void) fprintf(stderr,"LISTE INEGALITES (%p) ", sc->inegalites);
151  //(void) fprintf(stderr,"LISTE EGALITES (%p) ", sc->egalites);
152  (void) fprintf(stderr,"\nVAR ");
153  base_fprint(stderr,sc->base, variable_debug_name);
154  (void) fprintf(stderr," {\n");
157  (void) fprintf(stderr," }\n");
158  }
159  else
160  (void) fprintf(stderr, "SC_RN or SC_EMPTY or SC_UNDEFINED\n");
161 }
char *(* variable_debug_name)(Variable)
Debug support: pointer to the function used by debug print outs.
Definition: variable.c:114

References Ssysteme::base, base_fprint(), Ssysteme::dimension, Ssysteme::egalites, egalites_fprint(), fprintf(), Ssysteme::inegalites, inegalites_fprint(), and variable_debug_name.

Referenced by make_bound_expression(), sc_minmax_of_variable2(), transformer_combine(), and unimodular().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_fprint()

void sc_fprint ( FILE *  fp,
Psysteme  ps,
get_variable_name_t  nom_var 
)

void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier pointe par 'fp' la representation externe d'un systeme lineaire en nombres entiers, compatible avec la fonction de lecture sc_fscan()

nom_var est un pointeur vers la fonction permettant d'obtenir le
nom d'une variable (i.e. d'un des vecteurs de base)

FI:

  • le test ne devrait pas etre fait sur NULL;
  • il faudrait toujours faire quelque chose, ne serait-ce qu'imprimer un systeme nul sous la forme {}; et trouver quelque chose pour les systemes infaisables;
  • pourquoi n'utilise-t-on pas inegalites_fprint (et egalites_fprint) pour ne pas reproduire un boucle inutile? Sont-elles compatibles avec la routine de lecture d'un systeme?

DN: better use sc_fprint_for_sc_fscan()

Definition at line 220 of file sc_io.c.

223 {
224  register Pbase b;
225  Pcontrainte peq;
226 
227  if (ps != NULL) {
228  int count = 0;
229  if (ps->dimension >=1) {
230  (void)fprintf(fp,"VAR %s",(*nom_var)(vecteur_var(ps->base)));
231 
232  for (b=ps->base->succ; !VECTEUR_NUL_P(b); b = b->succ)
233  (void)fprintf(fp,", %s",(*nom_var)(vecteur_var(b)));
234  }
235  (void) fprintf(fp," \n { \n");
236 
237  for (peq = ps->inegalites, count=0; peq!=NULL; peq=peq->succ, count++)
238  inegalite_fprint(fp,peq,nom_var);
239 
240  assert(count==ps->nb_ineq);
241 
242  for (peq = ps->egalites, count=0; peq!=NULL; peq=peq->succ, count++)
243  egalite_fprint(fp,peq,nom_var);
244 
245  assert(count==ps->nb_eq);
246 
247  (void) fprintf(fp," } \n");
248  }
249  else
250  (void) fprintf(fp,"(nil)\n");
251 }
static int count
Definition: SDG.c:519
void egalite_fprint(FILE *, Pcontrainte, char *(*)(Variable))
void inegalite_fprint(FILE *, Pcontrainte, char *(*)(Variable))
char * nom_var[100]
Definition: sc_read.c:89
struct Scontrainte * succ
int nb_ineq
Definition: sc-local.h:73
int nb_eq
Definition: sc-local.h:72
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
struct Svecteur * succ
Definition: vecteur-local.h:92
#define vecteur_var(v)
#define VECTEUR_NUL_P(v)

References assert, Ssysteme::base, count, Ssysteme::dimension, egalite_fprint(), Ssysteme::egalites, fprintf(), inegalite_fprint(), Ssysteme::inegalites, Ssysteme::nb_eq, Ssysteme::nb_ineq, nom_var, Scontrainte::succ, Svecteur::succ, VECTEUR_NUL_P, and vecteur_var.

Referenced by add_var_sup(), bound_distribution(), bound_generation(), build_sc_machine(), build_sc_with_several_uniform_ref(), check_range_wrt_precondition(), chose_variable_to_project_for_feasability(), constraint_distribution(), contexts_mapping_of_nest(), cute_convex_union(), dj_system_complement(), eq_in_ineq(), evaluate_var_to_complexity(), expression_less_than_in_context(), find_iteration_domain(), fortran_user_call_to_transformer(), fprint_transformer(), local_tile_constraints(), loop_bounds_to_tile_bounds(), loop_nest_to_wp65_code(), main(), make_context_of_loop(), make_scanning_over_one_tile(), make_scanning_over_tiles(), make_tile_constraints(), movement_computation(), parallel_tiling(), parametric_transformer_empty_p(), plint_pas(), prettyprint_dependence_graph(), prettyprint_dependence_graph_view(), primal(), primal_pivot(), primal_positive(), recompute_loop_transformer(), reg_sc_debug(), sc_elim_redund_with_first_ofl_ctrl(), sc_fm_project_variables(), sc_fourier_motzkin_feasibility_ofl_ctrl(), sc_image_computation(), sc_print(), sc_resol_smith(), sc_supress_parallel_redund_constraints(), sc_supress_same_constraints(), sc_syst_debug(), set_dimensions_of_local_variable_family(), simplify_sc_to_complexity(), smith_int(), test_file(), tile_hyperplane_constraints(), tile_membership(), tile_membership_constraints(), tiling_transformation(), transformer_combine(), transformer_derivative_constraints(), transformer_derivative_fix_point(), transformer_equality_fix_point(), transformer_list_generic_transitive_closure(), transformer_pattern_fix_point(), transformer_projection_with_redundancy_elimination_and_check(), translate_global_values(), un_fprint_tab(), and var_ecart_sup().

+ Here is the call graph for this function:

◆ sc_fprint_for_sc_fscan()

void sc_fprint_for_sc_fscan ( FILE *  f,
Psysteme  sc,
char *(*)(Variable nom_var 
)

void sc_fprint_for_sc_fscan(FILE *f, Psysteme sc, char * (*nom_var)(Variable))

compatible with sc_fscan. Replaced sc_default_dump_to_file (not really in use)

should use default_variable_to_string

Definition at line 260 of file sc_io.c.

261 {
262  if(!SC_UNDEFINED_P(sc)) {
263  (void) fprintf(f,"#DIMENSION (%d) ",sc->dimension);
264  (void) fprintf(f,"INEGALITES (%d) ",sc_nbre_inegalites(sc));
265  (void) fprintf(f,"EGALITES (%d) ",sc_nbre_egalites(sc));
266  (void) fprintf(f,"\nVAR ");
267  base_fprint(f,sc->base, nom_var);
268  (void) fprintf(f," {\n ");
271  (void) fprintf(f," }\n");
272  }
273  else {
274  (void) fprintf(f, "SC_RN ou SC_EMPTY ou SC_UNDEFINED\n");
275  }
276 }

References Ssysteme::base, base_fprint(), Ssysteme::dimension, Ssysteme::egalites, egalites_fprint(), f(), fprintf(), Ssysteme::inegalites, inegalites_fprint(), and nom_var.

+ Here is the call graph for this function:

◆ sc_fscan()

bool sc_fscan ( FILE *  f,
Psysteme ps 
)

bool sc_fscan(FILE * f, Psysteme * ps): construit un systeme d'inegalites et d'egalites lineaires a partir d'une representation externe standard;

Le systeme s est alloue et son ancienne valeur est perdue. Cette fonction devrait donc etre appelee avec la precondition s==NULL. La variable s n'est pas retournee pour respecter la syntaxe habituelle de scanf et pour pouvoir retourner un code.

Si la syntaxe du fichier f est correct, la valeur true est retournee; false sinon.

les variables utilisees dans le systeme doivent etre declarees dans la premiere ligne precedees du mot-cle VAR et separees par des virgules

les inegalites et les egalites sont melangees entre elles, mais separees par des virgules et regroupees entre accolades; les inegalites sont toutes mises sous la forme :

sum a x <= b i i i

ou b est le terme constant; noter que le terme constant est conserve a droite du comparateur et la partie lineaire a gauche

Exemple: VAR x, y, z { x <= 1, y == 2, x + 2 z > y }

Noter l'absence de signe "multiplier" entre les coefficients numeriques et les noms de variables

Cette fonction peut relire un fichier cree par la fonction sc_fprint()

Definition at line 121 of file sc_io.c.

122 {
123  syst_in = f;
124  sc_init_lex();
125  syst_restart(f);
126  syst_parse();
128  *ps = ps_yacc;
129  return !syst_syntax_error;
130 }
void sc_init_lex(void)
int syst_parse(void)
bool syst_syntax_error
detection des erreurs de syntaxe par sc_gram.y
Definition: sc_gram.c:93
FILE * syst_in
fichier lu par sc_lex.l
Psysteme ps_yacc
package sc
Definition: sc_gram.c:95
Psysteme sc_reversal(Psysteme sc)
Psysteme sc_reversal(Psysteme sc)
Definition: sc_read.c:208

References f(), ps_yacc, sc_init_lex(), sc_reversal(), syst_in, syst_parse(), and syst_syntax_error.

Referenced by main(), read_syst_from_file(), and test_file().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_print()

void sc_print ( Psysteme  ps,
get_variable_name_t  nom_var 
)

void sc_print()

Obsolete. Better use sc_default_dump()

Definition at line 194 of file sc_io.c.

195 {
196  sc_fprint(stderr, ps, nom_var);
197 }
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
Definition: sc_io.c:220

References nom_var, and sc_fprint().

Referenced by copy_write_statement_with_cumulated_regions(), new_system_with_only_live_variable(), and regions_transformer_apply().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_read()

Psysteme* sc_read ( char *  nomfic)

Psysteme * sc_read(char * nomfic): construit un systeme d'inegalites lineaires a partir d'une representation externe standard; les variables utilisees dans le systeme doivent etre declarees dans la premiere ligne; les inegalites sont separees par des virgules et regroupees entre accolades; les egalites sont converties en paires d'inegalites.

Exemple: VAR x, y, z { x <= 1, y == 2, x + 2 z > y }

Noter l'absence de signe "multiplier" entre les coefficients numeriques et les noms de variables

Cette fonction relit un fichier cree par la fonction sc_fprint()

Ancien nom: fscsys_uf

Definition at line 74 of file sc_io.c.

75 {
76  if ((syst_in = fopen(nomfic, "r")) == NULL) {
77  (void) fprintf(stderr,
78  "Ouverture du fichier %s impossible\n",nomfic);
79  exit(4);
80  }
81  sc_init_lex();
82  syst_parse();
83  return &ps_yacc;
84 }
#define exit(code)
Definition: misc-local.h:54

References exit, fprintf(), ps_yacc, sc_init_lex(), syst_in, and syst_parse().

+ Here is the call graph for this function:

Variable Documentation

◆ ps_yacc

Psysteme ps_yacc
extern

package sc

Psysteme construit par sc_gram.y

Definition at line 95 of file sc_gram.c.

Referenced by sc_fscan(), and sc_read().

◆ syst_in

FILE* syst_in
extern

fichier lu par sc_lex.l

Referenced by sc_fscan(), and sc_read().

◆ syst_syntax_error

bool syst_syntax_error
extern

detection des erreurs de syntaxe par sc_gram.y

Definition at line 93 of file sc_gram.c.

Referenced by sc_fscan(), and syst_error().