PIPS
manage_pragma.c File Reference

This file holds transformations on OpenMP pragmas store in the RI as extension expression. More...

#include "genC.h"
#include "linear.h"
#include "misc.h"
#include "pipsdbm.h"
#include "properties.h"
#include "ri.h"
#include "ri-util.h"
#include "text-util.h"
#include "prettyprint.h"
#include "control.h"
#include "accel-util.h"
#include "callgraph.h"
#include "effects-generic.h"
#include "semantics.h"
#include "effects-convex.h"
+ Include dependency graph for manage_pragma.c:

Go to the source code of this file.

Data Structures

struct  context
 

Macros

#define statement_has_this_pragma_string_p(stmt, str)    (get_extension_from_statement_with_pragma(stmt,str)!=NULL)
 

Functions

bool statement_has_omp_parallel_directive_p (statement s)
 manage_pragma.c More...
 
bool pragma_omp_p (pragma p)
 Check that a pragma is an "omp" one. More...
 
static void build_omp_pragma_list (extensions exts, list *l_pragma)
 Callback for gen_recurse that build a list of OpenMP pragma to be merged. More...
 
static bool inner_filter (loop l, bool *inner_flag)
 
static void inner_rewrite (loop l, bool *inner_flag)
 
static bool build_outer (loop l, list *l_outer)
 
static void merge_on_outer (list l_outer)
 merge the omp pragma on the most outer parallel loop More...
 
static void build_iteration_list (range r, list *l_iters)
 
static void add_loop_parallel_threshold (pragma pr)
 add a if condition to the omp pragma More...
 
bool omp_merge_pragma (const char *module_name)
 merge the pragma on the outer loop More...
 
bool omp_loop_parallel_threshold_set (const char *module_name)
 
void clear_pragma_on_statement (statement s)
 Remove all pragma attached to a given statement. More...
 
bool clear_pragma (const char *module_name)
 Clear all pragma This should be done on any input with unhandled pragma, we don't what semantic we might break... More...
 
bool outline_stmts_between_pragmas_in_sequence (sequence s, void *_ctx)
 
bool pragma_outliner (char *module_name)
 

Detailed Description

This file holds transformations on OpenMP pragmas store in the RI as extension expression.

Here is the list of transformations: 1- add an OpenMP if clause 2- Merge nested OpenMP clause

Definition in file manage_pragma.c.

Macro Definition Documentation

◆ statement_has_this_pragma_string_p

#define statement_has_this_pragma_string_p (   stmt,
  str 
)     (get_extension_from_statement_with_pragma(stmt,str)!=NULL)

Definition at line 439 of file manage_pragma.c.

Function Documentation

◆ add_loop_parallel_threshold()

static void add_loop_parallel_threshold ( pragma  pr)
static

add a if condition to the omp pragma

Returns
void
Parameters
pr,thepragma to process

Definition at line 249 of file manage_pragma.c.

