Skip to content
This repository was archived by the owner on Dec 22, 2021. It is now read-only.

Implement tesseroid forward modeling using numba#175

Merged
leouieda merged 18 commits intomasterfrom
tesseroid-numba
Mar 13, 2015
Merged

Implement tesseroid forward modeling using numba#175
leouieda merged 18 commits intomasterfrom
tesseroid-numba

Conversation

@leouieda
Copy link
Copy Markdown
Member

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 the njobs argument. 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:

  • Remove old Cython code
  • Make tests for new code
  • Make tests for parallel execution
  • Create/update docstrings
  • Include relevant equations and citations in docstrings
  • Code follows PEP8 style conventions
  • Code and docs have been spellchecked
  • Include new dependencies in docs, requirements.txt, README
  • Documentation builds properly
  • All tests pass
  • Can be merged
  • Changelog entry

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)
@leouieda leouieda added this to the 0.4 milestone Mar 11, 2015
leouieda and others added 11 commits March 11, 2015 19:45
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
@leouieda leouieda merged commit 490a0b9 into master Mar 13, 2015
@leouieda leouieda deleted the tesseroid-numba branch March 13, 2015 21:11
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants