PIPS
generate-util.c File Reference
#include "defines-local.h"
+ Include dependency graph for generate-util.c:

Go to the source code of this file.

Functions

static expression pvm_encoding_option (int n)
 HPFC module by Fabien COELHO. More...
 
statement define_node_processor_id (entity proc, entity(*creation)(int))
 builds a statement VAR_i = MYPOS(i, proc_number) // i=1 to proc dimension More...
 
statement generate_deducables (list le)
 statement generate_deducables(list le) More...
 
list hpfc_gen_n_vars_expr (entity(*creation)(), int number)
 of expression More...
 
expression make_reference_expression (entity e, entity(*creation)())
 
statement hpfc_add_n (entity var, int n)
 returns statement VAR = VAR + N More...
 
statement hpfc_add_2 (expression exp)
 expr = expr + 2 More...
 
statement hpfc_message (expression tid, expression channel, bool send)
 
statement hpfc_lazy_guard (bool snd, statement then)
 returns if (LAZY_{SEND,RECV}) then More...
 
static statement hpfc_lazy_message (expression tid, expression channel, bool snd)
 IF (LAZY_snd) THEN PVMFsnd() LAZY_snd = false // if receive ENDIF. More...
 
statement hpfc_generate_message (entity ld, bool send, bool lazy)
 
statement hpfc_initsend (bool lazy)
 
static entity hpfc_buffer_entity (entity array, string suffix)
 returns the buffer entity for array More...
 
expression hpfc_buffer_reference (entity array, entity index)
 returns a reference to the typed common hpfc_buffer buffer, that suits array basic type and with index as an index. More...
 
