<?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 Nested For loops in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Nested-For-loops/m-p/739974#M35</link>
    <description>&lt;BR /&gt;&lt;BR /&gt;I underdstand that cilk_spawn and cilk_for can be nested. What I would like to know is what do you do about nested for loops? It seems that it might be okay to make the outer loop cilk_for, but oneshould not make the inner loop cilk_for.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Also, I have some legacy code that has some loops other than for, such as do while. Is the anything I can do about them? Is there some instruction for rewriting these loopsto for loops?&lt;BR /&gt;&lt;BR /&gt;Newport_j</description>
    <pubDate>Wed, 10 Nov 2010 14:08:09 GMT</pubDate>
    <dc:creator>newport_j</dc:creator>
    <dc:date>2010-11-10T14:08:09Z</dc:date>
    <item>
      <title>Nested For loops</title>
      <link>https://community.intel.com/t5/Software-Archive/Nested-For-loops/m-p/739974#M35</link>
      <description>&lt;BR /&gt;&lt;BR /&gt;I underdstand that cilk_spawn and cilk_for can be nested. What I would like to know is what do you do about nested for loops? It seems that it might be okay to make the outer loop cilk_for, but oneshould not make the inner loop cilk_for.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Also, I have some legacy code that has some loops other than for, such as do while. Is the anything I can do about them? Is there some instruction for rewriting these loopsto for loops?&lt;BR /&gt;&lt;BR /&gt;Newport_j</description>
      <pubDate>Wed, 10 Nov 2010 14:08:09 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Nested-For-loops/m-p/739974#M35</guid>
      <dc:creator>newport_j</dc:creator>
      <dc:date>2010-11-10T14:08:09Z</dc:date>
    </item>
    <item>
      <title>Nested For loops</title>
      <link>https://community.intel.com/t5/Software-Archive/Nested-For-loops/m-p/739975#M36</link>
      <description>&amp;gt; I underdstand that cilk_spawn and cilk_for can be nested. What I would like to know is what do you&lt;BR /&gt;&amp;gt;do about nested for loops? It seems that it might be okay to make the outer loop cilk_for, but one&lt;BR /&gt;&amp;gt;should not make the inner loop cilk_for.&lt;BR /&gt;&lt;BR /&gt;Nested cilk_for loops are no different from nesting cilk_for and cilk_spawn. Again, it's a balance thing. If you've got too little work in your spawned code, you'll have too much overhead. For example, in the loop&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;for (int x = 0; x &amp;lt; xmax; x++)
{
    for (int y = 0; y &amp;lt; ymax; y++)
    {
        for (int z = 0; z &amp;lt; zmax; z++)
        {
            [insert work on 3D points here]
        }
    }
}

&lt;/PRE&gt;I'd probably only make the outer loop a cilk_for loop, assuming that xmax was big enough, and there weren't race conditions introduced by parallelizing the outermost loop. The matrix-multiple sample gives an example of this.&lt;BR /&gt;&lt;BR /&gt;&amp;gt; Also, I have some legacy code that has some loops other than for, such as do while. Is the anything&lt;BR /&gt;&amp;gt;I can do about them? Is there some instruction for rewriting these loops to for loops?&lt;BR /&gt;&lt;BR /&gt;I've seen examples that gathers data in "chunks" together in a do/while loop, and then uses a cilk_for to parallelize the chunk. Something like:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE&gt;while (! done)
{
    data a[256];
    int i = 0;

    while ((! done) &amp;amp;&amp;amp; (i &amp;lt; 256))
    {
        a[i++] = generate_data();
    }

    cilk_for (int j = 0; j &amp;lt; i; j++)
    {
        process_data(a&lt;J&gt;);
    }
}

  - Barry&lt;/J&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Nov 2010 17:54:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Nested-For-loops/m-p/739975#M36</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2010-11-10T17:54:22Z</dc:date>
    </item>
  </channel>
</rss>

