Coder Social home page Coder Social logo

dudugang / mpl Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rabauke/mpl

0.0 0.0 0.0 15.96 MB

MPL - A C++11 message passing library based on MPI

Home Page: https://rabauke.github.io/mpl/html/

License: BSD 3-Clause "New" or "Revised" License

C++ 92.66% CMake 7.34%

mpl's Introduction

MPL - A message passing library

MPL is a message passing library written in C++11 based on the Message Passing Interface (MPI) standard. Since the C++ API has been dropped from the MPI standard in version 3.0 it is the aim of MPL to provide a modern C++ message passing library for high performance computing.

MPL will neither bring all functions of the C language MPI-API to C++ nor provide a direct mapping of the C API to some C++ functions and classes. Its focus lies on the MPI core message passing functions, ease of use, type safety, and elegance. This library is most useful for developers who have at least some basic knowledge of the Message Passing Interface and would like to utilize it via a more user friendly interface.

Installation

MPL is a header-only library. Just download the source and copy the mpl directory containing all header files to a place, where the compiler will find it, e.g., /usr/local/include on a typical Unix/Linux system. As MPL is built on MPI, an MPI implementation needs to be installed, e.g., Open MPI or MPICH.

Hello World

MPL is built on top of the Message Passing Interface (MPI) standard. Therefore, MPL shares many concepts known from the MPI standard, e.g., the concept of a communicator. Communicators manage the message exchange between different processes, i.e.,
messages are sent and received with the help of a communicator.

The MPL envirionment provides a global default communicator comm_world, which will be used in the following Hello-World program. The program prints out some information about each process:

  • its rank,
  • the total number of processes and
  • the computer's name the process is running on.

If there are two or more processes, a message is sent from process 0 to process 1, which is also printed.

#include <cstdlib>
#include <iostream>
// include MPL header file
#include <mpl/mpl.hpp>

int main() {
  // get a reference to communicator "world"
  const mpl::communicator &comm_world(mpl::environment::comm_world());
  // each process prints a message containing the processor name, the rank
  // in communicator world and the size of communicator world
  // output may depend on MPI implementation
  std::cout << "Hello world! I am running on \"" << mpl::environment::processor_name()
            << "\". My rank is " << comm_world.rank() << " out of " << comm_world.size()
            << " processes.\n";
  // if there are two or more processes send a message from process 0 to process 1
  if (comm_world.size() >= 2) {
    if (comm_world.rank() == 0) {
      std::string message{"Hello world!"};
      comm_world.send(message, 1);  // send message to rank 1
    } else if (comm_world.rank() == 1) {
      std::string message;
      comm_world.recv(message, 0);  // receive message from rank 0
      std::cout << "got: \"" << message << "\"\n";
    }
  }
  return EXIT_SUCCESS;
}

Documentation

For further documentation see the Doxygen-generated documentation, the blog posts

the presentation

and the files in the examples directory of the source package.

mpl's People

Contributors

rabauke avatar jsharpe avatar raulppelaez avatar

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.