static expression buffer_full_condition (entity array, bool is_send, bool is_full)
 generates the condition for testing the buffer state: returns (BUFFER_INDEX. More...
 
statement hpfc_buffer_packing (entity array, entity(*creation)(), bool pack)
 array(creation) = buffer(current++) or reverse assignment... More...
 
static entity hpfc_ith_broadcast_function (int dim, bool special)
 whether to use the special version More...
 
static statement hpfc_broadcast_buffers (entity src, entity trg, entity lid, entity proc)
 send the buffer, possibly a broadcast. More...
 
statement hpfc_packing_of_current__buffer (entity array, bool pack)
 CALL (pvmtype) HPFC {,UN}PACK. More...
 
statement hpfc_broadcast_if_necessary (entity array, entity trg, entity lid, entity proc, bool is_lazy)
 lazy or not... More...
 
statement hpfc_lazy_buffer_packing (entity src, entity trg, entity lid, entity proc, entity(*array_dim)(), bool is_send, bool is_lazy)
 lazy in actually sending or not the packed buffer immediatly... More...
 
statement hpfc_buffer_initialization (bool is_send, _UNUSED_ bool is_lazy, bool job_was_done)
 
statement hpfc_lazy_packing (entity array, entity lid, entity(*creation)(), bool pack, bool lazy)
 the lazy issues. More...
 
statement hpfc_compute_lid (entity lid, entity proc, entity(*creation)(), entity array)
 statement st_compute_lid(proc) More...
 

Function Documentation

◆ buffer_full_condition()

static expression buffer_full_condition ( entity  array,
bool  is_send,
bool  is_full 
)
static

generates the condition for testing the buffer state: returns (BUFFER_INDEX.

[eq|ne].BUFFER_[|RCV]SIZE) depending on swtiches. TRUE: is full, FALSE: is not empty

Parameters
is_sendarray for the typed buffer size
is_fullwhile sending or receiving

Definition at line 281 of file generate-util.c.

285 {
286  entity opera, bsize, index;
287 
289  opera = is_full ?
292  bsize = is_send ? is_full ?
294  MakeConstant("0", is_basic_int) :
296 
297  return MakeBinaryCall(opera,
298  entity_to_expression(index),
299  entity_to_expression(bsize));
300 }
entity MakeConstant(string name, tag bt)
Make a Fortran constant.
Definition: constant.c:351
static entity hpfc_buffer_entity(entity array, string suffix)
returns the buffer entity for array
#define BUFFER_RCV_SIZE
#define BUFFER_INDEX
#define BUFSZ
entity hpfc_name_to_entity(const char *)
Definition: run-time.c:817
#define EQUAL_OPERATOR_NAME
#define NON_EQUAL_OPERATOR_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
@ is_basic_int
Definition: ri.h:571
static entity array

References array, BUFFER_INDEX, BUFFER_RCV_SIZE, BUFSZ, entity_intrinsic(), entity_to_expression(), EQUAL_OPERATOR_NAME, hpfc_buffer_entity(), hpfc_name_to_entity(), is_basic_int, MakeBinaryCall(), MakeConstant(), and NON_EQUAL_OPERATOR_NAME.

Referenced by hpfc_broadcast_if_necessary(), and hpfc_lazy_buffer_packing().

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

◆ define_node_processor_id()

statement define_node_processor_id ( entity  proc,
entity(*)(int creation 
)

builds a statement VAR_i = MYPOS(i, proc_number) // i=1 to proc dimension

generate-util.c

of expression

of statement

Parameters
procroc

Definition at line 49 of file generate-util.c.

52 {
53  int i, procn = load_hpf_number(proc);
54  list /* of expression */ mypos_indices,
55  /* of statement */ ls = NIL;
56  reference mypos;
57  entity dummy;
58 
59  for(i=NumberOfDimension(proc); i>0; i--)
60  {
61  dummy = creation(i);
62  mypos_indices = CONS(EXPRESSION, int_to_expression(i),
64  NIL));
65  mypos = make_reference(hpfc_name_to_entity(MYPOS), mypos_indices);
66  ls = CONS(STATEMENT,
69  ls);
70  }
71 
72  return make_block_statement(ls);
73 }
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
int dummy
A dummy file, to prevent empty libraries from breaking builds.
Definition: dummy.c:41
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
statement make_assign_statement(expression, expression)
Definition: statement.c:583
#define MYPOS
intptr_t load_hpf_number(entity)
expression reference_to_expression(reference r)
Definition: expression.c:196
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
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, entity_to_expression(), EXPRESSION, hpfc_name_to_entity(), int_to_expression(), load_hpf_number(), make_assign_statement(), make_block_statement(), make_reference(), MYPOS, NIL, NumberOfDimension(), reference_to_expression(), and STATEMENT.

Referenced by GENERATION(), and processor_loop().

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

◆ generate_deducables()

statement generate_deducables ( list  le)

statement generate_deducables(list le)

the le list of expression is used to generate the deducables. The fields of interest are the variable which is referenced and the normalized field which is the expression that is going to be used to define the variable.

Parameters
leof expression

Definition at line 83 of file generate-util.c.

85 {
86  list rev = gen_nreverse(gen_copy_seq(le)), ls = NIL;
87 
88  MAP(EXPRESSION, e,
89  {
92 
93  ls = CONS(STATEMENT, Pvecteur_to_assign_statement(var, v), ls);
94  },
95  rev);
96 
97  gen_free_list(rev);
98  return make_block_statement(ls);
99 }
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#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
statement Pvecteur_to_assign_statement(entity var, Pvecteur v)
generates var = linear expression from the Pvecteur.
Definition: expression.c:1720
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832
#define reference_variable(x)
Definition: ri.h:2326
#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

References CONS, EXPRESSION, expression_normalized, expression_reference(), gen_copy_seq(), gen_free_list(), gen_nreverse(), make_block_statement(), MAP, NIL, normalized_linear, Pvecteur_to_assign_statement(), reference_variable, and STATEMENT.

Referenced by elements_loop(), generate_io_statements_for_shared_arrays(), and GENERATION().

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

◆ hpfc_add_2()

statement hpfc_add_2 ( expression  exp)

expr = expr + 2

Parameters
expxp

Definition at line 141 of file generate-util.c.

143 {
145  return(make_assign_statement
146  (copy_expression(exp),
147  MakeBinaryCall(plus, exp, int_to_expression(2))));
148 
149 }
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
#define PLUS_OPERATOR_NAME
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References copy_expression(), entity_intrinsic(), exp, int_to_expression(), make_assign_statement(), MakeBinaryCall(), and PLUS_OPERATOR_NAME.

Referenced by hpfc_message().

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

◆ hpfc_add_n()

statement hpfc_add_n ( entity  var,
int  n 
)

returns statement VAR = VAR + N

added value

Parameters
varar
ninteger scalar variable

Definition at line 128 of file generate-util.c.

References entity_intrinsic(), entity_to_expression(), int_to_expression(), make_assign_statement(), MakeBinaryCall(), and PLUS_OPERATOR_NAME.

Referenced by hpfc_buffer_packing().

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

◆ hpfc_broadcast_buffers()

static statement hpfc_broadcast_buffers ( entity  src,
entity  trg,
entity  lid,
entity  proc 
)
static

send the buffer, possibly a broadcast.

unconditional ? if non empty ? generates hpfc_broadcast_x as required. ??? hardwired for remappings... processor related to the array... (redundant!?)

of expression

??? possible replication on sections overlooked here

an argument needed by the special function

Parameters
trgsource array
lidshould be the target array
procbroadcast base, maybe partial?!

Definition at line 344 of file generate-util.c.

349 {
350  Pcontrainte c;
351  int size, npdim, nreplicated;
352  list /* of expression */ args = NIL;
353  bool avoid_twins =
354  get_bool_property("HPFC_GUARDED_TWINS") && replicated_p(src);
355 
356  c = full_linearization(proc, (entity) NULL, &size,
357  get_ith_temporary_dummy, false, 0);
358 
359  npdim = NumberOfDimension(proc);
360 
361  for (nreplicated=0; npdim; npdim--)
362  {
363  if (processors_dim_replicated_p(proc, trg, npdim))
364  {
365  /* ??? possible replication on sections overlooked here */
366  entity v;
367  Value step;
368  int number;
369 
370  nreplicated++;
371  v = get_ith_temporary_dummy(npdim);
372  step = vect_coeff((Variable) v, contrainte_vecteur(c));
373  number = SizeOfIthDimension(proc, npdim);
374 
375  args = CONS(EXPRESSION, int_to_expression(number),
377  args));
378  }
379  }
380 
381  args = CONS(EXPRESSION, entity_to_expression(lid), args);
382 
383  /* an argument needed by the special function */
384  if (avoid_twins)
386  contraintes_free(c);
387 
388  return call_to_statement
389  (make_call(hpfc_ith_broadcast_function(nreplicated, avoid_twins), args));
390 }
call make_call(entity a1, list a2)
Definition: ri.c:269
int Value
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
Pcontrainte contraintes_free(Pcontrainte pc)
Pcontrainte contraintes_free(Pcontrainte pc): desallocation de toutes les contraintes de la liste pc.
Definition: alloc.c:226
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
static entity hpfc_ith_broadcast_function(int dim, bool special)
whether to use the special version
bool replicated_p(entity e)
replicated_p
Definition: hpfc-util.c:96
bool processors_dim_replicated_p(_UNUSED_ entity p, entity a, int i)
true if array a is replicated on processors p i-th dimension.
Definition: hpfc-util.c:143
#define src(name, suf)
HPFC by Fabien Coelho, May 1993 and later...
Definition: compile.c:41
Pcontrainte full_linearization(entity, entity, int *, entity(*)(int), bool, int)
remapping.c
Definition: remapping.c:80
entity get_ith_temporary_dummy(int)
#define call_to_statement(c)
expression Value_to_expression(Value v)
added interface for linear stuff.
Definition: expression.c:1251
int SizeOfIthDimension(entity, int)
this function returns the size of the ith dimension of a variable e.
Definition: size.c:453
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
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 call_to_statement, CONS, contrainte_vecteur, contraintes_free(), entity_to_expression(), EXPRESSION, full_linearization(), get_bool_property(), get_ith_temporary_dummy(), hpfc_ith_broadcast_function(), int_to_expression(), load_hpf_number(), make_call(), NIL, NumberOfDimension(), processors_dim_replicated_p(), replicated_p(), SizeOfIthDimension(), src, Value_to_expression(), and vect_coeff().

