PIPS
directives.c File Reference
#include "defines-local.h"
#include "resources.h"
#include "control.h"
+ Include dependency graph for directives.c:

Go to the source code of this file.

Data Structures

struct  DirectiveHandler
 finds the handler for a given entity. More...
 

Macros

#define HANDLER(name)   handle_##name##_directive
 each directive is handled by a function here. More...
 

Functions

static void clean_statement (statement s)
 the directive is freed and replaced by a continue call or a copy loop nest, depending on the renamings. More...
 
static void add_statement_to_clean (statement s)
 
void add_a_dynamic (entity c)
 local primary dynamics More...
 
void hpfc_directives_error_handler ()
 the local stack is used to retrieve the current statement while scanning the AST with gen_recurse. More...
 
static void switch_basic_type_to_overloaded (entity e)
 management of PROCESSORS and TEMPLATE directives. More...
 
static void new_processor (expression e)
 
static void new_template (expression e)
 
static void new_dynamic (expression e)
 
static void new_io_function (expression e)
 
static void new_fake_function (expression e)
 
static void new_pure_function (expression e)
 
static void array_as_template (entity array)
 array is to be seen as a template. More...
 
static bool alignment_p (list align_src, expression subscript, int *padim, Value *prate, Value *pshift)
 one simple ALIGN directive is handled. More...
 
static align extract_the_align (reference alignee, reference temp, list lopt)
 builds an align from the alignee and template references. More...
 
static void initial_alignment (statement s)
 handle s as the initial alignment... More...
 
static void one_align_directive (reference alignee, reference temp, list lopt, bool dynamic)
 handle a simple (re)align directive. More...
 
static bool align_indices_p (entity f)
 hack, the common indices of a free form align is stored in a BLOCK() More...
 
static void handle_align_and_realign_directive (_UNUSED_ entity f, list args, bool dynamic)
 handle a full (re)align directive. More...
 
static tag distribution_format (expression e, list *pl)
 one DISTRIBUTE directive management More...
 
static distribute extract_the_distribute (reference distributee, reference proc)
 builds the distribute from the distributee and processor references. More...
 
static void one_distribute_directive (reference distributee, reference proc, bool dynamic)
 handles a simple (one template) distribute or redistribute directive. More...
 
static void handle_distribute_and_redistribute_directive (_UNUSED_ entity f, list args, bool dynamic)
 handles a full distribute or redistribute directive. More...
 
static void handle_unexpected_directive (_UNUSED_ entity f, _UNUSED_ list args)
 
static void handle_processors_directive (_UNUSED_ entity f, list args)
 
static void handle_template_directive (_UNUSED_ entity f, list args)
 
static void handle_align_directive (entity f, list args)
 
static void handle_distribute_directive (entity f, list args)
 
static void handle_reduction_directive (_UNUSED_ entity f, list args)
 I chose not to modify the ri to add reductions as private variables. More...
 
static void handle_independent_directive (_UNUSED_ entity f, list args)
 ??? I wait for the next statements in a particular order, what should not be necessary. More...
 
static void handle_new_directive (_UNUSED_ entity f, _UNUSED_ list args)
 ??? not implemented and not used. More...
 
static void handle_dynamic_directive (_UNUSED_ entity f, list args)
 
static void handle_pure_directive (_UNUSED_ entity f, list args)
 may be used to declare functions as pure. More...
 
static void handle_io_directive (_UNUSED_ entity f, list args)
 
static void handle_fake_directive (_UNUSED_ entity f, list args)
 
static void handle_realign_directive (entity f, list args)
 
static void handle_redistribute_directive (entity f, list args)
 
static void handle_synchro_directive (_UNUSED_ entity f, _UNUSED_ list args)
 
static void handle_time_directive (_UNUSED_ entity f, _UNUSED_ list args)
 for both timeon and timeoff More...
 
static void handle_host_section_directive (_UNUSED_ entity f, _UNUSED_ list args)
 
static void handle_set_directive (entity f, list args)
 for both setbool and setint ??? looks like a hack:-) More...
 
static void handle_prescriptive_directive (_UNUSED_ entity f, list args)
 prescriptive mappings before a call. More...
 
static void handle_kill_directive (_UNUSED_ entity f, _UNUSED_ list args)
 tells the compiler that the array values are dead from now on. More...
 
static void handle_nothing_directive (entity f, _UNUSED_ list args)
 
static bool directive_managed_now_p (const char *name)
 
static bool directive_filter (call c)
 newgen recursion thru the IR. More...
 
static bool prescription_filter (call c)
 
void handle_hpf_directives (statement s, bool dyn)
 void handle_hpf_directives(s) statement s; More...
 

Variables

static int analysis_phase = 0
 HPFC module by Fabien COELHO. More...
 
static list to_be_cleaned = NIL
 list of statements to be cleaned. More...
 
static struct DirectiveHandler handlers []
 
