This repository was archived by the owner on Dec 22, 2021. It is now read-only.
Implement tesseroid forward modeling using numba#175
Merged
Conversation
Want to allow an 'engine' option to choose between numpy and numba implementations.
Conflicts: fatiando/gravmag/tesseroid.py
These things are called from all other functions so put them separately.
Missing docstrings and more comments. I'm copy/pasting the adaptive discretization for each field because callbacks aren't supported. An alternative would be to use closures but those seem to give slower results. Need to investigate.
Added many helper functions to sanitize inputs, pre-compute degree-radian transformations, etc. Supports parallel execution by splitting the grid and spreading over processes.
All tests passing except comparison to numpy version (because it doesn't exist)
Moved the kernels from the numba version over to the numpy version (they are the same). The numba module now only loads them from the numpy version and jit compiles.
Both the pyx and C source
Gave different functions names and moved things around. Nothing much.
Included the new arguments in functions docs. Merged the make_buffers function into the adaptive discretization.
leouieda
added a commit
that referenced
this pull request
Mar 13, 2015
Implement tesseroid forward modeling using numba
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I needed to update the tesseroids implementation here to match the one in Tesseroids. There was a lot I had to change so I figured I could also try to do it in numba. It was pleasantly easy to implement the adaptive discretization with numba and the preliminary benchmarks show that it matches the speed of Cython. All this without any compiled code at install time (see #169).
As a bonus, I implemented a simple parallelism by splitting the computation grid into chunks and passing it to
multiprocessing.Pool. This is embedded in each function and can be activated by thenjobsargument. It will run in serial by default so that it doesn't interfere with other parallel code.Note: A big thanks to @gmarkall for helping with my initial doubts and getting this started!
I also made a version using pure Python + numpy for benchmarks and to use in testing. It is used as a fail-safe if numba is not available. For tesseroids this version is much slower (~100x). For the prism, sphere, etc it won't be. So it is a viable alternative to have.
Checklist: