25 #include "pips_config.h"
46 #include "resources.h"
232 " use MPI_status for blocking function\n"
233 " use MPI_Request for non-blocking function\n");
305 pips_internal_error(
"MPI_Status and MPI_Request can't be use at the same time for MPI_Recv/MPI_Irecv instruction\n"
306 " use MPI_status for blocking receive (MPI_Recv)\n"
307 " use MPI_Request for non-blocking receive (MPI_Irecv)\n");
309 pips_internal_error(
"MPI_Status xor MPI_Request must be use present for MPI_Recv/MPI_Irecv instruction\n"
310 " use MPI_status for blocking receive (MPI_Recv)\n"
311 " use MPI_Request for non-blocking receive (MPI_Irecv)\n");
647 pips_assert(
"number of cluster can't be equal to 0", nbr_cluster != 0);
657 for (
int i = 0; i < nbr_cluster; ++i) {
668 for (
int i = 0; i < nbr_cluster; ++i) {
670 for (
int j = 0; j < nbr_cluster; ++j) {
850 return ctx.
tag[sender][receiver];
853 pips_assert(
"sender_cluster<nbr_cluster\n", sender<ctx->nbr_cluster);
854 pips_assert(
"receiver_cluster<nbr_cluster\n", receiver<ctx->nbr_cluster);
855 ctx->
tag[sender][receiver]++;
891 if (i != current_cluster) {
952 string dist =
"distributed";
954 return strstr(comments, dist) != NULL;
961 string dist =
"distributed";
962 string send =
"send";
964 return strstr(comments, dist) != NULL && strstr(comments, send) != NULL;
971 string dist =
"distributed";
972 string receive =
"receive";
974 return strstr(comments, dist) != NULL && strstr(comments, receive) != NULL;
993 pips_assert(
"statement stat is copy receive statement",
1009 pips_assert(
"statement stat is copy send statement",
1033 pips_assert(
"statement stat is copy receive statement",
1065 "Modify variable to use vriable of the cluster number %i", *receiv_cluster);
1123 for (
int i = 0; i < nbr_cluster; ++i) {
1133 for (
int i = 0; i < nbr_cluster; ++i) {
1135 pips_assert(
"receiv_statement must be undefined when we enter this function\n",
1160 for (
int i = 0; i < nbr_cluster; ++i) {
1173 for (
int i = 0; i < nbr_cluster; ++i) {
1207 for (
int i = 0; i < nbr_cluster; ++i) {
1235 for (
int i = 0; i < nbr_cluster; ++i) {
1267 for (
int i = 0; i < nbr_cluster; ++i) {
1357 ctx_inc_tag(ctx, sender_cluster, receiver_cluster);
1418 pips_debug(8,
"ctx_get_statement_work_on(*ctx)\n");
1420 pips_debug(8,
"end ctx_get_statement_work_on(*ctx)\n");
1447 pips_internal_error(
"This case never happen because sequence_working_false always return false\n");
1452 pips_internal_error(
"This case never happen because test_working_false always return false\n");
1510 bool need_more_com =
false;
1517 if (need_more_com) {
1520 pips_internal_error(
"some variables do not exist on receive cluster. Need to send/receive them.\n");
1642 intptr_t newsizeint = upint-lowint+1;
1647 "This case never happen...", newsizeint);
1664 while (oldindices !=
NIL) {
1671 oldindices =
CDR(oldindices);
1697 call send_call, mpi_send_call;
1782 nlower, nupper, nincrement,
1791 nlower, nupper, nincrement,
1821 bool need_more_com =
false;
1824 if (need_more_com) {
1827 pips_internal_error(
"some variables do not exist on receive cluster. Need to send/receive them.\n");
1856 bool need_more_com =
false;
1863 if (need_more_com) {
1866 pips_internal_error(
"some variables do not exist on receive cluster. Need to send them.\n");
1973 pips_internal_error(
"The statement must be the module statement (a sequence of instruction).\n");
1982 return new_module_statement ;
1992 bool good_result_p =
true;
1994 debug_on(
"MPI_GENERATION_DEBUG_LEVEL");
2046 return (good_result_p);
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
int get_int_property(const string)
call make_call(entity a1, list a2)
basic make_basic_typedef(entity _field_)
storage make_storage_rom(void)
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
expression copy_expression(expression p)
EXPRESSION.
statement copy_statement(statement p)
STATEMENT.
void free_extensions(extensions p)
bool statement_consistent_p(statement p)
bool expression_consistent_p(expression p)
void free_expression(expression p)
storage make_storage_ram(ram _field_)
void free_statement(statement p)
static reference ref
Current stmt (an integer)
static statement module_statement
void put_new_typedef(const char *)
This function is used by libraries "step"* and "task_parallelization".
struct _newgen_struct_statement_ * statement
entity make_constant_entity(string name, tag bt, size_t size)
For historical reason, call the Fortran version.
void unspaghettify_statement(statement)
The real entry point of unspaghettify:
type ImplicitType(entity e)
This function computes the Fortran implicit type of entity e.
const char * module_name(const char *s)
Return the module part of an entity name.
char * get_string_property(const char *)
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
#define gen_get_ancestor_type(i, o)
statement make_empty_block_statement(void)
Build an empty statement (block/sequence)
statement make_block_with_stmt_if_not_already(statement)
Build a statement block from a statement if not already a statement block.
void reset_current_module_entity(void)
Reset the current module entity.
void reset_current_module_statement(void)
Reset the current module statement.
statement set_current_module_statement(statement)
Set the current module statement.
statement get_current_module_statement(void)
Get the current module statement.
entity set_current_module_entity(entity)
static.c
entity get_current_module_entity(void)
Get the entity of the current module.
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
void gen_core(__attribute__((unused)) void *p)
Abort when called.
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
list gen_make_list(int domain,...)
list gen_nreverse(list cp)
reverse a list in place
#define NIL
The empty list (nil in Lisp)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
#define CAR(pcons)
Get the value of the first element of a list.
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
#define CDR(pcons)
Get the list less its first element.
list gen_full_copy_list(list l)
Copy a list structure with element copy.
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
sequence statement_sequence(statement)
Get the sequence of a statement sequence.
loop statement_loop(statement)
Get the loop of a statement.
call statement_call(statement)
Get the call of a statement.
whileloop statement_whileloop(statement)
Get the whileloop of a statement.
forloop statement_forloop(statement)
Get the forloop of a statement.
bool empty_statement_or_continue_p(statement)
Return true if the statement is an empty instruction block or a continue or a recursive combination o...
bool statement_sequence_p(statement)
Statement classes induced from instruction type.
statement make_assign_statement(expression, expression)
statement add_declaration_statement_at_beginning(statement, entity)
statement make_whileloop_statement(expression, statement, int, bool)
Build a while loop statement.
statement make_loop_statement(entity, expression, expression, expression, statement)
Build a loop statement.
bool return_statement_p(statement)
Test if a statement is a C or Fortran "return".
void pop_generated_variable_commenter(void)
void insert_statement(statement, statement, bool)
This is the normal entry point.
bool assignment_statement_p(statement)
Test if a statement is an assignment.
void insert_statement_no_matter_what(statement, statement, bool)
Break the IR consistency or, at the very least, do not insert new declarations at the usual place,...
bool statement_replace_in_root_statement(statement, statement, statement)
replace old_stat by new_stat in root_stat this pass does not free old_stat similar to replace_in_sequ...
statement add_declaration_statement(statement, entity)
bool empty_comments_p(const char *)
statement make_test_statement(expression, statement, statement)
void push_generated_variable_commenter(string(*)(entity))
statement make_forloop_statement(expression, expression, expression, statement)
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
bool expression_constant_p(expression)
HPFC module by Fabien COELHO.
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
#define pips_user_warning
#define same_stringn_p(a, b, c)
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
#define pips_internal_error
static statement mpic_make_mpi_irecv(expression buffer, int size, entity mpitype, int source, int tag, entity communicator, entity request, entity result)
generate statement: {result =} MPI_Irecv(&buffer, size, mpitype, source, tag, communicator,...
static type mpi_type_mpi_comm()
return the type for MPI communicator: MPI_Comm
static statement mpic_make_mpi_finalize(entity result)
generate statement: MPI_Finalize(); or result = MPI_Finalize();
static bool test_working_false(test t, ctx_conv_t *ctx)
This function update the receive statements for a test statement NB : This function can be put in sea...
bool mpi_conversion(const char *module_name)
PIPS pass.
static call mpic_make_generic_mpi_send_call(expression buffer, int size, entity mpitype, int dest, int tag, entity communicator, entity request, enum mpi_communication_mode mode)
static statement mpic_make_mpi_init(entity result, entity argc, entity argv)
argc and argv must be defined generate statement: MPI_Init(&argc, &argv); or result = MPI_Init(&argc,...
static string mpi_conversion_declaration_commenter(__attribute__((unused)) entity e)
Pass: MPI_CONVERSION Debug mode: MPI_GENERATION_DEBUG_LEVEL Properties used:
static statement mpic_make_mpi_comm_rank(entity communicator, entity rank, entity result)
generate statement: MPI_Comm_rank(communicator, &rank); or result = MPI_Comm_rank(communicator,...
static void initilization(statement module_statement, const ctx_conv_t ctx)
put initialize MPI functions at the beginning of the module_stateent (function): // Generated by Pass...
static statement mpi_send_ctx(const ctx_mpi_t ctx, expression buffer, int size, int dest, int tag, bool blocking)
static statement mpic_make_mpi_isend(expression buffer, int size, entity mpitype, int dest, int tag, entity communicator, entity request, entity result)
generate statement: {result =} MPI_Isend(&buffer, size, mpitype, dest, tag, communicator,...
static statement ctx_get_return_statement(const ctx_conv_t ctx)
static statement ctx_get_send_statement(ctx_conv_t *ctx)
static statement make_mpi_conversion(entity module, statement module_statement)
static void ctx_set_receive_statement(ctx_conv_t *ctx, statement receive, int for_cluster)
static statement mpic_make_mpi_comm_size(entity communicator, entity size, entity result)
Functions to generate standard MPI function statement Can maybe also make function to return MPI func...
static statement ctx_get_statement_work_on(const ctx_conv_t ctx)
static statement mpic_make_mpi_recv(expression buffer, int size, entity mpitype, int source, int tag, entity communicator, entity status, entity result)
TODO do the same for MPI_Rsend/Irsend/Bsend/Ibsend/Ssend/Issend.
static void finalization(statement module_statement, const ctx_conv_t ctx)
put finalize MPI functions at the end of the module_stateent (function), before the return: MPI_Final...
static type mpi_type_mpi_request()
return the type for MPI request: MPI_Request
static statement ctx_generate_new_statement_cluster_dependant(const ctx_conv_t ctx)
static ctx_conv_t conv_make_ctx(entity module, int nbr_cluster)
static statement generate_receive_from_statement(ctx_conv_t *ctx, statement stat)
@ mpi_communication_synchronous_mode
@ mpi_communication_buffered_mode
@ mpi_communication_ready_mode
@ mpi_communication_default_mode
static void make_send_receive_conversion(statement stat, ctx_conv_t *ctx)
Update statement that we work on by replace communication assignment by real MPI_send function and co...
static int ctx_get_tag(const ctx_conv_t ctx, int sender, int receiver)
static void ctx_inc_tag(ctx_conv_t *ctx, int sender, int receiver)
static int find_sender_cluster(ctx_conv_t *ctx, __attribute__((__unused__)) statement stat)
static bool is_distributed_comments(string comments)
static ctx_mpi_t mpi_make_ctx(entity module)
static type mpi_type_mpi_status()
return the type for MPI status: MPI_Status
static call mpic_make_generic_mpi_receive_call(expression buffer, int size, entity mpitype, int dest, int tag, entity communicator, entity status, entity request)
static void ctx_set_statement_work_on(ctx_conv_t *ctx, statement st)
static statement mpi_recv_ctx(const ctx_mpi_t ctx, expression buffer, int size, int source, int tag, bool blocking)
TODO do the same for Ssend, Rsend, Bsend.
static statement ctx_get_receive_statement(const ctx_conv_t ctx, int for_cluster)
static int find_receiver_cluster(__attribute__((__unused__)) ctx_conv_t *ctx, statement stat)
static statement mpi_init_ctx(const ctx_mpi_t ctx)
static bool sequence_working_false(sequence seq, ctx_conv_t *ctx)
This function update the receive statements for a sequential statement NB : This function can be put ...
static void ctx_set_return_statement(ctx_conv_t *ctx, statement rs)
static void replace_sender_entity_by_receiver_entity_in_reference(reference ref, int *receiv_cluster)
static statement mpi_comm_size_ctx(const ctx_mpi_t ctx)
static list mpic_make_args_mpi_send_or_receiv(expression buffer, int size, entity mpitype, int ds, int tag, entity communicator, entity status, entity request)
tatic statement mpifortran_make_mpi_finalize(entity result) { list args = CONS(EXPRESSION,...
static statement generate_send_from_statement(ctx_conv_t *ctx, statement stat)
static void ctx_init(ctx_conv_t *ctx)
static void mpi_free_ctx(__attribute__((__unused__)) ctx_mpi_t *ctx)
struct ctx_mpi ctx_mpi_t
return the type for MPI datatype (to make custom datatype for example): MPI_Datatype
static statement mpi_finalize_ctx(const ctx_mpi_t ctx)
static bool ctx_is_blocking(const ctx_conv_t ctx)
static bool search_copy_communication(statement stat, ctx_conv_t *ctx)
use as filter for gen_context_recurse check if the statement stat will be communication if so,...
static bool is_distributed_send_comments(string comments)
static statement mpi_comm_rank_ctx(const ctx_mpi_t ctx)
struct ctx_conv ctx_conv_t
static statement mpic_make_mpi_send(expression buffer, int size, entity mpitype, int dest, int tag, entity communicator, entity result)
generate statement: {result =} MPI_Send(&buffer, size, mpitype, dest, tag, communicator);
static void conv_free_ctx(ctx_conv_t *ctx)
static void ctx_set_send_statement(ctx_conv_t *ctx, statement send)
static bool is_distributed_receive_comments(string comments)
#define TOP_LEVEL_MODULE_NAME
Module containing the global variables in Fortran and C.
#define STACK_AREA_LOCAL_NAME
list strsplit(const char *, const char *)
string concatenate(const char *,...)
Return the concatenation of the given strings.
void * gen_find_tabulated(const char *, int)
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
void print_entity_variable(entity e)
print_entity_variable(e)
void print_syntax(syntax s)
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
void print_reference(reference r)
string basic_to_string(basic)
void print_statement(statement)
Print a statement on stderr.
static const char * prefix
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
#define MPI_IBSEND_FUNCTION_NAME
#define MPI_RSEND_FUNCTION_NAME
#define MINUS_OPERATOR_NAME
#define MPI_IRSEND_FUNCTION_NAME
#define MPI_STATUS
PI types.
#define PLUS_OPERATOR_NAME
#define EQUAL_OPERATOR_NAME
#define STATEMENT_NUMBER_UNDEFINED
default values
#define MPI_SEND_FUNCTION_NAME
#define MPI_ISEND_FUNCTION_NAME
#define MPI_INIT_FUNCTION_NAME
PI calls.
#define call_to_statement(c)
#define MPI_RECV_FUNCTION_NAME
#define MPI_COMM_RANK_FUNCTION_NAME
#define MPI_COMM_SIZE_FUNCTION_NAME
#define MPI_BSEND_FUNCTION_NAME
#define MPI_IRECV_FUNCTION_NAME
#define MPI_SSEND_FUNCTION_NAME
#define not_expression(e)
#define MPI_ISSEND_FUNCTION_NAME
#define MPI_FINALIZE_FUNCTION_NAME
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
entity FindOrCreateEntity(const char *package, const char *local_name)
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a functi...
bool same_entity_p(entity e1, entity e2)
predicates on entities
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
static int init
Maximal value set for Fortran 77.
const char * module_local_name(entity e)
Returns the module local user name.
entity CreateIntrinsic(string name)
this function does not create an intrinsic function because they must all be created beforehand by th...
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
bool expression_integer_value(expression e, intptr_t *pval)
expression make_entity_expression(entity e, cons *inds)
expression make_address_of_expression(expression e)
generate a newly allocated expression for &(e)
bool zero_expression_p(expression e)
expression expressions_to_operation(const list l_exprs, entity op)
take a list of expression and apply a binary operator between all of them and return it as an express...
int expression_to_int(expression exp)
================================================================
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
call expression_call(expression e)
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
bool integer_constant_expression_p(expression e)
positive integer constant expression: call to a positive constant or to a sum of positive integer con...
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
entity expression_to_entity(expression e)
just returns the entity of an expression, or entity_undefined
expression call_to_expression(call c)
Build an expression that call a function or procedure.
extensions empty_extensions(void)
extension.c
basic MakeBasic(int)
END_EOLE.
entity make_new_scalar_variable_with_prefix(const char *, entity, basic)
Create a new scalar variable of type b in the given module.
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
#define test_domain
newgen_entity_domain_defined
#define expression_domain
newgen_execution_domain_defined
#define forloop_initialization(x)
#define reference_variable(x)
#define forloop_increment(x)
#define whileloop_evaluation(x)
#define entity_storage(x)
#define statement_domain
newgen_sizeofexpression_domain_defined
#define range_increment(x)
#define EXPRESSION(x)
EXPRESSION.
#define type_undefined_p(x)
#define entity_undefined_p(x)
#define reference_domain
newgen_range_domain_defined
#define expression_undefined
@ is_instruction_unstructured
@ is_instruction_whileloop
@ is_instruction_expression
@ is_instruction_multitest
@ is_instruction_sequence
#define instruction_tag(x)
#define sequence_statements(x)
#define reference_indices(x)
#define statement_extensions(x)
#define test_condition(x)
#define statement_declarations(x)
#define statement_instruction(x)
#define statement_comments(x)
#define instruction_call(x)
#define forloop_condition(x)
#define call_arguments(x)
#define statement_undefined_p(x)
#define whileloop_condition(x)
#define expression_syntax(x)
#define sequence_domain
newgen_reference_domain_defined
#define evaluation_before_p(x)
#define storage_undefined_p(x)
#define entity_domain
newgen_syntax_domain_defined
#define variable_basic(x)
#define statement_undefined
#define STATEMENT(x)
STATEMENT.
The structure used to build lists in NewGen.
statement statement_work_on
statement return_statement
statement * statement_send_receive
return the type for MPI datatype (to make custom datatype for example): MPI_Datatype
#define MPI_GENERATION_NBR_CLUSTER
#define MPI_COMM_WORLD_STRING
#define COMMENT_MPI_CONVERSION
#define MPI_GENERATION_PREFIX
task load_parallel_task_mapping(statement)
void set_parallel_task_mapping(statement_task)
void reset_parallel_task_mapping(void)
#define task_synchronization(x)
#define task_on_cluster(x)