249  {
250 
251  // FI: untested code
252  //entity m = module_name_to_entity(db_get_current_module_name());
253  //language pl = module_language(m);
255 
256  // only the pragma as expressions are managed
257  if(pragma_expression_p (pr) == true) {
258  // we need to get the loop index
261  if(instruction_loop_p(inst)) {
262  // The list of number of iteration (as expression) to be used in the if clause
263  list l_iters = NIL;
264  loop l = instruction_loop (inst);
265  // evaluate the number of iteration according to the property value
266  if(get_bool_property("OMP_IF_CLAUSE_RECURSIVE") == true) {
267  // collect the number of iteration of current loop and inner loops
268  gen_context_recurse(stmt, &l_iters,
270  } else {
271  // get the number of iteration of the current loop only
273  l_iters = gen_expression_cons(iter, l_iters);
274  }
275  // now we have a list of number of iteration we need to multiply them
277  expression cond = expressions_to_operation(l_iters, mul);
278  // compare the nb iteration to the threshold
279  cond = pragma_build_if_condition(cond, pl);
280  // encapsulate the condition into the if clause
281  expression expr_if = pragma_if_as_expr(cond);
282  // bind the clause to the pragma
283  add_expr_to_pragma_expr_list(pr, expr_if);
284  // free list
285  gen_free_list(l_iters);
286  }
287  }
288  return;
289 }
list gen_expression_cons(expression p, list l)
Definition: ri.c:866
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
gen_chunk * gen_get_ancestor(int, const void *)
return the first ancestor object found of the given type.
Definition: genClib.c:3560
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
language get_prettyprint_language()
please avoid using this function directly, use predicate instead (see below)
Definition: language.c:57
static void build_iteration_list(range r, list *l_iters)
void add_expr_to_pragma_expr_list(pragma pr, expression ex)
Add an expression to the pragma current expression list.
Definition: pragma.c:147
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
@ range_to_nbiter
#define MULTIPLY_OPERATOR_NAME
entity CreateIntrinsic(string name)
this function does not create an intrinsic function because they must all be created beforehand by th...
Definition: entity.c:1311
expression range_to_expression(range r, enum range_to_expression_mode mode)
computes the distance between the lower bound and the upper bound of the range
Definition: eval.c:963
expression expressions_to_operation(const list l_exprs, entity op)
take a list of expression and apply a binary operator between all of them and return it as an express...
Definition: expression.c:3544
expression pragma_if_as_expr(expression arg)
Definition: pragma.c:184
expression pragma_build_if_condition(expression cond, language l)
build the expression to be put in the if clause.
Definition: pragma.c:159
#define pragma_expression_p(x)
Definition: ri.h:2034
#define instruction_loop_p(x)
Definition: ri.h:1518
#define instruction_loop(x)
Definition: ri.h:1520
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define range_domain
newgen_ram_domain_defined
Definition: ri.h:330
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: statement.c:54

References add_expr_to_pragma_expr_list(), build_iteration_list(), CreateIntrinsic(), expressions_to_operation(), gen_context_recurse, gen_expression_cons(), gen_free_list(), gen_get_ancestor(), gen_true2(), get_bool_property(), get_prettyprint_language(), instruction_loop, instruction_loop_p, loop_range, MULTIPLY_OPERATOR_NAME, NIL, pl, pragma_build_if_condition(), pragma_expression_p, pragma_if_as_expr(), range_domain, range_to_expression(), range_to_nbiter, statement_domain, and statement_instruction.

Referenced by omp_loop_parallel_threshold_set().

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

◆ build_iteration_list()

static void build_iteration_list ( range  r,
list l_iters 
)
static

Definition at line 241 of file manage_pragma.c.

241  {
243  *l_iters = gen_expression_cons(iter, *l_iters);
244 }

References gen_expression_cons(), range_to_expression(), and range_to_nbiter.

Referenced by add_loop_parallel_threshold().

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

◆ build_omp_pragma_list()

static void build_omp_pragma_list ( extensions  exts,
list l_pragma 
)
static

Callback for gen_recurse that build a list of OpenMP pragma to be merged.

Also remove them from the list they currently belongs to. It'll ignore string pragma (at that time, all that aren't generated by PIPS). A pragma that begin with "omp" in the original code will lead to a warning It'll ignore all pragma that are not begining with "omp".

Definition at line 108 of file manage_pragma.c.

