How best to parallelize numba.stencil operations
See original GitHub issueIn https://numba.pydata.org/numba-doc/dev/user/stencil.html#numba-stencil it says the following:
Thus, the stencil decorator allows clearer, more concise code and in conjunction with the parallel jit option enables higher performance through parallelization of the stencil execution.
However, my naive attempt to use the parallel=True
keyword with numba.stencil
has failed:
In [1]: import numba
In [2]: @numba.stencil(parallel=True)
...: def f(x):
...: return (x[-1, -1] + x[-1, 0] + x[-1, 1] + x[0, -1] + x[0, 0] + x[0, 1] + x[1, -1] + x[1, 0] + x[1, 1])
...: / 9
...:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-9fe53b83f8a0> in <module>()
----> 1 @numba.stencil(parallel=True)
2 def f(x):
3 return (x[-1, -1] + x[-1, 0] + x[-1, 1] + x[0, -1] + x[0, 0] + x[0, 1] + x[1, -1] + x[1, 0] + x[1, 1]) / 9
~/Software/anaconda/lib/python3.6/site-packages/numba/stencil.py in stencil(func_or_mode, **options)
722 for option in options:
723 if option not in ["cval", "standard_indexing", "neighborhood"]:
--> 724 raise ValueError("Unknown stencil option " + option)
725
726 wrapper = _stencil(mode, options)
ValueError: Unknown stencil option parallel
What is the right way to parallelize stencil operations? If I’ve missed documentation on this I apologize.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5
Top Results From Across the Web
Notes on stencils — Numba 0.50.1 documentation
As mentioned above, Numba supports the calling of stencils from inside or outside a @jit compiled function, with or without the parallel=True option....
Read more >Automatic parallelization with @jit - Numba documentation
Instead, with auto-parallelization, Numba attempts to identify such operations in a user program, and fuse adjacent ones together, to form one or more...
Read more >Parallel Python with Numba and ParallelAccelerator - Anaconda
On the other hand, threads can be very lightweight and operate on shared ... there were not very good ways to describe stencil...
Read more >Composing Dask Array with Numba Stencils
Numba's stencil decorator to craft localized compute kernels · Numba's Just-In-Time (JIT) compiler for array computing in Python · Dask Array for ...
Read more >Basics [Numba] | Tips & Tricks - Diego Inácio
Jit has a flag which enables the automatic parallelization, and in addition, Numba has implemented the ability to run loops in parallel using...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
numba.stencil
decorator is for creating stencil kernels. It doesn’t even jit the kernel; it remains as regular python. Thenjit
functions that use the kernels can have theparallel=True
annotation.Looks like the documentation should be more clear on this.
Makes sense.