[lammps-users] lammps compilation options

Hi all,

I see that the default compile options in the lammps makefiles provided for different architectures use the -g and -O flags. Since I do not know the intricacies of the source code itself, I wonder if removing the debugging flag '-g' and increasing the compiler optimization e.g., '-O3' will make lammps run faster. Can the developers comment on whether such a change will maintain the stability of the lammps build?

Thanks
Shreevant

Hi all,

I see that the default compile options in the lammps makefiles provided for different architectures use the -g and -O flags. Since I do not know the intricacies of the source code itself, I wonder if removing the debugging flag '-g' and increasing the compiler optimization e.g., '-O3' will make lammps run faster. Can the developers comment on whether such a change will maintain the stability of the lammps build?

keeping the -g flag should not make a difference to
optimization with current compilers.

the impact of compiler optimization is often overestimated.
particularly very high optimization levels can do more damage
than good. the biggest change if usually between using no
optimization and "standard" optimization. most of the optimizations
could also be achieved by changing the source code, but
that would make the code near unreadable. so "standard" optimization
techniques, that compilers are quite good at, are left to the
compiler. the situation becomes even more complicated
by modern super-scalar CPUs, where a good deal of
optimization is essentially also done in the CPU itself
and that part usually works better with "simpler" code.

however, it is easy to do some benchmarks and find out
the impact. going from "normal" to "maximum" optimization
will usually not gain much, if at all.

on top of those considerations, you have to consider, that
execution speed is also impacted by a number of settings
of parameters in the MD algorithm itself that are often more
important than compiler optimizations.

if you are using a recent gcc, the most aggressive settings
that i found to be effective for lammps and work reliably are:

-O3 -march=native -mpc64 -fno-exceptions -fno-rtti -ffast-math \
   -funroll-loops -fstrict-aliasing

they are incompatible with the atc package as that uses exceptions.

axel