Software Archive
Read-only legacy content
17061 Discussions

internal error: bad pointer

yongbei_ma_
New Contributor I
809 Views

my code is this:

__________________________________________

#include <iostream>

class TEST{
public:
    double *A;
public:
    TEST(double * _A){
        A = _A;
        #pragma offload_transfer target(mic:0) nocopy(this : alloc_if(1) free_if(0)) in(A:length(2*3) alloc_if(1) free_if(0))
    }
    void run(){
        A[1] = 0;
        // double *B = A;
        std::cout<<A[1]<<std::endl;
        #pragma offload target (mic) nocopy(this : alloc_if(1) free_if(0)) out(A:length(2*3) alloc_if(0) free_if(1))
        {
            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();

}

 

______________________________________________________

I want to copy the matrix A in TEST constructor first,and then in run() using it.but it give me some error when I compile the code

------------------------------------------------------------

$ icpc testclass.cpp

testclass.cpp(9): internal error: bad pointer

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

                                                                                                                               ^

compilation aborted for testclass.cpp (code 4)

--------------------------------------------------------------

could someone help me figure out what wrong with this ,thanks.

0 Kudos
3 Replies
Kevin_D_Intel
Employee
809 Views

I will try reproducing the error and post again when I know more.
 

0 Kudos
Kevin_D_Intel
Employee
809 Views

NOTE: This post was Updated after my original post.

I reproduced the internal error and forwarded it to Development (see internal tracking id below).

After checking with Developers much more knowledgeable than me with C++ and offloading a CLASS member pointer, I removed my earlier code and provided their corrected code below. Unfortunately their variant is still similar to your code and still suffers the internal error with the Parallel Studio XE 2015 Update 2. I have verified there is a fix in our latest internal development compiler but I need to check whether it will make the upcoming Parallel Studio XE 2015 Update 3 release.

(Internal tracking id: DPD200368511)

#include <iostream>
#include <stdio.h>

class TEST{
public:
    double *A;
public:
    TEST(double * _A){
        A = _A;

//      #pragma offload_transfer target(mic:0) nocopy(this : alloc_if(1) free_if(0)) in(A:length(2*3) alloc_if(1) free_if(0))

	// Allocate the object
        #pragma offload_transfer target(mic:0) nocopy(this: alloc_if(1))
	// Use existing object, and allocate A in it
        #pragma offload_transfer target(mic:0) nocopy(this) in(A:length(2*3) alloc_if(1) free_if(0))

    }
    void run(){
        A[1] = 0;
        // double *B = A;
        std::cout<<A[1]<<std::endl;

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

	// Refresh "this" pointer in this offload
        #pragma offload target (mic) in(this: length(0) alloc_if(0) free_if(0) ) out(A:length(2*3) alloc_if(0) free_if(1))

        {
            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();
}

 

0 Kudos
pbkenned1
Employee
809 Views

The internal error is fixed in PSXE 2015 update #3, so I'm closing this ticket now.

Patrick (covering for Kevin)

C:\Users\pbkenned\ISN\U544988>icl U544988.cpp -GR-
Intel(R) C++ Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0.3.208 Build 20150407
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.

U544988.cpp
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:U544988.exe
U544988.obj
C:\Users\pbkenned\AppData\Local\Temp\5\6884173.obj
-defaultlib:liboffload
-defaultlib:libiomp5md
ofldbegin.obj
ofldend.obj

C:\Users\pbkenned\ISN\U544988>U544988.exe
0
1

C:\Users\pbkenned\ISN\U544988>

0 Kudos
Reply