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

📄 node63.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>5.12 Case Study: Fock Matrix Construction</TITLE>
</HEAD>
<BODY>
<meta name="description" value="5.12 Case Study: Fock Matrix Construction">
<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=tex2html2691 HREF="node62.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node62.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=tex2html2699 HREF="node64.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node64.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=tex2html2697 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.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=tex2html2701 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=tex2html2702 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=tex2html2700 HREF="node64.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node64.html">5.13 Summary</A>
<B>Up:</B> <A NAME=tex2html2698 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.html">5 Compositional C++
 </A>
<B> Previous:</B> <A NAME=tex2html2692 HREF="node62.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node62.html">5.11 Case Study: Channel Library</A>
<BR><HR><P>
<H1><A NAME=SECTION032120000000000000000>5.12 Case Study: Fock Matrix Construction</A></H1>
<P>
<A NAME=secccfock>&#160;</A>
<P>
<A NAME=7739>&#160;</A>
Our second case study illustrates the use of RPCs to implement
<A NAME=7740>&#160;</A>
asynchronous access to a distributed data structure.
<A NAME=7741>&#160;</A>
Programs <A HREF="node63.html#progccda" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node63.html#progccda">5.16</A> and <A HREF="node63.html#progccfock2a" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node63.html#progccfock2a">5.17</A> sketch a
<A NAME=7744>&#160;</A>
CC++
  implementation of the parallel Fock matrix construction algorithm of
<A NAME=7745>&#160;</A>
Section <A HREF="node22.html#secchem" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node22.html#secchem">2.8</A>.  Recall that in this algorithm,
<em> P</em>
 computation tasks must be able to read and write distributed arrays.
The programs presented here achieve this capability by distributing
the arrays over a set of processor objects.  Computation threads,
created one per processor object, operate on the distributed array by
invoking RPCs implementing operations such as accumulate and read.
<P>
The distributed array itself is implemented by the class <tt> Fock</tt>
and the processor object class <tt> FockNode</tt>, presented in
Program <A HREF="node63.html#progccda" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node63.html#progccda">5.16</A>.  These are derived from the classes <tt>
POArray</tt> and <tt> POArrayNode</tt> of Program <A HREF="node59.html#progccpo" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node59.html#progccpo">5.10</A>, much as in
the climate model of Program <A HREF="node59.html#progccoa" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node59.html#progccoa">5.11</A>, and provide definitions
for the virtual functions <tt> create_pobj</tt> and <tt> init_pobj</tt>.
The derived classes defined in Program <A HREF="node63.html#progccda" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node63.html#progccda">5.16</A> are used to
create the array of processor objects within which computation will
occur.  The data structures that implement the distributed array are
allocated within these same processor objects, with each of the <tt>
posize</tt> processor objects being assigned <tt> blocksize</tt> array
elements.  Notice how the initialization function for <tt> FockNode</tt>
allocates and initializes the elements of the distributed array.
<P>
<P><A NAME=progccda>&#160;</A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img866.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img866.gif"><P>
<P>
For brevity, Program <A HREF="node63.html#progccda" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node63.html#progccda">5.16</A> implements only an <tt>
accumulate</tt> operation.  This function is defined in
Program <A HREF="node63.html#progccfock2a" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node63.html#progccfock2a">5.17</A>.  Notice how it issues an RPC to a remote
processor object (number <tt> index/blocksize</tt>) requesting an
operation on a specified sequence of values.  The function invoked by
the RPC (<tt> accum_local</tt>) is an atomic function; this ensures that
two concurrent accumulate operations do not produce meaningless
results.
<P>
Having defined the classes <tt> Fock</tt> and <tt> FockNode</tt>, the
implementation of the rest of the ccode is fairly straightforward.
We first create and initialize <em> P</em>
 processor objects of type <tt>
FockNode</tt>, as follows.
<P>
<PRE>Fock darray(1024);     // 1024 is block size
darray.init(P, nodes); // P and nodes as usual
</PRE>
<P>
Then, we invoke on each processor object a task (<tt> fock_build</tt>)
responsible for performing one component of the Fock matrix
computation.  Each such task makes repeated calls to <tt> accumulate</tt>
to place the results of its computation into the distributed array.
<P>
<P><A NAME=progccfock2a>&#160;</A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img867.gif" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/img867.gif"><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=tex2html2691 HREF="node62.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node62.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=tex2html2699 HREF="node64.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node64.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=tex2html2697 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.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=tex2html2701 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=tex2html2702 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=tex2html2700 HREF="node64.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node64.html">5.13 Summary</A>
<B>Up:</B> <A NAME=tex2html2698 HREF="node51.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node51.html">5 Compositional C++
 </A>
<B> Previous:</B> <A NAME=tex2html2692 HREF="node62.html" tppabs="http://www.dit.hcmut.edu.vn/books/system/par_anl/node62.html">5.11 Case Study: Channel Library</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 + -