<?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: Debugging fun</title>
	<atom:link href="http://www.mailund.dk/index.php/2008/05/10/debugging-fun/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mailund.dk/index.php/2008/05/10/debugging-fun/</link>
	<description>Computer science, bioinformatics, genetics, and everything in between</description>
	<lastBuildDate>Fri, 19 Aug 2011 16:35:39 +0200</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
	<item>
		<title>By: Mikaelhc</title>
		<link>http://www.mailund.dk/index.php/2008/05/10/debugging-fun/comment-page-1/#comment-1428</link>
		<dc:creator>Mikaelhc</dc:creator>
		<pubDate>Tue, 13 May 2008 13:51:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.mailund.dk/index.php/2008/05/10/debugging-fun/#comment-1428</guid>
		<description>Well, it is only a guess. 

There must be something different between yours and Garrett&#039;s machine.

If both your machines are using Intel CPU&#039;s, it might be the case that the 64-bit machine defaults to using the fast SSE registers, which are 64-bit wide. This could be checked on a 32-bit machine/OS by compiling with &quot;-mfpmath=sse&quot; (for GCC) to see if the behavior changes. He might also have more aggressive optimization applied which turns off rounding (not very likely though). 

All guesses though, but let us know if you find out what causes the difference!</description>
		<content:encoded><![CDATA[<p>Well, it is only a guess. </p>
<p>There must be something different between yours and Garrett&#8217;s machine.</p>
<p>If both your machines are using Intel CPU&#8217;s, it might be the case that the 64-bit machine defaults to using the fast SSE registers, which are 64-bit wide. This could be checked on a 32-bit machine/OS by compiling with &#8220;-mfpmath=sse&#8221; (for GCC) to see if the behavior changes. He might also have more aggressive optimization applied which turns off rounding (not very likely though). </p>
<p>All guesses though, but let us know if you find out what causes the difference!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Mailund</title>
		<link>http://www.mailund.dk/index.php/2008/05/10/debugging-fun/comment-page-1/#comment-1427</link>
		<dc:creator>Thomas Mailund</dc:creator>
		<pubDate>Tue, 13 May 2008 11:12:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.mailund.dk/index.php/2008/05/10/debugging-fun/#comment-1427</guid>
		<description>Michael, I never compare floats without a threshold, but then, I rarely compare them...

Thanks for the info on Intel, though. Does it explain why it worked for Garrett and not me, though?</description>
		<content:encoded><![CDATA[<p>Michael, I never compare floats without a threshold, but then, I rarely compare them&#8230;</p>
<p>Thanks for the info on Intel, though. Does it explain why it worked for Garrett and not me, though?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikaelhc</title>
		<link>http://www.mailund.dk/index.php/2008/05/10/debugging-fun/comment-page-1/#comment-1426</link>
		<dc:creator>Mikaelhc</dc:creator>
		<pubDate>Tue, 13 May 2008 11:02:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.mailund.dk/index.php/2008/05/10/debugging-fun/#comment-1426</guid>
		<description>It is probably related to the internal rounding when doing floating point math. 

Since 0.5 may be exact represented, and both 0.1 and 0.4 have simple repeating bit patterns (e.g. 0.4 decimal = 0.0110011001100.... and 0.1 is the same shifted two positions) it should not matter at all how many bits you use to represent them. But the rounding will be important (it is stated in &#039;float.h&#039;).

Actually since Intel FPU&#039;s all use an internal 80-bit float representation, the compiler may choose to keep some numbers in registers at a higher resolution until the result is written back to memory - further complicating matters. 

But anyway, consider adding a threshold when comparing floats :-)</description>
		<content:encoded><![CDATA[<p>It is probably related to the internal rounding when doing floating point math. </p>
<p>Since 0.5 may be exact represented, and both 0.1 and 0.4 have simple repeating bit patterns (e.g. 0.4 decimal = 0.0110011001100&#8230;. and 0.1 is the same shifted two positions) it should not matter at all how many bits you use to represent them. But the rounding will be important (it is stated in &#8216;float.h&#8217;).</p>
<p>Actually since Intel FPU&#8217;s all use an internal 80-bit float representation, the compiler may choose to keep some numbers in registers at a higher resolution until the result is written back to memory &#8211; further complicating matters. </p>
<p>But anyway, consider adding a threshold when comparing floats :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Mailund</title>
		<link>http://www.mailund.dk/index.php/2008/05/10/debugging-fun/comment-page-1/#comment-1425</link>
		<dc:creator>Thomas Mailund</dc:creator>
		<pubDate>Tue, 13 May 2008 06:21:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.mailund.dk/index.php/2008/05/10/debugging-fun/#comment-1425</guid>
		<description>Michael: Actually, I was just guessing about the size of doubles.  If they are not of different size  than on my box, I don&#039;t know why it worked for Garrett and not me</description>
		<content:encoded><![CDATA[<p>Michael: Actually, I was just guessing about the size of doubles.  If they are not of different size  than on my box, I don&#8217;t know why it worked for Garrett and not me</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reed A. Cartwright</title>
		<link>http://www.mailund.dk/index.php/2008/05/10/debugging-fun/comment-page-1/#comment-1424</link>
		<dc:creator>Reed A. Cartwright</dc:creator>
		<pubDate>Mon, 12 May 2008 23:07:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.mailund.dk/index.php/2008/05/10/debugging-fun/#comment-1424</guid>
		<description>I think generate was making a temporary copy of my global random number object and when the temp copy of the object was destroyed (in connection with the push_back) command, the GSL rng that both wrapped was freed.  If I&#039;d written a proper copy constructor/operator it probably wouldn&#039;t have happened.

I solved the issue by passing a functional wrapper object to generate instead of the actual rng.</description>
		<content:encoded><![CDATA[<p>I think generate was making a temporary copy of my global random number object and when the temp copy of the object was destroyed (in connection with the push_back) command, the GSL rng that both wrapped was freed.  If I&#8217;d written a proper copy constructor/operator it probably wouldn&#8217;t have happened.</p>
<p>I solved the issue by passing a functional wrapper object to generate instead of the actual rng.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mikaelhc</title>
		<link>http://www.mailund.dk/index.php/2008/05/10/debugging-fun/comment-page-1/#comment-1420</link>
		<dc:creator>Mikaelhc</dc:creator>
		<pubDate>Sun, 11 May 2008 20:28:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.mailund.dk/index.php/2008/05/10/debugging-fun/#comment-1420</guid>
		<description>Hi,

Just out of curiosity: On which platform (and using which C++ type) did you find 128-bit floats? Isn&#039;t this quite exotic? (I believe most (all?) 64-bit platforms still use 8 bytes for doubles)</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Just out of curiosity: On which platform (and using which C++ type) did you find 128-bit floats? Isn&#8217;t this quite exotic? (I believe most (all?) 64-bit platforms still use 8 bytes for doubles)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thomas Mailund</title>
		<link>http://www.mailund.dk/index.php/2008/05/10/debugging-fun/comment-page-1/#comment-1418</link>
		<dc:creator>Thomas Mailund</dc:creator>
		<pubDate>Sun, 11 May 2008 06:59:37 +0000</pubDate>
		<guid isPermaLink="false">http://www.mailund.dk/index.php/2008/05/10/debugging-fun/#comment-1418</guid>
		<description>What was it, Reed, do you think?  Some trashing of uninitialized memory or such? I have struggled with such problems countless of times... valgrind usually is a life saver, but you don&#039;t want to run a long MCMC in valgrind, &#039;cause that will &lt;em&gt;never&lt;/em&gt; finish.

As for GSL, I had a problem with that yesterday, but that was (of course) my own fault.  I had a global variable for the random number generator.  I usually keep that global, but probably should use a Singleton pattern instead.  Anyway, the global variable is one of the last thing I initialise before I run my main code. I was re-factoring HapCluster yesterday to move a lot of the logic into two classes (a Chain and a State class for the MCMC) to make it easier to customise the chain to the different updates needed for different kinds of input data.  Now the problem was that I need to initialise these two classes early in the setup code and State objects need random numbers in the initialisation. Of course, before I had initialised the random number generator.  It took me a little while to figure out I was using uninitialised memory to generate random numbers...</description>
		<content:encoded><![CDATA[<p>What was it, Reed, do you think?  Some trashing of uninitialized memory or such? I have struggled with such problems countless of times&#8230; valgrind usually is a life saver, but you don&#8217;t want to run a long MCMC in valgrind, &#8217;cause that will <em>never</em> finish.</p>
<p>As for GSL, I had a problem with that yesterday, but that was (of course) my own fault.  I had a global variable for the random number generator.  I usually keep that global, but probably should use a Singleton pattern instead.  Anyway, the global variable is one of the last thing I initialise before I run my main code. I was re-factoring HapCluster yesterday to move a lot of the logic into two classes (a Chain and a State class for the MCMC) to make it easier to customise the chain to the different updates needed for different kinds of input data.  Now the problem was that I need to initialise these two classes early in the setup code and State objects need random numbers in the initialisation. Of course, before I had initialised the random number generator.  It took me a little while to figure out I was using uninitialised memory to generate random numbers&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reed A. Cartwright</title>
		<link>http://www.mailund.dk/index.php/2008/05/10/debugging-fun/comment-page-1/#comment-1412</link>
		<dc:creator>Reed A. Cartwright</dc:creator>
		<pubDate>Sun, 11 May 2008 03:29:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.mailund.dk/index.php/2008/05/10/debugging-fun/#comment-1412</guid>
		<description>I had a very strange bug in one of my programs recently.  After a couple of simple code changes GSL started to fail when I tried to generate a multinomial.  After a while, I eventually determined that my rand number object was being cleared earlier in the code.  I traced it to an unrelated vector::push_back command, which had been fine before.  I then went back to commenting out several recent changes and found that a &quot;generate&quot; command was doing &quot;something&quot; so that when I pushed the generated object onto the vector, it erased what I thought was an unrelated random number object.

As soon as I changed the generate line a bit, everything was fine.  It&#039;s the weirdest bug I&#039;ve ever had.</description>
		<content:encoded><![CDATA[<p>I had a very strange bug in one of my programs recently.  After a couple of simple code changes GSL started to fail when I tried to generate a multinomial.  After a while, I eventually determined that my rand number object was being cleared earlier in the code.  I traced it to an unrelated vector::push_back command, which had been fine before.  I then went back to commenting out several recent changes and found that a &#8220;generate&#8221; command was doing &#8220;something&#8221; so that when I pushed the generated object onto the vector, it erased what I thought was an unrelated random number object.</p>
<p>As soon as I changed the generate line a bit, everything was fine.  It&#8217;s the weirdest bug I&#8217;ve ever had.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

