我正在尝试使用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:没有当前线程
这种行为的原因是什么?
谢谢!
答案 0 :(得分:0)
好的想通了:
来自np.ndarray的隐式转换不起作用;我用额外的memoryview切片解决了它。