question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Numba 0.56 does not support `atomic.add` on arrays of complexs anymore

See original GitHub issue

Reporting a bug

  • I have tried using the latest released version of Numba (most recent is visible in the change log (https://github.com/numba/numba/blob/main/CHANGE_LOG).
  • I have included a self contained code sample to reproduce the problem. i.e. it’s possible to run as ‘python bug.py’.

The following code snippet uses an atomic.add on an array of complex numbers. It runs without any issues with numba 0.55.2, but fails with numba 0.56

from numba import cuda
import numpy as np

@cuda.jit
def atomic_add_one(values):
    """
    Adds 1 to each element values, with an atomic add

    Parameters:
    -----------
    values: 1darray of `complex128`
    """
    tid = cuda.threadIdx.x
    bid = cuda.blockIdx.x
    bdim = cuda.blockDim.x
    i = (bid * bdim) + tid
    cuda.atomic.add(values.real, i, 1)

arr = np.random.rand(16384) + 1.j*np.random.rand(16384)
print(arr.dtype)

atomic_add_one[256,64](arr)

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
gmarkallcommented, Aug 4, 2022

One potential fix is now ready for consideration in #8310. Whether this is the right fix and the general path forward is a complex decision, so I’ve added it to the agenda for next week’s dev meeting along with the considerations I can see as of now: https://hackmd.io/P1y0q3BcStKfIZky7CLHHg?view

1reaction
gmarkallcommented, Aug 3, 2022

Thanks for the reproducer - I can reproduce this issue, and I’m looking into it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Release Notes — Numba 0.56.4+0.g288a38bbd.dirty-py3.7 ...
PR #8310: CUDA: Fix Issue #8309 - atomics don't work on complex components (Graham ... Support for atomic xor , increment, decrement, exchange,...
Read more >
Supported Atomic Operations — Numba 0.50.1 documentation
Numba provides access to some of the atomic operations supported in CUDA. ... Multiple dimension arrays are supported by using a tuple of...
Read more >
Numba atomic.add issues - python - Stack Overflow
I am trying to make my first steps with numba. I have written a simple script that calculates the sum of all elements...
Read more >
Support Atomic Add on complex128 arrays in CUDA ... - GitHub
Currently NUMBA supports int32, float32, and float64 operands only for atomic add. It would be nice to have it for complex128 too, ...
Read more >
CUDA by Numba Examples: Atomics and Mutexes
The atomic add in Numba takes three parameters: the array which will be ... Some of these are not currently supported by Numba...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found