Revert scatsystem cython parallelisation.
It didn't work correctly on my laptop. This must be reviewed later, as the waiting is annoying.
This commit is contained in:
parent
227aaf4021
commit
b088464e3e
|
@ -17,8 +17,8 @@ from .cymaterials cimport EpsMuGenerator, EpsMu
|
||||||
from libc.stdlib cimport malloc, free, calloc
|
from libc.stdlib cimport malloc, free, calloc
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
from cython.parallel cimport prange, parallel
|
from cython.parallel import prange, parallel
|
||||||
from cython cimport boundscheck, wraparound
|
from cython import boundscheck, wraparound
|
||||||
|
|
||||||
# Set custom GSL error handler. N.B. this is obviously not thread-safe.
|
# Set custom GSL error handler. N.B. this is obviously not thread-safe.
|
||||||
cdef char *pgsl_err_reason
|
cdef char *pgsl_err_reason
|
||||||
|
@ -956,8 +956,8 @@ cdef class ScatteringSystem:
|
||||||
cdef ccart3_t res
|
cdef ccart3_t res
|
||||||
cdef cart3_t pos
|
cdef cart3_t pos
|
||||||
cdef Py_ssize_t i
|
cdef Py_ssize_t i
|
||||||
with nogil, parallel(), boundscheck(False), wraparound(False):
|
with nogil:
|
||||||
for i in prange(evalpos_a.shape[0]):
|
for i in range(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]
|
||||||
pos.z = evalpos_a[i,2]
|
pos.z = evalpos_a[i,2]
|
||||||
|
@ -997,6 +997,7 @@ def empty_lattice_modes_xy(EpsMu epsmu, reciprocal_basis, wavevector, double max
|
||||||
free(omegas_c)
|
free(omegas_c)
|
||||||
return omegas
|
return omegas
|
||||||
|
|
||||||
|
|
||||||
cdef class _ScatteringSystemAtOmegaK:
|
cdef class _ScatteringSystemAtOmegaK:
|
||||||
'''
|
'''
|
||||||
Wrapper over the C qpms_scatsys_at_omega_k_t structure
|
Wrapper over the C qpms_scatsys_at_omega_k_t structure
|
||||||
|
@ -1042,8 +1043,8 @@ cdef class _ScatteringSystemAtOmegaK:
|
||||||
cdef ccart3_t res
|
cdef ccart3_t res
|
||||||
cdef cart3_t pos
|
cdef cart3_t pos
|
||||||
cdef Py_ssize_t i
|
cdef Py_ssize_t i
|
||||||
with nogil, wraparound(False), parallel():
|
with nogil:
|
||||||
for i in prange(evalpos_a.shape[0]):
|
for i in range(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]
|
||||||
pos.z = evalpos_a[i,2]
|
pos.z = evalpos_a[i,2]
|
||||||
|
@ -1086,9 +1087,9 @@ cdef class _ScatteringSystemAtOmegaK:
|
||||||
cdef ccart3_t *res
|
cdef ccart3_t *res
|
||||||
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:
|
||||||
res = <ccart3_t *> malloc(fecv_size*sizeof(ccart3_t))
|
res = <ccart3_t *> malloc(fecv_size*sizeof(ccart3_t))
|
||||||
for i in prange(evalpos_a.shape[0]):
|
for i in range(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]
|
||||||
pos.z = evalpos_a[i,2]
|
pos.z = evalpos_a[i,2]
|
||||||
|
@ -1256,18 +1257,17 @@ cdef class _ScatteringSystemAtOmega:
|
||||||
cdef ccart3_t res
|
cdef ccart3_t res
|
||||||
cdef cart3_t pos
|
cdef cart3_t pos
|
||||||
cdef Py_ssize_t i
|
cdef Py_ssize_t i
|
||||||
with wraparound(False), nogil, parallel():
|
for i in range(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]
|
pos.z = evalpos_a[i,2]
|
||||||
pos.z = evalpos_a[i,2]
|
if alt:
|
||||||
if alt:
|
res = qpms_scatsysw_scattered_E__alt(self.ssw, btyp_c, &scv_view[0], pos)
|
||||||
res = qpms_scatsysw_scattered_E__alt(self.ssw, btyp_c, &scv_view[0], pos)
|
else:
|
||||||
else:
|
res = qpms_scatsysw_scattered_E(self.ssw, btyp_c, &scv_view[0], pos)
|
||||||
res = qpms_scatsysw_scattered_E(self.ssw, btyp_c, &scv_view[0], pos)
|
results[i,0] = res.x
|
||||||
results[i,0] = res.x
|
results[i,1] = res.y
|
||||||
results[i,1] = res.y
|
results[i,2] = res.z
|
||||||
results[i,2] = res.z
|
|
||||||
return results.reshape(evalpos.shape)
|
return results.reshape(evalpos.shape)
|
||||||
|
|
||||||
@boundscheck(False)
|
@boundscheck(False)
|
||||||
|
@ -1313,9 +1313,9 @@ cdef class _ScatteringSystemAtOmega:
|
||||||
cdef ccart3_t *res
|
cdef ccart3_t *res
|
||||||
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:
|
||||||
res = <ccart3_t *> malloc(basissize*sizeof(ccart3_t)) # thread-local
|
res = <ccart3_t *> malloc(basissize*sizeof(ccart3_t)) # thread-local
|
||||||
for i in prange(evalpos_a.shape[0]):
|
for i in range(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]
|
||||||
pos.z = evalpos_a[i,2]
|
pos.z = evalpos_a[i,2]
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -150,7 +150,7 @@ qpms_c = Extension('qpms.qpms_c',
|
||||||
sources = ['qpms/qpms_c.pyx',],
|
sources = ['qpms/qpms_c.pyx',],
|
||||||
libraries = common_libs,
|
libraries = common_libs,
|
||||||
include_dirs=['amos', 'qpms', numpy_includes],
|
include_dirs=['amos', 'qpms', numpy_includes],
|
||||||
extra_link_args=['-fopenmp'],
|
extra_link_args=['-fopenmp'], # needed?
|
||||||
extra_compile_args=['-fopenmp'],
|
extra_compile_args=['-fopenmp'],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue