📄 node100.html
字号:
<em> i</em>
+4, ..., <em> i</em>
+20. As these elements are not stored in
contiguous locations, a call to <tt> MPI_TYPE_VECTOR</tt> is used to
define the appropriate type, <tt> rowtype</tt>.
<P>
Program <A HREF="node100.html#progmpfd" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node100.html#progmpfd">8.8</A> frees the derived types that it defines
immediately after they are used. In practice, a type might be reused
many times before being freed.
<P>
<BR><HR>
<P>
<P><A NAME=progmpfd> </A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img1041.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img1041.gif"><P>
<P>
<P><A NAME=14199> </A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img1044.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img1044.gif">
<BR><STRONG>Figure 8.13:</STRONG> <em> A <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img1043.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img1043.gif"> finite difference grid. Areas to be sent
to west, east, north, and south neighbors are
highlighted.</em><A NAME=figbounds> </A><BR>
<P>
<P>
The third constructor, <tt> MPI_TYPE_INDEXED</tt>, is used to define a
type comprising one or more blocks of a primitive or
<A NAME=13330> </A>
previously defined datatype, where block lengths and the
displacements between blocks are specified in arrays. A call of the
form
<P>
<tt> MPI_TYPE_INDEXED(count, lengths, indices, oldtype, newtype)</tt>
<P>
defines a derived type <tt> newtype</tt> comprising <tt> count</tt>
consecutive blocks of data elements with datatype <tt> oldtype</tt>, with
block <em> i</em>
having a displacement of <tt> indices(<em> i</em>
)</tt> data
elements and containing <tt> lengths(<em> i</em>
)</tt> data elements.
<P>
<BR><HR>
<b> Example <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img1046.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img1046.gif">.<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img1045.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img1045.gif"> Fock Matrix Problem</b>:<A NAME=exfff> </A>
<P>
In Example <A HREF="node98.html#exmpfock1" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node98.html#exmpfock1">8.4</A> and Program <A HREF="node98.html#progmpfock" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node98.html#progmpfock">8.6</A>, we
<A NAME=13344> </A>
developed an implementation for a Fock matrix task that receives read
<A NAME=13345> </A>
requests containing the address of a single data value. A more
realistic program might support messages comprising <tt> len/2</tt>
indices followed by <tt> len/2</tt> block lengths. The <tt>
MPI_TYPE_INDEXED</tt> constructor can then be used to return the
required values, as follows.
<P>
<PRE> call MPI_TYPE_INDEXED(len/2, inbuf(len/2+1), inbuf(1),
$ MPI_INTEGER, focktype, ierr)
call MPI_TYPE_COMMIT(focktype, ierr);
call MPI_SEND(data, 1, focktype, source, MPI_COMM_WORLD,
ierr)
call MPI_TYPE_FREE(focktype, ierr)
</PRE>
<P>
An alternative approach that does not use the constructor is to
accumulate the values that are to be returned in a buffer. The
relative efficiency of the two approaches depends on several factors,
including the amount of data to be transferred and the capabilities of
the computer used to execute the program.
<P>
<BR><HR>
<P>
<H2><A NAME=SECTION03562000000000000000>8.6.2 MPI Features Not Covered</A></H2>
<P>
For simplicity, we have focused on a subset of MPI in this chapter.
Of necessity, numerous subtleties have been omitted in this brief
description. Also, the following MPI features have not been
covered.
<P>
<OL><LI>
<em> Heterogeneous types</em>. Different datatypes can be encapsulated
in a single derived type, thereby allowing communication of heterogeneous
messages. In addition, data can be sent in ``raw'' format, without
<A NAME=13353> </A>
data conversion in heterogeneous networks.
<P>
<LI>
<A NAME=13354> </A>
<A NAME=13355> </A>
<em> Environmental inquiry.</em> A program can obtain information about
the environment in which it is running, including information that can
be used to tune algorithm performance.
<P>
<LI>
<em> Additional global operations</em>. These operations support
all-to-all communication and variable-sized contributions from
different processes. Additional reduction operations can be used to
determine the location of minimum and maximum values and to perform
reductions with user-defined functions.
<P>
<LI>
<A NAME=13358> </A>
<em> Specialized communication modes.</em> These modes include
<A NAME=13360> </A>
synchronous communication, which causes the sender to block until the
corresponding receive operation has begun; buffered communication,
which allows the programmer to allocate buffers so as to ensure that
system resources are not exhausted during communications; and
<A NAME=13361> </A>
nonblocking communication, which can be more efficient on
computers that allow user computation to be overlapped with some of
the sending of a message.
<P>
</OL>
<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=tex2html3165 HREF="node99.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node99.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=tex2html3173 HREF="node101.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node101.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=tex2html3171 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=tex2html3175 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=tex2html3176 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=tex2html3174 HREF="node101.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node101.html">8.7 Performance Issues</A>
<B>Up:</B> <A NAME=tex2html3172 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=tex2html3166 HREF="node99.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node99.html">8.5 Modularity</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 + -