Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenMP in Pyclaw #527

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
dd60e39
Implemented OpenMP in the PyClaw step3ds.f90 for the dimensioanlly sp…
weslowrie Oct 16, 2015
2cffe8b
Fixed bug when OMP_NUM_THREADS env variable is not set, and uses nthr…
weslowrie Oct 16, 2015
2bfff21
Added a comment related to a hack of adding and subtracting a variabl…
weslowrie Oct 16, 2015
3bc6ba8
Update solver.py
weslowrie Oct 19, 2015
7e21323
Updated solver.py to set the default number of threads to the number …
weslowrie Oct 29, 2015
015ba3d
Merge branch 'pyclaw_openmp' of https://github.com/weslowrie/pyclaw i…
weslowrie Oct 29, 2015
9a871d6
Updated implementation to use 1 OpenMP thread by default and give a w…
weslowrie Nov 5, 2015
44230e8
small simplification to OMP_NUM_THREADS env variable check.
weslowrie Nov 5, 2015
2d325b4
Updated OpenMP warning to use the PyClaw logging. This prints to the…
weslowrie Nov 6, 2015
66a28ee
Implemented OpenMP in the PyClaw step3ds.f90 for the dimensioanlly sp…
weslowrie Oct 16, 2015
87f5f16
Added F90 and f2py options for OpenMP (-fopenmp, and gomp => -lgomp) …
weslowrie Oct 16, 2015
00880f6
Fixed bug when OMP_NUM_THREADS env variable is not set, and uses nthr…
weslowrie Oct 16, 2015
3dad707
removed debugging print statement
weslowrie Oct 19, 2015
51f7161
Updated solver.py to set the default number of threads to the number …
weslowrie Oct 29, 2015
ba15781
Updated implementation to use 1 OpenMP thread by default and give a w…
weslowrie Nov 5, 2015
55c4a3d
small simplification to OMP_NUM_THREADS env variable check.
weslowrie Nov 5, 2015
92158db
Updated OpenMP warning to use the PyClaw logging. This prints to the…
weslowrie Nov 6, 2015
b20bf4f
Merge branch 'master' of https://github.com/weslowrie/pyclaw into pyc…
weslowrie Jul 5, 2016
0b595de
Various changes to pyclaw. Updates to properly handle restarts using…
weslowrie Nov 23, 2017
cb6a50d
Revert "Various changes to pyclaw. Updates to properly handle restar…
weslowrie Nov 27, 2017
7a87fef
after_step readded to commit, and comments to be able to quickly swit…
weslowrie Nov 27, 2017
851b522
Merge branch 'master' of https://github.com/weslowrie/pyclaw into pyc…
weslowrie Nov 27, 2017
f4c60a9
removed the dimensional/non-dimensional split comments.
weslowrie Nov 27, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/pyclaw/classic/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def configuration(parent_package='',top_path=None):
['limiter.f90','philim.f90','flux2.f90','step2ds.f90','step2.f90'],f2py_options=['--quiet'])

config.add_extension('classic3',
['limiter.f90','philim.f90','flux3.f90','step3ds.f90','step3.f90'],f2py_options=['--quiet'])
['limiter.f90','philim.f90','flux3.f90','step3ds.f90','step3.f90'],f2py_options=['--quiet'],extra_f90_compile_args=['-fopenmp'],libraries=['gomp'])

return config

Expand Down
45 changes: 29 additions & 16 deletions src/pyclaw/classic/solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,9 +610,17 @@ def __init__(self, riemann_solver=None, claw_package=None):
self.aux2 = None
self.aux3 = None
self.work = None
self.nthreads = None

super(ClawSolver3D,self).__init__(riemann_solver, claw_package)

import os
if 'OMP_NUM_THREADS' not in os.environ:
self.logger.warn(""""The env variable 'OMP_NUM_THREADS' is unset.
Set this variable to use OpenMP with more
than 1 thread (i.e. export OMP_NUM_THREADS=4).""")
self.nthreads = int(os.environ.get('OMP_NUM_THREADS',1))

# ========== Setup routine =============================
def _allocate_workspace(self,solution):
r"""
Expand All @@ -636,10 +644,11 @@ def _allocate_workspace(self,solution):

# These work arrays really ought to live inside a fortran module
# as is done for sharpclaw
self.aux1 = np.empty((num_aux,maxm+2*num_ghost,3),order='F')
self.aux2 = np.empty((num_aux,maxm+2*num_ghost,3),order='F')
self.aux3 = np.empty((num_aux,maxm+2*num_ghost,3),order='F')
mwork = (maxm+2*num_ghost) * (31*num_eqn + num_waves + num_eqn*num_waves)
self.aux1 = np.empty((num_aux,maxm+2*num_ghost,3,self.nthreads),order='F')
self.aux2 = np.empty((num_aux,maxm+2*num_ghost,3,self.nthreads),order='F')
self.aux3 = np.empty((num_aux,maxm+2*num_ghost,3,self.nthreads),order='F')
mwork = (maxm+2*num_ghost)\
*(31*num_eqn + num_waves + num_eqn*num_waves)*self.nthreads
self.work = np.empty((mwork),order='F')


Expand Down Expand Up @@ -676,25 +685,29 @@ def step_hyperbolic(self,solution):
#Right now only Godunov-dimensional-splitting is implemented.
#Strang-dimensional-splitting could be added following dimsp3.f in Clawpack.

q, cfl_x = self.fmod.step3ds(maxm,self.num_ghost,mx,my,mz, \
qold,qnew,self.auxbc,dx,dy,dz,self.dt,self._method,self._mthlim,\
self.aux1,self.aux2,self.aux3,self.work,1,self.fwave,rpn3,rpt3,rptt3)
q, cfl_x = self.fmod.step3ds(maxm,self.nthreads,self.num_ghost,\
mx,my,mz,qold,qnew,self.auxbc,dx,dy,dz,self.dt,self._method,\
self._mthlim,self.aux1,self.aux2,self.aux3,self.work,1,\
self.fwave,rpn3,rpt3,rptt3)

q, cfl_y = self.fmod.step3ds(maxm,self.num_ghost,mx,my,mz, \
q,q,self.auxbc,dx,dy,dz,self.dt,self._method,self._mthlim,\
self.aux1,self.aux2,self.aux3,self.work,2,self.fwave,rpn3,rpt3,rptt3)
q, cfl_y = self.fmod.step3ds(maxm,self.nthreads,self.num_ghost,\
mx,my,mz,q,q,self.auxbc,dx,dy,dz,self.dt,self._method,\
self._mthlim,self.aux1,self.aux2,self.aux3,self.work,2,\
self.fwave,rpn3,rpt3,rptt3)

q, cfl_z = self.fmod.step3ds(maxm,self.num_ghost,mx,my,mz, \
q,q,self.auxbc,dx,dy,dz,self.dt,self._method,self._mthlim,\
self.aux1,self.aux2,self.aux3,self.work,3,self.fwave,rpn3,rpt3,rptt3)
q, cfl_z = self.fmod.step3ds(maxm,self.nthreads,self.num_ghost,\
mx,my,mz,q,q,self.auxbc,dx,dy,dz,self.dt,self._method,\
self._mthlim,self.aux1,self.aux2,self.aux3,self.work,3,\
self.fwave,rpn3,rpt3,rptt3)

cfl = max(cfl_x,cfl_y,cfl_z)

else:

q, cfl = self.fmod.step3(maxm,self.num_ghost,mx,my,mz, \
qold,qnew,self.auxbc,dx,dy,dz,self.dt,self._method,self._mthlim,\
self.aux1,self.aux2,self.aux3,self.work,self.fwave,rpn3,rpt3,rptt3)
q, cfl = self.fmod.step3(maxm,self.nthreads,self.num_ghost,\
mx,my,mz,qold,qnew,self.auxbc,dx,dy,dz,self.dt,self._method,\
self._mthlim,self.aux1,self.aux2,self.aux3,self.work,\
self.fwave,rpn3,rpt3,rptt3)

self.cfl.update_global_max(cfl)
state.set_q_from_qbc(self.num_ghost,self.qbc)
Expand Down
Loading