Referenced by hpfc_broadcast_if_necessary(), and hpfc_lazy_buffer_packing().

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

◆ hpfc_broadcast_if_necessary()

statement hpfc_broadcast_if_necessary ( entity  array,
entity  trg,
entity  lid,
entity  proc,
bool  is_lazy 
)

lazy or not...

Parameters
arrayrray
trgremapped source array
lidremapped target array
proclid for target processor(s)
is_lazytarget processor

Definition at line 404 of file generate-util.c.

410 {
411  expression not_empty;
412  statement send, pack;
413 
414  not_empty = buffer_full_condition(array, true, false);
415  send = hpfc_broadcast_buffers(array, trg, lid, proc);
417 
418  if (is_lazy)
419  return test_to_statement
420  (make_test(not_empty,
422  CONS(STATEMENT, send, NIL))),
424  else
425  return make_block_statement
426  (CONS(STATEMENT, test_to_statement(make_test(not_empty, pack,
431  NIL)));
432 }
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
static statement hpfc_broadcast_buffers(entity src, entity trg, entity lid, entity proc)
send the buffer, possibly a broadcast.
static expression buffer_full_condition(entity array, bool is_send, bool is_full)
generates the condition for testing the buffer state: returns (BUFFER_INDEX.
statement hpfc_packing_of_current__buffer(entity array, bool pack)
CALL (pvmtype) HPFC {,UN}PACK.
statement make_continue_statement(entity)
Definition: statement.c:953
#define SND_NOT_INIT
#define test_to_statement(t)
#define not_expression(e)
#define entity_undefined
Definition: ri.h:2761

References array, buffer_full_condition(), CONS, entity_to_expression(), entity_undefined, hpfc_broadcast_buffers(), hpfc_name_to_entity(), hpfc_packing_of_current__buffer(), make_block_statement(), make_continue_statement(), make_test(), NIL, not_expression, SND_NOT_INIT, STATEMENT, and test_to_statement.

Referenced by gen().

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

◆ hpfc_buffer_entity()

static entity hpfc_buffer_entity ( entity  array,
string  suffix 
)
static

returns the buffer entity for array

Definition at line 254 of file generate-util.c.

257 {
260  suffix, NULL));
261 }
string pvm_what_options(basic)
string pvm_what_options(b)
Definition: run-time.c:86
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
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

