Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge pull request #302 from mpoquet/rename-s4u-synchro-examples
authorMartin Quinson <624847+mquinson@users.noreply.github.com>
Tue, 25 Sep 2018 13:20:57 +0000 (15:20 +0200)
committerGitHub <noreply@github.com>
Tue, 25 Sep 2018 13:20:57 +0000 (15:20 +0200)
Rename s4u synchro examples

25 files changed:
ChangeLog
examples/s4u/CMakeLists.txt
examples/s4u/README.rst
examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp [moved from examples/s4u/barrier/s4u-barrier.cpp with 100% similarity]
examples/s4u/synchro-barrier/s4u-synchro-barrier.tesh [moved from examples/s4u/barrier/s4u-barrier.tesh with 91% similarity]
examples/s4u/synchro-mutex/.gitignore [moved from examples/s4u/mutex/.gitignore with 100% similarity]
examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp [moved from examples/s4u/mutex/s4u-mutex.cpp with 100% similarity]
examples/s4u/synchro-mutex/s4u-synchro-mutex.tesh [moved from examples/s4u/mutex/s4u-mutex.tesh with 97% similarity]
examples/smpi/replay_multiple_manual_deploy/replay_multiple_manual.cpp
include/smpi/mpif.h.in
include/smpi/smpi.h
src/smpi/bindings/smpi_f77.cpp
src/smpi/bindings/smpi_f77_comm.cpp
src/smpi/bindings/smpi_f77_type.cpp
src/smpi/bindings/smpi_mpi.cpp
src/smpi/bindings/smpi_pmpi.cpp
src/smpi/bindings/smpi_pmpi_type.cpp
src/smpi/bindings/smpi_pmpi_win.cpp
src/smpi/include/private.hpp
src/smpi/include/smpi_keyvals.hpp
src/smpi/mpi/smpi_comm.cpp
src/smpi/mpi/smpi_datatype.cpp
src/smpi/mpi/smpi_keyvals.cpp
teshsuite/smpi/mpich3-test/f77/testlist
tools/cmake/DefinePackages.cmake

index 08f5266..3ecc22e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -36,6 +36,17 @@ XBT:
  - Remove portability wrapper to condition variables
  - Remove xbt_os_thread_yield()
 
+SMPI:
+ - MPICH collective selector now mimics MPICH 3.3b
+ - OpenMPI collective selector now mimics OpenMPI 3.1.2 (default "tuned" setting)
+ - MPI_Init(NULL,NULL) is now allowed
+ - smpi/wtime option now injects time in gettimeofday or clock_gettime calls
+ - Command-line arguments should now be handled properly in Fortran simulations
+ - MPI Attributes and related callbacks should work in Fortran
+ - Apps using C + Fortran should now work
+ - MPI_* calls now check for non MPI_SUCCESS return values and emit warnings
+ - Support MPI_Error_String
+
 Java:
  - Due to an internal bug, Msg.run() must now be your last line.
    We hope to fix it in a future release, and we are sorry for the inconvenience.
index 42f6f42..9ae63e2 100644 (file)
@@ -4,16 +4,15 @@ foreach (example actor-create actor-daemon actor-join actor-kill
                  actor-lifetime actor-migration actor-suspend actor-yield
                  app-chainsend app-pingpong app-token-ring
                  async-ready async-wait async-waitany async-waitall async-waituntil
-                 barrier
                  cloud-capping cloud-migration cloud-simple
                  energy-exec energy-boot energy-link energy-vm
                  engine-filtering
                  exec-async exec-basic exec-dvfs exec-monitor exec-ptask exec-remote
                  io-async io-file-system io-file-remote io-storage-raw
-                 mutex
                  platform-failures platform-properties plugin-hostload 
                  replay-comm replay-storage
                  routing-get-clusters
+                 synchro-barrier synchro-mutex
                  trace-platform)
   add_executable       (s4u-${example}  ${example}/s4u-${example}.cpp)
   target_link_libraries(s4u-${example}  simgrid)
@@ -101,16 +100,16 @@ foreach(example actor-create actor-daemon actor-join actor-kill
                 actor-lifetime actor-migration actor-suspend actor-yield
                 app-bittorrent app-chainsend app-masterworkers app-pingpong app-token-ring 
                 async-ready async-wait async-waitall async-waitany async-waituntil
-                barrier
                 cloud-capping cloud-migration cloud-simple
                 dht-chord dht-kademlia
                 energy-exec energy-boot energy-link energy-vm
                 engine-filtering
                 exec-async exec-basic exec-dvfs exec-monitor exec-ptask exec-remote
-                platform-properties plugin-hostload mutex # FIXME: platform-failures is disabled
+                platform-properties plugin-hostload # FIXME: platform-failures is disabled
                 io-async io-file-system io-file-remote io-storage-raw
                 replay-comm replay-storage
                 routing-get-clusters
+                synchro-barrier synchro-mutex
                 )
   ADD_TESH_FACTORIES(s4u-${example} "thread;ucontext;raw;boost" 
                                     --setenv bindir=${CMAKE_CURRENT_BINARY_DIR}/${example} 
index d8e2522..a1f2bf4 100644 (file)
@@ -209,7 +209,11 @@ Classical synchronization objects
 
  - **Mutex:**
    Shows how to use simgrid::s4u::Mutex synchronization objects.
-   |br| `examples/s4u/mutex/s4u-mutex.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/mutex/s4u-mutex.cpp>`_
+   |br| `examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/synchro-mutex/s4u-synchro-mutex.cpp>`_
+
+ - **Barrier:**
+   Shows how to use simgrid::s4u::Barrier synchronization objects.
+   |br| `examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp <https://framagit.org/simgrid/simgrid/tree/master/examples/s4u/synchro-barrier/s4u-synchro-barrier.cpp>`_
 
 .............................
 Interacting with the platform
@@ -1,18 +1,18 @@
 #!/usr/bin/env tesh
 
-$ $SG_TEST_EXENV ${bindir:=.}/s4u-barrier 1
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-synchro-barrier 1
 > [Tremblay:master:(1) 0.000000] [s4u_test/INFO] Spawning 0 workers
 > [Tremblay:master:(1) 0.000000] [s4u_test/INFO] Waiting on the barrier
 > [Tremblay:master:(1) 0.000000] [s4u_test/INFO] Bye
 
-$ $SG_TEST_EXENV ${bindir:=.}/s4u-barrier 2
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-synchro-barrier 2
 > [Tremblay:master:(1) 0.000000] [s4u_test/INFO] Spawning 1 workers
 > [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] Waiting on the barrier
 > [Tremblay:master:(1) 0.000000] [s4u_test/INFO] Waiting on the barrier
 > [Tremblay:master:(1) 0.000000] [s4u_test/INFO] Bye
 > [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] Bye
 
-$ $SG_TEST_EXENV ${bindir:=.}/s4u-barrier 3
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-synchro-barrier 3
 > [Tremblay:master:(1) 0.000000] [s4u_test/INFO] Spawning 2 workers
 > [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] Waiting on the barrier
 > [Jupiter:worker:(3) 0.000000] [s4u_test/INFO] Waiting on the barrier
@@ -21,7 +21,7 @@ $ $SG_TEST_EXENV ${bindir:=.}/s4u-barrier 3
 > [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] Bye
 > [Jupiter:worker:(3) 0.000000] [s4u_test/INFO] Bye
 
-$ $SG_TEST_EXENV ${bindir:=.}/s4u-barrier 10
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-synchro-barrier 10
 > [Tremblay:master:(1) 0.000000] [s4u_test/INFO] Spawning 9 workers
 > [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] Waiting on the barrier
 > [Jupiter:worker:(3) 0.000000] [s4u_test/INFO] Waiting on the barrier
similarity index 97%
rename from examples/s4u/mutex/s4u-mutex.tesh
rename to examples/s4u/synchro-mutex/s4u-synchro-mutex.tesh
index ac3127f..94bf0ec 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/env tesh
 
-$ $SG_TEST_EXENV ${bindir:=.}/s4u-mutex
+$ $SG_TEST_EXENV ${bindir:=.}/s4u-synchro-mutex
 > [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] Hello s4u, I'm ready to compute after a lock_guard
 > [Jupiter:worker:(2) 0.000000] [s4u_test/INFO] I'm done, good bye
 > [Tremblay:worker:(3) 0.000000] [s4u_test/INFO] Hello s4u, I'm ready to compute after a regular lock
index c218cbe..9506b99 100644 (file)
@@ -16,7 +16,7 @@
         1. Sleep until job's starting time is reached (if needed)
         2. Launch the replay of the corresponding time-indepent trace.
         3. Create inter-process noise, by spawning useless actors.
-   4. Wait for completion (implicitly, via MSG_main's return)
+   4. Wait for completion (via s4u::Engine's run method)
 */
 
 #include <algorithm>
@@ -57,7 +57,7 @@ static bool job_comparator(const Job* j1, const Job* j2)
 
 struct s_smpi_replay_process_args {
   Job* job;
-  msg_sem_t semaphore;
+  simgrid::s4u::BarrierPtr barrier;
   int rank;
 };
 
@@ -65,9 +65,6 @@ static int smpi_replay_process(int argc, char* argv[])
 {
   s_smpi_replay_process_args* args = static_cast<s_smpi_replay_process_args*>(MSG_process_get_data(MSG_process_self()));
 
-  if (args->semaphore != nullptr)
-    MSG_sem_acquire(args->semaphore);
-
   XBT_INFO("Replaying rank %d of job %d (smpi_app '%s')", args->rank, args->job->unique_job_number,
            args->job->smpi_app_name.c_str());
 
@@ -75,8 +72,7 @@ static int smpi_replay_process(int argc, char* argv[])
   XBT_INFO("Finished replaying rank %d of job %d (smpi_app '%s')", args->rank, args->job->unique_job_number,
            args->job->smpi_app_name.c_str());
 
-  if (args->semaphore != nullptr)
-    MSG_sem_release(args->semaphore);
+  args->barrier->wait();
 
   delete args;
   return 0;
@@ -105,9 +101,10 @@ static void pop_some_processes(int nb_processes, simgrid::s4u::Host* host)
 
 static int job_executor_process(Job* job)
 {
-  msg_sem_t job_semaphore = MSG_sem_init(1);
   XBT_INFO("Executing job %d (smpi_app '%s')", job->unique_job_number, job->smpi_app_name.c_str());
 
+  simgrid::s4u::BarrierPtr barrier = simgrid::s4u::Barrier::create(job->app_size + 1);
+
   for (int i = 0; i < job->app_size; ++i) {
     char** argv = xbt_new(char*, 5);
     argv[0]     = xbt_strdup("1");                              // log only?
@@ -118,19 +115,15 @@ static int job_executor_process(Job* job)
 
     s_smpi_replay_process_args* args = new s_smpi_replay_process_args;
     args->job                        = job;
-    args->semaphore                  = nullptr;
+    args->barrier                    = barrier;
     args->rank                       = i;
 
-    if (i == 0)
-      args->semaphore = job_semaphore;
-
     char* str_pname = bprintf("%d_%d", job->unique_job_number, i);
     MSG_process_create_with_arguments(str_pname, smpi_replay_process, (void*)args, hosts[job->allocation[i]], 5, argv);
     xbt_free(str_pname);
   }
 
-  MSG_sem_acquire(job_semaphore);
-  MSG_sem_destroy(job_semaphore);
+  barrier->wait();
 
   XBT_INFO("Finished job %d (smpi_app '%s')", job->unique_job_number, job->smpi_app_name.c_str());
 
index 2a43590..1f01d37 100644 (file)
       integer MPI_COMM_NULL_COPY_FN, MPI_COMM_NULL_DELETE_FN
       parameter(MPI_COMM_NULL_COPY_FN =0)
       parameter(MPI_COMM_NULL_DELETE_FN =0)
-      integer MPI_COMM_NULL_DUP_FN, MPI_COMM_DUP_FN
-      parameter(MPI_COMM_NULL_DUP_FN =0)
-      parameter(MPI_COMM_DUP_FN =0)
+      integer MPI_COMM_DUP_FN
+      parameter(MPI_COMM_DUP_FN =1)
       integer MPI_WIN_NULL_COPY_FN, MPI_WIN_NULL_DELETE_FN
       parameter(MPI_WIN_NULL_COPY_FN =0)
       parameter(MPI_WIN_NULL_DELETE_FN =0)
       integer MPI_WIN_DUP_FN
-      parameter(MPI_WIN_DUP_FN =0)
+      parameter(MPI_WIN_DUP_FN =1)
+      integer MPI_TYPE_NULL_COPY_FN, MPI_TYPE_NULL_DELETE_FN
+      parameter(MPI_TYPE_NULL_COPY_FN =0)
+      parameter(MPI_TYPE_NULL_DELETE_FN =0)
+      integer MPI_TYPE_DUP_FN
+      parameter(MPI_TYPE_DUP_FN =1)
 
       integer MPI_ROOT, MPI_COMM_TYPE_SHARED
       parameter(MPI_ROOT=0)
index 51f0939..3bc7ae8 100644 (file)
@@ -372,14 +372,25 @@ typedef enum SMPI_Topo_type {
 typedef int MPI_Copy_function(MPI_Comm oldcomm, int keyval, void* extra_state, void* attribute_val_in,
                               void* attribute_val_out, int* flag);
 typedef int MPI_Delete_function(MPI_Comm comm, int keyval, void* attribute_val, void* extra_state);
+typedef void MPI_Copy_function_fort(MPI_Comm oldcomm, int keyval, void* extra_state, void* attribute_val_in,
+                              void* attribute_val_out, int* flag, int* ierr);
+typedef void MPI_Delete_function_fort(MPI_Comm comm, int keyval, void* attribute_val, void* extra_state, int* ierr);
 #define MPI_Comm_copy_attr_function MPI_Copy_function
 #define MPI_Comm_delete_attr_function MPI_Delete_function
+#define MPI_Comm_copy_attr_function_fort MPI_Copy_function_fort
+#define MPI_Comm_delete_attr_function_fort MPI_Delete_function_fort
 typedef int MPI_Type_copy_attr_function(MPI_Datatype type, int keyval, void* extra_state, void* attribute_val_in,
                               void* attribute_val_out, int* flag);
 typedef int MPI_Type_delete_attr_function(MPI_Datatype type, int keyval, void* attribute_val, void* extra_state);
 typedef int MPI_Win_copy_attr_function(MPI_Win win, int keyval, void* extra_state, void* attribute_val_in,
                               void* attribute_val_out, int* flag);
 typedef int MPI_Win_delete_attr_function(MPI_Win win, int keyval, void* attribute_val, void* extra_state);
+typedef void MPI_Type_copy_attr_function_fort(MPI_Datatype type, int keyval, void* extra_state, void* attribute_val_in,
+                              void* attribute_val_out, int* flag, int* ierr);
+typedef void MPI_Type_delete_attr_function_fort(MPI_Datatype type, int keyval, void* attribute_val, void* extra_state, int* ierr);
+typedef void MPI_Win_copy_attr_function_fort(MPI_Win win, int keyval, void* extra_state, void* attribute_val_in,
+                              void* attribute_val_out, int* flag, int* ierr);
+typedef void MPI_Win_delete_attr_function_fort(MPI_Win win, int keyval, void* attribute_val, void* extra_state, int* ierr);
 #define MPI_COMM_NULL_COPY_FN ((MPI_Comm_copy_attr_function*)0)
 #define MPI_COMM_NULL_DELETE_FN ((MPI_Comm_delete_attr_function*)0)
 #define MPI_TYPE_NULL_COPY_FN ((MPI_Type_copy_attr_function*)0)
@@ -714,7 +725,7 @@ typedef void MPI_Win_errhandler_function(MPI_Win *, int *, ...);
 typedef int MPI_Grequest_query_function(void *extra_state, MPI_Status *status);
 typedef int MPI_Grequest_free_function(void *extra_state);
 typedef int MPI_Grequest_cancel_function(void *extra_state, int complete);
-#define MPI_DUP_FN MPI_Comm_dup
+#define MPI_DUP_FN 1
 
 #define MPI_WIN_DUP_FN ((MPI_Win_copy_attr_function*)MPI_DUP_FN)
 #define MPI_TYPE_DUP_FN ((MPI_Type_copy_attr_function*)MPI_DUP_FN)
index 2dea2f4..42165e3 100644 (file)
@@ -117,7 +117,8 @@ void mpi_get_count_(MPI_Status * status, int* datatype, int *count, int* ierr){
 void mpi_attr_get_(int* comm, int* keyval, int* attr_value, int* flag, int* ierr ){
   int* value = nullptr;
   *ierr = MPI_Attr_get(simgrid::smpi::Comm::f2c(*comm), *keyval, &value, flag);
-  *attr_value = *value;
+  if(*flag == 1)
+    *attr_value=*value;
 }
 
 void mpi_error_string_(int* errorcode, char* string, int* resultlen, int* ierr){
@@ -228,11 +229,14 @@ void mpi_win_get_group_(int*  win, int* group, int* ierr){
 void mpi_win_get_attr_(int* win, int* type_keyval, int* attribute_val, int* flag, int* ierr){
    int* value = nullptr;
   *ierr = MPI_Win_get_attr(simgrid::smpi::Win::f2c(*win), *type_keyval, &value, flag);
-  *attribute_val=*value;
+  if (*flag == 1)
+    *attribute_val = *value;
 }
 
-void mpi_win_set_attr_(int* win, int* type_keyval, void* att, int* ierr){
-  *ierr = MPI_Win_set_attr(simgrid::smpi::Win::f2c(*win), *type_keyval, att);
+void mpi_win_set_attr_(int* win, int* type_keyval, int* att, int* ierr){
+ int* val = (int*)xbt_malloc(sizeof(int));
+ *val=*att;
+  *ierr = MPI_Win_set_attr(simgrid::smpi::Win::f2c(*win), *type_keyval, val);
 }
 
 void mpi_win_delete_attr_(int* win, int* comm_keyval, int* ierr){
@@ -240,8 +244,9 @@ void mpi_win_delete_attr_(int* win, int* comm_keyval, int* ierr){
 }
 
 void mpi_win_create_keyval_(void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr){
-  *ierr = MPI_Win_create_keyval(reinterpret_cast<MPI_Win_copy_attr_function*>(copy_fn),
-                                reinterpret_cast<MPI_Win_delete_attr_function*>(delete_fn), keyval, extra_state);
+  smpi_copy_fn _copy_fn={nullptr,nullptr,nullptr,nullptr,nullptr,(*(int*)copy_fn) == 0 ? nullptr : reinterpret_cast<MPI_Win_copy_attr_function_fort*>(copy_fn)};
+  smpi_delete_fn _delete_fn={nullptr,nullptr,nullptr,nullptr,nullptr,(*(int*)delete_fn) == 0 ? nullptr : reinterpret_cast<MPI_Win_delete_attr_function_fort*>(delete_fn)};
+  *ierr = simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Win>(_copy_fn, _delete_fn, keyval, extra_state);
 }
 
 void mpi_win_free_keyval_(int* keyval, int* ierr){
@@ -707,12 +712,16 @@ void mpi_attr_delete_ (int* comm, int* keyval, int* ierr) {
  *ierr = MPI_Attr_delete(simgrid::smpi::Comm::f2c(*comm), *keyval);
 }
 
-void mpi_attr_put_ (int* comm, int* keyval, void* attr_value, int* ierr) {
- *ierr = MPI_Attr_put(simgrid::smpi::Comm::f2c(*comm), *keyval, attr_value);
+void mpi_attr_put_ (int* comm, int* keyval, int* attr_value, int* ierr) {
+ int* val = (int*)xbt_malloc(sizeof(int));
+ *val=*attr_value;
+ *ierr = MPI_Attr_put(simgrid::smpi::Comm::f2c(*comm), *keyval, val);
 }
 
 void mpi_keyval_create_ (void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr) {
- *ierr = MPI_Keyval_create(reinterpret_cast<MPI_Copy_function*>(copy_fn),reinterpret_cast<MPI_Delete_function*>(delete_fn), keyval, extra_state);
+  smpi_copy_fn _copy_fn={nullptr,nullptr,nullptr,(*(int*)copy_fn) == 0 ? nullptr : reinterpret_cast<MPI_Copy_function_fort*>(copy_fn),nullptr,nullptr};
+  smpi_delete_fn _delete_fn={nullptr,nullptr,nullptr,(*(int*)delete_fn) == 0 ? nullptr : reinterpret_cast<MPI_Delete_function_fort*>(delete_fn),nullptr,nullptr};
+  *ierr = simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Comm>(_copy_fn, _delete_fn, keyval, extra_state);
 }
 
 void mpi_keyval_free_ (int* keyval, int* ierr) {
index e4c7886..3e051e5 100644 (file)
@@ -74,12 +74,14 @@ void mpi_comm_create_group_ (int* comm, int* group, int i, int* comm_out, int* i
 void mpi_comm_get_attr_ (int* comm, int* comm_keyval, int *attribute_val, int *flag, int* ierr){
  int* value = nullptr;
  *ierr = MPI_Comm_get_attr (simgrid::smpi::Comm::f2c(*comm), *comm_keyval, &value, flag);
- *attribute_val = *value;
+ if (*flag == 1)
+   *attribute_val = *value;
 }
 
-void mpi_comm_set_attr_ (int* comm, int* comm_keyval, void *attribute_val, int* ierr){
-
- *ierr = MPI_Comm_set_attr ( simgrid::smpi::Comm::f2c(*comm), *comm_keyval, attribute_val);
+void mpi_comm_set_attr_ (int* comm, int* comm_keyval, int *attribute_val, int* ierr){
+ int* val = (int*)xbt_malloc(sizeof(int));
+ *val=*attribute_val;
+ *ierr = MPI_Comm_set_attr ( simgrid::smpi::Comm::f2c(*comm), *comm_keyval, val);
 }
 
 void mpi_comm_delete_attr_ (int* comm, int* comm_keyval, int* ierr){
@@ -88,9 +90,9 @@ void mpi_comm_delete_attr_ (int* comm, int* comm_keyval, int* ierr){
 }
 
 void mpi_comm_create_keyval_ (void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr){
-
- *ierr = MPI_Comm_create_keyval(reinterpret_cast<MPI_Comm_copy_attr_function*>(copy_fn),  reinterpret_cast<MPI_Comm_delete_attr_function*>(delete_fn),
-         keyval,  extra_state) ;
+  smpi_copy_fn _copy_fn={nullptr,nullptr,nullptr,(*(int*)copy_fn) == 0 ? nullptr : reinterpret_cast<MPI_Comm_copy_attr_function_fort*>(copy_fn),nullptr,nullptr};
+  smpi_delete_fn _delete_fn={nullptr,nullptr,nullptr,(*(int*)delete_fn) == 0 ? nullptr : reinterpret_cast<MPI_Comm_delete_attr_function_fort*>(delete_fn),nullptr,nullptr};
+  *ierr = simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Comm>(_copy_fn, _delete_fn, keyval, extra_state);
 }
 
 void mpi_comm_free_keyval_ (int* keyval, int* ierr) {
index 6848328..ffd647b 100644 (file)
@@ -59,12 +59,14 @@ void mpi_type_get_name_ (int*  datatype, char * name, int* len, int* ierr){
 void mpi_type_get_attr_ (int* type, int* type_keyval, int *attribute_val, int* flag, int* ierr){
  int* value = nullptr;
  *ierr = MPI_Type_get_attr ( simgrid::smpi::Datatype::f2c(*type), *type_keyval, &value, flag);
- *attribute_val = *value;
+ if (*flag == 1)
+   *attribute_val = *value;
 }
 
-void mpi_type_set_attr_ (int* type, int* type_keyval, void *attribute_val, int* ierr){
-
- *ierr = MPI_Type_set_attr ( simgrid::smpi::Datatype::f2c(*type), *type_keyval, attribute_val);
+void mpi_type_set_attr_ (int* type, int* type_keyval, int *attribute_val, int* ierr){
+ int* val = (int*)xbt_malloc(sizeof(int));
+ *val=*attribute_val;
+ *ierr = MPI_Type_set_attr ( simgrid::smpi::Datatype::f2c(*type), *type_keyval, val);
 }
 
 void mpi_type_delete_attr_ (int* type, int* type_keyval, int* ierr){
@@ -73,9 +75,9 @@ void mpi_type_delete_attr_ (int* type, int* type_keyval, int* ierr){
 }
 
 void mpi_type_create_keyval_ (void* copy_fn, void*  delete_fn, int* keyval, void* extra_state, int* ierr){
-
- *ierr = MPI_Type_create_keyval(reinterpret_cast<MPI_Type_copy_attr_function*>(copy_fn), reinterpret_cast<MPI_Type_delete_attr_function*>(delete_fn),
-                                keyval,  extra_state) ;
+  smpi_copy_fn _copy_fn={nullptr,nullptr,nullptr,nullptr,(*(int*)copy_fn) == 0 ? nullptr : reinterpret_cast<MPI_Type_copy_attr_function_fort*>(copy_fn),nullptr};
+  smpi_delete_fn _delete_fn={nullptr,nullptr,nullptr,nullptr,(*(int*)delete_fn) == 0 ? nullptr : reinterpret_cast<MPI_Type_delete_attr_function_fort*>(delete_fn),nullptr};
+  *ierr = simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Datatype>(_copy_fn, _delete_fn, keyval, extra_state);
 }
 
 void mpi_type_free_keyval_ (int* keyval, int* ierr) {
index 93aead0..38caaaa 100644 (file)
@@ -35,7 +35,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_mpi, smpi, "Logging specific to SMPI ,(mpi)
       char error_string[MPI_MAX_ERROR_STRING];                                                                         \
       int error_size;                                                                                                  \
       PMPI_Error_string(ret, error_string, &error_size);                                                               \
-      XBT_DEBUG("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size,error_string);                       \
+      XBT_WARN("%s - returned %.*s instead of MPI_SUCCESS", __func__, error_size,error_string);                       \
     }                                                                                                                  \
     XBT_VERB("SMPI - Leaving %s", __func__);                                                                           \
     return ret;                                                                                                        \
index e8622ac..08daa66 100644 (file)
@@ -223,8 +223,8 @@ int PMPI_Error_string(int errorcode, char* string, int* resultlen){
 }
 
 int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {
-  smpi_copy_fn _copy_fn={copy_fn,nullptr,nullptr};
-  smpi_delete_fn _delete_fn={delete_fn,nullptr,nullptr};
+  smpi_copy_fn _copy_fn={copy_fn,nullptr,nullptr,nullptr,nullptr,nullptr};
+  smpi_delete_fn _delete_fn={delete_fn,nullptr,nullptr,nullptr,nullptr,nullptr};
   return simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Comm>(_copy_fn, _delete_fn, keyval, extra_state);
 }
 
index ada61b8..5fcc106 100644 (file)
@@ -325,8 +325,8 @@ int PMPI_Type_delete_attr (MPI_Datatype type, int type_keyval)
 int PMPI_Type_create_keyval(MPI_Type_copy_attr_function* copy_fn, MPI_Type_delete_attr_function* delete_fn, int* keyval,
                             void* extra_state)
 {
-  smpi_copy_fn _copy_fn={nullptr,copy_fn,nullptr};
-  smpi_delete_fn _delete_fn={nullptr,delete_fn,nullptr};
+  smpi_copy_fn _copy_fn={nullptr,copy_fn,nullptr,nullptr,nullptr,nullptr};
+  smpi_delete_fn _delete_fn={nullptr,delete_fn,nullptr,nullptr,nullptr,nullptr};
   return simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Datatype>(_copy_fn, _delete_fn, keyval, extra_state);
 }
 
index 5a8ca34..b3ca2d7 100644 (file)
@@ -829,8 +829,8 @@ int PMPI_Win_delete_attr (MPI_Win win, int type_keyval)
 int PMPI_Win_create_keyval(MPI_Win_copy_attr_function* copy_fn, MPI_Win_delete_attr_function* delete_fn, int* keyval,
                             void* extra_state)
 {
-  smpi_copy_fn _copy_fn={nullptr, nullptr, copy_fn};
-  smpi_delete_fn _delete_fn={nullptr, nullptr, delete_fn};
+  smpi_copy_fn _copy_fn={nullptr, nullptr,copy_fn,nullptr, nullptr,nullptr};
+  smpi_delete_fn _delete_fn={nullptr, nullptr,delete_fn,nullptr, nullptr,nullptr};
   return simgrid::smpi::Keyval::keyval_create<simgrid::smpi::Win>(_copy_fn, _delete_fn, keyval, extra_state);
 }
 
index e31f526..4b96a33 100644 (file)
@@ -191,7 +191,7 @@ void mpi_win_set_info_(int* win, int* info, int* ierr);
 void mpi_win_get_info_(int* win, int* info, int* ierr);
 void mpi_win_get_group_(int* win, int* group, int* ierr);
 void mpi_win_get_attr_(int* win, int* type_keyval, int* attribute_val, int* flag, int* ierr);
-void mpi_win_set_attr_(int* win, int* type_keyval, void* att, int* ierr);
+void mpi_win_set_attr_(int* win, int* type_keyval, int* att, int* ierr);
 void mpi_win_delete_attr_(int* win, int* comm_keyval, int* ierr);
 void mpi_win_create_keyval_(void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr);
 void mpi_win_free_keyval_(int* keyval, int* ierr);
@@ -243,7 +243,7 @@ void mpi_type_dup_(int* datatype, int* newdatatype, int* ierr);
 void mpi_type_set_name_(int* datatype, char* name, int* ierr, int size);
 void mpi_type_get_name_(int* datatype, char* name, int* len, int* ierr);
 void mpi_type_get_attr_(int* type, int* type_keyval, int* attribute_val, int* flag, int* ierr);
-void mpi_type_set_attr_(int* type, int* type_keyval, void* attribute_val, int* ierr);
+void mpi_type_set_attr_(int* type, int* type_keyval, int* attribute_val, int* ierr);
 void mpi_type_delete_attr_(int* type, int* type_keyval, int* ierr);
 void mpi_type_create_keyval_(void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr);
 void mpi_type_free_keyval_(int* keyval, int* ierr);
@@ -265,7 +265,7 @@ void mpi_group_excl_(int* group, int* n, int* ranks, int* newgroup, int* ierr);
 void mpi_group_range_incl_(int* group, int* n, int ranges[][3], int* newgroup, int* ierr);
 void mpi_group_range_excl_(int* group, int* n, int ranges[][3], int* newgroup, int* ierr);
 void mpi_comm_get_attr_(int* comm, int* comm_keyval, int* attribute_val, int* flag, int* ierr);
-void mpi_comm_set_attr_(int* comm, int* comm_keyval, void* attribute_val, int* ierr);
+void mpi_comm_set_attr_(int* comm, int* comm_keyval, int* attribute_val, int* ierr);
 void mpi_comm_delete_attr_(int* comm, int* comm_keyval, int* ierr);
 void mpi_comm_create_keyval_(void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr);
 void mpi_comm_free_keyval_(int* keyval, int* ierr);
@@ -337,7 +337,7 @@ void mpi_comm_remote_size_(int* comm, int* size, int* ierr);
 void mpi_issend_(void* buf, int* count, int* datatype, int* dest, int* tag, int* comm, int* request, int* ierr);
 void mpi_probe_(int* source, int* tag, int* comm, MPI_Status* status, int* ierr);
 void mpi_attr_delete_(int* comm, int* keyval, int* ierr);
-void mpi_attr_put_(int* comm, int* keyval, void* attr_value, int* ierr);
+void mpi_attr_put_(int* comm, int* keyval, int* attr_value, int* ierr);
 void mpi_rsend_init_(void* buf, int* count, int* datatype, int* dest, int* tag, int* comm, int* request, int* ierr);
 void mpi_keyval_create_(void* copy_fn, void* delete_fn, int* keyval, void* extra_state, int* ierr);
 void mpi_keyval_free_(int* keyval, int* ierr);
index 1f8ce73..c6a200f 100644 (file)
@@ -14,17 +14,24 @@ struct smpi_delete_fn {
   MPI_Comm_delete_attr_function          *comm_delete_fn;
   MPI_Type_delete_attr_function          *type_delete_fn;
   MPI_Win_delete_attr_function           *win_delete_fn;
+  MPI_Comm_delete_attr_function_fort     *comm_delete_fn_fort;
+  MPI_Type_delete_attr_function_fort     *type_delete_fn_fort;
+  MPI_Win_delete_attr_function_fort      *win_delete_fn_fort;
 };
 
 struct smpi_copy_fn {
   MPI_Comm_copy_attr_function          *comm_copy_fn;
   MPI_Type_copy_attr_function          *type_copy_fn;
   MPI_Win_copy_attr_function           *win_copy_fn;
+  MPI_Comm_copy_attr_function_fort     *comm_copy_fn_fort;
+  MPI_Type_copy_attr_function_fort     *type_copy_fn_fort;
+  MPI_Win_copy_attr_function_fort      *win_copy_fn_fort;
 };
 
 struct s_smpi_key_elem_t {
   smpi_copy_fn copy_fn;
   smpi_delete_fn delete_fn;
+  void* extra_state;
   int refcount;
 };
 
@@ -57,6 +64,7 @@ template <typename T> int Keyval::keyval_create(smpi_copy_fn copy_fn, smpi_delet
 
   value->copy_fn=copy_fn;
   value->delete_fn=delete_fn;
+  value->extra_state=extra_state;
   value->refcount=1;
 
   *keyval = T::keyval_id_;
@@ -124,15 +132,15 @@ template <typename T> int Keyval::attr_put(int keyval, void* attr_value){
   if(elem==nullptr)
     return MPI_ERR_ARG;
   elem->refcount++;
-  void * value = nullptr;
   int flag=0;
-  this->attr_get<T>(keyval, &value, &flag);
-  if(flag!=0){
-    int ret = call_deleter<T>((T*)this, elem, keyval,value,&flag);
+  auto p = attributes()->insert({keyval, attr_value});
+  if (!p.second) {
+    int ret = call_deleter<T>((T*)this, elem, keyval,p.first->second,&flag);
+    // overwrite previous value
+    p.first->second = attr_value;
     if(ret!=MPI_SUCCESS)
-        return ret;
+      return ret;
   }
-  attributes()->insert({keyval, attr_value});
   return MPI_SUCCESS;
 }
 
index 57c61d2..47cf004 100644 (file)
@@ -61,18 +61,29 @@ int Comm::dup(MPI_Comm* newcomm){
   int ret      = MPI_SUCCESS;
 
   if (not attributes()->empty()) {
-    int flag;
-    void* value_out;
+    int flag=0;
+    void* value_out=nullptr;
     for (auto const& it : *attributes()) {
       smpi_key_elem elem = keyvals_.at(it.first);
-      if (elem != nullptr && elem->copy_fn.comm_copy_fn != MPI_NULL_COPY_FN) {
-        ret = elem->copy_fn.comm_copy_fn(this, it.first, nullptr, it.second, &value_out, &flag);
+      if (elem != nullptr){
+        if( elem->copy_fn.comm_copy_fn != MPI_NULL_COPY_FN && 
+            elem->copy_fn.comm_copy_fn != MPI_COMM_DUP_FN)
+          ret = elem->copy_fn.comm_copy_fn(this, it.first, elem->extra_state, it.second, &value_out, &flag);
+        else if ( elem->copy_fn.comm_copy_fn_fort != MPI_NULL_COPY_FN &&
+                  *(int*)*elem->copy_fn.comm_copy_fn_fort != 1){
+          value_out=(int*)xbt_malloc(sizeof(int));
+          elem->copy_fn.comm_copy_fn_fort(this, it.first, elem->extra_state, it.second, value_out, &flag,&ret);
+        }
         if (ret != MPI_SUCCESS) {
           Comm::destroy(*newcomm);
           *newcomm = MPI_COMM_NULL;
           return ret;
         }
-        if (flag){
+        if (elem->copy_fn.comm_copy_fn == MPI_COMM_DUP_FN || 
+           ((elem->copy_fn.comm_copy_fn_fort != MPI_NULL_COPY_FN) && *(int*)*elem->copy_fn.comm_copy_fn_fort == 1)){
+          elem->refcount++;
+          (*newcomm)->attributes()->insert({it.first, it.second});
+        }else if (flag){
           elem->refcount++;
           (*newcomm)->attributes()->insert({it.first, value_out});
         }
index 5136911..c9b75ab 100644 (file)
@@ -128,21 +128,31 @@ Datatype::Datatype(Datatype *datatype, int* ret) : name_(nullptr), lb_(datatype-
   *ret = MPI_SUCCESS;
   if(datatype->name_)
     name_ = xbt_strdup(datatype->name_);
-
+    
   if (not datatype->attributes()->empty()) {
-    int flag;
+    int flag=0;
     void* value_out;
-    for(auto it = datatype->attributes()->begin(); it != datatype->attributes()->end(); it++){
-      smpi_key_elem elem = keyvals_.at((*it).first);
-
-      if (elem != nullptr && elem->copy_fn.type_copy_fn != MPI_NULL_COPY_FN) {
-        *ret = elem->copy_fn.type_copy_fn(datatype, (*it).first, nullptr, (*it).second, &value_out, &flag);
+    for (auto const& it : *(datatype->attributes())) {
+      smpi_key_elem elem = keyvals_.at(it.first);
+      if (elem != nullptr){
+        if( elem->copy_fn.type_copy_fn != MPI_NULL_COPY_FN && 
+            elem->copy_fn.type_copy_fn != MPI_TYPE_DUP_FN)
+          *ret = elem->copy_fn.type_copy_fn(datatype, it.first, elem->extra_state, it.second, &value_out, &flag);
+        else if ( elem->copy_fn.type_copy_fn_fort != MPI_NULL_COPY_FN &&
+                  (*(int*)*elem->copy_fn.type_copy_fn_fort) != 1){
+          value_out=(int*)xbt_malloc(sizeof(int));
+          elem->copy_fn.type_copy_fn_fort(datatype, it.first, elem->extra_state, it.second, value_out, &flag,ret);
+        }
         if (*ret != MPI_SUCCESS) {
           break;
         }
-        if (flag){
+        if(elem->copy_fn.type_copy_fn == MPI_TYPE_DUP_FN || 
+          ((elem->copy_fn.type_copy_fn_fort != MPI_NULL_COPY_FN) && (*(int*)*elem->copy_fn.type_copy_fn_fort == 1))){
+          elem->refcount++;
+          attributes()->insert({it.first, it.second});
+        } else if (flag){
           elem->refcount++;
-          attributes()->insert({(*it).first, value_out});
+          attributes()->insert({it.first, value_out});
         }
       }
     }
index 47728de..35b82ff 100644 (file)
@@ -16,30 +16,30 @@ std::unordered_map<int, void*>* Keyval::attributes(){
 
 
 template <> int Keyval::call_deleter<Comm>(Comm* obj, smpi_key_elem elem, int keyval, void * value, int* flag){
-  if(elem->delete_fn.comm_delete_fn!=MPI_NULL_DELETE_FN){
-    int ret = elem->delete_fn.comm_delete_fn(obj, keyval, value, flag);
-    if(ret!=MPI_SUCCESS)
-      return ret;
-  }
-  return MPI_SUCCESS;
+  int ret = MPI_SUCCESS;
+  if(elem->delete_fn.comm_delete_fn!=MPI_NULL_DELETE_FN)
+    ret = elem->delete_fn.comm_delete_fn(obj, keyval, value, elem->extra_state);
+  else if(elem->delete_fn.comm_delete_fn_fort!=MPI_NULL_DELETE_FN)
+    elem->delete_fn.comm_delete_fn_fort(obj, keyval, value, elem->extra_state, &ret);
+  return ret;
 }
 
 template <> int Keyval::call_deleter<Win>(Win* obj, smpi_key_elem elem, int keyval, void * value, int* flag){
-  if(elem->delete_fn.win_delete_fn!=MPI_NULL_DELETE_FN){
-    int ret = elem->delete_fn.win_delete_fn(obj, keyval, value, flag);
-    if(ret!=MPI_SUCCESS)
-      return ret;
-  }
-  return MPI_SUCCESS;
+  int ret = MPI_SUCCESS;
+  if(elem->delete_fn.win_delete_fn!=MPI_NULL_DELETE_FN)
+    ret = elem->delete_fn.win_delete_fn(obj, keyval, value, elem->extra_state);
+  else if(elem->delete_fn.win_delete_fn_fort!=MPI_NULL_DELETE_FN)
+    elem->delete_fn.win_delete_fn_fort(obj, keyval, value, elem->extra_state, &ret);
+  return ret;
 }
 
 template <> int Keyval::call_deleter<Datatype>(Datatype* obj, smpi_key_elem elem, int keyval, void * value, int* flag){
-  if(elem->delete_fn.type_delete_fn!=MPI_NULL_DELETE_FN){
-    int ret = elem->delete_fn.type_delete_fn(obj, keyval, value, flag);
-    if(ret!=MPI_SUCCESS)
-      return ret;
-  }
-  return MPI_SUCCESS;
+  int ret = MPI_SUCCESS;
+  if(elem->delete_fn.type_delete_fn!=MPI_NULL_DELETE_FN)
+    ret = elem->delete_fn.type_delete_fn(obj, keyval, value, elem->extra_state);
+  else if(elem->delete_fn.type_delete_fn_fort!=MPI_NULL_DELETE_FN)
+    elem->delete_fn.type_delete_fn_fort(obj, keyval, value, elem->extra_state, &ret);
+  return ret;
 }
 
 }
index 031d5f0..911fe58 100644 (file)
@@ -1050,7 +1050,7 @@ set(CMAKEFILES_TXT
   teshsuite/smpi/mpich3-test/coll/CMakeLists.txt
   teshsuite/smpi/mpich3-test/comm/CMakeLists.txt
   teshsuite/smpi/mpich3-test/datatype/CMakeLists.txt
-#  teshsuite/smpi/mpich3-test/f77/attr/CMakeLists.txt
+  teshsuite/smpi/mpich3-test/f77/attr/CMakeLists.txt
   teshsuite/smpi/mpich3-test/f77/coll/CMakeLists.txt
   teshsuite/smpi/mpich3-test/f77/info/CMakeLists.txt
   teshsuite/smpi/mpich3-test/f77/comm/CMakeLists.txt