各行がポイントを表し、各列がこのポイントとデータ内の他のすべてのポイントとの間の距離である距離行列を構築しています。しかし、私はそれを並列化しようとすると、私はセグメンテーションフォールトエラーを取得します。次は私のすべてのデータを含むマップであるパラレルのための私のコードです。ここの助けは非常に高く評価されます。セグメント化エラーopenmpエラー
map< int,string >::iterator datIt;
map< int,string >::iterator datIt2;
map <int, map< int, double> > dist;
int mycont=0;
datIt=dat.begin();
int size=dat.size();
#pragma omp parallel //construct the distance matrix
{
#pragma omp for
for(int i=0;i<size;i++)
{
datIt2=dat.find((*datIt).first);
datIt2++;
while(datIt2!=dat.end())
{
double ecl=0;
int c=count((*datIt).second.begin(),(*datIt).second.end(),delm)+1;
string line1=(*datIt).second;
string line2=(*datIt2).second;
for (int i=0;i<c;i++)
{
double num1=atof(line1.substr(0,line1.find_first_of(delm)).c_str());
line1=line1.substr(line1.find_first_of(delm)+1).c_str();
double num2=atof(line2.substr(0,line2.find_first_of(delm)).c_str());
line2=line2.substr(line2.find_first_of(delm)+1).c_str();
ecl += (num1-num2)*(num1-num2);
}
ecl=sqrt(ecl);
dist[(*datIt).first][(*datIt2).first]=ecl;
dist[(*datIt2).first][(*datIt).first]=ecl;
datIt2++;
}
datIt++;
}
}
私たちがそのコードをデバッグすることを期待しているなら、クラッシュの時点で少なくともスタックトレースを提供することができます。 – NPE
投稿する前にコードをインデントしてください。 –