Jump to content

parallel pathfinder


Torsten
 Share

Recommended Posts

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 by Torsten
  • Like 1
Link to comment
Share on other sites

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).

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...