108  {
109  list tmp = NIL;
110  list l_exts = extensions_extension (exts);
111  FOREACH(EXTENSION, ext, l_exts) {
112  // today extension is only pragma but can be something else in the future
113  // a test will have to be done
114  // if (extension_is_pragma_p ())
115  pragma p = extension_pragma (ext);
116  if(pragma_omp_p(p)) {
117  if(!pragma_expression_p(p)) {
118  pips_user_warning("We have an omp string pragma, we don't know yet to "
119  "parse it and thus it'll be ignored.\n");
120  } else {
121  // We record it so that we'll remove it from current stmt list later
122  tmp = gen_extension_cons(ext, tmp);
123  // Record in global list
124  *l_pragma = gen_pragma_cons(p, *l_pragma);
125  pips_debug(5, "adding pragma : %s for merging\n", pragma_to_string (p));
126  }
127  } else {
128  pips_debug(5,
129  "Ignore pragma : %s, it's not an openmp one !\n",
130  pragma_to_string (p));
131  }
132  }
133  // remove the extensions that will be merger at outer level
134  gen_list_and_not(&l_exts, tmp);
135  // update the extensions field
136  extensions_extension (exts) = l_exts;
137 }
list gen_pragma_cons(pragma p, list l)
Definition: ri.c:1745
list gen_extension_cons(extension p, list l)
Definition: ri.c:908
void gen_list_and_not(list *a, const list b)
Compute A = A inter non B:
Definition: list.c:963
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
bool pragma_omp_p(pragma p)
Check that a pragma is an "omp" one.
Definition: manage_pragma.c:78
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_user_warning
Definition: misc-local.h:146
string pragma_to_string(pragma p)
Definition: pragma.c:69
#define extension_pragma(x)
Definition: ri.h:1295
#define EXTENSION(x)
EXTENSION.
Definition: ri.h:1253
#define extensions_extension(x)
Definition: ri.h:1330

References EXTENSION, extension_pragma, extensions_extension, FOREACH, gen_extension_cons(), gen_list_and_not(), gen_pragma_cons(), NIL, pips_debug, pips_user_warning, pragma_expression_p, pragma_omp_p(), and pragma_to_string().

Referenced by merge_on_outer().

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

◆ build_outer()

static bool build_outer ( loop  l,
list l_outer 
)
static

Definition at line 183 of file manage_pragma.c.

183  {
186 
187  FOREACH(EXTENSION, ext, l_exts) {
188  // today extension is only pragma but can be something else in the future
189  // a test will have to be done
190  // if (extension_is_pragma_p ())
191  pragma pr = extension_pragma (ext);
192  pips_debug(5, "processing pragma : %s\n", pragma_to_string (pr));
193  // only the pragma as expressions are managed
194  if(pragma_expression_p (pr) == true) {
195  *l_outer = gen_statement_cons(stmt, *l_outer);
196  pips_debug(5, "outer pragma as expression found\n");
197  return false;
198  }
199  }
200  return true;
201 }
list gen_statement_cons(statement p, list l)
Definition: ri.c:2202
#define statement_extensions(x)
Definition: ri.h:2464

References EXTENSION, extension_pragma, extensions_extension, FOREACH, gen_get_ancestor(), gen_statement_cons(), pips_debug, pragma_expression_p, pragma_to_string(), statement_domain, and statement_extensions.

Referenced by omp_merge_pragma().

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

◆ clear_pragma()

bool clear_pragma ( const char *  module_name)

Clear all pragma This should be done on any input with unhandled pragma, we don't what semantic we might break...

Put the new CODE ressource into PIPS:

Parameters
module_nameodule_name

Definition at line 403 of file manage_pragma.c.

403  {
404  debug_on("CLEAR_PRAGMA_DEBUG_LEVEL");
405  statement mod_stmt = statement_undefined;
406  // Get the code and tell PIPS_DBM we do want to modify it
407  mod_stmt = (statement) db_get_memory_resource(DBR_CODE, module_name, true);
408 
409  // Set the current module entity and the current module statement that are
410  // required to have many things working in PIPS
413 
414  // Add the parallel threshold to all the omp for pragmas
416 
417  /* Put the new CODE ressource into PIPS: */
418  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, mod_stmt);
419 
420  // There is no longer a current module:
423 
424  pips_debug(2, "done for %s\n", module_name);
425  debug_off();
426 
427  return true;
428 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
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
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
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_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
void clear_pragma_on_statement(statement s)
Remove all pragma attached to a given statement.
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
#define statement_undefined
Definition: ri.h:2419

