Skip to content

Commit

Permalink
Merge pull request #16 from firedrakeproject/angus-g/upstream-20231013
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
connorjward authored Oct 19, 2023
2 parents 37b8d52 + da64333 commit 2eb7f70
Show file tree
Hide file tree
Showing 113 changed files with 1,279 additions and 1,381 deletions.
26 changes: 12 additions & 14 deletions config/BuildSystem/config/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,7 @@ def infinitePatch(str):
{x}
#define PetscXstr_(s) PetscStr_(s)
#define PetscStr_(s) #s
char *ver = "petscpkgver(" PetscXstr_({y}) ")";
const char *ver = "petscpkgver(" PetscXstr_({y}) ")";
'''.format(x=includeLines, y=self.versionname))
# Ex. char *ver = "petscpkgver(" "20211206" ")";
# But after stripping spaces, quotes etc below, it becomes char*ver=petscpkgver(20211206);
Expand All @@ -1241,20 +1241,18 @@ def infinitePatch(str):
return
self.popLanguage()
setattr(self.compilers, flagsArg,oldFlags)
#strip #lines
output = re.sub('#.*\n','\n',output)
#strip newlines,spaces,quotes
output = re.sub('[\n "]*','',output)
#strip backslash. Mumps' version macro already has "" around it, giving output: char *ver = petscpkgver(" "\"5.4.1\"" ")";
output = output.replace('\\','')
#now split over ';'
loutput = output.split(';')
# the preprocessor output might be very long, but the petscpkgver line should be at the end. Therefore, we partition it backwards
[mid, right] = output.rpartition('petscpkgver')[1:]
version = ''
for i in loutput:
if i.find('petscpkgver') >=0:
self.log.write('Found version string: ' + i +'\n')
version = i.split('(')[1].split(')')[0]
break
if mid: # if mid is not empty, then it should be 'petscpkgver', meaning we found the version string
verLine = right.split(';',1)[0] # get the string before the first ';'. Preprocessor might dump multiline result.
self.log.write('Found the raw version string: ' + verLine +'\n')
# strip backslashs, spaces and quotes. Note Mumps' version macro has "" around it, giving output: (" "\"5.4.1\"" ")";
for char in ['\\', ' ', '"']:
verLine = verLine.replace(char, '')
# get the string between the outer ()
version = verLine.split('(', 1)[-1].rsplit(')',1)[0]
self.log.write('This is the processed version string: ' + version +'\n')
if not version:
self.log.write('For '+self.package+' unable to find version information: output below, skipping version check\n')
self.log.write(output)
Expand Down
2 changes: 1 addition & 1 deletion config/BuildSystem/config/packages/cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class Configure(config.package.GNUPackage):
def __init__(self, framework):
config.package.GNUPackage.__init__(self, framework)
self.version = '3.27.6'
self.version = '3.27.7'
self.download = ['https://github.com/Kitware/CMake/releases/download/v'+self.version+'/cmake-'+self.version+'.tar.gz',
'https://gitlab.kitware.com/cmake/cmake/-/archive/v'+self.version+'/cmake-v'+self.version+'.tar.gz']
self.download_solaris = ['https://cmake.org/files/v3.11/cmake-3.11.4.tar.gz',
Expand Down
5 changes: 3 additions & 2 deletions config/BuildSystem/config/packages/hip.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ class Configure(config.package.Package):
def __init__(self, framework):
config.package.Package.__init__(self, framework)

self.minversion = '4.1'
self.versionname = 'HIP_VERSION_MAJOR.HIP_VERSION_MINOR'
self.minversion = '4.1.0'
# HIP_VERSION_PATCH (e.g., 31061) is not necessarily the AMD advertised patch version, e.g., in 5.6.0
self.versionname = 'HIP_VERSION_MAJOR.HIP_VERSION_MINOR.HIP_VERSION_PATCH'
self.versioninclude = 'hip/hip_version.h'
self.requiresversion = 1
self.functionsCxx = [1,'', 'rocblas_create']
Expand Down
2 changes: 1 addition & 1 deletion config/BuildSystem/config/packages/hpddm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class Configure(config.package.Package):
def __init__(self,framework):
config.package.Package.__init__(self,framework)
self.version = '2.2.4'
self.gitcommit = 'v'+self.version # main sep-15-2023
self.gitcommit = '69bebeece9139b59524c70b88b60ccd4fba8a16a' # fix-saddle oct-10-2023
self.download = ['git://https://github.com/hpddm/hpddm','https://github.com/hpddm/hpddm/archive/'+self.gitcommit+'.tar.gz']
self.minversion = '2.2.1'
self.versionname = 'HPDDM_VERSION'
Expand Down
2 changes: 1 addition & 1 deletion config/BuildSystem/config/packages/mpi4py.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Configure(config.package.Package):
def __init__(self, framework):
config.package.Package.__init__(self, framework)
self.download = ['https://github.com/mpi4py/mpi4py/releases/download/3.1.4/mpi4py-3.1.4.tar.gz']
self.download = ['https://github.com/mpi4py/mpi4py/releases/download/3.1.5/mpi4py-3.1.5.tar.gz']
self.functions = []
self.includes = []
self.useddirectly = 0
Expand Down
5 changes: 2 additions & 3 deletions config/BuildSystem/config/packages/sycl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ def __init__(self, framework):
config.package.Package.__init__(self, framework)
self.minversion = '20200101'
self.versionname = '__SYCL_COMPILER_VERSION' # The build date of the SYCL library, presented in the format YYYYMMDD.
self.versioninclude = 'CL/sycl/version.hpp'
# CL/sycl.h is dpcpp. Other SYCL impls may use SYCL/sycl.hpp -- defer
self.includes = ['CL/sycl.hpp']
self.versioninclude = 'sycl/version.hpp'
self.includes = ['sycl/sycl.hpp']
self.includedir = 'include/sycl'
self.functionsCxx = [1,'namespace sycl = cl;','sycl::device::get_devices()']
# Unlike CUDA or HIP, the blas issues are just part of MKL and handled as such.
Expand Down
5 changes: 3 additions & 2 deletions config/BuildSystem/config/packages/zlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
class Configure(config.package.Package):
def __init__(self, framework):
config.package.Package.__init__(self, framework)
self.version = '1.2.13'
self.version = '1.3'
self.versionname = 'ZLIB_VERSION'
self.download = ['http://www.zlib.net/zlib-'+self.version+'.tar.gz',
'https://github.com/madler/zlib/releases/download/v'+self.version+'/zlib-'+self.version+'.tar.gz',
'https://web.cels.anl.gov/projects/petsc/download/externalpackages/zlib-'+self.version+'.tar.gz']
self.functions = ['compress', 'uncompress']
self.includes = ['zlib.h']
Expand Down Expand Up @@ -44,7 +45,7 @@ def Install(self):
self.log.write('zlibDir = '+self.packageDir+' installDir '+self.installDir+'\n')
self.logPrintBox('Building and installing zlib; this may take several minutes')
try:
output,err,ret = config.base.Configure.executeShellCommand('cd '+self.packageDir+' && ' + args + ' ./configure '+cargs+' && '+self.make.make_jnp+' && '+self.make.make+' install', timeout=600, log = self.log)
output,err,ret = config.base.Configure.executeShellCommand('cd '+self.packageDir+' && ' + args + ' ./configure '+cargs+' && '+self.make.make_jnp+' && '+self.make.make+' install', timeout=600, log = self.log)
except RuntimeError as e:
raise RuntimeError('Error building/install zlib files from '+os.path.join(self.packageDir, 'zlib')+' to '+self.packageDir)
self.postInstall(output+err,conffile)
Expand Down
2 changes: 2 additions & 0 deletions doc/changes/dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ Changes: Development

.. rubric:: PC:

- Add ``PCGAMGSetLowMemoryFilter()`` with corresponding option ``-pc_gamg_low_memory_threshold_filter``. Use the system ``MatFilter`` graph/matrix filter, without a temporary copy of the graph, otherwise use method that can be faster

.. rubric:: KSP:

.. rubric:: SNES:
Expand Down
4 changes: 2 additions & 2 deletions doc/faq/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -669,8 +669,8 @@ PETSc also contains a balancing Neumann-Neumann type preconditioner, see the man
for ``PCBDDC``. This requires matrices be constructed with ``MatCreateIS()`` via the finite
element method. See ``src/ksp/ksp/tests/ex59.c`` for an example.

You have ``MATAIJ`` and ``MATBAIJ`` matrix formats, and ``MATSBAIJ`` for symmetric storage, how come no `MATSAIJ``?
-------------------------------------------------------------------------------------------------------------------
You have ``MATAIJ`` and ``MATBAIJ`` matrix formats, and ``MATSBAIJ`` for symmetric storage, how come no ``MATSAIJ``?
--------------------------------------------------------------------------------------------------------------------

Just for historical reasons; the ``MATSBAIJ`` format with blocksize one is just as efficient as
a `MATSAIJ` would be.
Expand Down
2 changes: 1 addition & 1 deletion doc/manual/ksp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,7 @@ scaling, available via the command line switch
``PCISSetSubdomainScalingFactor()``,
``PCISSetSubdomainDiagonalScaling()`` or
``PCISSetUseStiffnessScaling()``. However, the convergence properties of
the `PCBDDC`` method degrades in presence of large jumps in the material
the ``PCBDDC`` method degrades in presence of large jumps in the material
coefficients not aligned with the interface; for such cases, PETSc has
the capability of adaptively computing the primal constraints. Adaptive
selection of constraints could be requested by specifying a threshold
Expand Down
2 changes: 1 addition & 1 deletion doc/manual/mat.rst
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ Note that for
most PETSc matrices the values returned by ``MatGetOwnershipIS()`` are the same as those returned by ``MatGetOwnershipRange()`` and
``MatGetOwnershipRangeColumn()``.

The PETSc object ``PetscLayout`` contains the ownership information that is provided by ``VecGetOwnershipRange()`` and with ``MatGetOwnershipRange()``, ``MatGetOwnershipRangeColumn()``. Each vector has one layout, which can be obtained with ``VecGetLayout()`` and ``MatGetLayouts()``. Layouts support the routines ``PetscLayoutGetLocalSize()``, ``PetscLayoutGetSize()``, ``PetscLayoutGetBlockSize()``, ``PetscLayoutGetRanges()``, ``PetscLayoutCompare()`` as well as a variety of creation routines. These are used by the ``Vec`` and ``Mat`` and so are rarely needed directly. Finally ``PetscSplitOwnership()`` is a utility routine that does the same splitting of ownership ranges as `PetscLayout``.
The PETSc object ``PetscLayout`` contains the ownership information that is provided by ``VecGetOwnershipRange()`` and with ``MatGetOwnershipRange()``, ``MatGetOwnershipRangeColumn()``. Each vector has one layout, which can be obtained with ``VecGetLayout()`` and ``MatGetLayouts()``. Layouts support the routines ``PetscLayoutGetLocalSize()``, ``PetscLayoutGetSize()``, ``PetscLayoutGetBlockSize()``, ``PetscLayoutGetRanges()``, ``PetscLayoutCompare()`` as well as a variety of creation routines. These are used by the ``Vec`` and ``Mat`` and so are rarely needed directly. Finally ``PetscSplitOwnership()`` is a utility routine that does the same splitting of ownership ranges as ``PetscLayout``.


.. _sec_matsparse:
Expand Down
2 changes: 1 addition & 1 deletion gmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $(generated) : $(petscconf) $(petscvariables) config/gmakegen.py
$(PYTHON) ./config/gmakegen.py --petsc-arch=$(PETSC_ARCH)

# Skip including generated files (which triggers rebuilding them) when we're just going to clean anyway.
ifneq ($(filter-out alletags deletefortranstubs allfortranstubs allfortranstubsinplace help clean check info gmakeinfo,$(MAKECMDGOALS:clean%=clean)),)
ifneq ($(filter-out alletags deletefortranstubs allfortranstubs allfortranstubsinplace help clean distclean check info gmakeinfo,$(MAKECMDGOALS:clean%=clean)),)
include $(generated)
endif

Expand Down
2 changes: 1 addition & 1 deletion gmakefile.test
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ endif
$(generatedtest) : $(petscconf) $(petscvariables) $(CONFIGDIR)/gmakegentest.py $(TESTDIR)/.DIR | $$(@D)/.DIR
$(PYTHON) $(CONFIGDIR)/gmakegentest.py --petsc-dir=$(PETSC_DIR) --petsc-arch=$(PETSC_ARCH) --testdir=$(TESTDIR) --srcdir $(TESTSRCDIR) --pkg-pkgs "$(pkgs)"

ifneq ($(filter-out help docs clean check info gmakeinfo libs all install install-lib checkbadSource checkbadFileChange deletefortranstubs allfortranstubs allfortranstubsinplace alletags clangformat checkclangformat get%,$(MAKECMDGOALS:clean%=clean)),)
ifneq ($(filter-out help docs clean distclean check info gmakeinfo libs all install install-lib checkbadSource checkbadFileChange deletefortranstubs allfortranstubs allfortranstubsinplace alletags clangformat checkclangformat get%,$(MAKECMDGOALS:clean%=clean)),)
include $(generatedtest)
endif

Expand Down
1 change: 1 addition & 0 deletions include/petscpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ PETSC_EXTERN PetscErrorCode PCGAMGCreateGraph(PC, Mat, Mat *);
PETSC_EXTERN PetscErrorCode PCGAMGSetAggressiveSquareGraph(PC, PetscBool);
PETSC_EXTERN PetscErrorCode PCGAMGMISkSetMinDegreeOrdering(PC, PetscBool);
PETSC_EXTERN PetscErrorCode PCGAMGMISkSetAggressive(PC, PetscInt);
PETSC_EXTERN PetscErrorCode PCGAMGSetLowMemoryFilter(PC, PetscBool);

PETSC_EXTERN PetscErrorCode PCGAMGClassicalSetType(PC, PCGAMGClassicalType);
PETSC_EXTERN PetscErrorCode PCGAMGClassicalGetType(PC, PCGAMGClassicalType *);
Expand Down
4 changes: 2 additions & 2 deletions lib/petsc/conf/rules.doc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ manualpages:
html:
-@export htmlmap_tmp=$$(mktemp) ;\
petsc_dir=$$(realpath ${PETSC_DIR}); LOCDIR=$$(pwd | sed s"?$${petsc_dir}/??"g)/; \
sed -e s?man+manualpages/?man+ROOT/manualpages/? ${HTMLMAP} > $$htmlmap_tmp ;\
sed -e s?man+manualpages/?man+HTML_ROOT/manualpages/? ${HTMLMAP} > $$htmlmap_tmp ;\
cat ${PETSC_DIR}/doc/classic/mpi.www.index >> $$htmlmap_tmp ;\
ROOT=`echo $${LOCDIR} | sed -e s?/[-a-z_0-9]*?/..?g -e s?src/??g -e s?include/??g` ;\
loc=`pwd | sed -e s?\$${PETSC_DIR}?$${LOC}/?g -e s?/disks??g`; \
Expand All @@ -112,7 +112,7 @@ html:
awk '{ sub(/<pre width="80">/,"<pre width=\"80\">\n"); print }' | \
${PYTHON} ${PETSC_DIR}/lib/petsc/bin/maint/fixinclude.py $$i $${PETSC_DIR} | \
grep -E -v '(PetscValid|#if !defined\(__|#define __|#undef __|EXTERN_C )' | \
${MAPNAMES} -map $$htmlmap_tmp -inhtml | sed -e s?ROOT?$${IROOT}?g >> $${loc}/$$i.html ; \
${MAPNAMES} -map $$htmlmap_tmp -inhtml | sed -e s?HTML_ROOT?$${IROOT}?g >> $${loc}/$$i.html ; \
fi; \
done ;\
loc=`pwd | sed -e s?\$${PETSC_DIR}?$${LOC}/?g -e s?/disks??g`; ${RM} $${loc}/index.html; \
Expand Down
9 changes: 6 additions & 3 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,12 @@ clean:: allclean
distclean:
@if [ -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ]; then \
echo "*** Preserving ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py in ${PETSC_DIR} ***"; \
mv -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ${PETSC_DIR}/; fi
@echo "*** Deleting all build files in ${PETSC_DIR}/${PETSC_ARCH} ***"
-${RM} -rf ${PETSC_DIR}/${PETSC_ARCH}/
mv -f ${PETSC_DIR}/${PETSC_ARCH}/lib/petsc/conf/reconfigure-${PETSC_ARCH}.py ${PETSC_DIR}/; \
echo "*** Deleting all build files in ${PETSC_DIR}/${PETSC_ARCH} ***"; \
${RM} -rf ${PETSC_DIR}/${PETSC_ARCH}/ ; \
else \
echo "*** Build files in PETSC_ARCH=${PETSC_ARCH} not found. Skipping delete! ***"; \
fi

info:
+@${OMAKE} -f gmakefile gmakeinfo
Expand Down
61 changes: 61 additions & 0 deletions src/binding/petsc4py/src/lib-petsc/custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,67 @@ PetscErrorCode KSPConverged(KSP ksp,PetscInt iter,PetscReal rnorm,KSPConvergedRe
PetscFunctionReturn(PETSC_SUCCESS);
}

typedef struct {
PetscBool prepend_custom;
PetscErrorCode (*convtest)(KSP, PetscInt, PetscReal, KSPConvergedReason *, void *);
PetscErrorCode (*convdestroy)(void *);
PetscErrorCode (*convtestcustom)(KSP, PetscInt, PetscReal, KSPConvergedReason *, void *);
void *convctx;
} KSPConvergedNativeCtx;

static
PetscErrorCode KSPConvergedNative_Private(KSP ksp, PetscInt n, PetscReal rnorm, KSPConvergedReason *reason, void *cctx)
{
KSPConvergedNativeCtx *ctx = (KSPConvergedNativeCtx *)cctx;

PetscFunctionBegin;
*reason = KSP_CONVERGED_ITERATING;
if (ctx->prepend_custom) {
PetscCall((*ctx->convtestcustom)(ksp, n, rnorm, reason, NULL));
if (*reason) {
PetscCall(PetscInfo(ksp, "User provided prepended Python convergence test reason %s KSP iterations=%" PetscInt_FMT ", rnorm=%g\n", KSPConvergedReasons[*reason], n, (double)rnorm));
PetscFunctionReturn(PETSC_SUCCESS);
}
}
PetscCall((*ctx->convtest)(ksp, n, rnorm, reason, ctx->convctx));
if (*reason) {
PetscCall(PetscInfo(ksp, "Default convergence test reason %s KSP iterations=%" PetscInt_FMT ", rnorm=%g\n", KSPConvergedReasons[*reason], n, (double)rnorm));
PetscFunctionReturn(PETSC_SUCCESS);
}
if (!ctx->prepend_custom) {
PetscCall((*ctx->convtestcustom)(ksp, n, rnorm, reason, NULL));
if (*reason) PetscCall(PetscInfo(ksp, "User provide appended Python convergence test reason %s KSP iterations=%" PetscInt_FMT ", rnorm=%g\n", KSPConvergedReasons[*reason], n, (double)rnorm));
}
PetscFunctionReturn(PETSC_SUCCESS);
}

static PetscErrorCode KSPConvergedNative_Destroy(void *cctx)
{
KSPConvergedNativeCtx *ctx = (KSPConvergedNativeCtx *)cctx;

PetscFunctionBegin;
PetscCheck(ctx, PETSC_COMM_SELF, PETSC_ERR_PLIB, "Missing context");
if (ctx->convdestroy) PetscCall((*ctx->convdestroy)(ctx->convctx));
PetscCall(PetscFree(ctx));
PetscFunctionReturn(PETSC_SUCCESS);
}

static
PetscErrorCode KSPAddConvergenceTest(KSP ksp, PetscErrorCode (*custom)(KSP, PetscInt, PetscReal, KSPConvergedReason *, void *), PetscBool prepend)
{
KSPConvergedNativeCtx *ctx;

PetscFunctionBegin;
PetscValidHeaderSpecific(ksp,KSP_CLASSID,1);
PetscValidLogicalCollectiveBool(ksp,prepend,3);
PetscCall(PetscNew(&ctx));
ctx->convtestcustom = custom;
ctx->prepend_custom = prepend;
PetscCall(KSPGetAndClearConvergenceTest(ksp, &ctx->convtest, &ctx->convctx, &ctx->convdestroy));
PetscCall(KSPSetConvergenceTest(ksp, KSPConvergedNative_Private, ctx, KSPConvergedNative_Destroy));
PetscFunctionReturn(PETSC_SUCCESS);
}

static
PetscErrorCode KSPLogHistory(KSP ksp,PetscReal rnorm)
{
Expand Down
Loading

0 comments on commit 2eb7f70

Please sign in to comment.