136 lines
18 KiB
HTML
Executable File
136 lines
18 KiB
HTML
Executable File
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
|
|
<title>MPI On Cell (Documentation): src/spu/communication/moc_barrier_spu.c Source File</title>
|
|
<link href="../../doxygen.css" rel="stylesheet" type="text/css">
|
|
<link href="../../tabs.css" rel="stylesheet" type="text/css">
|
|
</head><body>
|
|
<!-- Generated by Doxygen 1.5.6 -->
|
|
<div class="navigation" id="top">
|
|
<div class="tabs">
|
|
<ul>
|
|
<li><a href="../../main.html"><span>Main Page</span></a></li>
|
|
<li><a href="../../modules.html"><span>Modules</span></a></li>
|
|
<li><a href="../../annotated.html"><span>Data Structures</span></a></li>
|
|
<li class="current"><a href="../../files.html"><span>Files</span></a></li>
|
|
</ul>
|
|
</div>
|
|
<h1>src/spu/communication/moc_barrier_spu.c</h1><a href="../../dc/d59/moc__barrier__spu_8c.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#include <stdio.h></span>
|
|
<a name="l00002"></a>00002 <span class="preprocessor">#include <string.h></span>
|
|
<a name="l00003"></a>00003 <span class="preprocessor">#include <spu_mfcio.h></span>
|
|
<a name="l00004"></a>00004
|
|
<a name="l00005"></a>00005 <span class="preprocessor">#include <<a class="code" href="../../d0/d3a/spu_2moc_8h.html">moc.h</a>></span>
|
|
<a name="l00006"></a>00006 <span class="preprocessor">#include <<a class="code" href="../../d9/db3/imoc_8h.html">internal/imoc.h</a>></span>
|
|
<a name="l00007"></a>00007 <span class="preprocessor">#include <<a class="code" href="../../d2/d42/imoc__macros_8h.html">internal/imoc_macros.h</a>></span>
|
|
<a name="l00008"></a>00008 <span class="preprocessor">#include "<a class="code" href="../../d9/d00/imoc__core__spu_8h.html">internal/spu/imoc_core_spu.h</a>"</span>
|
|
<a name="l00009"></a>00009
|
|
<a name="l00010"></a><a class="code" href="../../dc/d59/moc__barrier__spu_8c.html#8a4118b9364b4bb700441e9e9dd9c3ab">00010</a> <span class="preprocessor">#define IMOC_BARRIER_TAG 1</span>
|
|
<a name="l00011"></a>00011 <span class="preprocessor"></span>
|
|
<a name="l00012"></a><a class="code" href="../../db/dc2/group__broadcast.html#g110b00d5a4d9f970ddf8e9bd4c2d8834">00012</a> <span class="keywordtype">int</span> <a class="code" href="../../db/dc2/group__broadcast.html#g110b00d5a4d9f970ddf8e9bd4c2d8834" title="Blocks the caller until all processes in the communicator have called it; that is...">MOC_Barrier</a>(<a class="code" href="../../d1/dd1/group__comm__mgt.html#g3d2b8a9af65bff5f79d02bda13616767" title="Communicator-Handle.">MOC_Comm</a> comm)
|
|
<a name="l00013"></a>00013 {
|
|
<a name="l00014"></a>00014 <a class="code" href="../../df/dd4/structmoc__message__envelope__struct.html" title="Message-envelope structure.">moc_message_envelope_t</a> tempQueue[<a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.<a class="code" href="../../d8/d93/structmoc__node__handle__ppu__struct.html#ee1aa72cd99190cf97523a955cfa6141" title="Size of a message-queue.">queue_size</a>] <a class="code" href="../../d3/dd3/group__internal__p2p__bmalloc.html#gad8750c7ba3d6da9c137c2c462d2c531" title="void bmalloc_print_nodes() { if (!bmalloc_first_node) printf(&quot;No nodes in list\n&quot;);...">__attribute__</a>((__aligned__(16)));
|
|
<a name="l00015"></a>00015 <a class="code" href="../../df/dd4/structmoc__message__envelope__struct.html" title="Message-envelope structure.">moc_message_envelope_t</a> *sourceQueueEntry;
|
|
<a name="l00016"></a>00016 <a class="code" href="../../dd/d7a/structMOC__Status__struct.html" title="Structure holding information about a received message.">MOC_Status</a> status;
|
|
<a name="l00017"></a>00017 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> tag_id;
|
|
<a name="l00018"></a>00018 <span class="keywordtype">int</span> err, qindex;
|
|
<a name="l00019"></a>00019
|
|
<a name="l00020"></a>00020 <span class="keywordflow">if</span> (comm == <a class="code" href="../../d1/dd1/group__comm__mgt.html#gf8c5dfb6bb79027948fe63f4cf6504eb" title="Specifies a constant that contains only the calling process.">MOC_COMM_SELF</a>)
|
|
<a name="l00021"></a>00021 <span class="keywordflow">return</span> 0;
|
|
<a name="l00022"></a>00022
|
|
<a name="l00023"></a>00023 <span class="keywordflow">if</span> (<a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.<a class="code" href="../../d8/d93/structmoc__node__handle__ppu__struct.html#9005ee3d6d0ee8b2f15628dcca724710" title="rank of node">rank</a> == <a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.<a class="code" href="../../d8/d93/structmoc__node__handle__ppu__struct.html#3779cc1bda02c45a880389b109173778" title="number of overall processes">comm_size</a> - 1)
|
|
<a name="l00024"></a>00024 {
|
|
<a name="l00025"></a>00025 <span class="keywordtype">int</span> t;
|
|
<a name="l00026"></a>00026 <span class="keywordflow">for</span> (t = 0; t < <a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.<a class="code" href="../../d8/d93/structmoc__node__handle__ppu__struct.html#3779cc1bda02c45a880389b109173778" title="number of overall processes">comm_size</a> - 1; t++)
|
|
<a name="l00027"></a>00027 {
|
|
<a name="l00028"></a>00028 <span class="comment">//look up if there is data here</span>
|
|
<a name="l00029"></a>00029 sourceQueueEntry = 0;
|
|
<a name="l00030"></a>00030 <span class="keywordflow">while</span> (sourceQueueEntry == 0)
|
|
<a name="l00031"></a>00031 {
|
|
<a name="l00032"></a>00032 sourceQueueEntry = <a class="code" href="../../d8/d88/group__internal__p2p__main.html#g8980da77fa506e9a6d503c8c6eba68e2" title="Get the next valid message-envelope from &quot;source&quot; with specified &quot;tag&quot;...">IMOC_get_entry</a>(t, <a class="code" href="../../d1/d72/moc__barrier__ppu_8c.html#8a4118b9364b4bb700441e9e9dd9c3ab">IMOC_BARRIER_TAG</a>, comm, 1,
|
|
<a name="l00033"></a>00033 &status);
|
|
<a name="l00034"></a>00034 }
|
|
<a name="l00035"></a>00035 sourceQueueEntry-><a class="code" href="../../df/dd4/structmoc__message__envelope__struct.html#38288113f9b7adee1e444850112ff807" title="flag-union">flags</a>.<a class="code" href="../../df/dd4/structmoc__message__envelope__struct.html#e51379150ad496c8844a4b9b0096120b" title="union-value">value</a> = 0;
|
|
<a name="l00036"></a>00036 }
|
|
<a name="l00037"></a>00037 <span class="keywordflow">for</span> (t = 0; t < <a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.<a class="code" href="../../d8/d93/structmoc__node__handle__ppu__struct.html#3779cc1bda02c45a880389b109173778" title="number of overall processes">comm_size</a> - 1; t++)
|
|
<a name="l00038"></a>00038 {
|
|
<a name="l00039"></a>00039 <span class="comment">/* Get queue from remote-node */</span>
|
|
<a name="l00040"></a>00040 <span class="keywordflow">if</span> ((tag_id = mfc_tag_reserve()) == MFC_TAG_INVALID)
|
|
<a name="l00041"></a>00041 <span class="keywordflow">return</span> <a class="code" href="../../d8/da1/group__environment__error.html#g05b3a70831c823a59014c4853a76ca7e" title="Internal MOC (implementation) error.">MOC_ERR_INTERN</a>;
|
|
<a name="l00042"></a>00042 mfc_get(tempQueue, <a class="code" href="../../df/ddf/group__internal__am.html#gf02c3d971a2b5e72d22c9c16b1748c04" title="Effective base-address of own remote queue at node &#39;rank&#39;.">IMOC_EA_REMOTE_QUEUE</a>(t), <a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.<a class="code" href="../../d8/d93/structmoc__node__handle__ppu__struct.html#ee1aa72cd99190cf97523a955cfa6141" title="Size of a message-queue.">queue_size</a>
|
|
<a name="l00043"></a>00043 * <span class="keyword">sizeof</span>(<a class="code" href="../../df/dd4/structmoc__message__envelope__struct.html" title="Message-envelope structure.">moc_message_envelope_t</a>), tag_id, 0, 0);
|
|
<a name="l00044"></a>00044 mfc_write_tag_mask(1 << tag_id);
|
|
<a name="l00045"></a>00045 mfc_read_tag_status_all();
|
|
<a name="l00046"></a>00046 mfc_tag_release(tag_id);
|
|
<a name="l00047"></a>00047
|
|
<a name="l00048"></a>00048 <span class="comment">/* search free entry in message-queue */</span>
|
|
<a name="l00049"></a>00049 err = <a class="code" href="../../d8/d88/group__internal__p2p__main.html#g2a948cdecce651ae6cc1b0c0ddb1b750" title="Get next free entry in message-queue (a local copy of the message-queue has to be...">IMOC_getFreeEntry</a>(tempQueue, <a class="code" href="../../d1/d72/moc__barrier__ppu_8c.html#8a4118b9364b4bb700441e9e9dd9c3ab">IMOC_BARRIER_TAG</a>, comm, 1,
|
|
<a name="l00050"></a>00050 &qindex);
|
|
<a name="l00051"></a>00051 <span class="keywordflow">if</span> (err)
|
|
<a name="l00052"></a>00052 <span class="keywordflow">return</span> err;
|
|
<a name="l00053"></a>00053
|
|
<a name="l00054"></a>00054 tempQueue[qindex].communicator = comm;
|
|
<a name="l00055"></a>00055 tempQueue[qindex].flags.bits.special = 1;
|
|
<a name="l00056"></a>00056 tempQueue[qindex].flags.bits.valid = 1;
|
|
<a name="l00057"></a>00057 tempQueue[qindex].tag = <a class="code" href="../../d1/d72/moc__barrier__ppu_8c.html#8a4118b9364b4bb700441e9e9dd9c3ab">IMOC_BARRIER_TAG</a>;
|
|
<a name="l00058"></a>00058
|
|
<a name="l00059"></a>00059 <span class="comment">/* write message-envelope into queue */</span>
|
|
<a name="l00060"></a>00060 <span class="keywordflow">if</span> ((tag_id = mfc_tag_reserve()) == MFC_TAG_INVALID)
|
|
<a name="l00061"></a>00061 <span class="keywordflow">return</span> <a class="code" href="../../d8/da1/group__environment__error.html#g05b3a70831c823a59014c4853a76ca7e" title="Internal MOC (implementation) error.">MOC_ERR_INTERN</a>;
|
|
<a name="l00062"></a>00062 mfc_put(&tempQueue[qindex], <a class="code" href="../../df/ddf/group__internal__am.html#gf9ad028ccbfa406c49a0ebd943486698" title="Effective base-address of own remote queue-entry at node &#39;rank&#39;.">IMOC_EA_REMOTE_QUEUE_ENTRY</a>(t, qindex),
|
|
<a name="l00063"></a>00063 <span class="keyword">sizeof</span>(<a class="code" href="../../df/dd4/structmoc__message__envelope__struct.html" title="Message-envelope structure.">moc_message_envelope_t</a>), tag_id, 0, 0);
|
|
<a name="l00064"></a>00064 mfc_write_tag_mask(1 << tag_id);
|
|
<a name="l00065"></a>00065 mfc_read_tag_status_all();
|
|
<a name="l00066"></a>00066 mfc_tag_release(tag_id);
|
|
<a name="l00067"></a>00067 }
|
|
<a name="l00068"></a>00068 }
|
|
<a name="l00069"></a>00069 <span class="keywordflow">else</span>
|
|
<a name="l00070"></a>00070 {
|
|
<a name="l00071"></a>00071 <span class="comment">/* Get queue from remote-node */</span>
|
|
<a name="l00072"></a>00072 <span class="keywordflow">if</span> ((tag_id = mfc_tag_reserve()) == MFC_TAG_INVALID)
|
|
<a name="l00073"></a>00073 <span class="keywordflow">return</span> <a class="code" href="../../d8/da1/group__environment__error.html#g05b3a70831c823a59014c4853a76ca7e" title="Internal MOC (implementation) error.">MOC_ERR_INTERN</a>;
|
|
<a name="l00074"></a>00074 mfc_get(tempQueue, <a class="code" href="../../df/ddf/group__internal__am.html#gf02c3d971a2b5e72d22c9c16b1748c04" title="Effective base-address of own remote queue at node &#39;rank&#39;.">IMOC_EA_REMOTE_QUEUE</a>(<a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.<a class="code" href="../../d8/d93/structmoc__node__handle__ppu__struct.html#3779cc1bda02c45a880389b109173778" title="number of overall processes">comm_size</a> - 1),
|
|
<a name="l00075"></a>00075 <a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.<a class="code" href="../../d8/d93/structmoc__node__handle__ppu__struct.html#ee1aa72cd99190cf97523a955cfa6141" title="Size of a message-queue.">queue_size</a> * <span class="keyword">sizeof</span>(<a class="code" href="../../df/dd4/structmoc__message__envelope__struct.html" title="Message-envelope structure.">moc_message_envelope_t</a>),
|
|
<a name="l00076"></a>00076 tag_id, 0, 0);
|
|
<a name="l00077"></a>00077 mfc_write_tag_mask(1 << tag_id);
|
|
<a name="l00078"></a>00078 mfc_read_tag_status_all();
|
|
<a name="l00079"></a>00079 mfc_tag_release(tag_id);
|
|
<a name="l00080"></a>00080
|
|
<a name="l00081"></a>00081 <span class="comment">/* search free entry in message-queue */</span>
|
|
<a name="l00082"></a>00082 err = <a class="code" href="../../d8/d88/group__internal__p2p__main.html#g2a948cdecce651ae6cc1b0c0ddb1b750" title="Get next free entry in message-queue (a local copy of the message-queue has to be...">IMOC_getFreeEntry</a>(tempQueue, <a class="code" href="../../d1/d72/moc__barrier__ppu_8c.html#8a4118b9364b4bb700441e9e9dd9c3ab">IMOC_BARRIER_TAG</a>, comm, 1, &qindex);
|
|
<a name="l00083"></a>00083 <span class="keywordflow">if</span> (err)
|
|
<a name="l00084"></a>00084 <span class="keywordflow">return</span> err;
|
|
<a name="l00085"></a>00085
|
|
<a name="l00086"></a>00086 tempQueue[qindex].communicator = comm;
|
|
<a name="l00087"></a>00087 tempQueue[qindex].flags.bits.special = 1;
|
|
<a name="l00088"></a>00088 tempQueue[qindex].flags.bits.valid = 1;
|
|
<a name="l00089"></a>00089 tempQueue[qindex].tag = <a class="code" href="../../d1/d72/moc__barrier__ppu_8c.html#8a4118b9364b4bb700441e9e9dd9c3ab">IMOC_BARRIER_TAG</a>;
|
|
<a name="l00090"></a>00090
|
|
<a name="l00091"></a>00091 <span class="comment">/* write message-envelope into queue */</span>
|
|
<a name="l00092"></a>00092 <span class="keywordflow">if</span> ((tag_id = mfc_tag_reserve()) == MFC_TAG_INVALID)
|
|
<a name="l00093"></a>00093 <span class="keywordflow">return</span> <a class="code" href="../../d8/da1/group__environment__error.html#g05b3a70831c823a59014c4853a76ca7e" title="Internal MOC (implementation) error.">MOC_ERR_INTERN</a>;
|
|
<a name="l00094"></a>00094 mfc_put(&tempQueue[qindex],
|
|
<a name="l00095"></a>00095 <a class="code" href="../../df/ddf/group__internal__am.html#gf9ad028ccbfa406c49a0ebd943486698" title="Effective base-address of own remote queue-entry at node &#39;rank&#39;.">IMOC_EA_REMOTE_QUEUE_ENTRY</a>(<a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.<a class="code" href="../../d8/d93/structmoc__node__handle__ppu__struct.html#3779cc1bda02c45a880389b109173778" title="number of overall processes">comm_size</a> - 1, qindex),
|
|
<a name="l00096"></a>00096 <span class="keyword">sizeof</span>(<a class="code" href="../../df/dd4/structmoc__message__envelope__struct.html" title="Message-envelope structure.">moc_message_envelope_t</a>), tag_id, 0, 0);
|
|
<a name="l00097"></a>00097 mfc_write_tag_mask(1 << tag_id);
|
|
<a name="l00098"></a>00098 mfc_read_tag_status_all();
|
|
<a name="l00099"></a>00099 mfc_tag_release(tag_id);
|
|
<a name="l00100"></a>00100
|
|
<a name="l00101"></a>00101 <span class="comment">//look up if there is data here</span>
|
|
<a name="l00102"></a>00102 sourceQueueEntry = 0;
|
|
<a name="l00103"></a>00103 <span class="keywordflow">while</span> (sourceQueueEntry == 0)
|
|
<a name="l00104"></a>00104 {
|
|
<a name="l00105"></a>00105 sourceQueueEntry = <a class="code" href="../../d8/d88/group__internal__p2p__main.html#g8980da77fa506e9a6d503c8c6eba68e2" title="Get the next valid message-envelope from &quot;source&quot; with specified &quot;tag&quot;...">IMOC_get_entry</a>(<a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.<a class="code" href="../../d8/d93/structmoc__node__handle__ppu__struct.html#3779cc1bda02c45a880389b109173778" title="number of overall processes">comm_size</a> - 1,
|
|
<a name="l00106"></a>00106 <a class="code" href="../../d1/d72/moc__barrier__ppu_8c.html#8a4118b9364b4bb700441e9e9dd9c3ab">IMOC_BARRIER_TAG</a>, comm, 1, &status);
|
|
<a name="l00107"></a>00107 }
|
|
<a name="l00108"></a>00108 sourceQueueEntry-><a class="code" href="../../df/dd4/structmoc__message__envelope__struct.html#38288113f9b7adee1e444850112ff807" title="flag-union">flags</a>.<a class="code" href="../../df/dd4/structmoc__message__envelope__struct.html#e51379150ad496c8844a4b9b0096120b" title="union-value">value</a> = 0;
|
|
<a name="l00109"></a>00109 }
|
|
<a name="l00110"></a>00110
|
|
<a name="l00111"></a>00111 <span class="keywordflow">return</span> 0;
|
|
<a name="l00112"></a>00112 }
|
|
<a name="l00113"></a>00113
|
|
</pre></div></div>
|
|
<hr size="1"><address style="text-align: right;"><small>Generated on Thu Feb 12 13:49:47 2009 for MPI On Cell (Documentation) by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img src="../../doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
|
|
</body>
|
|
</html>
|