<?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 Well, to start with, the in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026634#M40367</link>
    <description>&lt;P&gt;Well, to start with, the value of a reducer in the middle of a parallel region is undefined, since the computation hasn't completed yet. I *think* what you want is to move the declaration of your reducer inside the outer cilk_for.&lt;/P&gt;

&lt;P&gt;Of course, then there's the question of why you need the inner cilk_for at all. It's not all that much work. Then you can just move the declaration of "number" inside the cilk_for, and each of the cilk_for iterations will have their own copy.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Barry&lt;/P&gt;</description>
    <pubDate>Tue, 19 Aug 2014 19:54:05 GMT</pubDate>
    <dc:creator>Barry_T_Intel</dc:creator>
    <dc:date>2014-08-19T19:54:05Z</dc:date>
    <item>
      <title>Data race problem</title>
      <link>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026633#M40366</link>
      <description>&lt;P&gt;P1 and P2 data race problems &amp;nbsp;are appear when I inspect program . I haven`t got&amp;nbsp;experience about Cilk Plus. I guess error is occur in nested loop . What should I do ?&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;    char * primary;
    char * secondary;
    primary = ( char * ) malloc (size * 15);
    secondary = ( char * ) malloc (size);

    cilk::reducer_opadd&amp;lt;long&amp;gt;number (0);

.  .  .  .

    cilk_for (int i= 0; i &amp;lt; size ; ++i)
    {
        cilk_for (int j = 14;  j &amp;gt;= 0;  --j )
        {
            number += (primary [(14 -  j ) + ( i * 15)] * (pow (3 ,  j )));
        }

        if (secondary [number.get_value ()] == 0)
        {
            secondary [number.get_value ()] = 1;
        }
        number.set_value (0);
    }

.  .  .  .&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Aug 2014 17:15:47 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026633#M40366</guid>
      <dc:creator>Ömer_Faruk_Kalkan</dc:creator>
      <dc:date>2014-08-19T17:15:47Z</dc:date>
    </item>
    <item>
      <title>Well, to start with, the</title>
      <link>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026634#M40367</link>
      <description>&lt;P&gt;Well, to start with, the value of a reducer in the middle of a parallel region is undefined, since the computation hasn't completed yet. I *think* what you want is to move the declaration of your reducer inside the outer cilk_for.&lt;/P&gt;

&lt;P&gt;Of course, then there's the question of why you need the inner cilk_for at all. It's not all that much work. Then you can just move the declaration of "number" inside the cilk_for, and each of the cilk_for iterations will have their own copy.&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; - Barry&lt;/P&gt;</description>
      <pubDate>Tue, 19 Aug 2014 19:54:05 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026634#M40367</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2014-08-19T19:54:05Z</dc:date>
    </item>
    <item>
      <title> </title>
      <link>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026635#M40368</link>
      <description>&lt;DIV class="line alt2" style="line-height: 14.30880069732666px; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; color: rgb(96, 96, 96); margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; min-height: inherit !important; background: none rgb(248, 248, 248) !important;"&gt;
	&lt;DIV class="line alt2" style="line-height: 14.30880069732666px; font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; color: rgb(96, 96, 96); margin: 0px !important; padding: 0px !important; border: 0px !important; outline: 0px !important; float: none !important; vertical-align: baseline !important; position: static !important; left: auto !important; top: auto !important; right: auto !important; bottom: auto !important; height: auto !important; width: auto !important; min-height: inherit !important; background: none rgb(248, 248, 248) !important;"&gt;
		&lt;P&gt;&amp;nbsp;&lt;/P&gt;

		&lt;P&gt;&lt;SPAN style="color: rgb(96, 96, 96); font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; line-height: 14.30880069732666px; background-color: rgb(248, 248, 248);"&gt;I understood inner cilk_for is&amp;nbsp;unnecessary . I have changed following way but data races are&amp;nbsp;&lt;/SPAN&gt;continuing.&lt;/P&gt;

		&lt;P&gt;exactly why the error is due ? Can show me over my code...&lt;/P&gt;

		&lt;P&gt;&amp;nbsp;&lt;/P&gt;

		&lt;PRE class="brush:cpp;"&gt; cilk::reducer_opadd&amp;lt;long&amp;gt;count (0);

cilk_for (int i= 0; i &amp;lt; size ; ++i)
    {
        for (int j = 14;  j &amp;gt;= 0;  --j )
        {
            number += (primary [(14 -  j ) + ( i * 15)] * (pow (3 ,  j )));
        }

        if (secondary [number.get_value ()] == 0)
        {
            secondary [number.get_value ()] = 1;,
            count++;
        }

        number.set_value (0);
    }
&lt;/PRE&gt;

		&lt;P&gt;&amp;nbsp;&lt;/P&gt;

		&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Ekran 3Alıntısı.PNG"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/7008iC9C21BE8E57CDD1A/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="Ekran 3Alıntısı.PNG" alt="Ekran 3Alıntısı.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;

		&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="Ekran Alıntıs2ı.PNG"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/7009i66D905231B943BA9/image-size/large?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="Ekran Alıntıs2ı.PNG" alt="Ekran Alıntıs2ı.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
	&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 19 Aug 2014 20:57:17 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026635#M40368</guid>
      <dc:creator>Ömer_Faruk_Kalkan</dc:creator>
      <dc:date>2014-08-19T20:57:17Z</dc:date>
    </item>
    <item>
      <title>A cilk_for loop runs all</title>
      <link>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026636#M40369</link>
      <description>&lt;P&gt;A cilk_for loop runs all iterations of the loop in parallel. You have no need of "number" outside of the cilk_for loop, so why bother with the reducer? Instead write:&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;cilk_for (int i= 0; i &amp;lt; size ; ++i)
    {
        long number = 0;

        for (int j = 14;  j &amp;gt;= 0;  --j )
        {
            number += (primary [(14 -  j ) + ( i * 15)] * (pow (3 ,  j )));
        }
 
        if (secondary [number] == 0)
        {
            secondary [number] = 1;,
            count++;
        }
    }
&lt;/PRE&gt;

&lt;P&gt;Now each iteration of your loop has a private copy of "number." Of course, you've still got a race on "count". &lt;STRONG&gt;That&lt;/STRONG&gt; may want to be an op_add reducer.&lt;/P&gt;

&lt;P&gt;&amp;nbsp; &amp;nbsp;- Barry&lt;/P&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Aug 2014 21:06:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026636#M40369</guid>
      <dc:creator>Barry_T_Intel</dc:creator>
      <dc:date>2014-08-19T21:06:52Z</dc:date>
    </item>
    <item>
      <title>I get it now. Data race</title>
      <link>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026637#M40370</link>
      <description>&lt;P&gt;I get it now. Data race&amp;nbsp;problems were solved. Thank you very much :)&amp;nbsp;Do you have resources that you recommend for learning parallel programming ?&amp;nbsp;Where should I start ...&lt;/P&gt;</description>
      <pubDate>Tue, 19 Aug 2014 23:23:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Data-race-problem/m-p/1026637#M40370</guid>
      <dc:creator>Ömer_Faruk_Kalkan</dc:creator>
      <dc:date>2014-08-19T23:23:28Z</dc:date>
    </item>
  </channel>
</rss>

