<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Generated Code for Variable Size Signals</title>
	<atom:link href="http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/</link>
	<description>This blog is about Simulink.</description>
	<lastBuildDate>Mon, 13 Feb 2012 02:07:34 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Ashish Sadanandan</title>
		<link>http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/#comment-891</link>
		<dc:creator>Ashish Sadanandan</dc:creator>
		<pubDate>Sun, 08 Nov 2009 15:16:17 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/#comment-891</guid>
		<description>@wei, I was talking about the case where the compiler would perform the &#039;model_Xdim-1&#039; operation each time through the loop before checking the exit condition.</description>
		<content:encoded><![CDATA[<p>@wei, I was talking about the case where the compiler would perform the &#8216;model_Xdim-1&#8242; operation each time through the loop before checking the exit condition.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: wei</title>
		<link>http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/#comment-890</link>
		<dc:creator>wei</dc:creator>
		<pubDate>Sat, 07 Nov 2009 14:51:48 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/#comment-890</guid>
		<description>@Ashish, I agree with your observation on compiler optimization but fail to see why Han&#039;s code would be less efficient than the original. Would you explain?</description>
		<content:encoded><![CDATA[<p>@Ashish, I agree with your observation on compiler optimization but fail to see why Han&#8217;s code would be less efficient than the original. Would you explain?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashish Sadanandan</title>
		<link>http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/#comment-889</link>
		<dc:creator>Ashish Sadanandan</dc:creator>
		<pubDate>Fri, 06 Nov 2009 18:24:13 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/#comment-889</guid>
		<description>Han,
Sorry for butting in with a reply, but the modification to the for-loop you&#039;ve suggested is really not an optimization IMHO. Even a moderately competent C compiler will generate identical code for the 2 versions since &#039;model_Xdim&#039; is not being modified within the for-loop. However, if you have a really non-optimizing compiler, the code generated by your version would be very inefficient. So I feel its better to leave the implementation of that for-loop as it is.

Ashish.</description>
		<content:encoded><![CDATA[<p>Han,<br />
Sorry for butting in with a reply, but the modification to the for-loop you&#8217;ve suggested is really not an optimization IMHO. Even a moderately competent C compiler will generate identical code for the 2 versions since &#8216;model_Xdim&#8217; is not being modified within the for-loop. However, if you have a really non-optimizing compiler, the code generated by your version would be very inefficient. So I feel its better to leave the implementation of that for-loop as it is.</p>
<p>Ashish.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Han Geerligs</title>
		<link>http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/#comment-887</link>
		<dc:creator>Han Geerligs</dc:creator>
		<pubDate>Fri, 06 Nov 2009 12:38:56 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.mathworks.com/seth/2009/11/06/generated-code-for-variable-size-signals/#comment-887</guid>
		<description>Hi Aarti,

thanks for providing the example! 

I was just wondering why the lines
  model_YDim = model_XDim;
  loop_ub = model_XDim - 1;
  for (tmp = 0; tmp &lt;= loop_ub; tmp++) {
    Y[tmp] = 2.0 * X[tmp];
  }

aren&#039;t converted into
  for (tmp = 0; tmp &lt;= model_Xdim-1; tmp++) {
    Y[tmp] = 2.0 * X[tmp];
  }

This would be a special case of expression folding.

I was wondering if this optimisation was considered at design/is planned for implementation?

Han</description>
		<content:encoded><![CDATA[<p>Hi Aarti,</p>
<p>thanks for providing the example! </p>
<p>I was just wondering why the lines<br />
  model_YDim = model_XDim;<br />
  loop_ub = model_XDim &#8211; 1;<br />
  for (tmp = 0; tmp &lt;= loop_ub; tmp++) {<br />
    Y[tmp] = 2.0 * X[tmp];<br />
  }</p>
<p>aren&#8217;t converted into<br />
  for (tmp = 0; tmp &lt;= model_Xdim-1; tmp++) {<br />
    Y[tmp] = 2.0 * X[tmp];<br />
  }</p>
<p>This would be a special case of expression folding.</p>
<p>I was wondering if this optimisation was considered at design/is planned for implementation?</p>
<p>Han</p>
]]></content:encoded>
	</item>
</channel>
</rss>

