From dde6c7d034ee1b54548e843aebfa2f9cbc834e48 Mon Sep 17 00:00:00 2001 From: Andreas Holm <60451789+holm10@users.noreply.github.com> Date: Fri, 10 Jan 2025 21:29:35 -0800 Subject: [PATCH] Adds special c!omp for single-source build c!omp lines are removed in BASIS builds, which do not support OMP --- bbb/oderhs.m | 18 +++++++++--------- localrules.py | 9 +++++++-- setup.py | 13 +++++++++++++ 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/bbb/oderhs.m b/bbb/oderhs.m index 99bd95c8..995f410f 100755 --- a/bbb/oderhs.m +++ b/bbb/oderhs.m @@ -12323,13 +12323,13 @@ integer ia(neq+1) # pointers to beginning of each row in jac,ja Use(ParallelEval) # ParallelJac write(*,*) "jc_interf, ParallelJac = ", ParallelJac - if (ParallelJac.eq.1) then - call jac_calc_parallel (neq, t, yl, yldot00, ml, mu, wk, - . nnzmx, jac, ja, ia) - else +c!omp if (ParallelJac.eq.1) then +c!omp call jac_calc_parallel (neq, t, yl, yldot00, ml, mu, wk, +c!omp. nnzmx, jac, ja, ia) +c!omp else call jac_calc (neq, t, yl, yldot00, ml, mu, wk, . nnzmx, jac, ja, ia) - endif +c!omp endif end subroutine jac_calc_interface subroutine Pandf1rhs_interface(neq, time, yl, yldot) @@ -12340,11 +12340,11 @@ subroutine Pandf1rhs_interface(neq, time, yl, yldot) integer neq real time, yl(neqmx),yldot(neq) - if (ParallelPandf1.gt.0) then - call OMPPandf1Rhs(neq, time, yl, yldot) - else +c!omp if (ParallelPandf1.gt.0) then +c!omp call OMPPandf1Rhs(neq, time, yl, yldot) +c!omp else call pandf1(-1, -1, 0, neq, time, yl, yldot) - endif +c!omp endif end subroutine Pandf1rhs_interface diff --git a/localrules.py b/localrules.py index e89fcaa4..89cd2255 100644 --- a/localrules.py +++ b/localrules.py @@ -43,11 +43,16 @@ def Petsc(s): s=s.replace("cpetsc","") return s def Omp(s): - if getenv("ENV_VAR", 'False').lower() in ('true', '1', 't') + if isomp['status']: if s.startswith("c!omp"): s=s.replace("c!omp"," ") return s - +# Check whether to include or exlude c!omp-lines +try: + with open("builder/omp.flag", "r") as f: + isomp = {'status': bool(int(f.readline()))} +except: + isomp = {'status': False} saved_dec=0 in_uses=0 savedlines=[] diff --git a/setup.py b/setup.py index ac279043..f60999fa 100644 --- a/setup.py +++ b/setup.py @@ -4,6 +4,7 @@ # import os import os.path +from os import remove import string import site from Forthon.compilers import FCompiler @@ -167,6 +168,11 @@ def run(self): FLAGS['OMPargs'].remove('--omp') FLAGS['FARGS'].remove('-fopenmp') FLAGS['CARGS'].remove('-fopenmp') + # Flag for localrules + set_basis_omp(False) + else: + # Flag for localrules + set_basis_omp(True) # Add boundary checking to non-debug build if arglist['checkbounds']: FLAGS['FARGSOPT'] = FLAGS['FARGSOPT'] + [ @@ -193,6 +199,7 @@ def run(self): if call(['make',COMPILEFLAGS,OMPFLAGS,'-f','Makefile.Forthon']) != 0: raise SystemExit("UEDGE build failure") build.run(self) + remove('builder/omp.flag') # Modify clean to use make clean class uedgeClean(build): @@ -201,6 +208,12 @@ def run(self): if call(['make', '-f', 'Makefile.Forthon', 'clean']) != 0: raise SystemExit("Clean failure") +def set_basis_omp(isomp): + print(isomp, str(int(isomp))) + with open("builder/omp.flag", "w") as f: + f.write(str(int(isomp))) + f.write("\nPassing information on OMP build to localrules.py") + setup( name="uedge", ext_modules= [