Compiler Optimization Override

Satish Balay balay at mcs.anl.gov
Wed Jun 27 08:21:46 CDT 2007


On Wed, 27 Jun 2007, Tim Stitt wrote:

> Hi PETSc Users/Developers,
> 
> Could someone explain how I can override the default optimization level that 
> comes with my PETSc build (currently -O). I want to set a more aggressive 
> optimization level (e.g. -O3) for my compiler (PathScale).

Rebuild a different variant of the libraires [with a different
PETSC_ARCH] using COPTFLAGS=-O3 FOPTFLAGS=-O3

> Ideally I would prefer a solution which doesn't involve rebuilding PETSc each 
> time I want to switch the optimization level.

You just build both versions once, and switch between them by switching PETSC_ARCH

make PETSC_ARCH=opt mybinary 
make PETSC_ARCH=opt-3 mybinary

> I tried to add the switch to the petscrules file but it always
> defaulted to the first (lower?)  optimization switch that appeared
> in the application compile command line which seems to be built into
> PETSc.

If you are chaning config files manually, then you'll have to change
all occurances of -O in petscconf file [not petscrules]. Also - if
you've used --download-mpich, then mpicc etc wrappers would need
this modification aswell.

So its best to build different variants of PETSc libraries with
different PETSC_ARCH values.

Satish




More information about the petsc-users mailing list