PIPS
compile_mpi.c File Reference
#include "defines-local.h"
#include "accel-util.h"
#include "semantics.h"
#include "workspace-util.h"
#include "prettyprint.h"
+ Include dependency graph for compile_mpi.c:

Go to the source code of this file.

Functions

static string step_head_hook (entity __attribute__((unused)) e)
 Copyright 2007-2012 Alain Muller, Frederique Silber-Chaussumier. More...
 
static void loopbounds_substitution (entity new_module, loop loop_stmt)
 
static statement compile_loopslices (entity new_module, loop loop_stmt)
 
static statement compile_loopbounds (entity new_module, loop loop_stmt, statement work_stmt)
 
static void compile_reduction (set reductions_l[STEP_UNDEF_REDUCE], statement before_stmt, statement after_stmt)
 
static void loop_basic_workchunk_to_workchunk (statement stmt, list *recv_l, list *send_l)
 
static statement compile_master (entity new_module, statement work_stmt)
 
static statement compile_barrier (entity __attribute__((unused)) new_module, statement work_stmt)
 
static bool step_get_directive_reductions (step_directive drt, set *reductions_l)
 
static list duplicate_regions_referenced_entity (list referenced_entities, list regions_l)
 
static list keep_recv_or_send_referenced_entity (list recv_l, list send_l, list referenced_entities)
 
static void compile_body (statement directive_stmt, entity new_module, step_directive drt, int transformation, list referenced_entities, statement new_body, statement mpi_begin_stmt, statement work_stmt, statement mpi_end_stmt)
 
static void update_referenced_entities (statement new_body, list *referenced_entities)
 
statement compile_mpi (statement directive_stmt, string new_module_name, step_directive drt, int transformation)
 compile_mpi.c More...
 

Function Documentation

◆ compile_barrier()

static statement compile_barrier ( entity __attribute__((unused))  new_module,
statement  work_stmt 
)
static

Definition at line 235 of file compile_mpi.c.

236 {
237  pips_debug(1, "begin\n");
238 
240  insert_statement(work_stmt, call_stmt, false);
241 
242  pips_debug(1, "end\n");
243  return work_stmt;
244 }
#define RT_STEP_barrier
Definition: STEP_name.h:60
statement call_STEP_subroutine2(string name,...)
Definition: compile_RT.c:819
void insert_statement(statement, statement, bool)
This is the normal entry point.
Definition: statement.c:2570
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145

References call_STEP_subroutine2(), insert_statement(), pips_debug, and RT_STEP_barrier.

Referenced by compile_body().

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

◆ compile_body()

static void compile_body ( statement  directive_stmt,
entity  new_module,
step_directive  drt,
int  transformation,
list  referenced_entities,
statement  new_body,
statement  mpi_begin_stmt,
statement  work_stmt,
statement  mpi_end_stmt 
)
static

Definition at line 331 of file compile_mpi.c.

333 {
334  bool loop_p = false;
335  set reductions_l[STEP_UNDEF_REDUCE];
336  bool reduction_p = false;
337 
339 
340  statement_effects send_regions = (statement_effects)db_get_memory_resource(DBR_STEP_SEND_REGIONS, get_current_module_name(), true);
341  list send_l = duplicate_regions_referenced_entity(referenced_entities, effects_effects(apply_statement_effects(send_regions, directive_stmt)));
342  statement_effects recv_regions = (statement_effects)db_get_memory_resource(DBR_STEP_RECV_REGIONS, get_current_module_name(), true);
343  list recv_l = duplicate_regions_referenced_entity(referenced_entities, effects_effects(apply_statement_effects(recv_regions, directive_stmt)));
344 
345 
346  pips_assert("step_directive_type(drt)",
349  step_directive_type(drt) == STEP_DO ||
353 
355 
356  loop loop_stmt = loop_undefined;
357 
359  {
360  generate_call_init_regionArray(referenced_entities, mpi_begin_stmt, mpi_end_stmt);
361  }
363  {
364  list l = keep_recv_or_send_referenced_entity(recv_l, send_l, referenced_entities);
365  generate_call_init_regionArray(l, mpi_begin_stmt, mpi_end_stmt);
366  gen_free_list(l);
367  }
368 
370  {
371  statement loopslices_stmt = statement_undefined;
372  list work_block = statement_block(work_stmt);
373 
374  loop_stmt = statement_loop(STATEMENT(CAR(statement_block(STATEMENT(CAR(work_block))))));
375  loop_p = true;
376 
377  pips_debug(2, "loop_stmt = %p\n", loop_stmt);
378 
379  loopslices_stmt = compile_loopslices(new_module, loop_stmt);
380  insert_statement(mpi_begin_stmt, loopslices_stmt, false);
381 
382  loopbounds_substitution(new_module, loop_stmt);
383  work_stmt = compile_loopbounds(new_module, loop_stmt, work_stmt);
384  loop_basic_workchunk_to_workchunk(directive_stmt, &recv_l, &send_l);
385  }
386 
387 
388  if (step_directive_type(drt) == STEP_MASTER)
389  {
390  work_stmt = compile_master(new_module, work_stmt);
391  }
392 
393  if (step_directive_type(drt) == STEP_BARRIER)
394  {
395  work_stmt = compile_barrier(new_module, work_stmt);
396  }
397 
398  reduction_p = step_get_directive_reductions(drt, reductions_l);
399  if (reduction_p)
400  compile_reduction(reductions_l, mpi_begin_stmt, mpi_end_stmt);
401 
402  if (recv_l != NIL)
403  {
404  pips_debug(2, "compile RECV regions\n");
405  list send_as_comm_l = list_undefined;
406  compile_regions(new_module, recv_l, loop_p, loop_stmt, send_as_comm_l, reductions_l, mpi_begin_stmt, mpi_end_stmt);
407  }
408 
409  if (send_l != NIL)
410  {
411  pips_debug(2, "compile SEND regions\n");
412  list send_as_comm_l = effects_effects(apply_statement_effects(send_regions, directive_stmt));
413  compile_regions(new_module, send_l, loop_p, loop_stmt, send_as_comm_l, reductions_l, mpi_begin_stmt, mpi_end_stmt);
414  }
415 
416  generate_call_construct_begin_construct_end(new_module, drt, mpi_begin_stmt, mpi_end_stmt);
417 
418  ifdebug(2)
419  {
420  pips_debug(2, "mpi_begin_stmt\n");
421  print_statement(mpi_begin_stmt);
422  pips_debug(2, "mpi_end_stmt\n");
423  print_statement(mpi_end_stmt);
424  }
425 
426  /*
427  Body building
428  */
429  statement begin_work_stmt = make_plain_continue_statement();
430  statement end_work_stmt = make_plain_continue_statement();
431  put_a_comment_on_a_statement(begin_work_stmt, strdup("\nBEGIN WORK"));
432  put_a_comment_on_a_statement(end_work_stmt, strdup("END WORK\n"));
433  insert_statement(work_stmt, begin_work_stmt, true);
434  insert_statement(work_stmt, end_work_stmt, false);
435  insert_statement(new_body, work_stmt, false);
436 
439  {
440  compile_omp(directive_stmt, drt);
441  add_omp_guard(&mpi_begin_stmt);
442  add_omp_guard(&mpi_end_stmt);
443  }
444 
445 
446  if(!empty_statement_p(mpi_begin_stmt))
447  insert_statement(new_body, mpi_begin_stmt, true);
448  if(!empty_statement_p(mpi_end_stmt))
449  insert_statement(new_body, mpi_end_stmt, false);
450 
453  {
454  add_omp_guard(&new_body);
455  }
456 }
effects apply_statement_effects(statement_effects f, statement k)
Definition: effects.c:1007
void generate_call_construct_begin_construct_end(entity new_module, step_directive drt, statement mpi_begin_stmt, statement mpi_end_stmt)
Definition: compile_RT.c:60
void generate_call_init_regionArray(list referenced_entities, statement before, statement __attribute__((unused)) after)
Definition: compile_RT.c:210
static bool step_get_directive_reductions(step_directive drt, set *reductions_l)
Definition: compile_mpi.c:246
static void loop_basic_workchunk_to_workchunk(statement stmt, list *recv_l, list *send_l)
Definition: compile_mpi.c:125
static statement compile_loopbounds(entity new_module, loop loop_stmt, statement work_stmt)
Definition: compile_mpi.c:51
static statement compile_barrier(entity __attribute__((unused)) new_module, statement work_stmt)
Definition: compile_mpi.c:235
static list keep_recv_or_send_referenced_entity(list recv_l, list send_l, list referenced_entities)
Definition: compile_mpi.c:302
static list duplicate_regions_referenced_entity(list referenced_entities, list regions_l)
Definition: compile_mpi.c:288
static statement compile_loopslices(entity new_module, loop loop_stmt)
Definition: compile_mpi.c:36
static void loopbounds_substitution(entity new_module, loop loop_stmt)
Definition: compile_mpi.c:27
static void compile_reduction(set reductions_l[STEP_UNDEF_REDUCE], statement before_stmt, statement after_stmt)
Definition: compile_mpi.c:68
static statement compile_master(entity new_module, statement work_stmt)
Definition: compile_mpi.c:205
void compile_regions(entity new_module, list regions_l, bool loop_p, loop loop_stmt, list send_as_comm_l, set reductions_l[STEP_UNDEF_REDUCE], statement mpi_begin_stmt, statement mpi_end_stmt)
static bool reduction_p(set reductions_l[STEP_UNDEF_REDUCE], entity e)
struct _newgen_struct_statement_effects_ * statement_effects
Definition: effects.h:210
#define effects_effects(x)
Definition: effects.h:710
const char * get_current_module_name(void)
Get the name of the current module.
Definition: static.c:121
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
list statement_block(statement)
Get the list of block statements of a statement sequence.
Definition: statement.c:1338
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
bool empty_statement_p(statement)
Test if a statement is empty.
Definition: statement.c:391
void put_a_comment_on_a_statement(statement, string)
Similar to try_to_put_a_comment_on_a_statement() but insert a CONTINUE to put the comment on it if th...
Definition: statement.c:1863
statement make_plain_continue_statement(void)
Make a simple continue statement to be used as a NOP or ";" in C.
Definition: statement.c:964
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define assert(ex)
Definition: newgen_assert.h:41
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
#define loop_undefined
Definition: ri.h:1612
#define entity_undefined_p(x)
Definition: ri.h:2762
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
char * strdup()
#define ifdebug(n)
Definition: sg.c:47
statement compile_omp(statement stmt, step_directive d)
compile.c
Definition: compile.c:32
void add_omp_guard(statement *block)
Definition: compile.c:62
#define STEP_TRANSFORMATION_HYBRID
Definition: defines-local.h:57
void step_directive_type_print(step_directive drt)
Definition: directives.c:51
#define STEP_THREADPRIVATE
Definition: step_common.h:50
#define STEP_UNDEF_REDUCE
Definition: step_common.h:95
#define STEP_PARALLEL
Handled construction.
Definition: step_common.h:43
#define STEP_PARALLEL_DO
Definition: step_common.h:45
#define STEP_MASTER
Definition: step_common.h:46
#define STEP_DO
Definition: step_common.h:44
#define STEP_BARRIER
Definition: step_common.h:48
#define step_directive_type(x)
Definition: step_private.h:429
FI: I do not understand why the type is duplicated at the set level.
Definition: set.c:59
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References add_omp_guard(), apply_statement_effects(), assert, CAR, compile_barrier(), compile_loopbounds(), compile_loopslices(), compile_master(), compile_omp(), compile_reduction(), compile_regions(), db_get_memory_resource(), duplicate_regions_referenced_entity(), effects_effects, empty_statement_p(), entity_undefined_p, gen_free_list(), generate_call_construct_begin_construct_end(), generate_call_init_regionArray(), get_current_module_entity(), get_current_module_name(), ifdebug, insert_statement(), keep_recv_or_send_referenced_entity(), list_undefined, loop_basic_workchunk_to_workchunk(), loop_undefined, loopbounds_substitution(), make_plain_continue_statement(), NIL, pips_assert, pips_debug, print_statement(), put_a_comment_on_a_statement(), reduction_p(), STATEMENT, statement_block(), statement_loop(), statement_undefined, STEP_BARRIER, step_directive_type, step_directive_type_print(), STEP_DO, step_get_directive_reductions(), STEP_MASTER, STEP_PARALLEL, STEP_PARALLEL_DO, STEP_THREADPRIVATE, STEP_TRANSFORMATION_HYBRID, STEP_UNDEF_REDUCE, and strdup().

Referenced by compile_mpi().

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

◆ compile_loopbounds()

static statement compile_loopbounds ( entity  new_module,
loop  loop_stmt,
statement  work_stmt 
)
static

Definition at line 51 of file compile_mpi.c.

52 {
54  statement rank_stmt;
55  statement get_loopbounds_stmt;
56  pips_debug(1, "begin\n");
57 
58 
59  rank_stmt = generate_call_get_rank(new_module);
60  get_loopbounds_stmt = generate_call_get_rank_loopbounds(new_module, loop_stmt);
61 
62  stmt = make_block_statement(make_statement_list(rank_stmt, get_loopbounds_stmt, work_stmt));
63 
64  pips_debug(1, "end\n");
65  return stmt;
66 }
statement generate_call_get_rank(entity new_module)
Definition: compile_RT.c:161
statement generate_call_get_rank_loopbounds(entity new_module, loop loop_stmt)
Definition: compile_RT.c:138
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
#define make_statement_list(stats...)
easy list constructor
Definition: statement.c:54

References generate_call_get_rank(), generate_call_get_rank_loopbounds(), make_block_statement(), make_statement_list, and pips_debug.

Referenced by compile_body().

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

◆ compile_loopslices()

static statement compile_loopslices ( entity  new_module,
loop  loop_stmt 
)
static

Definition at line 36 of file compile_mpi.c.

37 {
39  statement commsize_stmt;
40  statement loopslice_stmt;
41  pips_debug(1, "begin new_module = %p, loop_stmt = %p\n", new_module, loop_stmt);
42 
43  commsize_stmt = generate_call_get_commsize(new_module);
44  loopslice_stmt = generate_call_compute_loopslices(new_module, loop_stmt);
45 
46  stmt = make_block_statement(make_statement_list(commsize_stmt, loopslice_stmt));
47  pips_debug(1, "end\n");
48  return stmt;
49 }
statement generate_call_get_commsize(entity new_module)
Definition: compile_RT.c:193
statement generate_call_compute_loopslices(entity new_module, loop loop_stmt)
Definition: compile_RT.c:176

References generate_call_compute_loopslices(), generate_call_get_commsize(), make_block_statement(), make_statement_list, and pips_debug.

Referenced by compile_body().

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

◆ compile_master()

static statement compile_master ( entity  new_module,
statement  work_stmt 
)
static

Definition at line 205 of file compile_mpi.c.

206 {
207  statement stmt;
208  pips_debug(1, "begin\n");
209 
210  entity rank = get_entity_step_rank(new_module);
211  expression expr_rank = entity_to_expression(rank);
212 
213 
214  /*
215  Generation of
216  STEP_GET_RANK(&STEP_COMM_RANK);
217  */
219 
220  /*
221  Generation of
222  if (STEP_COMM_RANK==0) {}
223  */
225  expr_rank,
226  int_to_expression(0)),
227  work_stmt, make_block_statement(NIL))));
228 
229  stmt = make_block_statement(make_statement_list(rank_stmt, if_stmt));
230 
231  pips_debug(1, "end\n");
232  return stmt;
233 }
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
instruction make_instruction_test(test _field_)
Definition: ri.c:1172
#define RT_STEP_get_rank
Definition: STEP_name.h:68
expression get_expression_addr(expression expr)
compile_RT.c
Definition: compile_RT.c:27
entity get_entity_step_rank(entity module)
Definition: compile_RT.c:513
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
static entity rank
#define 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
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

References call_STEP_subroutine2(), entity_intrinsic(), entity_to_expression(), EQUAL_OPERATOR_NAME, get_entity_step_rank(), get_expression_addr(), instruction_to_statement(), int_to_expression(), make_block_statement(), make_instruction_test(), make_statement_list, make_test(), MakeBinaryCall(), NIL, pips_debug, rank, and RT_STEP_get_rank.

Referenced by compile_body().

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

◆ compile_mpi()

statement compile_mpi ( statement  directive_stmt,
string  new_module_name,
step_directive  drt,
int  transformation 
)

compile_mpi.c

Parameters
directive_stmtirective_stmt
new_module_nameew_module_name
drtrt
transformationransformation

Definition at line 517 of file compile_mpi.c.

518 {
519  pips_debug(1, "begin current module %p : %s\n", get_current_module_entity(), get_current_module_name());
520 
521  list statements_to_outline = make_statement_list(directive_stmt);
523  pips_assert("new_module", !entity_undefined_p(new_module));
524 
525  // Init hash table
526  hash_table entity_to_effective_parameter = outliner_init(new_module, statements_to_outline);
527 
528  // Find referenced entities in statements_to_outline
530  list referenced_entities = outliner_scan(new_module, statements_to_outline, new_body);
531 
532  // Generate the body of the new module
533  statement work_stmt = make_block_statement(gen_copy_seq(statements_to_outline));
534  statement mpi_begin_stmt = make_empty_block_statement();
535  statement mpi_end_stmt = make_empty_block_statement();
536  compile_body(directive_stmt, new_module, drt, transformation, referenced_entities, new_body, mpi_begin_stmt, work_stmt, mpi_end_stmt);
537 
538  // Some entities may be added by region_to_statement. Ensure they will be passed as parameters
539  update_referenced_entities(new_body, &referenced_entities);
540 
541  // Update hash table and build parameters
542  list effective_parameters = NIL, formal_parameters = NIL;
543  outliner_parameters(new_module, new_body, referenced_entities, entity_to_effective_parameter, &effective_parameters, &formal_parameters);
544 
545  // Patch parameters for side effects
547  outliner_patch_parameters(statements_to_outline, referenced_entities, effective_parameters, formal_parameters, new_body, mpi_begin_stmt, mpi_end_stmt);
548 
549  step_RT_set_local_declarations(new_module, new_body);
550 
551  // Source file generation
553  outliner_file(new_module, formal_parameters, &new_body);
555 
557 
558  statement call_stmt = outliner_call(new_module, statements_to_outline, effective_parameters);
559 
560  pips_debug(1, "end\n");
561  return call_stmt;
562 }
list outliner_scan(entity, list, statement)
Definition: outlining.c:555
void outliner_file(entity, list, statement *)
Definition: outlining.c:1138
hash_table outliner_init(entity, list)
Definition: outlining.c:546
statement outliner_call(entity, list, list)
Definition: outlining.c:1235
void outliner_patch_parameters(list, list, list, list, statement, statement, statement)
we need to patch parameters , effective parameters and body in C because parameters are passed by cop...
Definition: outlining.c:809
void outliner_parameters(entity, statement, list, hash_table, list *, list *)
Definition: outlining.c:698
void step_RT_set_local_declarations(entity module, statement body)
Definition: compile_RT.c:376
void step_RT_clean_local()
Definition: compile_RT.c:255
static void update_referenced_entities(statement new_body, list *referenced_entities)
Definition: compile_mpi.c:459
static string step_head_hook(entity __attribute__((unused)) e)
Copyright 2007-2012 Alain Muller, Frederique Silber-Chaussumier.
Definition: compile_mpi.c:20
static void compile_body(statement directive_stmt, entity new_module, step_directive drt, int transformation, list referenced_entities, statement new_body, statement mpi_begin_stmt, statement work_stmt, statement mpi_end_stmt)
Definition: compile_mpi.c:331
statement make_empty_block_statement(void)
Build an empty statement (block/sequence)
Definition: statement.c:625
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
Definition: naming-local.h:101
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
void reset_prettyprinter_head_hook()
Definition: misc.c:3964
void set_prettyprinter_head_hook(string(*f)(entity))
Definition: misc.c:3963
bool c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410

