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)
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_;
(*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());
#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
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);
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
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)
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)
--- /dev/null
+! 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
--- /dev/null
+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
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)
/* 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 */