openmp g ++错误:折叠的循环未完全嵌套 [英] openmp g++ error: collapsed loops not perfectly nested

查看:127
本文介绍了openmp g ++错误:折叠的循环未完全嵌套的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试编译

#include <omp.h>

using namespace std;

vector< vector<int> > multiplyMatrixes(const vector< vector<int> > &a, const vector<     vector<int> > &b, int aHeight, int aWidth, int bHeight, int bWidth) {
    vector < vector<int> > c(aHeight, vector<int>(bWidth, 0));
    #pragma omp parallel for collapse(2)
    for(int row = 0; row < aHeight; row++) {
            for(int col = 0; col < bWidth; col++) {
                   int value = 0;
                   for(int i = 0; i < aWidth; i++) {
                          value += a[row][i] * b[i][col];
                   }
                   c[row][col] = value;
                   cout<<"Tread #"<<omp_get_thread_num()<<"\n";
            }
            std::cout<<'\n';
    }
    return c;
}

int main() {}

使用'g ++ -fopenmp hello.cpp -o hello'命令,gcc版本为4.7,但我得到以下提示 'hello.cpp:19:17:错误:折叠的循环未完全嵌套" 是什么意思?

with 'g++ -fopenmp hello.cpp -o hello' command, gcc version is 4.7, but i get following 'hello.cpp:19:17: error: collapsed loops not perfectly nested' What does it mean?

推荐答案

在错误中进行搜索会发现循环必须完全嵌套;也就是说,在折叠的循环之间没有中间代码,也没有任何OpenMP编译指示"

Googling for the error finds "The loops must be perfectly nested; that is, there is no intervening code nor any OpenMP pragma between the loops which are collapsed"

我认为这意味着不允许在for(i)循环之前和之后的代码.

I think that means the code before and after the for(i) loop is not allowed.

这篇关于openmp g ++错误:折叠的循环未完全嵌套的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