openmp g++ error: collapsed loops not perfectly nested

…衆ロ難τιáo~ 提交于 2020-01-21 21:53:41

问题


I try to compile

#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() {}

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?


回答1:


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"

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



来源:https://stackoverflow.com/questions/13901673/openmp-g-error-collapsed-loops-not-perfectly-nested

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!