📄 node75.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.8 Mapping</TITLE>
</HEAD>
<BODY>
<meta name="description" value="6.8 Mapping">
<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=tex2html2847 HREF="node74.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node74.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=tex2html2855 HREF="node76.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node76.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=tex2html2853 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=tex2html2857 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=tex2html2858 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=tex2html2856 HREF="node76.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node76.html">6.9 Modularity</A>
<B>Up:</B> <A NAME=tex2html2854 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=tex2html2848 HREF="node74.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node74.html">6.7 Argument Passing</A>
<BR><HR><P>
<H1><A NAME=SECTION03380000000000000000>6.8 Mapping</A></H1>
<P>
<A NAME=9464> </A>
Process blocks and do-loops define concurrent processes; channels and
<A NAME=9465> </A>
mergers define how these processes communicate and synchronize. A
parallel program defined in terms of these constructs can be executed
on both uniprocessor and multiprocessor computers. In the latter
case, a complete program must also specify how processes are mapped to
processors. Recall from Chapter <A HREF="node14.html#chap2" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node14.html#chap2">2</A> that this is an
important part of parallel algorithm design.
<P>
FM provides three mapping constructs. The <tt> PROCESSORS</tt>
<A NAME=9468> </A>
declaration specifies the shape and dimension of a virtual processor
<A NAME=9469> </A>
array in which a program is assumed to execute, the <tt> LOCATION</tt>
<A NAME=9471> </A>
annotation maps processes to specified elements of this array, and the
<tt> SUBMACHINE</tt> annotation specifies that a process should execute in
a subset of the array. An important aspect of these constructs is
that they <em> influence performance but not correctness</em>. Hence, we
can develop a program on a uniprocessor and then tune performance on a
parallel computer by changing mapping constructs. This is consistent
with the PCAM design methodology discussed in Chapter <A HREF="node14.html#chap2" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node14.html#chap2">2</A>, in which
mapping is the fourth and final stage of the design process.
<P>
<H2><A NAME=SECTION03381000000000000000>6.8.1 Virtual Computers</A></H2>
<P>
<A NAME=secfmmap> </A>
<P>
FM's process placement constructs are based on the concept of a <em>
<A NAME=9477> </A>
virtual computer
</em>, a collection of virtual processors that may
<A NAME=9478> </A>
or may not have the same topology as the physical computer(s) on which
a program executes. For consistency with Fortran concepts, an FM
virtual computer is an <em> N</em>
-dimensional array, and the constructs
that control the placement of processes within this array are modeled
on Fortran's array manipulation constructs.
<P>
The <tt> PROCESSORS</tt> declaration is used to specify the shape and size
<A NAME=9481> </A>
of the (implicit) processor array on which a process executes. This
declaration is similar in form and function to the array <tt>
DIMENSION</tt> statement. It has the general form
<tt> PROCESSORS(I<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img901.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img901.gif">,...,I<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img902.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img902.gif">)</tt> ,
<P>
where <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img903.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img903.gif"> and the <tt> I<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img904.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img904.gif"></tt> have the same form as the arguments
to a <tt> DIMENSION</tt> statement. See Figure <A HREF="node75.html#figfmprocessor" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node75.html#figfmprocessor">6.7</A> for
some examples.
<P>
<P><A NAME=10397> </A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img905.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img905.gif">
<BR><STRONG>Figure 6.7:</STRONG> <em> Three different <tt> PROCESSORS</tt> configurations, all
involving 16 processors.</em><A NAME=figfmprocessor> </A><BR>
<P>
<P>
The <tt> PROCESSORS</tt> declaration in the main (top-level) program
specifies the shape and size of the virtual processor array on which
that program is to execute. The mapping of these virtual processors
to physical processors is specified at load time. This mapping may be
achieved in different ways on different computers. Usually, there is
a one-to-one mapping of virtual processors to physical processors.
However, it can sometimes be useful to have more virtual processors
than physical processors, for example, if a multicomputer program is
being developed on one processor. The mapping of virtual processors
to physical processors is not defined in FM, but is typically
specified using a configuration file or command line arguments.
<P>
A <tt> PROCESSORS</tt> declaration in a process definition specifies the
shape and size of the virtual processor array on which that particular
process is to execute. As with a regular array passed as an argument,
this processor array cannot be larger than that declared in its
parent, but it can be smaller or of a different shape.
<P>
<H2><A NAME=SECTION03382000000000000000>6.8.2 Process Placement</A></H2>
<P>
<A NAME=secfmlocn> </A>
<P>
The <tt> LOCATION</tt> annotation is similar in form and function to an
<A NAME=9498> </A>
array reference. It has the general form
<A NAME=9499> </A>
<tt> LOCATION(I<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img906.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img906.gif">, ..., I<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img907.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img907.gif">)</tt>
<P>
where <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img908.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img908.gif"> and the <tt> I<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img909.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img909.gif"></tt> have the same form as the
indices in an array reference, and specifies the processor on which
the annotated process is to execute. The indices must not reference a
processor array element that is outside the bounds specified by the
<tt> PROCESSORS</tt> declaration provided in the process or subroutine in
which the annotation occurs.
<P>
The following code fragment shows how the ring pipeline code of
Program <A HREF="node70.html#progfmring" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node70.html#progfmring">6.2</A> might be extended to specify process
placement. The <tt> PROCESSORS</tt> declaration indicates that this
program is to execute in a virtual computer with <tt> P</tt> processors,
while the <tt> LOCATION</tt> annotation placed on the process call
specifies that each <tt> ringnode</tt> process is to execute on a separate
virtual processor.
<P>
<PRE><TT>
<tt> program ring</tt> !
<P>
<tt> parameter(P=3)</tt> !
<P>
<tt> PROCESSORS(P)</tt> ! Three virtual processors
<P>
<tt> ...</tt> !
<P>
<tt> PROCESSDO i = 1,P</tt> ! Each process on a processor
<P>
<tt> PROCESSCALL ringnode(i, P, pi(i), po(i)) LOCATION(i)</tt>
<P>
<tt> ENDPROCESSDO</tt> !
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -