yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #10935
[Branch ~yade-pkg/yade/git-trunk] Rev 4003: Disable parallel code in conditionalyEraseNonReal
------------------------------------------------------------
revno: 4003
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
timestamp: Wed 2014-06-04 10:51:38 +0200
message:
Disable parallel code in conditionalyEraseNonReal
This is done temporarly to fix/rewrite this part
of the code. Disabling at the moment because it
is critical. For details see bug-report:
https://bugs.launchpad.net/yade/+bug/1326288
modified:
core/InteractionContainer.cpp
core/InteractionContainer.hpp
--
lp:yade
https://code.launchpad.net/~yade-pkg/yade/git-trunk
Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-pkg/yade/git-trunk/+edit-subscription
=== modified file 'core/InteractionContainer.cpp'
--- core/InteractionContainer.cpp 2014-05-23 13:05:19 +0000
+++ core/InteractionContainer.cpp 2014-06-04 08:51:38 +0000
@@ -59,7 +59,7 @@
const shared_ptr<Body>& b1((*bodies)[id1]);
const shared_ptr<Body>& b2((*bodies)[id2]);
-
+ LOG_DEBUG("InteractionContainer erase intrs id1=" << id1 << " id2=" << id2);
int linIx=-1;
if(!b1) linIx=linPos;
else {
@@ -67,6 +67,7 @@
if(I==b1->intrs.end()) linIx=linPos;
else {
linIx=I->second->linIx;
+ LOG_DEBUG("InteractionContainer linIx=" << linIx << " linPos=" << linPos);
assert(linIx==linPos);
//erase from body, we also erase from linIntrs below
b1->intrs.erase(I);
=== modified file 'core/InteractionContainer.hpp'
--- core/InteractionContainer.hpp 2014-02-22 04:56:33 +0000
+++ core/InteractionContainer.hpp 2014-06-04 08:51:38 +0000
@@ -108,29 +108,12 @@
*/
template<class T> size_t conditionalyEraseNonReal(const T& t, Scene* rb){
// beware iterators here, since erase is invalidating them. We need to iterate carefully, and keep in mind that erasing one interaction is moving the last one to the current position.
- // For the parallel flavor we build the list to be erased in parallel, then it is erased sequentially. Still significant speedup since checking bounds is the most expensive part.
- #ifndef YADE_OPENMP
size_t initSize=currSize;
for (size_t linPos=0; linPos<currSize;){
const shared_ptr<Interaction>& i=linIntrs[linPos];
if(!i->isReal() && t.shouldBeErased(i->getId1(),i->getId2(),rb)) erase(i->getId1(),i->getId2(),linPos);
else linPos++;}
return initSize-currSize;
- #else
- unsigned nThreads= omp_get_max_threads();
- assert(nThreads>0);
- std::vector<std::vector<Vector3i > >toErase;
- toErase.resize(nThreads,std::vector<Vector3i >());
- for (unsigned kk=0; kk<nThreads; kk++) toErase[kk].reserve(1000);//A smarter value than 1000?
- size_t initSize=currSize;
- #pragma omp parallel for schedule(guided,100) num_threads(nThreads)
- for (size_t linPos=0; linPos<currSize;linPos++){
- const shared_ptr<Interaction>& i=linIntrs[linPos];
- if(!i->isReal() && t.shouldBeErased(i->getId1(),i->getId2(),rb)) toErase[omp_get_thread_num()].push_back(Vector3i(i->getId1(),i->getId2(),linPos)) ;
- }
- for (unsigned int kk=0; kk<nThreads; kk++) for (size_t ii(0), jj(toErase[kk].size()); ii<jj;ii++) erase(toErase[kk][ii][0],toErase[kk][ii][1],toErase[kk][ii][2]);
- return initSize-currSize;
- #endif
}
// we must call Scene's ctor (and from Scene::postLoad), since we depend on the existing BodyContainer at that point.