# The future of kernel programming style with Numba

**URL:** <https://numba.discourse.group/t/the-future-of-kernel-programming-style-with-numba/1363>\
**Category:** Numba\
**Created:** [June 6, 2022, 4:11am UTC](https://numba.discourse.group/t/the-future-of-kernel-programming-style-with-numba/1363 "2022-06-06T04:11:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pauljurczak](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/pauljurczak/32/479_2.png) [@pauljurczak](https://numba.discourse.group/u/pauljurczak)\
**Post date:** [June 6, 2022, 4:11am UTC](https://numba.discourse.group/t/the-future-of-kernel-programming-style-with-numba/1363/1 "2022-06-06T04:11:45Z")

</div>

I did a few tests using `stencil` and the results are not great. This snippet:

```auto
import numba as nb
import numpy as np
import timeit as ti

def ker0(a):
  return 42*a

@nb.stencil
def ker(a):
  return 42*a[0, 0]

@nb.njit(fastmath=True)
def ker1(a):
  return ker(a)

@nb.njit(fastmath=True, parallel=True)
def ker2(a):
  return ker(a)

a = np.arange(10000).reshape((100, 100))

for i in range(3):
  fun = f'ker{i}(a)'
  t = 1000 * np.array(ti.repeat(stmt=fun, setup=fun, globals=globals(), number=1, repeat=100))
  print(f'{fun}: {np.amin(t):6.3f}ms {np.median(t):6.3f}ms')

```

produces:

```auto
ker0(a): 0.005ms 0.005ms
ker1(a): 0.009ms 0.009ms
ker2(a): 0.020ms 0.020ms

```

on a 6-core CPU with Python 3.10.4. Parallel mode slows `stencil` down. Are there more performant options to write kernels with? Perhaps [GitHub - IntelPython/numba-dpex: Numba extension for Intel(R) XPUs](https://github.com/IntelPython/numba-dpex)? Anything else? Where is the development effort going these days?

---

<div class="post-metadata">

**Author:** ![animator](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/animator/32/119_2.png) [@animator](https://numba.discourse.group/u/animator)\
**Post date:** [June 6, 2022, 12:32pm UTC](https://numba.discourse.group/t/the-future-of-kernel-programming-style-with-numba/1363/2 "2022-06-06T12:32:32Z")

</div>

@pauljurczak There is a [stencil issue](https://github.com/numba/numba/issues/6456) I opened and an ongoing pull request made by Dr. Todd in this respect.  
It would be great if you can add your findings to the issue thread.

---

<div class="post-metadata">

**Author:** ![pauljurczak](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/pauljurczak/32/479_2.png) [@pauljurczak](https://numba.discourse.group/u/pauljurczak)\
**Post date:** [June 13, 2022, 5:02am UTC](https://numba.discourse.group/t/the-future-of-kernel-programming-style-with-numba/1363/3 "2022-06-13T05:02:26Z")

</div>

It took a while, but I just did.
