<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div>  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?<div><br></div><div>  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?</div><div><br></div><div>  Barry</div><div><br></div><div>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?</div><div><br></div><div>   <br><div><br></div><div>  <br><div><br></div><div><br><div><br><blockquote type="cite"><div>On Aug 8, 2023, at 12:35 PM, Liu Wei AWE via petsc-dev <petsc-dev@mcs.anl.gov> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;"><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Hi all<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">I am currently building a large software stack using Spack with PETSc 3.19 as part of the dependency library.<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Spotted the following message during the build process<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9pt; font-family: Consolas; color: rgb(31, 35, 40); border: 1pt windowtext; padding: 0cm;">Using default optimization C flags “-g -O”. You might consider manually setting optimal optimization flags for your system with<o:p></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="font-size: 9pt; font-family: Consolas; color: rgb(31, 35, 40); border: 1pt windowtext; padding: 0cm;">COPTFLAGS="optimization flags" see config/examples/arch-*-opt.py for examples</span><span style="font-size: 9pt; font-family: Consolas; color: rgb(31, 35, 40);"><o:p></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Previously when we install PETSc manually, optimisation flags are enforced via configure script e.g.<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">COPTFLAGS=”-g -O3 -march=native”<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">CXXOPTFLAGS=”-g -O3 -march=native”    <o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">…<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">(or “-g -O3 -xhost” for intel compiler)<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Whilst spack spec syntax allows compiler parameters via cflags/cxxflags/fflags  <o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><a href="https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/petsc/package.py#L400" style="color: rgb(5, 99, 193); text-decoration: underline;">https://github.com/spack/spack/blob/develop/var/spack/repos/builtin/packages/petsc/package.py</a><o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">the requirement is not obvious, especially in a long build process.<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">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) ?<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;">Regards<o:p></o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(0, 116, 123);">Dr Wei Liu<o:p></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(118, 134, 147);">High Performance Computing<o:p></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(0, 116, 123);">To chat with me on Teams<span class="Apple-converted-space"> </span></span><a href="https://teams.microsoft.com/l/chat/0/0?users=wei.liu@awe.co.uk" style="color: rgb(5, 99, 193); text-decoration: underline;"><span>click here</span></a><span style="color: rgb(0, 116, 123);"><o:p></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(0, 116, 123);">T: +44 01189 856209<o:p></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(0, 116, 123);">M:<span class="Apple-converted-space"> </span></span><a href="mailto:wei.liu@awe.co.uk" style="color: rgb(5, 99, 193); text-decoration: underline;"><span>wei.liu@awe.co.uk</span></a><span style="color: rgb(0, 116, 123);"><o:p></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(118, 134, 147);">AWE Aldermaston,<o:p></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><span style="color: rgb(118, 134, 147);">Reading, Berkshire, RG7 4PR<o:p></o:p></span></div><div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;"><o:p> </o:p></div></div><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">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)</span><a href="http://awe.co.uk/" style="color: rgb(5, 99, 193); text-decoration: underline; font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">awe.co.uk</a><span style="caret-color: rgb(0, 0, 0); font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">, 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</span></div></blockquote></div><br></div></div></div></body></html>