PIPS
remapping.c File Reference
#include "defines-local.h"
#include "prettyprint.h"
#include "conversion.h"
#include "resources.h"
#include "pipsdbm.h"
+ Include dependency graph for remapping.c:

Go to the source code of this file.

Macros

#define CPY   0
 in the following functions tag t controls the code generation, depending of what is to be generated (send, receive, copy, broadcast)... More...
 
#define SND   1
 
#define RCV   2
 
#define BRD   3
 
#define PRE   0
 
#define INL   4
 
#define PST   8
 
#define NLZ   0
 
#define LZY   16
 
#define NBF   0
 
#define BUF   32
 
#define ret(name)   result = name; break
 I have to deal with a 4D space to generate some code: More...
 

Functions

static Pcontrainte partial_linearization (entity array, bool distributed, entity var, int *psize, entity(*create_var)(int))
 HPFC module by Fabien COELHO. More...
 
Pcontrainte full_linearization (entity obj, entity var, int *psize, entity(*create_var)(int), bool fortran_way, int initial_offset)
 builds a linarization equation of the dimensions of obj. More...
 
static Psysteme generate_work_sharing_system (entity src, entity trg)
 load-balancing equation as suggested in the A-274 report. More...
 
static Psysteme generate_remapping_system (entity src, entity trg)
 returns the full remapping system, including the source and target mappings systems, the link and the work sharing system More...
 
static void remapping_variables (Psysteme s, entity a1, entity a2, list *pl, list *plp, list *pll, list *plrm, list *pld, list *plo)
 ??? assumes that there are no parameters. More...
 
static statement processor_loop (Psysteme s, _UNUSED_ list l_psi, list l_oth, entity psi, entity oth, entity lid, entity array, entity(*create_psi)(), entity(*create_oth)(), statement body, bool sh)
 to be generated: ??? the Proc cycle should be deduce directly in some case... More...
 
static statement elements_loop (Psysteme s, list ll, list ld, statement body)
 to be generated: More...
 
static expression mylid_ne_lid (entity lid)
 
static statement if_different_pe_and_not_twin (entity src, entity lid, statement strue, statement sfalse)
 to be generated: IF (MYLID.NE.LID[.AND.NOT.HPFC_TWIN_P(an, LID)]) THEN true ELSE false ENDIF More...
 
static statement broadcast (entity src, entity lid, entity proc, Psysteme sr, list ldiff, bool lazy)
 builds the diffusion loop. More...
 
static statement gen (int what, entity src, entity trg, entity lid, entity proc, entity(*create_src)(), entity(*create_trg)(), Psysteme sr, list ldiff)
 arguments: all that may be useful to generate some code More...
 
static statement remapping_stats (int t, Psysteme s, Psysteme sr, list ll, list ldiff, list ld, entity lid, entity src, entity trg)
 generates a remapping loop nest (copy/send/receive/broadcast) basically a loop on elements with pre/in/post statements... More...
 
static statement generate_remapping_code (entity src, entity trg, Psysteme procs, Psysteme locals, list l, list lp, list ll, list ldiff, list ld, bool dist_p)
 generates a full remapping code, given the systems and indexes to be used in the different loops. More...
 
static expression live_mapping_expression (int index)
 returns LIVEMAPPING(index) More...
 
static statement set_array_status_to_target (entity trg)
 
static statement set_live_status (entity trg, _UNUSED_ bool val)
 
static statement update_runtime_for_remapping (entity trg)
 
static statement generate_remapping_guard (entity src, entity trg, statement the_code)
 Runtime descriptors management around the remapping code. More...
 
static statement generate_all_liveness_but (entity primary, bool val, entity butthisone)
 
statement generate_all_liveness (entity primary, bool val)
 
static statement generate_dynamic_liveness_for_primary (entity primary, list tokeep)
 
static statement generate_dynamic_liveness_management (statement s)
 
static statement hpf_remapping (entity src, entity trg)
 remaps src to trg. More...
 
static string remapping_file_name (renaming remap)
 file name for storing the remapping code. More...
 
static void loop_rwt (loop l)
 
static void reference_rwt (reference r)
 
static list list_of_referenced_entities (statement s)
 
static text protected_text_statement (statement s)
 
static void generate_hpf_remapping_file (renaming r)
 
static statement generate_remapping_include (renaming r)
 just a hack because pips does not have 'include' More...
 
statement root_statement_remapping_inits (statement root)
 returns the initialization statement: must initialize the status and liveness of arrays More...
 
void remapping_compile (statement s, statement *hsp, statement *nsp)
 void remapping_compile(s, hsp, nsp) statement s, *hsp, *nsp; More...
 

Variables

static list l_found
 quick recursion to find the entities referenced in a statement. More...
 

Macro Definition Documentation

◆ BRD

#define BRD   3

Definition at line 473 of file remapping.c.

◆ BUF

#define BUF   32

Definition at line 483 of file remapping.c.

◆ CPY

#define CPY   0

in the following functions tag t controls the code generation, depending of what is to be generated (send, receive, copy, broadcast)...

tag t may have the following values:

Definition at line 470 of file remapping.c.

◆ INL

#define INL   4

Definition at line 476 of file remapping.c.

◆ LZY

#define LZY   16

Definition at line 480 of file remapping.c.

◆ NBF

#define NBF   0

Definition at line 482 of file remapping.c.

◆ NLZ

#define NLZ   0

Definition at line 479 of file remapping.c.

◆ PRE

#define PRE   0

Definition at line 475 of file remapping.c.

◆ PST

#define PST   8

Definition at line 477 of file remapping.c.

◆ RCV

#define RCV   2

Definition at line 472 of file remapping.c.

◆ ret

#define ret (   name)    result = name; break

I have to deal with a 4D space to generate some code:

buffer/nobuf lazy/nolazy

pre/in/post cpy/snd/rcv/brd

Definition at line 494 of file remapping.c.

◆ SND

#define SND   1

Definition at line 471 of file remapping.c.

Function Documentation

◆ broadcast()

static statement broadcast ( entity  src,
entity  lid,
entity  proc,
Psysteme  sr,
list  ldiff,
bool  lazy 
)
static

builds the diffusion loop.

[ IF (LAZY_SEND) THEN ] DO ldiff in sr LID computation(...) IF (MYLID.NE.LID) send to LID ENDDO [ ENDIF ] whether to send empty messages

Parameters
lidsource array
procvariable to store the target local id
srtarget processors for the broadcast
ldiffbroadcast polyhedron of entity
lazydimension variables for the broadcast

Definition at line 442 of file remapping.c.

449 {
450  statement cmp_lid, body, nest;
451 
452  cmp_lid = hpfc_compute_lid(lid, proc, (entity(*)())get_ith_processor_prime, NULL);
453  body = make_block_statement
454  (CONS(STATEMENT, cmp_lid,
456  (src, lid, hpfc_generate_message(lid, true, false),
458  NIL)));
459 
460  nest = systeme_to_loop_nest(sr, ldiff, body, hpfc_name_to_entity(IDIVIDE));
461 
462  return lazy ? hpfc_lazy_guard(true, nest) : nest ;
463 }
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
statement systeme_to_loop_nest(Psysteme, list, statement, entity)
sc is used to generate the loop nest bounds for variables vars.
statement hpfc_compute_lid(entity lid, entity proc, entity(*creation)(), entity array)
statement st_compute_lid(proc)
statement hpfc_lazy_guard(bool snd, statement then)
returns if (LAZY_{SEND,RECV}) then
statement hpfc_generate_message(entity ld, bool send, bool lazy)
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
#define src(name, suf)
HPFC by Fabien Coelho, May 1993 and later...
Definition: compile.c:41
#define IDIVIDE
entity hpfc_name_to_entity(const char *)
Definition: run-time.c:817
entity get_ith_processor_prime(int)
static statement if_different_pe_and_not_twin(entity src, entity lid, statement strue, statement sfalse)
to be generated: IF (MYLID.NE.LID[.AND.NOT.HPFC_TWIN_P(an, LID)]) THEN true ELSE false ENDIF
Definition: remapping.c:408
#define make_empty_statement
An alias for make_empty_block_statement.
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References CONS, get_ith_processor_prime(), hpfc_compute_lid(), hpfc_generate_message(), hpfc_lazy_guard(), hpfc_name_to_entity(), IDIVIDE, if_different_pe_and_not_twin(), make_block_statement(), make_empty_statement, NIL, src, STATEMENT, and systeme_to_loop_nest().

Referenced by gen().

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

◆ elements_loop()

static statement elements_loop ( Psysteme  s,
list  ll,
list  ld,
statement  body 
)
static

to be generated:

DO ll's in S(ll)[...] DEDUCABLES(ld) body ENDDO loop body

Parameters
lltriangular bounds on ll of entities
ldloop indexes of expressions
bodydeduced scalars

Definition at line 381 of file remapping.c.

386 {
387  return systeme_to_loop_nest(s, ll,
389  CONS(STATEMENT, body,
390  NIL))),
392 }
statement generate_deducables(list le)
statement generate_deducables(list le)
Definition: generate-util.c:83

References CONS, generate_deducables(), hpfc_name_to_entity(), IDIVIDE, make_block_statement(), NIL, STATEMENT, and systeme_to_loop_nest().

Referenced by remapping_stats().

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

◆ full_linearization()

