From 5c8ede40c4f5e920bd12b2e4ede74db2892e0d60 Mon Sep 17 00:00:00 2001 From: pini Date: Mon, 17 Jan 2011 15:54:07 +0000 Subject: [PATCH] Access to SIMIX data without resorting to a request (and thus do not rely specifically on thread context in SMPI). git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@9424 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- include/smpi/smpi.h | 2 ++ include/smpi/smpi_cocci.h | 13 +------------ include/smpi/smpif.h.in | 2 +- src/smpi/private.h | 1 - src/smpi/smpi_global.c | 14 +------------- src/smpi/smpif2c.in | 5 ++--- 6 files changed, 7 insertions(+), 30 deletions(-) diff --git a/include/smpi/smpi.h b/include/smpi/smpi.h index b2589b86d5..dafc86da4c 100644 --- a/include/smpi/smpi.h +++ b/include/smpi/smpi.h @@ -444,5 +444,7 @@ XBT_PUBLIC(void) smpi_shared_free(void *data); /* Fortran specific stuff */ XBT_PUBLIC(int) MAIN__(void); +XBT_PUBLIC(int) smpi_process_index(void); + SG_END_DECL() #endif diff --git a/include/smpi/smpi_cocci.h b/include/smpi/smpi_cocci.h index cc03928600..29daeec643 100644 --- a/include/smpi/smpi_cocci.h +++ b/include/smpi/smpi_cocci.h @@ -38,17 +38,6 @@ void __attribute__((weak,destructor)) __postfini_##name(void) { \ name = NULL; \ } -#define SMPI_GLOBAL_VAR_LOCAL_ACCESS(name) name[__rank()] - -/* This function stores the rank locally, so that a request in - SIMIX is not created each time */ -int __attribute__((weak)) __rank(void) { - static __thread int rank = -1; - - if(rank < 0) { - rank = smpi_global_rank(); - } - return rank; -} +#define SMPI_GLOBAL_VAR_LOCAL_ACCESS(name) name[smpi_process_index()] #endif diff --git a/include/smpi/smpif.h.in b/include/smpi/smpif.h.in index 6f3ccb876c..890712bff7 100644 --- a/include/smpi/smpif.h.in +++ b/include/smpi/smpif.h.in @@ -14,11 +14,11 @@ #endif #include +#include #include XBT_PUBLIC(int) smpi_process_argc(void); XBT_PUBLIC(int) smpi_process_getarg(integer* index, char* dst, ftnlen len); -XBT_PUBLIC(int) smpi_global_rank(void); XBT_PUBLIC(int) smpi_global_size(void); #endif diff --git a/src/smpi/private.h b/src/smpi/private.h index eaafa4986f..65f48393f4 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -43,7 +43,6 @@ void smpi_process_destroy(void); smpi_process_data_t smpi_process_data(void); smpi_process_data_t smpi_process_remote_data(int index); int smpi_process_count(void); -int smpi_process_index(void); smx_rdv_t smpi_process_mailbox(void); smx_rdv_t smpi_process_remote_mailbox(int index); xbt_os_timer_t smpi_process_timer(void); diff --git a/src/smpi/smpi_global.c b/src/smpi/smpi_global.c index b8938fa95d..bd5a5f1e0e 100644 --- a/src/smpi/smpi_global.c +++ b/src/smpi/smpi_global.c @@ -94,10 +94,6 @@ int smpi_process_getarg(integer* index, char* dst, ftnlen len) { return 0; } -int smpi_global_rank(void) { - return smpi_process_index(); -} - int smpi_global_size(void) { char* value = getenv("SMPI_GLOBAL_SIZE"); @@ -109,7 +105,7 @@ int smpi_global_size(void) { smpi_process_data_t smpi_process_data(void) { - return SIMIX_req_process_get_data(SIMIX_process_self()); + return SIMIX_process_self_get_data(); } smpi_process_data_t smpi_process_remote_data(int index) @@ -227,12 +223,10 @@ void smpi_global_destroy(void) /* With smpiff, the following weak symbols are replaced by those in libf2c */ int __attribute__((weak)) xargc; char** __attribute__((weak)) xargv; -int fortran = 1; int __attribute__((weak)) main(int argc, char** argv) { xargc = argc; xargv = argv; - fortran = 0; return MAIN__(); } @@ -258,12 +252,6 @@ int MAIN__(void) xbt_cfgelm_double, &default_threshold, 1, 1, NULL, NULL); - if(fortran) { - /* Force thread contexts with fortran code */ - extern void SIMIX_ctx_thread_factory_init(smx_context_factory_t *factory); - smx_factory_initializer_to_use = SIMIX_ctx_thread_factory_init; - } - #ifdef HAVE_TRACING TRACE_global_init(&xargc, xargv); #endif diff --git a/src/smpi/smpif2c.in b/src/smpi/smpif2c.in index ce1272a111..1d6c4d0703 100755 --- a/src/smpi/smpif2c.in +++ b/src/smpi/smpif2c.in @@ -20,8 +20,7 @@ foreach my $fortran (@ARGV) { print $tmp "#define INTEGER_STAR_8\n"; print $tmp "#endif\n"; print $tmp "#include \n"; - print $tmp "#include \n\n"; - print $tmp "int __attribute__((weak)) __rank(void) {\n static __thread int rank = -1;\n\n if(rank < 0) {\n rank = smpi_global_rank();\n }\n return rank;\n}\n\n"; + print $tmp "#include \n"; while() { chomp; if(/\/\* Common Block Declarations \*\//) { @@ -31,7 +30,7 @@ foreach my $fortran (@ARGV) { if(/^} (.*?);/) { $_ = "}* __attribute__((weak)) $1 = NULL;\n"; } elsif(/^#define\s*(\S*)\s*\(?([^.]*)(\..*?)?\)?$/) { - $_ = "#define $1 $2\[__rank()\]"; + $_ = "#define $1 $2\[smpi_process_index()\]"; if(defined $3) { $_ .= $3; } -- 2.20.1