Add OpenMP support to forward modeling modules in gravmag.#106
Add OpenMP support to forward modeling modules in gravmag.#106leouieda merged 9 commits intokernel-functionsfrom
Conversation
Using Cython prange function in gravmag.sphere yields a 2x speedup in my i5 processor with 4 threads on a (200x200) grid. On smaller grids (20x20) it is at worse the same speed. Had to separate the kernel Cython functions because I couldn't do "elif field ==" without the GIL. Putting the gz kernel on a cdef inline function actually made it much faster.
As per this issue: travis-ci/travis-ci#1553
Had to change the coordinate system shift (x[0] = x2 - xp[l]) to use dx = x[i] - xp[l] inside the integration loops because I can't alter the x array in parallel. Benchmarks show 2x speedup in an i5 processor with 4 threads. harvester doesn't seem to be much faster though.
|
Installing on Windows gets a bit trickier because the MinGW that comes with Anaconda doesn't include OpenMP support. As discussed in the Anaconda mailing list, a workaround in to install TDM-GCC. I tried this on a Windows box and it works perfectly. Don't forget to select the |
|
@leouieda, after cloning your repo, I compiled the Fatiando with |
|
No, just the normal build. On Tue, Jun 10, 2014 at 5:42 PM, Vanderlei C Oliveira Jr <
|
Conflicts: setup.py Changed the setup for building extension modules. Getting a list of module names plus extra compile args.
Benchmarks are very good! Sometimes more than 2x speedup over numpy version. Moved the vertices loop out of kernels to avoid segfaults. Had to change the way PolygonalPrism makes .x and .y attributes so that they are C contiguous arrays.
Add OpenMP support to forward modeling modules in gravmag.
Giving decent speedups in my linux laptop and has no problem with
multiprocessing.Seems there might be some issues building the extension modules on Windows. Anaconda doesn't include OpenMP in its MinGW. See this discussion and the instructions here for a possible solution.
This is an addon for PR #105