Pcontrainte full_linearization ( entity  obj,
entity  var,
int psize,
entity(*)(int create_var,
bool  fortran_way,
int  initial_offset 
)

builds a linarization equation of the dimensions of obj.

remapping.c

var is set to the result. *psize returns the size of obj. Done the Fortran way, or the other way around... initial offset if desired

Parameters
objbj
vararray being lin.
psizeassigned variable if desired
create_varreturned array extent
fortran_waydimension variable builder
initial_offsetFortran/C linearization way

Definition at line 80 of file remapping.c.

87 {
88  int dim = NumberOfDimension(obj), low, up, size, i;
90 
91  for(*psize=1, i=fortran_way ? dim : 1 ;
92  fortran_way ? i>0 : i<=dim;
93  i+= fortran_way ? -1 : 1)
94  {
95  get_entity_dimensions(obj, i, &low, &up);
96  size = up - low + 1;
97  *psize *= size;
98  v = vect_multiply(v, int_to_value(size));
99  vect_add_elem(&v, (Variable) create_var(i), VALUE_ONE);
100  vect_add_elem(&v, TCST, int_to_value(-low));
101  }
102 
103  if (var) vect_add_elem(&v, (Variable) var, VALUE_MONE);
104  if (initial_offset)
105  vect_add_elem(&v, TCST,
106  int_to_value(initial_offset));
107 
108  return contrainte_make(v);
109 }
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define VALUE_MONE
#define VALUE_ONE
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
void get_entity_dimensions(entity e, int dim, int *plow, int *pup)
Definition: hpfc-util.c:651
int NumberOfDimension(entity)
Definition: size.c:588
Pvecteur vect_multiply(Pvecteur v, Value x)
Pvecteur vect_multiply(Pvecteur v, Value x): multiplication du vecteur v par le scalaire x,...
Definition: scalaires.c:123
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 VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
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
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 contrainte_make(), get_entity_dimensions(), int_to_value, NumberOfDimension(), TCST, VALUE_MONE, VALUE_ONE, vect_add_elem(), vect_multiply(), and VECTEUR_NUL.

Referenced by hpfc_broadcast_buffers(), and hpfc_compute_lid().

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

◆ gen()

static statement gen ( int  what,
entity  src,
entity  trg,
entity  lid,
entity  proc,
entity(*)()  create_src,
entity(*)()  create_trg,
Psysteme  sr,
list  ldiff 
)
static

arguments: all that may be useful to generate some code

cpy pre/post rcv post nbuf

snd.brd pre nbuf

cpy inl

snd/brd inl nbf

send!

receive!

snd/rcv pre buf

send!

receive!

default is a forgotten case, I guess

to avoid a gcc warning

Parameters
ldiffof entity

Definition at line 498 of file remapping.c.

502 {
503  statement result;
504  bool is_lazy = what & LZY,
505  is_buff = what & BUF;
506 
507  switch (what)
508  {
509  /* cpy pre/post
510  * rcv post nbuf
511  */
512  case CPY+PRE:
513  case CPY+PST:
514  case CPY+PRE+LZY:
515  case CPY+PST+LZY:
516  case CPY+PRE+BUF:
517  case CPY+PST+BUF:
518  case CPY+PRE+LZY+BUF:
519  case CPY+PST+LZY+BUF:
520  case RCV+PST:
521  case RCV+PST+LZY:
522  case RCV+PST+BUF:
523  case RCV+PST+LZY+BUF:
525 
526  /* snd.brd pre nbuf
527  */
528  case SND+PRE:
529  case BRD+PRE:
530  case SND+PRE+LZY:
531  case BRD+PRE+LZY:
532  ret(hpfc_initsend(is_lazy));
533 
534  case RCV+PRE+LZY:
536 
537  case RCV+PRE:
538  ret(hpfc_generate_message(lid, false, false));
539 
540  /* cpy inl
541  */
542  case CPY+INL:
543  case CPY+INL+LZY:
544  case CPY+INL+BUF:
545  case CPY+INL+LZY+BUF:
547  make_reference_expression(src, create_src)));
548 
549  /* snd/brd inl nbf
550  */
551  case SND+INL:
552  case BRD+INL:
553  case SND+INL+LZY:
554  case BRD+INL+LZY:
555  ret(hpfc_lazy_packing(src, lid, create_src, true, is_lazy));
556 
557  case SND+INL+BUF:
558  case SND+INL+LZY+BUF:
559  case BRD+INL+BUF:
560  case BRD+INL+LZY+BUF:
561  ret(hpfc_lazy_buffer_packing(src, trg, lid, proc, create_src,
562  true /* send! */, is_lazy));
563  case RCV+INL+BUF:
564  case RCV+INL+LZY+BUF:
565  ret(hpfc_lazy_buffer_packing(src, trg, lid, proc, create_trg,
566  false /* receive! */, is_lazy));
567  case RCV+INL:
568  case RCV+INL+LZY:
569  ret(hpfc_lazy_packing(trg, lid, create_trg, false, is_lazy));
570 
571  case SND+PST:
572  case SND+PST+LZY:
573  ret(hpfc_generate_message(lid, true, is_lazy));
574 
575  case BRD+PST:
576  case BRD+PST+LZY:
577  ret(broadcast(src, lid, proc, sr, ldiff, is_lazy));
578 
579  case SND+PST+BUF:
580  case SND+PST+LZY+BUF:
581  case BRD+PST+BUF:
582  case BRD+PST+LZY+BUF:
583  ret(hpfc_broadcast_if_necessary(src, trg, lid, proc, is_lazy));
584 
585  /* snd/rcv pre buf
586  */
587  case SND+PRE+BUF:
588  case SND+PRE+LZY+BUF:
589  case BRD+PRE+BUF:
590  case BRD+PRE+LZY+BUF:
591  ret(hpfc_buffer_initialization(true /* send! */, is_lazy, true));
592  case RCV+PRE+BUF:
593  case RCV+PRE+LZY+BUF:
594  ret(hpfc_buffer_initialization(false /* receive! */, is_lazy, true));
595 
596  /* default is a forgotten case, I guess
597  */
598  default:
599  pips_internal_error("invalid tag %d", what);
600  ret(statement_undefined); /* to avoid a gcc warning */
601  }
602 
603  pips_debug(7, "tag is %d (%s, %s)\n", what,
604  is_lazy ? "lazy" : "not lazy",
605  is_buff ? "bufferized" : "not bufferized");
606  DEBUG_STAT(7, "returning", result);
607 
608  return result;
609 }
statement hpfc_lazy_packing(entity array, entity lid, entity(*creation)(), bool pack, bool lazy)
the lazy issues.
expression make_reference_expression(entity e, entity(*creation)())
statement hpfc_initsend(bool lazy)
statement hpfc_buffer_initialization(bool is_send, _UNUSED_ bool is_lazy, bool job_was_done)
statement hpfc_broadcast_if_necessary(entity array, entity trg, entity lid, entity proc, bool is_lazy)
lazy or not...
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...
statement make_assign_statement(expression, expression)
Definition: statement.c:583
#define LAZY_RECV
#define DEBUG_STAT(D, W, S)
#define set_logical(var, b)
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_internal_error
Definition: misc-local.h:149
#define LZY
Definition: remapping.c:480
#define BUF
Definition: remapping.c:483
#define PRE
Definition: remapping.c:475
#define RCV
Definition: remapping.c:472
#define CPY
in the following functions tag t controls the code generation, depending of what is to be generated (...
Definition: remapping.c:470
static statement broadcast(entity src, entity lid, entity proc, Psysteme sr, list ldiff, bool lazy)
builds the diffusion loop.
Definition: remapping.c:442
#define PST
Definition: remapping.c:477
#define SND
Definition: remapping.c:471
#define BRD
Definition: remapping.c:473
#define INL
Definition: remapping.c:476
#define ret(name)
I have to deal with a 4D space to generate some code:
Definition: remapping.c:494
#define statement_undefined
Definition: ri.h:2419

References BRD, broadcast(), BUF, CPY, DEBUG_STAT, hpfc_broadcast_if_necessary(), hpfc_buffer_initialization(), hpfc_generate_message(), hpfc_initsend(), hpfc_lazy_buffer_packing(), hpfc_lazy_packing(), hpfc_name_to_entity(), INL, LAZY_RECV, LZY, make_assign_statement(), make_empty_statement, make_reference_expression(), pips_debug, pips_internal_error, PRE, PST, RCV, ret, set_logical, SND, src, and statement_undefined.

Referenced by compute_points_to_gen_set(), genref_any_loop(), genref_one_statement(), kill_effects(), list_assignment_to_points_to(), points_to_anywhere(), points_to_anywhere_typed(), points_to_nowhere(), and remapping_stats().

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

◆ generate_all_liveness()

statement generate_all_liveness ( entity  primary,
bool  val 
)
Parameters
primaryrimary
valal

Definition at line 940 of file remapping.c.

943 {
944  return generate_all_liveness_but(primary, val, entity_undefined);
945 }
static statement generate_all_liveness_but(entity primary, bool val, entity butthisone)
Definition: remapping.c:906
#define entity_undefined
Definition: ri.h:2761

References entity_undefined, and generate_all_liveness_but().

Referenced by hpf_compile_call(), and root_statement_remapping_inits().

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

◆ generate_all_liveness_but()

static statement generate_all_liveness_but ( entity  primary,
bool  val,
entity  butthisone 
)
static

of statement

LIVEMAPPING(array) = val (.TRUE. or .FALSE.)

commented result

Definition at line 906 of file remapping.c.

910 {
911  statement result;
912  list /* of statement */ ls = NIL;
913 
914  MAP(ENTITY, array,
915  {
916  /* LIVEMAPPING(array) = val (.TRUE. or .FALSE.)
917  */
918  if (array != butthisone)
919  ls = CONS(STATEMENT,
922  bool_to_expression(val)), ls);
923  },
924  entities_list(load_dynamic_hpf(primary)));
925 
926  /* commented result
927  */
928  result = make_block_statement(ls);
929  {
930  string comment =
931  strdup(concatenate("! all livenesss for ",
932  entity_local_name(primary), "\n", NULL));
934  free(comment);
935  }
936  return result;
937 }
static void comment(string_buffer code, spoc_hardware_type hw, dagvtx v, int stage, int side, bool flip)
Definition: freia_spoc.c:52
void free(void *)
#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 insert_comments_to_statement(statement, const char *)
Insert a comment string (if non empty) at the beginning of the comments of a statement.
Definition: statement.c:1916
#define entities_list(x)
Definition: hpf_private.h:414
entities load_dynamic_hpf(entity)
intptr_t load_hpf_number(entity)
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
static expression live_mapping_expression(int index)
returns LIVEMAPPING(index)
Definition: remapping.c:793
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
expression bool_to_expression(bool b)
Definition: expression.c:1238
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
char * strdup()
static entity array
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References array, bool_to_expression(), comment(), concatenate(), CONS, entities_list, ENTITY, entity_local_name(), free(), insert_comments_to_statement(), live_mapping_expression(), load_dynamic_hpf(), load_hpf_number(), make_assign_statement(), make_block_statement(), MAP, NIL, STATEMENT, and strdup().

