[petsc-dev] PETSc optimization

Barry Smith bsmith at petsc.dev
Tue Aug 8 12:04:07 CDT 2023

  The space of "best" choices for optimization flags for PETSc is huge; each OS, each compiler, and each particular piece of hardware may have different "best" choices, in addition, the previous choice may not even allow compiling with any small change in any of these things. Finally particular choices may not be compatible with choices may be other packages being linked with PETSc. Hence PETSc's configure punts on trying to select a good choice (and just uses -O).  Surely this is an issue with most portable open source packages not being able to select "good" optimization flags in a portable way?

  Does the Spack system contain any infrastructure to help solve this common problem? That ensures all the packages it builds have good compatible optimization flags for the particular system?


Perhaps the configure message you mention printed by PETSc is inappropriate for Spack builds of PETSc and we should print something different to help guide the user to the correct Spack solution to the issue?



> On Aug 8, 2023, at 12:35 PM, Liu Wei AWE via petsc-dev <petsc-dev at mcs.anl.gov> wrote:
> Hi all
> I am currently building a large software stack using Spack with PETSc 3.19 as part of the dependency library.
> Spotted the following message during the build process
> Using default optimization C flags “-g -O”. You might consider manually setting optimal optimization flags for your system with
> COPTFLAGS="optimization flags" see config/examples/arch-*-opt.py for examples
> Previously when we install PETSc manually, optimisation flags are enforced via configure script e.g.
> COPTFLAGS=”-g -O3 -march=native”
> CXXOPTFLAGS=”-g -O3 -march=native”    
>> (or “-g -O3 -xhost” for intel compiler)
> Whilst spack spec syntax allows compiler parameters via cflags/cxxflags/fflags  
> https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/petsc/package.py <https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/petsc/package.py#L400>
> the requirement is not obvious, especially in a long build process.
> The question is should optimisation be amended at spack recipe stage or should PETSc configure enforce some compiler optimisation (if –with-debugging=0 is set) ?
> Regards
> Dr Wei Liu
> High Performance Computing
> To chat with me on Teams click here <https://teams.microsoft.com/l/chat/0/0?users=wei.liu@awe.co.uk>
> T: +44 01189 856209
> M: wei.liu at awe.co.uk <mailto:wei.liu at awe.co.uk>
> AWE Aldermaston,
> Reading, Berkshire, RG7 4PR
> The information in this email and in any attachment(s) is commercial in confidence. If you are not the named addressee(s) or if you receive this email in error then any distribution, copying or use of this communication or the information in it is strictly prohibited. Please notify us immediately by email at admin.internet(at)awe.co.uk <http://awe.co.uk/>, and then delete this message from your computer. While attachments are virus checked, AWE plc does not accept any liability in respect of any virus which is not detected. AWE Plc Registered in England and Wales Registration No 02763902 AWE, Aldermaston, Reading, RG7 4PR

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20230808/19787f72/attachment.html>

More information about the petsc-dev mailing list