References clear_pragma_on_statement(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_recurse, gen_true(), module_name(), module_name_to_entity(), pips_debug, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), statement_domain, and statement_undefined.

+ Here is the call graph for this function:

◆ clear_pragma_on_statement()

void clear_pragma_on_statement ( statement  s)

Remove all pragma attached to a given statement.

Definition at line 388 of file manage_pragma.c.

388  {
390  list keep_exs = NIL;
391  FOREACH(EXTENSION, ex, exs) {
392  if(!extension_pragma_p(ex))
393  keep_exs = CONS(EXTENSION,ex,keep_exs);
394  }
396  gen_free_list(exs);
397 }
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define extension_pragma_p(x)
Definition: ri.h:1293

References CONS, EXTENSION, extension_pragma_p, extensions_extension, FOREACH, gen_free_list(), NIL, and statement_extensions.

Referenced by clear_pragma(), is_SCOP_rich(), and outline_stmts_between_pragmas_in_sequence().

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

◆ inner_filter()

static bool inner_filter ( loop  l,
bool inner_flag 
)
static

Definition at line 141 of file manage_pragma.c.

141  {
142  pips_debug(5, "processing loop : %p.\n", (void*) l);
143  *inner_flag = true;
144  return true;
145 }

References pips_debug.

Referenced by omp_merge_pragma().

+ Here is the caller graph for this function:

◆ inner_rewrite()

static void inner_rewrite ( loop  l,
bool inner_flag 
)
static

Definition at line 149 of file manage_pragma.c.

149  {
152  list l_exts = extensions_extension (exts);
153  list tmp = NIL;
154 
155  FOREACH(EXTENSION, ext, l_exts) {
156  // today extension is only pragma but can be something else in the future
157  // a test will have to be done
158  // if (extension_is_pragma_p ())
159  if(*inner_flag == true) {
160  // this is the inner pragma we have to keep it so set the flag to false
161  // to remove next extensions and exit
162  pips_debug(5,
163  "keeping pragma : %s from extensions %p.\n",
164  pragma_to_string (extension_pragma (ext)), (void*) exts);
165  *inner_flag = false;
166  return;
167  } else {
168  // we need to remove that extension because it is not an inner one
169  tmp = gen_extension_cons(ext, tmp);
170  pips_debug(5,
171  "removing pragma : %s from extensions %p.\n",
172  pragma_to_string (extension_pragma (ext)), (void*) exts);
173  }
174  //}
175  }
176  gen_list_and_not(&l_exts, tmp);
177  // update the extensions field
178  extensions_extension (exts) = l_exts;
179  return;
180 }

References EXTENSION, extension_pragma, extensions_extension, FOREACH, gen_extension_cons(), gen_get_ancestor(), gen_list_and_not(), NIL, pips_debug, pragma_to_string(), statement_domain, and statement_extensions.

Referenced by omp_merge_pragma().

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

◆ merge_on_outer()

static void merge_on_outer ( list  l_outer)
static

merge the omp pragma on the most outer parallel loop

Returns
void

Definition at line 205 of file manage_pragma.c.

