<?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 Problem of offloading 2-D Array in Software Archive</title>
    <link>https://community.intel.com/t5/Software-Archive/Problem-of-offloading-2-D-Array/m-p/1080633#M61434</link>
    <description>&lt;PRE class="brush:cpp;"&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
#include&amp;lt;string.h&amp;gt;

int main()
{
    int* p1[10];
    int* p2[10];
    int start[10];
    int len[10];
    for(int i=0;i&amp;lt;10;i++)
    {
        p1&lt;I&gt;=new int[(i+1)*1000];
        p2&lt;I&gt;=new int[(i+1)*1000];
        len&lt;I&gt;=(i+1)*1000;
        start&lt;I&gt;=0;
    }
    /*
        #pragma offload target(mic)\
        nocopy(p1[0:10]:\
        extent(start[0:10]:len[0:10]) alloc_if(1) free_if(0))\
        nocopy(p2[0:10]:\
        extent(start[0:10]:len[0:10]) alloc_if(1) free_if(0))
        {
            ;
        }
    */
    printf("init \n");
    
    int count=0;
    while(true)
    {
        #pragma offload target(mic)\
        in(p1[0:10]:\
        extent(start[0:10]:len[0:10]) alloc_if(1) free_if(1))\
        out(p2[0:10]:\
        extent(start[0:10]:len[0:10]) alloc_if(1) free_if(1))
        {
            
            for(int i=0;i&amp;lt;10;i++)
            {
                memcpy(p2,p1,(i+1)*1000*sizeof(int));
            }
            
        }
        printf("%d\n",count++);
    }
    
    return 0;
}
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I try to offload 2-D Array and copy the memory.But it crash at&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 13.008px; line-height: 19.512px;"&gt;memcpy(p2,p1,(i+1)*1000*sizeof(int));&lt;/PRE&gt;

&lt;P&gt;I have no idea why it crash.&lt;/P&gt;

&lt;P&gt;By the way,In another program ,some times the program will stuck at a very simple offload statement and it seems to sleep forever.&lt;/P&gt;</description>
    <pubDate>Fri, 08 Apr 2016 14:31:49 GMT</pubDate>
    <dc:creator>Ruixin_L_</dc:creator>
    <dc:date>2016-04-08T14:31:49Z</dc:date>
    <item>
      <title>Problem of offloading 2-D Array</title>
      <link>https://community.intel.com/t5/Software-Archive/Problem-of-offloading-2-D-Array/m-p/1080633#M61434</link>
      <description>&lt;PRE class="brush:cpp;"&gt;#include&amp;lt;stdio.h&amp;gt;
#include&amp;lt;stdlib.h&amp;gt;
#include&amp;lt;string.h&amp;gt;

int main()
{
    int* p1[10];
    int* p2[10];
    int start[10];
    int len[10];
    for(int i=0;i&amp;lt;10;i++)
    {
        p1&lt;I&gt;=new int[(i+1)*1000];
        p2&lt;I&gt;=new int[(i+1)*1000];
        len&lt;I&gt;=(i+1)*1000;
        start&lt;I&gt;=0;
    }
    /*
        #pragma offload target(mic)\
        nocopy(p1[0:10]:\
        extent(start[0:10]:len[0:10]) alloc_if(1) free_if(0))\
        nocopy(p2[0:10]:\
        extent(start[0:10]:len[0:10]) alloc_if(1) free_if(0))
        {
            ;
        }
    */
    printf("init \n");
    
    int count=0;
    while(true)
    {
        #pragma offload target(mic)\
        in(p1[0:10]:\
        extent(start[0:10]:len[0:10]) alloc_if(1) free_if(1))\
        out(p2[0:10]:\
        extent(start[0:10]:len[0:10]) alloc_if(1) free_if(1))
        {
            
            for(int i=0;i&amp;lt;10;i++)
            {
                memcpy(p2,p1,(i+1)*1000*sizeof(int));
            }
            
        }
        printf("%d\n",count++);
    }
    
    return 0;
}
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;

&lt;P&gt;I try to offload 2-D Array and copy the memory.But it crash at&amp;nbsp;&lt;/P&gt;

&lt;PRE class="brush:cpp;" style="font-size: 13.008px; line-height: 19.512px;"&gt;memcpy(p2,p1,(i+1)*1000*sizeof(int));&lt;/PRE&gt;

&lt;P&gt;I have no idea why it crash.&lt;/P&gt;

&lt;P&gt;By the way,In another program ,some times the program will stuck at a very simple offload statement and it seems to sleep forever.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Apr 2016 14:31:49 GMT</pubDate>
      <guid>https://community.intel.com/t5/Software-Archive/Problem-of-offloading-2-D-Array/m-p/1080633#M61434</guid>
      <dc:creator>Ruixin_L_</dc:creator>
      <dc:date>2016-04-08T14:31:49Z</dc:date>
    </item>
  </channel>
</rss>