References array, concatenate(), entity_basic(), hpfc_name_to_entity(), and pvm_what_options().

Referenced by buffer_full_condition(), hpfc_buffer_reference(), hpfc_lazy_buffer_packing(), and hpfc_packing_of_current__buffer().

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

◆ hpfc_buffer_initialization()

statement hpfc_buffer_initialization ( bool  is_send,
_UNUSED_ bool  is_lazy,
bool  job_was_done 
)

of statement

set_expression(hpfc_name_to_entity(BUFFER_ENCODING), pvm_encoding_option(2))

Definition at line 492 of file generate-util.c.

496 {
497  statement buffindex, msgstate, other;
498  list /* of statement */ l;
499 
502  (is_send ? SND_NOT_INIT : RCV_NOT_PRF), job_was_done);
503  if (is_send)
505  /* set_expression(hpfc_name_to_entity(BUFFER_ENCODING),
506  pvm_encoding_option(2)) */
507  else
508  other = set_expression
510 
511  l = CONS(STATEMENT, buffindex,
512  CONS(STATEMENT, msgstate,
513  CONS(STATEMENT, other,
514  NIL)));
515 
516  return make_block_statement(l);
517 }
#define set_integer(var, i)
Very Short and very local functions moved to macros, FC 17/05/94.
#define RCV_NOT_PRF
#define set_expression(var, e)
#define set_logical(var, b)

References BUFFER_INDEX, BUFFER_RCV_SIZE, CONS, entity_undefined, hpfc_name_to_entity(), int_to_expression(), make_block_statement(), make_continue_statement(), NIL, RCV_NOT_PRF, set_expression, set_integer, set_logical, SND_NOT_INIT, and STATEMENT.

Referenced by gen(), generate_io_statements_for_shared_arrays(), hpfc_hmessage(), and hpfc_nrecv().

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

◆ hpfc_buffer_packing()

statement hpfc_buffer_packing ( entity  array,
entity(*)()  creation,
bool  pack 
)

array(creation) = buffer(current++) or reverse assignment...

Definition at line 305 of file generate-util.c.

