OpenMP 2.0和Access违规读取位置0xFFFFFFFFFFFFFFFF

时间:2016-10-25 08:18:26

标签: c++ c++11 openmp

我正在尝试使用OpenMP V.2.0并行化填充向量(为什么不使用最新版本,请询问Visual studio;))。

shared_ptr<GroupManager> m_manager_ptr = std::make_shared< GroupManager>( m_manager);
        std::vector<IntersectionStrategyONE> vec;

#pragma omp parallel
{
    std::vector<IntersectionStrategyONE> vec_private;
    #pragma omp for nowait firstprivate(m_manager_ptr) //fill vec_private in parallel
    for (int i = 0; i < vectest.size(); ++i) // or use iterators in newer OpenMP, but I don't have access ;)
    {
        StlTriangle *i_triangle = vectest[i]->GetStlTriangle();
        if ((GroupManager::GetGroup(i_triangle) != 0) && (m_manager_ptr->GetThickness(i_triangle) != 0))
        {
            //Checking if current triangle does intersect 
            if (_DoesIntersect(i_triangle))
            {
                //Saving the data on intersection in a newly created object inter, and saving it into the set of intersections
                Intersection inter;
                _FindIntersection(inter, i_triangle);
                vec_private.push_back(inter);
            }
        }
    }
    #pragma omp critical
    vec.insert(vec.end(), vec_private.begin(), vec_private.end());
}

失败在获取GetStl()时函数GetThickness:

unsigned char GroupManager::GetThickness(StlTriangle * ip_tri) const
  {
  if (m_thickness_info.size() == 0)
    return 1;
  TThicknessInfo::const_iterator it = m_thickness_info.find(ip_tri->GetStl()); // **FAILS HERE**
  if (it == m_thickness_info.end())
    // default thickness is 1
    return 1;

  return it->second->GetInfo(*ip_tri);
}

StlTriangle * i_triangle是为每个线程构建的,为什么会失败?

0 个答案:

没有答案