Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

pramsey
Copy link
Member

@pramsey pramsey commented Jul 16, 2021

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.

CascadedPolygonUnion::pairUnion(
std::vector<const geom::Geometry*>& inply) const
{
int sz = (int)(inply.size());
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

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 */
Copy link
Contributor

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

@nyalldawson
Copy link

Nice work @pramsey ! Have you got any benchtests available of the performance changes yet?

@pramsey
Copy link
Member Author

pramsey commented Jul 27, 2021

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.

@pramsey
Copy link
Member Author

pramsey commented Nov 17, 2021

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.

@pramsey pramsey closed this Nov 17, 2021
@pramsey pramsey deleted the main-openmp branch August 19, 2022 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants