8000 prange() dead-locks with memoryviews when not freeing the GIL · Issue #2798 · cython/cython · GitHub
[go: up one dir, main page]

Skip to content
prange() dead-locks with memoryviews when not freeing the GIL #2798
@NicolasHug

Description

@NicolasHug

prange seems to hold forever if in the loop we call a function that uses a 1d view of a 2d view. Here is a reproducing example:

import numpy as np
from cython.parallel import prange


def wrapper():  # will hold forever
    a = np.random.uniform(0, 100, size=(100, 100)).astype(np.int32)
    g(a)


cdef int f(int [:] a_i) nogil:  # uses 1d view
    return 3


cdef int g (int [:, :] a) nogil:

    cdef:
        int i

    for i in prange(a.shape[0]):  # Works OK with range
        f(a[i])

As a workaround we can still pass a and i to f and use a[i] instead of a_i.

Thanks for all the work on Cython!

Versions:

Cython 0.29.2,
Python 3.7.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0