locked
why need I put the class declaration in the shared clause in #pragma omp parallel? RRS feed

  • Question

  • This Monday, I compile the following code with VS2010 with OpenMP turned on.

    CODE: SELECT ALL
    int intFacesSize_ = this->n_faces();
    TriMesh::FHandle faceHandle_;
    #pragma omp parallel for default(none) private(faceHandle_) shared(intFacesSize_)
    for(int faceIndex_ = 0; faceIndex_ < intFacesSize_; ++faceIndex_) {
    faceHandle_ = TriMesh::FHandle(faceIndex_);
    }


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

    I felt so strange, then I tried the code below, and the compiling passed without error.

    CODE: SELECT ALL
    int intFacesSize_ = this->n_faces();
    TriMesh::FHandle faceHandle_;
    #pragma omp parallel for default(none) private(faceHandle_) shared(intFacesSize_, TriMesh::FHandle)
    for(int faceIndex_ = 0; faceIndex_ < intFacesSize_; ++faceIndex_) {
    faceHandle_ = TriMesh::FHandle(faceIndex_);
    }


    So, it made me so puzzled that why I need to put the class declaration in the shared clause?????? :x 

    BTW, I am using Vs2010. and the FaceHandle is an ordinary struct as:


    CODE: SELECT ALL
    /// Handle for a face entity
    struct FaceHandle : public BaseHandle
    {
      explicit FaceHandle(int _idx=-1) : BaseHandle(_idx) {}
    };


    Finally, I hope somebody could help me out.

    • Moved by Amanda Zhu Monday, July 8, 2013 4:18 AM move to a more appropriate forum
    Friday, July 5, 2013 11:52 PM

All replies