我正在尝试使用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/