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

Computing partials for all segments and triangles at once #61

Open
tbenthompson opened this issue Jan 7, 2022 · 3 comments
Open

Computing partials for all segments and triangles at once #61

tbenthompson opened this issue Jan 7, 2022 · 3 comments

Comments

@tbenthompson
Copy link
Collaborator

At the moment, the segment and triangle partials are being computed one at a time. This is probably pretty slow. It's worth profiling (with something like line_profiler or pyspy) first to check before investing effort to change this, but I'm guessing this is something like 10x slower than it would be to pass all the necessary observation points and source triangles to cutde.disp_matrix. This is basically just standard Python/matlab "vectorize your code" advice.

Concretely, passing only a single triangle at a time removes a lot of the potential for parallelization and for amortizing operations over many source triangles.

As a point of reference, I remember getting something like 5 million TDE source-observation point computations per second running on CPU with cutde. So, if you do a line_profiler run and see performance substantially worse than that, the problem is likely to be the individual calls.

Both here:

for i in tqdm(

and here:
for i in tqdm(

@brendanjmeade
Copy link
Owner

I think the challenge that I've seen here is that I do a different map projection for each of the triangles. This essentially means that for each triangle there is a whole new set of observation coordinates because they go through the map projection too. That's not a linear transform so I don't think I can just factor it out. Maybe it's worth considering packaging all of the projected TDEs and projected station coordinates together anyway and doing a lot of unused calculations and then just extracting the subsets we need?

@tbenthompson
Copy link
Collaborator Author

Ah! That's exactly the use case for cutde.halfspace.disp: When you have a bunch of pairs but don't need to calculate all pairs.

https://github.com/tbenthompson/cutde#simple-pair-wise-tdes

@brendanjmeade
Copy link
Owner

That's a great suggestion and I'll leave this issue open so that I can try it out. Thanks for the idea!

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

No branches or pull requests

2 participants