Software Archive
Read-only legacy content
17061 ディスカッション

why this simple offload give Segmentation fault error

yongbei_ma_
新規コントリビューター I
406件の閲覧回数

this simple test code is this(testclass.cpp):

#include <iostream>

class TEST{
public:
    double *A;
public:
    TEST(double * _A){A = _A;}
    void run(){
        A[1] = 0;
        // double *B = A;
        std::cout<<A[1]<<std::endl;
        #pragma offload target (mic) inout(A:length(2*3))
        {
            A[1] = 1;
        }
        std::cout<<A[1]<<std::endl;
    }
};

int main()
{

    double *A = (double*)_mm_malloc(sizeof(double)*2*3,64);
    TEST test(A);
    test.run();

}

.............................................................................................

after complile and run ,this give me this error:

[root@localhost yb]# icpc testclass.cpp

[root@localhost yb]# ./a.out

0

Segmentation fault (core dumped)

......................................................................

thanks.

 

0 件の賞賛
1 返信
Kevin_D_Intel
従業員
406件の閲覧回数

It relates to the underlying "this" pointer. I need to check with someone more knowledgeable about the requirements for offload within the CLASS, but for now add the additional nocopy clause as shown below to create an instance of the underlying "this" pointer.

        #pragma offload target (mic) nocopy(this : alloc_if(1) free_if(0)) inout(A:length(2*3))

 

返信