<?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>rajorshi.net &#187; Hardware</title>
	<atom:link href="http://rajorshi.net/blog/category/technology/hardware-technology/feed/" rel="self" type="application/rss+xml" />
	<link>http://rajorshi.net/blog</link>
	<description>My musings on life, movies and technology</description>
	<lastBuildDate>Sat, 05 Jun 2010 19:15:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Programming for multicore: An introduction to OpenMP using GCC-4.4</title>
		<link>http://rajorshi.net/blog/2009/05/programming-for-multicore-introduction-openmp-gcc/</link>
		<comments>http://rajorshi.net/blog/2009/05/programming-for-multicore-introduction-openmp-gcc/#comments</comments>
		<pubDate>Sun, 24 May 2009 13:13:08 +0000</pubDate>
		<dc:creator>rajorshi</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[AMD]]></category>
		<category><![CDATA[boost]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[Intel]]></category>
		<category><![CDATA[Istanbul]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Multi-Core]]></category>
		<category><![CDATA[Nehalem]]></category>
		<category><![CDATA[OpenMP]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://rajorshi.net/blog/?p=52</guid>
		<description><![CDATA[About a couple of months back, I happened to attend a short seminar on multi-core programming by Intel here at Hyderabad. What I liked immensely about it was that it was not yet another blatant advertising campaign on some hardware or software product by some industry giant. It was about the paradigm shift that the [...]]]></description>
			<content:encoded><![CDATA[<p>About a couple of months back, I happened to attend a short seminar on <a href="http://en.wikipedia.org/wiki/Multi-core_(computing)">multi-core</a> programming by Intel here at Hyderabad. What I liked immensely about it was that it was not yet another blatant advertising campaign on some hardware or software product by some industry giant.</p>
<p>It was about the paradigm shift that the chip industry is undergoing &#8211; the trend towards more cores, rather than higher gigahertz horsepower. However, if you are an average Joe developer like me, you probably program your applications without leveraging the power of two or more cores simultaneously. By default, we don&#8217;t &#8216;think parallel&#8217; for various reasons. For one, threading is not an easy concept. The seminar looked at some of Intel&#8217;s software offerings that help developers (especially Visual Studio developers) to create, debug and optimize threaded/multicore applications. (However, this post will not focus on those tools &#8211; you may want to visit <a href="http://www.intel.com/go/parallel">www.intel.com/go/parallel</a> for more information).</p>
<p>On a related thread (pun intended!), <a href="http://gcc.gnu.org/gcc-4.4/">gcc-4.4.0</a> was released recently. This added support for version 3.0 of the <a href="http://openmp.org/">OpenMP</a> specification. OpenMP is something I had heard of before, but never actually tried. It is an API for C, C++ and Fortran programmers that enables you to &#8216;parallel program&#8217; easily. Jargonspeak calls it &#8216;platform independent shared memory multiprocessing&#8217;. In effect, it&#8217;s threads without the associated headache of thread management. By the way, gcc has supported OpenMP way back from version 4.2. So, you don&#8217;t need the latest bleeding edge version for this. However, should you want to, on Windows you can always download the excellent <a href="http://www.tdragon.net/recentgcc/">TDM MingW</a> builds for gcc-4.4.0 (<a href="http://downloads.sourceforge.net/tdm-gcc/tdm-mingw-1.905.0-4.4.0-2.exe">latest direct link</a>). If you&#8217;re a Linux geek, you probably know how to get gcc-4.4 for your distro anyway. Also, Microsoft Visual C++ Express does not include/support OpenMP &#8211; hence my experiments are limited to gcc on both Win and Lin.</p>
<p>All right then, let&#8217;s see how OpenMP aids a classic case of parallelization: matrix multiplication. Agreed &#8211; this is a rather simple programming problem, and real world problems are usually harder to parallelize than this. However, this should serve as a good starting point to explore further.</p>
<p>So, here&#8217;s the basic matrix multiplication loop that we want to parallelize, assuming arr1 and arr2 are inputs, and arr3 is the output array:</p>
<pre name="code" class="cpp">

for(i=0; i&lt;n; ++i) {
  for(j=0; j&lt;n; ++j) {
    temp = 0;
    for(k=0; k&lt;n; ++k) {
      temp += arr1[i][k] * arr2[k][j];
    }
    arr3[i][j] = temp;
  }
}
</pre>
<p>OpenMP is mostly a set of compiler directives (pragmas) and library routines. In this case, it&#39;s enough for us to add on single statement before our loop.</p>
<pre name="code" class="cpp">

#pragma omp parallel for private(i, j, k, temp)
for(i=0; i&lt;n; ++i) {
  for(j=0; j&lt;n; ++j) {
    temp = 0;
    for(k=0; k&lt;n; ++k) {
      temp += arr1[i][k] * arr2[k][j];
    }
    arr3[i][j] = temp;
  }
}
</pre>
<p>That&#8217;s it! This pragma tells the OpenMP subsystem to do it&#8217;s little magic behind the scenes and parallelize the &#8216;for loop&#8217; following it.</p>
<p>Here&#8217;s the <a href="http://rajorshi.net/blog/wp-content/uploads/2009/05/matmul.c">complete program</a>, which contains additional code to initialize the arrays arr1 and arr2 pseudo-randomly, and to calculate the timings taken by the normal and the parallelized versions. You can compile the program with gcc-4.4 by the simple command:</p>
<pre>
gcc -fopenmp matmul.c
</pre>
<p>And on Windows, you might need to edit the PATH variable to include the GNU libgomp runtime (libgomp-1.dll). (<a href="http://gcc.gnu.org/onlinedocs/libgomp/">Libgomp</a> is GNU&#8217;s implementation of OpenMP). Here&#8217;s how I did it, for example:</p>
<pre>
set PATH=D:\MinGW\lib\gcc\mingw32\bin;%PATH%
</pre>
<p>So, the end result? Here are 4 sets of execution outputs. Two from Windows (TDM gcc-4.4.0):</p>
<pre>
Enter dimension ('N' for 'NxN' matrix) (100-2000): 1000
Populating array with random values...
Completed array init.
Crunching without OMP... took 23.032000 seconds.
Crunching with OMP... took 13.000000 seconds.

Enter dimension ('N' for 'NxN' matrix) (100-2000): 2000
Populating array with random values...
Completed array init.
Crunching without OMP... took 216.140000 seconds.
Crunching with OMP... took 118.641000 seconds.
</pre>
<p>And two from Linux (Ubuntu 9.04, gcc-4.3.3):</p>
<pre>
Enter dimension ('N' for 'NxN' matrix) (100-2000): 1000
Populating array with random values...
Completed array init.
Crunching without OMP... took 21.623144 seconds.
Crunching with OMP... took 13.686926 seconds.

Enter dimension ('N' for 'NxN' matrix) (100-2000): 2000
Populating array with random values...
Completed array init.
Crunching without OMP... took 189.184673 seconds.
Crunching with OMP... took 104.220751 seconds.
</pre>
<p>That&#8217;s almost doubling the speed, while adding one statement to your program! Actually two statements, if you include the include directive for &lt;omp.h&gt;. I&#8217;m sure you&#8217;d agree that for this case, OpenMP provides a really easy way of utilizing the idle core of most desktop machines out there. The good part is, even on a single core machine, the code works the way it should (the pragmas essentially NOP out, since there&#8217;d be no benefit in parallelizing on one core).</p>
<p>A look at the CPU utilization proves to be interesting too. (By the way, my home <a href="http://rajorshi.net/blog/2008/08/upgrading-my-rig/">system</a> runs an AMD Althon64 X2 4600 dual core, at a clock speed of 2.4GHz). In the first case, here&#8217;s a snap of the system information (using the excellent <a href="http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx">Process Explorer</a>). Notice how the CPU usage remains peaked at around 50%, and the second CPU is mostly idle. Please click on the images below for the full view.</p>
<p><a href="http://rajorshi.net/blog/wp-content/uploads/2009/05/1.jpg"><img class="center frame" src="http://rajorshi.net/blog/wp-content/uploads/2009/05/1_tm.jpg" alt="1" width="450" height="438" /></a></p>
<p>And here&#8217;s the usage when the OpenMP crunching is in action:</p>
<p><a href="http://rajorshi.net/blog/wp-content/uploads/2009/05/2.jpg"><img class="center frame" src="http://rajorshi.net/blog/wp-content/uploads/2009/05/2_tm.jpg" alt="2" width="450" height="438" /></a></p>
<p>That&#8217;s more like it. Both horses in action, CPU peaked at 100%. Similar stuff can be seen on Linux, using Ubuntu&#8217;s (rather, GNOME&#8217;s) inbuilt System Monitor:</p>
<p><a href="http://rajorshi.net/blog/wp-content/uploads/2009/05/ubuntu-sm.jpg"><img class="center frame" src="http://rajorshi.net/blog/wp-content/uploads/2009/05/ubuntu_tm.jpg" alt="ubuntu sm" width="450" height="133" /></a></p>
<p>The portion where the red and orange worms collide at the top is the duration of the OpenMP version of the matrix multiplication program.</p>
<p>As already stated, matrix multiplication is an ideal case &#8211; and such 2x speedup on dual core machines are possible with only such ideal problems. However, there often are, if you look closely enough, parts of your program that can be parallelized. Further, we have not even scratched the surface of what&#8217;s possible using OpenMP 3.0. It goes way beyond parallelizing simple for loops. (<a href="http://www.openmp.org/mp-documents/spec30.pdf">Here&#8217;s</a> the link to the spec in PDF).</p>
<p>And for sure, OpenMP is not the only way to go parallel portably. If you work in C++, you would have heard of the <a href="http://www.boost.org/">Boost</a> C++ libraries. Give <a href="http://www.boost.org/doc/libs/1_39_0/doc/html/thread.html">boost::threads</a> a go!</p>
<p>With Intel gearing up for the release of its eight core <a href="http://en.wikipedia.org/wiki/Nehalem_(microarchitecture)">Nehalem</a> EX processors, and with AMD&#8217;s six core <a href="http://www.youtube.com/watch?v=XDdvZkBo4JE">Istanbul</a> processor already finding its way into mainstream desktop boards, there remains only one thing to say: if there is a time to think in parallel, this is it!</p>
<p>~Raj</p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Frajorshi.net%2Fblog%2F2009%2F05%2Fprogramming-for-multicore-introduction-openmp-gcc%2F';
  addthis_title  = 'Programming+for+multicore%3A+An+introduction+to+OpenMP+using+GCC-4.4';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://rajorshi.net/blog/2009/05/programming-for-multicore-introduction-openmp-gcc/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Bose In-Ear Headphones: A review</title>
		<link>http://rajorshi.net/blog/2008/10/bose-in-ear-headphones/</link>
		<comments>http://rajorshi.net/blog/2008/10/bose-in-ear-headphones/#comments</comments>
		<pubDate>Sun, 26 Oct 2008 15:17:02 +0000</pubDate>
		<dc:creator>rajorshi</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://rajorshi.net/blog/?p=33</guid>
		<description><![CDATA[Last month, I received a pair of Bose In-Ear headphones from my USA-return cousin bro. As you can see here, it&#8217;s obscenely expensive, at almost 5k INR, and not something lesser mortals such as I would consider buying otherwise. Perhaps what Russel Peters says about Indians here is true, after all (Poor) jokes apart, unboxing [...]]]></description>
			<content:encoded><![CDATA[<p>Last month, I received a pair of <a href="http://www.bose.com/controller?event=DTC_LINKS_TARGET_EVENT&amp;DTCLinkID=7474&amp;src=TRIPORT">Bose In-Ear headphones</a> from my USA-return cousin bro.</p>
<p><a href="http://rajorshi.net/blog/wp-content/uploads/2008/10/bose.jpg"><img class="left size-thumbnail wp-image-35" src="http://rajorshi.net/blog/wp-content/uploads/2008/10/bose-150x150.jpg" alt="Bose headphones" width="150" height="150" /></a></p>
<p>As you can see <a href="http://www.boseindia.com/retail/bose-product-detail.aspx?prd_Id=57&amp;Cat_Id=3">here</a>, it&#8217;s obscenely expensive, at almost 5k INR, and not something lesser mortals such as I would consider buying otherwise. Perhaps what Russel Peters says about Indians <a href="http://www.youtube.com/watch?v=EKqdIDxoWBE">here </a>is true, after all <img src='http://rajorshi.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>(Poor) jokes apart, unboxing the package reveals a manual, a warranty-card, two extra sets of plugs (for abnormally small and abnormally large ears) and a leather carrying case, apart from the headphones. The medium sized plugs come mounted on the headphones. People seem to have complaints that these plugs keep falling off, but that hasn&#8217;t happened with me.</p>
<p>The earphones by themselves are the &#8216;in-ear&#8217; type, meaning that they go quite a bit inside your ear-canal. At this point, I should probably mention that I&#8217;m no hardcore audiophile. Though this is my first set of in-ear headphones, I find that they fit in quite nicely, albeit a tad loose perhaps.</p>
<p>I plugged these babies into my PC, and set the mode to &#8220;headphone&#8221; on the Realtek HD Sound Manager (an app bundled with my <a href="http://www.gigabyte.com.tw/Products/Motherboard/Products_Spec.aspx?ProductID=2814">motherboard</a>). On my PC, I personally find that the best sound is produced by VLC media player (in &#8220;Rock&#8221; equalizer mode) for mp3 files.</p>
<p>The first thing I noticed about the sound was the humongous bass reproduction. I&#8217;ve never experienced such bass from such small earphones, for sure. The highs were also very crisp, but not tinny. After about a month of testing, this is what I would have to say, in summary:</p>
<p><strong>Pros:</strong></p>
<ul>
<li>Awesome bass reproduction, very good mids and highs</li>
<li>Comfortable even after long hours of use</li>
<li>Good looks, good build quality</li>
</ul>
<p><strong>Cons:</strong></p>
<ul>
<li>Extremely expensive</li>
<li>No noise cancellation, ineffective noise isolation</li>
</ul>
<p>Overall, a very good pair of headphones. However, the price is way too much. And for that very reason, you tend to be very cautious &#8211; being extremely careful not to tug it by mistake, for example. So the bottomline is, if you have tons of money, go for it! If that&#8217;s the case, you may also want to take a look at the <a href="http://www.bose.com/controller?url=/shop_online/headphones/noise_cancelling_headphones/index.jsp">Bose Quiet Comfort</a> range of headphones, which are said to offer the best noise-cancellation in the market today.</p>
<p>
~Raj</p>
<p></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Frajorshi.net%2Fblog%2F2008%2F10%2Fbose-in-ear-headphones%2F';
  addthis_title  = 'Bose+In-Ear+Headphones%3A+A+review';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://rajorshi.net/blog/2008/10/bose-in-ear-headphones/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Upgrading my rig</title>
		<link>http://rajorshi.net/blog/2008/08/upgrading-my-rig/</link>
		<comments>http://rajorshi.net/blog/2008/08/upgrading-my-rig/#comments</comments>
		<pubDate>Sun, 31 Aug 2008 05:51:15 +0000</pubDate>
		<dc:creator>rajorshi</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://rajorshi.net/blog/?p=11</guid>
		<description><![CDATA[This weekend, I had planned to upgrade my desktop PC. My PC was already a venerable powerhouse. Equipped with an AMD Sempron 2200+ (1.5GHz) processor, 512MB of RAM, and a GeForce 400MX IGP, it had the muscle to play all 3D FPS games of&#8230; well, the year 2003 at best The reason behind this upgrade [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend, I had planned to upgrade my desktop PC.</p>
<p>My PC was already a venerable powerhouse. Equipped with an AMD Sempron 2200+ (1.5GHz) processor, 512MB of RAM, and a GeForce 400MX <a href="http://www.techterms.com/definition/igp">IGP</a>, it had the muscle to play all 3D FPS games of&#8230; well, the year 2003 at best <img src='http://rajorshi.net/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p>The reason behind this upgrade was to spend less of my extremely valuable time twiddling my thumbs and waiting for Firefox to start, or a Half-Life 2 episode to load.</p>
<p>So I headed off to Chenoy Trade Centre at Secunderabad, to an affable guy named Gaffar at a store called &#8216;Computer Bazaar&#8217;. Incidentally, this is also where I had bought this PC. Till date, I&#8217;m not sure if this guy hoodwinks me with all his tall claims <img src='http://rajorshi.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I had a budget of around 10k INR in mind. This is what I ended up with, after overshooting it by around 1.3k:</p>
<ul>
<li>AMD Althon64 X2 4600 (dual core, clock speed of <strong>2.4GHz</strong>)</li>
<li>Gigabyte MA78GM-S2H mobo based on the <strong><a href="http://www.amd.com/us-en/0,,3715_15532,00.html">AMD 780G</a></strong> chipset, featuring <strong>ATI Radeon 3200 HD</strong> IGP</li>
<li><strong>2GB</strong> DDR 667 RAM</li>
<li>Seagate Barracuda <strong>250GB SATA</strong> hard drive</li>
<li>A new 400W SMPS from a shady brand (Xtec, if I remember correctly)</li>
</ul>
<p>This does look neat!</p>
<p><a href="http://rajorshi.net/blog/wp-content/uploads/2008/08/img_16011.jpg"><img class="aligncenter size-medium wp-image-12" src="http://rajorshi.net/blog/wp-content/uploads/2008/08/img_16011-300x279.jpg" alt="" width="300" height="279" /></a></p>
<p>The <a href="http://www.gigabyte.com.tw/Products/Motherboard/Products_Spec.aspx?ProductID=2814">motherboard itself</a> was highly rated by tech articles on the internet, and it does boast an array of features. I&#8217;ve yet to test the performance of the IGP on this board. As per <a href="http://www.techtree.com/India/Reviews/Gigabyte_MA78GM-S2H/551-89418-636-1.html">this Techtree.com article</a>, this IGP is capable of allowing playable framerates at medium resolutions/quality details for quite recent games such as F.E.A.R, HL2: Lost Coast and Quake 4! Far Cry should also be playable, woo hoo!</p>
<p>The folks at the store assembled this setup, and I brought the cabinet home. Powered on, and was greeted with this message:</p>
<blockquote><p>GRUB: Loading stage 1.5&#8230;. Read Error</p></blockquote>
<p>Since I had two hard drives now (an older 80GB IDE/PATA drive, and the new SATA drive), I was half expecting things to go wrong. Hence, I had planned to perform a fresh dual boot setup of Ubuntu Hardy Heron and Windows XP on the new SATA drive. When I popped in the Windows XP bootable disc, and rebooted the system, the CD failed to boot.</p>
<p>I rebooted into the BIOS, and could not find the DVD drive listed anywhere. Trying to plug in the IDE cable and power supply for the DVD drive again did not help. Finally it dawned upon me that the master-slave configuration of the drive was probably incorrect for my new configuration. I switched the jumper at the back of the DVD drive. Voila! Not only was the DVD drive recognized, but GRUB was also able to boot everything properly!</p>
<p>I still plan to perform fresh OS installs on the SATA drive for better performance. For now, I&#8217;m continuing with my old XP install, and a fresh Ubuntu 8.04 install over the 7.10 installation (since I&#8217;ve had a few problems with ATI drivers on Gutsy, and wanted an excuse to upgrade to Hardy anyway).</p>
<p>I&#8217;ll probably post on the performance of the IGP and the new processor/RAM combo later. But from what I&#8217;ve seen, the toil has been well worth it <img src='http://rajorshi.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>~Raj</p>
<p></p>
<script type="text/javascript">
  addthis_url    = 'http%3A%2F%2Frajorshi.net%2Fblog%2F2008%2F08%2Fupgrading-my-rig%2F';
  addthis_title  = 'Upgrading+my+rig';
  addthis_pub    = '';
</script><script type="text/javascript" src="http://s7.addthis.com/js/addthis_widget.php?v=12" ></script>
]]></content:encoded>
			<wfw:commentRss>http://rajorshi.net/blog/2008/08/upgrading-my-rig/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

