From fa6ad89b99abcf2f4b92a4da7a5ee52d90ad5142 Mon Sep 17 00:00:00 2001 From: sjplimp <sjplimp@f3b2605a-c512-4ea7-a41b-209d697bcdaa> Date: Mon, 5 Oct 2015 15:20:06 +0000 Subject: [PATCH] git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14091 f3b2605a-c512-4ea7-a41b-209d697bcdaa --- src/USER-INTEL/README | 9 +++++---- src/input.cpp | 28 ++++++++++++++++------------ src/lammps.cpp | 38 ++++++++++++++++++++------------------ 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/src/USER-INTEL/README b/src/USER-INTEL/README index 929bd00871..3465101074 100644 --- a/src/USER-INTEL/README +++ b/src/USER-INTEL/README @@ -21,11 +21,12 @@ This package is based on the USER-OMP package and provides LAMMPS styles that: ----------------------------------------------------------------------------- When using the suffix command with "intel", intel styles will be used if they -exist; if they do not, and the USER-OMP package is installed and an omp version -exists, that style will be used. For example, in the case the USER-OMP package -is installed, +exist. If the suffix command is used with "hybrid intel omp" and the USER-OMP +USER-OMP styles will be used whenever USER-INTEL styles are not available. This +allow for running most styles in LAMMPS with threading. For example, in the +latter case with the USER-OMP package installed, - kspace_style pppm/intel 1e-4 + kspace_style pppm 1e-4 is equivalent to: diff --git a/src/input.cpp b/src/input.cpp index 12e30e47f9..b820607261 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -1699,7 +1699,7 @@ void Input::special_bonds() void Input::suffix() { - if (narg != 1) error->all(FLERR,"Illegal suffix command"); + if (narg < 1) error->all(FLERR,"Illegal suffix command"); if (strcmp(arg[0],"off") == 0) lmp->suffix_enable = 0; else if (strcmp(arg[0],"on") == 0) lmp->suffix_enable = 1; @@ -1707,17 +1707,21 @@ void Input::suffix() lmp->suffix_enable = 1; delete [] lmp->suffix; - int n = strlen(arg[0]) + 1; - lmp->suffix = new char[n]; - strcpy(lmp->suffix,arg[0]); - - // set 2nd suffix = "omp" when suffix = "intel" - // but only if USER-OMP package is installed - - if (strcmp(lmp->suffix,"intel") == 0 && modify->check_package("OMP")) { - delete [] lmp->suffix2; - lmp->suffix2 = new char[4]; - strcpy(lmp->suffix2,"omp"); + delete [] lmp->suffix2; + + if (strcmp(arg[0],"hybrid") == 0) { + if (narg != 3) error->all(FLERR,"Illegal suffix command"); + int n = strlen(arg[1]) + 1; + lmp->suffix = new char[n]; + strcpy(lmp->suffix,arg[1]); + n = strlen(arg[2]) + 1; + lmp->suffix2 = new char[n]; + strcpy(lmp->suffix2,arg[2]); + } else { + if (narg != 1) error->all(FLERR,"Illegal suffix command"); + int n = strlen(arg[0]) + 1; + lmp->suffix = new char[n]; + strcpy(lmp->suffix,arg[0]); } } } diff --git a/src/lammps.cpp b/src/lammps.cpp index d6f46cc329..49e1311757 100644 --- a/src/lammps.cpp +++ b/src/lammps.cpp @@ -192,16 +192,25 @@ LAMMPS::LAMMPS(int narg, char **arg, MPI_Comm communicator) if (iarg+2 > narg) error->universe_all(FLERR,"Invalid command-line argument"); delete [] suffix; - int n = strlen(arg[iarg+1]) + 1; - suffix = new char[n]; - strcpy(suffix,arg[iarg+1]); - // set 2nd suffix = "omp" when suffix = "intel" - if (strcmp(suffix,"intel") == 0) { - suffix2 = new char[4]; - strcpy(suffix2,"omp"); - } + delete [] suffix2; suffix_enable = 1; - iarg += 2; + // hybrid option to set fall-back for suffix2 + if (strcmp(arg[iarg+1],"hybrid") == 0) { + if (iarg+4 > narg) + error->universe_all(FLERR,"Invalid command-line argument"); + int n = strlen(arg[iarg+2]) + 1; + suffix = new char[n]; + strcpy(suffix,arg[iarg+2]); + n = strlen(arg[iarg+3]) + 1; + suffix2 = new char[n]; + strcpy(suffix2,arg[iarg+3]); + iarg += 4; + } else { + int n = strlen(arg[iarg+1]) + 1; + suffix = new char[n]; + strcpy(suffix,arg[iarg+1]); + iarg += 2; + } } else if (strcmp(arg[iarg],"-reorder") == 0 || strcmp(arg[iarg],"-ro") == 0) { if (iarg+3 > narg) @@ -634,7 +643,6 @@ void LAMMPS::create() /* ---------------------------------------------------------------------- check suffix consistency with installed packages - turn off suffix2 = omp if USER-OMP is not installed invoke package-specific deafult package commands only invoke if suffix is set and enabled also check if suffix2 is set @@ -667,19 +675,13 @@ void LAMMPS::post_create(int npack, int *pfirst, int *plast, char **arg) if (strcmp(suffix,"omp") == 0 && !modify->check_package("OMP")) error->all(FLERR,"Using suffix omp without USER-OMP package installed"); - // suffix2 only currently set by -sf intel - // unset if LAMMPS was not built with USER-OMP package - - if (suffix2 && strcmp(suffix2,"omp") == 0 && !modify->check_package("OMP")) { - delete [] suffix2; - suffix2 = NULL; - } - if (strcmp(suffix,"gpu") == 0) input->one("package gpu 1"); if (strcmp(suffix,"intel") == 0) input->one("package intel 1"); if (strcmp(suffix,"omp") == 0) input->one("package omp 0"); if (suffix2) { + if (strcmp(suffix2,"gpu") == 0) input->one("package gpu 1"); + if (strcmp(suffix2,"intel") == 0) input->one("package intel 1"); if (strcmp(suffix2,"omp") == 0) input->one("package omp 0"); } -- GitLab