<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Hi, in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951812#M19783</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I've read about Cilkscreen, but I haven't founded how to run it with my executable. I've tried te type: cilkscreen -- ray.exe 1 &amp;gt; fig.ppm, but it doesn't recognize the cilkscreen command.&lt;/P&gt;
&lt;P&gt;How can I run it in command prompt?&lt;/P&gt;</description>
    <pubDate>Tue, 16 Jul 2013 18:01:11 GMT</pubDate>
    <dc:creator>Julio_V_</dc:creator>
    <dc:date>2013-07-16T18:01:11Z</dc:date>
    <item>
      <title>Ray Tracing with Cilk Plus</title>
      <link>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951810#M19781</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I'm trying to parallelize a Ray Tracing code that I've found here (in C++): &lt;A href="http://www.ffconsultancy.com/languages/ray_tracer/comparison.html" target="_blank"&gt;http://www.ffconsultancy.com/languages/ray_tracer/comparison.html&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;I'm using Visual Studio 2012 + Intel C++ Composer XE. To run de executable, what I'm doing is to build with VS 2012, and run with cmd like this:&lt;/P&gt;
&lt;P&gt;cd "path to the debug folder"&lt;/P&gt;
&lt;P&gt;ray.exe 1 &amp;gt; fig.ppm&lt;/P&gt;
&lt;P&gt;The number 1 is the level of complexitity of the image, being 1 the lighter to be done, and "&amp;gt; fig.ppm" exports de results to a .ppm image. The program results in a sphere (level 1) or many spheres.&lt;/P&gt;
&lt;P&gt;The problem is, when I try to change de code to use Cilk, the results are wrong. Instead of showing the normal result for level 1, the image is completely messed up. I've tried to:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Change the two firsts "for" in the main to cilk_for (one at the time and both at the same time);&lt;/LI&gt;
&lt;LI&gt;While doing the #1, tried to add cilk_spawn before function calling;&lt;/LI&gt;
&lt;LI&gt;While doing #1 and #2, tried to add cilk_sync after the fourth "for".&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;All these attempts have resulted in wrong outputs.&lt;/P&gt;
&lt;P&gt;Can someone help me with this? Where should I add cilk_for, cilk_spawn and/or cilk_sync for this to work?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2013 00:06:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951810#M19781</guid>
      <dc:creator>Julio_V_</dc:creator>
      <dc:date>2013-07-16T00:06:51Z</dc:date>
    </item>
    <item>
      <title>While I haven't looked at</title>
      <link>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951811#M19782</link>
      <description>&lt;P&gt;While I haven't looked at your code yet, my instinctive reaction is you've got a race.&amp;nbsp; To prove it, run with a single worker.&amp;nbsp; If the image is correct, you need to find it and fix it.&lt;/P&gt;
&lt;P&gt;The Cilkscreen race detector is a free download which will watch the executing code and tell you about races in any possible schedule of the executed code.&amp;nbsp; It's available as part of the Intel Cilk Plus SDK at &lt;A href="http://cilkplus.org/download"&gt;http://cilkplus.org/download&lt;/A&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Barry&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2013 14:28:32 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951811#M19782</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2013-07-16T14:28:32Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951812#M19783</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I've read about Cilkscreen, but I haven't founded how to run it with my executable. I've tried te type: cilkscreen -- ray.exe 1 &amp;gt; fig.ppm, but it doesn't recognize the cilkscreen command.&lt;/P&gt;
&lt;P&gt;How can I run it in command prompt?&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2013 18:01:11 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951812#M19783</guid>
      <dc:creator>Julio_V_</dc:creator>
      <dc:date>2013-07-16T18:01:11Z</dc:date>
    </item>
    <item>
      <title>The Cilkscreen race detector</title>
      <link>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951813#M19784</link>
      <description>&lt;P&gt;The Cilkscreen race detector is part of the "Intel Cilk Plus SDK" which is a free download from the cilkplus.org website: &amp;nbsp;http://cilkplus.org/download . &amp;nbsp;The SDK also includes the Cilkview scalability analyzer. &amp;nbsp;Documentation on them is included in the download.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;- Barry&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2013 18:03:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951813#M19784</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2013-07-16T18:03:52Z</dc:date>
    </item>
    <item>
      <title>Hi,</title>
      <link>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951814#M19785</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I was able to install and run cilkscreen, but when I do, the executable stops working (image attached)&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jul 2013 19:24:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951814#M19785</guid>
      <dc:creator>Julio_V_</dc:creator>
      <dc:date>2013-07-16T19:24:49Z</dc:date>
    </item>
    <item>
      <title>I do not have anything that</title>
      <link>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951815#M19786</link>
      <description>&lt;P&gt;I do not have anything that views a ppm image, so I can't view the images produced by this. &amp;nbsp;Which makes working with it difficult.&lt;/P&gt;
&lt;P&gt;However, it's pretty obvious that you've got races. &amp;nbsp;Consider your main loop:&lt;/P&gt;
&lt;P&gt;[cpp]&lt;/P&gt;
&lt;P&gt;int main(int argc, char *argv[]) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; int level = 6, n = 512, ss = 4;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if (argc == 2) level = atoi(argv[1]);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Vec light = unitise(Vec(-1, -3, 2));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Scene *s(create(level, Vec(0, -1, 0), 1));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; "P5\n" &amp;lt;&amp;lt; n &amp;lt;&amp;lt; " " &amp;lt;&amp;lt; n &amp;lt;&amp;lt; "\n255\n";&lt;BR /&gt;&amp;nbsp; &amp;nbsp; for (int y=n-1; y&amp;gt;=0; --y)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int x=0; x&amp;lt;n; ++x) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; double g=0;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int dx=0; dx&amp;lt;ss; ++dx)&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for (int dy=0; dy&amp;lt;ss; ++dy) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Vec dir(unitise(Vec(x+dx*1./ss-n/2., y+dy*1./ss-n/2., n)));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; g += ray_trace(light, Ray(Vec(0, 0, -4), dir), *s);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; cout &amp;lt;&amp;lt; char(int(.5 + 255. * g / (ss*ss)));&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;&amp;nbsp; &amp;nbsp; delete s;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; return 0;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;[/cpp]&lt;/P&gt;
&lt;P&gt;Now consider making the loop over "dx" a cilk_for. &amp;nbsp;You'll be racing on the calculation of "g," which would be bad.&lt;/P&gt;
&lt;P&gt;Now consider moving the cilk_for out to the loop over "x." You've removed the race on "g" (since it's now a local inside the loop), but now you're racing on the output. &amp;nbsp;You'd need to buffer the row of information in memory and write it out at the completion of the loop over "x." &amp;nbsp;Be warned that if you use a simple array to hold the values, you risk performance problems due to false sharing as the threads write to adjacent elements of the array.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; - Barry&lt;/P&gt;</description>
      <pubDate>Wed, 17 Jul 2013 14:26:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Ray-Tracing-with-Cilk-Plus/m-p/951815#M19786</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2013-07-17T14:26:00Z</dc:date>
    </item>
  </channel>
</rss>

