PIPS
prettyprint.c
Go to the documentation of this file.
1 /*
2 
3  $Id: prettyprint.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 /*****************************************************************************/
28 /* DG PRINTING FUNCTIONS */
29 /*****************************************************************************/
30 
31 #include "local.h"
32 #include "genC.h"
33 
34 bool print_whole_dependence_graph(const string mod_name)
35 {
36  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITHOUT_PRIVATIZED_DEPS",
37  false);
38  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITHOUT_NOLOOPCARRIED_DEPS",
39  false);
40  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITH_DEPENDENCE_CONES",
41  true);
42  return print_dependence_graph(mod_name);
43 }
44 
45 bool print_filtered_dependence_graph(const string mod_name)
46 {
47  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITH_DEPENDENCE_CONES",
48  true);
49  return print_filtered_dg_or_dvdg(mod_name, false);
50 }
51 
52 bool print_filtered_dependence_daVinci_graph(const string mod_name)
53 {
54  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITH_DEPENDENCE_CONES",
55  true);
56  return print_filtered_dg_or_dvdg(mod_name, true);
57 }
58 
59 bool print_effective_dependence_graph(const string mod_name)
60 {
61  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITHOUT_PRIVATIZED_DEPS",
62  true);
63  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITHOUT_NOLOOPCARRIED_DEPS",
64  false);
65  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITH_DEPENDENCE_CONES",
66  false);
67  return print_dependence_graph(mod_name);
68 }
69 
70 bool print_loop_carried_dependence_graph(const string mod_name)
71 {
72  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITHOUT_PRIVATIZED_DEPS",
73  true);
74  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITHOUT_NOLOOPCARRIED_DEPS",
75  true);
76  set_bool_property("PRINT_DEPENDENCE_GRAPH_WITH_DEPENDENCE_CONES",
77  true);
78  return print_dependence_graph(mod_name);
79 }
80 
81 static bool print_dependence_or_chains_graph(string mod_name, bool with_dg)
82 {
83  string dg_name = NULL;
84  string local_dg_name = NULL;
85  FILE *fp;
86  graph dg;
88 
91  db_get_memory_resource(DBR_CODE, mod_name, true) );
94 
95  /* get the dg or chains... */
97  with_dg? DBR_DG: DBR_CHAINS, mod_name, true);
98 
99  local_dg_name = db_build_file_resource_name(DBR_DG, mod_name, ".dg");
101  "/", local_dg_name, NULL));
102  fp = safe_fopen(dg_name, "w");
103 
104  debug_on("RICEDG_DEBUG_LEVEL");
105 
106  if (get_bool_property("PRINT_DEPENDENCE_GRAPH_WITHOUT_PRIVATIZED_DEPS") ||
107  get_bool_property("PRINT_DEPENDENCE_GRAPH_WITHOUT_NOLOOPCARRIED_DEPS"))
109  else
111 
112  debug_off();
113 
114  safe_fclose(fp, dg_name);
115  free(dg_name);
116 
117  DB_PUT_FILE_RESOURCE(DBR_DG_FILE, strdup(mod_name), local_dg_name);
118 
122 
123  return true;
124 }
125 
126 bool print_dependence_graph(string name)
127 {
128  return print_dependence_or_chains_graph(name, true);
129 }
130 
131 bool print_chains_graph(string name)
132 {
133  return print_dependence_or_chains_graph(name, false);
134 }
135 
136 
137 /** \fn static bool print_dot_dependence_or_chains_graph( string mod_name,
138  * bool with_dg )
139  * \brief Output dependence graph in a file in graphviz dot format
140  * \param mod_name is the name of the module
141  * \param with_dg is a flag indicating if it should use the chains or the dg
142  * \return always true (pipsmake will be happy)
143  */
144 static bool print_dot_dependence_or_chains_graph(string mod_name,
145  bool with_dg )
146 {
147  string dg_name = NULL;
148  string local_dg_name = NULL;
149  FILE *fp;
150  graph dg;
152 
155  mod_name,
156  true ) );
159 
160  // get the dg or chains...
161  dg = (graph) db_get_memory_resource( with_dg ? DBR_DG : DBR_CHAINS,
162  mod_name,
163  true );
164 
165  // Prepare the output file
166  local_dg_name = db_build_file_resource_name( DBR_DG, mod_name, ".dot" );
168  "/",
169  local_dg_name,
170  NULL ) );
171  fp = safe_fopen( dg_name, "w" );
172 
173 
174  debug_on( "RICEDG_DEBUG_LEVEL" );
175 
176  // Print the graph in the file
178 
179  debug_off( );
180 
181  safe_fclose( fp, dg_name );
182  free( dg_name );
183 
184  // FIXME strdup result should be freed,
185  DB_PUT_FILE_RESOURCE( DBR_DOTDG_FILE, strdup( mod_name ), local_dg_name );
186 
190 
191  return true;
192 }
193 
194 /** \fn bool print_dot_chains_graph(string name)
195  * \brief This pipmake pass output the chains in
196  * a file usable by the graphviz tool dot.
197  * \param name is the name of the module, given by pipsmake
198  * \return always true ? see print_dot_dependence_graph
199  */
200 bool print_dot_chains_graph( string name ) {
201  return print_dot_dependence_or_chains_graph( name, false );
202 }
203 
204 /** \fn bool print_dot_dependence_graph(string name)
205  * \brief This pipmake pass output the DG in
206  * a file usable by graphviz tool dot.
207  * \param name is the name of the module, given by pipsmake
208  * \return always true ? see print_dot_dependence_graph
209  */
210 bool print_dot_dependence_graph( string name ) {
211  return print_dot_dependence_or_chains_graph( name, true );
212 }
static graph dg
dg is the dependency graph ; FIXME : should not be static global ?
Definition: chains.c:124
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
void free(void *)
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
Definition: pipsdbm-local.h:85
static statement mod_stat
We want to keep track of the current statement inside the recurse.
Definition: impact_check.c:41
string db_build_file_resource_name(const char *rname, const char *oname, const char *suffix)
returns an allocated file name for a file resource.
Definition: lowlevel.c:169
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
Definition: ordering.c:172
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
Definition: ordering.c:185
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
void set_bool_property(const char *, bool)
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
bool print_chains_graph(string name)
Definition: prettyprint.c:131
static bool print_dot_dependence_or_chains_graph(string mod_name, bool with_dg)
Output dependence graph in a file in graphviz dot format.
Definition: prettyprint.c:144
bool print_dependence_graph(string name)
Definition: prettyprint.c:126
bool print_whole_dependence_graph(const string mod_name)
DG PRINTING FUNCTIONS
Definition: prettyprint.c:34
static bool print_dependence_or_chains_graph(string mod_name, bool with_dg)
Definition: prettyprint.c:81
bool print_loop_carried_dependence_graph(const string mod_name)
Definition: prettyprint.c:70
bool print_dot_chains_graph(string name)
This pipmake pass output the chains in a file usable by the graphviz tool dot.
Definition: prettyprint.c:200
bool print_filtered_dependence_graph(const string mod_name)
Definition: prettyprint.c:45
bool print_filtered_dependence_daVinci_graph(const string mod_name)
Definition: prettyprint.c:52
bool print_dot_dependence_graph(string name)
This pipmake pass output the DG in a file usable by graphviz tool dot.
Definition: prettyprint.c:210
bool print_effective_dependence_graph(const string mod_name)
Definition: prettyprint.c:59
void prettyprint_dependence_graph(FILE *, statement, graph)
Print all edges and arcs.
Definition: util.c:177
bool print_filtered_dg_or_dvdg(string, bool)
Definition: trace.c:202
void prettyprint_dependence_graph_view(FILE *, statement, graph)
Do not print vertices and arcs ignored by the parallelization algorithms.
Definition: util.c:833
void prettyprint_dot_dependence_graph(FILE *, statement, graph)
Output dependence graph in a file in graphviz dot format.
Definition: util.c:583
char * strdup()