Quantcast
Channel: Intel® Many Integrated Core Architecture
Viewing all articles
Browse latest Browse all 1347

Problem of offloading 2-D Array

$
0
0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
    int* p1[10];
    int* p2[10];
    int start[10];
    int len[10];
    for(int i=0;i<10;i++)
    {
        p1[i]=new int[(i+1)*1000];
        p2[i]=new int[(i+1)*1000];
        len[i]=(i+1)*1000;
        start[i]=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<10;i++)
            {
                memcpy(p2,p1,(i+1)*1000*sizeof(int));
            }

        }
        printf("%d\n",count++);
    }

    return 0;
}

 

I try to offload 2-D Array and copy the memory.But it crash at 

memcpy(p2,p1,(i+1)*1000*sizeof(int));

I have no idea why it crash.

By the way,In another program ,some times the program will stuck at a very simple offload statement and it seems to sleep forever.


Viewing all articles
Browse latest Browse all 1347


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>