133 lines
18 KiB
HTML
Executable File
133 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_issend_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_issend_spu.c</h1><a href="../../de/d76/moc__issend__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 <string.h></span>
|
|
<a name="l00002"></a>00002 <span class="preprocessor">#include <stdio.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="../../d0/d1d/moc__datatype__spu_8h.html">spu/moc_datatype_spu.h</a>></span>
|
|
<a name="l00007"></a>00007 <span class="preprocessor">#include <<a class="code" href="../../d9/db3/imoc_8h.html">internal/imoc.h</a>></span>
|
|
<a name="l00008"></a>00008 <span class="preprocessor">#include <<a class="code" href="../../d2/d42/imoc__macros_8h.html">internal/imoc_macros.h</a>></span>
|
|
<a name="l00009"></a>00009 <span class="preprocessor">#include <<a class="code" href="../../d4/dce/imoc__dma__spu_8h.html">internal/spu/imoc_dma_spu.h</a>></span>
|
|
<a name="l00010"></a>00010 <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="l00011"></a>00011
|
|
<a name="l00012"></a><a class="code" href="../../d7/d62/group__p2p__imm.html#gc148ff9b9bee69164139425a7df53697">00012</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="l00013"></a>00013 <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="l00014"></a>00014 {
|
|
<a name="l00015"></a>00015 <span class="keywordtype">int</span> queue_index, msg_id, bytecount, err;
|
|
<a name="l00016"></a>00016 <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(&quot;No nodes in list\n&quot;);...">__attribute__</a>((__aligned__(16)));
|
|
<a name="l00017"></a>00017
|
|
<a name="l00018"></a>00018 uint32_t tag_id;
|
|
<a name="l00019"></a>00019
|
|
<a name="l00020"></a>00020 <span class="keywordflow">if</span> (((datatype & 0xF0) >> 4) == 0)
|
|
<a name="l00021"></a>00021 bytecount = count;
|
|
<a name="l00022"></a>00022 <span class="keywordflow">else</span>
|
|
<a name="l00023"></a>00023 bytecount = count * (((datatype & 0xF0) >> 4) * 2);
|
|
<a name="l00024"></a>00024
|
|
<a name="l00025"></a>00025 request-><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="l00026"></a>00026 request-><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="l00027"></a>00027 request-><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="l00028"></a>00028 request-><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="l00029"></a>00029 request-><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="l00030"></a>00030
|
|
<a name="l00031"></a>00031 <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="l00032"></a>00032 <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="l00033"></a>00033 <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="l00034"></a>00034 <span class="comment">// if there is no data, permit Null-Buffer-Pointer</span>
|
|
<a name="l00035"></a>00035 <span class="keywordflow">if</span> (bytecount != 0)
|
|
<a name="l00036"></a>00036 {
|
|
<a name="l00037"></a>00037 <a class="code" href="../../d3/d32/group__internal__tm.html#g52f61fd7f3253d10b740a9fc792052c6" title="Tests if invalid buffer-pointer.">IMOC_TEST_BUFFER</a>(buf)
|
|
<a name="l00038"></a>00038 <span class="keywordflow">if</span> (bytecount > 16)
|
|
<a name="l00039"></a>00039 <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="l00040"></a>00040 }
|
|
<a name="l00041"></a>00041 <a class="code" href="../../d3/d32/group__internal__tm.html#g1dfddaa8f7d9aad32b00248c7dc782d2" title="Tests if invalid rank.">IMOC_TEST_RANK</a>(dest)
|
|
<a name="l00042"></a>00042 <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="l00043"></a>00043 <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="l00044"></a>00044
|
|
<a name="l00045"></a>00045 <span class="keywordflow">if</span> ((tag_id = mfc_tag_reserve()) == MFC_TAG_INVALID)
|
|
<a name="l00046"></a>00046 {
|
|
<a name="l00047"></a>00047 <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="l00048"></a>00048 }
|
|
<a name="l00049"></a>00049
|
|
<a name="l00050"></a>00050 mfc_get(queue_copy, <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="l00051"></a>00051 <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 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>, tag_id, 0,
|
|
<a name="l00052"></a>00052 0);
|
|
<a name="l00053"></a>00053 mfc_write_tag_mask(1 << tag_id);
|
|
<a name="l00054"></a>00054 mfc_read_tag_status_all();
|
|
<a name="l00055"></a>00055
|
|
<a name="l00056"></a>00056 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, &queue_index);
|
|
<a name="l00057"></a>00057 <span class="keywordflow">if</span> (err)
|
|
<a name="l00058"></a>00058 <span class="keywordflow">return</span> err;
|
|
<a name="l00059"></a>00059
|
|
<a name="l00060"></a>00060 err = <a class="code" href="../../d8/d88/group__internal__p2p__main.html#g409bdbea503611cf04829413d15830df" title="Get free message-ID.">IMOC_getFreeMID</a>(&msg_id);
|
|
<a name="l00061"></a>00061 <span class="keywordflow">if</span> (err)
|
|
<a name="l00062"></a>00062 <span class="keywordflow">return</span> err;
|
|
<a name="l00063"></a>00063
|
|
<a name="l00064"></a>00064 <span class="comment">/* small messages are directly sent instead of their address */</span>
|
|
<a name="l00065"></a>00065 <span class="keywordflow">if</span> (bytecount <= 8)
|
|
<a name="l00066"></a>00066 {
|
|
<a name="l00067"></a>00067 <span class="comment">//printf("SPU: sending in message-envelope\n");</span>
|
|
<a name="l00068"></a>00068 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="l00069"></a>00069 <span class="comment">// synchronous send waits till the message has been received (meaning</span>
|
|
<a name="l00070"></a>00070 <span class="comment">// recv has copied the message), so we need a signal-back.</span>
|
|
<a name="l00071"></a>00071 queue_copy[queue_index].flags.bits.signal_back = 1;
|
|
<a name="l00072"></a>00072 queue_copy[queue_index].flags.bits.in_mm = 0;
|
|
<a name="l00073"></a>00073 memcpy(&queue_copy[queue_index].message_address, buf, bytecount);
|
|
<a name="l00074"></a>00074 }
|
|
<a name="l00075"></a>00075 <span class="keywordflow">else</span>
|
|
<a name="l00076"></a>00076 {
|
|
<a name="l00077"></a>00077 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="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 queue_copy[queue_index].message_address = <a class="code" href="../../dd/df8/group__internal__core.html#geed5a271d50368d3cf9a858c4f57c895" title="Information each node knowns about himself and the world.">node_handle</a>.ls_base
|
|
<a name="l00081"></a>00081 + (uint32_t) buf;
|
|
<a name="l00082"></a>00082 }
|
|
<a name="l00083"></a>00083
|
|
<a name="l00084"></a>00084 <span class="comment">/* fill missing message-envelope-entries */</span>
|
|
<a name="l00085"></a>00085 queue_copy[queue_index].communicator = comm;
|
|
<a name="l00086"></a>00086 queue_copy[queue_index].datatype = datatype;
|
|
<a name="l00087"></a>00087 queue_copy[queue_index].id = msg_id;
|
|
<a name="l00088"></a>00088 queue_copy[queue_index].size = bytecount;
|
|
<a name="l00089"></a>00089 queue_copy[queue_index].tag = tag;
|
|
<a name="l00090"></a>00090 queue_copy[queue_index].flags.bits.collaborative = 0;
|
|
<a name="l00091"></a>00091 queue_copy[queue_index].flags.bits.special = 0;
|
|
<a name="l00092"></a>00092 queue_copy[queue_index].flags.bits.valid = 1;
|
|
<a name="l00093"></a>00093 queue_copy[queue_index].flags.bits.keep_valid = 1;
|
|
<a name="l00094"></a>00094
|
|
<a name="l00095"></a>00095 <span class="comment">/* fill message-status-entry */</span>
|
|
<a name="l00096"></a>00096 <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="l00097"></a>00097 <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="l00098"></a>00098
|
|
<a name="l00099"></a>00099 mfc_put(&queue_copy[queue_index], <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,
|
|
<a name="l00100"></a>00100 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>), tag_id, 0, 0);
|
|
<a name="l00101"></a>00101 mfc_write_tag_mask(1 << tag_id);
|
|
<a name="l00102"></a>00102 mfc_read_tag_status_all();
|
|
<a name="l00103"></a>00103 mfc_tag_release(tag_id);
|
|
<a name="l00104"></a>00104
|
|
<a name="l00105"></a>00105 request-><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="l00106"></a>00106 request-><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="l00107"></a>00107
|
|
<a name="l00108"></a>00108 <span class="keywordflow">return</span> <a class="code" href="../../d8/da1/group__environment__error.html#g8a73ed6676bcf0c0607d98482ca1aca4" title="No error.">MOC_SUCCESS</a>;
|
|
<a name="l00109"></a>00109 }
|
|
<a name="l00110"></a>00110
|
|
</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>
|