static void(*)(entity, listdirective_handler (const char *name)
 returns the handler for directive name. More...
 

Macro Definition Documentation

◆ HANDLER

#define HANDLER (   name)    handle_##name##_directive

each directive is handled by a function here.

these handlers may use the statement stack to proceed. I may add some handlers for private directives?

Definition at line 650 of file directives.c.

Function Documentation

◆ add_a_dynamic()

void add_a_dynamic ( entity  c)

local primary dynamics

Definition at line 99 of file directives.c.

100 {
101  the_dynamics_object = gen_once(c, the_dynamics_object);
102 }
list gen_once(const void *vo, list l)
Prepend an item to a list only if it is not already in the list.
Definition: list.c:722

References gen_once().

Referenced by hpfc_translate_call_with_distributed_args(), and new_dynamic().

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

◆ add_statement_to_clean()

static void add_statement_to_clean ( statement  s)
static

Definition at line 90 of file directives.c.

91 {
93 }
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
static list to_be_cleaned
list of statements to be cleaned.
Definition: directives.c:51
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References CONS, STATEMENT, and to_be_cleaned.

Referenced by directive_filter(), handle_set_directive(), handle_synchro_directive(), and handle_time_directive().

+ Here is the caller graph for this function:

◆ align_indices_p()

static bool align_indices_p ( entity  f)
static

hack, the common indices of a free form align is stored in a BLOCK()

Definition at line 406 of file directives.c.

407 {
409 }
#define same_string_p(s1, s2)
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
#define HPF_PREFIX
moved here because needed by syntax:-(
#define BLOCK_SUFFIX
suffixies for encoded hpf keywords
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

References BLOCK_SUFFIX, entity_local_name(), f(), HPF_PREFIX, and same_string_p.

Referenced by handle_align_and_realign_directive().

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

◆ alignment_p()

static bool alignment_p ( list  align_src,
expression  subscript,
int padim,
Value prate,
Value pshift 
)
static

one simple ALIGN directive is handled.

retrieve the alignment from references array and template true if the template dimension subscript is an alignment. false if the dimension is replicated.

else the subscript is affine

the alignment should be a simple affine expression

constant alignment case

affine alignment case

alignment ok

matching array dimension not found, replicated!

Parameters
align_srcof expressions

Definition at line 193 of file directives.c.

196 {
198  Pvecteur v, v_src;
199  int size, array_dim;
200 
201  if (normalized_complex_p(n)) return false;
202 
203  /* else the subscript is affine
204  */
205  v = normalized_linear(n);
206  size = vect_size(v);
207  *pshift = vect_coeff(TCST, v);
208 
209  /* the alignment should be a simple affine expression
210  */
211  pips_user_assert("affine align subscript", *pshift==0 ? size<=1 : size<=2);
212 
213  /* constant alignment case
214  */
215  if (size==0 || (*pshift!=0 && size==1))
216  {
217  *padim = 0, *prate = 0;
218  return true;
219  }
220 
221  /* affine alignment case
222  */
223  for(array_dim = 1; !ENDP(align_src); POP(align_src), array_dim++)
224  {
225  n = expression_normalized(EXPRESSION(CAR(align_src)));
226  if (normalized_linear_p(n))
227  {
228  v_src = normalized_linear(n);
229 
230  pips_user_assert("simple index",
231  vect_size(v_src)==1 && var_of(v_src)!=TCST);
232 
233  *prate = vect_coeff(var_of(v_src), v);
234 
235  if (*prate!=0)
236  {
237  *padim = array_dim;
238  return true; /* alignment ok */
239  }
240  }
241  }
242 
243  /* matching array dimension not found, replicated!
244  */
245  *padim = 0, *prate = 0;
246  return false;
247 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define pips_user_assert(what, predicate)
Definition: misc-local.h:181
#define normalized_complex_p(x)
Definition: ri.h:1782
#define normalized_linear_p(x)
Definition: ri.h:1779
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_normalized(x)
Definition: ri.h:1249
#define normalized_linear(x)
Definition: ri.h:1781
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define var_of(varval)
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228

References CAR, ENDP, EXPRESSION, expression_normalized, normalized_complex_p, normalized_linear, normalized_linear_p, pips_user_assert, POP, TCST, var_of, vect_coeff(), and vect_size().

Referenced by extract_the_align().

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

◆ array_as_template()

static void array_as_template ( entity  array)
static

array is to be seen as a template.

aligned to itself...

of alignment

Definition at line 170 of file directives.c.

171 {
172  int ndim = NumberOfDimension(array);
173  list /* of alignment */ l = NIL;
174 
177 
178  for(; ndim>0; ndim--)
179  l = CONS(ALIGNMENT, make_alignment(ndim, ndim,
181  int_to_expression(0)), l);
182 
184 }
alignment make_alignment(intptr_t a1, intptr_t a2, expression a3, expression a4)
Definition: hpf.c:94
align make_align(list a1, entity a2)
Definition: hpf.c:52
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define ALIGNMENT(x)
ALIGNMENT.
Definition: hpf.h:102
void set_template(entity)
void store_hpf_alignment(entity, align)
void set_array_as_distributed(entity)
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
int NumberOfDimension(entity)
Definition: size.c:588
static entity array
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References ALIGNMENT, array, CONS, int_to_expression(), make_align(), make_alignment(), NIL, NumberOfDimension(), set_array_as_distributed(), set_template(), and store_hpf_alignment().

Referenced by extract_the_align(), extract_the_distribute(), and one_distribute_directive().

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

◆ clean_statement()

static void clean_statement ( statement  s)
static

the directive is freed and replaced by a continue call or a copy loop nest, depending on the renamings.

of renamings

of statements

Do not forget to move forbidden information associated with block:

Definition at line 56 of file directives.c.

57 {
59 
60  pips_assert("call", instruction_call_p(i));
61 
64 
65  if (bound_renamings_p(s))
66  {
67  list /* of renamings */ lr = load_renamings(s),
68  /* of statements */ block = NIL;
69 
70  MAP(RENAMING, r,
71  {
72  entity o = renaming_old(r);
73  entity n = renaming_new(r);
74 
76  },
77  lr);
78 
81  /* Do not forget to move forbidden information associated with
82  block: */
84  }
85  else
86  instruction_call(i) =
88 }
call make_call(entity a1, list a2)
Definition: ri.c:269
void free_instruction(instruction p)
Definition: ri.c:1118
void free_call(call p)
Definition: ri.c:236
statement generate_copy_loop_nest(entity src, entity trg)
statement generate_copy_loop_nest(src, trg) entity src, trg;
Definition: dynamic.c:1568
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
Definition: instruction.c:106
#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
void fix_sequence_statement_attributes(statement)
Since blocks are not represented in Fortran, they cannot carry a label.
Definition: statement.c:2016
#define renaming_old(x)
Definition: hpf_private.h:969
#define renaming_new(x)
Definition: hpf_private.h:971
#define RENAMING(x)
RENAMING.
Definition: hpf_private.h:939
bool bound_renamings_p(statement)
list load_renamings(statement)
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define CONTINUE_FUNCTION_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
#define instruction_call_p(x)
Definition: ri.h:1527
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529
#define call_undefined
Definition: ri.h:685

References bound_renamings_p(), call_undefined, CONS, CONTINUE_FUNCTION_NAME, entity_intrinsic(), fix_sequence_statement_attributes(), free_call(), free_instruction(), generate_copy_loop_nest(), instruction_call, instruction_call_p, load_renamings(), make_call(), make_instruction_block(), MAP, NIL, pips_assert, RENAMING, renaming_new, renaming_old, STATEMENT, and statement_instruction.

Referenced by handle_hpf_directives().

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

◆ directive_filter()

static bool directive_filter ( call  c)
static

newgen recursion thru the IR.

Definition at line 1017 of file directives.c.

1018 {
1019  entity f = call_function(c);
1020 
1021  // DIRECTIVES
1023  {
1024  const char* name = entity_local_name(f);
1025  pips_debug(8, "hpfc entity is %s\n", entity_name(f));
1026 
1027  // call the appropriate handler for the directive.
1028  (directive_handler(name))(f, call_arguments(c));
1029 
1030  // the current statement will have to be cleaned.
1033  }
1034 
1035  return false; // no instructions within a call!
1036 }
static bool directive_managed_now_p(const char *name)
Definition: directives.c:1010
static void(*)(entity, list) directive_handler(const char *name)
returns the handler for directive name.
Definition: directives.c:1002
static void add_statement_to_clean(statement s)
Definition: directives.c:90
#define current_stmt_head()
We want to keep track of the current statement inside the recurse.
Definition: icfg_scan.c:76
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
bool hpf_directive_entity_p(entity e)
Definition: hpfc.c:56
bool keep_directive_in_code_p(const char *s)
whether an entity must be kept in the code.
Definition: hpfc.c:101
#define call_function(x)
Definition: ri.h:709
#define entity_name(x)
Definition: ri.h:2790
#define call_arguments(x)
Definition: ri.h:711

References add_statement_to_clean(), call_arguments, call_function, current_stmt_head, directive_handler, directive_managed_now_p(), entity_local_name(), entity_name, f(), hpf_directive_entity_p(), keep_directive_in_code_p(), and pips_debug.

Referenced by handle_hpf_directives().

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

◆ directive_managed_now_p()

static bool directive_managed_now_p ( const char *  name)
static

Definition at line 1010 of file directives.c.

1011 {
1012  return directive_handler(name)!=HANDLER(nothing);
1013 }
#define HANDLER(name)
each directive is handled by a function here.
Definition: directives.c:650

References directive_handler, and HANDLER.

Referenced by directive_filter().

+ Here is the caller graph for this function:

◆ distribution_format()

static tag distribution_format ( expression  e,
list pl 
)
static

one DISTRIBUTE directive management

returns the expected style tag for the given distribution format, plus a pointer to the list of arguments.

BLOCK()

CYCLIC()

just to avoid a gcc warning

Parameters
plof expressions

Definition at line 451 of file directives.c.

453 {
454  syntax s = expression_syntax(e);
455  entity function;
456  const char* name;
457  call c;
458 
459  pips_assert("valid distribution format", syntax_call_p(s));
460 
461  c = syntax_call(s);
462  function = call_function(c);
463  *pl = call_arguments(c);
464 
465  pips_assert("valid distribution format", hpf_directive_entity_p(function));
466 
467  name = entity_local_name(function);
468 
469  if (same_string_p(name, HPF_PREFIX BLOCK_SUFFIX)) /* BLOCK() */
470  return is_style_block;
471  else
472  if (same_string_p(name, HPF_PREFIX CYCLIC_SUFFIX)) /* CYCLIC() */
473  return is_style_cyclic;
474  else
475  if (same_string_p(name, HPF_PREFIX STAR_SUFFIX)) /* * [star] */
476  return is_style_none;
477  else
478  pips_user_error("invalid distribution format");
479 
480  return 0; /* just to avoid a gcc warning */
481 }
@ is_style_cyclic
Definition: hpf.h:239
@ is_style_block
Definition: hpf.h:238
@ is_style_none
Definition: hpf.h:237
#define pips_user_error
Definition: misc-local.h:147
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
#define CYCLIC_SUFFIX
#define STAR_SUFFIX
#define syntax_call_p(x)
Definition: ri.h:2734
#define syntax_call(x)
Definition: ri.h:2736
#define expression_syntax(x)
Definition: ri.h:1247

References BLOCK_SUFFIX, call_arguments, call_function, CYCLIC_SUFFIX, entity_local_name(), expression_syntax, hpf_directive_entity_p(), HPF_PREFIX, is_style_block, is_style_cyclic, is_style_none, pips_assert, pips_user_error, pl, same_string_p, STAR_SUFFIX, syntax_call, and syntax_call_p.

Referenced by extract_the_distribute().

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

◆ extract_the_align()

static align extract_the_align ( reference  alignee,
reference  temp,
list  lopt 
)
static

builds an align from the alignee and template references.

used by both align and realign management.

of alignments

of expressions

each array dimension is looked for a possible alignment

align A with T - implicit alignment

explicit alignment

for an alignment tree I should check here whether template is aligned to sg, and update accordingly. Also backtracking already built alignments when a "template" happens to be aligned would be useful. Some day...

built align is returned. should be normalized?

Parameters
loptof expression

Definition at line 253 of file directives.c.

257 {
258  list/* of alignments */ aligns = NIL,
259  /* of expressions */ align_src = reference_indices(alignee),
260  align_sub = reference_indices(temp);
261  entity template = reference_variable(temp),
262  array = reference_variable(alignee);
263  int array_dim, template_dim, tndim, andim;
264  Value rate, shift;
265 
266  if (!entity_template_p(template))
267  array_as_template(template);
268 
269  pips_user_assert("align with a template", entity_template_p(template));
270  pips_user_assert("one set of indices", !(lopt && align_src));
271 
272  if (lopt) align_src = lopt;
273 
274  tndim = NumberOfDimension(template);
275  andim = NumberOfDimension(array);
276 
277  /* each array dimension is looked for a possible alignment
278  */
279 
280  if (ENDP(align_src)) /* align A with T - implicit alignment */
281  {
282  int dim, ndim, tlower, alower, unused;
283 
284  pips_user_assert("no template subscripts", ENDP(align_sub));
285  ndim=MIN(andim, tndim);
286 
287  for (dim=1; dim<=ndim; dim++)
288  {
289  get_entity_dimensions(template, dim, &tlower, &unused);
290  get_entity_dimensions(array, dim, &alower, &unused);
291 
292  aligns = CONS(ALIGNMENT,
293  make_alignment(dim, dim,
295  int_to_expression(-alower+tlower)),
296  aligns);
297  }
298  }
299  else /* explicit alignment */
300  {
301  pips_user_assert("align-source-list length = rank",
302  (int)gen_length(align_src) == andim);
303  pips_user_assert("align-subscript-list length = rank",
304  (int)gen_length(align_sub) == tndim);
305 
306  for(template_dim=1; !ENDP(align_sub); POP(align_sub), template_dim++)
307  {
308  if (alignment_p(align_src, EXPRESSION(CAR(align_sub)),
309  &array_dim, &rate, &shift))
310  aligns = CONS(ALIGNMENT,
311  make_alignment(array_dim,
312  template_dim,
313  Value_to_expression(rate),
314  Value_to_expression(shift)),
315  aligns);
316  }
317  }
318 
319  /* for an alignment tree I should check here whether template is
320  * aligned to sg, and update accordingly. Also backtracking already
321  * built alignments when a "template" happens to be aligned would be
322  * useful. Some day...
323  */
324  /* built align is returned. should be normalized?
325  */
326  return make_align(aligns, template);
327 }
#define MIN(x, y)
minimum and maximum if they are defined somewhere else, they are very likely to be defined the same w...
int Value
size_t gen_length(const list l)
Definition: list.c:150
void get_entity_dimensions(entity e, int dim, int *plow, int *pup)
Definition: hpfc-util.c:651
static void array_as_template(entity array)
array is to be seen as a template.
Definition: directives.c:170
static bool alignment_p(list align_src, expression subscript, int *padim, Value *prate, Value *pshift)
one simple ALIGN directive is handled.
Definition: directives.c:193
bool entity_template_p(entity)
expression Value_to_expression(Value v)
added interface for linear stuff.
Definition: expression.c:1251
#define reference_variable(x)
Definition: ri.h:2326
#define reference_indices(x)
Definition: ri.h:2328

References ALIGNMENT, alignment_p(), array, array_as_template(), CAR, CONS, ENDP, entity_template_p(), EXPRESSION, gen_length(), get_entity_dimensions(), int_to_expression(), make_align(), make_alignment(), MIN, NIL, NumberOfDimension(), pips_user_assert, POP, reference_indices, reference_variable, and Value_to_expression().

Referenced by one_align_directive().

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

◆ extract_the_distribute()

static distribute extract_the_distribute ( reference  distributee,
reference  proc 
)
static

builds the distribute from the distributee and processor references.

of expressions

keep the non empty one

of distributions

the template arguments are scanned to build the distribution

distribute T onto P - implicit

explicit distribution

implicit size

explicit size

Definition at line 486 of file directives.c.

487 {
489  entity processor = reference_variable(proc),
490  template = reference_variable(distributee);
491  list/* of expressions */ largs,
492  lformat = reference_indices(distributee)? /* keep the non empty one */
493  reference_indices(distributee): reference_indices(proc),
494  /* of distributions */ ldist = NIL;
495  int npdim, ntdim;
496  tag format;
497 
498  if (!entity_template_p(template))
499  array_as_template(template);
500 
501  ntdim = NumberOfDimension(template);
502  npdim = NumberOfDimension(processor);
503 
504  pips_user_assert("more template dimensions than processor dimensions",
505  ntdim>=npdim);
506 
507  /* the template arguments are scanned to build the distribution
508  */
509  if (ENDP(lformat)) /* distribute T onto P - implicit */
510  {
511  int dim;
512  for (dim=1; dim<=npdim; dim++)
513  ldist = CONS(DISTRIBUTION,
516  ldist);
517  }
518  else /* explicit distribution */
519  {
520  for(; !ENDP(lformat); POP(lformat))
521  {
522  format = distribution_format(EXPRESSION(CAR(lformat)), &largs);
523 
524  switch (format)
525  {
526  case is_style_block:
527  case is_style_cyclic:
528  pips_assert("valid distribution", gen_length(largs)<=1);
529 
530  parameter = ENDP(largs) ?
531  expression_undefined : /* implicit size */
532  copy_expression(EXPRESSION(CAR(largs))); /* explicit size */
533 
534  break;
535  case is_style_none:
537  break;
538  default:
539  pips_internal_error("unexpected style tag (%d)", format);
540  }
541 
542  ldist = CONS(DISTRIBUTION,
544  ldist);
545  }
546  }
547 
548  return make_distribute(gen_nreverse(ldist), processor);
549 }
distribution make_distribution(style a1, expression a2)
Definition: hpf.c:178
distribute make_distribute(list a1, entity a2)
Definition: hpf.c:136
style make_style(enum style_utype tag, void *val)
Definition: hpf.c:228
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define DISTRIBUTION(x)
DISTRIBUTION.
Definition: hpf.h:180
static tag distribution_format(expression e, list *pl)
one DISTRIBUTE directive management
Definition: directives.c:451
#define pips_internal_error
Definition: misc-local.h:149
int tag
TAG.
Definition: newgen_types.h:92
#define UU
Definition: newgen_types.h:98
#define expression_undefined
Definition: ri.h:1223

References array_as_template(), CAR, CONS, copy_expression(), DISTRIBUTION, distribution_format(), ENDP, entity_template_p(), EXPRESSION, expression_undefined, gen_length(), gen_nreverse(), is_style_block, is_style_cyclic, is_style_none, make_distribute(), make_distribution(), make_style(), NIL, NumberOfDimension(), pips_assert, pips_internal_error, pips_user_assert, POP, reference_indices, reference_variable, and UU.

Referenced by one_distribute_directive().

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

◆ handle_align_and_realign_directive()

static void handle_align_and_realign_directive ( _UNUSED_ entity  f,
list  args,
bool  dynamic 
)
static

handle a full (re)align directive.

just decompose into simple alignments...

of expression

last points to the last item of args, which should be the template

Parameters
argsof expressions

Definition at line 415 of file directives.c.

419 {
420  list /* of expression */ last = gen_last(args), lopt=NIL;
421  reference template;
422  expression first;
423 
424  /* last points to the last item of args, which should be the template
425  */
426  pips_user_assert("align sg with sg", gen_length(args)>=2);
427  template = expression_to_reference(EXPRESSION(CAR(last)));
428 
430 
431  if (dynamic) store_renamings(current_stmt_head(), NIL);
432 
433  first = EXPRESSION(CAR(args));
435  {
436  pips_debug(5, "external align indices\n");
438  POP(args);
439  }
440 
441  for(; args!=last; POP(args))
443  template, lopt, dynamic);
444 }
void gen_map(gen_iter_func_t fp, const list l)
Definition: list.c:172
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
static void one_align_directive(reference alignee, reference temp, list lopt, bool dynamic)
handle a simple (re)align directive.
Definition: directives.c:355
static bool align_indices_p(entity f)
hack, the common indices of a free form align is stored in a BLOCK()
Definition: directives.c:406
void store_renamings(statement, list)
void(* gen_iter_func_t)(void *)
Definition: newgen_types.h:116
void normalize_all_expressions_of(void *obj)
Definition: normalize.c:668
reference expression_to_reference(expression e)
Definition: expression.c:212
entity expression_to_entity(expression e)
just returns the entity of an expression, or entity_undefined
Definition: expression.c:3140

References align_indices_p(), call_arguments, CAR, current_stmt_head, EXPRESSION, expression_syntax, expression_to_entity(), expression_to_reference(), gen_last(), gen_length(), gen_map(), NIL, normalize_all_expressions_of(), one_align_directive(), pips_debug, pips_user_assert, POP, store_renamings(), and syntax_call.

Referenced by handle_align_directive(), and handle_realign_directive().

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

◆ handle_align_directive()

static void handle_align_directive ( entity  f,
list  args 
)
static

Definition at line 672 of file directives.c.

673 {
675 }
static void handle_align_and_realign_directive(_UNUSED_ entity f, list args, bool dynamic)
handle a full (re)align directive.
Definition: directives.c:415

References f(), and handle_align_and_realign_directive().

+ Here is the call graph for this function:

◆ handle_distribute_and_redistribute_directive()

static void handle_distribute_and_redistribute_directive ( _UNUSED_ entity  f,
list  args,
bool  dynamic 
)
static

handles a full distribute or redistribute directive.

of expression

last points to the last item of args, which should be the processors

calls the simple case handler.

Definition at line 619 of file directives.c.

623 {
624  list /* of expression */ last = gen_last(args);
625  reference proc;
626 
627  if (dynamic) store_renamings(current_stmt_head(), NIL);
628 
629  /* last points to the last item of args, which should be the processors
630  */
631  pips_user_assert("distribute sg with sg", gen_length(args)>=2);
632  proc = expression_to_reference(EXPRESSION(CAR(last)));
634 
635  /* calls the simple case handler.
636  */
637  for(; args!=last; POP(args))
639  proc, dynamic);
640 }
static void one_distribute_directive(reference distributee, reference proc, bool dynamic)
handles a simple (one template) distribute or redistribute directive.
Definition: directives.c:554

References CAR, current_stmt_head, EXPRESSION, expression_to_reference(), gen_last(), gen_length(), gen_map(), NIL, normalize_all_expressions_of(), one_distribute_directive(), pips_user_assert, POP, and store_renamings().

Referenced by handle_distribute_directive(), and handle_redistribute_directive().

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

◆ handle_distribute_directive()

static void handle_distribute_directive ( entity  f,
list  args 
)
static

Definition at line 678 of file directives.c.

679 {
681 }
static void handle_distribute_and_redistribute_directive(_UNUSED_ entity f, list args, bool dynamic)
handles a full distribute or redistribute directive.
Definition: directives.c:619

References f(), and handle_distribute_and_redistribute_directive().

+ Here is the call graph for this function:

◆ handle_dynamic_directive()

static void handle_dynamic_directive ( _UNUSED_ entity  f,
list  args 
)
static

see new_dynamic

Definition at line 783 of file directives.c.

784 {
785  gen_map((gen_iter_func_t)new_dynamic, args); /* see new_dynamic */
786 }
static void new_dynamic(expression e)
Definition: directives.c:144

References gen_map(), and new_dynamic().

+ Here is the call graph for this function:

◆ handle_fake_directive()

static void handle_fake_directive ( _UNUSED_ entity  f,
list  args 
)
static

Definition at line 814 of file directives.c.

815 {
817  if (ENDP(args))
819  else
821 }
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
static void new_fake_function(expression e)
Definition: directives.c:158
void add_a_fake_function(entity f)
Definition: hpfc.c:88
static char * module
Definition: pips.c:74

References add_a_fake_function(), ENDP, gen_map(), get_current_module_entity(), module, and new_fake_function().

+ Here is the call graph for this function:

◆ handle_host_section_directive()

static void handle_host_section_directive ( _UNUSED_ entity  f,
_UNUSED_ list  args 
)
static

Definition at line 854 of file directives.c.

855 {
856  pips_debug(8, "host section\n");
857  return;
858 }

References pips_debug.

◆ handle_hpf_directives()

void handle_hpf_directives ( statement  s,
bool  dyn 
)

void handle_hpf_directives(s) statement s;

what: handles the HPF directives in statement s. how: recurses thru the AST, looking for special "directive calls". when found, a special handler is called for the given directive. input: the code statement s output: none side effects: (many)

  • the hpfc data structures are set/updated to store the hpf mapping.
  • parallel loops are tagged parallel.
  • a static stack is used to retrieve the current statement.
  • the ctrl_graph travelling is used, so should be initialized.
  • the special calls are freed and replaced by continues. bugs or features:
  • the "new" directive is not used to tag private variables.
  • a non hpf "pure" directive is parsed.

INITIALIZE needed static stuff

PHASE 1

PHASE 2

PHASE 3

OPTIMIZATION

CLEAN

Parameters
dynyn

Definition at line 1069 of file directives.c.

1070 {
1071  /* INITIALIZE needed static stuff
1072  */
1073  make_current_stmt_stack();
1074  to_be_cleaned = NIL;
1075 
1076  if (!dyn)
1077  {
1078  /* PHASE 1
1079  */
1080  pips_debug(1, "starting phase 1\n");
1081  analysis_phase = 1;
1083  statement_domain, current_stmt_filter, current_stmt_rewrite,
1086  NULL);
1087  }
1088  else
1089  {
1090  /* PHASE 2
1091  */
1094  store_renamings(s, NIL);
1095 
1096  pips_debug(1, "starting phase 2\n");
1097  analysis_phase = 2;
1099  statement_domain, current_stmt_filter, current_stmt_rewrite,
1101  NULL);
1102 
1103  DEBUG_STAT(7, "between phase 2 and 3", s);
1104 
1105 
1106  /* PHASE 3
1107  */
1108  pips_debug(1, "starting phase 3\n");
1109  analysis_phase = 3;
1112  statement_domain, current_stmt_filter, current_stmt_rewrite,
1115  NULL);
1116 
1117  initial_alignment(s);
1118 
1119  ifdebug(7) dump_current_remapping_graph("after phase 3");
1120  DEBUG_STAT(7, "after phase 3", s);
1121 
1122  /* OPTIMIZATION
1123  */
1124  if (get_bool_property("HPFC_OPTIMIZE_REMAPPINGS"))
1125  {
1126  pips_debug(1, "starting optimization phase\n");
1128  }
1129 
1130  clean_ctrl_graph();
1131 
1133 
1136 
1137  DEBUG_STAT(7, "after optimization phase", s);
1138  }
1139 
1140  /* CLEAN
1141  */
1143  pips_assert("empty stack", current_stmt_empty_p());
1145  free_current_stmt_stack();
1146 
1147  DEBUG_CODE(5, "resulting code", get_current_module_entity(), s);
1148 }
void build_full_ctrl_graph(statement)
Definition: graph.c:238
void clean_ctrl_graph(void)
global mapping from statements to their control in the full control graph
Definition: graph.c:53
void close_dynamic_locals()
Definition: dynamic.c:817
void init_dynamic_locals()
DYNAMIC LOCAL DATA.
Definition: dynamic.c:806
void dump_current_remapping_graph(string when)
Definition: dynamic.c:1440
void simplify_remapping_graph(void)
void simplify_remapping_graph()
Definition: dynamic.c:1467
void hpfc_check_for_similarities(list le)
check all dynamic arrays for some similars...
Definition: dynamic.c:269
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
if(!(yy_init))
Definition: genread_lex.c:1029
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
bool gen_false(__attribute__((unused)) gen_chunk *unused)
Return false and ignore the argument.
Definition: genClib.c:2796
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define DEBUG_STAT(D, W, S)
#define DEBUG_CODE(D, W, M, S)
static void initial_alignment(statement s)
handle s as the initial alignment...
Definition: directives.c:332
static bool prescription_filter(call c)
Definition: directives.c:1038
static bool directive_filter(call c)
newgen recursion thru the IR.
Definition: directives.c:1017
static int analysis_phase
HPFC module by Fabien COELHO.
Definition: directives.c:44
static void clean_statement(statement s)
the directive is freed and replaced by a continue call or a copy loop nest, depending on the renaming...
Definition: directives.c:56
list get_the_dynamics(void)
void close_the_dynamics(void)
void init_the_dynamics(void)
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
#define ifdebug(n)
Definition: sg.c:47

