Torsten Posted December 20, 2013 Report Share Posted December 20, 2013 (edited) Hi there, it should be very easy to calculate several paths in parallel - but some functions used by Compute(Short)Path and themself use this PROFILE stuff which can be used only by the main thread. If that will get fixed it should be that easy (you need to add '-fopenmp' to LIBS/C(XX)FLAGS): Index: source/simulation2/components/CCmpPathfinder.cpp===================================================================--- source/simulation2/components/CCmpPathfinder.cpp (revision 14386)+++ source/simulation2/components/CCmpPathfinder.cpp (working copy)@@ -576,6 +578,7 @@ void CCmpPathfinder::ProcessLongRequests(const std::vector<AsyncLongPathRequest>& longRequests) {+ #pragma omp parallel for for (size_t i = 0; i < longRequests.size(); ++i) { const AsyncLongPathRequest& req = longRequests[i];@@ -582,12 +585,16 @@ Path path; ComputePath(req.x0, req.z0, req.goal, req.passClass, req.costClass, path); CMessagePathResult msg(req.ticket, path);- GetSimContext().GetComponentManager().PostMessage(req.notify, msg);+ #pragma omp critical+ {+ GetSimContext().GetComponentManager().PostMessage(req.notify, msg);+ } } } void CCmpPathfinder::ProcessShortRequests(const std::vector<AsyncShortPathRequest>& shortRequests) {+ #pragma omp parallel for for (size_t i = 0; i < shortRequests.size(); ++i) { const AsyncShortPathRequest& req = shortRequests[i];@@ -595,7 +602,10 @@ ControlGroupMovementObstructionFilter filter(req.avoidMovingUnits, req.group); ComputeShortPath(filter, req.x0, req.z0, req.r, req.range, req.goal, req.passClass, path); CMessagePathResult msg(req.ticket, path);- GetSimContext().GetComponentManager().PostMessage(req.notify, msg);+ #pragma omp critical+ {+ GetSimContext().GetComponentManager().PostMessage(req.notify, msg);+ } } } Edited December 20, 2013 by Torsten 1 Quote Link to comment Share on other sites More sharing options...
niektb Posted December 20, 2013 Report Share Posted December 20, 2013 I suppose this topic is in the wrong forum. This place is for new people who want to contribute. Also use the code tags to enhance your post's lay-out. Quote Link to comment Share on other sites More sharing options...
sanderd17 Posted December 20, 2013 Report Share Posted December 20, 2013 I believe it's meant to happen in multiple threads, but as developing is easier in a single thread (you can e.g. profile the time the pathfinder needs), it's left this way.If you think you can help out, I invite you to the #0ad-dev IRC channel on quakenet. Philip is working on the pathfinder, and you can always find him there online (though he isn't always active). 2 Quote Link to comment Share on other sites More sharing options...
quantumstate Posted December 21, 2013 Report Share Posted December 21, 2013 Making things parallel in this way is very dangerous. You have identified one thing within the called functions which is not thread safe. Without carefully checking all of the called code you can't be sure that things won't occasionally break in strange unreproducible ways. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.