【发布时间】:2017-07-09 05:32:31
【问题描述】:
我正在尝试使用对犰狳矩阵求和的 OpenMP 并行化 for 循环。我有以下代码:
#include <armadillo>
#include <omp.h>
int main()
{
arma::mat A = arma::randu<arma::mat>(1000,700);
arma::mat X = arma::zeros(700,700);
arma::rowvec point = A.row(0);
# pragma omp parallel for shared(A) reduction(+:X)
for(unsigned int i = 0; i < A.n_rows; i++){
arma::rowvec diff = point - A.row(i);
X += diff.t() * diff; // Adding the matrices to X here
}
}
我收到此错误:
[Legendre@localhost ~]$ g++ test2.cpp -o test2 -O2 -larmadillo -fopenmp
test2.cpp: In function ‘int main()’:
test2.cpp:11:52: error: user defined reduction not found for ‘X’
我阅读了有关定义约简的内容,但我还没有找到使用犰狳矩阵的示例。在我的案例中,定义犰狳矩阵减少的最佳方法是什么?
【问题讨论】: