<?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"
	>

<channel>
	<title>Single Point of Failure</title>
	<atom:link href="http://www.singlepointoffailure.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.singlepointoffailure.net</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Sat, 28 Jan 2012 13:20:22 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>Map</title>
		<link>http://www.singlepointoffailure.net/2012/01/programming/map/</link>
		<comments>http://www.singlepointoffailure.net/2012/01/programming/map/#comments</comments>
		<pubDate>Sat, 28 Jan 2012 13:18:00 +0000</pubDate>
		<dc:creator>singlepointoffailure</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[Map]]></category>

		<category><![CDATA[Picture]]></category>

		<guid isPermaLink="false">http://www.singlepointoffailure.net/2012/01/programming/map/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><a href="http://dl.dropbox.com/u/110729/Blog/Images/cppmap-2012.png"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://lh5.googleusercontent.com/-AeJIvH_gzSs/TyPy3Mxxf9I/AAAAAAAA9z4/cmC7dcFVIl8/s400/cppmap-2012.png" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.singlepointoffailure.net/2012/01/programming/map/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Big Ball of Yarn</title>
		<link>http://www.singlepointoffailure.net/2012/01/work/big-ball-of-yarn/</link>
		<comments>http://www.singlepointoffailure.net/2012/01/work/big-ball-of-yarn/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 11:19:10 +0000</pubDate>
		<dc:creator>singlepointoffailure</dc:creator>
		
		<category><![CDATA[Work]]></category>

		<category><![CDATA[C/C++]]></category>

		<category><![CDATA[Fun]]></category>

		<category><![CDATA[include]]></category>

		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.singlepointoffailure.net/2012/01/work/big-ball-of-yarn/</guid>
		<description><![CDATA[New year, new project, right? Well&#8230; that not totally true for me this year! Let&#8217;s say that I&#8217;ve inherited a Big Ball of Yarn to play with. The goal is to &#8220;reuse&#8221; an existing project, remove unnecessary functionality (a.k.a. dead code), and plug-in some extra &#8220;algorithms&#8221;, but just lot at the #include dependencies of the [...]]]></description>
			<content:encoded><![CDATA[<p>New year, new project, right? Well&#8230; that not totally true for me this year! Let&#8217;s say that I&#8217;ve inherited a Big Ball of Yarn to play with. The goal is to &#8220;reuse&#8221; an existing project, remove unnecessary functionality (a.k.a. dead code), and plug-in some extra &#8220;algorithms&#8221;, but just lot at the #include dependencies of the &#8220;reusable&#8221; source code. This will be fun!</p>
<p style="text-align: center;"><a href="https://lh4.googleusercontent.com/-rwEwnHaT0P8/TwGM_mc0MlI/AAAAAAAA9zQ/EnJ0f90yZxQ/s800/BigBallOfYarn.png"><img src="https://lh4.googleusercontent.com/-rwEwnHaT0P8/TwGM_mc0MlI/AAAAAAAA9zQ/EnJ0f90yZxQ/s288/BigBallOfYarn.png" alt="" width="288" height="270" /></a></p>
<p style="text-align: center;">(<a href="https://lh4.googleusercontent.com/-rwEwnHaT0P8/TwGM_mc0MlI/AAAAAAAA9zQ/EnJ0f90yZxQ/s800/BigBallOfYarn.png">click</a> to enlarge)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.singlepointoffailure.net/2012/01/work/big-ball-of-yarn/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Caution: Highly Addictive</title>
		<link>http://www.singlepointoffailure.net/2011/12/tv/caution-highly-addictive/</link>
		<comments>http://www.singlepointoffailure.net/2011/12/tv/caution-highly-addictive/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 19:15:14 +0000</pubDate>
		<dc:creator>singlepointoffailure</dc:creator>
		
		<category><![CDATA[TV]]></category>

		<category><![CDATA[Bad]]></category>

		<category><![CDATA[Breaking]]></category>

		<category><![CDATA[Drugs]]></category>

		<category><![CDATA[Jesse Pinkman]]></category>

		<category><![CDATA[Methamphetamine]]></category>

		<category><![CDATA[Walter White]]></category>

		<guid isPermaLink="false">http://www.singlepointoffailure.net/2011/12/tv/caution-highly-addictive/</guid>
		<description><![CDATA[

]]></description>
			<content:encoded><![CDATA[<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://lh5.googleusercontent.com/-x7RleQTNLzM/Tvy5TCG8MII/AAAAAAAA9ys/xL-ikMF9ph0/s400/breaking_bad.jpg" alt="" /></p>
<p><a href="https://lh5.googleusercontent.com/-7ZVLWqskt_k/Tvy5bD2gUbI/AAAAAAAA9y0/R30zIt5bhKI/s1600/breaking-bad-7827-1920x1200.jpg"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://lh5.googleusercontent.com/-7ZVLWqskt_k/Tvy5bD2gUbI/AAAAAAAA9y0/R30zIt5bhKI/s400/breaking-bad-7827-1920x1200.jpg" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.singlepointoffailure.net/2011/12/tv/caution-highly-addictive/feed/</wfw:commentRss>
		</item>
		<item>
		<title>White Christmas</title>
		<link>http://www.singlepointoffailure.net/2011/12/family/white-christmas/</link>
		<comments>http://www.singlepointoffailure.net/2011/12/family/white-christmas/#comments</comments>
		<pubDate>Sat, 24 Dec 2011 14:37:10 +0000</pubDate>
		<dc:creator>singlepointoffailure</dc:creator>
		
		<category><![CDATA[Family]]></category>

		<category><![CDATA[Christmas]]></category>

		<category><![CDATA[Photo]]></category>

		<category><![CDATA[Tree]]></category>

		<category><![CDATA[White]]></category>

		<guid isPermaLink="false">http://www.singlepointoffailure.net/2011/12/family/white-christmas/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p><img style="display: block; margin-left: auto; margin-right: auto;" src="https://lh6.googleusercontent.com/-bnL4Q1E9v1E/TvXherwu9VI/AAAAAAAA7QA/JRUogkRa3Wo/s400/DSC_0096.JPG" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.singlepointoffailure.net/2011/12/family/white-christmas/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Mug Collection</title>
		<link>http://www.singlepointoffailure.net/2011/12/fun/mug-collection/</link>
		<comments>http://www.singlepointoffailure.net/2011/12/fun/mug-collection/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 16:58:00 +0000</pubDate>
		<dc:creator>singlepointoffailure</dc:creator>
		
		<category><![CDATA[Fun]]></category>

		<category><![CDATA[ACM]]></category>

		<category><![CDATA[Alan Turing]]></category>

		<category><![CDATA[DME]]></category>

		<category><![CDATA[IOCE]]></category>

		<category><![CDATA[Mug]]></category>

		<guid isPermaLink="false">http://www.singlepointoffailure.net/2011/12/fun/mug-collection/</guid>
		<description><![CDATA[ 
]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img src="https://lh4.googleusercontent.com/-iD19F_HZr1c/TvSx4Lg7ROI/AAAAAAAA7Ps/kc74HA0rBlw/s288/AlanTuring.JPG" alt="" width="268" height="268" /> <img src="https://lh4.googleusercontent.com/-J7JVoDQ-9uc/TvSyGiI1bZI/AAAAAAAA7Pw/dWHVu83-7SM/s288/IOCE.JPG" alt="" width="268" height="268" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.singlepointoffailure.net/2011/12/fun/mug-collection/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Going Concurrent</title>
		<link>http://www.singlepointoffailure.net/2011/12/programming/abyssround-2/</link>
		<comments>http://www.singlepointoffailure.net/2011/12/programming/abyssround-2/#comments</comments>
		<pubDate>Fri, 23 Dec 2011 16:28:52 +0000</pubDate>
		<dc:creator>singlepointoffailure</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Brain]]></category>

		<category><![CDATA[C++]]></category>

		<category><![CDATA[Concurrency]]></category>

		<category><![CDATA[Number]]></category>

		<category><![CDATA[OpenMP]]></category>

		<guid isPermaLink="false">http://www.singlepointoffailure.net/2011/12/programming/abyssround-2/</guid>
		<description><![CDATA[I had to implement a progress bar for a GUI application, and in order to keep the application &#8220;live&#8221; my focus during last couple of weeks shifted to multi-threaded concurrent programming. The solution was simple and it basically implied implementing a background thread to update the progress bar while filling a data structure by reading [...]]]></description>
			<content:encoded><![CDATA[<p>I had to implement a progress bar for a GUI application, and in order to keep the application &#8220;live&#8221; my focus during last couple of weeks shifted to multi-threaded concurrent programming. The solution was simple and it basically implied implementing a background thread to update the progress bar while filling a data structure by reading a file. It was simple enough to be implemented in a couple of days, but it became clear that some of the topics related to concurrent programing just weren&#8217;t as consolidated I would like.</p>
<p>Since the I&#8217;ve been skimming over some interesting articles on the subject. Also began to read &#8220;Concurrent Programming in Java, 2nd Edition&#8221; by Doug Lea and &#8220;The Art of Concurrency&#8221; by Clay Breshears .</p>
<p>The following is my attempt to solve the brain-number problem (addressed initially by <a href="http://software.intel.com/en-us/blogs/2011/10/18/my-first-experience-programmingin-parallel/">Ari Sundaram</a>).</p>
<pre class="brush: cpp; gutter: true; highlight: []; first-line: 1; pad-line-numbers: true; toolbar: false;">#include &lt;cmath&gt;
#include &lt;iostream&gt;
#include &lt;limits&gt;
#include &lt;cassert&gt;

#include "omp.h"

/* ***
 * Count the digits in the number
 * ***/
int count_digits(int number)
{
	return log10(static_cast&lt;double&gt;(number)) + 1;
}

/* ***
 * Calculate the brain-value of the number
 *
 * The brain-value is the sum of each digit in number to the power of the
 * number of digits.
 * BV(d1d2d3...dn) = d1^n + d2^n + d2^n + ...  + dn^n,
 *                                              where dn is the nth digit
 * ***/
int
brain_value(int number)
{
	int sum = 0;
	int digits = count_digits(number);

	while(number &gt; 0)
	{
		sum += ::pow(number % 10, digits);
		number = number / 10;
	}

	return sum;
}

/* ***
 * Checks if number is a brain-number
 *
 * A number is a brain-number when it's brain-value equals the number itself
 * ***/
bool
is_brain_number(int number)
{
	return brain_value(number) == number;
}

/* ***
 * Prints the brain-numbers in the lower/upper range
 *                                 (Serial Version)
 * ***/
void
print_brain_numbers_in_range(int lower, int upper)
{
	assert(lower &gt;= 0);
	assert(lower &lt;= upper);

	for(int i = lower; i &lt;=upper; i++)
		if(is_brain_number(i))
			std::cout &lt;&lt; i &lt;&lt; std::endl;
}

/* ***
 * Prints the brain-numbers in the lower/upper range
 *                                 (Parallel Version, using OpenMP)
 * ***/
void
print_brain_numbers_in_range_parallel(int lower, int upper)
{
	assert(lower &gt;= 0);
	assert(lower &lt;= upper);

	#pragma omp parallel
	{
		#pragma omp for
		for(int i = lower; i &lt;=upper; i++)
			if(is_brain_number(i))
				#pragma omp critical
				{
					// Critical section ensures correct output
					std::cout &lt;&lt; i &lt;&lt; std::endl;
				}
	}
}

/* ***
 * Helper function to test the
 * ***/
template&lt;typename Printer&gt;
void execute_print_brain_numbers(Printer&amp; printer, int lower, int upper) {

	std::cout &lt;&lt; "The brain numbers between "
	          &lt;&lt; lower &lt;&lt; " and " &lt;&lt; upper &lt;&lt; " are:" &lt;&lt; std::endl;
	double start = omp_get_wtime();
	printer(lower, upper);
	double end = omp_get_wtime();
	std::cout &lt;&lt; "Listed in " &lt;&lt; (end - start) &lt;&lt; " seconds" &lt;&lt; std::endl;
}

int main(void)
{
	execute_print_brain_numbers(
		print_brain_numbers_in_range,
			0,
			std::numeric_limits&lt;int&gt;::max() / 100);

	execute_print_brain_numbers(
		print_brain_numbers_in_range_parallel,
			0,
			std::numeric_limits&lt;int&gt;::max() / 100);

	return 0;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.singlepointoffailure.net/2011/12/programming/abyssround-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Today&#8217;s Soundtrack</title>
		<link>http://www.singlepointoffailure.net/2011/12/music/todays-soundtrack/</link>
		<comments>http://www.singlepointoffailure.net/2011/12/music/todays-soundtrack/#comments</comments>
		<pubDate>Tue, 20 Dec 2011 21:06:47 +0000</pubDate>
		<dc:creator>singlepointoffailure</dc:creator>
		
		<category><![CDATA[Music]]></category>

		<category><![CDATA[Bubbly]]></category>

		<category><![CDATA[Caillat]]></category>

		<category><![CDATA[Colbie]]></category>

		<category><![CDATA[Joy]]></category>

		<guid isPermaLink="false">http://www.singlepointoffailure.net/2011/12/music/todays-soundtrack/</guid>
		<description><![CDATA[
]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><iframe width="420" height="315" src="http://www.youtube.com/embed/AWGqoCNbsvM" frameborder="0"></iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://www.singlepointoffailure.net/2011/12/music/todays-soundtrack/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Just had a nice time with volatile!</title>
		<link>http://www.singlepointoffailure.net/2011/12/programming/just-had-a-nice-time-with-volatile/</link>
		<comments>http://www.singlepointoffailure.net/2011/12/programming/just-had-a-nice-time-with-volatile/#comments</comments>
		<pubDate>Sat, 17 Dec 2011 15:59:52 +0000</pubDate>
		<dc:creator>singlepointoffailure</dc:creator>
		
		<category><![CDATA[Programming]]></category>

		<category><![CDATA[C/C++]]></category>

		<category><![CDATA[Multi-Threaded]]></category>

		<category><![CDATA[volatile]]></category>

		<guid isPermaLink="false">http://www.singlepointoffailure.net/2011/12/programming/just-had-a-nice-time-with-volatile/</guid>
		<description><![CDATA[I&#8217;ve never had the chance (or in fact the need) to investigate the use of the volatile keyword in C/C++. Today I found some very interesting articles about the subject.
&#160;- Andrei Alexandrescu&#8217;s article &#8220;volatile: The Multithreaded Programmer&#8217;s Best Friend&#8221; at Dr. Doobs&#8217;s.
Explains that using volatile prevents compiler optimizations that might render code incorrect in  [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve never had the chance (or in fact the need) to investigate the use of the <code>volatile</code> keyword in C/C++. Today I found some very interesting articles about the subject.</p>
<p>&nbsp;- Andrei Alexandrescu&#8217;s article &#8220;volatile: The Multithreaded Programmer&#8217;s Best Friend&#8221; at <a href="http://drdobbs.com/cpp/184403766">Dr. Doobs&#8217;s</a>.<em><br />
Explains that using <code>volatile</code> prevents compiler optimizations that might render code incorrect in  the presence of certain asynchronous events. And presents a technical discussion on how to use the volatile qualifier to create critical sections and avoid race conditions.</em></p>
<p>&nbsp;- Arch Robison&#8217;s &#8220;Volatile: Almost Useless for Multi-Threaded Programming&#8221; at <a href="http://software.intel.com/en-us/blogs/2007/11/30/volatile-almost-useless-for-multi-threaded-programming/">Intel Software Blogs</a>.<em><br />
Provides an example where <code>volatile</code> does not work, and defends that volatile does not provide a sound base to create correct multi-threaded programs. The discussion that follows is very interesting, spawning comments for several years, and including several very interesting references to how the C++ communities discussed/evolved <code>volatile</code> understanding.</em></p>
<p>&nbsp;- Nigel Jones&#8217; &#8220;Introduction to the Volatile Keyword&#8221; (<a href="http://www.eetimes.com/discussion/beginner-s-corner/4023801/Introduction-to-the-Volatile-Keyword">here</a>) and San Saks&#8217; &#8220;Use voatile Judiciosly&#8221; (<a href="http://www.eetimes.com/discussion/programming-pointers/4025583/Use-volatile-judiciously">here</a>)<em>.<br />
Show interesting examples of what is and how to use the </em><em><code>volatile</code></em><em> qualifier, providing examples of use in the scope of embedded systems development.</em></p>
<ul></ul>
<ul></ul>
<ul></ul>
]]></content:encoded>
			<wfw:commentRss>http://www.singlepointoffailure.net/2011/12/programming/just-had-a-nice-time-with-volatile/feed/</wfw:commentRss>
		</item>
		<item>
		<title>So true&#8230; been there!</title>
		<link>http://www.singlepointoffailure.net/2011/12/cartoon/so-true-been-there/</link>
		<comments>http://www.singlepointoffailure.net/2011/12/cartoon/so-true-been-there/#comments</comments>
		<pubDate>Tue, 13 Dec 2011 20:02:05 +0000</pubDate>
		<dc:creator>singlepointoffailure</dc:creator>
		
		<category><![CDATA[Cartoon]]></category>

		<category><![CDATA[Interruptions]]></category>

		<category><![CDATA[Programmer]]></category>

		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://www.singlepointoffailure.net/2011/12/cartoon/so-true-been-there/</guid>
		<description><![CDATA[credits here.
]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><img style="display: block; margin-left: auto; margin-right: auto;" src="https://lh5.googleusercontent.com/-uo9HOJpyxW8/TueuQ9FKmRI/AAAAAAAA7PI/U-ao856ZAI8/s400/tirinhaEN-33.png" alt="" />credits <a href="http://aprogrammerslife.info/2011/12/12/what-are-you-doing/">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.singlepointoffailure.net/2011/12/cartoon/so-true-been-there/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Chinese proverb</title>
		<link>http://www.singlepointoffailure.net/2011/12/life/chinese-proverb/</link>
		<comments>http://www.singlepointoffailure.net/2011/12/life/chinese-proverb/#comments</comments>
		<pubDate>Sat, 10 Dec 2011 17:55:09 +0000</pubDate>
		<dc:creator>singlepointoffailure</dc:creator>
		
		<category><![CDATA[Life]]></category>

		<category><![CDATA[fool]]></category>

		<category><![CDATA[proverb]]></category>

		<category><![CDATA[Question]]></category>

		<guid isPermaLink="false">http://www.singlepointoffailure.net/2011/12/life/chinese-proverb/</guid>
		<description><![CDATA[&#160;
&#8220;He who asks is a fool for five minutes, but he who does not ask remains a fool forever.&#8221;
]]></description>
			<content:encoded><![CDATA[<p style="padding-left: 30px;">&nbsp;</p>
<p style="padding-left: 30px;">&#8220;He who asks is a fool for five minutes, but he who does not ask remains a fool forever.&#8221;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.singlepointoffailure.net/2011/12/life/chinese-proverb/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

