Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A C++17 message passing library based on MPI

License

NotificationsYou must be signed in to change notification settings

rabauke/mpl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

build-with-openmpibuild-with-mpichbuild-with-IntelMPILicense

MPL is a message passing library written in C++17 based on theMessage Passing Interface (MPI) standard.Since the C++ API has been dropped from the MPI standard in version3.1, it is the aim of MPL to provide a modern C++ message passinglibrary 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 andclasses. The library's focus lies on the MPI core message passingfunctions, ease of use, type safety, and elegance. The aim of MPL is toprovide an idiomatic C++ message passing library without introducing asignificant overhead compared to utilizing MPI via its plain C-API.This library is most useful for developers who have at least some basicknowledge of the Message Passing Interface standard and would like toutilize it via a more user-friendly interface in modern C++. UnlikeBoost.MPI,MPL does not rely on an external serialization library and has anegligible run-time overhead.

Supported features

MPL assumes that the underlying MPI implementation supports theversion 3.1of the Message Passing Interface standard. Future versions of MPLmay also employ features of the newversion 4.0or later MPI versions.

MPL gives currently access via a convenient C++ interface to thefollowing features of the Message Passing Interface standard:

  • environmental management (implicit initialization and finalization, timers, but no error handling).
  • point-to-point communication (blocking and non-blocking),
  • collective communication (blocking and non-blocking),
  • derived data types (happens automatically for many custom data types or via thebase_struct_builder helper class and the layout classes of MPL),
  • communicator- and group-management,
  • process topologies (cartesian and graph topologies),
  • inter-communicators,
  • dynamic process creation and
  • file i/o.

Currently, the following MPI features are not yet supported by MPL:

  • error handling and
  • one-sided communication.

Although MPL covers a subset of the MPI functionality only, it hasprobably the largest MPI-feature coverage among all alternative C++interfaces to MPI.

Hello parallel 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 acommunicator. Communicators manage the message exchange between different processes,i.e., messages are sent and received with the help of a communicator.

The MPL environment provides a global default communicatorcomm_world, which willbe used in the following Hello-World program. The program prints out some informationabout 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>intmain() {// 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 the underlying 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 1if (comm_world.size() >=2) {if (comm_world.rank() ==0) {      std::string message{"Hello world!"};      comm_world.send(message,1);// send message to rank 1    }elseif (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 thedocumentation, the blog posts

the presentation

the book

and the files in theexamples directory of the source package.


[8]ページ先頭

©2009-2025 Movatter.jp