Giter Club home page Giter Club logo

mpifx's Introduction

MpiFx - Modern Fortran Interface for MPI

The open source library MpiFx provides modern Fortran (Fortran 2008) wrappers around routines of the MPI library to make their use as simple as possible. Currently several data distribution routines are covered.

The documentation is included inside the repository, but is also available at dftbplus.github.io.

Installation

The preferred way of obtaining MpiFx is to install it via the Conda package management framework using Miniconda or Anaconda. Make sure to add/enable the conda-forge channel in order to be able to access MpiFx, and ensure that the conda-forge channel is the first repository to be searched for packages.

We provide both, OpenMPI and MPICH based build variants, choose the one suiting your needs. For example, issue

conda install 'mpifx=*=mpi_mpich_*'

or

conda install 'mpifx=*=mpi_openmpi_*'

to get the last stable release of MpiFx for the respective MPI framework.

Building from source

Prerequisites

  • CMake (version >= 3.16)
  • Fortran 2008 compatible Fortran compiler
  • MPI-library and wrappers for your compiler supporting the mpi_f08 interface
  • Fypp preprocessor

Building and installing the library

The library can be built and installed with the usual CMake-workflow:

FC=gfortran cmake -B _build -DCMAKE_INSTALL_PREFIX=$HOME/opt/mpifx
cmake --build _build
cmake --install _build

You can influence the configuration via CMake-variables, which are listed in config.cmake. You can either modify the values directly there or pass them as command line options at the configuration phase, e.g.:

FC=ifort cmake -B _build -DBUILD_TESTING=NO .

Testing

A few tests / usage examples can be found in the test/ subdirectory, a sub-set of which can be checked with ctest. The compiled test programs will be in the test/ subfolder of your build directory.

To disable building tests, include the cmake option -DBUILD_TESTING=OFF

Using the library

CMake build

  • Make sure to add the root folder of the installed library to the CMAKE_PREFIX_PATH environment variable.

  • Use find_package() in CMakeLists.txt to locate the library and link MpiFx::MpiFx to every target which relies directly on the library

    cmake_minimum_required(VERSION 3.16)
    
    project(TestMpiFx LANGUAGES Fortran)
    
    find_package(MpiFx REQUIRED)
    
    add_executable(test_mpifx test_mpifx.f90)
    target_link_libraries(test_mpifx MpiFx::MpiFx)
    

Pkg-config build

  • Make sure to add the lib/pkgconfig folder of the installed library to the PKG_CONFIG_PATH environment variable.

  • Query the include and library options needed for the build with the usual pkg-config commands:

    mpifort $(pkg-config --cflags mpifx) test_mpifx.f90 $(pkg-config --libs mpifx)
    

    Note, that neither -cflags or --libs return any options related to your MPI-framework nor is the MPI-framework specified as dependency in the pkg-config file. Use the MPI-wrapper of your compiler to compile and link your executable or pass the additional include and library options by hand.

License

MpiFx is licensed under the 2-Clause BSD License.

mpifx's People

Contributors

aradi avatar awvwgk avatar baradi09 avatar bhourahine avatar gpenazzi avatar jubich avatar pecchia avatar terminationshock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

mpifx's Issues

fypp as a submodule (?)

The readme needs to be updated to explain the fypp dependency, but should that be a submodule to the project or require installing?

Build of tests fails for version 1.3

Seems like a variable is not declared properly in one of the tests:

[89/121] Building Fortran object test/CMakeFiles/test_allgather.dir/test_allgather.f90.o
FAILED: test/CMakeFiles/test_allgather.dir/test_allgather.f90.o 
$BUILD_PREFIX/bin/x86_64-conda-linux-gnu-gfortran -I$SRC_DIR/test -I$SRC_DIR/_build/lib/include -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/mpifx-1.3 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix -fallow-argument-mismatch -O2 -g -DNDEBUG -Jtest -fpreprocessed -c test/CMakeFiles/test_allgather.dir/test_allgather.f90-pp.f90 -o test/CMakeFiles/test_allgather.dir/test_allgather.f90.o
$SRC_DIR/test/test_allgather.f90:27:11:

   27 |     tPassed = .false.
      |           1
Error: Symbol 'tpassed' at (1) has no IMPLICIT type; did you mean 'ispassed'?

Tests fail to run

Running tests...
/usr/local/bin/ctest --force-new-ctest-process 
Test project /usr/ports/net/mpifx/work/.build
    Start 1: test_allgather
1/2 Test #1: test_allgather ...................***Failed  Required regular expression not found. Regex=[TestPASSED
]  0.06 sec
--------------------------------------------------------------------------
There are not enough slots available in the system to satisfy the 8
slots that were requested by the application:

  /usr/ports/net/mpifx/work/.build/test/test_allgather

Either request fewer slots for your application, or make more slots
available for use.

A "slot" is the Open MPI term for an allocatable unit where we can
launch a process.  The number of slots available are defined by the
environment in which Open MPI processes are run:

  1. Hostfile, via "slots=N" clauses (N defaults to number of
     processor cores if not provided)
  2. The --host command line parameter, via a ":N" suffix on the
     hostname (N defaults to 1 if not provided)
  3. Resource manager (e.g., SLURM, PBS/Torque, LSF, etc.)
  4. If none of a hostfile, the --host command line parameter, or an
     RM is present, Open MPI defaults to the number of processor cores

In all the above cases, if you want Open MPI to default to the number
of hardware threads instead of the number of processor cores, use the
--use-hwthread-cpus option.

Alternatively, you can use the --oversubscribe option to ignore the
number of available slots when deciding the number of processes to
launch.
--------------------------------------------------------------------------

    Start 2: test_allgatherv
2/2 Test #2: test_allgatherv ..................***Failed  Required regular expression not found. Regex=[TestPASSED
]  0.04 sec
--------------------------------------------------------------------------
There are not enough slots available in the system to satisfy the 8
slots that were requested by the application:

  /usr/ports/net/mpifx/work/.build/test/test_allgatherv

Either request fewer slots for your application, or make more slots
available for use.

A "slot" is the Open MPI term for an allocatable unit where we can
launch a process.  The number of slots available are defined by the
environment in which Open MPI processes are run:

  1. Hostfile, via "slots=N" clauses (N defaults to number of
     processor cores if not provided)
  2. The --host command line parameter, via a ":N" suffix on the
     hostname (N defaults to 1 if not provided)
  3. Resource manager (e.g., SLURM, PBS/Torque, LSF, etc.)
  4. If none of a hostfile, the --host command line parameter, or an
     RM is present, Open MPI defaults to the number of processor cores

In all the above cases, if you want Open MPI to default to the number
of hardware threads instead of the number of processor cores, use the
--use-hwthread-cpus option.

Alternatively, you can use the --oversubscribe option to ignore the
number of available slots when deciding the number of processes to
launch.
--------------------------------------------------------------------------


0% tests passed, 2 tests failed out of 2

Total Test time (real) =   0.10 sec

The following tests FAILED:
	  1 - test_allgather (Failed)
	  2 - test_allgatherv (Failed)
Errors while running CTest

Version: 1.4
FreeBSD 13.2

CI for ctests

As there are ctests, could set up a github action for 2 processors. Likewise for condaforge packaging.

cmake build requires information/HINTs

Out of the box, there is no information in README.rst that covers cmake use and
mkdir build && cd build && cmake ..
will fail unless fypp is installed globally (and also probably fails at use mpi unless its been lucky on compiler choice),

missing includes when compiling as library with cmake

I am compiling as shared lib and it seems that the MPI includes are missing. Am I doing something wrong? Fixed locally by adding target_include_directories(mpifx PRIVATE ${MPI_Fortran_MODULE_DIR})

Related, wouldn't it make sense to also link the MPI libs as ttarget_link_libraries(mpifx PRIVATE ${MPI_Fortran_LIBRARIES}) when building as shared lib?

cmake has redundant library include

CMakeLists.txt has a stray set:

set(INSTALL_MOD_DIR "${CMAKE_INSTALL_PREFIX}/include/dftd3" CACHE PATH
"Installation directory for Fortran module files")

./test_comm_split fails: Floating-point exception - erroneous arithmetic operation

cd /disk-samsung/freebsd-ports/net/mpifx/work/.build/test && ./test_comm_split

Program received signal SIGFPE: Floating-point exception - erroneous arithmetic operation.

Backtrace for this error:
#0  0x800e1f6db in ???
#1  0x800e1e896 in ???
#2  0x800d1de5f in handle_signal
	at /disk-samsung/freebsd-src/lib/libthr/thread/thr_sig.c:303
#3  0x800d1d42e in thr_sighandler
	at /disk-samsung/freebsd-src/lib/libthr/thread/thr_sig.c:246
#4  0x7ffffffff002 in ???
#5  0x400eaa in ???
#6  0x400a5c in ???
#7  0x400b6f in _start
	at /disk-samsung/freebsd-src/lib/csu/amd64/crt1_c.c:75
*** Signal 8

Version: 1.2
OS: FreeBSD 13

Mismatching types in MPI_win wrappers (and resulting build problems with MPICH 4.x)

Currently, MPIFX can not be built with MPICH 4.x.

Problem

The MPI-window wrappers use the old F90 mpi module (instead of mpi_f08) but type(c_ptr) as argument type for pointers, which is strictly only valid when using mpi_f08.

Possible solution

One would have to upgrade the entire library to use mpi_f08 all over.

Converting the pointer argument types to integer(mpi_address_kind) to be compatible with the f90 mpi module is not a real option, as subsequent c_f_pointer() would not work due to type-mismatch.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.