205  {
206 
207  // FI: untested code
208  //entity m = module_name_to_entity(db_get_current_module_name());
209  //language l = module_language(m);
211 
212  FOREACH(STATEMENT, stmt, l_outer) {
213  // The list of pragma to be merged
214  list l_pragma = NIL;
215  list outer_extensions =
217  // collect the pragma and detach them from their statement
218  gen_context_recurse(stmt, &l_pragma,
220  list l_expr = pragma_omp_merge_expr(outer_extensions, l_pragma, l);
221  gen_free_list(outer_extensions);
222 
223  // We have to removed locally declared variables from the pragma clause,
224  // else generated code won't compile !
225  list locally_decls = statement_to_declarations(stmt);
226  ifdebug(4) {
227  pips_debug(4, "Filter out local variables from pragma : ");
228  print_entities(locally_decls);
229  fprintf(stderr, "\n");
230  }
231  l_expr = filter_variables_in_pragma_expr(l_expr, locally_decls);
232  gen_free_list(locally_decls);
233 
234  // The pragma can now be added to the statement
236  gen_free_list(l_pragma);
237  }
238  return;
239 }
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
list statement_to_declarations(void *)
Get a list of all variables declared recursively within a statement.
Definition: statement.c:3253
static void build_omp_pragma_list(extensions exts, list *l_pragma)
Callback for gen_recurse that build a list of OpenMP pragma to be merged.
void print_entities(list l)
Definition: entity.c:167
list pragma_omp_merge_expr(list outer_extensions, list l_pragma, language l)
merge omp pragma.
Definition: pragma.c:326
list filter_variables_in_pragma_expr(list l_expr, list to_filter)
filter out a pragma (expression list) removing all requested variables @params l_expr is the list of ...
Definition: pragma.c:256
void add_pragma_expr_to_statement(statement st, list l)
Add a pragma as a list of expression to a statement.
Definition: pragma.c:460
#define extensions_domain
newgen_extension_domain_defined
Definition: ri.h:170
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define ifdebug(n)
Definition: sg.c:47

References add_pragma_expr_to_statement(), build_omp_pragma_list(), extensions_domain, extensions_extension, filter_variables_in_pragma_expr(), FOREACH, fprintf(), gen_context_recurse, gen_copy_seq(), gen_free_list(), gen_true2(), get_prettyprint_language(), ifdebug, NIL, pips_debug, pragma_omp_merge_expr(), print_entities(), STATEMENT, statement_extensions, and statement_to_declarations().

Referenced by omp_merge_pragma().

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

◆ omp_loop_parallel_threshold_set()

bool omp_loop_parallel_threshold_set ( const char *  module_name)

Should never arise

Put the new CODE ressource into PIPS:

Parameters
module_nameodule_name

Definition at line 351 of file manage_pragma.c.

351  {
352  debug_on("OPMIFY_CODE_DEBUG_LEVEL");
353  statement mod_stmt = statement_undefined;
354  // Get the code and tell PIPS_DBM we do want to modify it
355  mod_stmt = (statement) db_get_memory_resource(DBR_CODE, module_name, true);
356 
357  // Set the current module entity and the current module statement that are
358  // required to have many things working in PIPS
361 
362  // generate pragma string or expression using the correct language:
364  if(value_code_p(mv)) {
365  code c = value_code(mv);
367  } else {
368  /* Should never arise */
370  }
371 
372  // Add the parallel threshold to all the omp for pragmas
374 
375  /* Put the new CODE ressource into PIPS: */
376  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, mod_stmt);
377  // There is no longer a current module:
380 
381  pips_debug(2, "done for %s\n", module_name);
382  debug_off();
383 
384  return true;
385 }
void set_prettyprint_language_from_property(enum language_utype native)
set the prettyprint language according to the property PRETTYPRINT_LANGUAGE @description If the prope...
Definition: language.c:103
static void add_loop_parallel_threshold(pragma pr)
add a if condition to the omp pragma
#define value_code_p(x)
Definition: ri.h:3065
#define pragma_domain
newgen_persistant_statement_to_statement_domain_defined
Definition: ri.h:290
#define value_code(x)
Definition: ri.h:3067
#define code_language(x)
Definition: ri.h:792
#define language_tag(x)
Definition: ri.h:1590
@ is_language_fortran
Definition: ri.h:1566
#define entity_initial(x)
Definition: ri.h:2796

