A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/cython/cython/issues/2798 below:

prange() dead-locks with memoryviews when not freeing the GIL · Issue #2798 · cython/cython · GitHub

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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4