Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of git+ssh://scm.gforge.inria.fr//gitroot/simgrid/simgrid
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 26 Jul 2018 07:09:02 +0000 (09:09 +0200)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Thu, 26 Jul 2018 07:09:02 +0000 (09:09 +0200)
CMakeLists.txt
src/smpi/include/smpi_actor.hpp
src/smpi/internals/smpi_actor.cpp
src/smpi/internals/smpi_global.cpp
teshsuite/smpi/CMakeLists.txt
teshsuite/smpi/fort_args/fort_args.f90 [new file with mode: 0644]
teshsuite/smpi/fort_args/fort_args.tesh [new file with mode: 0644]
tools/cmake/MakeLib.cmake
tools/cmake/src/internal_config.h.in

index 31f0405..25cd68f 100644 (file)
@@ -87,12 +87,15 @@ if ((NOT DEFINED enable_smpi) OR enable_smpi)
     if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
       set(SMPI_Fortran_FLAGS "\"-fpic\" \"-ff2c\" \"-fno-second-underscore\"")
       set(SMPI_Fortran_LIBS "\"-lgfortran\"")
+      set(SMPI_GFORTRAN 1)
     elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
       set(SMPI_Fortran_FLAGS "\"-fPIC\" \"-nofor-main\"")
       set(SMPI_Fortran_LIBS "\"-lifcore\"")
+      set(SMPI_IFORT 1)
     elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI|Flang") # flang
       set(SMPI_Fortran_FLAGS "\"-fPIC\"")
       set(SMPI_Fortran_LIBS "")
+      set(SMPI_FLANG 1)
     endif()
 
     set(SMPI_FORTRAN 1)
index bf6371c..0f1a13e 100644 (file)
@@ -17,8 +17,6 @@ namespace smpi {
 class ActorExt {
 private:
   double simulated_ = 0 /* Used to time with simulated_start/elapsed */;
-  int* argc_        = nullptr;
-  char*** argv_     = nullptr;
   simgrid::s4u::MailboxPtr mailbox_;
   simgrid::s4u::MailboxPtr mailbox_small_;
   xbt_mutex_t mailboxes_mutex_;
index 42847cf..c358275 100644 (file)
@@ -75,8 +75,6 @@ void ActorExt::set_data(int* argc, char*** argv)
     (*argv)[(*argc) - 2] = nullptr;
   }
   (*argc) -= 2;
-  argc_ = argc;
-  argv_ = argv;
   // set the process attached to the mailbox
   mailbox_small_->set_receiver(actor_);
   XBT_DEBUG("<%ld> SMPI process has been initialized: %p", actor_->get_pid(), actor_.get());
index 5e70fb2..66a4be2 100644 (file)
@@ -42,6 +42,15 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_kernel, smpi, "Logging specific to SMPI (ke
 #include <boost/tokenizer.hpp>
 #include <boost/algorithm/string.hpp> /* trim_right / trim_left */
 
+#if SMPI_IFORT
+  extern "C" void for_rtl_init_ (int *, char **);
+#elif SMPI_FLANG
+  extern "C" void __io_set_argc(int);
+  extern "C" void __io_set_argv(char **);
+#elif SMPI_GFORTRAN
+  extern "C" void _gfortran_set_args(int, char **);
+#endif
+
 #ifndef RTLD_DEEPBIND
 /* RTLD_DEEPBIND is a bad idea of GNU ld that obviously does not exist on other platforms
  * See https://www.akkadia.org/drepper/dsohowto.pdf
@@ -423,9 +432,15 @@ static int smpi_run_entry_point(smpi_entry_point_type entry_point, std::vector<s
     argv[i] = args[i].empty() ? noarg : &args[i].front();
   argv[argc] = nullptr;
   char ** argvptr=argv.get();
-
   simgrid::smpi::ActorExt::init(&argc, &argvptr);
-
+#if SMPI_IFORT
+  for_rtl_init_ (&argc, argvptr);
+#elif SMPI_FLANG
+  __io_set_argc(argc);
+  __io_set_argv(argvptr);
+#elif SMPI_GFORTRAN
+  _gfortran_set_args(argc, argvptr);
+#endif 
   int res = entry_point(argc, argvptr);
   if (res != 0){
     XBT_WARN("SMPI process did not return 0. Return value : %d", res);
index 18ac176..97e081c 100644 (file)
@@ -21,6 +21,13 @@ if(enable_smpi)
       set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
     endforeach()
   endif()
+
+  if(enable_smpi AND SMPI_FORTRAN)
+    set(CMAKE_Fortran_COMPILER "${CMAKE_BINARY_DIR}/smpi_script/bin/smpif90")
+    add_executable       (fort_args fort_args/fort_args.f90)
+    target_link_libraries(fort_args simgrid)
+    set_target_properties(fort_args PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/fort_args)
+  endif()
 endif()
 
 foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast
@@ -31,16 +38,18 @@ foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-allto
   set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.c)
 endforeach()
 
-set (teshsuite_src ${teshsuite_src} PARENT_SCOPE)
+set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/fort_args/fort_args.f90 PARENT_SCOPE)
 set(tesh_files    ${tesh_files}     ${CMAKE_CURRENT_SOURCE_DIR}/coll-allreduce/coll-allreduce-large.tesh
                                     ${CMAKE_CURRENT_SOURCE_DIR}/coll-allreduce/coll-allreduce-automatic.tesh
                                     ${CMAKE_CURRENT_SOURCE_DIR}/coll-alltoall/clusters.tesh
                                     ${CMAKE_CURRENT_SOURCE_DIR}/pt2pt-pingpong/broken_hostfiles.tesh
-                                    ${CMAKE_CURRENT_SOURCE_DIR}/pt2pt-pingpong/TI_output.tesh                                       PARENT_SCOPE)
+                                    ${CMAKE_CURRENT_SOURCE_DIR}/pt2pt-pingpong/TI_output.tesh
+                                    ${CMAKE_CURRENT_SOURCE_DIR}/fort_args/fort_args.tesh  PARENT_SCOPE)
 set(bin_files       ${bin_files}    ${CMAKE_CURRENT_SOURCE_DIR}/hostfile
                                     ${CMAKE_CURRENT_SOURCE_DIR}/hostfile_cluster
                                     ${CMAKE_CURRENT_SOURCE_DIR}/hostfile_coll
-                                    ${CMAKE_CURRENT_SOURCE_DIR}/hostfile_empty                             PARENT_SCOPE)
+                                    ${CMAKE_CURRENT_SOURCE_DIR}/hostfile_empty  PARENT_SCOPE)
+
 
 if(enable_smpi)
   if(NOT WIN32)
@@ -51,10 +60,14 @@ if(enable_smpi)
 
   foreach(x coll-allgather coll-allgatherv coll-allreduce coll-alltoall coll-alltoallv coll-barrier coll-bcast
             coll-gather coll-reduce coll-reduce-scatter coll-scatter macro-sample pt2pt-dsend pt2pt-pingpong
-            type-hvector type-indexed type-struct type-vector bug-17132 timers)
+           type-hvector type-indexed type-struct type-vector bug-17132 timers)
     ADD_TESH_FACTORIES(tesh-smpi-${x} "thread;ucontext;raw;boost" --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/${x} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/${x} ${x}.tesh)
   endforeach()
 
+  if(SMPI_FORTRAN)
+    ADD_TESH_FACTORIES(tesh-smpi-fort_args "thread;ucontext;raw;boost" --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv srcdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/fort_args --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/fort_args fort_args.tesh)
+  endif()
+
   foreach (ALLGATHER 2dmesh 3dmesh bruck GB loosely_lr NTSLR NTSLR_NB pair rdb  rhv ring SMP_NTS smp_simple spreading_simple
                      ompi mpich ompi_neighborexchange mvapich2 mvapich2_smp impi)
     ADD_TESH(tesh-smpi-coll-allgather-${ALLGATHER} --cfg smpi/allgather:${ALLGATHER} --setenv platfdir=${CMAKE_HOME_DIRECTORY}/examples/platforms --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/smpi/coll-allgather --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/smpi/coll-allgather coll-allgather.tesh)
diff --git a/teshsuite/smpi/fort_args/fort_args.f90 b/teshsuite/smpi/fort_args/fort_args.f90
new file mode 100644 (file)
index 0000000..dbd9c10
--- /dev/null
@@ -0,0 +1,30 @@
+! Check that getarg does somethig sensible.
+program getarg_1
+  CHARACTER*10 ARGS, ARGS2
+  INTEGER*4 I
+  INTEGER*2 I2
+  I = 0
+  CALL GETARG(I,ARGS)
+  ! This should return the invoking command.  The actual value depends 
+  ! on the OS, but a blank string is wrong no matter what.
+  ! ??? What about deep embedded systems?
+
+  I2 = 0
+  CALL GETARG(I2,ARGS2)
+  if (args2.ne.args) STOP 1
+
+  if (args.eq.'') STOP 2
+  I = 1
+  CALL GETARG(I,ARGS)
+  if (args.ne.'a') STOP 3
+  I = -1
+  CALL GETARG(I,ARGS)
+  if (args.ne.'') STOP 4
+  ! Assume we won't have been called with more that 4 args.
+  I = 4
+  CALL GETARG(I,ARGS)
+  if (args.ne.'') STOP 5
+  I = 1000
+  CALL GETARG(I,ARGS)
+  if (args.ne.'') STOP 6
+end
diff --git a/teshsuite/smpi/fort_args/fort_args.tesh b/teshsuite/smpi/fort_args/fort_args.tesh
new file mode 100644 (file)
index 0000000..8e220e3
--- /dev/null
@@ -0,0 +1,5 @@
+p Test fortran params
+! output sort
+$ ${bindir:=.}/../../../smpi_script/bin/smpirun -map -hostfile ../hostfile -platform ${platfdir}/small_platform.xml -np 2 ${bindir:=.}/fort_args 'a' 3 -q --log=smpi_kernel.thres:warning --log=xbt_cfg.thres:warning
+> [rank 0] -> Tremblay
+> [rank 1] -> Jupiter
index 57292dd..24b8b07 100644 (file)
@@ -94,6 +94,20 @@ if(enable_smpi)
     PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/simgrid)
   install(TARGETS smpimain # install that binary without breaking the rpath on Mac
     RUNTIME DESTINATION lib/simgrid)
+
+  if(SMPI_FORTRAN)
+    if(CMAKE_Fortran_COMPILER_ID MATCHES "GNU")
+      SET(SIMGRID_DEP "${SIMGRID_DEP} -lgfortran")
+    elseif(CMAKE_Fortran_COMPILER_ID MATCHES "Intel")
+      SET(SIMGRID_DEP "${SIMGRID_DEP} -lifcore")
+    elseif(CMAKE_Fortran_COMPILER_ID MATCHES "PGI|Flang")
+      SET(SIMGRID_DEP "${SIMGRID_DEP} -lflang")
+      if("${CMAKE_SYSTEM}" MATCHES "FreeBSD")
+        set(SIMGRID_DEP "${SIMGRID_DEP} -lexecinfo")
+      endif()
+    endif()
+  endif()
+
 endif()
 
 if(enable_smpi AND APPLE)
index 8b25542..934d648 100644 (file)
 /* SMPI variables */
 /* SMPI enabled */
 #cmakedefine01 HAVE_SMPI
-/* Fortran language is available for SMPI */
+/* Fortran language is available for SMPI, and which one */
 #cmakedefine01 SMPI_FORTRAN
+#cmakedefine01 SMPI_GFORTRAN
+#cmakedefine01 SMPI_FLANG
+#cmakedefine01 SMPI_IFORT
 /* We have mmap and objdump to handle privatization */
 #cmakedefine01 HAVE_PRIVATIZATION
 /* We have PAPI to fine-grain trace execution time */