Referenced by generate_all_liveness().

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

◆ generate_dynamic_liveness_for_primary()

static statement generate_dynamic_liveness_for_primary ( entity  primary,
list  tokeep 
)
static

of statement

clean not maybeuseful instances of the primary

LIVEMAPPING(array) = .FALSE.

commented result

Parameters
tokeepof entity

Definition at line 948 of file remapping.c.

951 {
952  statement result;
953  list /* of statement */ ls = NIL;
954 
955  /* clean not maybeuseful instances of the primary
956  */
957  MAP(ENTITY, array,
958  {
959  if (!gen_in_list_p(array, tokeep))
960  {
961  /* LIVEMAPPING(array) = .FALSE.
962  */
963  ls = CONS(STATEMENT,
966  bool_to_expression(false)), ls);
967  }
968  },
969  entities_list(load_dynamic_hpf(primary)));
970 
971  /* commented result
972  */
973  result = make_block_statement(ls);
974  if (ls) {
975  string comment =
976  strdup(concatenate("! clean live set for ",
977  entity_local_name(primary), "\n", NULL));
979  free(comment);
980  }
981  return result;
982 }
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734

References array, bool_to_expression(), comment(), concatenate(), CONS, entities_list, ENTITY, entity_local_name(), free(), gen_in_list_p(), insert_comments_to_statement(), live_mapping_expression(), load_dynamic_hpf(), load_hpf_number(), make_assign_statement(), make_block_statement(), MAP, NIL, STATEMENT, and strdup().

Referenced by generate_dynamic_liveness_management().

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

◆ generate_dynamic_liveness_management()

static statement generate_dynamic_liveness_management ( statement  s)
static

of entity

of statement

for each primary remapped at s, generate the management code.

commented result

Definition at line 985 of file remapping.c.

986 {
987  statement result;
988  list /* of entity */ already_seen = NIL,
990  /* of statement */ ls;
991 
992  result = make_empty_statement();
993  {
994  string comment =
995  strdup(concatenate("! end of liveness management\n", NULL));
997  free(comment);
998  }
999  ls = CONS(STATEMENT, result, NIL);
1000 
1001  /* for each primary remapped at s, generate the management code.
1002  */
1003  MAP(ENTITY, array,
1004  {
1005  entity primary = load_primary_entity(array);
1006 
1007  if (!gen_in_list_p(primary, already_seen))
1008  {
1009  ls = CONS(STATEMENT,
1010  generate_dynamic_liveness_for_primary(primary, tokeep),
1011  ls);
1012  already_seen = CONS(ENTITY, primary, already_seen);
1013  }
1014  },
1015  tokeep);
1016 
1017  /* commented result
1018  */
1019  result = make_block_statement(ls);
1020  {
1021  string comment =
1022  strdup(concatenate("! liveness management\n", NULL));
1024  free(comment);
1025  }
1026  return result;
1027 }
entity load_primary_entity(entity)
entities load_maybeuseful_mappings(statement)
static statement generate_dynamic_liveness_for_primary(entity primary, list tokeep)
Definition: remapping.c:948

References array, comment(), concatenate(), CONS, entities_list, ENTITY, free(), gen_in_list_p(), generate_dynamic_liveness_for_primary(), insert_comments_to_statement(), load_maybeuseful_mappings(), load_primary_entity(), make_block_statement(), make_empty_statement, MAP, NIL, STATEMENT, and strdup().

Referenced by remapping_compile().

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

◆ generate_hpf_remapping_file()

static void generate_hpf_remapping_file ( renaming  r)
static

of entity

generates the remapping code and text !!! generated between similar arrays...

stores the remapping as computed

put it in a file

Definition at line 1200 of file remapping.c.

1201 {
1202  string file_name, dir;
1203  FILE * f;
1204  statement remap;
1205  text t;
1206  list /* of entity */ l;
1207  entity src = renaming_old(r), trg = renaming_new(r);
1208 
1209  pips_debug(1, "%s -> %s\n",
1210  entity_name(src), entity_name(trg));
1211 
1212  /* generates the remapping code and text
1213  * !!! generated between similar arrays...
1214  */
1216  load_similar_mapping(trg));
1218  t = protected_text_statement(remap);
1219 
1220  /* stores the remapping as computed
1221  */
1222  l = list_of_referenced_entities(remap);
1224 
1225  /* put it in a file
1226  */
1228  string rfn = remapping_file_name(r);
1229  asprintf(&file_name,"%s/%s",dir,rfn);
1230  free(rfn);
1231  free(dir);
1232 
1233  f = hpfc_fopen(file_name);
1234  print_text(f, t);
1236 
1237  free_text(t);
1238  free(file_name);
1239  free_statement(remap);
1240  gen_free_list(l);
1241 }
void free_statement(statement p)
Definition: ri.c:2189
void free_text(text p)
Definition: text.c:74
entity node_module
Definition: compiler.c:47
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
void update_object_for_module(void *obj, entity module)
#define renaming_old(x)
Definition: hpf_private.h:969
#define renaming_new(x)
Definition: hpf_private.h:971
FILE * hpfc_fopen(string name)
Definition: compile.c:329
void hpfc_fclose(FILE *f, string name)
Definition: compile.c:341
void add_remapping_as_computed(renaming r, list vars)
variables to be declared
Definition: hpfc.c:121
entity load_similar_mapping(entity)
string db_get_directory_name_for_module(const char *name)
returns the allocated and mkdir'ed directory for module name
Definition: lowlevel.c:150
#define asprintf
Definition: misc-local.h:225
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
#define WORKSPACE_SRC_SPACE
Definition: pipsdbm-local.h:32
static text protected_text_statement(statement s)
Definition: remapping.c:1190
static string remapping_file_name(renaming remap)
file name for storing the remapping code.
Definition: remapping.c:1152
static list list_of_referenced_entities(statement s)
Definition: remapping.c:1181
static statement hpf_remapping(entity src, entity trg)
remaps src to trg.
Definition: remapping.c:1034
#define entity_name(x)
Definition: ri.h:2790
void print_text(FILE *fd, text t)
Definition: print.c:195
static string file_name

References add_remapping_as_computed(), asprintf, db_get_directory_name_for_module(), entity_name, f(), file_name, free(), free_statement(), free_text(), gen_free_list(), hpf_remapping(), hpfc_fclose(), hpfc_fopen(), list_of_referenced_entities(), load_similar_mapping(), node_module, pips_debug, print_text(), protected_text_statement(), remapping_file_name(), renaming_new, renaming_old, src, update_object_for_module(), and WORKSPACE_SRC_SPACE.

Referenced by remapping_compile().

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

◆ generate_remapping_code()

static statement generate_remapping_code ( entity  src,
entity  trg,
Psysteme  procs,
Psysteme  locals,
list  l,
list  lp,
list  ll,
list  ldiff,
list  ld,
bool  dist_p 
)
static

generates a full remapping code, given the systems and indexes to be used in the different loops.

that is complementary send/broadcast and receive/copy. The distribution of target onto source processors may require special care if lambda.

output: AS a source DO target DO element PACK SEND/BROADCAST to target(s) AS a target DO source DO element RECEIVE/UNPACK OR DO element COPY true if must take care of lambda

the send is different for diffusions

distributed

replicated

polyhedron separation to extract the diffusions.

??? to be deduced

some comments to help understand the generated code

Parameters
trgsource array
procstarget array
localscommunicating processors polyhedron
lelements polyhedron of entity
lpsource processor indexes
lltarget processor indexes
ldiffelement indexes
ldbroadcast target processor indexes of expression
dist_pdeducable elements

Definition at line 679 of file remapping.c.

