92 lines
16 KiB
HTML
Executable File
92 lines
16 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/system/moc_init_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/system/moc_init_spu.c</h1><a href="../../d4/de2/moc__init__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 <stdlib.h></span>
|
|
<a name="l00002"></a>00002 <span class="preprocessor">#include <string.h></span>
|
|
<a name="l00003"></a>00003 <span class="preprocessor">#include <malloc_align.h></span>
|
|
<a name="l00004"></a>00004 <span class="preprocessor">#include <free_align.h></span>
|
|
<a name="l00005"></a>00005 <span class="preprocessor">#include <stdio.h></span>
|
|
<a name="l00006"></a>00006 <span class="preprocessor">#include <spu_mfcio.h></span>
|
|
<a name="l00007"></a>00007
|
|
<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 <span class="preprocessor">#include <<a class="code" href="../../d9/db3/imoc_8h.html">internal/imoc.h</a>></span>
|
|
<a name="l00010"></a>00010 <span class="preprocessor">#include <<a class="code" href="../../d0/d3a/spu_2moc_8h.html">spu/moc.h</a>></span>
|
|
<a name="l00011"></a>00011
|
|
<a name="l00012"></a><a class="code" href="../../d4/de2/moc__init__spu_8c.html#ee36daffc6d5276cabe2b44afeb35ece">00012</a> <span class="keywordtype">int</span> <a class="code" href="../../d8/d9a/group__environment__startup.html#g9a59090c9d03e89f019e8276d4013c72" title="Initialize the MPI execution environment.">MOC_Init</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">long</span> <span class="keywordtype">long</span> argp <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>((unused)), <span class="keywordtype">int</span> length <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>((unused)), <span class="keywordtype">void</span>* buffer <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>((unused)) )
|
|
<a name="l00013"></a>00013 {
|
|
<a name="l00014"></a>00014 <span class="keywordtype">char</span> temp[24];
|
|
<a name="l00015"></a>00015 uint32_t tag_id;
|
|
<a name="l00016"></a>00016 <span class="comment">/* wait till four messages from PPU are received */</span>
|
|
<a name="l00017"></a>00017 <span class="keywordflow">while</span> (spu_stat_in_mbox() < 4)
|
|
<a name="l00018"></a>00018 ;
|
|
<a name="l00019"></a>00019 <span class="comment">/* read messages */</span>
|
|
<a name="l00020"></a>00020 *((uint32_t*) &temp[0]) = spu_read_in_mbox();
|
|
<a name="l00021"></a>00021 *((uint32_t*) &temp[4]) = spu_read_in_mbox();
|
|
<a name="l00022"></a>00022 *((uint32_t*) &temp[8]) = spu_read_in_mbox();
|
|
<a name="l00023"></a>00023 *((uint32_t*) &temp[12]) = spu_read_in_mbox();
|
|
<a name="l00024"></a>00024 <span class="comment">/* wait till two messages from PPU are received */</span>
|
|
<a name="l00025"></a>00025 <span class="keywordflow">while</span> (spu_stat_in_mbox() < 2)
|
|
<a name="l00026"></a>00026 ;
|
|
<a name="l00027"></a>00027 <span class="comment">/* read messages */</span>
|
|
<a name="l00028"></a>00028 *((uint32_t*) &temp[16]) = spu_read_in_mbox();
|
|
<a name="l00029"></a>00029 *((uint32_t*) &temp[20]) = spu_read_in_mbox();
|
|
<a name="l00030"></a>00030 <span class="comment">/* create own node-handle and data-structures */</span>
|
|
<a name="l00031"></a>00031 <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> = temp[0];
|
|
<a name="l00032"></a>00032 <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> = temp[1];
|
|
<a name="l00033"></a>00033 <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> = temp[2];
|
|
<a name="l00034"></a>00034 <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#90096c2a63d01f0251fdd6c642601f45" title="size of own buffer">buffer_size</a> = *((uint32_t*) &temp[4]);
|
|
<a name="l00035"></a>00035 <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#ee118aad604058291438923545af37db" title="base-address of own buffer">buffer_base</a> = *((uint64_t*) &temp[8]);
|
|
<a name="l00036"></a>00036 <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 = *((uint64_t*) &temp[16]);
|
|
<a name="l00037"></a>00037 <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#58ca7dd0e2874d0317038dbb0c279b82" title="base-address of own message-queues">message_queue_base</a> = _malloc_align(
|
|
<a name="l00038"></a>00038 <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#3779cc1bda02c45a880389b109173778" title="number of overall processes">comm_size</a> - 1)
|
|
<a name="l00039"></a>00039 * <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>, 4);
|
|
<a name="l00040"></a>00040 <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#58ca7dd0e2874d0317038dbb0c279b82" title="base-address of own message-queues">message_queue_base</a> == 0)
|
|
<a name="l00041"></a>00041 <span class="keywordflow">return</span> <a class="code" href="../../d8/da1/group__environment__error.html#gfd59894aba31d32eeff506d8df838089" title="Insufficient Memory.">MOC_ERR_NO_MEMORY</a>;
|
|
<a name="l00042"></a>00042 <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> = _malloc_align(<span class="keyword">sizeof</span>(<a class="code" href="../../dd/df5/structmoc__message__status__struct.html" title="Message-status structure.">moc_message_status_t</a>)
|
|
<a name="l00043"></a>00043 * (<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 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>, 4);
|
|
<a name="l00044"></a>00044 <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#abccbc7beefa7b1e2ccc84b8bd2b8805" title="base-address of own message-status-array">status_array_base</a> == 0)
|
|
<a name="l00045"></a>00045 <span class="keywordflow">return</span> <a class="code" href="../../d8/da1/group__environment__error.html#gfd59894aba31d32eeff506d8df838089" title="Insufficient Memory.">MOC_ERR_NO_MEMORY</a>;
|
|
<a name="l00046"></a>00046 <span class="comment">/* send memory addresses of message-queue and status-array to PPU */</span>
|
|
<a name="l00047"></a>00047 spu_write_out_mbox((uint32_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#58ca7dd0e2874d0317038dbb0c279b82" title="base-address of own message-queues">message_queue_base</a>);
|
|
<a name="l00048"></a>00048 spu_write_out_mbox((uint32_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#abccbc7beefa7b1e2ccc84b8bd2b8805" title="base-address of own message-status-array">status_array_base</a>);
|
|
<a name="l00049"></a>00049 <span class="comment">/* allocate space for process-list */</span>
|
|
<a name="l00050"></a>00050 <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#528d5743c1b49553cc9b812a211afa53" title="list of all other MOC-processes (index is rank of process)">moc_process_list</a> = _malloc_align(<span class="keyword">sizeof</span>(<a class="code" href="../../d0/db8/structmoc__process__struct.html" title="Process-information structure.">moc_process_t</a>)
|
|
<a name="l00051"></a>00051 * <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>, 4);
|
|
<a name="l00052"></a>00052 <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#528d5743c1b49553cc9b812a211afa53" title="list of all other MOC-processes (index is rank of process)">moc_process_list</a> == 0)
|
|
<a name="l00053"></a>00053 <span class="keywordflow">return</span> <a class="code" href="../../d8/da1/group__environment__error.html#gfd59894aba31d32eeff506d8df838089" title="Insufficient Memory.">MOC_ERR_NO_MEMORY</a>;
|
|
<a name="l00054"></a>00054 <span class="comment">/* receive memory-address of prozess-list in main-memory from PPU */</span>
|
|
<a name="l00055"></a>00055 <span class="keywordflow">while</span> (spu_stat_in_mbox() < 2)
|
|
<a name="l00056"></a>00056 ;
|
|
<a name="l00057"></a>00057 *((uint32_t*) &temp[0]) = spu_read_in_mbox();
|
|
<a name="l00058"></a>00058 *((uint32_t*) &temp[4]) = spu_read_in_mbox();
|
|
<a name="l00059"></a>00059 <span class="comment">/* get process-list from main-memory via DMA */</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_get((<span class="keywordtype">void</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#528d5743c1b49553cc9b812a211afa53" title="list of all other MOC-processes (index is rank of process)">moc_process_list</a>, *((uint64_t*) &temp[0]),
|
|
<a name="l00063"></a>00063 <span class="keyword">sizeof</span>(<a class="code" href="../../d0/db8/structmoc__process__struct.html" title="Process-information structure.">moc_process_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#3779cc1bda02c45a880389b109173778" title="number of overall processes">comm_size</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 <span class="keywordflow">return</span> 0;
|
|
<a name="l00068"></a>00068 }
|
|
<a name="l00069"></a>00069
|
|
</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>
|