References analysis_phase, build_full_ctrl_graph(), call_domain, clean_ctrl_graph(), clean_statement(), close_dynamic_locals(), close_the_dynamics(), DEBUG_CODE, DEBUG_STAT, directive_filter(), dump_current_remapping_graph(), expression_domain, gen_false(), gen_free_list(), gen_map(), gen_multi_recurse(), gen_null(), get_bool_property(), get_current_module_entity(), get_the_dynamics(), hpfc_check_for_similarities(), ifdebug, init_dynamic_locals(), init_the_dynamics(), initial_alignment(), NIL, pips_assert, pips_debug, prescription_filter(), simplify_remapping_graph(), statement_domain, store_renamings(), and to_be_cleaned.

Referenced by hpfc_directives_handler().

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

◆ handle_independent_directive()

static void handle_independent_directive ( _UNUSED_ entity  f,
list  args 
)
static

??? I wait for the next statements in a particular order, what should not be necessary.

Means I should deal with independent directives on the PARSED_CODE rather than after the CONTROLIZED.

of entities

travels thru the full control graph to find the loops and tag them as parallel.

what we're looking for

simple independent case, first loop is tagged //

else general independent case (with a list of indexes)

the end

Definition at line 721 of file directives.c.

722 {
723  list /* of entities */ l = expressions_to_entities(args);
724  statement s;
725 
726  pips_debug(2, "%zd index(es)\n", gen_length(l));
727 
728  /* travels thru the full control graph to find the loops
729  * and tag them as parallel.
730  */
732 
733  while(next_ctrl_graph_travel(&s))
734  {
736 
737  if (instruction_loop_p(i)) /* what we're looking for */
738  {
739  loop o = instruction_loop(i);
740  entity index = loop_index(o);
741 
742  if (ENDP(l)) /* simple independent case, first loop is tagged // */
743  {
744  pips_debug(3, "parallel loop\n");
745 
748  return;
749  }
750  /* else general independent case (with a list of indexes)
751  */
752  if (gen_in_list_p(index, l))
753  {
754  pips_debug(3, "parallel loop (%s)\n", entity_name(index));
755 
757  gen_remove(&l, index);
758 
759  if (ENDP(l)) /* the end */
760  {
762  return;
763  }
764  }
765  }
766  }
767 
769  pips_user_error("some loop not found!\n");
770 }
bool next_ctrl_graph_travel(statement *)
Definition: graph.c:325
void init_ctrl_graph_travel(statement, bool(*)(statement))
Definition: graph.c:315
void close_ctrl_graph_travel(void)
Definition: graph.c:340
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
list expressions_to_entities(list expressions)
map expression_to_entity on expressions
Definition: expression.c:3161
#define execution_tag(x)
Definition: ri.h:1207
#define loop_execution(x)
Definition: ri.h:1648
#define instruction_loop_p(x)
Definition: ri.h:1518
#define instruction_loop(x)
Definition: ri.h:1520
@ is_execution_parallel
Definition: ri.h:1190
#define loop_index(x)
Definition: ri.h:1640

