<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>RC-Lab</title>
	<atom:link href="http://ccom.uprrp.edu/~rarce/wp/wordpress/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://ccom.uprrp.edu/~rarce/wp/wordpress</link>
	<description>Reconfigurable Computing Laboratory @ UPR-RP</description>
	<lastBuildDate>Tue, 20 Nov 2012 02:47:50 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>One simple problem, (too) many solutions with MitrionC</title>
		<link>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=103</link>
		<comments>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=103#comments</comments>
		<pubDate>Wed, 22 Sep 2010 22:15:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MitrionC]]></category>

		<guid isPermaLink="false">http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=103</guid>
		<description><![CDATA[In preparation to tackle a bigger problem, I decided to code a MitrionC program that does the following: reads MEMSIZE numbers from an external memory and writes them to an internal memory (I call these numbers the &#8216;database&#8217;) reads 1 &#8230; <a href="http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=103">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>In preparation to tackle a bigger problem, I decided to code a MitrionC program that does the following:</p>
<ol>
<li>reads MEMSIZE numbers from an external memory and writes them to an internal memory (I call these numbers the &#8216;database&#8217;)
<li>reads 1 number from another external memory (I call this number the &#8216;query&#8217;)
<li>determine if the query is equal to any of the database numbers.
</ol>
<hr />
<h4>Attempt #1</h4>
<pre>
Mitrion-C 1.5;

MEMSIZE = 100;
MemElem = typedef int:8;

AttRAM = typedef mem MemElem[MEMSIZE];


(bool ,AttRAM ) main(AttRAM RAM0_it0, AttRAM RAM1_it0)
{

    LUT_it0 = _memcreate(mem MemElem[MEMSIZE] LUT_it_last);
    LUT_it_last = LUT_it0;
    AttRAM  LUT_it3 = LUT_it0;


    (MemElem<MEMSIZE> list, LUT_it2) =
    foreach (i in <0 .. MEMSIZE-1>)
    {
	    d = memread(RAM0_it0, i);
	    LUT_it1 = memwrite(LUT_it0,d,i);
    } (d,LUT_it1);
    
    MemElem query = memread(RAM1_it0, 0);
    
    bool e = false;
    (found,LUT_it4)= for (i in <0 .. MEMSIZE-1>) {
    //found = for (element in list) {
	(element,LUT_it3) = memread(LUT_it2, i);
	e = if ( element == query) true else e;
    } (e,LUT_it3) ;

} (found, LUT_it4);

</pre>
<p><u>Observations:</u><br />
Too sequential!!</p>
<p><u>Results:</u></p>
<table border="1">
<tr>
<td>MEMSIZE</td>
<td>CYCLES</td>
</tr>
<tr>
<td>10</td>
<td>79</td>
</tr>
<tr>
<td>20</td>
<td>142</td>
</tr>
<tr>
<td>30</td>
<td>204</td>
</tr>
<tr>
<td>40</td>
<td>267</td>
</tr>
<tr>
<td>100</td>
<td>642</td>
</tr>
</table>
<p><!-- ================================================================ --></p>
<hr />
<h4>Attempt #2</h4>
<pre>
Mitrion-C 1.5;

/*
Given a list of size LISTSIZE determine if it contains duplicates.
Version 2.
*/

LISTSIZE = 10;
ElemType = typedef int:8;


(bool) main(ElemType <LISTSIZE> list)
{
    vector = reformat(list, [LISTSIZE]);
    comp_list_of_lists = foreach (e,i in list  ,<0 .. LISTSIZE-1>) {
        comp_list = foreach(f,j in vector,[0 .. LISTSIZE-1]) {
            comp = ( (i!=j) &#038;&#038; (f == e));
        } comp;
    } comp_list;
    
    gathered_comp_list = foreach (e  in comp_list_of_lists) {
        temp_vector = reformat(e, [LISTSIZE]);
        bits:LISTSIZE scalar = temp_vector;
        f = if ((uint:LISTSIZE)scalar != 0) true else false;
    } f;
    
    regathered_comp_list = reformat(gathered_comp_list, [LISTSIZE]);
    bits:LISTSIZE scalar = regathered_comp_list;
    bool found = if ((uint:LISTSIZE)scalar  != 0) true else false;
    watch found;
} found;
</pre>
<p><u>Observations:</u><br />
Creates MEMSIZE structures in parallel. For example, here&#8217;s the resulting structure for MEMSIZE=10.</p>
<p><u>Results:</u></p>
<table border="1">
<tr>
<td>MEMSIZE</td>
<td>CYCLES</td>
</tr>
<tr>
<td>10</td>
<td>60</td>
</tr>
<tr>
<td>20</td>
<td>80</td>
</tr>
<tr>
<td>30</td>
<td>100</td>
</tr>
<tr>
<td>100</td>
<td>240</td>
</tr>
</table>
<p><!-- ================================================================ --></p>
<hr />
<h4>Attempt #3</h4>
<pre>
Mitrion-C 1.5;

MEMSIZE = 10;
SEARCHSIZE = 10;
MemElem = typedef int:8;
bits:SEARCHSIZE ZERO = 0x000;

AttRAM = typedef mem MemElem[MEMSIZE];

(bool) main(AttRAM RAM0_it0, AttRAM RAM1_it0)
{
    // This is the internal memory
    LUT_it0 = _memcreate(mem MemElem[MEMSIZE] LUT_it_last);
    LUT_it_last = LUT_it0;
    AttRAM  LUT_it3 = LUT_it0;

    // Read from external memory and write to internal LUT
	
    (MemElem<MEMSIZE> list, LUT_it2) =
    foreach (i in <0 .. MEMSIZE-1>)
    {
	    d = memread(RAM0_it0, i);
	    LUT_it1 = memwrite(LUT_it0,d,i);
    } (d,LUT_it1);
	
    // Read the query
    MemElem query = memread(RAM1_it0, 0);

    // Compare query against each element in the DBase
    (found_list,LUT_it04)  = foreach (i in <0 .. SEARCHSIZE-1>) {
		(element, LUT_it3) = memread(LUT_it2, i);
		e = if ( element == query) 1 else 0;
    }(e, LUT_it3);

    bool e = false;
    found_vector = reformat(found_list, [SEARCHSIZE]);
    watch found_vector;
    bits:SEARCHSIZE scalar = found_vector;

    bool found = if ((uint:SEARCHSIZE)scalar > 0) true else false;
    // recred(found_vector);
    watch found;

} (found);
</pre>
<p><u>Observations:</u><br />
????</p>
<p><u>Results:</u></p>
<table border="1">
<tr>
<td>MEMSIZE</td>
<td>CYCLES</td>
</tr>
<tr>
<td>10</td>
<td>57</td>
</tr>
<tr>
<td>20</td>
<td>77</td>
</tr>
<tr>
<td>30</td>
<td>99</td>
</tr>
<tr>
<td>100</td>
<td>257</td>
</tr>
</table>
<p><!-- ================================================================ --></p>
<hr />
<h4>Attempt #4</h4>
<pre>
Mitrion-C 1.5;

MEMSIZE = 100;
SEARCHSIZE = 100;
MemElem = typedef int:8;
bits:SEARCHSIZE ZERO = 0x000;

AttRAM = typedef mem MemElem[MEMSIZE];


(bool) main(AttRAM RAM0_it0, AttRAM RAM1_it0)
{
    // This is the internal memory
    LUT_it0 = _memcreate(mem MemElem[MEMSIZE] LUT_it_last);
    LUT_it_last = LUT_it0;
    AttRAM  LUT_it3 = LUT_it0;

    // Read from external memory and write to internal LUT
    (MemElem<MEMSIZE> list, LUT_it2) =
    foreach (i in <0 .. MEMSIZE-1>)
    {
	    d = memread(RAM0_it0, i);
	    LUT_it1 = memwrite(LUT_it0,d,i);
    } (d,LUT_it1);
    
    // Read the query
    MemElem query = memread(RAM1_it0, 0);
    
    int:8 i = 0;
    bool e = false;
    // Compare query against each element in the DBase
    (found,LUT_it04)  = while ( (e == false) &#038;&#038; ( i < SEARCHSIZE) ) {
    //found = for (element in list) {
	(element, LUT_it3) = memread(LUT_it2, i);
	e = if ( element == query) true else false;
	i = i + 1;
    }(e, LUT_it3);
    


} (found);
</pre>
<p><u>Observations:</u><br />
The use of while serializes everything. Avoid!</p>
<p><u>Results:</u></p>
<table border="1">
<tr>
<td>MEMSIZE</td>
<td>CYCLES</td>
</tr>
<tr>
<td>10</td>
<td>164</td>
</tr>
<tr>
<td>20</td>
<td>317</td>
</tr>
<tr>
<td>30</td>
<td>469</td>
</tr>
<tr>
<td>100</td>
<td>1537</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://ccom.uprrp.edu/~rarce/wp/wordpress/?feed=rss2&#038;p=103</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convey HC-1 Features</title>
		<link>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=78</link>
		<comments>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=78#comments</comments>
		<pubDate>Wed, 22 Sep 2010 16:09:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Convey HC-1]]></category>

		<guid isPermaLink="false">http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=78</guid>
		<description><![CDATA[Question: What are the FPGA models included in the HC-1. Response: The HC-1 is organized as follows: Each of the 4 FPGAs is a Virtex 5 LX330. For more information, see: Virtex-5 FPGA Family Overview : http://www.xilinx.com/support/documentation/data_sheets/ds100.pdf Virtex-5 FPGA User &#8230; <a href="http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=78">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><span style="text-decoration: underline;">Question:</span></p>
<p>What are the FPGA models included in the HC-1.</p>
<p><span style="text-decoration: underline;">Response:</span></p>
<p>The HC-1 is organized as follows:</p>
<p><a rel="attachment wp-att-80" href="http://ccom.uprrp.edu/~rarce/wp/wordpress/?attachment_id=80"><img class="alignnone size-full wp-image-80" title="hc1-arch" src="http://ccom.uprrp.edu/~rarce/wp/wordpress/wp-content/uploads/2010/09/hc1-arch.png" alt="" width="1011" height="639" /></a></p>
<p>Each of the 4 FPGAs is a <strong>Virtex 5 LX330</strong>. For more information, see:<br />
Virtex-5 FPGA Family Overview : <a href="http://www.xilinx.com/support/documentation/data_sheets/ds100.pdf">http://www.xilinx.com/support/documentation/data_sheets/ds100.pdf</a><br />
Virtex-5 FPGA User Guide: <a href="http://www.xilinx.com/support/documentation/user_guides/ug190.pdf">http://www.xilinx.com/support/documentation/user_guides/ug190.pdf</a></p>
<p>Each of the 8 memory controllers supports two memory channels populated with scatter-gather DIMMs. The coprocessor in our system has a total memory of 16GB.</p>
<p>Here is some basic information from the <strong>Virtex 5 LX330 </strong>data sheet:</p>
<p><a rel="attachment wp-att-86" href="http://ccom.uprrp.edu/~rarce/wp/wordpress/?attachment_id=86"><img class="alignnone size-full wp-image-86" title="xc5vlx330-data" src="http://ccom.uprrp.edu/~rarce/wp/wordpress/wp-content/uploads/2010/09/xc5vlx330-data.png" alt="" width="1600" height="259" /></a></p>
<p>With respect to MitrionC the most important (limiting) resource are the Flip/Flop.  Each Virtex-5 FPGA slice contains four LUTs and <strong>four flip-flops</strong>. Thus the total amount of available F/Fs is 51,840 x 4 = 207,360. Usually an FPGA will have 100% slice utilization at around 50-60% flip-flop usage, thus you can safely count on 103,680 F/Fs (for each FPGA).</p>
<p>Here is an illustration of a <a href="http://ccom.uprrp.edu/~rarce/wp/wordpress/wp-content/uploads/2011/09/slice_of_virtex5.png">Virtex 5 slice</a>.</p>
<p>Each <strong>DSP48E</strong> slice contains a 25 x 18 multiplier, an adder, and an accumulator.</p>
]]></content:encoded>
			<wfw:commentRss>http://ccom.uprrp.edu/~rarce/wp/wordpress/?feed=rss2&#038;p=78</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xilinx Tools and Mitrion-C</title>
		<link>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=72</link>
		<comments>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=72#comments</comments>
		<pubDate>Tue, 21 Sep 2010 12:17:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Convey HC-1]]></category>

		<guid isPermaLink="false">http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=72</guid>
		<description><![CDATA[I have installed the Xilinx tools and Mitrion-C to the first of the Convey HC-1 machines. The Mitrion-C is practical only in the -batch mode since the java platform (or libraries) on which it is based doesn&#8217;t export graphics too &#8230; <a href="http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=72">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I have installed the Xilinx tools and Mitrion-C to the first of the Convey HC-1 machines. The Mitrion-C is practical only in the -batch mode since the java platform (or libraries) on which it is based doesn&#8217;t export graphics too effficiently.  Beter to do the Mitrion simulations locally in your PC.</p>
<p>You may request your account to this machine by emailing: rafael (dot) arce (at) upr (dot) edu.</p>
]]></content:encoded>
			<wfw:commentRss>http://ccom.uprrp.edu/~rarce/wp/wordpress/?feed=rss2&#038;p=72</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Post-workshop question 003</title>
		<link>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=60</link>
		<comments>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=60#comments</comments>
		<pubDate>Mon, 20 Sep 2010 23:00:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MitrionC]]></category>

		<guid isPermaLink="false">http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=60</guid>
		<description><![CDATA[Question: Here is a log of what happens if I run mitrion with the -sizes option. Can you tell me what is wrong? % mitrion -batch -sizes dumb_search_v02.mitc Mitrion SDK PE v1.5.3 build 537 - http://www.mitrionics.com 2008/11/11 14:56:05 GMT Your &#8230; <a href="http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=60">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><span style="text-decoration: underline;">Question:</span></p>
<p>Here is a log of what happens if I run mitrion with the -sizes option. Can you tell me what is wrong?</p>
<pre>% mitrion -batch -sizes dumb_search_v02.mitc
Mitrion SDK PE v1.5.3 build 537 - http://www.mitrionics.com
2008/11/11 14:56:05 GMT

Your code will now be transfered to secure.mitrion.com
over a secure connection and there it will calculate
the resource usage of the Virtual Mitrion Processor.

Are you sure you want to continue? [yes/no] yes

Please select a hardware platform for size estimation.
1) SGI RC100 Virtex 4 LX200
2) Cray XD1 with Virtex 4 LX160
3) Cray XD1 with Virtex 2 VP50
4) Nallatech H101 Virtex 4 LX100

