Skip to content

Commit

Permalink
Merge pull request #19 from firedrakeproject/connorjward/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
ksagiyam authored Mar 22, 2024
2 parents fe46695 + 083dd4d commit 272f13d
Show file tree
Hide file tree
Showing 2,453 changed files with 97,093 additions and 49,257 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ IndentWidth: 2
IndentWrappedFunctionNames: false
InsertTrailingCommas: None
KeepEmptyLinesAtTheStartOfBlocks: false
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
MacroBlockBegin: ''
MacroBlockEnd: ''
Expand Down
16 changes: 13 additions & 3 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,19 @@ c99-mlib-static-py:
clang-uni:
extends: .stage-1
variables:
CONFIG_OPTS: --with-cc=clang --with-cxx=clang++ --with-mpi=0
CONFIG_OPTS: --with-cc=clang --with-cxx=clang++ --with-mpi=0 --with-strict-petscerrorcode
TEST_SEARCH: snes_tutorials-ex48%

gcc-lto:
extends: .stage-1
variables:
CONFIG_OPTS: CFLAGS= CXXFLAGS= FFLAGS=
MAKE_CFLAGS: -Werror -flto=4 -Werror=odr -Werror=lto-type-mismatch
MAKE_CXXFLAGS: -Werror -flto=4 -Werror=odr -Werror=lto-type-mismatch
MAKE_FFLAGS: -Werror -flto=4 -Werror=odr -Werror=lto-type-mismatch
TEST_SEARCH: snes_tutorials-ex19% snes_tutorials-ex5f%
LOAD_MODULES: gcc/12.1.0 mpich/4.1-gcc-12.1.0

petsc4py-install:
extends: .stage-2
tags:
Expand Down Expand Up @@ -218,7 +228,7 @@ checksource:
- python3 ./configure --with-mpi=0 --with-fc=0 --with-cxx=0 --with-x=0 --with-bison=0 --with-cmake=0 --with-pthread=0 --with-regex=0
- vermin --version
- make vermin
- PATH=/nfs/gce/projects/petsc/soft/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/bin:$PATH make checkclangformat SHELL=bash
- PATH=/nfs/gce/projects/petsc/soft/u22.04/spack-2024-03-06/opt/spack/linux-ubuntu22.04-x86_64/gcc-11.4.0/llvm-18.1.0-7hsf4hzma6aebqsd4ifb5brchcooktkp/bin:$PATH make checkclangformat SHELL=bash
- make checkbadSource SHELL=bash
- make checkbadFileChange SHELL=bash
- make -f gmakefile check_output SHELL=bash
Expand Down Expand Up @@ -833,7 +843,7 @@ check-each-commit:
tags:
- gce-u22-stage2
script:
- export PATH=/nfs/gce/projects/petsc/soft/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/bin:$PATH
- export PATH=/nfs/gce/projects/petsc/soft/u22.04/spack-2024-03-06/opt/spack/linux-ubuntu22.04-x86_64/gcc-11.4.0/llvm-18.1.0-7hsf4hzma6aebqsd4ifb5brchcooktkp/bin:$PATH
- lib/petsc/bin/maint/check-each-commit.sh
except:
variables:
Expand Down
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
level of experience, education, socioeconomic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.

## Our Standards
Expand Down
9 changes: 0 additions & 9 deletions config/BuildSystem/.hgignore

This file was deleted.

6 changes: 0 additions & 6 deletions config/BuildSystem/.hgtags

This file was deleted.

22 changes: 11 additions & 11 deletions config/BuildSystem/config/compilerOptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import re
import nargs

re_win32fe_cl = re.compile(r'win32fe\s+cl')
re_win32fe_icl = re.compile(r'win32fe\s+icl')
re_win32fe_ifort = re.compile(r'win32fe\s+ifort')
re_win32fe_cl = re.compile(r'win32fe[\s_]+cl')
re_win32fe_icl = re.compile(r'win32fe[\s_]+ic[lx]')
re_win32fe_ifort = re.compile(r'win32fe[\s_]+if(x|ort)')

class CompilerOptions(config.base.Configure):
def getCFlags(self, compiler, bopt, language):
Expand Down Expand Up @@ -50,7 +50,7 @@ def getCFlags(self, compiler, bopt, language):
flags.append('-O')
else:
# Linux Intel
if config.setCompilers.Configure.isIntel(compiler, self.log) and not compiler.find('win32fe') >=0:
if config.setCompilers.Configure.isIntel(compiler, self.log) and not re_win32fe_icl.search(compiler):
if bopt == '':
flags.extend(['-wd1572', '-Wno-unknown-pragmas'])
# next one fails in OpenMP build and we don't use it anyway so remove
Expand All @@ -61,7 +61,7 @@ def getCFlags(self, compiler, bopt, language):
flags.append('-g')
flags.append('-O3')
# Windows Intel
elif 'win_icl' in compiler or re_win32fe_icl.search(compiler):
elif re_win32fe_icl.search(compiler):
if bopt == '':
flags.extend(['-Qstd=c99'])
if self.argDB['with-shared-libraries']:
Expand All @@ -73,7 +73,7 @@ def getCFlags(self, compiler, bopt, language):
elif bopt == 'O':
flags.extend(['-O3', '-QxW'])
# Windows Microsoft
elif 'win_cl' in compiler or re_win32fe_cl.search(compiler):
elif re_win32fe_cl.search(compiler):
if bopt == '':
dir(self)
# cause compiler to generate only a single copy of static strings; needed usage of __func__ in PETSc
Expand Down Expand Up @@ -176,7 +176,7 @@ def getCxxFlags(self, compiler, bopt, language):
flags.append('-O')
else:
# Linux Intel
if config.setCompilers.Configure.isIntel(compiler, self.log) and not compiler.find('win32fe') >=0:
if config.setCompilers.Configure.isIntel(compiler, self.log) and not re_win32fe_icl.search(compiler):
if bopt == '':
flags.append('-wd1572')
elif bopt == 'g':
Expand All @@ -185,7 +185,7 @@ def getCxxFlags(self, compiler, bopt, language):
flags.append('-g')
flags.append('-O3')
# Windows Intel
elif 'win_icl' in compiler or re_win32fe_icl.search(compiler):
elif re_win32fe_icl.search(compiler):
if bopt == '':
if self.argDB['with-shared-libraries']:
flags.extend(['-MD','-GR','-EHsc'])
Expand All @@ -196,7 +196,7 @@ def getCxxFlags(self, compiler, bopt, language):
elif bopt in ['O']:
flags.extend(['-O3', '-QxW'])
# Windows Microsoft
elif 'win_cl' in compiler or re_win32fe_cl.search(compiler):
elif re_win32fe_cl.search(compiler):
if bopt == '':
# cause compiler to generate only a single copy of static strings; needed usage of __func__ in PETSc
flags.extend(['-GF'])
Expand Down Expand Up @@ -274,14 +274,14 @@ def getFortranFlags(self, compiler, bopt):
elif bopt == 'O':
flags.extend(['-fast', '-Mnoframe'])
# Linux Intel
if config.setCompilers.Configure.isIntel(compiler, self.log) and not compiler.find('win32fe') >=0:
if config.setCompilers.Configure.isIntel(compiler, self.log) and not re_win32fe_ifort.search(compiler):
if bopt == 'g':
flags.extend(['-g','-O0'])
elif bopt == 'O':
flags.append('-g')
flags.append('-O3')
# Windows Intel
elif 'win_ifort' in compiler or re_win32fe_ifort.search(compiler):
elif re_win32fe_ifort.search(compiler):
if bopt == '':
if self.argDB['with-shared-libraries']:
flags.extend(['-MD'])
Expand Down
45 changes: 21 additions & 24 deletions config/BuildSystem/config/compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ def getSkipDefaultPaths(self):
if len(self.skipdefaultpaths):
return self.skipdefaultpaths
else:
self.skipdefaultpaths = ['/usr/lib','/lib','/usr/lib64','/lib64','/usr/lib/x86_64-linux-gnu','/lib/x86_64-linux-gnu','/usr/lib/i386-linux-gnu']
self.skipdefaultpaths = ['/usr/lib','/lib','/usr/lib64','/lib64']
for loc in ['/usr/lib','/lib']:
for arch in ['x86_64','i386','aarch64']:
self.skipdefaultpaths.append(os.path.join(loc,arch+'-linux-gnu'))
conda_sysrt = os.getenv('CONDA_BUILD_SYSROOT')
if conda_sysrt:
conda_sysrt = os.path.abspath(conda_sysrt)
Expand Down Expand Up @@ -622,6 +625,9 @@ def checkCxxLibraries(self):
elif arg == '-lLTO' and self.setCompilers.isDarwin(self.log):
self.logPrint('Skipping -lTO')
continue
elif arg.find('-libpath:')>=0:
self.logPrint('Skipping Intel oneAPI icx (on Microsoft Windows) compiler option: '+arg)
continue
elif iscray and (arg == '-lsci_cray_mpi' or arg == '-lsci_cray' or arg == '-lsci_cray_mp'):
self.logPrint('Skipping CRAY LIBSCI library: '+arg, 4, 'compilers')
continue
Expand Down Expand Up @@ -850,6 +856,7 @@ def checkFortranLibraries(self):
fbody = " subroutine asub()\n print*,'testing'\n return\n end\n"
self.popLanguage()
iscray = config.setCompilers.Configure.isCray(self.getCompiler('FC'), self.log)
isintel = config.setCompilers.Configure.isIntel(self.getCompiler('C'), self.log)
try:
if self.checkCrossLink(fbody,cbody,language1='FC',language2='C'):
self.logWrite(self.setCompilers.restoreLog())
Expand All @@ -858,34 +865,25 @@ def checkFortranLibraries(self):
skipfortranlibraries = 0
self.logWrite(self.setCompilers.restoreLog())
oldLibs = self.setCompilers.LIBS
self.setCompilers.LIBS = '-lgfortran '+self.setCompilers.LIBS
self.setCompilers.saveLog()
if self.checkCrossLink(fbody,cbody,language1='FC',language2='C'):
self.logWrite(self.setCompilers.restoreLog())
self.logPrint('Fortran requires -lgfortran to link with C compiler', 3, 'compilers')
self.setCompilers.LIBS = oldLibs
self.flibs.append('-lgfortran')
skipfortranlibraries = 1
else:
self.logWrite(self.setCompilers.restoreLog())
self.setCompilers.LIBS = oldLibs
self.logPrint('Fortran code cannot directly be linked with C linker, therefore will determine needed Fortran libraries')
skipfortranlibraries = 0
if iscray:
oldLibs = self.setCompilers.LIBS
self.setCompilers.LIBS = '-lmpifort_cray '+self.setCompilers.LIBS
testlibs = ['-lgfortran']
if iscray: testlibs.append('-lmpifort_cray')
if isintel: testlibs.append('-fortlib')
for testlib in testlibs:
self.setCompilers.LIBS = testlib+' '+self.setCompilers.LIBS
self.setCompilers.saveLog()
if self.checkCrossLink(fbody,cbody,language1='FC',language2='C'):
self.logWrite(self.setCompilers.restoreLog())
self.logPrint('Fortran requires -lmpifort_cray to link with C compiler', 3, 'compilers')
self.logPrint('Fortran requires '+testlib+' to link with C compiler', 3, 'compilers')
self.setCompilers.LIBS = oldLibs
self.flibs.append('-lmpifort_cray')
self.flibs.append(testlib)
skipfortranlibraries = 1
break
else:
self.logWrite(self.setCompilers.restoreLog())
self.setCompilers.LIBS = oldLibs
self.logPrint('Fortran code cannot directly be linked with C linker, therefore will determine needed Fortran libraries')
skipfortranlibraries = 0
if not skipfortranlibraries:
self.logPrint('Fortran code cannot directly be linked with C linker, therefore will determine needed Fortran libraries')
except RuntimeError as e:
self.logWrite(self.setCompilers.restoreLog())
self.logPrint('Error message from compiling {'+str(e)+'}', 4, 'compilers')
Expand Down Expand Up @@ -1061,10 +1059,6 @@ def checkFortranLibraries(self):
if not lib == '-LLTO' or not self.setCompilers.isDarwin(self.log):
flibs.append(lib)
continue
# intel windows compilers can use -libpath argument
if arg.find('-libpath:')>=0:
self.logPrint('Skipping win32 ifort option: '+arg)
continue
# Check for special library arguments
m = re.match(r'^-l.*$', arg)
if m:
Expand All @@ -1083,6 +1077,9 @@ def checkFortranLibraries(self):
continue
elif arg == '-lLTO' and self.setCompilers.isDarwin(self.log):
self.logPrint('Skipping -lTO')
elif arg.find('-libpath:')>=0:
self.logPrint('Skipping Intel oneAPI ifort (on Microsoft Windows) compiler option: '+arg)
continue
elif iscray and (arg == '-lsci_cray_mpi' or arg == '-lsci_cray' or arg == '-lsci_cray_mp'):
self.logPrint('Skipping CRAY LIBSCI library: '+arg, 4, 'compilers')
continue
Expand Down
2 changes: 1 addition & 1 deletion config/BuildSystem/config/compilersFortran.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def checkFortranModuleOutput(self):
self.popLanguage()
if modname: os.remove(os.path.join(testdir, modname))
os.rmdir(testdir)
# Flag not used by PETSc - do do not flag a runtime error
# Flag not used by PETSc - do not flag a runtime error
#if not found:
# raise RuntimeError('Cannot determine Fortran module output flag')
return
Expand Down
5 changes: 4 additions & 1 deletion config/BuildSystem/config/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,10 @@ def outputMakeRuleHeader(self, name):

