<?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>Rubén Penalva&#039;s Blog</title>
	<atom:link href="http://www.rpenalva.com/blog/?feed=rss2&#038;p=243" rel="self" type="application/rss+xml" />
	<link>http://www.rpenalva.com/blog</link>
	<description>Computer graphics, tech demos and another thoughts...</description>
	<lastBuildDate>Thu, 11 Oct 2012 17:51:17 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Test: Gpu Raymarch of Distance fields</title>
		<link>http://www.rpenalva.com/blog/?p=254</link>
		<comments>http://www.rpenalva.com/blog/?p=254#comments</comments>
		<pubDate>Wed, 20 Apr 2011 21:39:34 +0000</pubDate>
		<dc:creator>Ruben Penalva</dc:creator>
				<category><![CDATA[Codepixel]]></category>
		<category><![CDATA[Tests]]></category>

		<guid isPermaLink="false">http://www.rpenalva.com/blog/?p=254</guid>
		<description><![CDATA[Features Ray marching of distance fields done on the Gpu inspired by IQ demo &#8220;Slisesix&#8221; and  Shadertoy. The video shows two scenes rendered with a pixel shader: the simple scene showing basic distance fields and the more elaborated one, showing procedural distance fields and shading. Report This test is heavily inspired by the IQ&#8217;s work [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rpenalva.com/blog/?p=254"><em>Click here to view the embedded video.</em></a></p>
<p><strong>Features</strong></p>
<ul>
<li>Ray marching of distance fields done on the Gpu inspired by <a href="http://www.iquilezles.org/prods/index.htm">IQ demo &#8220;Slisesix&#8221;</a> and  <a href="http://www.iquilezles.org/apps/shadertoy/">Shadertoy</a>. The video shows two scenes rendered with a pixel shader: the simple scene showing basic distance fields and the more elaborated one, showing procedural distance fields and shading.</li>
</ul>
<p><span id="more-254"></span><img title="More..." src="http://www.rpenalva.com/blog/wp-includes/js/tinymce/plugins/wordpress/img/trans.gif" alt="" /></p>
<p><strong>Report</strong></p>
<p>This test is heavily inspired by the IQ&#8217;s work done on ray marching and his several raymarched demos. The test builds the pixel shader, which is the ray marcher, on the fly everytime the shader changes. The algorithm is as straightforward as cast a ray, sample the distance in a position and advance to the next with the distance obtained until you reach a minimun distance or a maximun number of iterations. The distance fields are functions like spheres, cylinders and torus. The fun comes with the csg operators you can use like union or difference. I have had a great amount of fun developing the procedural distance fields but requires a lot of tweaking and time.</p>
<p><strong>Controls</strong></p>
<ul>
<li>Left click plus mouse movement to rotate the camera around the center of the scene.</li>
</ul>
<p><strong>Technology</strong></p>
<ul>
<li>C++</li>
<li>Boost</li>
<li>Opengl 2.0</li>
<li>Glew</li>
<li>CMake</li>
<li>Microsoft Visual Studio 2010</li>
<li>Subversion</li>
<li>Redmine</li>
<li>Windows 7 x64</li>
</ul>
<p><strong>Develop/Build/Test Machine Specs </strong></p>
<ul>
<li>Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz</li>
<li>3072 Mb RAM</li>
<li>Nvidia GeForce GTX 260</li>
<li>Nvidia Driver Version: 260.99</li>
<li>Microsoft Windows 7 Professional x64</li>
</ul>
<p><strong>Resources</strong></p>
<ul>
<li><a href="http://www.iquilezles.org/www/articles/raymarchingdf/raymarchingdf.htm">Raymarching distance fields</a> by IQ</li>
<li><a href="http://graphics.cs.uiuc.edu/~jch/papers/zeno.pdf">Sphere tracing:a geometric methodfor the antialiased raytracing of implicitsurfaces</a> by John C. Hart</li>
<li><a href="http://www.iquilezles.org/www/articles/terrainmarching/terrainmarching.htm">Terrain raymarching</a> by IQ</li>
<li><a href="http://www.iquilezles.org/www/material/nvscene2008/rwwtt.pdf">Rendering worlds with two triangles with raytracing on the GPU in 4096 bytes</a> by IQ</li>
<li><a href="http://www.iquilezles.org/www/material/function2009/function2009.pdf">Behind elevated</a> by IQ</li>
<li><a href="http://www.iquilezles.org/www/articles/proceduralgfx/inspire2008.pdf">Making graphics in 4 kilobytes</a> by IQ</li>
<li><a href="http://www.iquilezles.org/www/articles/fog/fog.htm">Better fog</a> by IQ</li>
<li><a href="http://www.iquilezles.org/apps/shadertoy/">Shadertoy</a> by IQ</li>
<li><a href="http://www.ozone3d.net/tutorials/glsl_fog/p03.php">Fog in GLSL</a> by oZone3D.Net</li>
<li><a href="http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter19.html">Gpu Gems 2. Chapter 19. Generic refraction simulation</a> by Tiago Sousa</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rpenalva.com/blog/?feed=rss2&#038;p=254</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Siggraph 2010</title>
		<link>http://www.rpenalva.com/blog/?p=243</link>
		<comments>http://www.rpenalva.com/blog/?p=243#comments</comments>
		<pubDate>Fri, 23 Jul 2010 22:18:11 +0000</pubDate>
		<dc:creator>Ruben Penalva</dc:creator>
				<category><![CDATA[Blog Things]]></category>

		<guid isPermaLink="false">http://www.rpenalva.com/blog/?p=243</guid>
		<description><![CDATA[As you may already know Siggraph 2010 is taking place this year at the LA Convention Center from 25th to 29th  July. I will be there, in fact I&#8217;m already, as a member of the Siggraph GraphicsNet team, which deploys and engineers the conference network. That means: running tons of cable through all the conference [...]]]></description>
				<content:encoded><![CDATA[<p style="text-align: left;"><a href="http://www.siggraph.org/s2010/"><img class="aligncenter size-medium wp-image-244" title="s2010_logo_lft" src="http://www.rpenalva.com/blog/wp-content/uploads/2010/07/s2010_logo_lft-300x98.jpg" alt="" width="300" height="98" /></a>As you may already know Siggraph 2010 is taking place this year at the LA Convention Center from 25th to 29th  July. I will be there, in fact I&#8217;m already, as a member of the Siggraph GraphicsNet team, which deploys and engineers the conference network. That means: running tons of cable through all the conference center!</p>
<p style="text-align: left;">Hopefully I will have some time to attend a talk or maybe a course. Anyway, if you want to catch me up during the conference just drop me an email.</p>
<p style="text-align: left;">Happy Siggraph everyone!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rpenalva.com/blog/?feed=rss2&#038;p=243</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test: Task based Flock Simulation</title>
		<link>http://www.rpenalva.com/blog/?p=234</link>
		<comments>http://www.rpenalva.com/blog/?p=234#comments</comments>
		<pubDate>Tue, 08 Jun 2010 23:15:02 +0000</pubDate>
		<dc:creator>Ruben Penalva</dc:creator>
				<category><![CDATA[Codepixel]]></category>
		<category><![CDATA[Tests]]></category>

		<guid isPermaLink="false">http://www.rpenalva.com/blog/?p=234</guid>
		<description><![CDATA[Features Flock simulation using tasks in order to keep busy all the cpu cores. It uses the Vista Pool Thread API to make a really simple wrap for send multiple tasks to the pool. The video shows how most of cpu cores (hardware threads) are not working under a heavy load of work with only [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rpenalva.com/blog/?p=234"><em>Click here to view the embedded video.</em></a></p>
<p><strong>Features</strong></p>
<ul>
<li>Flock simulation using tasks in order to keep busy all the cpu cores. It uses the Vista Pool Thread API to make a really simple wrap for send multiple tasks to the pool. The video shows how most of cpu cores (hardware threads) are not working under a heavy load of work with only one task in the pool. If the work is spread across multiple tasks, the video shows how all the cpu cores are busy.</li>
</ul>
<p><strong>Downloads</strong></p>
<ul>
<li><a href="http://www.rpenalva.com/downloads/tests/taskBasedFlockSim/TaskBasedFlockSim.zip">Source code</a></li>
</ul>
<p><span id="more-234"></span></p>
<p><strong>Report</strong></p>
<p>After seeing the gdc10 intel talk about tasks using the vista thread pool api,  I wanted to give it a try. So, the objective of this test is just try the thread pool api that vista provides. I dont try to get a massive amount of geometry on screen, just have something cpu intensive and appealing like a flock simulation algorithm.</p>
<p><strong>Controls</strong></p>
<ul>
<li>Left click plus mouse movement to rotate the camera around the flock.</li>
<li>Right click plus mouse move up/down to zoom in/out.</li>
</ul>
<p><strong>Technology</strong></p>
<ul>
<li>C++</li>
<li>Boost</li>
<li>Opengl 2.0</li>
<li>Qt</li>
<li>Freeglut</li>
<li>Glew</li>
<li>Microsoft Visual Studio 2008 Professional Edition</li>
<li>Subversion</li>
<li>Redmine</li>
<li>Windows 7 x64</li>
</ul>
<p><strong>Develop/Build/Test Machine Specs </strong></p>
<ul>
<li>Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz</li>
<li>3072 Mb RAM</li>
<li> Nvidia GeForce GTX 260</li>
<li>Nvidia Driver Version: 196.21 WHQL</li>
<li>Microsoft Windows 7 Professional x64</li>
</ul>
<p><strong>Resources</strong></p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/ms686766(VS.85).aspx">Vista Thread Pool API</a> from msdn</li>
<li><a href="http://www.red3d.com/cwr/steer/">&#8220;Steering Behaviors For Autonomous Characters&#8221;</a> by Craig Reynolds</li>
<li><a href="http://www.gdcvault.com/showConference.php?category=free&amp;conference=280&amp;expand_conferences=,280#conference280">“Task-based Multithreading — How to Program for 100 Cores”</a> by Ron Fosner</li>
<li><a href="http://en.wikipedia.org/wiki/Trefoil_knot">&#8220;Trefoil knot&#8221;</a> from Wikipedia</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rpenalva.com/blog/?feed=rss2&#038;p=234</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Test: CUDA Volume Raycasting</title>
		<link>http://www.rpenalva.com/blog/?p=229</link>
		<comments>http://www.rpenalva.com/blog/?p=229#comments</comments>
		<pubDate>Wed, 03 Mar 2010 00:02:53 +0000</pubDate>
		<dc:creator>Ruben Penalva</dc:creator>
				<category><![CDATA[Codepixel]]></category>
		<category><![CDATA[Tests]]></category>

		<guid isPermaLink="false">http://www.rpenalva.com/blog/?p=229</guid>
		<description><![CDATA[Features CUDA based application showing gpu volume raycasting using single pass Stegmaier et al. technique. Downloads Video Source code Report The cuda raycasting implementation is the same approach as the Stegmaier one but with some minor changes and simplifications: CUDA kernel The volume is a cube: width, height and depth are all the same. Proxy [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rpenalva.com/blog/?p=229"><em>Click here to view the embedded video.</em></a></p>
<p><strong>Features</strong></p>
<ul>
<li>CUDA based application showing gpu volume raycasting using single pass <a href="http://www.vis.uni-stuttgart.de/ger/research/pub/pub2005/vg2005-stegmaier.pdf">Stegmaier et al.</a> technique.</li>
</ul>
<p><strong>Downloads</strong></p>
<ul>
<li><a href="http://www.rpenalva.com/downloads/tests/cudaRayCasting/cudaraycasting.mov">Video</a></li>
<li><a href="http://www.rpenalva.com/downloads/tests/cudaRayCasting/CUDARayCasting.zip">Source code</a></li>
</ul>
<p><span id="more-229"></span></p>
<p><strong>Report</strong></p>
<p>The cuda raycasting implementation is the same approach as the Stegmaier one but with some minor changes and simplifications:</p>
<ul>
<li>CUDA kernel</li>
<li>The volume is a cube: width, height and depth are all the same.</li>
<li>Proxy geometry (the six quads or the cube) is normalized and translated so the center its the same as the center of the scene.</li>
</ul>
<p>The intersection code is really unoptimized. It&#8217;s just a straightforward implementation of the intersection ray-aabox function shown in <a href="http://realtimecollisiondetection.net/books/rtcd/">&#8220;Real time collision detection&#8221; by Christer Ericson</a>. I would suggest you to see the implementation of this function within the nvidia sdk volume render sample .</p>
<p><strong>Controls</strong></p>
<ul>
<li>Left click plus mouse movement to rotate the camera around the volume.</li>
<li>Right click to show the context menu.</li>
<li>Middle click plus vertical movement to increase/decrease the density window width.</li>
<li>Middle click plus horizontal movement to move right/left the density window.</li>
</ul>
<p><strong>Technology</strong></p>
<ul>
<li>C++</li>
<li>Opengl 2.1</li>
<li>CUDA</li>
<li>Glut for Win32</li>
<li>Glew</li>
<li>Microsoft Visual Studio 2008 Professional Edition</li>
<li>Subversion</li>
<li>Redmine</li>
</ul>
<p><strong>Develop/Build/Test Machine Specs </strong></p>
<ul>
<li>Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz</li>
<li>3072 Mb RAM</li>
<li> Nvidia GeForce GTX 260</li>
<li>Nvidia Driver Version: 196.21 WHQL</li>
<li>Microsoft Windows 7 Professional x64</li>
</ul>
<p><strong>Resources</strong></p>
<ul>
<li>[SSKE05] S. Stegmaier, M. Strengert, T. Klein, and T. Ertl.<br />
<a href="http://www.vis.uni-stuttgart.de/ger/research/pub/pub2005/vg2005-stegmaier.pdf"> A Simple and Flexible Volume Rendering Framework for Graphics-Hardware-based Raycasting</a>,<br />
Proceedings of Volume Graphics 2005, Stony Brook, New York, USA, pp.187-195, 2005</li>
<li><a href="http://www.vis.uni-stuttgart.de/ger/research/fields/current/spvolren/">A Simple and Flexible Volume Rendering Framework for Graphics-Hardware-based Raycasting</a> website. Includes paper, dataset and source code.</li>
<li><a href="http://www9.informatik.uni-erlangen.de/External/vollib/">The Volume Library</a></li>
<li><a href="http://developer.nvidia.com/object/gpucomputing.html">NVIDIA GPU Computing Developer Home Page</a></li>
<li><a href="http://glew.sourceforge.net/">GLEW: The OpenGL Extension Wrangler Library</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rpenalva.com/blog/?feed=rss2&#038;p=229</wfw:commentRss>
		<slash:comments>9</slash:comments>
<enclosure url="http://www.rpenalva.com/downloads/tests/cudaRayCasting/cudaraycasting.mov" length="4028107" type="video/quicktime" />
		</item>
		<item>
		<title>Test: GPU Volume Raycasting</title>
		<link>http://www.rpenalva.com/blog/?p=213</link>
		<comments>http://www.rpenalva.com/blog/?p=213#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:45:14 +0000</pubDate>
		<dc:creator>Ruben Penalva</dc:creator>
				<category><![CDATA[Codepixel]]></category>
		<category><![CDATA[Tests]]></category>

		<guid isPermaLink="false">http://www.rpenalva.com/blog/?p=213</guid>
		<description><![CDATA[Features Opengl based application showing gpu volume raycasting using single pass Stegmaier et al. technique. Downloads Video Source code Report The gpu raycasting implementation is the same approach as the Stegmaier one but with some minor changes and simplifications: GLSL shaders The volume is a cube: width, height and depth are all the same. Proxy [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://www.rpenalva.com/blog/?p=213"><em>Click here to view the embedded video.</em></a></p>
<p><strong>Features</strong></p>
<ul>
<li>Opengl based application showing gpu volume raycasting using single pass <a href="http://www.vis.uni-stuttgart.de/ger/research/pub/pub2005/vg2005-stegmaier.pdf">Stegmaier et al.</a> technique.</li>
</ul>
<p><strong>Downloads</strong></p>
<ul>
<li><a href="http://rpenalva.com/downloads/tests/gpuraycasting/gpuraycasting.mov">Video</a></li>
<li><a href="http://rpenalva.com/downloads/tests/gpuraycasting/GpuRayCasting.zip">Source code</a></li>
</ul>
<p><span id="more-213"></span></p>
<p><strong>Report</strong></p>
<p>The gpu raycasting implementation is the same approach as the Stegmaier one but with some minor changes and simplifications:</p>
<ul>
<li>GLSL shaders</li>
<li>The volume is a cube: width, height and depth are all the same.</li>
<li>Proxy geometry (the six quads or the cube) is normalized and translated so the center its the same as the center of the scene.</li>
</ul>
<p><strong>Controls</strong></p>
<ul>
<li>Left click plus mouse movement to rotate the camera around the volume.</li>
<li>Right click to show the context menu.</li>
<li>Middle click plus vertical movement to increase/decrease the density window width.</li>
<li>Middle click plus horizontal movement to move right/left the density window.</li>
</ul>
<p><strong>Technology</strong></p>
<ul>
<li>C++</li>
<li>Opengl 2.1</li>
<li>GLSL</li>
<li>Glut for Win32</li>
<li>Glew</li>
<li>Microsoft Visual Studio 2008 Professional Edition</li>
<li>Subversion</li>
<li>Redmine</li>
</ul>
<p><strong>Develop/Build/Test Machine Specs </strong></p>
<ul>
<li>Intel(R) Core(TM) i7 CPU 920 @ 2.67GHz</li>
<li>3072 Mb RAM</li>
<li> Nvidia GeForce GTX 260</li>
<li>Nvidia Driver Version: 196.21 WHQL</li>
<li>Microsoft Windows 7 Professional x64</li>
</ul>
<p><strong>Resources</strong></p>
<ul>
<li>[SSKE05] S. Stegmaier, M. Strengert, T. Klein, and T. Ertl.<br />
<a href="http://www.vis.uni-stuttgart.de/ger/research/pub/pub2005/vg2005-stegmaier.pdf"> A Simple and Flexible Volume Rendering Framework for Graphics-Hardware-based Raycasting</a>,<br />
Proceedings of Volume Graphics 2005, Stony Brook, New York, USA, pp.187-195, 2005</li>
<li><a href="http://www.vis.uni-stuttgart.de/ger/research/fields/current/spvolren/">A Simple and Flexible Volume Rendering Framework for Graphics-Hardware-based Raycasting</a> website. Includes paper, dataset and source code.</li>
<li><a href="http://www9.informatik.uni-erlangen.de/External/vollib/">The Volume Library</a></li>
<li><a href="http://glew.sourceforge.net/">GLEW: The OpenGL Extension Wrangler Library</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.rpenalva.com/blog/?feed=rss2&#038;p=213</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://rpenalva.com/downloads/tests/gpuraycasting/gpuraycasting.mov" length="6151663" type="video/quicktime" />
		</item>
		<item>
		<title>New adventure in Cambridge</title>
		<link>http://www.rpenalva.com/blog/?p=209</link>
		<comments>http://www.rpenalva.com/blog/?p=209#comments</comments>
		<pubDate>Mon, 12 Oct 2009 12:24:49 +0000</pubDate>
		<dc:creator>Ruben Penalva</dc:creator>
				<category><![CDATA[Blog Things]]></category>
		<category><![CDATA[Codepixel]]></category>

		<guid isPermaLink="false">http://www.rpenalva.com/blog/?p=209</guid>
		<description><![CDATA[Well, after some time without updating the blog I&#8217;m giving some life signals. Sorry for the lack of updates but I&#8217;ve been super busy moving to Cambridge. Yes, I moved to Cambridge to work for ArtVPS as a software developer. I&#8217;m working with real time ray tracing renderers, which is really cool. The people here [...]]]></description>
				<content:encoded><![CDATA[<p>Well, after some time without updating the blog I&#8217;m giving some life signals. Sorry for the lack of updates but I&#8217;ve been super busy moving to Cambridge. Yes, I moved to Cambridge to work for <a href="http://www.artvps.com/">ArtVPS</a> as a software developer. I&#8217;m working with real time ray tracing renderers, which is really cool. The people here are great professionals and I&#8217;m very pleased to have the opportunity to work with them.  As you could imagine I have no time to do anything aside searching a flat and getting used to listen English the whole day. I left my machine in Madrid, so no tech demos in a couple of months. I have to figure out how the hell I&#8217;m going to bring all that (2 monitors, a big case, 7.1 speakers,&#8230;..) to Cambridge.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rpenalva.com/blog/?feed=rss2&#038;p=209</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Summer blog break</title>
		<link>http://www.rpenalva.com/blog/?p=185</link>
		<comments>http://www.rpenalva.com/blog/?p=185#comments</comments>
		<pubDate>Thu, 23 Jul 2009 08:00:00 +0000</pubDate>
		<dc:creator>Ruben Penalva</dc:creator>
				<category><![CDATA[Blog Things]]></category>
		<category><![CDATA[Codepixel]]></category>

		<guid isPermaLink="false">http://www.rpenalva.com/blog/?p=185</guid>
		<description><![CDATA[I&#8217;m going to take a break from updating the blog. I will post again in September. Have a happy summer!]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m going to take a break from updating the blog. I will post again in September. Have a happy summer!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rpenalva.com/blog/?feed=rss2&#038;p=185</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ITC2009: Line Segment Intersection</title>
		<link>http://www.rpenalva.com/blog/?p=174</link>
		<comments>http://www.rpenalva.com/blog/?p=174#comments</comments>
		<pubDate>Sat, 04 Jul 2009 10:00:48 +0000</pubDate>
		<dc:creator>Ruben Penalva</dc:creator>
				<category><![CDATA[Codepixel]]></category>
		<category><![CDATA[Contests]]></category>

		<guid isPermaLink="false">http://www.rpenalva.com/blog/?p=174</guid>
		<description><![CDATA[The problem of this contest’s round was to find the intersections within a set of 3d line segments. I found tons of information in google about algorithms solving this problem in 2d. It seems that finding the intersections in a set of 2d line segments is a well known problem of computational geometry. Unfortunately, I [...]]]></description>
				<content:encoded><![CDATA[<p>The problem of this contest’s round was to find the intersections within a set of 3d line segments. I found tons of information in google about algorithms solving this problem in 2d. It seems that finding the intersections in a set of 2d line segments is a well known problem of computational geometry. Unfortunately, I didn’t find any algorithm in 3d and I wasn’t sure that converting the 2d algorithms to 3d could give better results than a brute force approach. Taking this into account, I decided to implement a brute force algorithm using a simple line segment intersection test. This approach gave ~800secs in a set of 100.000 line segments. I realized that the tests that were already tested could be skipped, after the modification the algorithm gave ~300secs. At this moment, I removed every instruction of the if intersection test statement (don’t ask why) resulting in a running time of ~6secs. This time was wrong. I was compiling with the optimizations active, so the compiler just removed the call to the intersection test function, giving a double nested loop doing pointer dereferencing. Well, after this little mistake I was ready to think in how to parallelize the algorithm.</p>
<p>As with the previous problem I used Threading Building Blocks as the tool to parallelize the algorithm. I chose to use the parallel_reduce algorithm, after trying to make it with parallel_for. The problem is gathering the results across all the tasks. Parallel_reduce is an easy way of collect results after the tasks completion. The algorithm includes a synchronization method: join. After a task ends the join method is called to merge the results. The parallel approach gave me a time of ~60secs.</p>
<p>I think the speed I got wasn’t that fast to win this round but that’s not my objective. I’m having a lot of fun, I’m learning from other people and I’m learning how to use TBB. Those are my objectives.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rpenalva.com/blog/?feed=rss2&#038;p=174</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ITC2009: Knapsack</title>
		<link>http://www.rpenalva.com/blog/?p=171</link>
		<comments>http://www.rpenalva.com/blog/?p=171#comments</comments>
		<pubDate>Sat, 20 Jun 2009 10:00:42 +0000</pubDate>
		<dc:creator>Ruben Penalva</dc:creator>
				<category><![CDATA[Codepixel]]></category>
		<category><![CDATA[Contests]]></category>

		<guid isPermaLink="false">http://www.rpenalva.com/blog/?p=171</guid>
		<description><![CDATA[The 5th problem of the Intel Threading Challenge 2009 Contest is a bounded knapsack  problem with real numbers instead of integers. You can get more information about knapsack problems in &#8220;Knapsack Problems: Algorithms and Computer Implementations&#8221;, Silvano Martello and Paolo Tooth, which is a free book.  I implemented a classical dynamic programming algorithm using Intel [...]]]></description>
				<content:encoded><![CDATA[<p>The 5th problem of the <a href="http://software.intel.com/en-us/contests/Threading-Challenge-2009/codecontest.php">Intel Threading Challenge 2009 Contest</a> is a bounded knapsack  problem with real numbers instead of integers. You can get more information about knapsack problems in <a href="http://www.or.deis.unibo.it/knapsack.html">&#8220;Knapsack Problems: Algorithms and Computer Implementations&#8221;, Silvano Martello and Paolo Tooth</a>, which is a free book.  I implemented a classical dynamic programming algorithm using <a href="http://www.threadingbuildingblocks.org/">Intel Threading Build Blocks</a> to parallelize it. More information on dynamic programming in <a href="http://mitpress.mit.edu/algorithms/">&#8220;Introduction to Algorithms, Second Edition&#8221;</a> .</p>
<p>The approach I took to solve the problem is really naive due time constraints. The problems I found were:</p>
<ul>
<li>Convert a bounded knapsack problem to a 0-1 knapsack problem.</li>
<li>Convert real number weights and benefits to integers.</li>
<li>Parallelization of the serial algorithm.</li>
<li>Memory efficiency.</li>
</ul>
<p>The serial algorithm is really naive:</p>
<ol>
<li>Convert the weights and values to integer numbers.</li>
<li>Convert the problem to a 0-1 knapsack problem repeating bounded limit times the items.</li>
<li>Solve 0-1 knapsack problems with a dynamic programming algorithm.</li>
<li>Trace back the items.</li>
</ol>
<p>As you see this approach is the classical example of dynamic programming you can find in textbooks. Although it has big problems when you try to solve big data.  Repeating the items bounded limit times its a really easy way to convert the problem but needs tons of memory. Multiplying by 100 makes the deal, but it can lead to rounding precision problems. The parallel algorithm is the same but using a &#8220;parallel_for&#8221; to replace the second for loop of the algorithm.</p>
<p>Well, the solution proposed is very naive, so I don&#8217;t expect good results in the contest. Anyway, I enjoyed the problem and I&#8217;m already thinking about the next one: &#8220;Segment intersection&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rpenalva.com/blog/?feed=rss2&#038;p=171</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intel Threading Challenge 2009</title>
		<link>http://www.rpenalva.com/blog/?p=158</link>
		<comments>http://www.rpenalva.com/blog/?p=158#comments</comments>
		<pubDate>Mon, 08 Jun 2009 11:59:42 +0000</pubDate>
		<dc:creator>Ruben Penalva</dc:creator>
				<category><![CDATA[Blog Things]]></category>
		<category><![CDATA[Codepixel]]></category>

		<guid isPermaLink="false">http://www.rpenalva.com/blog/?p=158</guid>
		<description><![CDATA[Intel Threading Challenge 2009 is an intel contest where you have to implement a multi-threaded solution for a given set of problems using any tech you want (not necessarily from intel) but taking into account the test machine specs. The problems are spawned every two weeks with 19 days to complete the task. There are [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://software.intel.com/en-us/contests/Threading-Challenge-2009/codecontest.php">Intel Threading Challenge 2009</a> is an intel contest where you have to implement a multi-threaded solution for a given set of problems using any tech  you want (not necessarily from intel) but taking into account the <a href="http://software.intel.com/file/15447">test machine specs</a>. The problems are spawned every two weeks with 19 days to complete the task. There are two phases with six problems to solve. The score in a phase will be the sum of your three best scored submitted solutions. The solution should include a kind of report and of course the source code. You can find <a href="http://software.intel.com/file/15448">here</a> an example of the report and more information about the rules, prizes, etc&#8230; <a href="http://software.intel.com/en-us/articles/threading-challenge-2009-official-rules/">here</a>. The contest is managed, or at least it seems so, by <span class="sectionHeading">Dr. Clay Breshears. As his <a href="http://software.intel.com/en-us/articles/threading-challenge-2009-meet-the-judges/">bio</a> shows, he is a really experienced engineer. Recently, he published a book on parallel programming &#8220;</span><a href="http://www.amazon.com/Art-Concurrency-Monkeys-Parallel-Applications/dp/0596521537">The Art of Concurrency: A Thread Monkey&#8217;s Guide to Writing Parallel Applications</a>&#8220;, which I&#8217;m going to buy after I read &#8220;<a href="http://www.amazon.com/Intel-Threading-Building-Blocks-Parallelism/dp/0596514808">Intel Threading Building Blocks: Outfitting C++ for Multi-core Processor Parallelism</a>&#8220;and &#8220;<a href="http://www.amazon.com/Art-Multiprocessor-Programming-Maurice-Herlihy/dp/0123705916">The Art of Multiprocessor Programming</a>&#8220;. By the way, he made a hell of a fun video about concurrent programming: &#8220;<a href="http://software.intel.com/en-us/videos/a-visual-guide-to-key-concepts-in-threaded-programming-Common-problems-and-how-to-solve-them/">A visual guide to key concepts in threaded programming – Common problems and how to solve them</a>&#8221;</p>
<p>I really don&#8217;t have much time but I could enjoy participating in this contest and well, it&#8217;s a nice excuse to get my hands on Threading Building Blocks. I&#8217;m going to give a try for the next couple of weeks to the first problem (bounded knapsack problem) and I will see if I have fun. Don&#8217;t expect any graphics related tests/tech demos in the meantime although I want to show something of the entry development. For the moment, I don&#8217;t know exactly what I&#8217;m going to show but I will.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rpenalva.com/blog/?feed=rss2&#038;p=158</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
