Files
MPIonCell/documentation/developer/html/df/df8/moc__issend__ppu_8c-source.html
2017-10-26 19:57:24 +02:00

139 lines
20 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_issend_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&nbsp;Page</span></a></li>
<li><a href="../../modules.html"><span>Modules</span></a></li>
<li><a href="../../annotated.html"><span>Data&nbsp;Structures</span></a></li>
<li class="current"><a href="../../files.html"><span>Files</span></a></li>
</ul>
</div>
<h1>src/ppu/communication/moc_issend_ppu.c</h1><a href="../../dc/d02/moc__issend__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 &lt;stdio.h&gt;</span>
<a name="l00002"></a>00002 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00003"></a>00003
<a name="l00004"></a>00004 <span class="preprocessor">#include &lt;<a class="code" href="../../d0/d3a/spu_2moc_8h.html">moc.h</a>&gt;</span>
<a name="l00005"></a>00005 <span class="preprocessor">#include &lt;<a class="code" href="../../d8/de2/moc__datatype__ppu_8h.html">ppu/moc_datatype_ppu.h</a>&gt;</span>
<a name="l00006"></a>00006 <span class="preprocessor">#include &lt;<a class="code" href="../../d9/db3/imoc_8h.html">internal/imoc.h</a>&gt;</span>
<a name="l00007"></a>00007 <span class="preprocessor">#include &lt;<a class="code" href="../../d8/d98/imoc__macros__ppu_8h.html">internal/ppu/imoc_macros_ppu.h</a>&gt;</span>
<a name="l00008"></a>00008 <span class="preprocessor">#include &lt;<a class="code" href="../../d6/d09/imoc__core__ppu_8h.html">internal/ppu/imoc_core_ppu.h</a>&gt;</span>
<a name="l00009"></a>00009
<a name="l00010"></a><a class="code" href="../../d7/d62/group__p2p__imm.html#gc148ff9b9bee69164139425a7df53697">00010</a> <span class="keywordtype">int</span> <a class="code" href="../../d7/d62/group__p2p__imm.html#gc148ff9b9bee69164139425a7df53697" title="Performs a non-blocking synchronous mode send operation.">MOC_ISsend</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 class="code" href="../../db/d17/structmoc__request__struct.html" title="Communication-Request (Handle).">MOC_Request</a> *request)
<a name="l00012"></a>00012 {
<a name="l00013"></a>00013 <span class="keywordtype">int</span> queue_index, msg_id, bytecount, err;
<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> queue_copy[<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(&amp;quot;No nodes in list\n&amp;quot;);...">__attribute__</a>((__aligned__(16)));
<a name="l00015"></a>00015
<a name="l00016"></a>00016 uint32_t dmastatus;
<a name="l00017"></a>00017
<a name="l00018"></a>00018 <span class="keywordflow">if</span> (((datatype &amp; 0xF0) &gt;&gt; 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 &amp; 0xF0) &gt;&gt; 4) * 2);
<a name="l00022"></a>00022
<a name="l00023"></a>00023 request-&gt;<a class="code" href="../../db/d17/structmoc__request__struct.html#4878ce199375f8a411520c887f908a4f">request_data</a>.<a class="code" href="../../db/d17/structmoc__request__struct.html#47db330291fdf4864201fe106ec53db8">issend_request</a>.<a class="code" href="../../d9/d89/structimoc__issend__request__struct.html#db3150d28936af45c475ec5c9fb65cd8">isFinished</a> = 1;
<a name="l00024"></a>00024 request-&gt;<a class="code" href="../../db/d17/structmoc__request__struct.html#56ab14d3df6e8c232e66aec78be949f3">request_type</a> = <a class="code" href="../../d7/d41/group__internal__p2p__imm.html#g755884e41591a0d838f45b04f3a92ab9" title="MOC_Request is associated with aISsend-Communication.">MOC_REQ_TYPE_ISSEND</a>;
<a name="l00025"></a>00025 request-&gt;<a class="code" href="../../db/d17/structmoc__request__struct.html#4878ce199375f8a411520c887f908a4f">request_data</a>.<a class="code" href="../../db/d17/structmoc__request__struct.html#47db330291fdf4864201fe106ec53db8">issend_request</a>.<a class="code" href="../../d9/d89/structimoc__issend__request__struct.html#2cfe5aa07e2fc69eff15e0e65da4efea">source</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#9005ee3d6d0ee8b2f15628dcca724710" title="rank of node">rank</a>;
<a name="l00026"></a>00026 request-&gt;<a class="code" href="../../db/d17/structmoc__request__struct.html#4878ce199375f8a411520c887f908a4f">request_data</a>.<a class="code" href="../../db/d17/structmoc__request__struct.html#47db330291fdf4864201fe106ec53db8">issend_request</a>.<a class="code" href="../../d9/d89/structimoc__issend__request__struct.html#526dc209a5b20ff98169e0803812fbb1">tag</a> = tag;
<a name="l00027"></a>00027 request-&gt;<a class="code" href="../../db/d17/structmoc__request__struct.html#4878ce199375f8a411520c887f908a4f">request_data</a>.<a class="code" href="../../db/d17/structmoc__request__struct.html#47db330291fdf4864201fe106ec53db8">issend_request</a>.<a class="code" href="../../d9/d89/structimoc__issend__request__struct.html#942c10dc3d21a8830d7714a4018cd42b">message_size</a> = bytecount;
<a name="l00028"></a>00028
<a name="l00029"></a>00029 <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="l00030"></a>00030 <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="l00031"></a>00031 <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="l00032"></a>00032 <span class="comment">// if there is no data, permit Null-Buffer-Pointer</span>
<a name="l00033"></a>00033 <span class="keywordflow">if</span> (bytecount != 0)
<a name="l00034"></a>00034 {
<a name="l00035"></a>00035 <a class="code" href="../../d3/d32/group__internal__tm.html#g52f61fd7f3253d10b740a9fc792052c6" title="Tests if invalid buffer-pointer.">IMOC_TEST_BUFFER</a>(buf)
<a name="l00036"></a>00036 }
<a name="l00037"></a>00037 <a class="code" href="../../d3/d32/group__internal__tm.html#g1dfddaa8f7d9aad32b00248c7dc782d2" title="Tests if invalid rank.">IMOC_TEST_RANK</a>(dest)
<a name="l00038"></a>00038 <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="l00039"></a>00039 <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="l00040"></a>00040
<a name="l00041"></a>00041 <span class="comment">/* Get queue from remote-node, choose fastest method depending on transfer-size */</span>
<a name="l00042"></a>00042 <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="l00043"></a>00043 &gt; <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="l00044"></a>00044 {
<a name="l00045"></a>00045 err = spe_mfcio_put(
<a name="l00046"></a>00046 <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="l00047"></a>00047 <a class="code" href="../../df/ddf/group__internal__am.html#g48013d236aaa37226bbba460eaf3aca5" title="LS-Address of own remote queue at node &amp;#39;rank&amp;#39;.">IMOC_LS_REMOTE_QUEUE</a>(dest), queue_copy, <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="l00048"></a>00048 * <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="l00049"></a>00049 <span class="keywordflow">if</span> (err)
<a name="l00050"></a>00050 <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="l00051"></a>00051 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="l00052"></a>00052 - <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, &amp;dmastatus);
<a name="l00053"></a>00053 <span class="keywordflow">if</span> (err)
<a name="l00054"></a>00054 <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="l00055"></a>00055 }
<a name="l00056"></a>00056 <span class="keywordflow">else</span>
<a name="l00057"></a>00057 {
<a name="l00058"></a>00058 memcpy(queue_copy, (<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 &amp;#39;rank&amp;#39;.">IMOC_EA_REMOTE_QUEUE</a>(dest),
<a name="l00059"></a>00059 <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="l00060"></a>00060 }
<a name="l00061"></a>00061
<a name="l00062"></a>00062 <span class="comment">/* search free entry in message-queue */</span>
<a name="l00063"></a>00063 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>(queue_copy, tag, comm, 0, &amp;queue_index);
<a name="l00064"></a>00064 <span class="keywordflow">if</span> (err)
<a name="l00065"></a>00065 <span class="keywordflow">return</span> err;
<a name="l00066"></a>00066
<a name="l00067"></a>00067 <span class="comment">/* search free message-ID */</span>
<a name="l00068"></a>00068 err = <a class="code" href="../../d8/d88/group__internal__p2p__main.html#g409bdbea503611cf04829413d15830df" title="Get free message-ID.">IMOC_getFreeMID</a>(&amp;msg_id);
<a name="l00069"></a>00069 <span class="keywordflow">if</span> (err)
<a name="l00070"></a>00070 <span class="keywordflow">return</span> err;
<a name="l00071"></a>00071
<a name="l00072"></a>00072 <span class="comment">/* small messages are directly sent instead of their address */</span>
<a name="l00073"></a>00073 <span class="keywordflow">if</span> (bytecount &lt;= 8)
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075 queue_copy[queue_index].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="l00076"></a>00076 <span class="comment">// synchronous send waits till the message has been received (meaning</span>
<a name="l00077"></a>00077 <span class="comment">// recv has copied the message), so we need a signal-back.</span>
<a name="l00078"></a>00078 queue_copy[queue_index].flags.bits.signal_back = 1;
<a name="l00079"></a>00079 queue_copy[queue_index].flags.bits.in_mm = 0;
<a name="l00080"></a>00080 memcpy(&amp;queue_copy[queue_index].message_address, buf, bytecount);
<a name="l00081"></a>00081 }
<a name="l00082"></a>00082 <span class="keywordflow">else</span>
<a name="l00083"></a>00083 {
<a name="l00084"></a>00084 <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="l00085"></a>00085 queue_copy[queue_index].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="l00086"></a>00086 queue_copy[queue_index].flags.bits.signal_back = 1;
<a name="l00087"></a>00087 queue_copy[queue_index].flags.bits.in_mm = 1;
<a name="l00088"></a>00088 queue_copy[queue_index].message_address = (uint64_t) buf;
<a name="l00089"></a>00089 }
<a name="l00090"></a>00090
<a name="l00091"></a>00091 <span class="comment">/* fill missing message-envelope-entries */</span>
<a name="l00092"></a>00092 queue_copy[queue_index].communicator = comm;
<a name="l00093"></a>00093 queue_copy[queue_index].datatype = datatype;
<a name="l00094"></a>00094 queue_copy[queue_index].id = msg_id;
<a name="l00095"></a>00095 queue_copy[queue_index].size = bytecount;
<a name="l00096"></a>00096 queue_copy[queue_index].tag = tag;
<a name="l00097"></a>00097 queue_copy[queue_index].flags.bits.collaborative = 0;
<a name="l00098"></a>00098 queue_copy[queue_index].flags.bits.special = 0;
<a name="l00099"></a>00099 queue_copy[queue_index].flags.bits.valid = 1;
<a name="l00100"></a>00100 queue_copy[queue_index].flags.bits.keep_valid = 1;
<a name="l00101"></a>00101
<a name="l00102"></a>00102 <span class="comment">/* fill message-status-entry */</span>
<a name="l00103"></a>00103 <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>[msg_id].<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="l00104"></a>00104 <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>[msg_id].<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="l00105"></a>00105
<a name="l00106"></a>00106 request-&gt;<a class="code" href="../../db/d17/structmoc__request__struct.html#4878ce199375f8a411520c887f908a4f">request_data</a>.<a class="code" href="../../db/d17/structmoc__request__struct.html#47db330291fdf4864201fe106ec53db8">issend_request</a>.<a class="code" href="../../d9/d89/structimoc__issend__request__struct.html#db3150d28936af45c475ec5c9fb65cd8">isFinished</a> = 0;
<a name="l00107"></a>00107 request-&gt;<a class="code" href="../../db/d17/structmoc__request__struct.html#4878ce199375f8a411520c887f908a4f">request_data</a>.<a class="code" href="../../db/d17/structmoc__request__struct.html#47db330291fdf4864201fe106ec53db8">issend_request</a>.<a class="code" href="../../d9/d89/structimoc__issend__request__struct.html#53cf82f3cdd5ddb731296d3c494d4958">mid</a> = msg_id;
<a name="l00108"></a>00108
<a name="l00109"></a>00109 <span class="comment">/* write message-envelope into queue, because transfer-size is always 16-byte,</span>
<a name="l00110"></a>00110 <span class="comment"> * memcpy is fastest method */</span>
<a name="l00111"></a>00111 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 &amp;#39;rank&amp;#39;.">IMOC_EA_REMOTE_QUEUE_ENTRY</a>(dest, queue_index),
<a name="l00112"></a>00112 &amp;queue_copy[queue_index], <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="l00113"></a>00113
<a name="l00114"></a>00114 <span class="keywordflow">return</span> <a class="code" href="../../d8/da1/group__environment__error.html#g8a73ed6676bcf0c0607d98482ca1aca4" title="No error.">MOC_SUCCESS</a>;
<a name="l00115"></a>00115 }
<a name="l00116"></a>00116
</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&nbsp;
<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>