New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenMP Parallelization for CascadedUnion [WIP] #468
Conversation
CascadedPolygonUnion::pairUnion( | ||
std::vector<const geom::Geometry*>& inply) const | ||
{ | ||
int sz = (int)(inply.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you used size_t here and in other places, I guess you could avoid the explicit casts below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annoyingly, OpenMP on Windows insists that the loop iterators be int
, which then cascades into all these wonderful casts. 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, a comment in the code would help other readers then
|
||
#pragma omp parallel for | ||
for (int i = 0; i < sz; i += 2) { | ||
/* Work backwards to preserve an old regression result */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hum I don't see this backward effect in the binaryUnion() implementation. At least not in an obvious way
Nice work @pramsey ! Have you got any benchtests available of the performance changes yet? |
Only on my 2-core laptop, which takes a union from 3.5s to 2.7s. Since the last (biggest) union will always be single-threaded, we'll never get up to 1/N speed-ups with this. |
This was fun, but I don't think it's The Way we are going to do parallelism. OpenMP is Too Cute By Half, and probably we're just going to have to bite the bullet and do pthreads implementations for the widest/simplest cross platform acceptance. |
Experiment in using multi-threading to speed up computationally expensive processes. Works "as advertised" but best way to support build on multiple platforms and to expose hooks so that controlling systems (PgSQL) can throttle the number of threads to a set maximum is still TBD.