References c_module_p(), compile_body(), concatenate(), entity_domain, entity_undefined_p, gen_copy_seq(), gen_find_tabulated(), get_current_module_entity(), get_current_module_name(), make_block_statement(), make_empty_block_statement(), make_statement_list, MODULE_SEP_STRING, NIL, outliner_call(), outliner_file(), outliner_init(), outliner_parameters(), outliner_patch_parameters(), outliner_scan(), pips_assert, pips_debug, reset_prettyprinter_head_hook(), set_prettyprinter_head_hook(), step_head_hook(), step_RT_clean_local(), step_RT_set_local_declarations(), TOP_LEVEL_MODULE_NAME, and update_referenced_entities().

Referenced by compile_rewrite().

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

◆ compile_reduction()

static void compile_reduction ( set  reductions_l[STEP_UNDEF_REDUCE],
statement  before_stmt,
statement  after_stmt 
)
static

Definition at line 68 of file compile_mpi.c.

69 {
70  int op;
72 
73  pips_debug(1, "begin\n");
74 
75  pips_assert("block before", !statement_undefined_p(before_stmt) && statement_block_p(before_stmt));
76  pips_assert("block after", !statement_undefined_p(after_stmt) && statement_block_p(after_stmt));
77 
78  for (op = 0; op < STEP_UNDEF_REDUCE; op++)
79  if (!set_empty_p(reductions_l[op]))
80  {
82  {
83  expression variable_expr, variable_type_expr;
84  statement reduction_init_stmt;
85  /*
86  Generation of
87  STEP_INITREDUCTION(&sum, STEP_SUM, STEP_INTEGER4);
88  */
89 
91 
92  variable_expr = entity_to_expression(variable);
93  variable_type_expr = entity_to_expression(step_type(variable));
94  reduction_init_stmt = call_STEP_subroutine2(RT_STEP_initreduction, get_expression_addr(variable_expr), entity_to_expression(MakeConstant(op_name[op], is_basic_string)), variable_type_expr, NULL);
95 
96  insert_statement(before_stmt,
97  reduction_init_stmt, false);
98 
99  /*
100  Generation of
101  STEP_REDUCTION(&sum);
102  */
103 
104  /*
105  list arglist = CONS(EXPRESSION, variable_expr,
106  CONS(EXPRESSION, entity_to_expression(MakeConstant(op_name[op], is_basic_string)),
107  NIL));
108  insert_statement(before_stmt,
109  call_STEP_subroutine(RT_STEP_initreduction, arglist, variable), false);
110  */
111 
112  insert_statement(after_stmt,
113  call_STEP_subroutine2(RT_STEP_reduction, get_expression_addr(variable_expr), NULL), false);
114  }
115  }
116 
117  pips_debug(1, "end\n");
118 }
#define STEP_SUM_REDUCE_NAME
Definition: STEP_name.h:47
#define STEP_PROD_REDUCE_NAME
Definition: STEP_name.h:41
#define STEP_MIN_REDUCE_NAME
Definition: STEP_name.h:36
#define RT_STEP_initreduction
Definition: STEP_name.h:72
#define RT_STEP_reduction
Definition: STEP_name.h:73
#define STEP_MAX_REDUCE_NAME
Definition: STEP_name.h:35
void check_entity_step_type(entity data)
Definition: compile_RT.c:845
entity step_type(entity data)
Definition: compile_RT.c:542
entity MakeConstant(string name, tag bt)
Make a Fortran constant.
Definition: constant.c:351
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
bool set_empty_p(const set)
tell whether set s is empty.
Definition: set.c:367
list set_to_sorted_list(const set, gen_cmp_func_t)
Definition: set.c:447
int(* gen_cmp_func_t)(const void *, const void *)
Definition: newgen_types.h:114
#define statement_block_p(stat)
int compare_entities(const entity *pe1, const entity *pe2)
Comparison function for qsort.
Definition: entity.c:1328
@ is_basic_string
Definition: ri.h:576
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define statement_undefined_p(x)
Definition: ri.h:2420