def processPackageListDefine(self, defineDict):
key = 'PETSC_HAVE_PACKAGES'
pkglist = sorted(set([pkg.pkgname.lower() for pkg in self.packages]))
pkglist = []
for pkg in self.packages:
pkglist.extend(pkg.pkgname.lower().split())
pkglist.sort()
str = '":' + ':'.join(pkglist) + ':"'
defineDict[key] = (key, str)

Expand Down
42 changes: 30 additions & 12 deletions config/BuildSystem/config/libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,39 @@ def getLibArgumentList(self, library, with_rpath=True):
return [library] if with_rpath else []
if library.startswith('${FC_LINKER_SLFLAG}'):
return [library] if with_rpath else []
flagName = self.language[-1]+'SharedLinkerFlag'
flagSubst = self.language[-1].upper()+'_LINKER_SLFLAG'
rpathFlag = ''
if hasattr(self.setCompilers, flagName) and not getattr(self.setCompilers, flagName) is None:
rpathFlag = getattr(self.setCompilers, flagName)
elif flagSubst in self.argDB:
rpathFlag = self.argDB[flagSubst]
if library.startswith('-L'):
dirname = library[2:]
if not dirname.startswith('$') and not os.path.isdir(dirname): self.logPrint('Warning! getLibArgumentList(): could not locate dir '+ dirname)
if dirname in self.sysDirs:
return []
elif with_rpath and rpathFlag and not dirname in self.rpathSkipDirs:
return [rpathFlag+dirname,library]
else:
return [library]
if library.lstrip()[0] == '-':
return [library]
if len(library) > 3 and library[-4:] == '.lib':
return [library.replace('\\ ',' ').replace(' ', '\\ ').replace('\\(','(').replace('(', '\\(').replace('\\)',')').replace(')', '\\)')]
if os.path.basename(library).startswith('lib'):
name = self.getLibName(library)
if ((len(library) > 2 and library[1] == ':') or os.path.isabs(library)):
flagName = self.language[-1]+'SharedLinkerFlag'
flagSubst = self.language[-1].upper()+'_LINKER_SLFLAG'
dirname = os.path.dirname(library).replace('\\ ',' ').replace(' ', '\\ ').replace('\\(','(').replace('(', '\\(').replace('\\)',')').replace(')', '\\)')
if dirname in self.sysDirs:
return [library]
if with_rpath and not dirname in self.rpathSkipDirs:
if hasattr(self.setCompilers, flagName) and not getattr(self.setCompilers, flagName) is None:
return [getattr(self.setCompilers, flagName)+dirname,'-L'+dirname,'-l'+name]
import pathlib
if pathlib.Path(library).suffix[1:].isnumeric(): # libfoo.so.1.0
return [getattr(self.setCompilers, flagName)+dirname,library]
else:
return [getattr(self.setCompilers, flagName)+dirname,'-L'+dirname,'-l'+name]
if flagSubst in self.argDB:
return [self.argDB[flagSubst]+dirname,'-L'+dirname,'-l'+name]
return ['-L'+dirname,'-l'+name]
Expand Down Expand Up @@ -182,10 +200,10 @@ def genPreamble(f, funcName):
pre = prototype[f]
else:
# We use char because int might match the return type of a gcc2 builtin and its argument prototype would still apply.
pre = 'char '+funcName+'();'
pre = 'char '+funcName+'(void);'
# Capture the function call in a static function so that any local variables are isolated from
# calls to other library functions.
return pre + '\nstatic void _check_%s() { %s }' % (funcName, genCall(f, funcName, pre=True))
return pre + '\nstatic void _check_%s(void) { %s }' % (funcName, genCall(f, funcName, pre=True))
def genCall(f, funcName, pre=False):
if self.language[-1] != 'FC' and not pre:
return '_check_' + funcName + '();'
Expand Down Expand Up @@ -302,10 +320,10 @@ def checkMath(self):
'#include <stdio.h>\ndouble floor(double);',
'#include <stdio.h>\ndouble log10(double);',
'#include <stdio.h>\ndouble pow(double, double);']
calls = ['double x,y; int s = scanf("%lf",&x); y = sin(x); printf("%f %d",y,s);\n',
'double x,y; int s = scanf("%lf",&x); y = floor(x); printf("%f %d",y,s);\n',
'double x,y; int s = scanf("%lf",&x); y = log10(x); printf("%f %d",y,s);\n',
'double x,y; int s = scanf("%lf",&x); y = pow(x,x); printf("%f %d",y,s);\n']
calls = ['double x,y; int s = scanf("%lf",&x); y = sin(x); printf("%f %d",y,s)',
'double x,y; int s = scanf("%lf",&x); y = floor(x); printf("%f %d",y,s)',
'double x,y; int s = scanf("%lf",&x); y = log10(x); printf("%f %d",y,s)',
'double x,y; int s = scanf("%lf",&x); y = pow(x,x); printf("%f %d",y,s)']
if self.check('', funcs, prototype = prototypes, call = calls):
self.math = []
elif self.check('m', funcs, prototype = prototypes, call = calls):
Expand Down Expand Up @@ -348,11 +366,11 @@ def checkMathLgamma(self):

def checkMathFenv(self):
'''Checks if <fenv.h> can be used with FE_DFL_ENV'''
if not self.math is None and self.check(self.math, ['fesetenv'], prototype = ['#include <fenv.h>'], call = ['fesetenv(FE_DFL_ENV);']):
if not self.math is None and self.check(self.math, ['fesetenv'], prototype = ['#include <fenv.h>'], call = ['fesetenv(FE_DFL_ENV)']):
self.addDefine('HAVE_FENV_H', 1)
else:
self.logPrint('<fenv.h> with FE_DFL_ENV not found')
if not self.math is None and self.check(self.math, ['feclearexcept'], prototype = ['#include <fenv.h>'], call = ['feclearexcept(FE_INEXACT);']):
if not self.math is None and self.check(self.math, ['feclearexcept'], prototype = ['#include <fenv.h>'], call = ['feclearexcept(FE_INEXACT)']):
self.addDefine('HAVE_FE_VALUES', 1)
else:
self.logPrint('<fenv.h> with FE_INEXACT not found')
Expand All @@ -372,7 +390,7 @@ def checkRealtime(self):
self.rt = None
funcs = ['clock_gettime']
prototypes = ['#include <time.h>']
calls = ['struct timespec tp; clock_gettime(CLOCK_REALTIME,&tp);']
calls = ['struct timespec tp; clock_gettime(CLOCK_REALTIME,&tp)']
if self.check('', funcs, prototype=prototypes, call=calls):
self.logPrint('realtime functions are linked in by default')
self.rt = []
Expand Down
Loading

0 comments on commit 272f13d

Please sign in to comment.