multithreading - Cython Prange失败并显示致命Python错误: PyThreadState_Get: no current thread

标签 multithreading parallel-processing cython

我正在尝试使用prange并行化循环:

cdef fun(double [::1] someData)) nogil:
    #direct call to a external c function
    C_function(&someData[0])

#....
def parallelEvaluate(np.ndarray[np.double_t] largerArray):
    #....
    cdef np.ndarray[np.double_t] array
    cdef np.ndarray[np.int] arbitraryIndices
    for n in prange(loopLength, nogil=true):
        with gil:
            arbitraryIndices = # ... indices dependent on n
            array = np.copy( largerArray[ arbitraryIndices]  ) # copy of a non cont. array to the cont. 'array'
        fun(array)

但是,这样做失败:
致命的Python错误:PyThreadState_Get:当前没有线程

这种行为的原因是什么?

谢谢!

最佳答案

确定了:

来自np.ndarray的隐式转换不起作用。我用一个额外的memoryview slice解决了它。

关于multithreading - Cython Prange失败并显示致命Python错误: PyThreadState_Get: no current thread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42131988/

相关文章:

java - Android 中完全控制的线程队列

c - MPI_等待: Request pending due to failure

windows - 在没有 Visual Studio 的情况下编译 CUDA - "Cannot find compiler cl.exe in path"

Python 和 Cython 代码分析和调用图

python - 在 C++/Cython 中,是否可以仅声明相关属性在 Python 中可见?

python - 在 cython 中创建小数组需要大量时间

c++ - 在循环中线程化 unique_ptr

java - 最佳线程数的原因

java - 多线程访问物化 View : refresh and read at the same time seems to result in inconsistent behaviour

matlab - Matlab(或 Octave)中 meshgrid 的矢量化