690 {
692  p_src = array_to_processors(src),
693  p_trg = array_to_processors(trg),
694  lambda = get_ith_temporary_dummy(3),
695  primary = load_primary_entity(src);
696  statement copy, recv, send, receive, cont, result;
697  bool is_buffer = get_bool_property(USE_BUFFERS);
698 
699  pips_debug(3, "%s taking care of processor cyclic distribution\n",
700  dist_p ? "actually" : "not");
701 
702  copy = remapping_stats(CPY, locals, SC_EMPTY, ll, NIL, ld, lid, src, trg);
703  recv = remapping_stats(RCV, locals, SC_EMPTY, ll, NIL, ld, lid, src, trg);
704 
705  if (dist_p) lp = CONS(ENTITY, lambda, lp);
706 
707  /* the send is different for diffusions
708  */
709  if (ENDP(ldiff))
710  {
711  statement rp_send;
712 
713  rp_send =
714  remapping_stats(SND, locals, SC_EMPTY, ll, NIL, ld, lid, src, trg);
715 
716  send = processor_loop
717  (procs, l, lp, p_src, p_trg, lid, NULL,
719  if_different_pe_and_not_twin(src, lid, rp_send,
720  make_empty_statement()), false);
721  }
722  else
723  {
724  Pbase b = entity_list_to_base(ldiff);
725  list lpproc = gen_copy_seq(lp);
726  statement diff;
727  Psysteme
728  sd /* distributed */,
729  sr /* replicated */;
730 
731  MAP(ENTITY, e, gen_remove(&lpproc, e), ldiff);
732 
733  /* polyhedron separation to extract the diffusions.
734  */
735  sc_separate_on_vars(procs, b, &sr, &sd);
736  base_rm(b);
737 
738  diff = remapping_stats(BRD, locals, sr, ll, ldiff, ld, lid, src, trg);
739 
740  send = processor_loop
741  (sd, l, lpproc, p_src, p_trg, lid, is_buffer ? trg : NULL,
743  diff, false);
744 
745  gen_free_list(lpproc); sc_rm(sd); sc_rm(sr);
746  }
747 
748  if (dist_p)
749  {
750  gen_remove(&lp, lambda);
751  l = gen_nconc(l, CONS(ENTITY, lambda, NIL)); /* ??? to be deduced */
752  }
753 
754  receive = processor_loop
755  (procs, lp, l, p_trg, p_src, lid, NULL,
757  if_different_pe_and_not_twin(src, lid, recv, copy), true);
758 
759  if (dist_p) gen_remove(&l, lambda);
760 
761  cont = make_empty_statement();
762 
763  result = make_block_statement(CONS(STATEMENT, send,
764  CONS(STATEMENT, receive,
765  CONS(STATEMENT, cont,
766  NIL))));
767 
768  /* some comments to help understand the generated code
769  */
770  {
771  char *buffer;
772 
773  asprintf(&buffer, "! remapping %s[%"PRIdPTR"]: %s[%"PRIdPTR"] -> %s[%"PRIdPTR"]\n",
774  entity_local_name(primary), load_hpf_number(primary),
777 
779  free(buffer);
780  insert_comments_to_statement(send, "! send part\n");
781  insert_comments_to_statement(receive, "! receive part\n");
782  insert_comments_to_statement(cont, "! end of remapping\n");
783  }
784 
785  DEBUG_STAT(3, "result", result);
786 
787  return result;
788 }
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
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
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define array_to_processors(array)
#define T_LID
Variables.
#define USE_BUFFERS
entity get_ith_processor_dummy(int)
entity get_ith_temporary_dummy(int)
static statement remapping_stats(int t, Psysteme s, Psysteme sr, list ll, list ldiff, list ld, entity lid, entity src, entity trg)
generates a remapping loop nest (copy/send/receive/broadcast) basically a loop on elements with pre/i...
Definition: remapping.c:615
static statement processor_loop(Psysteme s, _UNUSED_ list l_psi, list l_oth, entity psi, entity oth, entity lid, entity array, entity(*create_psi)(), entity(*create_oth)(), statement body, bool sh)
to be generated: ??? the Proc cycle should be deduce directly in some case...
Definition: remapping.c:304
Pbase entity_list_to_base(list l)
Definition: entity.c:2860
void sc_separate_on_vars(Psysteme s, Pbase b, Psysteme *pwith, Psysteme *pwithout)
Definition: sc.c:418
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
static string buffer
Definition: string.c:113
#define base_rm(b)

References array_to_processors, asprintf, base_rm, BRD, buffer, CONS, CPY, DEBUG_STAT, ENDP, ENTITY, entity_list_to_base(), entity_local_name(), free(), gen_copy_seq(), gen_free_list(), gen_nconc(), gen_remove(), get_bool_property(), get_ith_processor_dummy(), get_ith_processor_prime(), get_ith_temporary_dummy(), hpfc_name_to_entity(), if_different_pe_and_not_twin(), insert_comments_to_statement(), load_hpf_number(), load_primary_entity(), make_block_statement(), make_empty_statement, MAP, NIL, pips_debug, processor_loop(), RCV, remapping_stats(), sc_rm(), sc_separate_on_vars(), SND, src, STATEMENT, T_LID, and USE_BUFFERS.

Referenced by hpf_remapping().

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

◆ generate_remapping_guard()

static statement generate_remapping_guard ( entity  src,
entity  trg,
statement  the_code 
)
static

Runtime descriptors management around the remapping code.

performs the remapping if reaching mapping is ok, and update the mapping status.

IF (MSTATUS(primary_number).eq.src_number) THEN [ IF (.not.LIVEMAPPING(target_number)]) THEN ] the_code [ ENDIF ] [ LIVEMAPPING(target_number) = .TRUE. ] MSTATUS(primary_number) = trg_number ENDDIF remapping code

source, target and primary numbers

mapping status

of statement

MSTATUS(primary_n)

MSTATUS(primary_number) = trg_number

MSTATUS(primary_number).eq.src_number

checks whether alive or not

Parameters
trgsource array
the_codetarget array

Definition at line 859 of file remapping.c.

863 {
864  int src_n = load_hpf_number(src), /* source, target and primary numbers */
865  trg_n = load_hpf_number(trg),
867  entity m_status = hpfc_name_to_entity(MSTATUS); /* mapping status */
868  expression m_stat_ref, cond;
869  statement result;
870  list /* of statement */ l = NIL;
871 
872  /* MSTATUS(primary_n) */
873  m_stat_ref =
875  (make_reference(m_status,
876  CONS(EXPRESSION, int_to_expression(prm_n), NIL)));
877 
878  /* MSTATUS(primary_number) = trg_number */
880 
881  /* MSTATUS(primary_number).eq.src_number */
882  cond = eq_expression(m_stat_ref, int_to_expression(src_n));
883 
884  /* checks whether alive or not */
885  if (get_bool_property("HPFC_DYNAMIC_LIVENESS"))
886  {
887  expression live_cond =
889 
890  the_code = test_to_statement(make_test
891  (live_cond, the_code, make_empty_statement()));
892 
893  l = CONS(STATEMENT,
895  bool_to_expression(true)), l);
896  }
897 
898  result = test_to_statement(make_test(cond,
899  make_block_statement(CONS(STATEMENT, the_code, l)),
901 
902  return result;
903 }
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
#define MSTATUS
static statement set_array_status_to_target(entity trg)
Definition: remapping.c:801
#define test_to_statement(t)
#define eq_expression(e1, e2)
#define not_expression(e)
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
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217

References bool_to_expression(), CONS, eq_expression, EXPRESSION, get_bool_property(), hpfc_name_to_entity(), int_to_expression(), live_mapping_expression(), load_hpf_number(), load_primary_entity(), make_assign_statement(), make_block_statement(), make_empty_statement, make_reference(), make_test(), MSTATUS, NIL, not_expression, reference_to_expression(), set_array_status_to_target(), src, STATEMENT, and test_to_statement.

Referenced by hpf_remapping().

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

◆ generate_remapping_include()

static statement generate_remapping_include ( renaming  r)
static

just a hack because pips does not have 'include'

Definition at line 1246 of file remapping.c.

1247 {
1248  statement result;
1249 
1250  result = make_empty_statement();
1251  {
1252  string comment =
1253  strdup(concatenate(" include '",
1254  remapping_file_name(r), "'\n", NULL));
1256  free(comment);
1257  }
1258  return result;
1259 }

References comment(), concatenate(), free(), insert_comments_to_statement(), make_empty_statement, remapping_file_name(), and strdup().

Referenced by remapping_compile().

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

◆ generate_remapping_system()

static Psysteme generate_remapping_system ( entity  src,
entity  trg 
)
static

returns the full remapping system, including the source and target mappings systems, the link and the work sharing system

target array

Parameters
trgsource array for the remapping

Definition at line 175 of file remapping.c.

178 {
179  int ndim = variable_entity_dimension(src);
180  Psysteme
181  result,
187  s_shr = generate_work_sharing_system(src, trg);
188 
189  DEBUG_SYST(6, concatenate("source ", entity_name(src), NULL), s_src);
190  DEBUG_SYST(6, concatenate("target ", entity_name(trg), NULL), s_trg);
191  DEBUG_SYST(6, "link", s_equ);
192  DEBUG_SYST(6, "sharing", s_shr);
193 
194  result = s_src;
195  result = sc_append(result, s_trg), sc_rm(s_trg);
196  result = sc_append(result, s_equ), sc_rm(s_equ);
197  result = sc_append(result, s_shr), sc_rm(s_shr);
198 
199  return result;
200 }
Psysteme generate_system_for_equal_variables(int n, entity(*gen1)(int), entity(*gen2)(int))
Definition: build-system.c:751
Psysteme shift_system_to_prime_variables(Psysteme s)
Definition: build-system.c:173
Psysteme generate_system_for_distributed_variable(entity v)
Psysteme generate_system_for_variable(v) entity v;.
Definition: build-system.c:789
#define DEBUG_SYST(D, W, S)
entity get_ith_array_prime(int)
entity get_ith_array_dummy(int)
static Psysteme generate_work_sharing_system(entity src, entity trg)
load-balancing equation as suggested in the A-274 report.
Definition: remapping.c:122
int variable_entity_dimension(entity)
variable_entity_dimension(entity v): returns the dimension of variable v; scalar have dimension 0.
Definition: variable.c:1293
Psysteme sc_append(Psysteme s1, Psysteme s2)
Psysteme sc_append(Psysteme s1, Psysteme s2): calcul de l'intersection des polyedres definis par s1 e...

References concatenate(), DEBUG_SYST, entity_name, generate_system_for_distributed_variable(), generate_system_for_equal_variables(), generate_work_sharing_system(), get_ith_array_dummy(), get_ith_array_prime(), sc_append(), sc_rm(), shift_system_to_prime_variables(), src, and variable_entity_dimension().

Referenced by hpf_remapping().

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

◆ generate_work_sharing_system()

static Psysteme generate_work_sharing_system ( entity  src,
entity  trg 
)
static

load-balancing equation as suggested in the A-274 report.

here some choices are quite arbitrary:

  • the dimension order linearization of both source and target procs.
  • the initial offset some clever choice could be suggested so as to minimize the required communications by maximizing the local copies, knowing the actual hpf processors to real processors affectation...

should allow a stupid system with some property? target array

psi_d = psi_r + |psi_r| delta

0 <= delta (there are cycles)

delta <= -((size_d-1)/size_r) // not really necessary, but may help.

delta == 0

Parameters
trgsource array

Definition at line 122 of file remapping.c.

125 {
126  entity psi_r = get_ith_temporary_dummy(1),
127  psi_d = get_ith_temporary_dummy(2),
128  delta = get_ith_temporary_dummy(3);
129  int size_r, size_d;
130  Psysteme sharing = sc_new();
131 
132  sc_add_egalite(sharing, partial_linearization(src, false, psi_r, &size_r,
134  sc_add_egalite(sharing, partial_linearization(trg, true, psi_d, &size_d,
136 
137  /* psi_d = psi_r + |psi_r| delta
138  */
140  (VECTEUR_NUL, psi_d, VALUE_MONE,
141  psi_r, VALUE_ONE,
142  delta, int_to_value(size_r),
143  TCST, VALUE_ZERO)));
144 
145  if (size_d > size_r)
146  {
147  /* 0 <= delta (there are cycles)
148  */
151 
152  /* delta <= -((size_d-1)/size_r) // not really necessary, but may help.
153  */
155  (vect_make(VECTEUR_NUL, delta, VALUE_ONE,
156  TCST, int_to_value(-((size_d-1)/size_r)))));
157  }
158  else
159  {
160  /* delta == 0
161  */
162  sc_add_egalite(sharing,
164  }
165 
166  sc_creer_base(sharing);
167 
168  return sharing;
169 }
#define VALUE_ZERO
static Pcontrainte partial_linearization(entity array, bool distributed, entity var, int *psize, entity(*create_var)(int))
HPFC module by Fabien COELHO.
Definition: remapping.c:48
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
void sc_add_egalite(Psysteme p, Pcontrainte e)
void sc_add_egalite(Psysteme p, Pcontrainte e): macro ajoutant une egalite e a un systeme p; la base ...
Definition: sc_alloc.c:389
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
void sc_add_inegalite(Psysteme p, Pcontrainte i)
void sc_add_inegalite(Psysteme p, Pcontrainte i): macro ajoutant une inegalite i a un systeme p; la b...
Definition: sc_alloc.c:406
Pvecteur vect_make(Pvecteur v, Variable var, Value val,...)
Pvecteur vect_make(v, [var, val,]* 0, val) Pvecteur v; // may be NULL, use assigne anyway Variable va...
Definition: alloc.c:165
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110

References contrainte_make(), get_ith_processor_dummy(), get_ith_processor_prime(), get_ith_temporary_dummy(), int_to_value, partial_linearization(), sc_add_egalite(), sc_add_inegalite(), sc_creer_base(), sc_new(), src, TCST, VALUE_MONE, VALUE_ONE, VALUE_ZERO, vect_make(), vect_new(), and VECTEUR_NUL.

Referenced by generate_remapping_system().

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

◆ hpf_remapping()

static statement hpf_remapping ( entity  src,
entity  trg 
)
static

remaps src to trg.

first builds the equation and needed lists of indexes, then call the actual code generation phase.

P cycle

of entities

of expressions

(optimization:-)

builds and simplifies the systems.

it is not obvious to decide where to place the cleaning, the equalities detection and the deducables...

the P cycle ?

processors/array elements separation.

??? why row echelon? why not... it is not too bad a projection! actually, what I want is to separate processors and elements. Then I would like to perform some manipulations on the systems to improve them, extracting deducables and lattices... but the conservation of the optimized order is not obvious... May/should I give it up in some cases? Well, I guess so.

What's missing:

  • extraction of the lattice if equalities remain in a system. 1 Hermite transformation + variable list update...
  • also some deducables could be extracted once the code is transformed.
  • Q: what about variables which were kept althought not desired?

{ list ns = NIL; extract_lattice(proc, lp, &ns, &lp..

generates the code.

clean.

???

Definition at line 1034 of file remapping.c.

1037 {
1038  Psysteme p, proc, enume;
1039  statement s;
1040  entity lambda = get_ith_temporary_dummy(3) ; /* P cycle */
1041  bool proc_distribution_p;
1042  list /* of entities */ l, lp, ll, lrm, ld, lo, left, scanners,
1043  /* of expressions */ lddc;
1044  bool time_remapping = get_bool_property("HPFC_TIME_REMAPPINGS");
1045 
1046  pips_debug(1, "%s -> %s\n", entity_name(src), entity_name(trg));
1047 
1048  if (src==trg) /* (optimization:-) */
1049  return make_empty_statement();
1050 
1051  if (time_remapping) push_performance_spy();
1052 
1053  /* builds and simplifies the systems.
1054  */
1055  p = generate_remapping_system(src, trg);
1057 
1058  remapping_variables(p, src, trg, &l, &lp, &ll, &lrm, &ld, &lo);
1059 
1060  /* it is not obvious to decide where to place
1061  * the cleaning, the equalities detection and the deducables...
1062  */
1063 
1064  clean_the_system(&p, &lrm, &lo);
1065  DEBUG_SYST(4, "cleaned system", p);
1066 
1067  if (get_bool_property("HPFC_EXTRACT_EQUALITIES"))
1068  {
1069  sc_find_equalities(&p);
1070  DEBUG_SYST(4, "more equalities", p);
1071  }
1072 
1073  lddc = simplify_deducable_variables(p, ll, &left);
1074  gen_free_list(ll);
1075  DEBUG_SYST(4, "without deducables system", p);
1076 
1077  /* the P cycle ?
1078  */
1079  proc_distribution_p = gen_in_list_p(lambda, lo);
1080  if (proc_distribution_p) gen_remove(&lo, lambda);
1081  scanners = gen_nconc(lo, left);
1082 
1083  DEBUG_ELST(4, "scanners", scanners);
1084 
1085  /* processors/array elements separation.
1086  *
1087  * ??? why row echelon? why not... it is not too bad a projection!
1088  * actually, what I want is to separate processors and elements.
1089  * Then I would like to perform some manipulations on the systems
1090  * to improve them, extracting deducables and lattices...
1091  * but the conservation of the optimized order is not obvious...
1092  * May/should I give it up in some cases? Well, I guess so.
1093  *
1094  * What's missing:
1095  * - extraction of the lattice if equalities remain in a system.
1096  * 1 Hermite transformation + variable list update...
1097  * - also some deducables could be extracted once the code is transformed.
1098  * - Q: what about variables which were kept althought not desired?
1099  */
1100  hpfc_algorithm_row_echelon(p, scanners, &proc, &enume);
1101  sc_rm(p);
1102 
1104  sc_transform_ineg_in_eg(enume);
1105 
1106  if (sc_egalites(proc))
1107  hpfc_warning("lattice extraction not implemented (proc)\n");
1108  /* {
1109  list ns = NIL;
1110  extract_lattice(proc, lp, &ns, &lp.. */
1111 
1112 
1113  if (sc_egalites(enume))
1114  {
1115  list ns = NIL;
1116  extract_lattice(enume, scanners, &ns, &lddc);
1117  gen_free_list(scanners), scanners=ns;
1118  }
1119 
1120  DEBUG_SYST(3, "proc", proc);
1121  DEBUG_SYST(3, "enum", enume);
1122 
1123  /* generates the code.
1124  */
1126  (src, trg, proc, enume, l, lp, scanners, ld, lddc, proc_distribution_p));
1127 
1128  /* clean.
1129  */
1130  sc_rm(proc), sc_rm(enume);
1131  gen_free_list(scanners);
1133  gen_map((gen_iter_func_t)gen_free, lddc), gen_free_list(lddc); /* ??? */
1134 
1136 
1137  if (time_remapping)
1138  pop_performance_spy(stderr,
1139  concatenate("remapping ",
1140  entity_name(src), " -> ",
1141  entity_name(trg), NULL));
1142 
1143  DEBUG_STAT(6, "result", s);
1144 
1145  return s;
1146 }
void reset_information_for_code_optimizations(void)
void set_information_for_code_optimizations(Psysteme)
I could keep the system for further optimizations...
void gen_free(gen_chunk *obj)
version without shared_pointers.
Definition: genClib.c:992
void gen_map(gen_iter_func_t fp, const list l)
Definition: list.c:172
#define DEBUG_ELST(D, W, L)
#define hpfc_warning
WARNING.
void clean_the_system(Psysteme *, list *, list *)
Definition: io-compile.c:360
void hpfc_algorithm_row_echelon(Psysteme, list, Psysteme *, Psysteme *)
io-compile.c
Definition: io-compile.c:127
list simplify_deducable_variables(Psysteme, list, list *)
list simplify_deducable_variables(syst, vars, pleftvars) Psysteme syst; list vars,...
Definition: io-compile.c:562
void extract_lattice(Psysteme, list, list *, list *)
lattice_extraction.c
void push_performance_spy(void)
perf_spy.c
Definition: perf_spy.c:89
void pop_performance_spy(FILE *, string)
Definition: perf_spy.c:97
void(* gen_iter_func_t)(void *)
Definition: newgen_types.h:116
static statement generate_remapping_guard(entity src, entity trg, statement the_code)
Runtime descriptors management around the remapping code.
Definition: remapping.c:859
static Psysteme generate_remapping_system(entity src, entity trg)
returns the full remapping system, including the source and target mappings systems,...
Definition: remapping.c:175
static void remapping_variables(Psysteme s, entity a1, entity a2, list *pl, list *plp, list *pll, list *plrm, list *pld, list *plo)
??? assumes that there are no parameters.
Definition: remapping.c:206
static statement generate_remapping_code(entity src, entity trg, Psysteme procs, Psysteme locals, list l, list lp, list ll, list ldiff, list ld, bool dist_p)
generates a full remapping code, given the systems and indexes to be used in the different loops.
Definition: remapping.c:679
void sc_find_equalities(Psysteme *ps)
void sc_transform_ineg_in_eg(Psysteme sc)
Transform the two constraints A.x <= b and -A.x <= -b of system sc into an equality A....

References clean_the_system(), concatenate(), DEBUG_ELST, DEBUG_STAT, DEBUG_SYST, entity_name, extract_lattice(), gen_free(), gen_free_list(), gen_in_list_p(), gen_map(), gen_nconc(), gen_remove(), generate_remapping_code(), generate_remapping_guard(), generate_remapping_system(), get_bool_property(), get_ith_temporary_dummy(), hpfc_algorithm_row_echelon(), hpfc_warning, make_empty_statement, NIL, pips_debug, pop_performance_spy(), push_performance_spy(), remapping_variables(), reset_information_for_code_optimizations(), sc_find_equalities(), sc_rm(), sc_transform_ineg_in_eg(), set_information_for_code_optimizations(), simplify_deducable_variables(), and src.

Referenced by generate_hpf_remapping_file().

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

◆ if_different_pe_and_not_twin()

static statement if_different_pe_and_not_twin ( entity  src,
entity  lid,
statement  strue,
statement  sfalse 
)
static

to be generated: IF (MYLID.NE.LID[.AND.NOT.HPFC_TWIN_P(an, LID)]) THEN true ELSE false ENDIF

else statement

of expression

Parameters
lidsource array processor
strueprocess local id variable
sfalsethen statement

Definition at line 408 of file remapping.c.

413 {
414  expression cond = mylid_ne_lid(lid);
415 
416  if (get_bool_property("HPFC_GUARDED_TWINS") && replicated_p(src))
417  {
418  list /* of expression */ largs;
419  expression not_twin;
420 
425 
426  cond = and_expression(cond, not_twin);
427  }
428 
429  return test_to_statement(make_test(cond, strue, sfalse));
430 }
call make_call(entity a1, list a2)
Definition: ri.c:269
bool replicated_p(entity e)
replicated_p
Definition: hpfc-util.c:96
#define TWIN_P
static expression mylid_ne_lid(entity lid)
Definition: remapping.c:395
#define and_expression(e1, e2)
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
expression call_to_expression(call c)
Build an expression that call a function or procedure.
Definition: expression.c:309

References and_expression, call_to_expression(), CONS, entity_to_expression(), EXPRESSION, get_bool_property(), hpfc_name_to_entity(), int_to_expression(), load_hpf_number(), make_call(), make_test(), mylid_ne_lid(), NIL, not_expression, replicated_p(), src, test_to_statement, and TWIN_P.

Referenced by broadcast(), and generate_remapping_code().

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

◆ list_of_referenced_entities()

static list list_of_referenced_entities ( statement  s)
static

Definition at line 1181 of file remapping.c.

1182 {
1183  l_found = NIL;
1186  return l_found;
1187 }
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
static void loop_rwt(loop l)
Definition: remapping.c:1175
static list l_found
quick recursion to find the entities referenced in a statement.
Definition: remapping.c:1174
static void reference_rwt(reference r)
Definition: remapping.c:1177
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338

References gen_multi_recurse(), gen_true(), l_found, loop_domain, loop_rwt(), NIL, reference_domain, and reference_rwt().

Referenced by generate_hpf_remapping_file().

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

◆ live_mapping_expression()

static expression live_mapping_expression ( int  index)
static

returns LIVEMAPPING(index)

Definition at line 793 of file remapping.c.

794 {
795  entity live_status = hpfc_name_to_entity(LIVEMAPPING);
797  (live_status, CONS(EXPRESSION, int_to_expression(index), NIL)));
798 }
#define LIVEMAPPING

References CONS, EXPRESSION, hpfc_name_to_entity(), int_to_expression(), LIVEMAPPING, make_reference(), NIL, and reference_to_expression().

Referenced by generate_all_liveness_but(), generate_dynamic_liveness_for_primary(), generate_remapping_guard(), and set_live_status().

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

◆ loop_rwt()

static void loop_rwt ( loop  l)
static

Definition at line 1175 of file remapping.c.

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
#define loop_index(x)
Definition: ri.h:1640

References gen_once(), l_found, and loop_index.

Referenced by list_of_referenced_entities().

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

◆ mylid_ne_lid()

static expression mylid_ne_lid ( entity  lid)
static

Definition at line 395 of file remapping.c.

396 {
398  entity_to_expression(lid));
399 }
#define MYLID
#define ne_expression(e1, e2)

References entity_to_expression(), hpfc_name_to_entity(), MYLID, and ne_expression.

Referenced by if_different_pe_and_not_twin().

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

◆ partial_linearization()

static Pcontrainte partial_linearization ( entity  array,
bool  distributed,
entity  var,
int psize,
entity(*)(int create_var 
)
static

HPFC module by Fabien COELHO.

generates a remapping code. debug controlled with HPFC_REMAPPING_DEBUG_LEVEL. ??? should drop the renaming domain? linearize the processor arrangement on which array is distributed or replicated (driven by distributed). The variables are those created or returned by the create_var function. var is set as the linearization result, if not NULL. *psize the the extent of the returned array. Special care is taken about the declaration shifts. dimension variable builder

Parameters
distributedarray variable
vardistributed or replicated dimensions lin.
psizeassigned variable if desired
create_varreturned array extent

Definition at line 48 of file remapping.c.

54 {
56  int dim = NumberOfDimension(proc), low, up, size;
58 
59  for(*psize=1; dim>0; dim--)
60  if (distributed ^ processors_dim_replicated_p(proc, array, dim))
61  {
62  get_entity_dimensions(proc, dim, &low, &up);
63  size = up - low + 1;
64  *psize *= size;
65  v = vect_multiply(v, int_to_value(size));
66  vect_add_elem(&v, (Variable) create_var(dim), VALUE_ONE);
67  vect_add_elem(&v, TCST, int_to_value(-low));
68  }
69 
70  if (var) vect_add_elem(&v, (Variable) var, VALUE_MONE);
71 
72  return contrainte_make(v);
73 }
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

References array, array_to_processors, contrainte_make(), get_entity_dimensions(), int_to_value, NumberOfDimension(), processors_dim_replicated_p(), TCST, VALUE_MONE, VALUE_ONE, vect_add_elem(), vect_multiply(), and VECTEUR_NUL.

Referenced by generate_work_sharing_system().

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

◆ processor_loop()

static statement processor_loop ( Psysteme  s,
_UNUSED_ list  l_psi,
list  l_oth,
entity  psi,
entity  oth,
entity  lid,
entity  array,
entity(*)()  create_psi,
entity(*)()  create_oth,
statement  body,
bool  sh 
)
static

to be generated: ??? the Proc cycle should be deduce directly in some case...

PSI_i's definitions [ IF (I AM IN S(PSI_i)) THEN ] DO OTH_i's in S(OTH_i's)[PSI_i's] LID computation(OTH_i's) // if LID is not NULL! body ENDDO [ ENDIF ] whether to shift the psi's

the lid computation is delayed in the body for broadcasts.

simplifies the processor arrangement for the condition

the processor must be in the psi processor arrangement

target processors enumeration loop

Parameters
l_psisystem of comm. couples of processors of entities
l_othprocessor local dimensions of entities
psicommunicating proc. dimensions
othlocal processor arrangement
lidcommunicating processor arrangement
arrayvariable for the comm. proc local id
create_psiarray being remapped
create_othto create a local proc. dim.
bodyto create a comm. proc. dim.
shloop body

Definition at line 304 of file remapping.c.

316 {
318  Psysteme condition, enumeration, known, simpler;
319  statement define_psis, compute_lid, oth_loop, if_guard;
320 
321  define_psis = define_node_processor_id(psi, create_psi);
322 
323  /* the lid computation is delayed in the body for broadcasts.
324  */
325  compute_lid = (lid) ?
326  hpfc_compute_lid(lid, oth, create_oth, array) :
328 
329  /* simplifies the processor arrangement for the condition
330  */
331  known = sc_dup(entity_to_declaration_constraints(psi, 2));
332  if (sh) known = shift_system_to_prime_variables(known);
333 
334  DEBUG_SYST(7, "initial system", s);
335  DEBUG_ELST(7, "loop indexes", l_oth);
336 
337  hpfc_algorithm_row_echelon(s, l_oth, &condition, &enumeration);
338 
339  DEBUG_SYST(7, "P condition", condition);
340 
341  simpler = extract_nredund_subsystem(condition, known);
342  sc_rm(condition), sc_rm(known);
343 
344  /* the processor must be in the psi processor arrangement
345  */
346  sc_add_inegalite(simpler,
353 
354  DEBUG_SYST(5, "P simpler", simpler);
355  DEBUG_SYST(5, "P enumeration", enumeration);
356 
357  /* target processors enumeration loop
358  */
359  oth_loop = systeme_to_loop_nest(enumeration, l_oth,
360  make_block_statement(CONS(STATEMENT, compute_lid,
361  CONS(STATEMENT, body,
362  NIL))), divide);
363 
364  if_guard = generate_optional_if(simpler, oth_loop);
365 
366  sc_rm(simpler); sc_rm(enumeration);
367 
368  return make_block_statement(CONS(STATEMENT, define_psis,
369  CONS(STATEMENT, if_guard,
370  NIL)));
371 }
#define divide(a, b)
Psysteme entity_to_declaration_constraints(entity e, tag what)
gives back the constraints due to the declarations.
Definition: build-system.c:285
statement generate_optional_if(Psysteme, statement)
statement generate_optional_if(sc, stat)
statement define_node_processor_id(entity proc, entity(*creation)(int))
builds a statement VAR_i = MYPOS(i, proc_number) // i=1 to proc dimension
Definition: generate-util.c:49
int element_number(basic, list)
END_EOLE.
Definition: size.c:391
#define type_variable(x)
Definition: ri.h:2949
#define variable_dimensions(x)
Definition: ri.h:3122
#define entity_type(x)
Definition: ri.h:2792
#define variable_basic(x)
Definition: ri.h:3120
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
Psysteme extract_nredund_subsystem(Psysteme s1, Psysteme s2)
Psysteme extract_nredund_subsystem(s1, s2) Psysteme s1, s2;.

References array, CONS, contrainte_make(), DEBUG_ELST, DEBUG_SYST, define_node_processor_id(), divide, element_number(), entity_to_declaration_constraints(), entity_type, extract_nredund_subsystem(), generate_optional_if(), hpfc_algorithm_row_echelon(), hpfc_compute_lid(), hpfc_name_to_entity(), IDIVIDE, int_to_value, make_block_statement(), make_empty_statement, MYLID, NIL, sc_add_inegalite(), sc_dup(), sc_rm(), shift_system_to_prime_variables(), STATEMENT, systeme_to_loop_nest(), TCST, type_variable, VALUE_ONE, variable_basic, variable_dimensions, vect_make(), and VECTEUR_NUL.

Referenced by generate_remapping_code().

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

◆ protected_text_statement()

static text protected_text_statement ( statement  s)
static

Definition at line 1190 of file remapping.c.

1191 {
1192  text t;
1193  debug_on("PRETTYPRINT_DEBUG_LEVEL");
1194  t = Text_Statement(entity_undefined, 0, s);
1195  debug_off();
1196  return t;
1197 }
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
text Text_Statement(entity, int, statement)

References debug_off, debug_on, entity_undefined, and Text_Statement().

Referenced by generate_hpf_remapping_file().

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

◆ reference_rwt()

static void reference_rwt ( reference  r)
static

Definition at line 1177 of file remapping.c.

#define reference_variable(x)
Definition: ri.h:2326

References gen_once(), l_found, and reference_variable.

Referenced by list_of_referenced_entities().

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

◆ remapping_compile()

void remapping_compile ( statement  s,
statement hsp,
statement nsp 
)

void remapping_compile(s, hsp, nsp) statement s, *hsp, *nsp;

what: generates the remapping code for s. how: polyhedron technique. input: s, the statement. output: statements *hsp and *nsp, the host and SPMD node code. side effects: (none?) bugs or features: idem Node

of statements

nothing for host

comment at the end

dynamic liveness management if required

remapping codes (indirect thru include)

KILL => status update

comment at the beginning

block of remaps for the nodes

Parameters
hspinitial statement in the source code
nspHost Statement Pointer

Definition at line 1302 of file remapping.c.

1306 {
1307  statement tmp;
1308  list /* of statements */ l = NIL;
1309 
1310  debug_on("HPFC_REMAPPING_DEBUG_LEVEL");
1311  what_stat_debug(1, s);
1312 
1313  *hsp = make_empty_statement(); /* nothing for host */
1314 
1315  /* comment at the end
1316  */
1317  tmp = make_empty_statement();
1318  {
1319  string comment = strdup(concatenate("! end remappings\n", NULL));
1321  free(comment);
1322  }
1323  l = CONS(STATEMENT, tmp, l);
1324 
1325  /* dynamic liveness management if required
1326  */
1327  if (get_bool_property("HPFC_DYNAMIC_LIVENESS"))
1328  {
1330  }
1331 
1332  /* remapping codes (indirect thru include)
1333  */
1334  MAP(RENAMING, r,
1335  {
1336  pips_debug(7, "remapping %s -> %s\n", entity_name(renaming_old(r)),
1338  if (renaming_old(r)==renaming_new(r)) /* KILL => status update */
1340  l);
1341  else
1342  {
1345 
1348  }
1349  },
1350  load_renamings(s));
1351 
1352  /* comment at the beginning
1353  */
1354  tmp = make_empty_statement();
1355  {
1356  string comment = strdup(concatenate("! begin remappings\n", NULL));
1358  free(comment);
1359  }
1360  l = CONS(STATEMENT, tmp, l);
1361 
1362  *nsp = make_block_statement(l); /* block of remaps for the nodes */
1363  DEBUG_STAT(8, "result", *nsp);
1364 
1365  debug_off();
1366 }
#define RENAMING(x)
RENAMING.
Definition: hpf_private.h:939
#define what_stat_debug(level, stat)
void add_remapping_as_used(renaming x)
Definition: hpfc.c:135
bool remapping_already_computed_p(renaming x)
list of already computed remappings...
Definition: hpfc.c:105
list load_renamings(statement)
static statement generate_dynamic_liveness_management(statement s)
Definition: remapping.c:985
static statement generate_remapping_include(renaming r)
just a hack because pips does not have 'include'
Definition: remapping.c:1246
static void generate_hpf_remapping_file(renaming r)
Definition: remapping.c:1200

References add_remapping_as_used(), comment(), concatenate(), CONS, debug_off, debug_on, DEBUG_STAT, entity_name, free(), generate_dynamic_liveness_management(), generate_hpf_remapping_file(), generate_remapping_include(), get_bool_property(), insert_comments_to_statement(), load_renamings(), make_block_statement(), make_empty_statement, MAP, NIL, pips_debug, remapping_already_computed_p(), RENAMING, renaming_new, renaming_old, set_array_status_to_target(), STATEMENT, strdup(), and what_stat_debug.

Referenced by hpf_compiler().

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

◆ remapping_file_name()

static string remapping_file_name ( renaming  remap)
static

file name for storing the remapping code.

{module}_{array}_{src}_{trg}_node.h

Definition at line 1152 of file remapping.c.

1154 {
1155  char *buffer;
1156  entity src = renaming_old(remap), trg = renaming_new(remap);
1157  string module, array;
1158 
1161 
1162  asprintf(&buffer, "%s_%s_%"PRIdPTR"_%"PRIdPTR"_node.h", module, array,
1164 
1165  free(module);
1166  free(array);
1167 
1168  return buffer;
1169 }
static char * module
Definition: pips.c:74
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092

References array, asprintf, buffer, entity_local_name(), entity_module_name(), free(), load_hpf_number(), load_primary_entity(), module, renaming_new, renaming_old, src, and strdup().

Referenced by generate_hpf_remapping_file(), and generate_remapping_include().

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

◆ remapping_stats()

static statement remapping_stats ( int  t,
Psysteme  s,
Psysteme  sr,
list  ll,
list  ldiff,
list  ld,
entity  lid,
entity  src,
entity  trg 
)
static

generates a remapping loop nest (copy/send/receive/broadcast) basically a loop on elements with pre/in/post statements...

target array

comments are added to help understand the generated code

Parameters
stag: CPY/SND/RCV/BRD
srelements polyhedron
llbroadcast polyhedron of entity
ldiffindexes for element loops of entity
ldindexes for broadcasts of expressions
liddeducable elements
srclid variable to be used
trgsource array

Definition at line 615 of file remapping.c.

625 {
626  entity proc = array_to_processors(trg);
627  statement inner, prel, postl, result;
628  bool is_buffer, is_lazy;
629  int what;
630 
631  is_lazy = get_bool_property(LAZY_MESSAGES);
632  is_buffer = get_bool_property(USE_BUFFERS);
633  what = (is_lazy ? LZY : NLZ) + (is_buffer ? BUF : NBF) + t;
634 
635  prel = gen(what+PRE, src, trg, lid, proc,
637  inner = gen(what+INL, src, trg, lid, proc,
639  postl = gen(what+PST, src, trg, lid, proc,
641 
642  result = make_block_statement
643  (CONS(STATEMENT, prel,
644  CONS(STATEMENT, elements_loop(s, ll, ld, inner),
645  CONS(STATEMENT, postl,
646  NIL))));
647 
648  {
649  /* comments are added to help understand the generated code
650  */
651  string comment = strdup(concatenate("! - ", (what & LZY) ? "lazy " : "",
652  t==CPY ? "copy" : t==SND ? "send" : t==RCV ? "receiv" :
653  t==BRD ? "broadcast" : "?", "ing\n", NULL));
655  free(comment);
656  }
657  return result;
658 }
#define LAZY_MESSAGES
entity get_ith_local_prime(int)
entity get_ith_local_dummy(int)
#define NLZ
Definition: remapping.c:479
#define NBF
Definition: remapping.c:482
static statement gen(int what, entity src, entity trg, entity lid, entity proc, entity(*create_src)(), entity(*create_trg)(), Psysteme sr, list ldiff)
arguments: all that may be useful to generate some code
Definition: remapping.c:498
static statement elements_loop(Psysteme s, list ll, list ld, statement body)
to be generated:
Definition: remapping.c:381

References array_to_processors, BRD, BUF, comment(), concatenate(), CONS, CPY, elements_loop(), free(), gen(), get_bool_property(), get_ith_local_dummy(), get_ith_local_prime(), INL, insert_comments_to_statement(), LAZY_MESSAGES, LZY, make_block_statement(), NBF, NIL, NLZ, PRE, PST, RCV, SND, src, STATEMENT, strdup(), and USE_BUFFERS.

Referenced by generate_remapping_code().

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

◆ remapping_variables()

static void remapping_variables ( Psysteme  s,
entity  a1,
entity  a2,
list pl,
list plp,
list pll,
list plrm,
list pld,
list plo 
)
static

??? assumes that there are no parameters.

what should be the case... generates the list of variables needed by the code generation. others

processors.

to be removed.

corresponding equations generated in the sharing system

Replicated dimensions associated variables must be removed. A nicer approach would have been not to generate them, but it's not so hard to remove them, and the equation generation is kept simpler this way. At least in my own opinion:-)

locals.

others.

Parameters
a1full remapping system
a2source array
pltarget array
plpP
pllP'
plrmlocals
pldto remove
plodiffusion processor variables

Definition at line 206 of file remapping.c.

216 {
217  entity
218  t1 = array_to_template(a1),
219  p1 = template_to_processors(t1),
220  t2 = array_to_template(a2),
221  p2 = template_to_processors(t2);
222  int
223  a1dim = variable_entity_dimension(a1),
224  a2dim = variable_entity_dimension(a2),
225  t1dim = variable_entity_dimension(t1),
226  t2dim = variable_entity_dimension(t2),
227  p1dim = variable_entity_dimension(p1),
228  p2dim = variable_entity_dimension(p2), i;
229 
230  /* processors.
231  */
233  *plp = NIL; add_to_list_of_vars(*plp, get_ith_processor_prime, p2dim);
234 
235  *pld = NIL;
236  for (i=p2dim; i>0; i--)
237  if (processors_dim_replicated_p(p2, a2, i))
238  *pld = CONS(ENTITY, get_ith_processor_prime(i), *pld);
239 
240  /* to be removed.
241  */
242  *plrm = NIL;
247 
248  /* corresponding equations generated in the sharing system
249  */
251 
252 
253  /* Replicated dimensions associated variables must be removed.
254  * A nicer approach would have been not to generate them, but
255  * it's not so hard to remove them, and the equation generation is
256  * kept simpler this way. At least in my own opinion:-)
257  */
258  for (i=p1dim; i>0; i--)
259  if (processors_dim_replicated_p(p1, a1, i))
260  *plrm = CONS(ENTITY, get_ith_block_dummy(i),
261  CONS(ENTITY, get_ith_cycle_dummy(i), *plrm));
262 
263  for (i=p2dim; i>0; i--)
264  if (processors_dim_replicated_p(p2, a2, i))
265  *plrm = CONS(ENTITY, get_ith_block_prime(i),
266  CONS(ENTITY, get_ith_cycle_prime(i), *plrm));
267 
268  /* locals.
269  */
270  *pll = NIL;
273 
274  /* others.
275  */
276  *plo = base_to_list(sc_base(s));
277  gen_remove(plo, (entity) TCST);
278 
279  MAP(ENTITY, e, gen_remove(plo, e), *pl);
280  MAP(ENTITY, e, gen_remove(plo, e), *plp);
281  MAP(ENTITY, e, gen_remove(plo, e), *plrm);
282  MAP(ENTITY, e, gen_remove(plo, e), *pll);
283 
284  DEBUG_ELST(7, "P", *pl);
285  DEBUG_ELST(7, "P'", *plp);
286  DEBUG_ELST(7, "RM", *plrm);
287  DEBUG_ELST(7, "LOCALS", *pll);
288  DEBUG_ELST(7, "DIFFUSION", *pld);
289  DEBUG_ELST(7, "OTHERS", *plo);
290 }
#define array_to_template(array)
#define template_to_processors(template)
#define add_to_list_of_vars(l, fun, n)
list of variables...
Definition: defines-local.h:89
list base_to_list(Pbase base)
Most includes are centralized here.
entity get_ith_template_dummy(int)
entity get_ith_cycle_dummy(int)
entity get_ith_template_prime(int)
entity get_ith_cycle_prime(int)
entity get_ith_block_dummy(int)
entity get_ith_block_prime(int)
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783

References add_to_list_of_vars, array_to_template, base_to_list(), CONS, DEBUG_ELST, ENTITY, gen_remove(), get_ith_array_dummy(), get_ith_array_prime(), get_ith_block_dummy(), get_ith_block_prime(), get_ith_cycle_dummy(), get_ith_cycle_prime(), get_ith_local_dummy(), get_ith_local_prime(), get_ith_processor_dummy(), get_ith_processor_prime(), get_ith_template_dummy(), get_ith_template_prime(), get_ith_temporary_dummy(), MAP, NIL, pl, processors_dim_replicated_p(), TCST, template_to_processors, and variable_entity_dimension().

Referenced by hpf_remapping().

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

◆ root_statement_remapping_inits()

statement root_statement_remapping_inits ( statement  root)

returns the initialization statement: must initialize the status and liveness of arrays

of statement

of entity

LIVENESS(...) = .TRUE. STATUS(...) = ...

LIVENESS(...) = .FALSE.

Parameters
rootoot

Definition at line 1265 of file remapping.c.

1267 {
1268  list /* of statement */ ls = NIL;
1269  list /* of entity */ le =
1271 
1272  /* LIVENESS(...) = .TRUE.
1273  * STATUS(...) = ...
1274  */
1275  MAP(RENAMING, r,
1277  load_renamings(root));
1278 
1279  /* LIVENESS(...) = .FALSE.
1280  */
1281  MAP(ENTITY, array,
1283  ls = CONS(STATEMENT, generate_all_liveness(array, false), ls),
1284  le);
1285 
1286  gen_free_list(le), le = NIL;
1287 
1288  return make_block_statement(ls);
1289 }
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
list list_of_distributed_arrays_for_module(entity module)
returns the list of entities that are 'local' to module
Definition: declarations.c:72
#define primary_entity_p(a)
bool bound_dynamic_hpf_p(entity)
statement generate_all_liveness(entity primary, bool val)
Definition: remapping.c:940
static statement update_runtime_for_remapping(entity trg)
Definition: remapping.c:829

References array, bound_dynamic_hpf_p(), CONS, ENTITY, gen_free_list(), generate_all_liveness(), get_current_module_entity(), list_of_distributed_arrays_for_module(), load_renamings(), make_block_statement(), MAP, NIL, primary_entity_p, RENAMING, renaming_new, STATEMENT, and update_runtime_for_remapping().

Referenced by hpf_compiler().

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

◆ set_array_status_to_target()

static statement set_array_status_to_target ( entity  trg)
static

mapping status

MSTATUS(primary_n)

Definition at line 801 of file remapping.c.

802 {
803  int trg_n = load_hpf_number(trg),
804  prm_n = load_hpf_number(load_primary_entity(trg));
805  entity m_status = hpfc_name_to_entity(MSTATUS); /* mapping status */
806  expression m_stat_ref;
807 
808  /* MSTATUS(primary_n) */
809  m_stat_ref =
811  (make_reference(m_status,
812  CONS(EXPRESSION, int_to_expression(prm_n), NIL)));
813 
814  return make_assign_statement(m_stat_ref, int_to_expression(trg_n));
815 }

References CONS, EXPRESSION, hpfc_name_to_entity(), int_to_expression(), load_hpf_number(), load_primary_entity(), make_assign_statement(), make_reference(), MSTATUS, NIL, and reference_to_expression().

Referenced by generate_remapping_guard(), remapping_compile(), and update_runtime_for_remapping().

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

◆ set_live_status()

static statement set_live_status ( entity  trg,
_UNUSED_ bool  val 
)
static

Definition at line 818 of file remapping.c.

821 {
822  int trg_n = load_hpf_number(load_similar_mapping(trg));
823 
825  bool_to_expression(true));
826 }

References bool_to_expression(), live_mapping_expression(), load_hpf_number(), load_similar_mapping(), and make_assign_statement().

Referenced by update_runtime_for_remapping().

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

◆ update_runtime_for_remapping()

static statement update_runtime_for_remapping ( entity  trg)
static

Definition at line 829 of file remapping.c.

830 {
831  statement s = set_live_status(trg, true);
832 
833  {
834  string comment =
835  strdup(concatenate("! direct remapping for ",
836  entity_local_name(load_primary_entity(trg)), "\n", NULL));
838  free(comment);
839  }
840 
841  return make_block_statement
842  (CONS(STATEMENT, s,
844 }
static statement set_live_status(entity trg, _UNUSED_ bool val)
Definition: remapping.c:818

References comment(), concatenate(), CONS, entity_local_name(), free(), insert_comments_to_statement(), load_primary_entity(), make_block_statement(), NIL, set_array_status_to_target(), set_live_status(), STATEMENT, and strdup().

Referenced by root_statement_remapping_inits().

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

Variable Documentation

◆ l_found

list l_found
static

quick recursion to find the entities referenced in a statement.

the list is allocated and returned. of entity

Definition at line 1174 of file remapping.c.

Referenced by list_of_referenced_entities(), loop_rwt(), and reference_rwt().