使用 Armadillo 时 GCC OpenMP 目标“不是可映射类型”错误

问题描述

我正在尝试重写一个与 OpenMP 并行的算法来尝试目标加速。 OMP 的设备功能。我偶然发现了以下问题(我准备了一个最小的例子): 当尝试访问目标区域内的犰狳矩阵对象时,编译时会产生以下错误(使用 GCC 9.3.0,Cuda 10.1.243):

user@machine:~/tmp/gpu-test$ g++ -fopenmp -fcf-protection=none -fno-stack-protector -foffload='-larmadillo' minimal.cxx -larmadillo
minimal.cxx: In function ‘int main()’:
minimal.cxx:9:41: error: ‘mtotal’ does not have a mappable type in ‘map’ clause
    9 | parallel for map(tofrom: total) map(to: mtotal) reduction(+:total)
      |                                         ^~~~~~
minimal.cxx:11:28: error: ‘mtotal’ referenced in target region does not have a mappable type
   11 |         total += mtotal(0,0);
      |                            ^

最小的例子:

#include <armadillo>

int main() {

    double total = 0;
    arma::mat mtotal(1,1,arma::fill::randu);

#pragma omp target teams distribute \
parallel for map(tofrom: total) map(to: mtotal) reduction(+:total)
    for (int i = 0; i < 5; ++i) {
        total += mtotal(0,0);
    }//for
}//main

我试图找出在这种情况下“不可映射类型”的含义,但在搜索后我无法连接到 arma::mat 对象。此外,我已经使用在 GPU 上运行的设置生成了可运行的代码,因此设置本身应该没有问题。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...