python: unlock python GIL for long running tasks
Signed-off-by: Thorsten Liebig <liebig@imst.de>pull/66/head
parent
e7475a3bd1
commit
9e5dcecd31
|
@ -24,9 +24,9 @@ cimport cython.numeric
|
|||
|
||||
cdef extern from "openEMS/nf2ff.h":
|
||||
cdef cppclass cpp_nf2ff "nf2ff":
|
||||
cpp_nf2ff(vector[float] freq, vector[float] theta, vector[float] phi, vector[float] center, unsigned int numThreads) except +
|
||||
cpp_nf2ff(vector[float] freq, vector[float] theta, vector[float] phi, vector[float] center, unsigned int numThreads) nogil except +
|
||||
|
||||
bool AnalyseFile(string E_Field_file, string H_Field_file)
|
||||
bool AnalyseFile(string E_Field_file, string H_Field_file) nogil
|
||||
|
||||
void SetRadius(float radius)
|
||||
void SetPermittivity(vector[float] permittivity);
|
||||
|
@ -41,7 +41,7 @@ cdef extern from "openEMS/nf2ff.h":
|
|||
complex[double]** GetEPhi(size_t f_idx)
|
||||
double** GetRadPower(size_t f_idx)
|
||||
|
||||
bool Write2HDF5(string filename)
|
||||
bool Write2HDF5(string filename) nogil
|
||||
|
||||
void SetVerboseLevel(int level)
|
||||
|
||||
|
|
|
@ -40,7 +40,11 @@ cdef class _nf2ff:
|
|||
def AnalyseFile(self, e_file, h_file):
|
||||
assert os.path.exists(e_file)
|
||||
assert os.path.exists(h_file)
|
||||
return self.thisptr.AnalyseFile(e_file.encode('UTF-8'), h_file.encode('UTF-8'))
|
||||
cdef string e_fn = e_file.encode('UTF-8')
|
||||
cdef string h_fn = h_file.encode('UTF-8')
|
||||
with nogil:
|
||||
ok = self.thisptr.AnalyseFile(e_fn, h_fn)
|
||||
return ok
|
||||
|
||||
def SetMirror(self, mirr_type, ny, pos):
|
||||
if mirr_type<=0:
|
||||
|
|
|
@ -23,7 +23,7 @@ from CSXCAD.CSXCAD cimport _ContinuousStructure, ContinuousStructure
|
|||
|
||||
cdef extern from "openEMS/openems.h":
|
||||
cdef cppclass _openEMS "openEMS":
|
||||
_openEMS() except +
|
||||
_openEMS() nogil except +
|
||||
void SetNumberOfTimeSteps(unsigned int val)
|
||||
void SetCSX(_ContinuousStructure* csx)
|
||||
|
||||
|
@ -49,13 +49,15 @@ cdef extern from "openEMS/openems.h":
|
|||
|
||||
void SetGaussExcite(double f0, double fc)
|
||||
|
||||
void SetVerboseLevel(int level)
|
||||
void DebugPEC()
|
||||
void DebugMaterial()
|
||||
void DebugCSX()
|
||||
void SetAbort(bool val)
|
||||
|
||||
int SetupFDTD()
|
||||
void RunFDTD()
|
||||
void SetVerboseLevel(int level)
|
||||
void DebugPEC() nogil
|
||||
void DebugMaterial() nogil
|
||||
void DebugCSX() nogil
|
||||
|
||||
int SetupFDTD() nogil
|
||||
void RunFDTD() nogil
|
||||
|
||||
@staticmethod
|
||||
void WelcomeScreen()
|
||||
|
|
|
@ -432,15 +432,21 @@ cdef class openEMS:
|
|||
if verbose is not None:
|
||||
self.thisptr.SetVerboseLevel(verbose)
|
||||
if debug_pec:
|
||||
self.thisptr.DebugPEC()
|
||||
with nogil:
|
||||
self.thisptr.DebugPEC()
|
||||
if 'numThreads' in kw:
|
||||
self.thisptr.SetNumberOfThreads(int(kw['numThreads']))
|
||||
assert os.getcwd() == sim_path
|
||||
_openEMS.WelcomeScreen()
|
||||
cdef int EC
|
||||
EC = self.thisptr.SetupFDTD()
|
||||
with nogil:
|
||||
EC = self.thisptr.SetupFDTD()
|
||||
if EC!=0:
|
||||
print('Run: Setup failed, error code: {}'.format(EC))
|
||||
if setup_only or EC!=0:
|
||||
return EC
|
||||
self.thisptr.RunFDTD()
|
||||
with nogil:
|
||||
self.thisptr.RunFDTD()
|
||||
|
||||
def SetAbort(self, val):
|
||||
self.thisptr.SetAbort(val)
|
||||
|
|
Loading…
Reference in New Issue