Fix prange race conditions.
This commit is contained in:
parent
1158e116d2
commit
7e390180cd
|
@ -1093,10 +1093,10 @@ cdef class _ScatteringSystemAtOmegaK:
|
||||||
cdef np.ndarray[double,ndim=2] evalpos_a = evalpos.reshape(-1,3)
|
cdef np.ndarray[double,ndim=2] evalpos_a = evalpos.reshape(-1,3)
|
||||||
cdef np.ndarray[complex, ndim=3] results = np.empty((evalpos_a.shape[0], fecv_size, 3), dtype=complex)
|
cdef np.ndarray[complex, ndim=3] results = np.empty((evalpos_a.shape[0], fecv_size, 3), dtype=complex)
|
||||||
cdef ccart3_t *res
|
cdef ccart3_t *res
|
||||||
res = <ccart3_t *> malloc(fecv_size*sizeof(ccart3_t))
|
|
||||||
cdef cart3_t pos
|
cdef cart3_t pos
|
||||||
cdef Py_ssize_t i, j
|
cdef Py_ssize_t i, j
|
||||||
with nogil, wraparound(False), parallel():
|
with nogil, wraparound(False), parallel():
|
||||||
|
res = <ccart3_t *> malloc(fecv_size*sizeof(ccart3_t))
|
||||||
for i in prange(evalpos_a.shape[0]):
|
for i in prange(evalpos_a.shape[0]):
|
||||||
pos.x = evalpos_a[i,0]
|
pos.x = evalpos_a[i,0]
|
||||||
pos.y = evalpos_a[i,1]
|
pos.y = evalpos_a[i,1]
|
||||||
|
@ -1106,7 +1106,7 @@ cdef class _ScatteringSystemAtOmegaK:
|
||||||
results[i,j,0] = res[j].x
|
results[i,j,0] = res[j].x
|
||||||
results[i,j,1] = res[j].y
|
results[i,j,1] = res[j].y
|
||||||
results[i,j,2] = res[j].z
|
results[i,j,2] = res[j].z
|
||||||
free(res)
|
free(res)
|
||||||
return results.reshape(evalpos.shape[:-1] + (self.fecv_size, 3))
|
return results.reshape(evalpos.shape[:-1] + (self.fecv_size, 3))
|
||||||
|
|
||||||
property fecv_size:
|
property fecv_size:
|
||||||
|
@ -1326,10 +1326,10 @@ cdef class _ScatteringSystemAtOmega:
|
||||||
cdef np.ndarray[double,ndim=2] evalpos_a = evalpos.reshape(-1,3)
|
cdef np.ndarray[double,ndim=2] evalpos_a = evalpos.reshape(-1,3)
|
||||||
cdef np.ndarray[complex, ndim=3] results = np.empty((evalpos_a.shape[0], basissize, 3), dtype=complex)
|
cdef np.ndarray[complex, ndim=3] results = np.empty((evalpos_a.shape[0], basissize, 3), dtype=complex)
|
||||||
cdef ccart3_t *res
|
cdef ccart3_t *res
|
||||||
res = <ccart3_t *> malloc(basissize*sizeof(ccart3_t))
|
|
||||||
cdef cart3_t pos
|
cdef cart3_t pos
|
||||||
cdef Py_ssize_t i, j
|
cdef Py_ssize_t i, j
|
||||||
with nogil, wraparound(False), parallel():
|
with nogil, wraparound(False), parallel():
|
||||||
|
res = <ccart3_t *> malloc(basissize*sizeof(ccart3_t)) # thread-local
|
||||||
for i in prange(evalpos_a.shape[0]):
|
for i in prange(evalpos_a.shape[0]):
|
||||||
pos.x = evalpos_a[i,0]
|
pos.x = evalpos_a[i,0]
|
||||||
pos.y = evalpos_a[i,1]
|
pos.y = evalpos_a[i,1]
|
||||||
|
@ -1342,7 +1342,7 @@ cdef class _ScatteringSystemAtOmega:
|
||||||
results[i,j,0] = res[j].x
|
results[i,j,0] = res[j].x
|
||||||
results[i,j,1] = res[j].y
|
results[i,j,1] = res[j].y
|
||||||
results[i,j,2] = res[j].z
|
results[i,j,2] = res[j].z
|
||||||
free(res)
|
free(res)
|
||||||
return results.reshape(evalpos.shape[:-1] + (basissize, 3))
|
return results.reshape(evalpos.shape[:-1] + (basissize, 3))
|
||||||
|
|
||||||
def bspec_pi(self, pi):
|
def bspec_pi(self, pi):
|
||||||
|
|
Loading…
Reference in New Issue