Do we need to put class declaration in the shared clause

General OpenMP discussion

Do we need to put class declaration in the shared clause

Postby ayongwust_sjtu » Mon Jul 01, 2013 9:27 pm

I sincerely hope and appreciate that somebody could share ideas.

Today, I found that if we want to involve OpenMP in our project, we need to put the class declaration in the shared clause, otherwise, we get a compiling error:

error C3052: 'OpenMesh::PolyConnectivity::FHandle' : variable doesn't appear in a data-sharing clause under a default(none) clause

#pragma omp parallel for default(none) private(faceHandle_) shared(intFacesSize_, TriMesh::FHandle)
for(int faceIndex_ = 0; faceIndex_ < intFacesSize_; ++faceIndex_) {
faceHandle_ = TriMesh::FHandle(faceIndex_);
}


Is this a requirement asked by OpenMP, or asked by the third-party library I am using????
It makes me not confident to use them together.
ayongwust_sjtu
 
Posts: 3
Joined: Mon Jul 01, 2013 6:13 pm

Re: Do we need to put class declaration in the shared clause

Postby chabachull » Fri Jul 05, 2013 2:54 am

Hi,

This error is due to the way you are using OpenMP.
You have put the "default(none)" clause in your parallel pragma. This clause requires that all the elements you are using in your parallel region should appear either in a "private(...)" or "shared(...)" clause.

You can write the same openmp line without the "default(none)" clause, and all the items that are not referenced in a data sharing clause will be considered by the runtime as shared variables. Then you will not have to add "TriMesh::FHandle" in the shared clause, and your code will be equivalent than the one you presented.

This should work:
Code: Select all
#pragma omp parallel for private(faceHandle_)
for(int faceIndex_ = 0; faceIndex_ < intFacesSize_; ++faceIndex_) {
  faceHandle_ = TriMesh::FHandle(faceIndex_);
}