# Optimization in gfortran vs pgf95

**URL:** <https://fortran-lang.discourse.group/t/optimization-in-gfortran-vs-pgf95/6687>\
**Category:** Help\
**Created:** [October 24, 2023, 4:27pm UTC](https://fortran-lang.discourse.group/t/optimization-in-gfortran-vs-pgf95/6687 "2023-10-24T16:27:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![astropig](https://avatars.discourse-cdn.com/v4/letter/a/a9adbd/32.png) [@astropig](https://fortran-lang.discourse.group/u/astropig)\
**Post date:** [October 24, 2023, 4:27pm UTC](https://fortran-lang.discourse.group/t/optimization-in-gfortran-vs-pgf95/6687/1 "2023-10-24T16:27:56Z")

</div>

I’m running some stellar atmosphere code on a Mac. When the code is compiled with the pgf95 compiler using the flags -mp -Mlarge\_arrays -O2 -fast -Mconcur  
it takes about 3 hours to run.

When I compile the same code using gfortran and the switches  
-O2 -fopenmp -m64  
it takes about 5 hours to run.

In both cases I’m running nominally on 4 cores, although the gfortran compilation may not  
be fully utilizing them based on what I see using “top”.

I’d appreciate any suggestions. The “-fast” in pgf95 seems to do a lot of good things, but I can’t seem to identify anything analogous in gfortran. Thanks for any advice.

---

<div class="post-metadata">

**Author:** ![rbitr](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rbitr](https://fortran-lang.discourse.group/u/rbitr)\
**Post date:** [October 24, 2023, 4:44pm UTC](https://fortran-lang.discourse.group/t/optimization-in-gfortran-vs-pgf95/6687/2 "2023-10-24T16:44:41Z")

</div>

gfortran has an -ofast option:

Disregard strict standards compliance. -Ofast enables all -O3 optimizations. It also enables optimizations that are not valid for all standard-compliant programs. It turns on -ffast-math, -fallow-store-data-races and the Fortran-specific -fstack-arrays, unless -fmax-stack-var-size is specified, and -fno-protect-parens. It turns off -fsemantic-interposition.

> **[Optimize Options (Using the GNU Compiler Collection (GCC))](https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html)**
>
> Optimize Options (Using the GNU Compiler Collection (GCC))

Edit: looks like they are different though and -fast in pgf95 may be about enabling simd vectorisation? Which I think would be -march=native in gfortran

> **[Reference Manual :: PGI
         version
         19.1
         Documentation...](https://docs.nvidia.com/hpc-sdk/pgi-compilers/19.1/x86/pgi-ref-guide/index.htm#fast)**
>
> Reference manual for using the PGI Compiler.
