disable optimization on functions building factories for many entries

this will speed up compilation and also avoid spurious warnings with gcc 4.4 and later
This commit is contained in:
Axel Kohlmeyer
2019-06-06 20:37:17 -04:00
parent 56e3b1d1f4
commit b53df3dd63
6 changed files with 34 additions and 9 deletions

View File

@ -80,7 +80,11 @@ Force::Force(LAMMPS *lmp) : Pointers(lmp)
strcpy(kspace_style,str);
pair_restart = NULL;
create_factories();
}
void _noopt Force::create_factories()
{
// fill pair map with pair styles listed in style_pair.h
pair_map = new PairCreatorMap();

View File

@ -143,6 +143,7 @@ class Force : protected Pointers {
bigint memory_usage();
private:
void create_factories();
template <typename T> static Pair *pair_creator(LAMMPS *);
template <typename T> static Bond *bond_creator(LAMMPS *);
template <typename T> static Angle *angle_creator(LAMMPS *);

View File

@ -53,12 +53,6 @@
#include "memory.h"
#include "error.h"
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))
#pragma GCC optimize ("no-var-tracking-assignments")
#endif
#endif
#include "lmpinstalledpkgs.h"
#include "lmpgitversion.h"
@ -902,7 +896,7 @@ void LAMMPS::destroy()
initialize lists of styles in packages
------------------------------------------------------------------------- */
void LAMMPS::init_pkg_lists()
void _noopt LAMMPS::init_pkg_lists()
{
pkg_lists = new package_styles_lists;
#define PACKAGE "UNKNOWN"
@ -1045,7 +1039,7 @@ const char *LAMMPS::match_style(const char *style, const char *name)
help message for command line options and styles present in executable
------------------------------------------------------------------------- */
void LAMMPS::help()
void _noopt LAMMPS::help()
{
FILE *fp = screen;
const char *pager = NULL;

View File

@ -179,6 +179,9 @@ typedef int bigint;
#ifdef _noalias
#undef _noalias
#endif
#ifdef _noopt
#undef _noopt
#endif
// define stack variable alignment
@ -200,6 +203,23 @@ typedef int bigint;
#define _noalias
#endif
// declaration to turn off optimization for specific functions
// and avoid compiler warnings about variable tracking
#if defined(__clang__)
# define _noopt __attribute__((optnone))
#elif defined(__INTEL_COMPILER)
# define _noopt
#elif defined(__GNUC__)
# if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4))
# define _noopt __attribute__((optimize("O0","no-var-tracking-assignments")))
# else
# define _noopt __attribute__((optimize("O0")))
# endif
#else
# define _noopt
#endif
// settings to enable LAMMPS to build under Windows
#ifdef _WIN32

View File

@ -81,6 +81,11 @@ Modify::Modify(LAMMPS *lmp) : Pointers(lmp)
ncompute = maxcompute = 0;
compute = NULL;
create_factories();
}
void _noopt Modify::create_factories()
{
// fill map with fixes listed in style_fix.h
fix_map = new FixCreatorMap();

View File

@ -172,6 +172,7 @@ class Modify : protected Pointers {
FixCreatorMap *fix_map;
protected:
void create_factories();
template <typename T> static Compute *compute_creator(LAMMPS *, int, char **);
template <typename T> static Fix *fix_creator(LAMMPS *, int, char **);
};