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/ppu/communication/moc_bsend_ppu.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/ppu/communication/moc_bsend_ppu.c</h1><a href="../../d9/d14/moc__bsend__ppu_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
|
|
<a name="l00004"></a>00004 <span class="preprocessor">#include <<a class="code" href="../../d0/d3a/spu_2moc_8h.html">moc.h</a>></span>
|
|
<a name="l00005"></a>00005 <span class="preprocessor">#include <<a class="code" href="../../d9/db3/imoc_8h.html">internal/imoc.h</a>></span>
|
|
<a name="l00006"></a>00006 <span class="preprocessor">#include <<a class="code" href="../../d8/d98/imoc__macros__ppu_8h.html">internal/ppu/imoc_macros_ppu.h</a>></span>
|
|
<a name="l00007"></a>00007 <span class="preprocessor">#include <<a class="code" href="../../de/df9/imoc__dma__ppu_8h.html">internal/ppu/imoc_dma_ppu.h</a>></span>
|
|
<a name="l00008"></a>00008 <span class="preprocessor">#include <<a class="code" href="../../d6/d09/imoc__core__ppu_8h.html">internal/ppu/imoc_core_ppu.h</a>></span>
|
|
<a name="l00009"></a>00009
|
|
<a name="l00010"></a><a class="code" href="../../de/d84/group__p2p__buffered.html#g307bf844e1416c7c021e4a3468209d0b">00010</a> <span class="keywordtype">int</span> <a class="code" href="../../de/d84/group__p2p__buffered.html#g307bf844e1416c7c021e4a3468209d0b" title="Performs a blocking buffered mode send operation.">MOC_Bsend</a>(<span class="keywordtype">void</span>* buf, <span class="keywordtype">int</span> count, <a class="code" href="../../dc/d6e/group__p2p__datatype.html#gb4e45f15c08578bd3fc97c0cca2a509a" title="Typedef defining MOC_Datatype.">MOC_Datatype</a> datatype, <span class="keywordtype">int</span> dest, <span class="keywordtype">int</span> tag,
|
|
<a name="l00011"></a>00011 <a class="code" href="../../d1/dd1/group__comm__mgt.html#g3d2b8a9af65bff5f79d02bda13616767" title="Communicator-Handle.">MOC_Comm</a> comm)
|
|
<a name="l00012"></a>00012 {
|
|
<a name="l00013"></a>00013 <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="l00014"></a>00014 <span class="keywordtype">int</span> err, qindex, mid, bytecount;
|
|
<a name="l00015"></a>00015 <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> dmastatus;
|
|
<a name="l00016"></a>00016 <span class="keywordtype">void</span>* ea_buffer;
|
|
<a name="l00017"></a>00017
|
|
<a name="l00018"></a>00018 <span class="keywordflow">if</span> (((datatype & 0xF0) >> 4) == 0)
|
|
<a name="l00019"></a>00019 bytecount = count;
|
|
<a name="l00020"></a>00020 <span class="keywordflow">else</span>
|
|
<a name="l00021"></a>00021 bytecount = count * (((datatype & 0xF0) >> 4) * 2);
|
|
<a name="l00022"></a>00022
|
|
<a name="l00023"></a>00023 <a class="code" href="../../d3/d32/group__internal__tm.html#g615b65fb3c3ad16711686a178ac7d1c3" title="Tests if rank is MOC_PROC_NULL and returns with MOC_SUCCESS itself.">IMOC_TEST_PROC_NULL</a>(dest)
|
|
<a name="l00024"></a>00024 <a class="code" href="../../d3/d32/group__internal__tm.html#gf902b6e1cbe077abf0f8d02a488fec8a" title="Tests if rank is own rank and returns with MOC_SUCCESS itself.">IMOC_TEST_PROC_SELF</a>(dest)
|
|
<a name="l00025"></a>00025 <a class="code" href="../../d3/d32/group__internal__tm.html#g8026463e106a01cc8efb816d7dc1036a" title="Tests if invalid byte-count in a recv-operation.">IMOC_TEST_BYTECOUNT</a>(bytecount)
|
|
<a name="l00026"></a>00026 <span class="comment">// if there is no data, permit Null-Buffer-Pointer</span>
|
|
<a name="l00027"></a>00027 <span class="keywordflow">if</span> (bytecount != 0)
|
|
<a name="l00028"></a>00028 {
|
|
<a name="l00029"></a>00029 <a class="code" href="../../d3/d32/group__internal__tm.html#g52f61fd7f3253d10b740a9fc792052c6" title="Tests if invalid buffer-pointer.">IMOC_TEST_BUFFER</a>(buf)
|
|
<a name="l00030"></a>00030 }
|
|
<a name="l00031"></a>00031 <a class="code" href="../../d3/d32/group__internal__tm.html#g1dfddaa8f7d9aad32b00248c7dc782d2" title="Tests if invalid rank.">IMOC_TEST_RANK</a>(dest)
|
|
<a name="l00032"></a>00032 <a class="code" href="../../d3/d32/group__internal__tm.html#g49637a9f588e1c44584d8def5c45e811" title="Tests if invalid tag in a send-operation.">IMOC_TEST_TAG_SEND</a>(tag)
|
|
<a name="l00033"></a>00033 <a class="code" href="../../d3/d32/group__internal__tm.html#gfc07f5e570f47525b80a1f3e5a36b3b3" title="Tests if invalid communicator in a send-operation.">IMOC_TEST_COMM_SEND</a>(comm)
|
|
<a name="l00034"></a>00034
|
|
<a name="l00035"></a>00035 <span class="comment">/* Get queue from remote-node, choose fastest method depending on transfer-size */</span>
|
|
<a name="l00036"></a>00036 <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#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="l00037"></a>00037 > <a class="code" href="../../d8/d88/group__internal__p2p__main.html#ge9f5f9bdfa51d7683fbe312d4a667afd" title="Defines a treshold, when to use memcpy and when to use DMA in a get-operation on...">MEMCPY_GET_TRESHOLD</a>)
|
|
<a name="l00038"></a>00038 {
|
|
<a name="l00039"></a>00039 err = spe_mfcio_put(
|
|
<a name="l00040"></a>00040 <a class="code" href="../../dc/df1/group__internal__spu__thread.html#ga5b74732b1e31ec1674ea0e5ae465c4e" title="array of SPU-Threads.">moc_spu_thread_list</a>[dest - <a class="code" href="../../dc/df1/group__internal__spu__thread.html#gf4270da4dbf663fde50a876067ed0d52" title="actual number of PPU-Threads.">moc_ppu_thread_count</a>].speid,
|
|
<a name="l00041"></a>00041 <a class="code" href="../../df/ddf/group__internal__am.html#g48013d236aaa37226bbba460eaf3aca5" title="LS-Address of own remote queue at node &#39;rank&#39;.">IMOC_LS_REMOTE_QUEUE</a>(dest), 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 name="l00042"></a>00042 * <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>), 15, 0, 0);
|
|
<a name="l00043"></a>00043 <span class="keywordflow">if</span> (err)
|
|
<a name="l00044"></a>00044 <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="l00045"></a>00045 err = spe_mfcio_tag_status_read(<a class="code" href="../../dc/df1/group__internal__spu__thread.html#ga5b74732b1e31ec1674ea0e5ae465c4e" title="array of SPU-Threads.">moc_spu_thread_list</a>[dest
|
|
<a name="l00046"></a>00046 - <a class="code" href="../../dc/df1/group__internal__spu__thread.html#gf4270da4dbf663fde50a876067ed0d52" title="actual number of PPU-Threads.">moc_ppu_thread_count</a>].speid, 0, SPE_TAG_ALL, &dmastatus);
|
|
<a name="l00047"></a>00047 <span class="keywordflow">if</span> (err)
|
|
<a name="l00048"></a>00048 <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="l00049"></a>00049 }
|
|
<a name="l00050"></a>00050 <span class="keywordflow">else</span>
|
|
<a name="l00051"></a>00051 {
|
|
<a name="l00052"></a>00052 memcpy(tempQueue, (<span class="keywordtype">void</span>*) <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>(dest),
|
|
<a name="l00053"></a>00053 <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="l00054"></a>00054 }
|
|
<a name="l00055"></a>00055
|
|
<a name="l00056"></a>00056 <span class="comment">/* search free entry in message-queue */</span>
|
|
<a name="l00057"></a>00057 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, tag, comm, 0, &qindex);
|
|
<a name="l00058"></a>00058 <span class="keywordflow">if</span> (err)
|
|
<a name="l00059"></a>00059 <span class="keywordflow">return</span> err;
|
|
<a name="l00060"></a>00060
|
|
<a name="l00061"></a>00061 <span class="comment">/* messages smaller-equal 8 bytes are stored directly into the message-envelope</span>
|
|
<a name="l00062"></a>00062 <span class="comment"> instead of the data's effective address */</span>
|
|
<a name="l00063"></a>00063 <span class="keywordflow">if</span> (bytecount <= 8)
|
|
<a name="l00064"></a>00064 {
|
|
<a name="l00065"></a>00065 tempQueue[qindex].flags.bits.channel = <a class="code" href="../../dd/df8/group__internal__core.html#g1a3153033a1eaac0ddff04deac271947" title="Constant for moc_message_envelope_t.flags.channel.">IMOC_MESSAGE_CHANNEL_ENV</a>;
|
|
<a name="l00066"></a>00066 tempQueue[qindex].flags.bits.signal_back = 0;
|
|
<a name="l00067"></a>00067 tempQueue[qindex].flags.bits.in_mm = 0;
|
|
<a name="l00068"></a>00068 memcpy(&tempQueue[qindex].message_address, buf, bytecount);
|
|
<a name="l00069"></a>00069 }
|
|
<a name="l00070"></a>00070 <span class="keywordflow">else</span> <span class="comment">/* normal delivery of messages */</span>
|
|
<a name="l00071"></a>00071 {
|
|
<a name="l00072"></a>00072 <a class="code" href="../../d3/d32/group__internal__tm.html#gc89a1f53869fe90c838a714621e20d88" title="Tests if address is 16-byte aligned.">IMOC_TEST_ALIGNMENT</a>(buf)
|
|
<a name="l00073"></a>00073 <span class="comment">/* search free message-ID */</span>
|
|
<a name="l00074"></a>00074 err = <a class="code" href="../../d8/d88/group__internal__p2p__main.html#g409bdbea503611cf04829413d15830df" title="Get free message-ID.">IMOC_getFreeMID</a>(&mid);
|
|
<a name="l00075"></a>00075 <span class="keywordflow">if</span> (err)
|
|
<a name="l00076"></a>00076 <span class="keywordflow">return</span> err;
|
|
<a name="l00077"></a>00077
|
|
<a name="l00078"></a>00078 <span class="comment">/* search free buffer-space */</span>
|
|
<a name="l00079"></a>00079 ea_buffer = (<span class="keywordtype">void</span>*) <a class="code" href="../../d3/dd3/group__internal__p2p__bmalloc.html#g5295b372d853993b2e6cfb6912a0ee41" title="Allocate buffer-space.">IMOC_bmalloc</a>(bytecount, mid);
|
|
<a name="l00080"></a>00080 <span class="keywordflow">if</span> (!ea_buffer)
|
|
<a name="l00081"></a>00081 <span class="keywordflow">return</span> <a class="code" href="../../d8/da1/group__environment__error.html#gb3b13f443f9a869ef4200334eb8792d0" title="Insufficient Buffer-Space.">MOC_ERR_NO_BUFFER</a>;
|
|
<a name="l00082"></a>00082
|
|
<a name="l00083"></a>00083 tempQueue[qindex].flags.bits.channel = <a class="code" href="../../dd/df8/group__internal__core.html#gda23ff5baabe186f8c37c0424598c7bc" title="Constant for moc_message_envelope_t.flags.channel.">IMOC_MESSAGE_CHANNEL_DMA</a>;
|
|
<a name="l00084"></a>00084 tempQueue[qindex].flags.bits.signal_back = 1;
|
|
<a name="l00085"></a>00085 tempQueue[qindex].flags.bits.in_mm = 1;
|
|
<a name="l00086"></a>00086 tempQueue[qindex].message_address = (uint64_t) ea_buffer;
|
|
<a name="l00087"></a>00087 <span class="comment">/* copy data into buffer */</span>
|
|
<a name="l00088"></a>00088 memcpy(ea_buffer, buf, bytecount);
|
|
<a name="l00089"></a>00089
|
|
<a name="l00090"></a>00090 <span class="comment">/* fill message-status-entry */</span>
|
|
<a name="l00091"></a>00091 <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#abccbc7beefa7b1e2ccc84b8bd2b8805" title="base-address of own message-status-array">status_array_base</a>[mid].<a class="code" href="../../dd/df5/structmoc__message__status__struct.html#086c0d449d25774d43512b6f7fdab8ed" title="flag-union">flags</a>.<a class="code" href="../../dd/df5/structmoc__message__status__struct.html#c0bdc214525521d58f12c72874de0512" title="flag-struct">bits</a>.valid = 1;
|
|
<a name="l00092"></a>00092 <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#abccbc7beefa7b1e2ccc84b8bd2b8805" title="base-address of own message-status-array">status_array_base</a>[mid].<a class="code" href="../../dd/df5/structmoc__message__status__struct.html#086c0d449d25774d43512b6f7fdab8ed" title="flag-union">flags</a>.<a class="code" href="../../dd/df5/structmoc__message__status__struct.html#c0bdc214525521d58f12c72874de0512" title="flag-struct">bits</a>.outstanding = 1;
|
|
<a name="l00093"></a>00093 }
|
|
<a name="l00094"></a>00094
|
|
<a name="l00095"></a>00095 <span class="comment">/* fill missing message-envelope-entries */</span>
|
|
<a name="l00096"></a>00096 tempQueue[qindex].communicator = comm;
|
|
<a name="l00097"></a>00097 tempQueue[qindex].datatype = datatype;
|
|
<a name="l00098"></a>00098 tempQueue[qindex].id = mid;
|
|
<a name="l00099"></a>00099 tempQueue[qindex].size = bytecount;
|
|
<a name="l00100"></a>00100 tempQueue[qindex].tag = tag;
|
|
<a name="l00101"></a>00101 tempQueue[qindex].flags.bits.collaborative = 0;
|
|
<a name="l00102"></a>00102 tempQueue[qindex].flags.bits.special = 0;
|
|
<a name="l00103"></a>00103 tempQueue[qindex].flags.bits.valid = 1;
|
|
<a name="l00104"></a>00104 tempQueue[qindex].flags.bits.keep_valid = 0;
|
|
<a name="l00105"></a>00105
|
|
<a name="l00106"></a>00106 <span class="comment">/* write message-envelope into queue, because transfer-size is always 16-byte,</span>
|
|
<a name="l00107"></a>00107 <span class="comment"> * memcpy is fastest method */</span>
|
|
<a name="l00108"></a>00108 memcpy((<span class="keywordtype">void</span>*) <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>(dest, qindex),
|
|
<a name="l00109"></a>00109 &tempQueue[qindex], <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="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>
|