309 {
310  entity index;
311  expression array_ref, buffer_ref;
312  statement increment, assignment;
313 
315  array_ref = make_reference_expression(array, creation);
316  buffer_ref = hpfc_buffer_reference(array, index);
317  increment = hpfc_add_n(index, 1);
318  assignment = make_assign_statement(pack ? buffer_ref : array_ref,
319  pack ? array_ref : buffer_ref);
320 
321  return make_block_statement(CONS(STATEMENT, increment,
323  NIL)));
324 }
struct _newgen_struct_assignment_ * assignment
Definition: eole_private.h:29
statement hpfc_add_n(entity var, int n)
returns statement VAR = VAR + N
expression make_reference_expression(entity e, entity(*creation)())
expression hpfc_buffer_reference(entity array, entity index)
returns a reference to the typed common hpfc_buffer buffer, that suits array basic type and with inde...

References array, BUFFER_INDEX, CONS, hpfc_add_n(), hpfc_buffer_reference(), hpfc_name_to_entity(), make_assign_statement(), make_block_statement(), make_reference_expression(), NIL, and STATEMENT.

Referenced by generate_io_statements_for_shared_arrays(), hpfc_lazy_buffer_packing(), and hpfc_lazy_packing().

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

◆ hpfc_buffer_reference()

expression hpfc_buffer_reference ( entity  array,
entity  index 
)

returns a reference to the typed common hpfc_buffer buffer, that suits array basic type and with index as an index.

index variable

Parameters
arrayrray
indexarray to select the right typed buffer

Definition at line 267 of file generate-util.c.

270 {
274  NIL)));
275 }
#define BUFFER
common /hpfc_buffers/

References array, BUFFER, CONS, entity_to_expression(), EXPRESSION, hpfc_buffer_entity(), make_reference(), NIL, and reference_to_expression().

Referenced by hpfc_buffer_packing().

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

◆ hpfc_compute_lid()

statement hpfc_compute_lid ( entity  lid,
entity  proc,
entity(*)()  creation,
entity  array 
)

statement st_compute_lid(proc)

  T_LID=CMP_LID(pn, pi...)

if array is not NULL, partial according to array. the offset is shifted as if proc dimensions were normalized, in order to match the runtime library hpfc_broadcast_* expectations. to be used for partial (broadcasts...)

remove distributed dimensions from the constraint and normalize the partial system so that dims are 0:...

Parameters
procvariable to be assigned to
creationprocessor arrangement
arrayindividual variables

Definition at line 553 of file generate-util.c.

558 {
559  if (!get_bool_property("HPFC_EXPAND_CMPLID"))
560  {
561  int ndim = NumberOfDimension(proc);
563 
564  pips_assert("implemented", !array);
565 
569  gen_nconc(hpfc_gen_n_vars_expr(creation, ndim),
570  make_list_of_constant(0, 7-ndim)))));
571  }
572  else
573  {
574  int size;
575  Pcontrainte c;
576  Pvecteur v;
577  statement result;
578 
579  c = full_linearization(proc, lid, &size, creation, false, 1);
580  v = contrainte_vecteur(c);
581 
582  if (array)
583  {
584  /* remove distributed dimensions from the constraint
585  * and normalize the partial system so that dims are 0:...
586  */
587  int npdim;
588  pips_assert("defined", array && !entity_undefined_p(array));
589 
590  for(npdim = NumberOfDimension(proc); npdim; npdim--)
591  if (processors_dim_replicated_p(proc, array, npdim))
592  {
593  Variable var = (Variable) creation(npdim);
594  int low, up;
595  Value cf, vlow;
596 
597  get_entity_dimensions(proc, npdim, &low, &up);
598  cf = vect_coeff(var, v);
599  vlow = int_to_value(low);
601  value_uminus(cf));
603  value_mult(cf,vlow));
604  }
605  }
606 
608  contraintes_free(c);
609 
610  return result;
611  }
612 }
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define value_uminus(val)
unary operators on values
#define value_mult(v, w)
whether the default is protected or not this define makes no sense any more...
list hpfc_gen_n_vars_expr(entity(*creation)(), int number)
of expression
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
void get_entity_dimensions(entity e, int dim, int *plow, int *pup)
Definition: hpfc-util.c:651
#define CMP_LID
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
expression make_call_expression(entity e, list l)
Build an expression that call an function entity with an argument list.
Definition: expression.c:321
list make_list_of_constant(int val, int number)
of expression
Definition: expression.c:3369
#define entity_undefined_p(x)
Definition: ri.h:2762
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72

References array, CMP_LID, CONS, contrainte_vecteur, contraintes_free(), entity_to_expression(), entity_undefined_p, EXPRESSION, full_linearization(), gen_nconc(), get_bool_property(), get_entity_dimensions(), hpfc_gen_n_vars_expr(), hpfc_name_to_entity(), int_to_expression(), int_to_value, load_hpf_number(), make_assign_statement(), make_call_expression(), make_list_of_constant(), NumberOfDimension(), pips_assert, processors_dim_replicated_p(), Pvecteur_to_assign_statement(), TCST, value_mult, value_uminus, vect_add_elem(), and vect_coeff().

Referenced by broadcast(), hpfc_hmessage(), and processor_loop().

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

◆ hpfc_gen_n_vars_expr()

list hpfc_gen_n_vars_expr ( entity(*)()  creation,
int  number 
)

of expression

Definition at line 102 of file generate-util.c.

105 {
106  list result = NIL;
107  pips_assert("valid dimension number", number>=0 && number<=7);
108 
109  for(; number>0; number--)
110  result = CONS(EXPRESSION, entity_to_expression(creation(number)),
111  result);
112 
113  return result;
114 }

References CONS, entity_to_expression(), EXPRESSION, NIL, and pips_assert.

Referenced by hpfc_compute_lid(), and make_reference_expression().

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

◆ hpfc_generate_message()

statement hpfc_generate_message ( entity  ld,
bool  send,
bool  lazy 
)
Parameters
ldd
sendend
lazyazy

Definition at line 208 of file generate-util.c.

212 {
213  entity nc, nt;
214  expression lid, tid, chn;
215 
218  lid = entity_to_expression(ld);
220  (make_reference(nt, CONS(EXPRESSION, lid, NIL)));
223 
224  return lazy ? hpfc_lazy_message(tid, chn, send) :
225  hpfc_message(tid, chn, send);
226 }
statement hpfc_message(expression tid, expression channel, bool send)
static statement hpfc_lazy_message(expression tid, expression channel, bool snd)
IF (LAZY_snd) THEN PVMFsnd() LAZY_snd = false // if receive ENDIF.
#define SEND_CHANNELS
#define NODETIDS
#define RECV_CHANNELS

References CONS, copy_expression(), entity_to_expression(), EXPRESSION, hpfc_lazy_message(), hpfc_message(), hpfc_name_to_entity(), make_reference(), NIL, NODETIDS, RECV_CHANNELS, reference_to_expression(), and SEND_CHANNELS.

Referenced by broadcast(), gen(), and hpfc_lazy_packing().

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

◆ hpfc_initsend()

statement hpfc_initsend ( bool  lazy)

2 args to pvmfinitsend

Parameters
lazyazy

Definition at line 229 of file generate-util.c.

231 {
232  statement init;
233 
234  /* 2 args to pvmfinitsend
235  */
240  NIL)));
241 
242  return lazy ? make_block_statement
243  (CONS(STATEMENT, init,
245  NIL))) :
246  init ;
247 }
static expression pvm_encoding_option(int n)
HPFC module by Fabien COELHO.
Definition: generate-util.c:33
#define PVM_INITSEND
PVM functions that may be called by the generated code.
#define LAZY_SEND
#define BUFID
statement hpfc_make_call_statement(entity, list)
statement hpfc_make_call_statement(e, l) generate a call statement to function e, with expression lis...
Definition: run-time.c:318
static int init
Maximal value set for Fortran 77.
Definition: entity.c:320

References BUFID, CONS, entity_to_expression(), EXPRESSION, hpfc_make_call_statement(), hpfc_name_to_entity(), init, LAZY_SEND, make_block_statement(), NIL, pvm_encoding_option(), PVM_INITSEND, set_logical, and STATEMENT.

Referenced by gen().

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

◆ hpfc_ith_broadcast_function()

static entity hpfc_ith_broadcast_function ( int  dim,
bool  special 
)
static

whether to use the special version

??? static buffer size

Parameters
specialnumber of dimensions of the broadcast

Definition at line 327 of file generate-util.c.

330 {
331  char *buffer; /* ??? static buffer size */
332  asprintf(&buffer, "%s%d", special? GUARDED_BRD: BROADCAST, dim);
334  free(buffer);
335  return e;
336 }
void free(void *)
#define GUARDED_BRD
#define BROADCAST
entity MakeRunTimeSupportSubroutine(string, int)
run-time.c
#define asprintf
Definition: misc-local.h:225
static string buffer
Definition: string.c:113

References asprintf, BROADCAST, buffer, free(), GUARDED_BRD, and MakeRunTimeSupportSubroutine().

Referenced by hpfc_broadcast_buffers().

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

◆ hpfc_lazy_buffer_packing()

statement hpfc_lazy_buffer_packing ( entity  src,
entity  trg,
entity  lid,
entity  proc,
entity(*)()  array_dim,
bool  is_send,
bool  is_lazy 
)

lazy in actually sending or not the packed buffer immediatly...

means you send the buffer directly, without packing...

of statement

array being manipulated

CALL HPFC PACK/UNPACK

BUF INDEX=0

Parameters
trgsource array
lidtarget array
proclocal id for base target
array_dimthe processors, needed for broadcasts
is_sendvariables for array dimensions
is_lazysend or receive ?

Definition at line 437 of file generate-util.c.

445 {
446  statement packing, realpack, indexeq0, ifcond, optional;
447  expression condition;
448  list /* of statement */ l;
449  entity array; /* array being manipulated */
450 
451  array = is_send ? src : trg;
452  packing = hpfc_buffer_packing(array, array_dim, is_send);
453  condition = buffer_full_condition(array, is_send, true);
454 
455  /* CALL HPFC PACK/UNPACK
456  */
457  realpack = call_to_statement
459  is_send ? NIL : CONS(EXPRESSION, entity_to_expression(lid), NIL)));
460 
461  /* BUF INDEX=0
462  */
464  optional = is_lazy ?
465  is_send ? hpfc_broadcast_buffers(array, trg, lid, proc) :
468 
469  if (is_send)
470  l = CONS(STATEMENT, realpack,
471  CONS(STATEMENT, optional,
472  CONS(STATEMENT, indexeq0,
473  is_lazy?
475  true), NIL): NIL)));
476  else
477  l = CONS(STATEMENT, optional,
478  CONS(STATEMENT, realpack,
479  CONS(STATEMENT, indexeq0, NIL)));
480 
481  ifcond = test_to_statement
482  (make_test(condition,
485 
486  return make_block_statement
487  (is_send ? CONS(STATEMENT, packing, CONS(STATEMENT, ifcond, NIL)) :
488  CONS(STATEMENT, ifcond, CONS(STATEMENT, packing, NIL)));
489 }
statement hpfc_buffer_packing(entity array, entity(*creation)(), bool pack)
array(creation) = buffer(current++) or reverse assignment...
#define BUFPCK
hpfc packing and unpacking
#define BUFUPK
#define true
Definition: newgen_types.h:81

References array, buffer_full_condition(), BUFFER_INDEX, BUFPCK, BUFUPK, call_to_statement, CONS, entity_to_expression(), entity_undefined, EXPRESSION, hpfc_broadcast_buffers(), hpfc_buffer_entity(), hpfc_buffer_packing(), hpfc_name_to_entity(), make_block_statement(), make_call(), make_continue_statement(), make_test(), NIL, RCV_NOT_PRF, set_integer, set_logical, SND_NOT_INIT, src, STATEMENT, and test_to_statement.

Referenced by gen().

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

◆ hpfc_lazy_guard()

statement hpfc_lazy_guard ( bool  snd,
statement  then 
)

returns if (LAZY_{SEND,RECV}) then

Parameters
sndnd
thenhen

Definition at line 176 of file generate-util.c.

179 {
180  entity decision = hpfc_name_to_entity(snd ? LAZY_SEND : LAZY_RECV);
181  return test_to_statement
183 }
#define LAZY_RECV
#define make_empty_statement
An alias for make_empty_block_statement.

References entity_to_expression(), hpfc_name_to_entity(), LAZY_RECV, LAZY_SEND, make_empty_statement, make_test(), and test_to_statement.

Referenced by broadcast(), and hpfc_lazy_message().

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

◆ hpfc_lazy_message()

static statement hpfc_lazy_message ( expression  tid,
expression  channel,
bool  snd 
)
static

IF (LAZY_snd) THEN PVMFsnd() LAZY_snd = false // if receive ENDIF.

Definition at line 191 of file generate-util.c.

195 {
196  entity decision = hpfc_name_to_entity(snd ? LAZY_SEND : LAZY_RECV);
197  statement
198  comm = hpfc_message(tid, channel, snd),
199  then = snd ? comm :
201  CONS(STATEMENT, set_logical(decision, false),
202  NIL))) ;
203 
204  return hpfc_lazy_guard(snd, then);
205 }
statement hpfc_lazy_guard(bool snd, statement then)
returns if (LAZY_{SEND,RECV}) then

References CONS, hpfc_lazy_guard(), hpfc_message(), hpfc_name_to_entity(), LAZY_RECV, LAZY_SEND, make_block_statement(), NIL, set_logical, and STATEMENT.

Referenced by hpfc_generate_message().

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

◆ hpfc_lazy_packing()

statement hpfc_lazy_packing ( entity  array,
entity  lid,
entity(*)()  creation,
bool  pack,
bool  lazy 
)

the lazy issues.

note that target processors should be known to generate the appropriate broadcast?

Definition at line 524 of file generate-util.c.

530 {
531  statement pack_stmt = hpfc_buffer_packing(array, creation, pack);
532 
533  return lazy ? (pack ? make_block_statement
534  (CONS(STATEMENT, pack_stmt,
536  NIL))) :
539  CONS(STATEMENT, pack_stmt,
540  NIL)))) : pack_stmt ;
541 }
statement hpfc_generate_message(entity ld, bool send, bool lazy)
#define false
Definition: newgen_types.h:80

References array, CONS, hpfc_buffer_packing(), hpfc_generate_message(), hpfc_name_to_entity(), LAZY_SEND, make_block_statement(), NIL, set_logical, and STATEMENT.

Referenced by gen().

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

◆ hpfc_message()

statement hpfc_message ( expression  tid,
expression  channel,
bool  send 
)
Parameters
tidid
channelhannel
sendend

Definition at line 152 of file generate-util.c.

156 {
157  expression third;
158  entity pvmf;
159 
161  pvmf = hpfc_name_to_entity(send ? PVM_SEND : PVM_RECV);
162 
163  return make_block_statement
165  CONS(EXPRESSION, tid,
166  CONS(EXPRESSION, channel,
167  CONS(EXPRESSION, third,
168  NIL)))),
170  NIL)));
171 }
statement hpfc_add_2(expression exp)
expr = expr + 2
#define PVM_RECV
#define PVM_SEND
#define INFO

References BUFID, CONS, copy_expression(), entity_to_expression(), EXPRESSION, hpfc_add_2(), hpfc_make_call_statement(), hpfc_name_to_entity(), INFO, make_block_statement(), NIL, PVM_RECV, PVM_SEND, and STATEMENT.

Referenced by hpfc_generate_message(), and hpfc_lazy_message().

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

◆ hpfc_packing_of_current__buffer()

statement hpfc_packing_of_current__buffer ( entity  array,
bool  pack 
)

CALL (pvmtype) HPFC {,UN}PACK.

Parameters
arrayrray
packack

Definition at line 395 of file generate-util.c.

398 {
401 }

References array, BUFPCK, BUFUPK, hpfc_buffer_entity(), hpfc_make_call_statement(), and NIL.

Referenced by hpfc_broadcast_if_necessary(), hpfc_hcast(), hpfc_hmessage(), hpfc_nrecv(), and hpfc_nsend().

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

◆ make_reference_expression()

expression make_reference_expression ( entity  e,
entity(*)()  creation 
)

Definition at line 117 of file generate-util.c.

120 {
122  hpfc_gen_n_vars_expr(creation, NumberOfDimension(e))));
123 }

References hpfc_gen_n_vars_expr(), make_reference(), NumberOfDimension(), and reference_to_expression().

Referenced by gen(), and hpfc_buffer_packing().

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

◆ pvm_encoding_option()

static expression pvm_encoding_option ( int  n)
static

HPFC module by Fabien COELHO.

Definition at line 33 of file generate-util.c.

34 {
35  static const string option[] =
36  {
37  "PvmDataDefault",
38  "PvmDataRaw",
39  "PvmDataInPlace"
40  };
41 
42  return MakeCharacterConstantExpression(option[n]);
43 }
expression MakeCharacterConstantExpression(string s)
END_EOLE.
Definition: constant.c:573

References MakeCharacterConstantExpression().

Referenced by hpfc_initsend().

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