References close_ctrl_graph_travel(), current_stmt_head, ENDP, entity_name, execution_tag, expressions_to_entities(), gen_in_list_p(), gen_length(), gen_remove(), gen_true(), init_ctrl_graph_travel(), instruction_loop, instruction_loop_p, is_execution_parallel, loop_execution, loop_index, next_ctrl_graph_travel(), pips_debug, pips_user_error, and statement_instruction.

+ Here is the call graph for this function:

◆ handle_io_directive()

static void handle_io_directive ( _UNUSED_ entity  f,
list  args 
)
static

Definition at line 804 of file directives.c.

805 {
807  if (ENDP(args))
809  else
811 }
static void new_io_function(expression e)
Definition: directives.c:153
void add_an_io_function(entity f)
Definition: hpfc.c:74

References add_an_io_function(), ENDP, gen_map(), get_current_module_entity(), module, and new_io_function().

+ Here is the call graph for this function:

◆ handle_kill_directive()

static void handle_kill_directive ( _UNUSED_ entity  f,
_UNUSED_ list  args 
)
static

tells the compiler that the array values are dead from now on.

can be used by the propagation to stop the process... and mark at this point all copies as live! pretty simple handling! I let the call as a marker for itself, and it will be removed later on at the compilation stage only...

Definition at line 929 of file directives.c.

