diff --git a/src/force.cpp b/src/force.cpp index 2691cb3fd8..ed27df1215 100644 --- a/src/force.cpp +++ b/src/force.cpp @@ -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(); diff --git a/src/force.h b/src/force.h index 2b4298d049..227b9427c0 100644 --- a/src/force.h +++ b/src/force.h @@ -143,6 +143,7 @@ class Force : protected Pointers { bigint memory_usage(); private: + void create_factories(); template static Pair *pair_creator(LAMMPS *); template static Bond *bond_creator(LAMMPS *); template static Angle *angle_creator(LAMMPS *); diff --git a/src/lammps.cpp b/src/lammps.cpp index 780327c0d9..f8d04c9323 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -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" @@ -1002,7 +996,7 @@ void LAMMPS::init_pkg_lists() #include "packages_region.h" #undef RegionStyle #undef REGION_CLASS -} +} bool LAMMPS::is_installed_pkg(const char *pkg) { @@ -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; diff --git a/src/lmptype.h b/src/lmptype.h index 4743a38837..20d29880ed 100644 --- a/src/lmptype.h +++ b/src/lmptype.h @@ -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 diff --git a/src/modify.cpp b/src/modify.cpp index 69cdb424b2..3f034bf034 100644 --- a/src/modify.cpp +++ b/src/modify.cpp @@ -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(); diff --git a/src/modify.h b/src/modify.h index 537ff81543..5ff81855fe 100644 --- a/src/modify.h +++ b/src/modify.h @@ -172,6 +172,7 @@ class Modify : protected Pointers { FixCreatorMap *fix_map; protected: + void create_factories(); template static Compute *compute_creator(LAMMPS *, int, char **); template static Fix *fix_creator(LAMMPS *, int, char **); };