- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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); } } }

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page