References add_loop_parallel_threshold(), code_language, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, entity_initial, gen_recurse, gen_true(), is_language_fortran, language_tag, module_name(), module_name_to_entity(), pips_debug, pragma_domain, reset_current_module_entity(), reset_current_module_statement(), set_current_module_entity(), set_current_module_statement(), set_prettyprint_language_from_property(), statement_undefined, value_code, and value_code_p.

+ Here is the call graph for this function:

◆ omp_merge_pragma()

bool omp_merge_pragma ( const char *  module_name)

merge the pragma on the outer loop

Should never arise

Parameters
module_nameodule_name

Definition at line 297 of file manage_pragma.c.

297  {
298  // Use this module name and this environment variable to set
300  "OPMIFY_CODE_DEBUG_LEVEL");
301 
302  /* // generate pragma string or expression using the correct language: */
304  if(value_code_p(mv)) {
305  code c = value_code(mv);
307  } else {
308  /* Should never arise */
310  }
311 
312  // getting the properties to configure the phase
313  const char* merge_policy = get_string_property("OMP_MERGE_POLICY");
314  bool outer = (strcmp(merge_policy, "outer") == 0);
315 
316  // The list of outer loop as a list of statements
317  list l_outer = NIL;
318 
319  // build the list of outer loop with pragma this is also needed by the
320  // inner mode
321  gen_context_recurse(mod_stmt, &l_outer,
323 
324  if(outer == true) {
325  pips_debug(3, "outer mode\n");
326  // merge the pragma on the outer loop
327  merge_on_outer(l_outer);
328  } else { //inner
329  pips_debug(3, "inner mode\n");
330  // The inner flag
331  bool inner_flag = true;
332  FOREACH(statement, stmt, l_outer)
333  {
335  &inner_flag,
336  loop_domain,
337  inner_filter,
338  inner_rewrite);
339  }
340  }
341 
342  // freeing memory
343  gen_free_list(l_outer);
344 
345  //Put back the new statement module
346  PIPS_PHASE_POSTLUDE(mod_stmt);
347 
348  return true;
349 }
char * get_string_property(const char *)
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
Definition: genClib.c:2758
#define PIPS_PHASE_POSTLUDE(new_module_statement)
End a transformation phase by putting back into PIPS the (possibly) modified statement.
#define PIPS_PHASE_PRELUDE(module_name, debug_env_var)
Start a phase that use a module CODE.
static void inner_rewrite(loop l, bool *inner_flag)
static void merge_on_outer(list l_outer)
merge the omp pragma on the most outer parallel loop
static bool inner_filter(loop l, bool *inner_flag)
static bool build_outer(loop l, list *l_outer)
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218

References build_outer(), code_language, entity_initial, FOREACH, gen_context_recurse, gen_free_list(), gen_null2(), get_string_property(), inner_filter(), inner_rewrite(), is_language_fortran, language_tag, loop_domain, merge_on_outer(), module_name(), module_name_to_entity(), NIL, pips_debug, PIPS_PHASE_POSTLUDE, PIPS_PHASE_PRELUDE, set_prettyprint_language_from_property(), value_code, and value_code_p.

+ Here is the call graph for this function:

◆ outline_stmts_between_pragmas_in_sequence()

bool outline_stmts_between_pragmas_in_sequence ( sequence  s,
void *  _ctx 
)
Parameters
_ctxctx

Definition at line 454 of file manage_pragma.c.

