<?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"
	>
<channel>
	<title>Comments for Software Ramblings</title>
	<atom:link href="http://softwareramblings.com/comments/feed" rel="self" type="application/rss+xml" />
	<link>http://softwareramblings.com</link>
	<description>Stephen Doyles Ramblings on the Art of Software Engineering</description>
	<pubDate>Thu, 28 Aug 2008 06:39:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>Comment on Multi-thread scaling issues with Python and Ruby by Jesse</title>
		<link>http://softwareramblings.com/2008/07/multi-thread-scaling-issues-with-python-and-ruby.html#comment-29</link>
		<dc:creator>Jesse</dc:creator>
		<pubDate>Fri, 01 Aug 2008 01:07:46 +0000</pubDate>
		<guid isPermaLink="false">http://softwareramblings.com/?p=33#comment-29</guid>
		<description>In addition to safethread, there's the work going on in 2.6/3.0 courtesy of pep-371 (http://python.org/dev/peps/pep-0371/) to add in a threading-like interface to process-based threading. Adam's right though - "Of course the Multicore Crisis is all about ease of programming, not simply performance".

Threads, as they sit today in most languages are a pain to get right no matter what.</description>
		<content:encoded><![CDATA[<p>In addition to safethread, there&#8217;s the work going on in 2.6/3.0 courtesy of pep-371 (http://python.org/dev/peps/pep-0371/) to add in a threading-like interface to process-based threading. Adam&#8217;s right though - &#8220;Of course the Multicore Crisis is all about ease of programming, not simply performance&#8221;.</p>
<p>Threads, as they sit today in most languages are a pain to get right no matter what.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Regular Expressions in C++ by Applications</title>
		<link>http://softwareramblings.com/2008/07/regular-expressions-in-c.html#comment-25</link>
		<dc:creator>Applications</dc:creator>
		<pubDate>Sun, 27 Jul 2008 21:26:54 +0000</pubDate>
		<guid isPermaLink="false">http://softwareramblings.com/?p=31#comment-25</guid>
		<description>&lt;strong&gt;yo...&lt;/strong&gt;

wonderful...</description>
		<content:encoded><![CDATA[<p><strong>yo&#8230;</strong></p>
<p>wonderful&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Demystifying the volatile keyword by Igor Levicki</title>
		<link>http://softwareramblings.com/2008/05/demystifying-the-volatile-keyword.html#comment-24</link>
		<dc:creator>Igor Levicki</dc:creator>
		<pubDate>Sun, 27 Jul 2008 18:59:24 +0000</pubDate>
		<guid isPermaLink="false">http://softwareramblings.com/?p=25#comment-24</guid>
		<description>&#62;&#62;Have you observed a compiler optimizing away such a variable and resulting in a crash?

Yes I did.

&#62;&#62;I’m tempted to write a code snippet and see what some standard compilers do in this scenario - have you already done this?

I tested it only with Intel C++ Compiler and it crashes so I submitted an issue with Intel Premier Support to get some clarification and so far I haven't got anything except the confirmation that they have reproduced it.

Let me save you some effort, here is the code snippet I used:

#include 

#define ALIGN	__declspec(align(16))

void zealot(void)
{
ALIGN	volatile float wkr[4096]; // 16384 bytes
ALIGN	volatile float wki[4096]; // 16384 bytes
ALIGN	volatile float ak0[4096]; // 16384 bytes
ALIGN	volatile float ak1[4096]; // 16384 bytes

	__asm	{
		xor	eax, eax
		mov	edx, 16384
		lea	esi, wkr // reference wkr
		lea	edi, ak0 // reference ak0
		mov	dword ptr [1024 + edi + edx], eax // ak1[256] = 0
	}
}

int main(void)
{
	zealot();
	printf("I am not a zealot!\n");
	return 0;
}

Arrays wki and ak1 get optimized away because there is no explicit reference in the inline assembler block.

In my opinion the original C/C++ standard is too vague on the volatile keyword definition. They do say that the compiler should not optimize if it is not sure that the variable cannot be changed from the outside but in this case "outside" really should mean "outside of the compiler generated code", not "outside of the function".</description>
		<content:encoded><![CDATA[<p>&gt;&gt;Have you observed a compiler optimizing away such a variable and resulting in a crash?</p>
<p>Yes I did.</p>
<p>&gt;&gt;I’m tempted to write a code snippet and see what some standard compilers do in this scenario - have you already done this?</p>
<p>I tested it only with Intel C++ Compiler and it crashes so I submitted an issue with Intel Premier Support to get some clarification and so far I haven&#8217;t got anything except the confirmation that they have reproduced it.</p>
<p>Let me save you some effort, here is the code snippet I used:</p>
<p>#include </p>
<p>#define ALIGN	__declspec(align(16))</p>
<p>void zealot(void)<br />
{<br />
ALIGN	volatile float wkr[4096]; // 16384 bytes<br />
ALIGN	volatile float wki[4096]; // 16384 bytes<br />
ALIGN	volatile float ak0[4096]; // 16384 bytes<br />
ALIGN	volatile float ak1[4096]; // 16384 bytes</p>
<p>	__asm	{<br />
		xor	eax, eax<br />
		mov	edx, 16384<br />
		lea	esi, wkr // reference wkr<br />
		lea	edi, ak0 // reference ak0<br />
		mov	dword ptr [1024 + edi + edx], eax // ak1[256] = 0<br />
	}<br />
}</p>
<p>int main(void)<br />
{<br />
	zealot();<br />
	printf(&#8221;I am not a zealot!\n&#8221;);<br />
	return 0;<br />
}</p>
<p>Arrays wki and ak1 get optimized away because there is no explicit reference in the inline assembler block.</p>
<p>In my opinion the original C/C++ standard is too vague on the volatile keyword definition. They do say that the compiler should not optimize if it is not sure that the variable cannot be changed from the outside but in this case &#8220;outside&#8221; really should mean &#8220;outside of the compiler generated code&#8221;, not &#8220;outside of the function&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Multi-thread scaling issues with Python and Ruby by Multi-thread scaling issues with Python and Ruby</title>
		<link>http://softwareramblings.com/2008/07/multi-thread-scaling-issues-with-python-and-ruby.html#comment-22</link>
		<dc:creator>Multi-thread scaling issues with Python and Ruby</dc:creator>
		<pubDate>Sat, 26 Jul 2008 13:12:10 +0000</pubDate>
		<guid isPermaLink="false">http://softwareramblings.com/?p=33#comment-22</guid>
		<description>[...] Full Story [...]</description>
		<content:encoded><![CDATA[<p>[...] Full Story [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Demystifying the volatile keyword by Jack of All Trades &#187; Blog Archives &#187; links for 2008-07-23</title>
		<link>http://softwareramblings.com/2008/05/demystifying-the-volatile-keyword.html#comment-20</link>
		<dc:creator>Jack of All Trades &#187; Blog Archives &#187; links for 2008-07-23</dc:creator>
		<pubDate>Wed, 23 Jul 2008 04:38:58 +0000</pubDate>
		<guid isPermaLink="false">http://softwareramblings.com/?p=25#comment-20</guid>
		<description>[...] Demystifying the volatile keyword » Software Ramblings What is volatile keyword means and when to use it (tags: C++ Programming) [...]</description>
		<content:encoded><![CDATA[<p>[...] Demystifying the volatile keyword » Software Ramblings What is volatile keyword means and when to use it (tags: C++ Programming) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Demystifying the volatile keyword by Stephen Doyle</title>
		<link>http://softwareramblings.com/2008/05/demystifying-the-volatile-keyword.html#comment-18</link>
		<dc:creator>Stephen Doyle</dc:creator>
		<pubDate>Sun, 20 Jul 2008 00:02:00 +0000</pubDate>
		<guid isPermaLink="false">http://softwareramblings.com/?p=25#comment-18</guid>
		<description>Ah - I hadn't thought of indirectly accessing that from an inline assembler block. In this case I'm not sure that the volatile keyword adds any value.

Have you observed a compiler optimizing away such a variable and resulting in a crash? I'm tempted to write a code snippet and see what some standard compilers do in this scenario - have you already done this?</description>
		<content:encoded><![CDATA[<p>Ah - I hadn&#8217;t thought of indirectly accessing that from an inline assembler block. In this case I&#8217;m not sure that the volatile keyword adds any value.</p>
<p>Have you observed a compiler optimizing away such a variable and resulting in a crash? I&#8217;m tempted to write a code snippet and see what some standard compilers do in this scenario - have you already done this?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Demystifying the volatile keyword by Igor Levicki</title>
		<link>http://softwareramblings.com/2008/05/demystifying-the-volatile-keyword.html#comment-17</link>
		<dc:creator>Igor Levicki</dc:creator>
		<pubDate>Sat, 19 Jul 2008 23:55:40 +0000</pubDate>
		<guid isPermaLink="false">http://softwareramblings.com/?p=25#comment-17</guid>
		<description>Yes but that local variable could be indirectly accessed (and thus its value changed) from inline assembler block -- then what?

It is clear that in such case optimizing the variable away would lead to a program crash because of a stack overflow.

I just checked C++ Standard draft and it is pretty unclear on that. I believe that there should be a way to tell the compiler "do not optimize away unreferenced local variables".

What do you think?</description>
		<content:encoded><![CDATA[<p>Yes but that local variable could be indirectly accessed (and thus its value changed) from inline assembler block &#8212; then what?</p>
<p>It is clear that in such case optimizing the variable away would lead to a program crash because of a stack overflow.</p>
<p>I just checked C++ Standard draft and it is pretty unclear on that. I believe that there should be a way to tell the compiler &#8220;do not optimize away unreferenced local variables&#8221;.</p>
<p>What do you think?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Demystifying the volatile keyword by Stephen Doyle</title>
		<link>http://softwareramblings.com/2008/05/demystifying-the-volatile-keyword.html#comment-16</link>
		<dc:creator>Stephen Doyle</dc:creator>
		<pubDate>Fri, 18 Jul 2008 21:02:12 +0000</pubDate>
		<guid isPermaLink="false">http://softwareramblings.com/?p=25#comment-16</guid>
		<description>Sorry, I don't know for certain. I would suspect though that it is allowed to optimize away the unreferenced local variable. Volatile really only protects against optimizations that may affect the value of the variable. Since the value of unreferenced variables is not an issue, then everything should be ok if it is optimized away.</description>
		<content:encoded><![CDATA[<p>Sorry, I don&#8217;t know for certain. I would suspect though that it is allowed to optimize away the unreferenced local variable. Volatile really only protects against optimizations that may affect the value of the variable. Since the value of unreferenced variables is not an issue, then everything should be ok if it is optimized away.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Demystifying the volatile keyword by Igor Levicki</title>
		<link>http://softwareramblings.com/2008/05/demystifying-the-volatile-keyword.html#comment-15</link>
		<dc:creator>Igor Levicki</dc:creator>
		<pubDate>Fri, 18 Jul 2008 20:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://softwareramblings.com/?p=25#comment-15</guid>
		<description>Do you perhaps have any idea what the C++ standard says regarding whether the compiler is allowed to optimize away unreferenced local variable marked as volatile?</description>
		<content:encoded><![CDATA[<p>Do you perhaps have any idea what the C++ standard says regarding whether the compiler is allowed to optimize away unreferenced local variable marked as volatile?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Multi-thread scaling issues with Python and Ruby by roger accredited colleges</title>
		<link>http://softwareramblings.com/2008/07/multi-thread-scaling-issues-with-python-and-ruby.html#comment-14</link>
		<dc:creator>roger accredited colleges</dc:creator>
		<pubDate>Wed, 16 Jul 2008 19:41:58 +0000</pubDate>
		<guid isPermaLink="false">http://softwareramblings.com/?p=33#comment-14</guid>
		<description>Yeah with Ruby even 1.9 you're still locked to a single core.  Only way to overcome this currently is running multiple processes side by side.  Until...who knows when.  I guess there are some other languages that overcome this, but not Ruby, yet.</description>
		<content:encoded><![CDATA[<p>Yeah with Ruby even 1.9 you&#8217;re still locked to a single core.  Only way to overcome this currently is running multiple processes side by side.  Until&#8230;who knows when.  I guess there are some other languages that overcome this, but not Ruby, yet.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