References call_STEP_subroutine2(), check_entity_step_type(), compare_entities(), ENTITY, entity_to_expression(), FOREACH, get_expression_addr(), insert_statement(), is_basic_string, MakeConstant(), pips_assert, pips_debug, RT_STEP_initreduction, RT_STEP_reduction, set_empty_p(), set_to_sorted_list(), statement_block_p, statement_undefined_p, STEP_MAX_REDUCE_NAME, STEP_MIN_REDUCE_NAME, STEP_PROD_REDUCE_NAME, STEP_SUM_REDUCE_NAME, step_type(), and STEP_UNDEF_REDUCE.

Referenced by compile_body().

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

◆ duplicate_regions_referenced_entity()

static list duplicate_regions_referenced_entity ( list  referenced_entities,
list  regions_l 
)
static

Definition at line 288 of file compile_mpi.c.

289 {
290  list l = NIL;
291 
292  FOREACH(REGION, reg, regions_l)
293  {
294  if (gen_in_list_p(region_entity(reg), referenced_entities))
295  l = CONS(REGION, copy_effect(reg), l);
296  else
297  pips_debug(2,"drop entity %s not in referenced_entities\n", entity_name(region_entity(reg)));
298  }
299  return gen_nreverse(l);
300 }
effect copy_effect(effect p)
EFFECT.
Definition: effects.c:448
#define region_entity(reg)
#define REGION
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
#define entity_name(x)
Definition: ri.h:2790

References CONS, copy_effect(), entity_name, FOREACH, gen_in_list_p(), gen_nreverse(), NIL, pips_debug, REGION, and region_entity.

Referenced by compile_body().

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

◆ keep_recv_or_send_referenced_entity()

static list keep_recv_or_send_referenced_entity ( list  recv_l,
list  send_l,
list  referenced_entities 
)
static

Definition at line 302 of file compile_mpi.c.

303 {
304  list l = NIL;
305  set recv_s = set_make(set_pointer);
306  set send_s = set_make(set_pointer);
307 
308  FOREACH(REGION, r, recv_l)
309  {
310  recv_s = set_add_element(recv_s, recv_s, region_entity(r));
311  }
312  FOREACH(REGION, r, send_l)
313  {
314  send_s = set_add_element(send_s, send_s, region_entity(r));
315  }
316 
317  FOREACH(ENTITY, e, referenced_entities)
318  {
319  if (set_belong_p(recv_s, e) || set_belong_p(send_s, e))
320  l = CONS(ENTITY, e, l);
321  else
322  pips_debug(2, "entity %s in referenced entities but not in recv nor send regions\n", entity_name(e));
323  }
324 
325  set_free(recv_s);
326  set_free(send_s);
327 
328  return gen_nreverse(l);
329 }
void set_free(set)
Definition: set.c:332
bool set_belong_p(const set, const void *)
Definition: set.c:194
@ set_pointer
Definition: newgen_set.h:44
set set_make(set_type)
Create an empty set of any type but hash_private.
Definition: set.c:102
set set_add_element(set, const set, const void *)
Definition: set.c:152

References CONS, ENTITY, entity_name, FOREACH, gen_nreverse(), NIL, pips_debug, REGION, region_entity, set_add_element(), set_belong_p(), set_free(), set_make(), and set_pointer.

Referenced by compile_body().

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

◆ loop_basic_workchunk_to_workchunk()

static void loop_basic_workchunk_to_workchunk ( statement  stmt,
list recv_l,
list send_l 
)
static

find the real upper and lower bounds

Definition at line 125 of file compile_mpi.c.

126 {
127  pips_debug(1, "begin\n");
128  list dir_block = statement_block(stmt);
129  loop l = statement_loop(STATEMENT(CAR(dir_block)));
130  entity index = loop_index(l);
131  range r = loop_range(l);
132 
133  /* find the real upper and lower bounds */
134  int incr_lb = 0;
135  int incr_ub = 0;
136  expression e_incr = range_increment(r);
138  // is the loop increment numerically known? Is its sign known?
139  expression_and_precondition_to_integer_interval(e_incr, loop_prec, &incr_lb, &incr_ub);
140 
141  int incr = 0;
142  if (incr_lb == incr_ub) {
143  if (incr_lb == 0) {
144  pips_user_error("Illegal null increment\n");
145  }
146  else
147  incr = incr_lb;
148  }
149  else if (incr_lb >= 1) {
150  incr = 1;
151  }
152  else if (incr_ub <= -1) {
153  incr = -1;
154  }
157 
158  // to check later in update_referenced_entities
161 
162  if (incr < 0)
163  {
164  entity tmp = e_lb;
165  e_lb = e_ub;
166  e_ub = tmp;
167  }
168  /*
169  Add constraints
170  Projection
171  */
172  Psysteme sc_bounds = sc_new();
173  // contrainte lb - index <= 0
175  // contrainte index - ub <= 0
177  sc_creer_base(sc_bounds);
178 
179  *send_l = all_regions_sc_append(*send_l, sc_bounds, true);
180  *recv_l = all_regions_sc_append(*recv_l, sc_bounds, true);
181  project_regions_along_variables(*send_l, CONS(entity, index, NIL));
182  project_regions_along_variables(*recv_l, CONS(entity, index, NIL));
183 
184  FOREACH(REGION, reg, *send_l)
185  {
187  }
188  FOREACH(REGION, reg, *recv_l)
189  {
191  }
192 
193  ifdebug(1)
194  {
195  pips_debug(1, "SEND after projection and rectangularization : \n");
196  print_rw_regions(*send_l);
197  pips_debug(1, "RECV after projection and rectangularization : \n");
198  print_rw_regions(*recv_l);
199  }
200 
201  pips_debug(1, "end\n");
202 }
transformer make_transformer(list a1, predicate a2)
Definition: ri.c:2649
predicate make_predicate(Psysteme a1)
Definition: ri.c:1820
#define STEP_BOUNDS_UP(index)
Definition: STEP_name.h:9
#define STEP_BOUNDS_LOW(index)
Definition: STEP_name.h:8
region rectangularization_region(region reg)
Definition: analyse.c:395
#define VALUE_ZERO
#define VALUE_MONE
#define VALUE_ONE
set step_created_entity
Definition: compile_RT.c:245
entity step_local_loop_index(entity module, string name)
Definition: compile_RT.c:534
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
list all_regions_sc_append(list, Psysteme, bool)
void print_rw_regions(list)
void project_regions_along_variables(list, list)
void project_regions_along_variables(list l_reg, list l_param) input : a list of regions to project,...
#define pips_user_error
Definition: misc-local.h:147
#define range_increment(x)
Definition: ri.h:2292
#define loop_range(x)
Definition: ri.h:1642
#define loop_index(x)
Definition: ri.h:1640
Psysteme sc_rn(Pbase b)
Psysteme sc_rn(Pbase b): build a Psysteme without constraints to define R^n, where n is b's dimension...
Definition: sc_alloc.c:336
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
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 insert_ineq_begin_sc(Psysteme sc, Pcontrainte ineq)
This function inserts the constraint ineq at the beginning of the system of inequalities of sc.
Definition: sc_insert_eq.c:40
void expression_and_precondition_to_integer_interval(expression, transformer, int *, int *)
Evaluate expression e in context p, assuming that e is an integer expression.
Definition: utils.c:325
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
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 all_regions_sc_append(), CAR, CONS, contrainte_make(), expression_and_precondition_to_integer_interval(), FOREACH, get_current_module_entity(), ifdebug, insert_ineq_begin_sc(), loop_index, loop_range, make_predicate(), make_transformer(), NIL, pips_debug, pips_user_error, print_rw_regions(), project_regions_along_variables(), range_increment, rectangularization_region(), REGION, sc_creer_base(), sc_new(), sc_rn(), set_add_element(), STATEMENT, statement_block(), statement_loop(), STEP_BOUNDS_LOW, STEP_BOUNDS_UP, step_created_entity, step_local_loop_index(), strdup(), TCST, VALUE_MONE, VALUE_ONE, VALUE_ZERO, vect_make(), vect_new(), and VECTEUR_NUL.

Referenced by compile_body().

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

◆ loopbounds_substitution()

static void loopbounds_substitution ( entity  new_module,
loop  loop_stmt 
)
static

Definition at line 27 of file compile_mpi.c.

28 {
29  entity index = loop_index(loop_stmt);
30  range r = loop_range(loop_stmt);
31 
34 }
#define range_upper(x)
Definition: ri.h:2290
#define range_lower(x)
Definition: ri.h:2288

References entity_to_expression(), loop_index, loop_range, range_lower, range_upper, STEP_BOUNDS_LOW, STEP_BOUNDS_UP, and step_local_loop_index().

Referenced by compile_body().

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

◆ step_get_directive_reductions()

static bool step_get_directive_reductions ( step_directive  drt,
set reductions_l 
)
static

Definition at line 246 of file compile_mpi.c.

247 {
248  bool reduction_p = false;
249  int op;
250 
251  pips_debug(1, "begin\n");
252 
253  for(op = 0; op < STEP_UNDEF_REDUCE; op++)
254  reductions_l[op] = set_make(set_pointer);
255 
257  {
258  switch (step_clause_tag(c))
259  {
262  set_add_element(reductions_l[op], reductions_l[op], variable);
263  reduction_p = true;
264  }, step_clause_reduction(c));
265  break;
274  break;
275  default: pips_assert("clause not compiled", 0);
276  }
277  }
278 
279  pips_debug(1, "end\n");
280  return reduction_p;
281 }
@ is_step_clause_reduction
Definition: step_private.h:248
@ is_step_clause_private
Definition: step_private.h:249
@ is_step_clause_transformation
Definition: step_private.h:251
@ is_step_clause_nowait
Definition: step_private.h:252
@ is_step_clause_copyin
Definition: step_private.h:254
@ is_step_clause_threadprivate
Definition: step_private.h:253
@ is_step_clause_schedule
Definition: step_private.h:256
@ is_step_clause_firstprivate
Definition: step_private.h:255
@ is_step_clause_shared
Definition: step_private.h:250
#define step_directive_clauses(x)
Definition: step_private.h:433
#define step_clause_tag(x)
Definition: step_private.h:287
#define STEP_CLAUSE(x)
STEP_CLAUSE.
Definition: step_private.h:227
#define step_clause_reduction(x)
Definition: step_private.h:290
#define MAP_ENTITY_INT_MAP(k, v, c, f)
Definition: step_private.h:217

References FOREACH, is_step_clause_copyin, is_step_clause_firstprivate, is_step_clause_nowait, is_step_clause_private, is_step_clause_reduction, is_step_clause_schedule, is_step_clause_shared, is_step_clause_threadprivate, is_step_clause_transformation, MAP_ENTITY_INT_MAP, pips_assert, pips_debug, reduction_p(), set_add_element(), set_make(), set_pointer, STEP_CLAUSE, step_clause_reduction, step_clause_tag, step_directive_clauses, and STEP_UNDEF_REDUCE.

Referenced by compile_body().

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

◆ step_head_hook()

static string step_head_hook ( entity __attribute__((unused))  e)
static

Copyright 2007-2012 Alain Muller, Frederique Silber-Chaussumier.

This file is part of STEP.

The program is distributed under the terms of the GNU General Public License.

Definition at line 20 of file compile_mpi.c.

21 {
22  return strdup(concatenate
23  (" implicit none\n",
24  " include \"STEP.h\"\n", NULL));
25 }

References concatenate(), and strdup().

Referenced by compile_mpi().

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

◆ update_referenced_entities()

static void update_referenced_entities ( statement  new_body,
list referenced_entities 
)
static

Definition at line 459 of file compile_mpi.c.

460 {
461  int local_dbg_lvl = 2;
462  set new_entities = set_make(set_pointer);
463  list l_body = make_statement_list(new_body);
464 
466 
468  {
469  SET_FOREACH(entity, step_symbolic_e, step_created_symbolic)
470  {
471  pips_debug(local_dbg_lvl, "drop entities step_symbolic : %s\n", entity_name(step_symbolic_e));
472  new_entities = set_del_element(new_entities, new_entities, step_symbolic_e);
473  }
474  }
475 
476  FOREACH(ENTITY, e, *referenced_entities)
477  {
478  pips_debug(local_dbg_lvl, "drop referenced entity : %s\n", entity_name(e));
479  new_entities = set_del_element(new_entities, new_entities, e);
480  }
481 
483  {
485  {
486  pips_debug(local_dbg_lvl, "drop entities step_created : %s\n", entity_name(created_e));
487  new_entities = set_del_element(new_entities, new_entities, created_e);
488  }
489  }
490 
492  {
493  pips_debug(local_dbg_lvl, "drop declared entity : %s\n", entity_name(e));
494  new_entities = set_del_element(new_entities, new_entities, e);
495  }
496 
498  {
500  {
501  if(top_level_entity_p(e) && set_belong_p(new_entities, e))
502  {
503  pips_debug(local_dbg_lvl, "drop global entity : %s\n", entity_name(e));
504  new_entities = set_del_element(new_entities, new_entities, e);
505  }
506  }
507  }
508 
509  list new_e = set_to_sorted_list(new_entities, (gen_cmp_func_t)compare_entities);
510  set_free(new_entities);
511 
512  pips_debug(local_dbg_lvl, "New entities : "); print_entities(new_e); fprintf(stderr, "\n\n");
513 
514  *referenced_entities = gen_nconc(*referenced_entities, new_e);
515 }
list outliner_statements_referenced_entities(list)
outlining.c
Definition: outlining.c:251
set step_created_symbolic
Definition: compile_RT.c:276
string compilation_unit_of_module(const char *)
The output is undefined if the module is referenced but not defined in the workspace,...
Definition: module.c:350
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
list statements_to_declarations(list)
Returns the declarations contained in a list of statement.
Definition: statement.c:3265
set set_assign_list(set, const list)
assigns a list contents to a set all duplicated elements are lost
Definition: set.c:474
set set_del_element(set, const set, const void *)
Definition: set.c:265
#define set_undefined
Definition: newgen_set.h:48
#define SET_FOREACH(type_name, the_item, the_set)
enumerate set elements in their internal order.
Definition: newgen_set.h:78
#define set_undefined_p(s)
Definition: newgen_set.h:49
#define entity_declarations(e)
MISC: newgen shorthands.
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
void print_entities(list l)
Definition: entity.c:167
bool top_level_entity_p(entity e)
Check if the scope of entity e is global.
Definition: entity.c:1130
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References c_module_p(), compare_entities(), compilation_unit_of_module(), ENTITY, entity_declarations, entity_name, FOREACH, fprintf(), gen_nconc(), get_current_module_entity(), get_current_module_name(), make_statement_list, module_name_to_entity(), outliner_statements_referenced_entities(), pips_debug, print_entities(), set_assign_list(), set_belong_p(), set_del_element(), SET_FOREACH, set_free(), set_make(), set_pointer, set_to_sorted_list(), set_undefined, set_undefined_p, statements_to_declarations(), step_created_entity, step_created_symbolic, and top_level_entity_p().

Referenced by compile_mpi().

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