Reputation: 1680
I am wondering how I can parallelise for loop below in a secure way. I found some possible solution like this . However I am limited to use OpenMP version 2.0 and Boost version 1.59.
algorithm explanation:
It iterates over all of my triangles which lie within the bounding box, then it checks possibility of the intersection (with a unique triangle) in _considerTriangle function. Finally in the _considerTriangle, if a triangle is intersected it inserts triangle to a set container intersectedTri.
//Iterating through every triangle
std::set<Triangle> intersectedTri;
for(IntersectedTrianglesIterator it=tree.Begin_IteratorByBoundingBox(bbox_min,bbox_max);it!=tree.End_IteratorByBoundingBox(bbox_min,bbox_max);++it)
_ConsiderTriangle(it->GetTriangle());
I am wonderying how I can paralllise it safely.
Upvotes: 0
Views: 290
Reputation: 1879
You can use any method, as long as you synchronize the insertion into intersectedTri.
// globals
boost::mutex mut;
// inside func
boost::mutex::scoped_lock lock(mut);
intersectedTri.insert(tri);
Upvotes: 0