<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Kyle Wu</title>
	
	<link>http://www.kylewu.net</link>
	<description>CodeGeek &amp; MacFan</description>
	<lastBuildDate>Fri, 27 Aug 2010 07:49:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/kylewu" /><feedburner:info uri="kylewu" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Install Erlang on Mac</title>
		<link>http://feedproxy.google.com/~r/kylewu/~3/WHiWHBSV94A/install-erlang-on-mac.html</link>
		<comments>http://www.kylewu.net/install-erlang-on-mac.html#comments</comments>
		<pubDate>Fri, 27 Aug 2010 07:49:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[erlang]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.kylewu.net/install-erlang-on-mac.html</guid>
		<description><![CDATA[Before install Erlang, please make sure GCC is installed.
1. Download Erlang source code from http://www.erlang.org/download.html
2. Unarchive the file
3. run Terminal and follow the steps
cd otp_src_R14A
./configure
make
sudo make install
4. type erl in Terminal, it should be ok now.
There is a plugin for XCode to use Erlang.
Download from http://sourceforge.net/projects/quickconnect/ , and run it.

© admin for Kyle Wu, 2010. [...]]]></description>
			<content:encoded><![CDATA[<p>Before install Erlang, please make sure GCC is installed.</p>
<p>1. Download Erlang source code from <a href="http://www.erlang.org/download.html">http://www.erlang.org/download.html</a></p>
<p>2. Unarchive the file</p>
<p>3. run Terminal and follow the steps</p>
<p>cd otp_src_R14A<br />
./configure<br />
make<br />
sudo make install</p>
<p>4. type erl in Terminal, it should be ok now.</p>
<p>There is a plugin for XCode to use Erlang.</p>
<p>Download from <a href="http://sourceforge.net/projects/quickconnect/">http://sourceforge.net/projects/quickconnect/</a> , and run it.</p>
<hr />
<p><small>© admin for <a href="http://www.kylewu.net">Kyle Wu</a>, 2010. |
<a href="http://www.kylewu.net/install-erlang-on-mac.html">Permalink</a> |
<a href="http://www.kylewu.net/install-erlang-on-mac.html#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.kylewu.net/install-erlang-on-mac.html&title=Install Erlang on Mac">del.icio.us</a>
<br/>
Post tags: <a href="http://www.kylewu.net/tag/erlang" rel="tag">erlang</a>, <a href="http://www.kylewu.net/tag/mac" rel="tag">mac</a>, <a href="http://www.kylewu.net/tag/software" rel="tag">Software</a><br/>
</small></p>
<p><a href="http://feedads.g.doubleclick.net/~a/YDvF1_UXZjzU89xiiOw7_TaAVUU/0/da"><img src="http://feedads.g.doubleclick.net/~a/YDvF1_UXZjzU89xiiOw7_TaAVUU/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/YDvF1_UXZjzU89xiiOw7_TaAVUU/1/da"><img src="http://feedads.g.doubleclick.net/~a/YDvF1_UXZjzU89xiiOw7_TaAVUU/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kylewu?a=WHiWHBSV94A:31lfcvbzvhk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/kylewu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=WHiWHBSV94A:31lfcvbzvhk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kylewu?i=WHiWHBSV94A:31lfcvbzvhk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=WHiWHBSV94A:31lfcvbzvhk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kylewu?i=WHiWHBSV94A:31lfcvbzvhk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=WHiWHBSV94A:31lfcvbzvhk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kylewu?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kylewu/~4/WHiWHBSV94A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.kylewu.net/install-erlang-on-mac.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.kylewu.net/install-erlang-on-mac.html</feedburner:origLink></item>
		<item>
		<title>Quickly turn off the screen in Mac</title>
		<link>http://feedproxy.google.com/~r/kylewu/~3/gzPKMLCAgew/quickly-turn-off-the-screen-in-mac.html</link>
		<comments>http://www.kylewu.net/quickly-turn-off-the-screen-in-mac.html#comments</comments>
		<pubDate>Sat, 14 Aug 2010 05:42:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[OS]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://www.kylewu.net/quickly-turn-off-the-screen-in-mac.html</guid>
		<description><![CDATA[Did you turn off the screen by pressing Fn ＋ F1 several times?
Try to use Ctrl + Shift + power button.
Don&#8217;t forget that cmd + opt + power button can make mac sleep.

© admin for Kyle Wu, 2010. &#124;
Permalink &#124;
One comment &#124;
Add to
del.icio.us

Post tags: mac
]]></description>
			<content:encoded><![CDATA[<p>Did you turn off the screen by pressing Fn ＋ F1 several times?</p>
<p>Try to use Ctrl + Shift + power button.</p>
<p>Don&#8217;t forget that cmd + opt + power button can make mac sleep.</p>
<hr />
<p><small>© admin for <a href="http://www.kylewu.net">Kyle Wu</a>, 2010. |
<a href="http://www.kylewu.net/quickly-turn-off-the-screen-in-mac.html">Permalink</a> |
<a href="http://www.kylewu.net/quickly-turn-off-the-screen-in-mac.html#comments">One comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.kylewu.net/quickly-turn-off-the-screen-in-mac.html&title=Quickly turn off the screen in Mac">del.icio.us</a>
<br/>
Post tags: <a href="http://www.kylewu.net/tag/mac" rel="tag">mac</a><br/>
</small></p>
<p><a href="http://feedads.g.doubleclick.net/~a/stVoLhmzx8EXvWg510kS62FHC9E/0/da"><img src="http://feedads.g.doubleclick.net/~a/stVoLhmzx8EXvWg510kS62FHC9E/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/stVoLhmzx8EXvWg510kS62FHC9E/1/da"><img src="http://feedads.g.doubleclick.net/~a/stVoLhmzx8EXvWg510kS62FHC9E/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kylewu?a=gzPKMLCAgew:SX9zfCIhEmk:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/kylewu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=gzPKMLCAgew:SX9zfCIhEmk:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kylewu?i=gzPKMLCAgew:SX9zfCIhEmk:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=gzPKMLCAgew:SX9zfCIhEmk:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kylewu?i=gzPKMLCAgew:SX9zfCIhEmk:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=gzPKMLCAgew:SX9zfCIhEmk:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kylewu?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kylewu/~4/gzPKMLCAgew" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.kylewu.net/quickly-turn-off-the-screen-in-mac.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.kylewu.net/quickly-turn-off-the-screen-in-mac.html</feedburner:origLink></item>
		<item>
		<title>Illinois Multicore Summer Course</title>
		<link>http://feedproxy.google.com/~r/kylewu/~3/-el5obsjVs0/illinois-multicore-summer-course.html</link>
		<comments>http://www.kylewu.net/illinois-multicore-summer-course.html#comments</comments>
		<pubDate>Sat, 24 Jul 2010 12:20:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[pthreads]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.kylewu.net/?p=662</guid>
		<description><![CDATA[The course of multicore is one week long (5 days actually).
Here is some key word during the course:
shared memory
OpenMP
PThreads
TBB (intel)
VS2010
Vectorization
GPU
java parallelism
Both TBB and VS2010 are very good tools to develop multicore programme. There are many websites about these topics.

© admin for Kyle Wu, 2010. &#124;
Permalink &#124;
3 comments &#124;
Add to
del.icio.us

Post tags: Eclipse, Java, parallel, pthreads, Tools
]]></description>
			<content:encoded><![CDATA[<p>The course of multicore is one week long (5 days actually).<br />
Here is some key word during the course:<br />
shared memory<br />
OpenMP<br />
PThreads<br />
TBB (intel)<br />
VS2010<br />
Vectorization<br />
GPU<br />
java parallelism</p>
<p>Both TBB and VS2010 are very good tools to develop multicore programme. There are many websites about these topics.</p>
<hr />
<p><small>© admin for <a href="http://www.kylewu.net">Kyle Wu</a>, 2010. |
<a href="http://www.kylewu.net/illinois-multicore-summer-course.html">Permalink</a> |
<a href="http://www.kylewu.net/illinois-multicore-summer-course.html#comments">3 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.kylewu.net/illinois-multicore-summer-course.html&title=Illinois Multicore Summer Course">del.icio.us</a>
<br/>
Post tags: <a href="http://www.kylewu.net/tag/eclipse" rel="tag">Eclipse</a>, <a href="http://www.kylewu.net/tag/java" rel="tag">Java</a>, <a href="http://www.kylewu.net/tag/parallel" rel="tag">parallel</a>, <a href="http://www.kylewu.net/tag/pthreads" rel="tag">pthreads</a>, <a href="http://www.kylewu.net/tag/tools" rel="tag">Tools</a><br/>
</small></p>
<p><a href="http://feedads.g.doubleclick.net/~a/_2cdK_iL7-StLB87h9v91eKENSQ/0/da"><img src="http://feedads.g.doubleclick.net/~a/_2cdK_iL7-StLB87h9v91eKENSQ/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/_2cdK_iL7-StLB87h9v91eKENSQ/1/da"><img src="http://feedads.g.doubleclick.net/~a/_2cdK_iL7-StLB87h9v91eKENSQ/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kylewu?a=-el5obsjVs0:AX9gNu9-x-w:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/kylewu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=-el5obsjVs0:AX9gNu9-x-w:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kylewu?i=-el5obsjVs0:AX9gNu9-x-w:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=-el5obsjVs0:AX9gNu9-x-w:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kylewu?i=-el5obsjVs0:AX9gNu9-x-w:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=-el5obsjVs0:AX9gNu9-x-w:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kylewu?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kylewu/~4/-el5obsjVs0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.kylewu.net/illinois-multicore-summer-course.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://www.kylewu.net/illinois-multicore-summer-course.html</feedburner:origLink></item>
		<item>
		<title>Fix ‘Taglist: Failed to generate tags’ in Vim</title>
		<link>http://feedproxy.google.com/~r/kylewu/~3/LS7XBW7Izxs/fix-taglist-failed-to-generate-tags-in-vim.html</link>
		<comments>http://www.kylewu.net/fix-taglist-failed-to-generate-tags-in-vim.html#comments</comments>
		<pubDate>Tue, 13 Jul 2010 07:15:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Vim]]></category>

		<guid isPermaLink="false">http://www.kylewu.net/?p=661</guid>
		<description><![CDATA[When open taglist in vim, it may says:
Taglist: Failed to generate tags for /my/path/to/file
ctags: illegal option &#8212; -^@usage: ctags [-BFadtuwvx] [-f tagsfile] file &#8230;
Solution is quite easy, open .vimrc and add the following line
let Tlist_Ctags_Cmd=&#8217;/location/ctags&#8217;
In my mbp, Snow Leopard, it is &#8216;/opt/local/var/macports/software/ctags/5.8_0/opt/local/bin/ctags&#8217; 

© admin for Kyle Wu, 2010. &#124;
Permalink &#124;
No comment &#124;
Add to
del.icio.us

Post tags: Software, [...]]]></description>
			<content:encoded><![CDATA[<p>When open taglist in vim, it may says:</p>
<blockquote><p>Taglist: Failed to generate tags for /my/path/to/file<br />
ctags: illegal option &#8212; -^@usage: ctags [-BFadtuwvx] [-f tagsfile] file &#8230;</p></blockquote>
<p>Solution is quite easy, open .vimrc and add the following line</p>
<blockquote><p>let Tlist_Ctags_Cmd=&#8217;/location/ctags&#8217;</p></blockquote>
<p>In my mbp, Snow Leopard, it is &#8216;/opt/local/var/macports/software/ctags/5.8_0/opt/local/bin/ctags&#8217; </p>
<hr />
<p><small>© admin for <a href="http://www.kylewu.net">Kyle Wu</a>, 2010. |
<a href="http://www.kylewu.net/fix-taglist-failed-to-generate-tags-in-vim.html">Permalink</a> |
<a href="http://www.kylewu.net/fix-taglist-failed-to-generate-tags-in-vim.html#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.kylewu.net/fix-taglist-failed-to-generate-tags-in-vim.html&title=Fix &#8216;Taglist: Failed to generate tags&#8217; in Vim">del.icio.us</a>
<br/>
Post tags: <a href="http://www.kylewu.net/tag/software" rel="tag">Software</a>, <a href="http://www.kylewu.net/tag/vim" rel="tag">Vim</a><br/>
</small></p>
<p><a href="http://feedads.g.doubleclick.net/~a/DEYMMt8fzea-aoqdgegVn-pHqSs/0/da"><img src="http://feedads.g.doubleclick.net/~a/DEYMMt8fzea-aoqdgegVn-pHqSs/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/DEYMMt8fzea-aoqdgegVn-pHqSs/1/da"><img src="http://feedads.g.doubleclick.net/~a/DEYMMt8fzea-aoqdgegVn-pHqSs/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kylewu?a=LS7XBW7Izxs:_LiPBM1E0RA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/kylewu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=LS7XBW7Izxs:_LiPBM1E0RA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kylewu?i=LS7XBW7Izxs:_LiPBM1E0RA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=LS7XBW7Izxs:_LiPBM1E0RA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kylewu?i=LS7XBW7Izxs:_LiPBM1E0RA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=LS7XBW7Izxs:_LiPBM1E0RA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kylewu?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kylewu/~4/LS7XBW7Izxs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.kylewu.net/fix-taglist-failed-to-generate-tags-in-vim.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.kylewu.net/fix-taglist-failed-to-generate-tags-in-vim.html</feedburner:origLink></item>
		<item>
		<title>Back to home</title>
		<link>http://feedproxy.google.com/~r/kylewu/~3/yQpdJ1BHKv4/back-to-home.html</link>
		<comments>http://www.kylewu.net/back-to-home.html#comments</comments>
		<pubDate>Wed, 30 Jun 2010 02:34:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[My Life]]></category>

		<guid isPermaLink="false">http://www.kylewu.net/?p=660</guid>
		<description><![CDATA[I have been in Sweden for 10 months. Now I&#8217;m back to China.
It&#8217;s so hot in China now. After I got out of airplane, I changed my cloth immediately. Another thing is that there are so many people in front of you 
I need some time to be used to this.

© admin for Kyle Wu, [...]]]></description>
			<content:encoded><![CDATA[<p>I have been in Sweden for 10 months. Now I&#8217;m back to China.<br />
It&#8217;s so hot in China now. After I got out of airplane, I changed my cloth immediately. Another thing is that there are so many people in front of you <img src='http://www.kylewu.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /><br />
I need some time to be used to this.</p>
<hr />
<p><small>© admin for <a href="http://www.kylewu.net">Kyle Wu</a>, 2010. |
<a href="http://www.kylewu.net/back-to-home.html">Permalink</a> |
<a href="http://www.kylewu.net/back-to-home.html#comments">One comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.kylewu.net/back-to-home.html&title=Back to home">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><a href="http://feedads.g.doubleclick.net/~a/7wxER1CHUAjYRw6-PlceVmManR0/0/da"><img src="http://feedads.g.doubleclick.net/~a/7wxER1CHUAjYRw6-PlceVmManR0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/7wxER1CHUAjYRw6-PlceVmManR0/1/da"><img src="http://feedads.g.doubleclick.net/~a/7wxER1CHUAjYRw6-PlceVmManR0/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kylewu?a=yQpdJ1BHKv4:vhHjsQQ4LWI:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/kylewu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=yQpdJ1BHKv4:vhHjsQQ4LWI:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kylewu?i=yQpdJ1BHKv4:vhHjsQQ4LWI:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=yQpdJ1BHKv4:vhHjsQQ4LWI:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kylewu?i=yQpdJ1BHKv4:vhHjsQQ4LWI:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=yQpdJ1BHKv4:vhHjsQQ4LWI:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kylewu?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kylewu/~4/yQpdJ1BHKv4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.kylewu.net/back-to-home.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.kylewu.net/back-to-home.html</feedburner:origLink></item>
		<item>
		<title>2010 World Cup Souch Africa</title>
		<link>http://feedproxy.google.com/~r/kylewu/~3/u02xHVM10fk/2010-world-cup-souch-africa.html</link>
		<comments>http://www.kylewu.net/2010-world-cup-souch-africa.html#comments</comments>
		<pubDate>Wed, 16 Jun 2010 13:21:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[My Life]]></category>

		<guid isPermaLink="false">http://www.kylewu.net/?p=659</guid>
		<description><![CDATA[
Brazil and North Korea, good luck. 

© admin for Kyle Wu, 2010. &#124;
Permalink &#124;
2 comments &#124;
Add to
del.icio.us

Post tags: 
]]></description>
			<content:encoded><![CDATA[<p><img src="http://img.fifa.com/imgml/worldcup/lngc/wc2010logo.png" alt="fifa" /><br />
Brazil and North Korea, good luck. </p>
<hr />
<p><small>© admin for <a href="http://www.kylewu.net">Kyle Wu</a>, 2010. |
<a href="http://www.kylewu.net/2010-world-cup-souch-africa.html">Permalink</a> |
<a href="http://www.kylewu.net/2010-world-cup-souch-africa.html#comments">2 comments</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.kylewu.net/2010-world-cup-souch-africa.html&title=2010 World Cup Souch Africa">del.icio.us</a>
<br/>
Post tags: <br/>
</small></p>
<p><a href="http://feedads.g.doubleclick.net/~a/wYW8c93gXl-iYStNV60jc5BgCok/0/da"><img src="http://feedads.g.doubleclick.net/~a/wYW8c93gXl-iYStNV60jc5BgCok/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/wYW8c93gXl-iYStNV60jc5BgCok/1/da"><img src="http://feedads.g.doubleclick.net/~a/wYW8c93gXl-iYStNV60jc5BgCok/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kylewu?a=u02xHVM10fk:1TfofZ5EQgg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/kylewu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=u02xHVM10fk:1TfofZ5EQgg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kylewu?i=u02xHVM10fk:1TfofZ5EQgg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=u02xHVM10fk:1TfofZ5EQgg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kylewu?i=u02xHVM10fk:1TfofZ5EQgg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=u02xHVM10fk:1TfofZ5EQgg:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kylewu?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kylewu/~4/u02xHVM10fk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.kylewu.net/2010-world-cup-souch-africa.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://www.kylewu.net/2010-world-cup-souch-africa.html</feedburner:origLink></item>
		<item>
		<title>QuickSort using pthreads</title>
		<link>http://feedproxy.google.com/~r/kylewu/~3/3-kIgrhBz50/quicksort-using-pthreads.html</link>
		<comments>http://www.kylewu.net/quicksort-using-pthreads.html#comments</comments>
		<pubDate>Sun, 06 Jun 2010 09:56:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[parallel]]></category>
		<category><![CDATA[pthreads]]></category>
		<category><![CDATA[UU]]></category>

		<guid isPermaLink="false">http://www.kylewu.net/?p=658</guid>
		<description><![CDATA[
#include &#60;pthread.h&#62;
#include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;math.h&#62;

#define NUM_THREADS 8

#define FRAND frand(1, 100)
#define frand(xmin, xmax) ( (double)xmin + (double)(xmax-xmin) * rand()/(double)RAND_MAX)

void serial&#40;double*, int, int&#41;;
int partition&#40;double*, int, int, int&#41;;
void swap&#40;double*, double *&#41;;

void parallel&#40;double*, int, int&#41;;
void* parallel_thread&#40;void *&#41;;

void print&#40;double*, int&#41;;
int check&#40;double*, double*, int&#41;;
int sorted&#40;double*, int&#41;;

int timer&#40;&#41;;

struct thread_data &#123;
&#160; &#160; double *array;
&#160; &#160; int left;
&#160; &#160; int right;
&#160; &#160; int current_depth;
&#160; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.flickr.com/photos/dickmann/4469468165/" class="tt-flickr tt-flickr-Square" title="Skybreaker"><img class="alignnone" src="http://farm3.static.flickr.com/2754/4469468165_5e69e70c22_s.jpg" alt="Skybreaker" width="1" height="1" /></a></p>
<div class="codecolorer-container c mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:600px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">#include &lt;pthread.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdio.h&gt;</span><br />
<span style="color: #339933;">#include &lt;stdlib.h&gt;</span><br />
<span style="color: #339933;">#include &lt;math.h&gt;</span><br />
<br />
<span style="color: #339933;">#define NUM_THREADS 8</span><br />
<br />
<span style="color: #339933;">#define FRAND frand(1, 100)</span><br />
<span style="color: #339933;">#define frand(xmin, xmax) ( (double)xmin + (double)(xmax-xmin) * rand()/(double)RAND_MAX)</span><br />
<br />
<span style="color: #993333;">void</span> serial<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*,</span> <span style="color: #993333;">int</span><span style="color: #339933;">,</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #993333;">int</span> partition<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*,</span> <span style="color: #993333;">int</span><span style="color: #339933;">,</span> <span style="color: #993333;">int</span><span style="color: #339933;">,</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #993333;">void</span> swap<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*,</span> <span style="color: #993333;">double</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #993333;">void</span> parallel<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*,</span> <span style="color: #993333;">int</span><span style="color: #339933;">,</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #993333;">void</span><span style="color: #339933;">*</span> parallel_thread<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #993333;">void</span> print<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*,</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #993333;">int</span> check<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*,</span> <span style="color: #993333;">double</span><span style="color: #339933;">*,</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #993333;">int</span> sorted<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*,</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #993333;">int</span> timer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
<span style="color: #993333;">struct</span> thread_data <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">double</span> <span style="color: #339933;">*</span>array<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> left<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> right<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> current_depth<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> depth<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span> <span style="color: #339933;">;</span><br />
<br />
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">const</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
<br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> n<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> num_threads<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">double</span><span style="color: #339933;">*</span> arrayA<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">double</span><span style="color: #339933;">*</span> arrayB<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> serial_time<span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> parallel_time<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>argc <span style="color: #339933;">!=</span> <span style="color: #0000dd;">3</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Please support an argument n<span style="color: #000099; font-weight: bold;">\n</span> quick n, where n is the size of matrix<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; n <span style="color: #339933;">=</span> atoi<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; num_threads <span style="color: #339933;">=</span> atoi<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; arrayA <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> malloc<span style="color: #009900;">&#40;</span>n <span style="color: #339933;">*</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; arrayB <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> malloc<span style="color: #009900;">&#40;</span>n <span style="color: #339933;">*</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> n<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; arrayA<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> FRAND<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; arrayB<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> arrayA<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//printf(&quot;Array :\n&quot;);</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//print(arrayA, n);</span><br />
<br />
&nbsp; &nbsp; serial_time <span style="color: #339933;">=</span> timer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; serial<span style="color: #009900;">&#40;</span>arrayA<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> n<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; serial_time <span style="color: #339933;">=</span> timer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> serial_time<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Serial time : %f <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> serial_time<span style="color: #339933;">/</span><span style="color:#800080;">1000000.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; parallel_time <span style="color: #339933;">=</span> timer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; parallel<span style="color: #009900;">&#40;</span>arrayB<span style="color: #339933;">,</span> n<span style="color: #339933;">,</span> num_threads<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; parallel_time <span style="color: #339933;">=</span> timer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> parallel_time<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Parallel time : %f <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> parallel_time<span style="color: #339933;">/</span><span style="color:#800080;">1000000.0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #808080; font-style: italic;">/*<br />
&nbsp; &nbsp; if (sorted(arrayA, n) != 1)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;A Not sorted\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; if (sorted(arrayB, n) != 1)<br />
&nbsp; &nbsp; {<br />
&nbsp; &nbsp; &nbsp; &nbsp; printf(&quot;B Not sorted\n&quot;);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return 1;<br />
&nbsp; &nbsp; }<br />
&nbsp; &nbsp; */</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>check<span style="color: #009900;">&#40;</span>arrayA<span style="color: #339933;">,</span> arrayB<span style="color: #339933;">,</span> n<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Different Result Error<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//printf(&quot;Result A:\n&quot;);</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//print(arrayA, n);</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//print(arrayB, n);</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">int</span> partition<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span> <span style="color: #339933;">*</span>A<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> left<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> right<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> pivotIndex<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> i<span style="color: #339933;">,</span>storeIndex<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">double</span> pivotValue <span style="color: #339933;">=</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>A<span style="color: #339933;">+</span>pivotIndex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; swap<span style="color: #009900;">&#40;</span>A<span style="color: #339933;">+</span>pivotIndex<span style="color: #339933;">,</span>A<span style="color: #339933;">+</span>right<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; storeIndex <span style="color: #339933;">=</span> left<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span>left<span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>right<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>A<span style="color: #339933;">+</span>i<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;=</span> pivotValue<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; swap<span style="color: #009900;">&#40;</span>A<span style="color: #339933;">+</span>i<span style="color: #339933;">,</span>A<span style="color: #339933;">+</span>storeIndex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; storeIndex<span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; swap<span style="color: #009900;">&#40;</span>A<span style="color: #339933;">+</span>storeIndex<span style="color: #339933;">,</span>A<span style="color: #339933;">+</span>right<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> storeIndex<span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
&nbsp;<br />
<span style="color: #993333;">void</span> serial<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span> <span style="color: #339933;">*</span>A<span style="color: #339933;">,</span><span style="color: #993333;">int</span> left<span style="color: #339933;">,</span><span style="color: #993333;">int</span> right<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> pivotIndex<span style="color: #339933;">,</span>pivotNewIndex<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>right <span style="color: #339933;">&gt;</span> left<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pivotIndex <span style="color: #339933;">=</span> left <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>right <span style="color: #339933;">-</span> left<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #0000dd;">2</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pivotNewIndex <span style="color: #339933;">=</span> partition<span style="color: #009900;">&#40;</span>A<span style="color: #339933;">,</span>left<span style="color: #339933;">,</span>right<span style="color: #339933;">,</span>pivotIndex<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; serial<span style="color: #009900;">&#40;</span>A<span style="color: #339933;">,</span>left<span style="color: #339933;">,</span>pivotNewIndex <span style="color: #339933;">-</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; serial<span style="color: #009900;">&#40;</span>A<span style="color: #339933;">,</span>pivotNewIndex <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">,</span>right<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> parallel<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*</span> A<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> n<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> num<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">struct</span> thread_data thread_data<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; pthread_t thread<span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #993333;">void</span><span style="color: #339933;">*</span> status<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; thread_data.<span style="color: #202020;">array</span> <span style="color: #339933;">=</span> A<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; thread_data.<span style="color: #202020;">left</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; thread_data.<span style="color: #202020;">right</span> <span style="color: #339933;">=</span> n<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; thread_data.<span style="color: #202020;">current_depth</span> <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; thread_data.<span style="color: #202020;">depth</span> <span style="color: #339933;">=</span> log2<span style="color: #009900;">&#40;</span>num<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; parallel_thread<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;</span>thread_data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span><span style="color: #339933;">*</span> parallel_thread<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span> <span style="color: #339933;">*</span>data<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">double</span> time<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Get data </span><br />
&nbsp; &nbsp; <span style="color: #993333;">struct</span> thread_data <span style="color: #339933;">*</span>my_data <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> thread_data<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>data<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">double</span><span style="color: #339933;">*</span> array <span style="color: #339933;">=</span> my_data<span style="color: #339933;">-&gt;</span>array<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> left <span style="color: #339933;">=</span> my_data<span style="color: #339933;">-&gt;</span>left<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> right <span style="color: #339933;">=</span> my_data<span style="color: #339933;">-&gt;</span>right<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> depth <span style="color: #339933;">=</span> my_data<span style="color: #339933;">-&gt;</span>depth<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> current_depth <span style="color: #339933;">=</span> my_data<span style="color: #339933;">-&gt;</span>current_depth<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// pthread attribute</span><br />
&nbsp; &nbsp; pthread_attr_t attr<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; pthread_attr_init<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>attr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; pthread_attr_setdetachstate<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>attr<span style="color: #339933;">,</span> PTHREAD_CREATE_JOINABLE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// threads array</span><br />
&nbsp; &nbsp; pthread_t <span style="color: #339933;">*</span>threads <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>pthread_t<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> malloc<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>depth <span style="color: #339933;">-</span> current_depth<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>pthread_t<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">struct</span> thread_data <span style="color: #339933;">*</span>thread_data_array <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> thread_data<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> malloc <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>depth <span style="color: #339933;">-</span> current_depth<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> thread_data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">void</span><span style="color: #339933;">*</span> status<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// variables for partition</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> l<span style="color: #339933;">,</span>r<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">double</span> pivot<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">double</span> temp<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> pivotIndex<span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> depth <span style="color: #339933;">-</span> current_depth<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// partition</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pivotIndex <span style="color: #339933;">=</span> left <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span>right<span style="color: #339933;">-</span>left<span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #0000dd;">2</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; l <span style="color: #339933;">=</span> left<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; r <span style="color: #339933;">=</span> right<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pivot <span style="color: #339933;">=</span> array<span style="color: #009900;">&#91;</span>pivotIndex<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; time <span style="color: #339933;">=</span> timer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>l <span style="color: #339933;">&lt;=</span> r<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>array <span style="color: #339933;">+</span> l<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> pivot<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; l<span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span>array <span style="color: #339933;">+</span> r<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> pivot<span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r<span style="color: #339933;">--;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>l <span style="color: #339933;">&lt;=</span> r<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; temp <span style="color: #339933;">=</span> array<span style="color: #009900;">&#91;</span>l<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array<span style="color: #009900;">&#91;</span>l<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> array<span style="color: #009900;">&#91;</span>r<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; array<span style="color: #009900;">&#91;</span>r<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> temp<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; l<span style="color: #339933;">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r<span style="color: #339933;">--;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// construct thread data</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; thread_data_array<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">array</span> <span style="color: #339933;">=</span> array<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; thread_data_array<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">left</span> <span style="color: #339933;">=</span> l<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; thread_data_array<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">right</span> <span style="color: #339933;">=</span> right<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; thread_data_array<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">depth</span> <span style="color: #339933;">=</span> depth<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; thread_data_array<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">current_depth</span> <span style="color: #339933;">=</span> current_depth <span style="color: #339933;">+</span> i <span style="color: #339933;">+</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//printf(&quot;new thread left %d right %d %d new %d\n&quot;, thread_data_array[i].left, thread_data_array[i].right, current_depth, thread_data_array[i].current_depth);</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pthread_create<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>threads<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>attr<span style="color: #339933;">,</span> parallel_thread<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span> <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">&amp;</span>thread_data_array<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// update local variable</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; right <span style="color: #339933;">=</span> r<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//time = timer();</span><br />
&nbsp; &nbsp; serial<span style="color: #009900;">&#40;</span>array<span style="color: #339933;">,</span> left<span style="color: #339933;">,</span> right<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//printf(&quot;%d begin serial sort left %d right %d\nTime : %lf\n&quot;, current_depth, left, right, (timer()-time) / 10e6);</span><br />
<br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> depth <span style="color: #339933;">-</span> current_depth<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; pthread_join<span style="color: #009900;">&#40;</span>threads<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>status<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">int</span> timer<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; <span style="color: #993333;">struct</span> timeval tv<span style="color: #339933;">;</span><br />
&nbsp; gettimeofday<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>tv<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> timezone<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span>tv.<span style="color: #202020;">tv_sec</span><span style="color: #339933;">*</span><span style="color: #0000dd;">1000000</span><span style="color: #339933;">+</span>tv.<span style="color: #202020;">tv_usec</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> swap<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span> <span style="color: #339933;">*</span>A<span style="color: #339933;">,</span> <span style="color: #993333;">double</span> <span style="color: #339933;">*</span>B<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">double</span> temp<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; temp <span style="color: #339933;">=</span> <span style="color: #339933;">*</span>A<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">*</span>A <span style="color: #339933;">=</span> <span style="color: #339933;">*</span>B<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #339933;">*</span>B <span style="color: #339933;">=</span> temp<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">void</span> print<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*</span> A<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> n<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> n<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%lf &quot;</span><span style="color: #339933;">,</span> A<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">int</span> check<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span><span style="color: #339933;">*</span> A<span style="color: #339933;">,</span> <span style="color: #993333;">double</span><span style="color: #339933;">*</span> B<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> n<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> n<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>A<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> B<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color:#800080;">10e-6</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.opengroup.org/onlinepubs/009695399/functions/printf.html"><span style="color: #000066;">printf</span></a><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>%d %lf %lf<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>i<span style="color: #339933;">,</span> A<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> B<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><br />
<br />
<span style="color: #993333;">int</span> sorted<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span> <span style="color: #339933;">*</span>A<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> n<span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> n<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>A<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> A<span style="color: #009900;">&#91;</span>i<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color:#800080;">10e-6</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">1</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></div>
<hr />
<p><small>© admin for <a href="http://www.kylewu.net">Kyle Wu</a>, 2010. |
<a href="http://www.kylewu.net/quicksort-using-pthreads.html">Permalink</a> |
<a href="http://www.kylewu.net/quicksort-using-pthreads.html#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.kylewu.net/quicksort-using-pthreads.html&title=QuickSort using pthreads">del.icio.us</a>
<br/>
Post tags: <a href="http://www.kylewu.net/tag/parallel" rel="tag">parallel</a>, <a href="http://www.kylewu.net/tag/pthreads" rel="tag">pthreads</a>, <a href="http://www.kylewu.net/tag/uu" rel="tag">UU</a><br/>
</small></p>
<p><a href="http://feedads.g.doubleclick.net/~a/JdQga6cfhTttC5_sGlDQCwPqCq0/0/da"><img src="http://feedads.g.doubleclick.net/~a/JdQga6cfhTttC5_sGlDQCwPqCq0/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/JdQga6cfhTttC5_sGlDQCwPqCq0/1/da"><img src="http://feedads.g.doubleclick.net/~a/JdQga6cfhTttC5_sGlDQCwPqCq0/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kylewu?a=3-kIgrhBz50:5no2lwP19RM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/kylewu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=3-kIgrhBz50:5no2lwP19RM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kylewu?i=3-kIgrhBz50:5no2lwP19RM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=3-kIgrhBz50:5no2lwP19RM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kylewu?i=3-kIgrhBz50:5no2lwP19RM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=3-kIgrhBz50:5no2lwP19RM:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kylewu?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kylewu/~4/3-kIgrhBz50" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.kylewu.net/quicksort-using-pthreads.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.kylewu.net/quicksort-using-pthreads.html</feedburner:origLink></item>
		<item>
		<title>Implementation of matrix multiplication fox algorithm using MPI</title>
		<link>http://feedproxy.google.com/~r/kylewu/~3/zWKr7V5crWo/implementation-of-matrix-multiplication-fox-algorithm-using-mpi.html</link>
		<comments>http://www.kylewu.net/implementation-of-matrix-multiplication-fox-algorithm-using-mpi.html#comments</comments>
		<pubDate>Wed, 05 May 2010 18:52:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[IT]]></category>
		<category><![CDATA[MPI]]></category>
		<category><![CDATA[parallel]]></category>

		<guid isPermaLink="false">http://www.kylewu.net/?p=655</guid>
		<description><![CDATA[ Software efficiency  always improves a lot by parallelizing. Here is an implementation of fox algorithm, which is one of the algorithms calculating matrix multiplication, using MPI.
Message Passing Interface (MPI) is a specification for an API that allows many computers to communicate with one another.
MPI is an parallel library to help programming. Its main idea is transferring messages between [...]]]></description>
			<content:encoded><![CDATA[<p><a class="tt-flickr tt-flickr-Square" title="Power" href="http://www.flickr.com/photos/boilermatt/4578284881/"><img class="alignnone" src="http://farm5.static.flickr.com/4016/4578284881_3cbe155aa6_s.jpg" alt="Power" width="1" height="1" /></a> Software efficiency  always improves a lot by parallelizing. Here is an implementation of fox algorithm, which is one of the algorithms calculating matrix multiplication, using MPI.</p>
<blockquote><p><strong><a title="MPI" href="http://en.wikipedia.org/wiki/Message_Passing_Interface" target="_blank">Message Passing Interface</a></strong><a title="MPI" href="http://en.wikipedia.org/wiki/Message_Passing_Interface" target="_blank"> (</a><strong><a title="MPI" href="http://en.wikipedia.org/wiki/Message_Passing_Interface" target="_blank">MPI</a></strong><a title="MPI" href="http://en.wikipedia.org/wiki/Message_Passing_Interface" target="_blank">)</a> is a specification for an API that allows many computers to communicate with one another.</p></blockquote>
<p>MPI is an parallel library to help programming. Its main idea is transferring messages between processes, which are paralleling running in different cores or even CPUs.</p>
<p>About fox algorithm, I recommend everyone read this <a title="fox algorithm" href="http://facultyfp.salisbury.edu/taanastasio/COSC490/Fall03/Lectures/FoxMM/example.pdf" target="_blank">pdf file</a>.</p>
<p>Here is my code.</p>
<p>(...)<br/>Read the rest of <a href="http://www.kylewu.net/implementation-of-matrix-multiplication-fox-algorithm-using-mpi.html">Implementation of matrix multiplication fox algorithm using MPI</a> (865 words)</p>
<hr />
<p><small>© admin for <a href="http://www.kylewu.net">Kyle Wu</a>, 2010. |
<a href="http://www.kylewu.net/implementation-of-matrix-multiplication-fox-algorithm-using-mpi.html">Permalink</a> |
<a href="http://www.kylewu.net/implementation-of-matrix-multiplication-fox-algorithm-using-mpi.html#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.kylewu.net/implementation-of-matrix-multiplication-fox-algorithm-using-mpi.html&title=Implementation of matrix multiplication fox algorithm using MPI">del.icio.us</a>
<br/>
Post tags: <a href="http://www.kylewu.net/tag/mpi" rel="tag">MPI</a>, <a href="http://www.kylewu.net/tag/parallel" rel="tag">parallel</a><br/>
</small></p>
<p><a href="http://feedads.g.doubleclick.net/~a/5QR86OPC4C_OmDYlQxGnxQUdFaw/0/da"><img src="http://feedads.g.doubleclick.net/~a/5QR86OPC4C_OmDYlQxGnxQUdFaw/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/5QR86OPC4C_OmDYlQxGnxQUdFaw/1/da"><img src="http://feedads.g.doubleclick.net/~a/5QR86OPC4C_OmDYlQxGnxQUdFaw/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kylewu?a=zWKr7V5crWo:IkuzTqadv7M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/kylewu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=zWKr7V5crWo:IkuzTqadv7M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kylewu?i=zWKr7V5crWo:IkuzTqadv7M:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=zWKr7V5crWo:IkuzTqadv7M:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kylewu?i=zWKr7V5crWo:IkuzTqadv7M:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=zWKr7V5crWo:IkuzTqadv7M:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kylewu?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kylewu/~4/zWKr7V5crWo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.kylewu.net/implementation-of-matrix-multiplication-fox-algorithm-using-mpi.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.kylewu.net/implementation-of-matrix-multiplication-fox-algorithm-using-mpi.html</feedburner:origLink></item>
		<item>
		<title>My travel : Stockholm and Helsinki</title>
		<link>http://feedproxy.google.com/~r/kylewu/~3/qkC9m3Q5cok/my-travel-stockholm-and-helsinki.html</link>
		<comments>http://www.kylewu.net/my-travel-stockholm-and-helsinki.html#comments</comments>
		<pubDate>Sat, 01 May 2010 07:54:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[My Life]]></category>
		<category><![CDATA[Sweden]]></category>

		<guid isPermaLink="false">http://www.kylewu.net/?p=653</guid>
		<description><![CDATA[ It&#8217;s my first time leave Uppsala since I came to Sweden.


More pictures : Helsinki, Stockholm

© admin for Kyle Wu, 2010. &#124;
Permalink &#124;
No comment &#124;
Add to
del.icio.us

Post tags: Sweden
]]></description>
			<content:encoded><![CDATA[<p><a class="tt-flickr tt-flickr-Square" title=".. تــرى الــذكــرى ولــو حـــلـوه" href="http://www.flickr.com/photos/mariquita-qtr/4469836895/"><img class="alignnone" src="http://farm3.static.flickr.com/2789/4469836895_64afc6e3e7_s.jpg" alt=".. تــرى الــذكــرى ولــو حـــلـوه" width="1" height="1" /></a> It&#8217;s my first time leave Uppsala since I came to Sweden.</p>
<p><a title="Helsinki, on Flickr" href="http://www.flickr.com/photos/wenbinwu/4566959931/"><img src="http://farm4.static.flickr.com/3023/4566959931_f69b738518.jpg" alt="Helsinki" width="500" height="375" /></a></p>
<p><a title="Stockholm, on Flickr" href="http://www.flickr.com/photos/wenbinwu/4566962299/"><img src="http://farm4.static.flickr.com/3145/4566962299_fb1ba40a9c.jpg" alt="Stockholm" width="375" height="500" /></a></p>
<p>More pictures : <a title="Helsinki" href="http://www.flickr.com/photos/wenbinwu/sets/72157623966819926/" target="_blank">Helsinki</a>, <a title="Stockholm" href="http://www.flickr.com/photos/wenbinwu/sets/72157623966818288/" target="_blank">Stockholm</a></p>
<hr />
<p><small>© admin for <a href="http://www.kylewu.net">Kyle Wu</a>, 2010. |
<a href="http://www.kylewu.net/my-travel-stockholm-and-helsinki.html">Permalink</a> |
<a href="http://www.kylewu.net/my-travel-stockholm-and-helsinki.html#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.kylewu.net/my-travel-stockholm-and-helsinki.html&title=My travel : Stockholm and Helsinki">del.icio.us</a>
<br/>
Post tags: <a href="http://www.kylewu.net/tag/sweden" rel="tag">Sweden</a><br/>
</small></p>
<p><a href="http://feedads.g.doubleclick.net/~a/Eb6Y1V79Zf5sCVnPhNm6nF4Rk6k/0/da"><img src="http://feedads.g.doubleclick.net/~a/Eb6Y1V79Zf5sCVnPhNm6nF4Rk6k/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/Eb6Y1V79Zf5sCVnPhNm6nF4Rk6k/1/da"><img src="http://feedads.g.doubleclick.net/~a/Eb6Y1V79Zf5sCVnPhNm6nF4Rk6k/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kylewu?a=qkC9m3Q5cok:KxZeZR9z1wo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/kylewu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=qkC9m3Q5cok:KxZeZR9z1wo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kylewu?i=qkC9m3Q5cok:KxZeZR9z1wo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=qkC9m3Q5cok:KxZeZR9z1wo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kylewu?i=qkC9m3Q5cok:KxZeZR9z1wo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=qkC9m3Q5cok:KxZeZR9z1wo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kylewu?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kylewu/~4/qkC9m3Q5cok" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.kylewu.net/my-travel-stockholm-and-helsinki.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.kylewu.net/my-travel-stockholm-and-helsinki.html</feedburner:origLink></item>
		<item>
		<title>Parallel programming and viking line travel</title>
		<link>http://feedproxy.google.com/~r/kylewu/~3/PQ2zElmia4A/parallel-programming-and-viking-line-travel.html</link>
		<comments>http://www.kylewu.net/parallel-programming-and-viking-line-travel.html#comments</comments>
		<pubDate>Mon, 19 Apr 2010 07:29:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[My Life]]></category>
		<category><![CDATA[Uppsala]]></category>

		<guid isPermaLink="false">http://www.kylewu.net/?p=652</guid>
		<description><![CDATA[ It is a long time since my last post. I have only one course this period, parallel programming. Very good, useful course.
And spring is coming, I decide to go to Helsinki at the end of this month. I have been in Uppsala for 9 months, so I hope it will be a nice trip.

© [...]]]></description>
			<content:encoded><![CDATA[<p><a class="tt-flickr tt-flickr-Square" title="things to come" href="http://www.flickr.com/photos/dyrkwyst/4362968026/"><img class="alignnone" src="http://farm3.static.flickr.com/2698/4362968026_7ec21844d4_s.jpg" alt="things to come" width="1" height="1" /></a> It is a long time since my last post. I have only one course this period, parallel programming. Very good, useful course.</p>
<p>And spring is coming, I decide to go to Helsinki at the end of this month. I have been in Uppsala for 9 months, so I hope it will be a nice trip.</p>
<hr />
<p><small>© admin for <a href="http://www.kylewu.net">Kyle Wu</a>, 2010. |
<a href="http://www.kylewu.net/parallel-programming-and-viking-line-travel.html">Permalink</a> |
<a href="http://www.kylewu.net/parallel-programming-and-viking-line-travel.html#comments">No comment</a> |
Add to
<a href="http://del.icio.us/post?url=http://www.kylewu.net/parallel-programming-and-viking-line-travel.html&title=Parallel programming and viking line travel">del.icio.us</a>
<br/>
Post tags: <a href="http://www.kylewu.net/tag/uppsala" rel="tag">Uppsala</a><br/>
</small></p>
<p><a href="http://feedads.g.doubleclick.net/~a/2KSP392FjVpY_k9uwHhkIwwAmis/0/da"><img src="http://feedads.g.doubleclick.net/~a/2KSP392FjVpY_k9uwHhkIwwAmis/0/di" border="0" ismap="true"></img></a><br/>
<a href="http://feedads.g.doubleclick.net/~a/2KSP392FjVpY_k9uwHhkIwwAmis/1/da"><img src="http://feedads.g.doubleclick.net/~a/2KSP392FjVpY_k9uwHhkIwwAmis/1/di" border="0" ismap="true"></img></a></p><div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/kylewu?a=PQ2zElmia4A:ZgAvWCBBONw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/kylewu?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=PQ2zElmia4A:ZgAvWCBBONw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/kylewu?i=PQ2zElmia4A:ZgAvWCBBONw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=PQ2zElmia4A:ZgAvWCBBONw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/kylewu?i=PQ2zElmia4A:ZgAvWCBBONw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/kylewu?a=PQ2zElmia4A:ZgAvWCBBONw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/kylewu?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/kylewu/~4/PQ2zElmia4A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.kylewu.net/parallel-programming-and-viking-line-travel.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.kylewu.net/parallel-programming-and-viking-line-travel.html</feedburner:origLink></item>
	</channel>
</rss>