Enter a number: 4
------------[ Connecting to server

*** ERROR: Error connecting to Mitrion server
------------[ Doing shutdown due to errors.</pre>
<p><span style="text-decoration: underline;">Response from Mitrionics support:</span></p>
<p>Unfortunately, the sizes server is currently down (it will likely be down for some months). However, you can use the sizes option in the configurator-enabled version of the SDK without the sizes server (i.e. the one for the Convey machine). Also, if you have a Linux or Windows machine, you can install the SDK v2.0 there: That can give you size information directly in the GUI for every node and function.</p>
<p><span style="text-decoration: underline;">Follow-up question:</span></p>
<p>Where in the gui is it that I can see the sizes? What is the mitrion command that I should be using to see the sizes? I am using version v2.1.0.</p>
<p><span style="text-decoration: underline;">Response to follow-up question:</span></p>
<p>You should use the -gui-optimized flag to get size information (though the -gui flag will give you more accurate location information). Then either press shift and hover over a node, or tick the popups checkbox and hover over a node.</p>
<p>Not all nodes cause flip-flops to be consumed, and we only measure and report flip-flop usage. LUT usage after synthesis and P&amp;R is so unpredictable that it is useless as a predictor of FPGA-fit. However, flip-flop usage is useful and usually an FPGA will have 100% slice utilization at around 50-60% flip-flop usage.</p>
]]></content:encoded>
			<wfw:commentRss>http://ccom.uprrp.edu/~rarce/wp/wordpress/?feed=rss2&#038;p=60</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Post-workshop question 002</title>
		<link>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=56</link>
		<comments>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=56#comments</comments>
		<pubDate>Mon, 20 Sep 2010 22:58:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MitrionC]]></category>

		<guid isPermaLink="false">http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=56</guid>
		<description><![CDATA[Question: Is there any way of converting a type bits:1&#60;10&#62; to a type bits:10? Response from Mitrionics Support: Sure, just reformat the list to a vector: bits:1[10] vector = reformat(list,[10]); then do a direct assignment bits:10 scalar: bits:10 scalar = &#8230; <a href="http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=56">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><span style="text-decoration: underline;">Question:</span></p>
<p>Is there any way of converting a type bits:1&lt;10&gt; to a type bits:10?</p>
<p><span style="text-decoration: underline;">Response from Mitrionics Support:</span></p>
<p>Sure, just reformat the list to a vector:</p>
<p>bits:1[10] vector = reformat(list,[10]);</p>
<p>then do a direct assignment bits:10 scalar:</p>
<p>bits:10 scalar = vector;</p>
<p>The bits type will accept literally anything (including a collection,<br />
such as a vector) as long as the width of the bits type and the source<br />
type coincide. From the bits type you can then further convert into the<br />
other data types.</p>
]]></content:encoded>
			<wfw:commentRss>http://ccom.uprrp.edu/~rarce/wp/wordpress/?feed=rss2&#038;p=56</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Post-workshop question 001</title>
		<link>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=17</link>
		<comments>http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=17#comments</comments>
		<pubDate>Fri, 17 Sep 2010 21:47:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MitrionC]]></category>

		<guid isPermaLink="false">http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=17</guid>
		<description><![CDATA[Question: I am trying to code a program that reads 10 numbers from an external memory and 1 query number from another external memory. The 10 numbers are written to an internal memory. Then I would like to determine if &#8230; <a href="http://ccom.uprrp.edu/~rarce/wp/wordpress/?p=17">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p><span style="text-decoration: underline;">Question:</span></p>
<p>I am trying to code a program that reads 10 numbers from an external<br />
memory and 1 query number from another external memory. The 10 numbers are written to an internal memory. Then I would like to determine if the query is equal to any of the 10 numbers.</p>
<p>Here is my program. I generate a list of booleans that contains the<br />
comparisons of the query against each of the 10 numbers. How do I<br />
specify that I would like a parallel &#8216;AND&#8217; function performed over the<br />
10 booleans?</p>
<pre>Mitrion-C 1.5;

MEMSIZE = 10;
MemElem = typedef int:8;

AttRAM = typedef mem MemElem[MEMSIZE];

(bool) main(AttRAM RAM0_it0, AttRAM RAM1_it0)
{
// This is the internal memory (LUT)
LUT_it0 = _memcreate(mem MemElem[MEMSIZE] LUT_it_last);
LUT_it_last = LUT_it0;
AttRAM  LUT_it3 = LUT_it0;

// Read the 10 numbers from external mem and write them to LUT
(MemElem&lt;MEMSIZE&gt; list, LUT_it2) =
foreach (i in &lt;0 .. MEMSIZE-1&gt;)
{
d = memread(RAM0_it0, i);
LUT_it1 = memwrite(LUT_it0,d,i);
} (d,LUT_it1);

// Read the query
MemElem query = memread(RAM1_it0, 0);

// Compare query against numbers
found_list  = foreach (i in &lt;0 .. MEMSIZE-1&gt;) {
element = memread(LUT_it2, i);
e = if ( element == query) true else false;
} e ;

bool e = false;
found_vector = reformat(found_list, [MEMSIZE]);
watch found_vector;

found = myAND(found_vector);
watch found;

} (found);

// There must be a cleaner way of doing this!!!!!

bool myAND(bool [MEMSIZE] x) {
res = x[0] || x[1] || x[2] || x[3] || x[4] || x[5] || x[6] || x[7]
|| x[8] || x[9];
}res;</pre>
<p><span style="text-decoration: underline;">Response from Mitrionics support:</span></p>
<p>There are a couple of alternative solutions to your problem. For one,<br />
since you are only comparing a single element at a time (you are taking<br />
the elements you are comparing from a memory), you could do the test<br />
sequentially (i.e. the same way as you did the max() function in the<br />
training, but now an and() or or() function instead).</p>
<p>Alternatively, you could use a recursive tree reduction on your<br />
collection; I included a general-purpose tree-reducer below. Keep in<br />
mind though, tree-reducers are a usually wasteful of LUTs unless you can<br />
feed them with wide data (i.e. vectors as input). In this particular<br />
case, you are only doing a bitwise boolean, so it will likely be cheaper<br />
than a loop, but that is not generally the case.</p>
<p>You should change the internal reduce()-function to do a logical<br />
or-comparison to fit your program.</p>
<p>I should also comment on a construction in your code in lines 12-13 and 21:</p>
<p>LUT_it0 = _memcreate(mem MemElem[MEMSIZE] LUT_it_last);<br />
LUT_it_last = LUT_it0;<br />
&#8230;<br />
LUT_it1 = memwrite(LUT_it0,d,i);</p>
<p>It is dangerous to get into the habit of doing like this. If you<br />
sometime in the future call this function from within a loop, it will<br />
cause a race-condition. The effect of this is similar to freeing memory,<br />
and then using the pointer to the freed memory.</p>
<p>Instead, you should accept the instance token from line 30:</p>
<p>(element, LUT_it3) = memread(LUT_it2, i);</p>
<p>return it from the loop, and then put that into LUT_it_last instead of<br />
LUT_it0:</p>
<p>LUT_it_last = LUT_it4;</p>
<pre>// A general purpose reduction tree function. Change the operation
// of the internal reduce() function to the operation required.

recred(a)
{
   reduce(a, b) a + b;

   half = length(typeof(a)) / 2;
   res = if(half &gt; 0)
   {
       lower = foreach(e in a &lt; !-- half) e;
       upper = foreach(e in a /&lt; half) e;
       res = reduce(recred(lower), recred(upper));
   } res
   else
   {
       vect = reformat(a, [1]);
       res =  vect[0];
   } res;
} res;</pre>
]]></content:encoded>
			<wfw:commentRss>http://ccom.uprrp.edu/~rarce/wp/wordpress/?feed=rss2&#038;p=17</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
