⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 node68.html

📁 Design and building parallel program
💻 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>6.1 FM Introduction</TITLE>
</HEAD>
<BODY>
<meta name="description" value="6.1 FM Introduction">
<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=tex2html2763 HREF="node67.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node67.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=tex2html2771 HREF="node69.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node69.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=tex2html2769 HREF="node67.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node67.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=tex2html2773 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=tex2html2774 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=tex2html2772 HREF="node69.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node69.html">6.2 Concurrency</A>
<B>Up:</B> <A NAME=tex2html2770 HREF="node67.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node67.html">6 Fortran M</A>
<B> Previous:</B> <A NAME=tex2html2764 HREF="node67.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node67.html">6 Fortran M</A>
<BR><HR><P>
<H1><A NAME=SECTION03310000000000000000>6.1 FM Introduction</A></H1>
<P>
Fortran M provides language constructs for creating tasks and
channels and for sending and receiving messages.  It ensures that
programs are deterministic if specialized constructs are not used, and
it provides the encapsulation properties needed for modular programming.
Its mapping constructs affect performance but not correctness,
thereby allowing mapping decisions to be modified without changing other
aspects of a design.  These features make it particularly easy to
translate algorithms designed using the techniques of Part I into
executable FM programs.
<P>
<A NAME=8647>&#160;</A>
FM is a small set of <em> extensions
 </em> to Fortran.  Thus, any
valid Fortran program is also a valid FM program.  (There is one
exception to this rule: the keyword <tt> COMMON</tt> must be renamed to
<tt> PROCESS COMMON</tt>.  However, FM compilers usually provide a flag
that causes this renaming to be performed automatically.)  The
extensions are modeled whenever possible on existing Fortran concepts.
Hence, tasks are defined in the same way as subroutines, communication
operations have a syntax similar to Fortran I/O statements, and
mapping is specified with respect to processor arrays.
<P>
The FM extensions are summarized in the following; detailed
descriptions are provided in subsequent sections.  In this chapter, FM
extensions (and defined parameters) are typeset in <tt> UPPER CASE</tt>,
and other program components in <tt> lower case</tt>.
<P>
<OL><LI>
A task is implemented as a process.  A process definition has the same
syntax as a subroutine, except that the keyword <tt> PROCESS</tt> is
substituted for the keyword <tt> subroutine</tt>.  Process common data are
global to any subroutines called by that process but are not shared
with other processes.
<P>
<LI>
Single-producer, single-consumer channels and
multiple-producer, single-consumer mergers are created with
the executable statements <tt> CHANNEL</tt> and <tt> MERGER</tt>,
respectively.  These statements take new datatypes, called <em>
inports
 </em> and <em> outports</em>, as arguments and define them to
be references to the newly created communication structure.
<P>
<LI>
Processes are created in <em> process blocks
 </em> and <em> process
do-loops</em>, and can be passed inports and outports as arguments.
<P>
<LI>
Statements are provided to <tt> SEND</tt> messages on outports, to <tt>
RECEIVE</tt> messages on inports, and to close an outport (<tt>
ENDCHANNEL</tt>).  Messages can include port variables, thereby allowing a
process to transfer to another process the right to send or receive
messages on a channel or merger.
<P>
<LI>
Mapping constructs can be used to specify that a program executes in a
virtual processor array of specified size and shape, to locate a
process within this processor array, or to specify that a process is
to execute in a subset of this processor array.
<P>
<LI> For convenience, processes can be passed ordinary variables as
arguments, as well as ports; these variables are copied on call and
return, so as to ensure deterministic execution.  Copying can be
suppressed to improve performance.
<P>
</OL>
<P>
<A NAME=8666>&#160;</A>
The FM language design emphasizes support for <em> modularity</em>.
<A NAME=8668>&#160;</A>
Program components can be combined using sequential, parallel, or
concurrent composition, as described in Chapter <A HREF="node39.html#chapmod" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node39.html#chapmod">4</A>.  In
parallel and concurrent composition, the process serves as the basic
building block.  A process can encapsulate data, computation,
concurrency, and communication; the ports and other variables passed
as arguments define its interface to the rest of the program.  The
techniques used to implement sequential composition will be discussed
in Section <A HREF="node76.html#secfmmod" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node76.html#secfmmod">6.9</A>.
<P>
FM extensions can be defined for both the simpler and more established
Fortran 77 and the more advanced Fortran 90.  For the most part, we
use Fortran 77 constructs in this chapter, except when Fortran 90
constructs are significantly more concise.
<P>
<BR><HR>
<b> Example <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img873.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img873.gif">.<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img871.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img871.gif">    Bridge Construction</b>:<A NAME=exfmbridge>&#160;</A>
<P>
Program <A HREF="node68.html#progfmbuild" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node68.html#progfmbuild">6.1</A> illustrates many FM features.  This is an
<A NAME=8674>&#160;</A>
implementation of the bridge construction algorithm developed in
<A NAME=8675>&#160;</A>
Example <A HREF="node9.html#exbridge" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node9.html#exbridge">1.1</A>.  The program creates two processes, <tt>
foundry</tt> and <tt> bridge</tt>, and connects them with a channel.  The
channel is used to communicate a stream of integer values <tt> 1..100</tt>
from <tt> foundry</tt> to <tt> bridge</tt>.
<P>
<P><A NAME=progfmbuild>&#160;</A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img872.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img872.gif"><P>
<P>
<A NAME=8712>&#160;</A>
<P>
This program comprises a main program and two process definitions.  The
main program creates a channel and instances of the processes <tt>
foundry</tt> and <tt> bridge</tt>.  It first declares two port variables, <tt>
pi</tt> and <tt> po</tt>, that can be used to receive and send integer
messages, respectively.  The <tt> CHANNEL</tt> statement creates a channel
and initializes <tt> pi</tt> and <tt> po</tt> to be references to this
channel.  The process block (<tt> PROCESSES</tt>/<tt> ENDPROCESSES</tt>)
creates the two concurrent processes, passing the port variables as
arguments.
<P>
The process definitions are distinguished by the <tt> PROCESS</tt>
keyword.  The <tt> foundry</tt> process uses the <tt> SEND</tt> statement to
add a sequence of messages to the message queue associated with the
channel referenced by <tt> po</tt>.  The <tt> ENDCHANNEL</tt> statement
terminates this sequence.  The <tt> bridge</tt> process uses the <tt>
RECEIVE</tt> statement to remove messages from this message queue until
termination is detected.
<P>
<BR><HR>
<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=tex2html2763 HREF="node67.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node67.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=tex2html2771 HREF="node69.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node69.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=tex2html2769 HREF="node67.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node67.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=tex2html2773 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=tex2html2774 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=tex2html2772 HREF="node69.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node69.html">6.2 Concurrency</A>
<B>Up:</B> <A NAME=tex2html2770 HREF="node67.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node67.html">6 Fortran M</A>
<B> Previous:</B> <A NAME=tex2html2764 HREF="node67.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node67.html">6 Fortran M</A>
<BR><HR><P>
<P><ADDRESS>
<I>&#169 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 + -