930 {
931  pips_debug(4, "dead directive encountered");
932 }

References pips_debug.

◆ handle_new_directive()

static void handle_new_directive ( _UNUSED_ entity  f,
_UNUSED_ list  args 
)
static

??? not implemented and not used.

The independent directive is trusted by the compiler to apply its optimizations...

(that's indeed a first implementation:-)

Definition at line 776 of file directives.c.

777 {
778  hpfc_warning("not implemented\n");
779  return; /* (that's indeed a first implementation:-) */
780 }
#define hpfc_warning
WARNING.

References hpfc_warning.

◆ handle_nothing_directive()

static void handle_nothing_directive ( entity  f,
_UNUSED_ list  args 
)
static

Definition at line 935 of file directives.c.

936 {
937  pips_debug(4, "skipping entity %s\n", entity_name(f));
938 }

References entity_name, f(), and pips_debug.

+ Here is the call graph for this function:

◆ handle_prescriptive_directive()

static void handle_prescriptive_directive ( _UNUSED_ entity  f,
list  args 
)
static

prescriptive mappings before a call.

another kind of remapping, as realign and redistribute.

only one renaming per rename directive!

Definition at line 905 of file directives.c.

906 {
908  entity array, new_array;
909 
911  new_array = expression_to_entity(EXPRESSION(CAR(CDR(args))));
912 
913  propagate_synonym(current, array, new_array, true);
914 
915  /* only one renaming per rename directive!
916  */
918  CONS(RENAMING, make_renaming(array, new_array), NIL));
919 
920 }
renaming make_renaming(entity a1, entity a2)
Definition: hpf_private.c:881
void propagate_synonym(statement s, entity old, entity new, bool is_array)
Definition: dynamic.c:1096
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
static size_t current
Definition: string.c:115

References array, CAR, CDR, CONS, current, current_stmt_head, EXPRESSION, expression_to_entity(), make_renaming(), NIL, propagate_synonym(), RENAMING, and store_renamings().

+ Here is the call graph for this function:

◆ handle_processors_directive()

static void handle_processors_directive ( _UNUSED_ entity  f,
list  args 
)
static

see new_processor

Definition at line 660 of file directives.c.

661 {
662  gen_map((gen_iter_func_t)new_processor, args); /* see new_processor */
663 }
static void new_processor(expression e)
Definition: directives.c:126

References gen_map(), and new_processor().

+ Here is the call graph for this function:

◆ handle_pure_directive()

static void handle_pure_directive ( _UNUSED_ entity  f,
list  args 
)
static

may be used to declare functions as pure.

??? it is not a directive in HPF, but I put it this way in F77. ??? pure declarations are not yet used by HPFC.

Definition at line 793 of file directives.c.

794 {
796 
797  if (ENDP(args))
799  else
801 }
static void new_pure_function(expression e)
Definition: directives.c:163
void add_a_pure(entity f)
Definition: hpfc.c:62

References add_a_pure(), ENDP, gen_map(), get_current_module_entity(), module, and new_pure_function().

+ Here is the call graph for this function:

◆ handle_realign_directive()

static void handle_realign_directive ( entity  f,
list  args 
)
static

Definition at line 824 of file directives.c.

825 {
827 }

References f(), and handle_align_and_realign_directive().

+ Here is the call graph for this function:

◆ handle_redistribute_directive()

static void handle_redistribute_directive ( entity  f,
list  args 
)
static

Definition at line 830 of file directives.c.

831 {
833 }

References f(), and handle_distribute_and_redistribute_directive().

+ Here is the call graph for this function:

◆ handle_reduction_directive()

static void handle_reduction_directive ( _UNUSED_ entity  f,
list  args 
)
static

I chose not to modify the ri to add reductions as private variables.

the reason is the following: locals are not well placed (they should be attached to statements?), I won't add one more misplaced sg. Also I would have to update all make_loop() within PIPS...

of entity

Definition at line 689 of file directives.c.

690 {
691  list /* of entity */ l = expressions_to_entities(args);
692  statement s;
693 
695 
696  while(next_ctrl_graph_travel(&s))
697  {
699  {
700  if (!bound_hpf_reductions_p(s))
702  else
703  {
706  }
708  return;
709  }
710  }
711 
713  pips_user_error("some loop not found!\n");
714 }
entities make_entities(list a)
Definition: hpf_private.c:250
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define entities_list(x)
Definition: hpf_private.h:414
bool bound_hpf_reductions_p(statement)
entities load_hpf_reductions(statement)
void store_hpf_reductions(statement, entities)

References bound_hpf_reductions_p(), close_ctrl_graph_travel(), current_stmt_head, entities_list, expressions_to_entities(), gen_nconc(), gen_true(), init_ctrl_graph_travel(), instruction_loop_p, load_hpf_reductions(), make_entities(), next_ctrl_graph_travel(), pips_user_error, statement_instruction, and store_hpf_reductions().

+ Here is the call graph for this function:

◆ handle_set_directive()

static void handle_set_directive ( entity  f,
list  args 
)
static

for both setbool and setint ??? looks like a hack:-)

property name. ??? moved to uppers because hpfc_directives put lowers. ??? plus having to deal with quotes that are put in the name!

Definition at line 864 of file directives.c.

865 {
867  {
868  expression arg1, arg2;
869  string property;
870  int val, i;
871 
872  pips_user_assert("two args", gen_length(args)==2);
873  arg1 = EXPRESSION(CAR(args));
874  arg2 = EXPRESSION(CAR(CDR(args)));
875  pips_user_assert("constant args",
876  expression_is_constant_p(arg1) &&
878 
879  /* property name.
880  * ??? moved to uppers because hpfc_directives put lowers.
881  * ??? plus having to deal with quotes that are put in the name!
882  */
883  property = strdup(entity_local_name
885  for (i=0; property[i]; i++) property[i]=toupper(property[i]);
886  property[i-1]='\0';
887 
888  val = HpfcExpressionToInt(arg2);
889 
891  set_bool_property(property+1, val);
892  else
893  set_int_property(property+1, val);
894 
895  free(property);
896  }
897 
899 }
bool expression_is_constant_p(expression e)
BEGIN_EOLE.
Definition: constant.c:666
void free(void *)
int HpfcExpressionToInt(expression e)
HpfcExpressionToInt(e)
Definition: hpfc-util.c:569
void set_bool_property(const char *, bool)
void set_int_property(const char *, int)
struct _newgen_struct_property_ * property
Definition: property.h:15
#define FCD_IGNORE_PREFIX
property prefix for ignoring FCD directives TIME, SYNCHRO and SET exists.
#define SETBOOL_SUFFIX
char * strdup()

References add_statement_to_clean(), call_function, CAR, CDR, current_stmt_head, entity_local_name(), EXPRESSION, expression_is_constant_p(), expression_syntax, f(), FCD_IGNORE_PREFIX, free(), gen_length(), get_bool_property(), HPF_PREFIX, HpfcExpressionToInt(), pips_user_assert, same_string_p, set_bool_property(), set_int_property(), SETBOOL_SUFFIX, strdup(), and syntax_call.

+ Here is the call graph for this function:

◆ handle_synchro_directive()

static void handle_synchro_directive ( _UNUSED_ entity  f,
_UNUSED_ list  args 
)
static

Definition at line 838 of file directives.c.

839 {
840  if (get_bool_property(FCD_IGNORE_PREFIX "SYNCHRO"))
842 }

References add_statement_to_clean(), current_stmt_head, FCD_IGNORE_PREFIX, and get_bool_property().

+ Here is the call graph for this function:

◆ handle_template_directive()

static void handle_template_directive ( _UNUSED_ entity  f,
list  args 
)
static

see new_template

Definition at line 666 of file directives.c.

667 {
668  gen_map((gen_iter_func_t)new_template, args); /* see new_template */
669 }
static void new_template(expression e)
Definition: directives.c:135

References gen_map(), and new_template().

+ Here is the call graph for this function:

◆ handle_time_directive()

static void handle_time_directive ( _UNUSED_ entity  f,
_UNUSED_ list  args 
)
static

for both timeon and timeoff

Definition at line 847 of file directives.c.

References add_statement_to_clean(), current_stmt_head, FCD_IGNORE_PREFIX, and get_bool_property().

+ Here is the call graph for this function:

◆ handle_unexpected_directive()

static void handle_unexpected_directive ( _UNUSED_ entity  f,
_UNUSED_ list  args 
)
static

Definition at line 654 of file directives.c.

655 {
656  pips_user_error("unexpected hpf directive\n");
657 }

References pips_user_error.

◆ hpfc_directives_error_handler()

void hpfc_directives_error_handler ( void  )

the local stack is used to retrieve the current statement while scanning the AST with gen_recurse.

Definition at line 109 of file directives.c.

110 {
111  error_reset_current_stmt_stack();
112 }

Referenced by hpfc_error_handler().

+ Here is the caller graph for this function:

◆ initial_alignment()

static void initial_alignment ( statement  s)
static

handle s as the initial alignment...

to be called after the dynamics arrays...

a formal is considered as used to force the remapping

Definition at line 332 of file directives.c.

333 {
334  MAP(ENTITY, array,
335  {
337  {
338  propagate_synonym(s, array, array, true);
340  load_renamings(s)));
341 
343  /* a formal is considered as used to force the remapping
344  */
346  }
347  },
348  get_the_dynamics());
349 }
void add_as_a_used_dynamic_to_statement(statement s, entity e)
Definition: dynamic.c:904
void update_renamings(statement, list)
bool array_distributed_p(entity)
#define storage_formal_p(x)
Definition: ri.h:2522
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_storage(x)
Definition: ri.h:2794

References add_as_a_used_dynamic_to_statement(), array, array_distributed_p(), CONS, ENTITY, entity_storage, get_the_dynamics(), load_renamings(), make_renaming(), MAP, propagate_synonym(), RENAMING, storage_formal_p, and update_renamings().

Referenced by handle_hpf_directives().

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

◆ new_dynamic()

static void new_dynamic ( expression  e)
static

Definition at line 144 of file directives.c.

145 {
148  add_a_dynamic(a);
149 
150  pips_debug(3, "entity is %s\n", entity_name(a));
151 }
void set_entity_as_dynamic(entity e)
a new dynamic entity is stored.
Definition: dynamic.c:130
void add_a_dynamic(entity c)
local primary dynamics
Definition: directives.c:99

References add_a_dynamic(), entity_name, expression_to_entity(), pips_debug, and set_entity_as_dynamic().

Referenced by handle_dynamic_directive().

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

◆ new_fake_function()

static void new_fake_function ( expression  e)
static

Definition at line 158 of file directives.c.

159 {
161 }

References add_a_fake_function(), and expression_to_entity().

Referenced by handle_fake_directive().

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

◆ new_io_function()

static void new_io_function ( expression  e)
static

Definition at line 153 of file directives.c.

154 {
156 }

References add_an_io_function(), and expression_to_entity().

Referenced by handle_io_directive().

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

◆ new_processor()

static void new_processor ( expression  e)
static

Definition at line 126 of file directives.c.

127 {
130  set_processor(p);
131 
132  pips_debug(3, "entity is %s\n", entity_name(p));
133 }
static void switch_basic_type_to_overloaded(entity e)
management of PROCESSORS and TEMPLATE directives.
Definition: directives.c:119
void set_processor(entity)

References entity_name, expression_to_entity(), pips_debug, set_processor(), and switch_basic_type_to_overloaded().

Referenced by handle_processors_directive().

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

◆ new_pure_function()

static void new_pure_function ( expression  e)
static

Definition at line 163 of file directives.c.

164 {
166 }

References add_a_pure(), and expression_to_entity().

Referenced by handle_pure_directive().

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

◆ new_template()

static void new_template ( expression  e)
static

Definition at line 135 of file directives.c.

136 {
139  set_template(t);
140 
141  pips_debug(3, "entity is %s\n", entity_name(t));
142 }

References entity_name, expression_to_entity(), pips_debug, set_template(), and switch_basic_type_to_overloaded().

Referenced by handle_template_directive().

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

◆ one_align_directive()

static void one_align_directive ( reference  alignee,
reference  temp,
list  lopt,
bool  dynamic 
)
static

handle a simple (re)align directive.

store the mappings in internal data structures. realign or align

a variable in a common can be declared several alignments that MUST be the same...

Parameters
tempthe array
loptthe template of expressions

Definition at line 355 of file directives.c.

360 {
361  entity template = reference_variable(temp),
362  array = reference_variable(alignee);
363  align a;
364 
365  pips_debug(3, "%s %saligned with %s\n", entity_name(array),
366  dynamic ? "re" : "", entity_name(template));
367 
368  a = extract_the_align(alignee, temp, lopt);
370 
371  ifdebug(8) print_align(a);
372 
373  if (dynamic)
374  {
376  entity new_array;
377 
378  pips_user_assert("dynamic array realignment",
380 
381  new_array = array_synonym_aligned_as(array, a);
382  propagate_synonym(current, array, new_array, true);
384  CONS(RENAMING, make_renaming(array, new_array),
386  }
387  else
388  {
390  {
393  }
394  else
395  {
396  /* a variable in a common can be declared several alignments
397  * that MUST be the same...
398  */
399  pips_assert("some alignment", bound_hpf_alignment_p(array));
400  }
401  }
402 }
void print_align(align a)
this is a set of functions to help hpfc debugging
Definition: debug-util.c:38
bool(* dynamic_entity_p)(entity)
as expected, true if entity e is dynamic.
Definition: dynamic.c:145
entity array_synonym_aligned_as(entity array, align a)
entity array_synonym_aligned_as(array, a) entity array; align a;
Definition: dynamic.c:449
void normalize_align(_UNUSED_ entity e, align a)
Definition: declarations.c:426
static align extract_the_align(reference alignee, reference temp, list lopt)
builds an align from the alignee and template references.
Definition: directives.c:253
bool bound_hpf_alignment_p(entity)

References array, array_distributed_p(), array_synonym_aligned_as(), bound_hpf_alignment_p(), CONS, current, current_stmt_head, dynamic_entity_p, entity_name, extract_the_align(), ifdebug, load_renamings(), make_renaming(), normalize_align(), pips_assert, pips_debug, pips_user_assert, print_align(), propagate_synonym(), reference_variable, RENAMING, set_array_as_distributed(), store_hpf_alignment(), and update_renamings().

Referenced by handle_align_and_realign_directive().

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

◆ one_distribute_directive()

static void one_distribute_directive ( reference  distributee,
reference  proc,
bool  dynamic 
)
static

handles a simple (one template) distribute or redistribute directive.

redistribute or distribute

the new template may be an array, thus auto-aligned

all arrays aligned to template are propagated in turn.

Parameters
procthe template
dynamicthe processor arrangement

Definition at line 554 of file directives.c.

558 {
559  entity processor = reference_variable(proc),
560  template = reference_variable(distributee);
561  distribute d = extract_the_distribute(distributee, proc);
562 
563  pips_user_assert("no indices to processor or :: syntax",
564  ENDP(reference_indices(proc)) || ENDP(reference_indices(distributee)));
565 
566  normalize_distribute(template, d);
567 
568  pips_debug(3, "%s %sdistributed onto %s\n", entity_name(template),
569  dynamic ? "re" : "", entity_name(processor));
570 
571  if (dynamic)
572  {
574  entity new_t;
575 
576  pips_user_assert("dynamic template redistribution",
577  entity_template_p(template) && dynamic_entity_p(template));
578 
579  new_t = template_synonym_distributed_as(template, d);
580  propagate_synonym(current, template, new_t, false);
581 
582  /* the new template may be an array, thus auto-aligned
583  */
584  if (array_distributed_p(template) && !bound_hpf_alignment_p(new_t))
585  array_as_template(new_t);
586 
587  /* all arrays aligned to template are propagated in turn.
588  */
589  MAP(ENTITY, array,
590  {
591  align a;
592  entity new_array;
593 
594  pips_debug(7, "array 0x%p\n", array);
595  pips_debug(7, "alive array %s\n", entity_name(array));
596 
598  new_array = array_synonym_aligned_as(array, a);
599 
600  propagate_synonym(current, array, new_array, true);
602  CONS(RENAMING, make_renaming(array, new_array),
604 
605  pips_debug(9, "done with %s->%s\n",
606  entity_name(array), entity_name(new_array));
607  },
608  alive_arrays(current, template));
609  }
610  else
611  store_hpf_distribution(template, d);
612 
613  pips_debug(4, "out\n");
614 }
list alive_arrays(statement s, entity t)
what: returns the list of alive arrays for statement s and template t.
Definition: dynamic.c:1504
align new_align_with_template(align a, entity t)
Definition: dynamic.c:474
entity template_synonym_distributed_as(entity temp, distribute d)
what: finds or creates a new entity distributed as needed.
Definition: dynamic.c:491
void normalize_distribute(entity t, distribute d)
Definition: declarations.c:408
static distribute extract_the_distribute(reference distributee, reference proc)
builds the distribute from the distributee and processor references.
Definition: directives.c:486
void store_hpf_distribution(entity, distribute)
align load_hpf_alignment(entity)

References alive_arrays(), array, array_as_template(), array_distributed_p(), array_synonym_aligned_as(), bound_hpf_alignment_p(), CONS, current, current_stmt_head, dynamic_entity_p, ENDP, ENTITY, entity_name, entity_template_p(), extract_the_distribute(), load_hpf_alignment(), load_renamings(), make_renaming(), MAP, new_align_with_template(), normalize_distribute(), pips_debug, pips_user_assert, propagate_synonym(), reference_indices, reference_variable, RENAMING, store_hpf_distribution(), template_synonym_distributed_as(), and update_renamings().

Referenced by handle_distribute_and_redistribute_directive().

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

◆ prescription_filter()

static bool prescription_filter ( call  c)
static

Definition at line 1038 of file directives.c.

1039 {
1040  entity f = call_function(c);
1041 
1043  {
1044  pips_debug(5, "distributed call to %s\n", entity_name(f));
1046  }
1047 
1048  return false;
1049 }
void hpfc_translate_call_with_distributed_args(statement s, call c)
??? only simple calls are handled.
Definition: dynamic.c:687
bool hpfc_call_with_distributed_args_p(call c)
whether call c inplies a distributed argument
Definition: dynamic.c:645

References call_function, current_stmt_head, entity_name, f(), hpfc_call_with_distributed_args_p(), hpfc_translate_call_with_distributed_args(), and pips_debug.

Referenced by handle_hpf_directives().

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

◆ switch_basic_type_to_overloaded()

static void switch_basic_type_to_overloaded ( entity  e)
static

management of PROCESSORS and TEMPLATE directives.

just changes the basic type to overloaded and stores the entity as a processor or a template.

Definition at line 119 of file directives.c.

120 {
121  basic b = entity_basic(e);
122  pips_assert("basic defined", b!=basic_undefined);
124 }
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
@ is_basic_overloaded
Definition: ri.h:574
#define basic_tag(x)
Definition: ri.h:613
#define basic_undefined
Definition: ri.h:556

References basic_tag, basic_undefined, entity_basic(), is_basic_overloaded, and pips_assert.

Referenced by new_processor(), and new_template().

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

Variable Documentation

◆ analysis_phase

int analysis_phase = 0
static

HPFC module by Fabien COELHO.

These functions deal with HPF directives. (just a big hack, but few lines of code and neither lex nor yacc:-) I'm definitely happy with this. FC. several phases are used to analyze the directives. 1: static directives 2: special management of prescriptive mappings 3: dynamic mappings

Definition at line 44 of file directives.c.

Referenced by handle_hpf_directives().

◆ directive_handler

void(*)(entity, list) directive_handler(const char *name) ( const char *  name)
static

returns the handler for directive name.

assumes that name should point to a directive.

Definition at line 1002 of file directives.c.

1003 {
1004  struct DirectiveHandler *x=handlers;
1005  while (x->name && strcmp(name, x->name)) x++;
1006  return (!x->phase || x->phase==analysis_phase)?
1007  x->handler: HANDLER(nothing);
1008 }
static struct DirectiveHandler handlers[]
Definition: directives.c:955
static char * x
Definition: split_file.c:159
finds the handler for a given entity.
Definition: directives.c:949

Referenced by directive_filter(), and directive_managed_now_p().

◆ handlers

struct DirectiveHandler handlers[]
static

Definition at line 935 of file directives.c.

◆ to_be_cleaned

list to_be_cleaned = NIL
static

list of statements to be cleaned.

the operation is delayed because the directives are needed in place to stop the dynamic updates. of statements

Definition at line 51 of file directives.c.

Referenced by add_statement_to_clean(), and handle_hpf_directives().