Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 247b28499c443e092731ffba814075f2 > files > 1216

mpqc-html-2.3.1-9mdv2010.0.i586.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>MPQC: memory.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
    </ul>
  </div>
<h1>memory.h</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">//</span>
<a name="l00002"></a>00002 <span class="comment">// memory.h</span>
<a name="l00003"></a>00003 <span class="comment">//</span>
<a name="l00004"></a>00004 <span class="comment">// Copyright (C) 1996 Limit Point Systems, Inc.</span>
<a name="l00005"></a>00005 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment">// Author: Curtis Janssen &lt;cljanss@limitpt.com&gt;</span>
<a name="l00007"></a>00007 <span class="comment">// Maintainer: LPS</span>
<a name="l00008"></a>00008 <span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// This file is part of the SC Toolkit.</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">// The SC Toolkit is free software; you can redistribute it and/or modify</span>
<a name="l00012"></a>00012 <span class="comment">// it under the terms of the GNU Library General Public License as published by</span>
<a name="l00013"></a>00013 <span class="comment">// the Free Software Foundation; either version 2, or (at your option)</span>
<a name="l00014"></a>00014 <span class="comment">// any later version.</span>
<a name="l00015"></a>00015 <span class="comment">//</span>
<a name="l00016"></a>00016 <span class="comment">// The SC Toolkit is distributed in the hope that it will be useful,</span>
<a name="l00017"></a>00017 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00018"></a>00018 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00019"></a>00019 <span class="comment">// GNU Library General Public License for more details.</span>
<a name="l00020"></a>00020 <span class="comment">//</span>
<a name="l00021"></a>00021 <span class="comment">// You should have received a copy of the GNU Library General Public License</span>
<a name="l00022"></a>00022 <span class="comment">// along with the SC Toolkit; see the file COPYING.LIB.  If not, write to</span>
<a name="l00023"></a>00023 <span class="comment">// the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.</span>
<a name="l00024"></a>00024 <span class="comment">//</span>
<a name="l00025"></a>00025 <span class="comment">// The U.S. Government is granted a limited license as per AL 91-7.</span>
<a name="l00026"></a>00026 <span class="comment">//</span>
<a name="l00027"></a>00027 
<a name="l00028"></a>00028 <span class="preprocessor">#ifdef __GNUC__</span>
<a name="l00029"></a>00029 <span class="preprocessor"></span><span class="preprocessor">#pragma interface</span>
<a name="l00030"></a>00030 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>
<a name="l00032"></a>00032 <span class="preprocessor">#ifndef _util_group_memory_h</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#define _util_group_memory_h</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00035"></a>00035 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00036"></a>00036 
<a name="l00037"></a>00037 <span class="preprocessor">#include &lt;scconfig.h&gt;</span>
<a name="l00038"></a>00038 <span class="preprocessor">#include &lt;util/class/class.h&gt;</span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;util/group/thread.h&gt;</span>
<a name="l00040"></a>00040 
<a name="l00041"></a>00041 <span class="keyword">namespace </span>sc {
<a name="l00042"></a>00042 
<a name="l00043"></a>00043 <span class="preprocessor">#if 0 // this can be used to catch accidental conversions to int</span>
<a name="l00044"></a>00044 <span class="preprocessor"></span><span class="keyword">class </span>distsize_t {
<a name="l00045"></a>00045     <span class="keyword">friend</span> <span class="keywordtype">size_t</span> distsize_to_size(<span class="keyword">const</span> distsize_t &amp;a);
<a name="l00046"></a>00046     <span class="keyword">friend</span> distsize_t operator *(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> distsize_t &amp;b);
<a name="l00047"></a>00047     <span class="keyword">friend</span> distsize_t operator +(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> distsize_t &amp;b);
<a name="l00048"></a>00048     <span class="keyword">friend</span> distsize_t operator -(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> distsize_t &amp;b);
<a name="l00049"></a>00049     <span class="keyword">friend</span> distsize_t operator /(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> distsize_t &amp;b);
<a name="l00050"></a>00050     <span class="keyword">friend</span> distsize_t operator %(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> distsize_t &amp;b);
<a name="l00051"></a>00051     <span class="keyword">friend</span> ostream&amp; operator &lt;&lt;(ostream&amp; o, <span class="keyword">const</span> distsize_t &amp;s);
<a name="l00052"></a>00052   <span class="keyword">private</span>:
<a name="l00053"></a>00053     <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> s;
<a name="l00054"></a>00054   <span class="keyword">public</span>:
<a name="l00055"></a>00055     distsize_t(): s(999999999999999LL) {}
<a name="l00056"></a>00056     distsize_t(<span class="keywordtype">int</span> a): s(a) {}
<a name="l00057"></a>00057     distsize_t(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> a): s(a) {}
<a name="l00058"></a>00058     distsize_t(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> a): s(a) {}
<a name="l00059"></a>00059     distsize_t &amp;operator =(<span class="keyword">const</span> distsize_t &amp;a)
<a name="l00060"></a>00060         { s=a.s; <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
<a name="l00061"></a>00061     distsize_t &amp;operator +=(<span class="keyword">const</span> distsize_t &amp;a)
<a name="l00062"></a>00062         { s+=a.s; <span class="keywordflow">return</span> *<span class="keyword">this</span>; }
<a name="l00063"></a>00063     distsize_t operator *(<span class="keyword">const</span> distsize_t &amp;a)<span class="keyword"> const</span>
<a name="l00064"></a>00064 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s*a.s; }
<a name="l00065"></a>00065     distsize_t operator +(<span class="keyword">const</span> distsize_t &amp;a)<span class="keyword"> const</span>
<a name="l00066"></a>00066 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s+a.s; }
<a name="l00067"></a>00067     distsize_t operator -(<span class="keyword">const</span> distsize_t &amp;a)<span class="keyword"> const</span>
<a name="l00068"></a>00068 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s-a.s; }
<a name="l00069"></a>00069     distsize_t operator /(<span class="keyword">const</span> distsize_t &amp;a)<span class="keyword"> const</span>
<a name="l00070"></a>00070 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s/a.s; }
<a name="l00071"></a>00071     distsize_t operator %(<span class="keyword">const</span> distsize_t &amp;a)<span class="keyword"> const</span>
<a name="l00072"></a>00072 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s%a.s; }
<a name="l00073"></a>00073     <span class="keywordtype">bool</span> operator &lt;(<span class="keyword">const</span> distsize_t &amp;a)<span class="keyword"> const</span>
<a name="l00074"></a>00074 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s&lt;a.s; }
<a name="l00075"></a>00075     <span class="keywordtype">bool</span> operator &lt;=(<span class="keyword">const</span> distsize_t &amp;a)<span class="keyword"> const</span>
<a name="l00076"></a>00076 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s&lt;=a.s; }
<a name="l00077"></a>00077     <span class="keywordtype">bool</span> operator &gt;(<span class="keyword">const</span> distsize_t &amp;a)<span class="keyword"> const</span>
<a name="l00078"></a>00078 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s&gt;a.s; }
<a name="l00079"></a>00079     <span class="keywordtype">bool</span> operator &gt;=(<span class="keyword">const</span> distsize_t &amp;a)<span class="keyword"> const</span>
<a name="l00080"></a>00080 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s&gt;=a.s; }
<a name="l00081"></a>00081     <span class="keywordtype">bool</span> operator ==(<span class="keyword">const</span> distsize_t &amp;a)<span class="keyword"> const</span>
<a name="l00082"></a>00082 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s==a.s; }
<a name="l00083"></a>00083     distsize_t operator *(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a)<span class="keyword"> const</span>
<a name="l00084"></a>00084 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s*a; }
<a name="l00085"></a>00085     distsize_t operator +(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a)<span class="keyword"> const</span>
<a name="l00086"></a>00086 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s+a; }
<a name="l00087"></a>00087     distsize_t operator -(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a)<span class="keyword"> const</span>
<a name="l00088"></a>00088 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s-a; }
<a name="l00089"></a>00089     distsize_t operator /(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a)<span class="keyword"> const</span>
<a name="l00090"></a>00090 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s/a; }
<a name="l00091"></a>00091     distsize_t operator %(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a)<span class="keyword"> const</span>
<a name="l00092"></a>00092 <span class="keyword">        </span>{ <span class="keywordflow">return</span> s%a; }
<a name="l00093"></a>00093 };
<a name="l00094"></a>00094 <span class="keyword">inline</span> distsize_t operator *(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> distsize_t &amp;b)
<a name="l00095"></a>00095 { <span class="keywordflow">return</span> a*b.s; }
<a name="l00096"></a>00096 <span class="keyword">inline</span> distsize_t operator +(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> distsize_t &amp;b)
<a name="l00097"></a>00097 { <span class="keywordflow">return</span> a+b.s; }
<a name="l00098"></a>00098 <span class="keyword">inline</span> distsize_t operator -(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> distsize_t &amp;b)
<a name="l00099"></a>00099 { <span class="keywordflow">return</span> a-b.s; }
<a name="l00100"></a>00100 <span class="keyword">inline</span> distsize_t operator /(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> distsize_t &amp;b)
<a name="l00101"></a>00101 { <span class="keywordflow">return</span> a/b.s; }
<a name="l00102"></a>00102 <span class="keyword">inline</span> distsize_t operator %(<span class="keyword">const</span> <span class="keywordtype">int</span> &amp;a,<span class="keyword">const</span> distsize_t &amp;b)
<a name="l00103"></a>00103 { <span class="keywordflow">return</span> a%b.s; }
<a name="l00104"></a>00104 <span class="keyword">inline</span> ostream&amp; operator &lt;&lt;(ostream&amp; o, <span class="keyword">const</span> distsize_t &amp;s) { <span class="keywordflow">return</span> o&lt;&lt;s.s; }
<a name="l00105"></a>00105 <span class="keyword">inline</span> <span class="keywordtype">size_t</span> distsize_to_size(<span class="keyword">const</span> distsize_t &amp;a) {<span class="keywordflow">return</span> a.s;}
<a name="l00106"></a>00106 <span class="preprocessor">#elif defined(HAVE_LONG_LONG)</span>
<a name="l00107"></a>00107 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> distsize_t;
<a name="l00108"></a>00108 <span class="keyword">typedef</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> distssize_t;
<a name="l00109"></a>00109 <span class="keyword">inline</span> <span class="keywordtype">size_t</span> distsize_to_size(<span class="keyword">const</span> distsize_t &amp;a) {<span class="keywordflow">return</span> a;}
<a name="l00110"></a>00110 <span class="preprocessor">#else</span>
<a name="l00111"></a>00111 <span class="preprocessor"></span><span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> distsize_t;
<a name="l00112"></a>00112 <span class="keyword">typedef</span> <span class="keywordtype">long</span> distssize_t;
<a name="l00113"></a>00113 <span class="keyword">inline</span> <span class="keywordtype">size_t</span> distsize_to_size(<span class="keyword">const</span> distsize_t &amp;a) {<span class="keywordflow">return</span> a;}
<a name="l00114"></a>00114 <span class="preprocessor">#endif</span>
<a name="l00115"></a>00115 <span class="preprocessor"></span>
<a name="l00124"></a><a class="code" href="classsc_1_1MemoryGrp.html">00124</a> <span class="keyword">class </span><a class="code" href="classsc_1_1MemoryGrp.html" title="The MemoryGrp abstract class provides a way of accessing distributed memory in a...">MemoryGrp</a>: <span class="keyword">public</span> <a class="code" href="classsc_1_1DescribedClass.html" title="Classes which need runtime information about themselves and their relationship to...">DescribedClass</a> {
<a name="l00125"></a>00125   <span class="keyword">private</span>:
<a name="l00126"></a>00126     <a class="code" href="classsc_1_1Ref.html">Ref&lt;ThreadLock&gt;</a> *locks_;
<a name="l00127"></a>00127     <span class="keywordtype">int</span> nlock_;
<a name="l00128"></a>00128  
<a name="l00129"></a>00129     <span class="keywordtype">void</span> init_locks();
<a name="l00130"></a>00130 
<a name="l00131"></a>00131 
<a name="l00132"></a>00132   <span class="keyword">protected</span>:
<a name="l00133"></a>00133     <span class="comment">// derived classes must fill in all these</span>
<a name="l00134"></a>00134     <span class="comment">// ~MemoryGrp deletes the arrays</span>
<a name="l00135"></a>00135     <span class="keywordtype">int</span> me_;
<a name="l00136"></a>00136     <span class="keywordtype">int</span> n_;
<a name="l00137"></a>00137     distsize_t *offsets_; <span class="comment">// offsets_[n_] is the fence for all data</span>
<a name="l00138"></a>00138 
<a name="l00139"></a>00139     <span class="comment">// set to nonzero for debugging information</span>
<a name="l00140"></a>00140     <span class="keywordtype">int</span> debug_;
<a name="l00141"></a>00141 
<a name="l00142"></a>00142     <span class="keywordtype">void</span> obtain_local_lock(<span class="keywordtype">size_t</span> start, <span class="keywordtype">size_t</span> fence);
<a name="l00143"></a>00143     <span class="keywordtype">void</span> release_local_lock(<span class="keywordtype">size_t</span> start, <span class="keywordtype">size_t</span> fence);
<a name="l00144"></a>00144   <span class="keyword">public</span>:
<a name="l00145"></a>00145     <a class="code" href="classsc_1_1MemoryGrp.html" title="The MemoryGrp abstract class provides a way of accessing distributed memory in a...">MemoryGrp</a>();
<a name="l00146"></a>00146     <a class="code" href="classsc_1_1MemoryGrp.html" title="The MemoryGrp abstract class provides a way of accessing distributed memory in a...">MemoryGrp</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html">Ref&lt;KeyVal&gt;</a>&amp;);
<a name="l00147"></a>00147     <span class="keyword">virtual</span> ~<a class="code" href="classsc_1_1MemoryGrp.html" title="The MemoryGrp abstract class provides a way of accessing distributed memory in a...">MemoryGrp</a>();
<a name="l00148"></a>00148     
<a name="l00150"></a><a class="code" href="classsc_1_1MemoryGrp.html#b61aa9431f137985c7cbfcf84e2b573e">00150</a>     <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrp.html#b61aa9431f137985c7cbfcf84e2b573e" title="Returns who I am.">me</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> me_; }
<a name="l00152"></a><a class="code" href="classsc_1_1MemoryGrp.html#a2f204165147154bd15600ea8929b3c6">00152</a>     <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrp.html#a2f204165147154bd15600ea8929b3c6" title="Returns how many nodes there are.">n</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> n_; }
<a name="l00153"></a>00153 
<a name="l00157"></a>00157     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#4ee243438a21eb017e3f5f6624ab9cfc" title="Set the size of locally held memory.">set_localsize</a>(<span class="keywordtype">size_t</span>) = 0;
<a name="l00159"></a><a class="code" href="classsc_1_1MemoryGrp.html#e56426818b8a6d9b333e33ccdd23f32b">00159</a>     <span class="keywordtype">size_t</span> <a class="code" href="classsc_1_1MemoryGrp.html#e56426818b8a6d9b333e33ccdd23f32b" title="Returns the amount of memory residing locally on me().">localsize</a>() { <span class="keywordflow">return</span> distsize_to_size(offsets_[me_+1]-offsets_[me_]); }
<a name="l00161"></a>00161     <span class="keyword">virtual</span> <span class="keywordtype">void</span> *<a class="code" href="classsc_1_1MemoryGrp.html#ddc2e145860610b03e2e2af5417e74c8" title="Returns a pointer to the local data.">localdata</a>() = 0;
<a name="l00163"></a><a class="code" href="classsc_1_1MemoryGrp.html#ea2b088ce7904ec4cba6f40555a69833">00163</a>     distsize_t <a class="code" href="classsc_1_1MemoryGrp.html#ea2b088ce7904ec4cba6f40555a69833" title="Returns the global offset to this node&amp;#39;s memory.">localoffset</a>() { <span class="keywordflow">return</span> offsets_[me_]; }
<a name="l00165"></a><a class="code" href="classsc_1_1MemoryGrp.html#16856ef367eb8d9b39bb36525d7753bf">00165</a>     <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrp.html#16856ef367eb8d9b39bb36525d7753bf" title="Returns the amount of memory residing on node.">size</a>(<span class="keywordtype">int</span> node)
<a name="l00166"></a>00166         { <span class="keywordflow">return</span> distsize_to_size(offsets_[node+1] - offsets_[node]); }
<a name="l00168"></a><a class="code" href="classsc_1_1MemoryGrp.html#c65ac54b76c98942de3dcae3bb776e03">00168</a>     distsize_t <a class="code" href="classsc_1_1MemoryGrp.html#c65ac54b76c98942de3dcae3bb776e03" title="Returns the global offset to node&amp;#39;s memory.">offset</a>(<span class="keywordtype">int</span> node) { <span class="keywordflow">return</span> offsets_[node]; }
<a name="l00170"></a><a class="code" href="classsc_1_1MemoryGrp.html#70f900af5de88700224ed3cceecd1fc9">00170</a>     distsize_t <a class="code" href="classsc_1_1MemoryGrp.html#70f900af5de88700224ed3cceecd1fc9" title="Returns the sum of all memory allocated on all nodes.">totalsize</a>() { <span class="keywordflow">return</span> offsets_[n_]; }
<a name="l00171"></a>00171 
<a name="l00173"></a>00173     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#72903ddd45d1dd9deabb92970a81aec8" title="Activate is called before the memory is to be used.">activate</a>();
<a name="l00175"></a>00175     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#ee66fcdd210e3d4670d5e2e4ae9c0755" title="Deactivate is called after the memory has been used.">deactivate</a>();
<a name="l00176"></a>00176 
<a name="l00178"></a>00178     <span class="keyword">virtual</span> <span class="keywordtype">void</span> *<a class="code" href="classsc_1_1MemoryGrp.html#2724fd5ab40d08eb3a437c33a2ce8cd3" title="This gives write access to the memory location. No locking is done.">obtain_writeonly</a>(distsize_t <a class="code" href="classsc_1_1MemoryGrp.html#c65ac54b76c98942de3dcae3bb776e03" title="Returns the global offset to node&amp;#39;s memory.">offset</a>, <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrp.html#16856ef367eb8d9b39bb36525d7753bf" title="Returns the amount of memory residing on node.">size</a>) = 0;
<a name="l00184"></a>00184     <span class="keyword">virtual</span> <span class="keywordtype">void</span> *<a class="code" href="classsc_1_1MemoryGrp.html#adba96c579589e6be4ce48bd275137a0" title="Only one thread can have an unreleased obtain_readwrite at a time.">obtain_readwrite</a>(distsize_t <a class="code" href="classsc_1_1MemoryGrp.html#c65ac54b76c98942de3dcae3bb776e03" title="Returns the global offset to node&amp;#39;s memory.">offset</a>, <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrp.html#16856ef367eb8d9b39bb36525d7753bf" title="Returns the amount of memory residing on node.">size</a>) = 0;
<a name="l00186"></a>00186     <span class="keyword">virtual</span> <span class="keywordtype">void</span> *<a class="code" href="classsc_1_1MemoryGrp.html#024fecfeccb5aba14fa924c269f53004" title="This gives read access to the memory location. No locking is done.">obtain_readonly</a>(distsize_t <a class="code" href="classsc_1_1MemoryGrp.html#c65ac54b76c98942de3dcae3bb776e03" title="Returns the global offset to node&amp;#39;s memory.">offset</a>, <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrp.html#16856ef367eb8d9b39bb36525d7753bf" title="Returns the amount of memory residing on node.">size</a>) = 0;
<a name="l00188"></a>00188     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#6e89f53271232a10bd206dabf6445bad" title="This is called when read access is no longer needed.">release_readonly</a>(<span class="keywordtype">void</span> *data, distsize_t <a class="code" href="classsc_1_1MemoryGrp.html#c65ac54b76c98942de3dcae3bb776e03" title="Returns the global offset to node&amp;#39;s memory.">offset</a>, <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrp.html#16856ef367eb8d9b39bb36525d7753bf" title="Returns the amount of memory residing on node.">size</a>) = 0;
<a name="l00190"></a>00190     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#4e2cd771d786240a0885f842a183f5f1" title="This is called when write access is no longer needed.">release_writeonly</a>(<span class="keywordtype">void</span> *data, distsize_t <a class="code" href="classsc_1_1MemoryGrp.html#c65ac54b76c98942de3dcae3bb776e03" title="Returns the global offset to node&amp;#39;s memory.">offset</a>, <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrp.html#16856ef367eb8d9b39bb36525d7753bf" title="Returns the amount of memory residing on node.">size</a>)=0;
<a name="l00193"></a>00193     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#ab51f4f3cf1d7c12fe9c834e0d928eed" title="This is called when read/write access is no longer needed.">release_readwrite</a>(<span class="keywordtype">void</span> *data, distsize_t <a class="code" href="classsc_1_1MemoryGrp.html#c65ac54b76c98942de3dcae3bb776e03" title="Returns the global offset to node&amp;#39;s memory.">offset</a>, <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrp.html#16856ef367eb8d9b39bb36525d7753bf" title="Returns the amount of memory residing on node.">size</a>)=0;
<a name="l00194"></a>00194 
<a name="l00195"></a>00195     <span class="keyword">virtual</span> <span class="keywordtype">void</span> sum_reduction(<span class="keywordtype">double</span> *data, distsize_t doffset, <span class="keywordtype">int</span> dsize);
<a name="l00196"></a>00196     <span class="keyword">virtual</span> <span class="keywordtype">void</span> sum_reduction_on_node(<span class="keywordtype">double</span> *data, <span class="keywordtype">size_t</span> doffset, <span class="keywordtype">int</span> dsize,
<a name="l00197"></a>00197                                        <span class="keywordtype">int</span> node = -1);
<a name="l00198"></a>00198 
<a name="l00202"></a>00202     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#0ef395631d3e3b7fe740e28bb7d9f571" title="Synchronizes all the nodes.">sync</a>() = 0;
<a name="l00203"></a>00203 
<a name="l00208"></a>00208     <span class="keyword">virtual</span> <span class="keywordtype">void</span>* <a class="code" href="classsc_1_1MemoryGrp.html#026f90c96fb4c9523327c4943005131c" title="Allocate data that will be accessed locally only.">malloc_local</a>(<span class="keywordtype">size_t</span> nbyte);
<a name="l00209"></a>00209     <span class="keyword">virtual</span> <span class="keywordtype">double</span>* malloc_local_double(<span class="keywordtype">size_t</span> ndouble);
<a name="l00210"></a>00210 
<a name="l00212"></a>00212     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#d2bfbe8d9d28611a16660064795df0db" title="Free data that was allocated with malloc_local_double.">free_local</a>(<span class="keywordtype">void</span> *data);
<a name="l00213"></a>00213     <span class="keyword">virtual</span> <span class="keywordtype">void</span> free_local_double(<span class="keywordtype">double</span> *data);
<a name="l00214"></a>00214 
<a name="l00221"></a>00221     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#f72d6e855cf5d1bc1eae03f690b1ac75" title="Processes outstanding requests.">catchup</a>();
<a name="l00222"></a>00222 
<a name="l00224"></a>00224     <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#9574150fb8dfbe8fd46de5fba60d5c0a" title="Prints out information about the object.">print</a>(std::ostream &amp;o = <a class="code" href="classsc_1_1ExEnv.html#360216acd1f990e999c0ed46cb350b1f" title="Return an ostream that writes from node 0.">ExEnv::out0</a>()) <span class="keyword">const</span>;
<a name="l00225"></a>00225 
<a name="l00233"></a>00233     <span class="keyword">static</span> <a class="code" href="classsc_1_1MemoryGrp.html" title="The MemoryGrp abstract class provides a way of accessing distributed memory in a...">MemoryGrp</a>* initial_memorygrp(<span class="keywordtype">int</span> &amp;argc, <span class="keywordtype">char</span>** argv);
<a name="l00234"></a>00234     <span class="keyword">static</span> <a class="code" href="classsc_1_1MemoryGrp.html" title="The MemoryGrp abstract class provides a way of accessing distributed memory in a...">MemoryGrp</a>* initial_memorygrp();
<a name="l00237"></a>00237     <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrp.html#41fdf83fb404c5f1c5b0daab4bc0b3ff" title="The default memory group contains the primary memory group to be used by an application...">set_default_memorygrp</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html">Ref&lt;MemoryGrp&gt;</a>&amp;);
<a name="l00243"></a>00243     <span class="keyword">static</span> <a class="code" href="classsc_1_1MemoryGrp.html" title="The MemoryGrp abstract class provides a way of accessing distributed memory in a...">MemoryGrp</a>* <a class="code" href="classsc_1_1MemoryGrp.html#00e239959d75cf50d70e525224587732" title="Returns the default memory group.">get_default_memorygrp</a>();
<a name="l00244"></a>00244 };
<a name="l00245"></a>00245 
<a name="l00246"></a>00246 
<a name="l00252"></a>00252 <span class="keyword">template</span> &lt;<span class="keyword">class</span> data_t&gt;
<a name="l00253"></a><a class="code" href="classsc_1_1MemoryGrpBuf.html">00253</a> <span class="keyword">class </span><a class="code" href="classsc_1_1MemoryGrpBuf.html" title="The MemoryGrpBuf class provides access to pieces of the global shared memory that...">MemoryGrpBuf</a> {
<a name="l00254"></a>00254     <a class="code" href="classsc_1_1Ref.html">Ref&lt;MemoryGrp&gt;</a> grp_;
<a name="l00255"></a>00255     <span class="keyword">enum</span> AccessType { None, Read, Write, ReadWrite };
<a name="l00256"></a>00256     AccessType accesstype_;
<a name="l00257"></a>00257     data_t *data_;
<a name="l00258"></a>00258     distsize_t offset_;
<a name="l00259"></a>00259     <span class="keywordtype">int</span> length_;
<a name="l00260"></a>00260   <span class="keyword">public</span>:
<a name="l00264"></a>00264     <a class="code" href="classsc_1_1MemoryGrpBuf.html#abdd09a39ba4f22a0ca295fb3d4c4b5d" title="Creates a new MemoryGrpBuf given a MemoryGrp reference.">MemoryGrpBuf</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html">Ref&lt;MemoryGrp&gt;</a> &amp;);
<a name="l00269"></a>00269     data_t *<a class="code" href="classsc_1_1MemoryGrpBuf.html#ce536f26e642f09eac0e31a8b81b10a5" title="Request write only access to global memory at the global address offset and with...">writeonly</a>(distsize_t offset, <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrpBuf.html#03d557a160399d3d73009a6c92f3d8c5" title="The length of the current bit of memory.">length</a>);
<a name="l00274"></a>00274     data_t *<a class="code" href="classsc_1_1MemoryGrpBuf.html#7f070fd74eeacf3f9f77ed929994cf7f" title="Request read write access to global memory at the global address offset and with...">readwrite</a>(distsize_t offset, <span class="keywordtype">int</span> length);
<a name="l00279"></a>00279     <span class="keyword">const</span> data_t *<a class="code" href="classsc_1_1MemoryGrpBuf.html#aba979ed25ec96c2771beea923f345d7" title="Request read only access to global memory at the global address offset and with size...">readonly</a>(distsize_t offset, <span class="keywordtype">int</span> length);
<a name="l00283"></a>00283     data_t *<a class="code" href="classsc_1_1MemoryGrpBuf.html#c7045040edf4d6ec71aefeb8f01994a8" title="These behave like writeonly, readwrite, and readonly, except the offset is local...">writeonly_on_node</a>(<span class="keywordtype">size_t</span> offset, <span class="keywordtype">int</span> length, <span class="keywordtype">int</span> node = -1);
<a name="l00284"></a>00284     data_t *readwrite_on_node(<span class="keywordtype">size_t</span> offset, <span class="keywordtype">int</span> length, <span class="keywordtype">int</span> node = -1);
<a name="l00285"></a>00285     <span class="keyword">const</span> data_t *readonly_on_node(<span class="keywordtype">size_t</span> offset, <span class="keywordtype">int</span> length, <span class="keywordtype">int</span> node = -1);
<a name="l00289"></a>00289     <span class="keywordtype">void</span> <a class="code" href="classsc_1_1MemoryGrpBuf.html#a7389d8fc9ec334db770be2b254a2300" title="Release the access to the chunk of global memory that was obtained with writeonly...">release</a>();
<a name="l00291"></a><a class="code" href="classsc_1_1MemoryGrpBuf.html#03d557a160399d3d73009a6c92f3d8c5">00291</a>     <span class="keywordtype">int</span> <a class="code" href="classsc_1_1MemoryGrpBuf.html#03d557a160399d3d73009a6c92f3d8c5" title="The length of the current bit of memory.">length</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> length_; }
<a name="l00292"></a>00292 };
<a name="l00293"></a>00293 
<a name="l00295"></a>00295 <span class="comment">// MemoryGrpBuf members</span>
<a name="l00296"></a>00296 
<a name="l00297"></a>00297 <span class="keyword">template</span> &lt;<span class="keyword">class</span> data_t&gt;
<a name="l00298"></a><a class="code" href="classsc_1_1MemoryGrpBuf.html#abdd09a39ba4f22a0ca295fb3d4c4b5d">00298</a> <a class="code" href="classsc_1_1MemoryGrpBuf.html#abdd09a39ba4f22a0ca295fb3d4c4b5d" title="Creates a new MemoryGrpBuf given a MemoryGrp reference.">MemoryGrpBuf&lt;data_t&gt;::MemoryGrpBuf</a>(<span class="keyword">const</span> <a class="code" href="classsc_1_1Ref.html">Ref&lt;MemoryGrp&gt;</a> &amp; grp)
<a name="l00299"></a>00299 {
<a name="l00300"></a>00300   grp_ = grp;
<a name="l00301"></a>00301   accesstype_ = None;
<a name="l00302"></a>00302 }
<a name="l00303"></a>00303 
<a name="l00304"></a>00304 <span class="keyword">template</span> &lt;<span class="keyword">class</span> data_t&gt;
<a name="l00305"></a>00305 data_t *
<a name="l00306"></a><a class="code" href="classsc_1_1MemoryGrpBuf.html#ce536f26e642f09eac0e31a8b81b10a5">00306</a> <a class="code" href="classsc_1_1MemoryGrpBuf.html#ce536f26e642f09eac0e31a8b81b10a5" title="Request write only access to global memory at the global address offset and with...">MemoryGrpBuf&lt;data_t&gt;::writeonly</a>(distsize_t offset, <span class="keywordtype">int</span> length)
<a name="l00307"></a>00307 {
<a name="l00308"></a>00308   <span class="keywordflow">if</span> (accesstype_ != None) <a class="code" href="classsc_1_1MemoryGrpBuf.html#a7389d8fc9ec334db770be2b254a2300" title="Release the access to the chunk of global memory that was obtained with writeonly...">release</a>();
<a name="l00309"></a>00309   data_ = (data_t *) grp_-&gt;obtain_writeonly(<span class="keyword">sizeof</span>(data_t)*offset,
<a name="l00310"></a>00310                                             <span class="keyword">sizeof</span>(data_t)*length);
<a name="l00311"></a>00311   offset_ = offset;
<a name="l00312"></a>00312   length_ = length;
<a name="l00313"></a>00313   accesstype_ = Write;
<a name="l00314"></a>00314   <span class="keywordflow">return</span> data_;
<a name="l00315"></a>00315 }
<a name="l00316"></a>00316 
<a name="l00317"></a>00317 <span class="keyword">template</span> &lt;<span class="keyword">class</span> data_t&gt;
<a name="l00318"></a>00318 data_t *
<a name="l00319"></a><a class="code" href="classsc_1_1MemoryGrpBuf.html#7f070fd74eeacf3f9f77ed929994cf7f">00319</a> <a class="code" href="classsc_1_1MemoryGrpBuf.html#7f070fd74eeacf3f9f77ed929994cf7f" title="Request read write access to global memory at the global address offset and with...">MemoryGrpBuf&lt;data_t&gt;::readwrite</a>(distsize_t offset, <span class="keywordtype">int</span> length)
<a name="l00320"></a>00320 {
<a name="l00321"></a>00321   <span class="keywordflow">if</span> (accesstype_ != None) <a class="code" href="classsc_1_1MemoryGrpBuf.html#a7389d8fc9ec334db770be2b254a2300" title="Release the access to the chunk of global memory that was obtained with writeonly...">release</a>();
<a name="l00322"></a>00322   data_ = (data_t *) grp_-&gt;obtain_readwrite(<span class="keyword">sizeof</span>(data_t)*offset,
<a name="l00323"></a>00323                                             <span class="keyword">sizeof</span>(data_t)*length);
<a name="l00324"></a>00324   offset_ = offset;
<a name="l00325"></a>00325   length_ = length;
<a name="l00326"></a>00326   accesstype_ = ReadWrite;
<a name="l00327"></a>00327   <span class="keywordflow">return</span> data_;
<a name="l00328"></a>00328 }
<a name="l00329"></a>00329 
<a name="l00330"></a>00330 <span class="keyword">template</span> &lt;<span class="keyword">class</span> data_t&gt;
<a name="l00331"></a>00331 <span class="keyword">const</span> data_t *
<a name="l00332"></a><a class="code" href="classsc_1_1MemoryGrpBuf.html#aba979ed25ec96c2771beea923f345d7">00332</a> <a class="code" href="classsc_1_1MemoryGrpBuf.html#aba979ed25ec96c2771beea923f345d7" title="Request read only access to global memory at the global address offset and with size...">MemoryGrpBuf&lt;data_t&gt;::readonly</a>(distsize_t offset, <span class="keywordtype">int</span> length)
<a name="l00333"></a>00333 {
<a name="l00334"></a>00334   <span class="keywordflow">if</span> (accesstype_ != None) <a class="code" href="classsc_1_1MemoryGrpBuf.html#a7389d8fc9ec334db770be2b254a2300" title="Release the access to the chunk of global memory that was obtained with writeonly...">release</a>();
<a name="l00335"></a>00335   data_ = (data_t *) grp_-&gt;obtain_readonly(<span class="keyword">sizeof</span>(data_t)*offset,
<a name="l00336"></a>00336                                            <span class="keyword">sizeof</span>(data_t)*length);
<a name="l00337"></a>00337   offset_ = offset;
<a name="l00338"></a>00338   length_ = length;
<a name="l00339"></a>00339   accesstype_ = Read;
<a name="l00340"></a>00340   <span class="keywordflow">return</span> data_;
<a name="l00341"></a>00341 }
<a name="l00342"></a>00342 
<a name="l00343"></a>00343 <span class="keyword">template</span> &lt;<span class="keyword">class</span> data_t&gt;
<a name="l00344"></a>00344 data_t *
<a name="l00345"></a><a class="code" href="classsc_1_1MemoryGrpBuf.html#c7045040edf4d6ec71aefeb8f01994a8">00345</a> <a class="code" href="classsc_1_1MemoryGrpBuf.html#c7045040edf4d6ec71aefeb8f01994a8" title="These behave like writeonly, readwrite, and readonly, except the offset is local...">MemoryGrpBuf&lt;data_t&gt;::writeonly_on_node</a>(<span class="keywordtype">size_t</span> offset, <span class="keywordtype">int</span> length, <span class="keywordtype">int</span> node)
<a name="l00346"></a>00346 {
<a name="l00347"></a>00347   <span class="keywordflow">if</span> (node == -1) node = grp_-&gt;me();
<a name="l00348"></a>00348   <span class="keywordflow">return</span> <a class="code" href="classsc_1_1MemoryGrpBuf.html#ce536f26e642f09eac0e31a8b81b10a5" title="Request write only access to global memory at the global address offset and with...">writeonly</a>(offset + grp_-&gt;offset(node)/<span class="keyword">sizeof</span>(data_t), length);
<a name="l00349"></a>00349 }
<a name="l00350"></a>00350 
<a name="l00351"></a>00351 <span class="keyword">template</span> &lt;<span class="keyword">class</span> data_t&gt;
<a name="l00352"></a>00352 data_t *
<a name="l00353"></a>00353 <a class="code" href="classsc_1_1MemoryGrpBuf.html" title="The MemoryGrpBuf class provides access to pieces of the global shared memory that...">MemoryGrpBuf&lt;data_t&gt;::readwrite_on_node</a>(<span class="keywordtype">size_t</span> offset, <span class="keywordtype">int</span> length, <span class="keywordtype">int</span> node)
<a name="l00354"></a>00354 {
<a name="l00355"></a>00355   <span class="keywordflow">if</span> (node == -1) node = grp_-&gt;me();
<a name="l00356"></a>00356   <span class="keywordflow">return</span> <a class="code" href="classsc_1_1MemoryGrpBuf.html#7f070fd74eeacf3f9f77ed929994cf7f" title="Request read write access to global memory at the global address offset and with...">readwrite</a>(offset + grp_-&gt;offset(node)/<span class="keyword">sizeof</span>(data_t), length);
<a name="l00357"></a>00357 }
<a name="l00358"></a>00358 
<a name="l00359"></a>00359 <span class="keyword">template</span> &lt;<span class="keyword">class</span> data_t&gt;
<a name="l00360"></a>00360 <span class="keyword">const</span> data_t *
<a name="l00361"></a>00361 MemoryGrpBuf&lt;data_t&gt;::readonly_on_node(<span class="keywordtype">size_t</span> offset, <span class="keywordtype">int</span> length, <span class="keywordtype">int</span> node)
<a name="l00362"></a>00362 {
<a name="l00363"></a>00363   <span class="keywordflow">if</span> (node == -1) node = grp_-&gt;me();
<a name="l00364"></a>00364   <span class="keywordflow">return</span> <a class="code" href="classsc_1_1MemoryGrpBuf.html#aba979ed25ec96c2771beea923f345d7" title="Request read only access to global memory at the global address offset and with size...">readonly</a>(offset + grp_-&gt;offset(node)/<span class="keyword">sizeof</span>(data_t), length);
<a name="l00365"></a>00365 }
<a name="l00366"></a>00366 
<a name="l00367"></a>00367 <span class="keyword">template</span> &lt;<span class="keyword">class</span> data_t&gt;
<a name="l00368"></a>00368 <span class="keywordtype">void</span>
<a name="l00369"></a><a class="code" href="classsc_1_1MemoryGrpBuf.html#a7389d8fc9ec334db770be2b254a2300">00369</a> <a class="code" href="classsc_1_1MemoryGrpBuf.html#a7389d8fc9ec334db770be2b254a2300" title="Release the access to the chunk of global memory that was obtained with writeonly...">MemoryGrpBuf&lt;data_t&gt;::release</a>()
<a name="l00370"></a>00370 {
<a name="l00371"></a>00371   <span class="keywordflow">if</span> (accesstype_ == Write)
<a name="l00372"></a>00372       grp_-&gt;release_writeonly((data_t *)data_,
<a name="l00373"></a>00373                               <span class="keyword">sizeof</span>(data_t)*offset_, <span class="keyword">sizeof</span>(data_t)*length_);
<a name="l00374"></a>00374   <span class="keywordflow">if</span> (accesstype_ == Read)
<a name="l00375"></a>00375       grp_-&gt;release_readonly(data_, <span class="keyword">sizeof</span>(data_t)*offset_,
<a name="l00376"></a>00376                              <span class="keyword">sizeof</span>(data_t)*length_);
<a name="l00377"></a>00377   <span class="keywordflow">if</span> (accesstype_ == ReadWrite)
<a name="l00378"></a>00378       grp_-&gt;release_readwrite(data_, <span class="keyword">sizeof</span>(data_t)*offset_,
<a name="l00379"></a>00379                               <span class="keyword">sizeof</span>(data_t)*length_);
<a name="l00380"></a>00380 
<a name="l00381"></a>00381   accesstype_ = None;
<a name="l00382"></a>00382 }
<a name="l00383"></a>00383 
<a name="l00384"></a>00384 }
<a name="l00385"></a>00385 
<a name="l00386"></a>00386 <span class="preprocessor">#endif</span>
<a name="l00387"></a>00387 <span class="preprocessor"></span>
<a name="l00388"></a>00388 <span class="comment">// Local Variables:</span>
<a name="l00389"></a>00389 <span class="comment">// mode: c++</span>
<a name="l00390"></a>00390 <span class="comment">// c-file-style: "CLJ"</span>
<a name="l00391"></a>00391 <span class="comment">// End:</span>
</pre></div></div>
<hr>
<address>
<small>

Generated at Wed Oct 14 14:12:10 2009 for <a
href="http://www.mpqc.org">MPQC</a>
2.3.1 using the documentation package <a
href="http://www.doxygen.org">Doxygen</a>
1.5.9.

</small>
</address>
</body>
</html>