454  {
455  // Cast of the void pointer
456  context *ctx = (context *) _ctx;
457  // Are we in a SCoP of the code ?
458  bool in_scop = false;
459  // A list of the statements contained in the sequence
460  list stmts = sequence_statements(s);
461  list stmts_to_outline = NIL;
462 
463  FOREACH(statement, stmt, stmts) {
464  // Flag that check if we are at the end of a list of stmts to outline
465  bool has_to_outline_p = false;
466  // If we are not already in a SCoP of the code and if the statement is preceded
467  // by pragma_start
468  // Else if we are already in a SCoP of the code and if the statement is followed
469  //by pragma_end
471  in_scop = true;
473  } else if(in_scop
475  in_scop = false;
476  has_to_outline_p = true;
478  }
479  // If we are in a SCoP : create an one-element statement list (cons) containing stmt
480  if(in_scop) {
481  stmts_to_outline = CONS(STATEMENT, stmt, stmts_to_outline );
482  }
483  // ENDP : true if list is empty, false if is a cons
484  if(has_to_outline_p && !ENDP(stmts_to_outline)) {
485  // Reverse the order of the list
486  stmts_to_outline = gen_nreverse(stmts_to_outline);
487  string func_name = build_new_top_level_module_name(ctx->prefix, false);
488  // Here we call the outliner on the collected statements
489  outliner(func_name, stmts_to_outline);
490  // Free the list of statement so that we can continue to build one
491  gen_free_list(stmts_to_outline);
492  stmts_to_outline = NIL;
493 
494  // Mark that a substitution have been done
495  ctx->outline_done = true;
496  }
497  }
498  if(in_scop) {
499  pips_user_warning("End of a sequence with a sentinel starting SCoP pragma "
500  "(%s) but did not encountered any pragma end (%s)\n",
501  ctx->pragma_begin, ctx->pragma_end);
502  }
503  return true;
504 }
statement outliner(const char *, list)
outline the statements in statements_to_outline into a module named outline_module_name the outlined ...
Definition: outlining.c:1327
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define statement_has_this_pragma_string_p(stmt, str)
string build_new_top_level_module_name(const char *prefix, bool prevent_suffix)
Get a new name for a module built from a prefix.
Definition: module.c:55
#define sequence_statements(x)
Definition: ri.h:2360
Definition: delay.c:253
string prefix
string pragma_end
string pragma_begin
bool outline_done

References build_new_top_level_module_name(), clear_pragma_on_statement(), CONS, ENDP, FOREACH, gen_free_list(), gen_nreverse(), NIL, context::outline_done, outliner(), pips_user_warning, context::pragma_begin, context::pragma_end, context::prefix, sequence_statements, STATEMENT, and statement_has_this_pragma_string_p.

Referenced by pragma_outliner().

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

◆ pragma_omp_p()

bool pragma_omp_p ( pragma  p)

Check that a pragma is an "omp" one.

Definition at line 78 of file manage_pragma.c.

78  {
79  bool pragma_omp = false;
80  if(pragma_expression_p(p)) {
81  list expr = pragma_expression(p);
82  // The list is reversed !
83  expression begin = EXPRESSION(CAR(gen_last(expr)));
84  if(expression_call_p(begin)) {
85  entity called = call_function(expression_call(begin));
87  pragma_omp = true;
88  }
89  }
90  } else if(pragma_string_p(p)) {
91  if(strncasecmp("omp", pragma_string(p), 3) == 0) {
92  pragma_omp = true;
93  }
94  } else {
95  pips_internal_error("We don't know how to handle this kind of pragma !\n");
96  }
97  return pragma_omp;
98 }
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
#define pips_internal_error
Definition: misc-local.h:149
#define same_string_p(s1, s2)
#define OMP_OMP_FUNCTION_NAME
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
bool expression_call_p(expression e)
Definition: expression.c:415
call expression_call(expression e)
Definition: expression.c:445
#define pragma_string(x)
Definition: ri.h:2033
#define call_function(x)
Definition: ri.h:709
#define pragma_string_p(x)
Definition: ri.h:2031
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define pragma_expression(x)
Definition: ri.h:2036

References call_function, CAR, entity_local_name(), EXPRESSION, expression_call(), expression_call_p(), gen_last(), OMP_OMP_FUNCTION_NAME, pips_internal_error, pragma_expression, pragma_expression_p, pragma_string, pragma_string_p, and same_string_p.

Referenced by build_omp_pragma_list().

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

◆ pragma_outliner()

bool pragma_outliner ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 512 of file manage_pragma.c.

512  {
513  // Standard procedure for phases
515 
517  module_name,
518  true));
519  statement module_stat = get_current_module_statement();
520 
521  // Needed for outliner !
523  module_name,
524  true));
526  module_name,
527  true));
528  // Needed for outliner using option OUTLINE_SMART_REFERENCE_COMPUTATION TRUE
530  // Needed for induction variable removal
534 
536 
537  // Recursion context
538  // Getting the parameters of the pragmas in order to be able to parse them later
539  context ctx;
540  ctx.pragma_begin = (string) get_string_property("PRAGMA_OUTLINER_BEGIN");
541  ctx.pragma_end = (string) get_string_property("PRAGMA_OUTLINER_END");
542  ctx.prefix = (string) get_string_property("PRAGMA_OUTLINER_PREFIX");
543  ctx.outline_done = false;
544  // Recurse over sequence
545  gen_context_recurse(module_stat, &ctx,
547  // If a substitution has been done correctly, we put the new resources
548  if(ctx.outline_done) {
549  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES,
550  module_name,
551  compute_callees(module_stat));
552 
553  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, module_stat);
554  }
555  // Standard procedure for reseting after a phase
565  return true;
566 }
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
Definition: callgraph.c:355
void set_methods_for_convex_effects(void)
methods.c
Definition: methods.c:235
void set_rw_effects(statement_effects)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void generic_effects_reset_all_methods(void)
void reset_cumulated_rw_effects(void)
void reset_rw_effects(void)
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
bool outline_stmts_between_pragmas_in_sequence(sequence s, void *_ctx)
char * string
STRING.
Definition: newgen_types.h:39
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
#define sequence_domain
newgen_reference_domain_defined
Definition: ri.h:346
void module_to_value_mappings(entity m)
void module_to_value_mappings(entity m): build hash tables between variables and values (old,...
Definition: mappings.c:624
void set_transformer_map(statement_mapping)
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
void reset_transformer_map(void)
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212

References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, free_value_mappings(), gen_context_recurse, gen_null2(), generic_effects_reset_all_methods(), get_current_module_entity(), get_current_module_statement(), get_string_property(), local_name_to_top_level_entity(), module_name(), module_to_value_mappings(), context::outline_done, outline_stmts_between_pragmas_in_sequence(), context::pragma_begin, context::pragma_end, context::prefix, reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_precondition_map(), reset_proper_rw_effects(), reset_rw_effects(), reset_transformer_map(), sequence_domain, set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_methods_for_convex_effects(), set_precondition_map(), set_proper_rw_effects(), set_rw_effects(), and set_transformer_map().

+ Here is the call graph for this function:

◆ statement_has_omp_parallel_directive_p()

bool statement_has_omp_parallel_directive_p ( statement  s)

manage_pragma.c

Definition at line 52 of file manage_pragma.c.

52  {
53  bool found = false;
55  pragma p = extension_pragma(ex);
56  if(pragma_string_p(p)) {
57  string ps = pragma_string(p);
58  if((found = (strstr(ps, "omp parallel") || strstr(ps, "OMP PARALLEL"))))
59  goto found;
60  } else if(pragma_expression_p(p)) {
62  {
63  if(expression_call_p(pe)) {
64  call c = expression_call(pe);
65  if((found = (same_entity_p(call_function(c),
67  goto found;
68  }
69  }
70  }
71  }
72  found: return found;
73 }
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321

References call_function, CreateIntrinsic(), EXPRESSION, expression_call(), expression_call_p(), EXTENSION, extension_pragma, extensions_extension, FOREACH, OMP_OMP_FUNCTION_NAME, pragma_expression, pragma_expression_p, pragma_string, pragma_string_p, same_entity_p(), and statement_extensions.

+ Here is the call graph for this function: