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

📄 node85.html

📁 Design and building parallel program
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<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>7.3 Data Distribution</TITLE>
</HEAD>
<BODY>
<meta name="description" value="7.3 Data Distribution">
<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=tex2html2976 HREF="node84.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node84.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=tex2html2984 HREF="node86.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node86.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=tex2html2982 HREF="node82.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node82.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=tex2html2986 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=tex2html2987 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=tex2html2985 HREF="node86.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node86.html">7.4 Concurrency</A>
<B>Up:</B> <A NAME=tex2html2983 HREF="node82.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node82.html">7 High Performance Fortran</A>
<B> Previous:</B> <A NAME=tex2html2977 HREF="node84.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node84.html">7.2 Fortran 90</A>
<BR><HR><P>
<H1><A NAME=SECTION03430000000000000000>7.3 Data Distribution</A></H1>
<P>
<A NAME=10860>&#160;</A>
Array expressions specify concurrency but not
<A NAME=10861>&#160;</A>
locality.  That is, they specify opportunities for parallel execution
<A NAME=10862>&#160;</A>
but not how these opportunities should be exploited so as to minimize
communication costs on a parallel computer.  HPF introduces <em> data
distribution directives
 </em> to provide the programmer with control
over locality.  These directives work as follows.  The
<A NAME=10864>&#160;</A>
<tt> PROCESSORS</tt> directive is used to specify the shape and size of an
array of abstract processors.  The <tt> ALIGN</tt> directive is used
<A NAME=10867>&#160;</A>
to align elements of different arrays with each other,
indicating that they should be distributed in the same manner.  The
<A NAME=10868>&#160;</A>
<tt> DISTRIBUTE</tt> directive is used to distribute an object (and any
other objects that may be aligned with it) onto an abstract processor
array.  The mapping of abstract processors to physical processors is
implementation dependent and is not specified in the language.  The
three directives are summarized in Figure <A HREF="node85.html#fighpfdist" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node85.html#fighpfdist">7.4</A>.
<P>
Figure <A HREF="node85.html#fighpf" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node85.html#fighpf">7.5</A> illustrates the use of <tt> ALIGN</tt> and <tt>
DISTRIBUTE</tt>.  The two-phase mapping strategy reduces the number of
changes needed to move from one machine to another.  A different
machine may necessitate a different partitioning strategy but is less
likely to require changes to array alignments.
<P>
<P><A NAME=11751>&#160;</A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img951.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img951.gif">
<BR><STRONG>Figure 7.4:</STRONG>  HPF data distribution directives.
<A NAME=fighpfdist>&#160;</A><BR>
<P>
<P>
<P><A NAME=11879>&#160;</A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img952.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img952.gif">
<BR><STRONG>Figure 7.5:</STRONG> <em> HPF data allocation model.  The mapping of data to abstract
processors is performed in two phases: <tt> ALIGN</tt> is used to create a
relationship between objects and <tt> DISTRIBUTE</tt> is used to partition
onto processors both a specified object and any objects that are
aligned with it.</em><A NAME=fighpf>&#160;</A><BR>
<P>
<P>
Data distribution directives can have a major impact on a program's
<A NAME=10901>&#160;</A>
performance but <em> do not affect the result computed.</em> In this sense,
they are similar to FM mapping annotations. However, they have
a more profound effect on program structure: they affect partitioning,
agglomeration, and communication as well as mapping.  As in FM,
this orthogonality makes it possible to experiment with alternative
parallel algorithms simply by changing directives.
<P>
Data distribution directives are <em> recommendations
 </em> to an HPF
compiler, not instructions.  The compiler does not have to obey them
if, for example, it determines that performance can be improved by
ignoring them.
<P>
<H2><A NAME=SECTION03431000000000000000>7.3.1 Processors</A></H2>
<P>
<A NAME=secprocessors>&#160;</A>
<P>
<A NAME=10906>&#160;</A>
A <tt> PROCESSORS</tt> directive declares a named arrangement of abstract
<A NAME=10908>&#160;</A>
processors.  For example, both of the following statements declare 32
<A NAME=10909>&#160;</A>
abstract processors.
<P>
<PRE><TT> 
		<tt> !HPF$</tt> 		 <tt> PROCESSORS P(32)</tt>
<P>
		<tt> !HPF$</tt> 		 <tt> PROCESSORS Q(4,8)</tt>
<P>
</TT></PRE>
<P>
Normally, one abstract processor is created for each physical
processor, although an implementation could in principle use a smaller
number of physical processors to implement the abstract processors.
The mapping of abstract processors to physical processors is not
specified in HPF and can vary according to the implementation.
<P>
<H2><A NAME=SECTION03432000000000000000>7.3.2 Alignment</A></H2>
<P>
<A NAME=secalign>&#160;</A>
<P>
<A NAME=10918>&#160;</A>
The <tt> ALIGN</tt> directive is used to specify array elements that
<A NAME=10920>&#160;</A>
should, if possible, be <em> collocated
 </em>---mapped to the same
<A NAME=10922>&#160;</A>
processor.  Operations between aligned data objects are likely to be
more efficient than operations between objects that are not known to
be aligned.  An alignment directive has the general form
<P>
<PRE>        !HPF$   ALIGN  array  WITH  target
</PRE>
which indicates that the specified <tt> array</tt> should be aligned with
<tt> target</tt>.  A list of subscripts associated with the array and
target control the alignment, For example, the following code
specifies a simple alignment of arrays <tt> B</tt> and <tt> C</tt> in which
each <tt> B(i)</tt> is aligned with the corresponding <tt> C(i)</tt>.
<P>
<PRE><TT> 
				                <tt> real B(50), C(50)</tt>
<P>
		  <tt> !HPF$</tt> 		 <tt> ALIGN C(:) WITH B(:)</tt>
<P>
</TT></PRE>
<P>
<P><A NAME=11895>&#160;</A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img953.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img953.gif">
<BR><STRONG>Figure 7.6:</STRONG> <em> Six examples of the HPF <tt> ALIGN</tt> statement, with arrows
and shading used to associate representative aligned components in the
two arrays being aligned. (a) A simple alignment of two
one-dimensional arrays. (b) Alignment with an offset. (c) An alignment
of a smaller array onto a larger.  (d) Alignment with indices inverted
(transpose). (e) Collapsing a dimension: aligning a two-dimensional
array with a one-dimensional array. (f) Replicating data: aligning a
one-dimensional array with a two-dimensional
array.</em><A NAME=fighpfalign>&#160;</A><BR>
<P>
<P>
<A NAME=10938>&#160;</A>
Dummy arguments can be used in <tt> ALIGN</tt> directives to name
dimensions, integer expressions can be used to specify offsets, and
<tt> *</tt> can be used to collapse dimensions.  See
Figure <A HREF="node85.html#fighpfalign" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node85.html#fighpfalign">7.6</A> for examples of the alignments that can be
specified using these mechanisms.  Notice that an <tt> ALIGN</tt>
statement can be used to specify that elements of an array should be
replicated over processors.  This can improve efficiency if the array
is read more often than it is written.  For example, assume that the
two-dimensional array <tt> Y(N,N)</tt> is to be distributed by columns so
that each processor performs computation on one or more columns.  If
the computation performed at a single processor requires data from a
one-dimensional array <tt> X(N)</tt> that is not updated during a
computation, replicating <tt> X</tt> may be useful.  This is accomplished
by the following alignment directive
<P>
<PRE>        !HPF$   ALIGN X(*) WITH Y(*,j)
</PRE>
<P>
Care must be taken not to replicate arrays that are frequently
updated, as considerable communication and/or redundant computation
can result.
<P>
<H2><A NAME=SECTION03433000000000000000>7.3.3 Distribution</A></H2>
<P>
<A NAME=secdistribute>&#160;</A>
<P>
<A NAME=10948>&#160;</A>
A <tt> DISTRIBUTE</tt>
<A NAME=10950>&#160;</A>
directive is used to indicate how data are to be
<A NAME=10951>&#160;</A>
partitioned among computer memories.  It specifies, for each dimension

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -