📄 node95.html
字号:
<html><!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 95.1 (Fri Jan 20 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE>8.1 The MPI Programming Model</TITLE>
</HEAD>
<BODY>
<meta name="description" value="8.1 The MPI Programming Model">
<meta name="keywords" value="book">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<BR> <HR><a href="msgs0.htm#2" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#2"><img ALIGN=MIDDLE src="asm_color_tiny.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/asm_color_tiny.gif" alt="[DBPP]"></a> <A NAME=tex2html3105 HREF="node94.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node94.html"><IMG ALIGN=MIDDLE ALT="previous" SRC="previous_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/previous_motif.gif"></A> <A NAME=tex2html3113 HREF="node96.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node96.html"><IMG ALIGN=MIDDLE ALT="next" SRC="next_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/next_motif.gif"></A> <A NAME=tex2html3111 HREF="node94.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node94.html"><IMG ALIGN=MIDDLE ALT="up" SRC="up_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/up_motif.gif"></A> <A NAME=tex2html3115 HREF="node1.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node1.html"><IMG ALIGN=MIDDLE ALT="contents" SRC="contents_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/contents_motif.gif"></A> <A NAME=tex2html3116 HREF="node133.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node133.html"><IMG ALIGN=MIDDLE ALT="index" SRC="index_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/index_motif.gif"></A> <a href="msgs0.htm#3" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#3"><img ALIGN=MIDDLE src="search_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/search_motif.gif" alt="[Search]"></a> <BR>
<B> Next:</B> <A NAME=tex2html3114 HREF="node96.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node96.html">8.2 MPI Basics</A>
<B>Up:</B> <A NAME=tex2html3112 HREF="node94.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node94.html">8 Message Passing Interface</A>
<B> Previous:</B> <A NAME=tex2html3106 HREF="node94.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node94.html">8 Message Passing Interface</A>
<BR><HR><P>
<H1><A NAME=SECTION03510000000000000000>8.1 The MPI Programming Model</A></H1>
<P>
<A NAME=12188> </A>
<P>
<A NAME=12189> </A>
In the MPI programming model, a computation comprises one or more
<A NAME=12190> </A>
processes that communicate by calling library routines to send
<A NAME=12191> </A>
and receive messages to other processes. In most MPI implementations,
<A NAME=12192> </A>
a fixed set of processes is created at program initialization, and one
process is created per processor. However, these processes may
execute different programs. Hence, the MPI programming model is
sometimes referred to as <em> multiple program multiple data
</em>
(MPMD) to distinguish it from the SPMD model in which every processor
<A NAME=12194> </A>
executes the same program.
<P>
Because the number of processes in an MPI computation is normally fixed,
<A NAME=12195> </A>
our focus in this chapter is on the mechanisms used to communicate
<A NAME=12196> </A>
data between processes. Processes can use <em> point-to-point
</em>
communication operations to send a message from one named process to
another; these operations can be used to implement local and
unstructured communications. A group of processes can call <em>
collective
</em> communication operations to perform commonly used
<A NAME=12199> </A>
global operations such as summation and broadcast. MPI's ability to
<em> probe
</em> for messages supports asynchronous communication.
Probably MPI's most important feature from a software engineering
viewpoint is its support for modular programming. A mechanism called
a <em> communicator
</em> allows the MPI programmer to define modules
that encapsulate internal communication structures. In the
terminology used in Chapter <A HREF="node39.html#chapmod" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node39.html#chapmod">4</A>, these modules can be
combined by both sequential and parallel composition.
<P>
Most parallel algorithms designed using the techniques of Part I are
readily implemented using MPI. Algorithms that create just one task
per processor can be implemented directly, with point-to-point or
collective communication routines used to meet communication
requirements. Algorithms that create tasks in a dynamic fashion or
that rely on the concurrent execution of several tasks on a processor
must be further refined to permit an MPI implementation. For example,
consider the first branch-and-bound search algorithm
<A NAME=12203> </A>
developed in Section <A HREF="node21.html#secfloor" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node21.html#secfloor">2.7</A>, which creates a tree of
``search'' tasks dynamically. This algorithm cannot be implemented
directly in MPI; however, as discussed in Chapter <A HREF="node14.html#chap2" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node14.html#chap2">2</A>, it can
be refined to obtain an algorithm that creates a fixed set of worker
processes that exchange messages representing tree nodes to be
searched. The resulting SPMD algorithm can be implemented as an MPI
program. Algorithms that are not easily modified in this way are
better implemented using alternative technologies.
<P>
<BR> <HR><a href="msgs0.htm#2" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#2"><img ALIGN=MIDDLE src="asm_color_tiny.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/asm_color_tiny.gif" alt="[DBPP]"></a> <A NAME=tex2html3105 HREF="node94.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node94.html"><IMG ALIGN=MIDDLE ALT="previous" SRC="previous_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/previous_motif.gif"></A> <A NAME=tex2html3113 HREF="node96.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node96.html"><IMG ALIGN=MIDDLE ALT="next" SRC="next_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/next_motif.gif"></A> <A NAME=tex2html3111 HREF="node94.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node94.html"><IMG ALIGN=MIDDLE ALT="up" SRC="up_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/up_motif.gif"></A> <A NAME=tex2html3115 HREF="node1.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node1.html"><IMG ALIGN=MIDDLE ALT="contents" SRC="contents_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/contents_motif.gif"></A> <A NAME=tex2html3116 HREF="node133.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node133.html"><IMG ALIGN=MIDDLE ALT="index" SRC="index_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/index_motif.gif"></A> <a href="msgs0.htm#3" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#3"><img ALIGN=MIDDLE src="search_motif.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/search_motif.gif" alt="[Search]"></a> <BR>
<B> Next:</B> <A NAME=tex2html3114 HREF="node96.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node96.html">8.2 MPI Basics</A>
<B>Up:</B> <A NAME=tex2html3112 HREF="node94.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node94.html">8 Message Passing Interface</A>
<B> Previous:</B> <A NAME=tex2html3106 HREF="node94.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node94.html">8 Message Passing Interface</A>
<BR><HR><P>
<P><ADDRESS>
<I>© Copyright 1995 by <A href="msgs0.htm#6" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/tppmsgs/msgs0.htm#6">Ian Foster</a></I>
</ADDRESS>
</BODY>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -