Skip to content

Commit

Permalink
python: add set number of threads interface
Browse files Browse the repository at this point in the history
Signed-off-by: Thorsten Liebig <Thorsten.Liebig@gmx.de>
  • Loading branch information
thliebig committed Jan 4, 2018
1 parent 9b86db4 commit 65ca6bf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion openems.cpp
Expand Up @@ -217,7 +217,7 @@ bool openEMS::parseCommandLineArgument( const char *argv )
}
else if (strncmp(argv,"--numThreads=",13)==0)
{
m_engine_numThreads = atoi(argv+13);
this->SetNumberOfThreads(atoi(argv+13));
cout << "openEMS - fixed number of threads: " << m_engine_numThreads << endl;
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions openems.h
Expand Up @@ -70,6 +70,8 @@ class openEMS
void SetTimeStepFactor(double val) {m_TS_fac=val;}
void SetMaxTime(double val) {m_maxTime=val;}

void SetNumberOfThreads(unsigned int val) {m_engine_numThreads = val;}

void DebugMaterial() {DebugMat=true;}
void DebugOperator() {DebugOp=true;}
void DebugBox() {m_debugBox=true;}
Expand Down
2 changes: 2 additions & 0 deletions python/openEMS/openEMS.pxd
Expand Up @@ -39,6 +39,8 @@ cdef extern from "openEMS/openems.h":
void SetTimeStepFactor(double val)
void SetMaxTime(double val)

void SetNumberOfThreads(int val)

void Set_BC_Type(int idx, int _type)
int Get_BC_Type(int idx)
void Set_BC_PML(int idx, unsigned int size)
Expand Down
7 changes: 6 additions & 1 deletion python/openEMS/openEMS.pyx
Expand Up @@ -410,7 +410,7 @@ cdef class openEMS:
continue
grid.AddLine(n, hint[n])

def Run(self, sim_path, cleanup=False, setup_only=False, debug_pec=False, verbose=None):
def Run(self, sim_path, cleanup=False, setup_only=False, debug_pec=False, verbose=None, **kw):
""" Run(sim_path, cleanup=False, setup_only=False, verbose=None)
Run the openEMS FDTD simulation.
Expand All @@ -419,6 +419,9 @@ cdef class openEMS:
:param cleanup: bool -- remove exisiting sim_path to cleanup old results
:param setup_only: bool -- only perform FDTD setup, do not run simulation
:param verbose: int -- set the openEMS verbosity level 0..3
Additional keyword parameter:
:param numThreads: int -- set the number of threads (default 0 --> max)
"""
if cleanup and os.path.exists(sim_path):
shutil.rmtree(sim_path)
Expand All @@ -431,6 +434,8 @@ cdef class openEMS:
self.thisptr.SetVerboseLevel(verbose)
if debug_pec:
self.thisptr.DebugPEC()
if 'numThreads' in kw:
self.thisptr.SetNumberOfThreads(int(kw['numThreads']))
assert os.getcwd() == sim_path
_openEMS.WelcomeScreen()
cdef int EC
Expand Down

0 comments on commit 65ca6bf

Please sign in to comment.