<?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 openmp construct with, memcpy insides the for loop results in wrong output values in Intel® Moderncode for Parallel Architectures</title>
    <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/openmp-construct-with-memcpy-insides-the-for-loop-results-in/m-p/1180955#M8126</link>
    <description>&lt;P&gt;I'm trying to copy input buffer values into the multiple output buffers. To do this, i have used memcpy(..) inside the for loop. To get the better performance i have used the openmp construct outside of the for loop. I'm gaining some performance improvement but it results in wrong output buffer values.&lt;/P&gt;&lt;P&gt;In my project, i tried to use memcpy to copy some channels of input image into the output buffers. And i have used openmp construct outside of the loop. I am getting incorrect output values.&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;// sudo code to copy required channels from ipBuffer.
/* ipBuffer - input buffer 
 * opBuffer[] - Array of output bufferc
 * opChnls[] - How many channels does each ouput buffer needed from input.
 */
#pragma omp parallel for
   for (int i = 0; i &amp;lt; bs; i++) {

        for (int j = 0; j &amp;lt; numOutBufs; j++) {

            long int opElemPerBatch = opChnls&lt;J&gt; * inputH * inputW;
            std::memcpy(opBuffers&lt;J&gt; + opMemOffsets&lt;J&gt;, ipBuffer + ipMemOffset, sizeof(float) * opElemPerBatch);

            ipMemOffset += (opElemPerBatch);
            opMemOffsets&lt;J&gt; += opElemPerBatch;
        }

    }&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/PRE&gt;

&lt;P&gt;My main concern is to performance need to imroved with same accuracy. I new to openmp. Could anyone please help in understand openmp construct with memcpy in for loop in detailed manner?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 03 Apr 2019 06:11:01 GMT</pubDate>
    <dc:creator>Nalla__Hari</dc:creator>
    <dc:date>2019-04-03T06:11:01Z</dc:date>
    <item>
      <title>openmp construct with, memcpy insides the for loop results in wrong output values</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/openmp-construct-with-memcpy-insides-the-for-loop-results-in/m-p/1180955#M8126</link>
      <description>&lt;P&gt;I'm trying to copy input buffer values into the multiple output buffers. To do this, i have used memcpy(..) inside the for loop. To get the better performance i have used the openmp construct outside of the for loop. I'm gaining some performance improvement but it results in wrong output buffer values.&lt;/P&gt;&lt;P&gt;In my project, i tried to use memcpy to copy some channels of input image into the output buffers. And i have used openmp construct outside of the loop. I am getting incorrect output values.&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;// sudo code to copy required channels from ipBuffer.
/* ipBuffer - input buffer 
 * opBuffer[] - Array of output bufferc
 * opChnls[] - How many channels does each ouput buffer needed from input.
 */
#pragma omp parallel for
   for (int i = 0; i &amp;lt; bs; i++) {

        for (int j = 0; j &amp;lt; numOutBufs; j++) {

            long int opElemPerBatch = opChnls&lt;J&gt; * inputH * inputW;
            std::memcpy(opBuffers&lt;J&gt; + opMemOffsets&lt;J&gt;, ipBuffer + ipMemOffset, sizeof(float) * opElemPerBatch);

            ipMemOffset += (opElemPerBatch);
            opMemOffsets&lt;J&gt; += opElemPerBatch;
        }

    }&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/J&gt;&lt;/PRE&gt;

&lt;P&gt;My main concern is to performance need to imroved with same accuracy. I new to openmp. Could anyone please help in understand openmp construct with memcpy in for loop in detailed manner?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 06:11:01 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/openmp-construct-with-memcpy-insides-the-for-loop-results-in/m-p/1180955#M8126</guid>
      <dc:creator>Nalla__Hari</dc:creator>
      <dc:date>2019-04-03T06:11:01Z</dc:date>
    </item>
    <item>
      <title>Your parallel slicing is</title>
      <link>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/openmp-construct-with-memcpy-insides-the-for-loop-results-in/m-p/1180956#M8127</link>
      <description>&lt;P&gt;Your parallel slicing is working on loop control variable i (outer loop).&lt;BR /&gt;Whereas all threads in the region iterate j=0;j&amp;lt;... (inner loop)&lt;BR /&gt;All the indexing inside the inner loop uses baseOfArray[ j ] to access the same portion of each array.&lt;/P&gt;&lt;P&gt;Also at issue is ipMemOffset +=... and opMemOffsets[ j ]+=...&amp;nbsp;are being advanced by all threads indeterminately while being previously used (line 12) as if&amp;nbsp;they were a known offset.&lt;/P&gt;&lt;P&gt;You have to re-think how you intend to partition the procedure.&lt;/P&gt;&lt;P&gt;Jim Dempsey&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 12:22:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Moderncode-for-Parallel/openmp-construct-with-memcpy-insides-the-for-loop-results-in/m-p/1180956#M8127</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2019-04-04T12:22:15Z</dc:date>
    </item>
  </channel>
</rss>

