Software Archive
Read-only legacy content
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
17060 Discussions

offload error: process on the device 0 was terminated by signal 11 (SIGSEGV)

yuanyuan_s_
Beginner
572 Views

I need some help,here is my code,I want to know why I can't do like this:

 

//this is the headfile

#include <stdio.h>
#include <stdlib.h>
class ihavefun{
public:
        void callfun();
        int* inint

}

//.cpp

void ihavefun::callfun(){
        inint = new int[100];
#pragma offload target(mic:0)in(inint:length(100))
{
        int i=0;
        for(i=0;i<100;i++){
        printf("%d\n",inint[0]);
        fflush(0);
        }
}
}

then I run the function "callfun" will cause the above error.

 

 

0 Kudos
1 Reply
Kevin_D_Intel
Employee
572 Views

I was unable to get your example to compile. My mock-up suffered a compile error when using ininit within the offload clause
$ icpc -V
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.2.144 Build 20140120

$ icpc t.cpp
t.cpp(8): error: invalid entity for this variable list in offload clause
          #pragma offload target(mic:0)in(inint:length(100))
                                          ^
compilation aborted for t.cpp (code 2)
Our Developers said you cannot refer to data members of a class directly in an offload pragma currently. This may be allowed in a future release later this year; however, for now you need to copy the data member to a local variable and then use that variable instead of "inint".
I was able to do that and successfully offload and access the class data member’s data using this:

void ihavefun::callfun()
{
        int* loc_int;

        inint = new int[100];
        loc_int = inint;

        #pragma offload target(mic:0) in(loc_int:length(100))
        {
        int i=0;
        for(i=0;i<100;i++){
           printf("%d\n",loc_int);
           fflush(0);
        }
        }
}

 

0 Kudos
Reply