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

📄 node75.html

📁 Design and building parallel program
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<P>
</TT></PRE>

<P>
<H2><A NAME=SECTION03383000000000000000>6.8.3 Submachines</A></H2>
<P>
<A NAME=secfmsubm>&#160;</A>
<P>
A <tt> SUBMACHINE</tt> annotation is similar in form and function to an
array section passed as an argument to a subroutine.  It has the
general form
<A NAME=9522>&#160;</A>
<tt> SUBMACHINE(I<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img910.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img910.gif">, ..., I<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img911.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img911.gif">)</tt>
<P>
where <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img912.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img912.gif"> and the arguments <tt> I<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img913.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img913.gif"></tt> have the same form as an
array section and denote a set of processors in the current virtual
computer.  The annotated process executes in a new virtual computer
comprising just these virtual processors.  The <tt> PROCESSORS</tt>
declaration in the process definition should agree in size and shape.
<P>
The <tt> SUBMACHINE</tt> annotation allows us to create ``subcomputers,''
<A NAME=9529>&#160;</A>
each comprising a subset of available processors, and hence to control
resource allocation in programs comprising multiple components.
<P>
<BR><HR>
<b> Example <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img916.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img916.gif">.<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img914.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img914.gif">    Coupled Climate Model</b>:<A NAME=exccmx>&#160;</A>
<P>
<A NAME=9532>&#160;</A>
A coupled climate modeling system comprising an ocean model and an
atmosphere model can be structured as a <em> parallel
<A NAME=9533>&#160;</A>
composition
 </em> of the two component models.  This organization is
illustrated in Figure <A HREF="node75.html#figmap" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node75.html#figmap">6.8</A>(a) and can be specified as
follows.
<P>

<PRE>    parameter(P=4)
    PROCESSORS(P,2*P)
    ...
    PROCESSES
       PROCESSCALL atmosphere(...) SUBMACHINE(1:P, 1:P)
       PROCESSCALL ocean(...)      SUBMACHINE(1:P, P+1:2*P)
    ENDPROCESSES
</PRE>

<P>
The <tt> ocean</tt> and <tt> atmosphere</tt> processes are invoked in disjoint
virtual computers of size <tt> P</tt> <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img915.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img915.gif"> <tt> P</tt>; hence, both
process definitions should incorporate a declaration <tt>
PROCESSORS(P,P)</tt>.  In some situations, it may be more efficient to
structure the coupled model as a <em> concurrent composition
 </em> of
<A NAME=9542>&#160;</A>
the two components, as illustrated in Figure <A HREF="node75.html#figmap" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node75.html#figmap">6.8</A> (b).  This
effect can be achieved
<A NAME=9544>&#160;</A>
by changing the <tt> PROCESSORS</tt> declaration to <tt> PROCESSORS(P,P)</tt>
and omitting the <tt> SUBMACHINE</tt> annotations.  No change to the
component programs is required.
<P>
<BR><HR>
<P>
<P><A NAME=10421>&#160;</A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img919.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img919.gif">
<BR><STRONG>Figure 6.8:</STRONG> <em> Alternative mapping strategies in climate model.  In (a),
the two components are mapped to disjoint sets of <IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img918.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img918.gif">
processors.  In (b), they are mapped to the same
processors.</em><A NAME=figmap>&#160;</A><BR>
<P>
<P>
<BR><HR>
<b> Example <IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img922.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img922.gif">.<IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img920.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img920.gif">    Search</b>:<A NAME=exsearchy>&#160;</A>
<P>
The following code fragment shows how virtual computers and the <tt>
<A NAME=9554>&#160;</A>
SUBMACHINE</tt> annotation can be used to control mapping in
<A NAME=9555>&#160;</A>
Program <A HREF="node70.html#progfmtree" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node70.html#progfmtree">6.3</A>.
<PRE><TT> 
		<tt> PROCESS tree(id, n, toparent)</tt>
<P>
		<tt> PROCESSORS(n)</tt>               						 ! Size of my computer
<P>
		<tt> ...</tt>
<P>
		<tt> PROCESSES</tt>                   						 ! 		 Create children
<P>
				<tt> PROCESSCALL tree(id, n/2, lo) SUBMACHINE(1:n/2)</tt>
<P>
				<tt> PROCESSCALL tree(id+n/2, n/2, ro) SUBMACHINE(1+n/2:n)</tt>
<P>
				<tt> call nonleaf(id, li, ri, toparent)</tt>
<P>
		<tt> ENDPROCESSES</tt>
<P>
</TT></PRE>
<P>
Recall that Program <A HREF="node70.html#progfmtree" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node70.html#progfmtree">6.3</A> creates a set of
<em> 2n-1</em>
 (<em> n</em>
 a power of 2) processes connected in a binary tree of depth
<IMG BORDER=0 ALIGN=MIDDLE ALT="" SRC="img921.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img921.gif">.  As illustrated in Figure <A HREF="node75.html#figfmtree" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node75.html#figfmtree">6.9</A>, mapping can be
achieved by using <tt> SUBMACHINE</tt> annotations to place processes
located at the same depth in the tree on different processors
(assuming that at least <em> n</em>
 processors are available).
<P>
<BR><HR>
<P>
<A NAME=9573>&#160;</A>
<P>
<P><A NAME=10449>&#160;</A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img923.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img923.gif">
<BR><STRONG>Figure 6.9:</STRONG> <em> Using submachines to control mapping in a tree-based algorithm
executing on four processors.  The figures shows both the nodes in the
process tree (circles) and the virtual computer in which each process
executes (the shaded portion of the original four-processor virtual
<A NAME=10444>&#160;</A>
computer).</em><A NAME=figfmtree>&#160;</A><BR>
<P>
<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>
<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 + -