为什么下面的代码不允许我var
通过10
函数设置intfun
?
#include <iostream>
void intfun(int * variable){
#pragma acc parallel deviceptr(variable) num_gangs(1) num_workers(1)
{
*variable = 10;
}
}
int main(){
int var;
#pragma acc enter data create(var)
#pragma acc host_data use_device(var)
{
intfun(&var);
}
#pragma acc exit data copyout(var)
std::cout << var << std::endl;
}
汇编:
pgcpp -acc main.cpp
执行:
PGCC-S-0155-Compiler failed to translate accelerator region (see -Minfo messages): Unknown variable reference (main.cpp: 5)
PGCC/x86 Linux 14.9-0: compilation completed with severe errors
如何在设备上intfun
设置参数值int var
?