PIPS
debug-util.c
Go to the documentation of this file.
1 /*
2 
3  $Id: debug-util.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /* this is a set of functions to help hpfc debugging
28  *
29  * Fabien Coelho, May 1993.
30  */
31 
32 #include "defines-local.h"
33 #include "pipsdbm.h"
34 #include "workspace-util.h" // for text_common_declaration() which might be better placed in prettyprint.h...
35 #include "prettyprint.h"
36 
37 
39 {
40  (void) fprintf(stderr, "aligned (%zd dimensions)\n",
43  (void) fprintf(stderr, "to template %s\n\n",
45 }
46 
48 {
49  (void) fprintf(stderr,
50  "Alignment: arraydim %"PRIdPTR", templatedim %"PRIdPTR",\n",
53 
54  (void) fprintf(stderr,"rate: ");
56  (void) fprintf(stderr,"\nconstant: ");
58  (void) fprintf(stderr,"\n");
59 }
60 
61 void print_aligns(void)
62 {
63  fprintf(stderr,"Aligns:\n");
64  MAP(ENTITY, a,
65  {
66  (void) fprintf(stderr, "of array %s\n", entity_name(a));
68  (void) fprintf(stderr,"\n");
69  },
71 }
72 
74 {
75  fprintf(stderr,"Distributes:\n");
76 
77  MAP(ENTITY, t,
78  {
79  (void) fprintf(stderr, "of template %s\n", entity_name(t));
81  (void) fprintf(stderr,"\n");
82  },
84 
85 }
86 
88 {
89  (void) fprintf(stderr,"distributed\n");
90 
92 
93  (void) fprintf(stderr, "to processors %s\n\n",
95 }
96 
98 {
99  switch(style_tag(distribution_style(d)))
100  {
101  case is_style_none:
102  (void) fprintf(stderr,"none, ");
103  break;
104  case is_style_block:
105  (void) fprintf(stderr,"BLOCK(");
107  (void) fprintf(stderr,"), ");
108  break;
109  case is_style_cyclic:
110  (void) fprintf(stderr,"CYCLIC(");
112  (void) fprintf(stderr,"), ");
113  break;
114  default:
115  pips_internal_error("unexpected style tag");
116  break;
117  }
118  (void) fprintf(stderr,"\n");
119 }
120 
121 void print_hpf_dir(void)
122 {
123  (void) fprintf(stderr,"HPF directives:\n");
124 
125  print_templates();
126  (void) fprintf(stderr,"--------\n");
128  (void) fprintf(stderr,"--------\n");
130  (void) fprintf(stderr,"--------\n");
131  print_aligns();
132  (void) fprintf(stderr,"--------\n");
134 }
135 
136 void print_templates(void)
137 {
138  (void) fprintf(stderr,"Templates:\n");
140 }
141 
143 {
144  (void) fprintf(stderr,"Processors:\n");
146 }
147 
149 {
150  (void) fprintf(stderr,"Distributed Arrays:\n");
152 }
153 
155  FILE *file,
156  entity module,
157  entity common)
158 {
159  text t;
160  debug_on("PRETTYPRINT_DEBUG_LEVEL");
161 
162  t = text_common_declaration(common, module);
163  print_text(file, t);
164  free_text(t);
165 
166  debug_off();
167 }
168 
170 {
171  string dir_name = db_get_current_workspace_directory();
172 
173  safe_system(concatenate("cat ", dir_name, "/", file_name, " >&2", NULL));
174 }
175 
177  FILE* file,
178  range r)
179 {
180  int lo, up, in;
181  bool
185 
186  if (blo && bup && bin)
187  {
188  if (in==1)
189  if (lo==up)
190  fprintf(file, "%d", lo);
191  else
192  fprintf(file, "%d:%d", lo, up);
193  else
194  fprintf(file, "%d:%d:%d", lo, up, in);
195  }
196  else
197  fprintf(file, "X");
198 }
199 
201  FILE* file,
202  list l)
203 {
204  bool firstrange = true;
205 
206  MAP(RANGE, r,
207  {
208  if (!firstrange)
209  (void) fprintf(file, ", ");
210 
211  firstrange = false;
212  fprint_range(file, r);
213  },
214  l);
215 }
216 
218  FILE* file,
219  message m)
220 {
221  (void) fprintf(file, "message is array %s(",
223  fprint_lrange(file, message_content(m));
224  (void) fprintf(file, ")\nto\n");
226  (void) fprintf(file, "domain is ");
227  fprint_lrange(file, message_dom(m));
228  (void) fprintf(file, "\n");
229 }
230 
232  FILE* file,
233  list l)
234 {
235  if (ENDP(l))
236  fprintf(file, "message list is empty\n");
237  else
238  MAP(MESSAGE, m, fprint_message(file, m), l);
239 }
240 
241 /* that is all
242  */
void free_text(text p)
Definition: text.c:74
bool hpfc_integer_constant_expression_p(expression e, int *pi)
void hpfc_print_file(string file_name)
Definition: debug-util.c:169
void print_processors(void)
Definition: debug-util.c:142
void print_align(align a)
this is a set of functions to help hpfc debugging
Definition: debug-util.c:38
void fprint_message(FILE *file, message m)
Definition: debug-util.c:217
void print_distributes(void)
Definition: debug-util.c:73
void print_distributed_arrays(void)
Definition: debug-util.c:148
void fprint_range(FILE *file, range r)
Definition: debug-util.c:176
void fprint_lrange(FILE *file, list l)
Definition: debug-util.c:200
void print_alignment(alignment a)
Definition: debug-util.c:47
void print_aligns(void)
Definition: debug-util.c:61
void print_templates(void)
Definition: debug-util.c:136
void hpfc_print_common(FILE *file, entity module, entity common)
Definition: debug-util.c:154
void print_distribute(distribute d)
Definition: debug-util.c:87
void print_hpf_dir(void)
Definition: debug-util.c:121
void print_distribution(distribution d)
Definition: debug-util.c:97
void fprint_lmessage(FILE *file, list l)
Definition: debug-util.c:231
text text_common_declaration(entity common, entity module)
needed for hpfc
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
void gen_map(gen_iter_func_t fp, const list l)
Definition: list.c:172
size_t gen_length(const list l)
Definition: list.c:150
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
#define alignment_templatedim(x)
Definition: hpf.h:136
#define distribution_style(x)
Definition: hpf.h:210
#define alignment_constant(x)
Definition: hpf.h:140
#define align_template(x)
Definition: hpf.h:98
#define align_alignment(x)
Definition: hpf.h:96
#define distribute_distribution(x)
Definition: hpf.h:174
#define alignment_rate(x)
Definition: hpf.h:138
#define style_tag(x)
Definition: hpf.h:258
#define alignment_arraydim(x)
Definition: hpf.h:134
#define distribute_processors(x)
Definition: hpf.h:176
#define distribution_parameter(x)
Definition: hpf.h:212
@ is_style_cyclic
Definition: hpf.h:239
@ is_style_block
Definition: hpf.h:238
@ is_style_none
Definition: hpf.h:237
list list_of_processors(void)
list list_of_templates(void)
distribute load_hpf_distribution(entity)
align load_hpf_alignment(entity)
list list_of_distributed_arrays(void)
void vect_fprint(FILE *f, Pvecteur v, get_variable_name_t variable_name)
void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v su...
Definition: io.c:124
char * variable_dump_name(Variable v)
variable_dump_name() returns an unambiguous name for variable v, based on the pointer used to really ...
Definition: variable.c:96
#define message_array(x)
Definition: message.h:75
#define message_dom(x)
Definition: message.h:81
#define MESSAGE(x)
newgen_message_domain_defined
Definition: message.h:43
#define message_neighbour(x)
Definition: message.h:79
#define message_content(x)
Definition: message.h:77
#define debug_on(env)
Definition: misc-local.h:157
#define pips_internal_error
Definition: misc-local.h:149
#define debug_off()
Definition: misc-local.h:160
void safe_system(string)
system.c
Definition: system.c:38
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void(* gen_iter_func_t)(void *)
Definition: newgen_types.h:116
static char * module
Definition: pips.c:74
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
void print_entity_variable(entity e)
print_entity_variable(e)
Definition: entity.c:56
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
Definition: expression.c:58
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
#define range_upper(x)
Definition: ri.h:2290
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define range_increment(x)
Definition: ri.h:2292
#define RANGE(x)
RANGE.
Definition: ri.h:2257
#define entity_name(x)
Definition: ri.h:2790
#define range_lower(x)
Definition: ri.h:2288
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
void print_text(FILE *fd, text t)
Definition: print.c:195
static string file_name