Commit b9d0f96a authored by Steve Plimpton's avatar Steve Plimpton
Browse files

change purge target in Makefile, also fixed one issue with Make.py

parent f7b5afee
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
Run this example as:

mpirun -np 3 lmp_linux -partition 3x1 -in in.tad
mpirun -np 3 lmp_g++ -partition 3x1 -in in.tad

You should be able to use any number of replicas >= 3.
+266 −0
Original line number Diff line number Diff line
/* ----------------------------------------------------------------------
   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
   http://lammps.sandia.gov, Sandia National Laboratories
   Steve Plimpton, sjplimp@sandia.gov

   Copyright (2003) Sandia Corporation.  Under the terms of Contract
   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
   certain rights in this software.  This software is distributed under
   the GNU General Public License.

   See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */

#include <string.h>
#include "comm_tiled_kokkos.h"
#include "comm_brick.h"
#include "atom_kokkos.h"
#include "atom_vec.h"
#include "domain.h"
#include "force.h"
#include "pair.h"
#include "neighbor.h"
#include "modify.h"
#include "fix.h"
#include "compute.h"
#include "output.h"
#include "dump.h"
#include "memory.h"
#include "error.h"
#include "atom_masks.h"

using namespace LAMMPS_NS;

#define BUFFACTOR 1.5
#define BUFFACTOR 1.5
#define BUFMIN 1000
#define BUFEXTRA 1000
#define EPSILON 1.0e-6

#define DELTA_PROCS 16

enum{SINGLE,MULTI};               // same as in Comm
enum{LAYOUT_UNIFORM,LAYOUT_NONUNIFORM,LAYOUT_TILED};    // several files

/* ---------------------------------------------------------------------- */

CommTiledKokkos::CommTiledKokkos(LAMMPS *lmp) : CommTiled(lmp)
{

}

/* ---------------------------------------------------------------------- */
//IMPORTANT: we *MUST* pass "*oldcomm" to the Comm initializer here, as
//           the code below *requires* that the (implicit) copy constructor
//           for Comm is run and thus creating a shallow copy of "oldcomm".
//           The call to Comm::copy_arrays() then converts the shallow copy
//           into a deep copy of the class with the new layout.

CommTiledKokkos::CommTiledKokkos(LAMMPS *lmp, Comm *oldcomm) : CommTiled(lmp,oldcomm)
{

}

/* ---------------------------------------------------------------------- */

CommTiledKokkos::~CommTiledKokkos()
{

}

/* ---------------------------------------------------------------------- */


/* ----------------------------------------------------------------------
   forward communication of atom coords every timestep
   other per-atom attributes may also be sent via pack/unpack routines
------------------------------------------------------------------------- */

void CommTiledKokkos::forward_comm(int dummy)
{
  if (comm_x_only) {
    atomKK->sync(Host,X_MASK);
    atomKK->modified(Host,X_MASK);
  } else if (ghost_velocity) {
    atomKK->sync(Host,X_MASK | V_MASK);
    atomKK->modified(Host,X_MASK | V_MASK);
  } else {
    atomKK->sync(Host,ALL_MASK);
    atomKK->modified(Host,ALL_MASK);
  }

  CommTiled::forward_comm(dummy);
}

/* ----------------------------------------------------------------------
   reverse communication of forces on atoms every timestep
   other per-atom attributes may also be sent via pack/unpack routines
------------------------------------------------------------------------- */

void CommTiledKokkos::reverse_comm()
{
  if (comm_f_only)
    atomKK->sync(Host,F_MASK);
  else
    atomKK->sync(Host,ALL_MASK);
  CommTiled::reverse_comm();
  if (comm_f_only)
    atomKK->modified(Host,F_MASK);
  else
    atomKK->modified(Host,ALL_MASK);
  atomKK->sync(Device,ALL_MASK);
}

/* ----------------------------------------------------------------------
   exchange: move atoms to correct processors
   atoms exchanged with procs that touch sub-box in each of 3 dims
   send out atoms that have left my box, receive ones entering my box
   atoms will be lost if not inside a touching proc's box
     can happen if atom moves outside of non-periodic bounary
     or if atom moves more than one proc away
   this routine called before every reneighboring
   for triclinic, atoms must be in lamda coords (0-1) before exchange is called
------------------------------------------------------------------------- */

void CommTiledKokkos::exchange()
{
  atomKK->sync(Host,ALL_MASK);
  CommTiled::exchange();
  atomKK->modified(Host,ALL_MASK);
}

/* ----------------------------------------------------------------------
   borders: list nearby atoms to send to neighboring procs at every timestep
   one list is created per swap/proc that will be made
   as list is made, actually do communication
   this does equivalent of a forward_comm(), so don't need to explicitly
     call forward_comm() on reneighboring timestep
   this routine is called before every reneighboring
   for triclinic, atoms must be in lamda coords (0-1) before borders is called
------------------------------------------------------------------------- */

void CommTiledKokkos::borders()
{
  atomKK->sync(Host,ALL_MASK);
  CommTiled::borders();
  atomKK->modified(Host,ALL_MASK);
}

/* ----------------------------------------------------------------------
   forward communication invoked by a Pair
   nsize used only to set recv buffer limit
------------------------------------------------------------------------- */

void CommTiledKokkos::forward_comm_pair(Pair *pair)
{
  CommTiled::forward_comm_pair(pair);
}

/* ----------------------------------------------------------------------
   reverse communication invoked by a Pair
   nsize used only to set recv buffer limit
------------------------------------------------------------------------- */

void CommTiledKokkos::reverse_comm_pair(Pair *pair)
{
  CommTiled::reverse_comm_pair(pair);
}

/* ----------------------------------------------------------------------
   forward communication invoked by a Fix
   size/nsize used only to set recv buffer limit
   size = 0 (default) -> use comm_forward from Fix
   size > 0 -> Fix passes max size per atom
   the latter is only useful if Fix does several comm modes,
     some are smaller than max stored in its comm_forward
------------------------------------------------------------------------- */

void CommTiledKokkos::forward_comm_fix(Fix *fix, int size)
{
  CommTiled::forward_comm_fix(fix,size);
}

/* ----------------------------------------------------------------------
   reverse communication invoked by a Fix
   size/nsize used only to set recv buffer limit
   size = 0 (default) -> use comm_forward from Fix
   size > 0 -> Fix passes max size per atom
   the latter is only useful if Fix does several comm modes,
     some are smaller than max stored in its comm_forward
------------------------------------------------------------------------- */

void CommTiledKokkos::reverse_comm_fix(Fix *fix, int size)
{
  CommTiled::reverse_comm_fix(fix,size);
}

/* ----------------------------------------------------------------------
   reverse communication invoked by a Fix with variable size data
   query fix for all pack sizes to insure buf_send is big enough
   handshake sizes before irregular comm to insure buf_recv is big enough
   NOTE: how to setup one big buf recv with correct offsets ??
------------------------------------------------------------------------- */

void CommTiledKokkos::reverse_comm_fix_variable(Fix *fix)
{
  CommTiled::reverse_comm_fix_variable(fix);
}

/* ----------------------------------------------------------------------
   forward communication invoked by a Compute
   nsize used only to set recv buffer limit
------------------------------------------------------------------------- */

void CommTiledKokkos::forward_comm_compute(Compute *compute)
{
  CommTiled::forward_comm_compute(compute);
}

/* ----------------------------------------------------------------------
   reverse communication invoked by a Compute
   nsize used only to set recv buffer limit
------------------------------------------------------------------------- */

void CommTiledKokkos::reverse_comm_compute(Compute *compute)
{
  CommTiled::reverse_comm_compute(compute);
}

/* ----------------------------------------------------------------------
   forward communication invoked by a Dump
   nsize used only to set recv buffer limit
------------------------------------------------------------------------- */

void CommTiledKokkos::forward_comm_dump(Dump *dump)
{
  CommTiled::forward_comm_dump(dump);
}

/* ----------------------------------------------------------------------
   reverse communication invoked by a Dump
   nsize used only to set recv buffer limit
------------------------------------------------------------------------- */

void CommTiledKokkos::reverse_comm_dump(Dump *dump)
{
  CommTiled::reverse_comm_dump(dump);
}

/* ----------------------------------------------------------------------
   forward communication of Nsize values in per-atom array
------------------------------------------------------------------------- */

void CommTiledKokkos::forward_comm_array(int nsize, double **array)
{
  CommTiled::forward_comm_array(nsize,array);
}

/* ----------------------------------------------------------------------
   exchange info provided with all 6 stencil neighbors
   NOTE: this method is currently not used
------------------------------------------------------------------------- */

int CommTiledKokkos::exchange_variable(int n, double *inbuf, double *&outbuf)
{
  CommTiled::exchange_variable(n,inbuf,outbuf);
}
 No newline at end of file
+59 −0
Original line number Diff line number Diff line
/* -*- c++ -*- ----------------------------------------------------------
   LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
   http://lammps.sandia.gov, Sandia National Laboratories
   Steve Plimpton, sjplimp@sandia.gov

   Copyright (2003) Sandia Corporation.  Under the terms of Contract
   DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
   certain rights in this software.  This software is distributed under
   the GNU General Public License.

   See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */

#ifndef LMP_COMM_TILED_KOKKOS_H
#define LMP_COMM_TILED_KOKKOS_H

#include "comm_tiled.h"
#include "kokkos_type.h"

namespace LAMMPS_NS {

class CommTiledKokkos : public CommTiled {
 public:
  CommTiledKokkos(class LAMMPS *);
  CommTiledKokkos(class LAMMPS *, class Comm *);
  virtual ~CommTiledKokkos();

  void forward_comm(int dummy = 0);    // forward comm of atom coords
  void reverse_comm();                 // reverse comm of forces
  void exchange();                     // move atoms to new procs
  void borders();                      // setup list of atoms to comm

  void forward_comm_pair(class Pair *);    // forward comm from a Pair
  void reverse_comm_pair(class Pair *);    // reverse comm from a Pair
  void forward_comm_fix(class Fix *, int size=0);
                                                   // forward comm from a Fix
  void reverse_comm_fix(class Fix *, int size=0);
                                                   // reverse comm from a Fix
  void reverse_comm_fix_variable(class Fix *);
                                     // variable size reverse comm from a Fix
  void forward_comm_compute(class Compute *);  // forward from a Compute
  void reverse_comm_compute(class Compute *);  // reverse from a Compute
  void forward_comm_dump(class Dump *);    // forward comm from a Dump
  void reverse_comm_dump(class Dump *);    // reverse comm from a Dump

  void forward_comm_array(int, double **);          // forward comm of array
  int exchange_variable(int, double *, double *&);  // exchange on neigh stencil

 private:

};

}

#endif

/* ERROR/WARNING messages:

*/
+10 −6
Original line number Diff line number Diff line
@@ -280,15 +280,19 @@ void NeighborKokkos::choose_build(int index, NeighRequest *rq)
  if (rq->kokkos_host != 0) {
    PairPtrHost pb = NULL;
    if (rq->ghost) {
      if (rq->full) pb = &NeighborKokkos::full_bin_kokkos<LMPHostType,0,1>;
      else if (rq->half) &NeighborKokkos::full_bin_kokkos<LMPHostType,1,1>;
      pair_build_host[index] = pb;
      if (rq->full) {
        if (rq->full_cluster) pb = &NeighborKokkos::full_bin_cluster_kokkos<LMPHostType>;
        else pb = &NeighborKokkos::full_bin_kokkos<LMPHostType,0,1>;
      }
      else if (rq->half) pb = &NeighborKokkos::full_bin_kokkos<LMPHostType,1,1>;
    } else {
      if (rq->full) pb = &NeighborKokkos::full_bin_kokkos<LMPHostType,0,0>;
      if (rq->full) {
        if (rq->full_cluster) pb = &NeighborKokkos::full_bin_cluster_kokkos<LMPHostType>;
        else pb = &NeighborKokkos::full_bin_kokkos<LMPHostType,0,0>;
      }
      else if (rq->half) pb = &NeighborKokkos::full_bin_kokkos<LMPHostType,1,0>;
      pair_build_host[index] = pb;
    }
    return;
    pair_build_host[index] = pb;
  }
  if (rq->kokkos_device != 0) {
    PairPtrDevice pb = NULL;
+47 −23
Original line number Diff line number Diff line
@@ -26,7 +26,8 @@ libclasses = ("atc","awpmd","colvars","cuda","gpu","h5md",
buildclasses = ("intel","kokkos")
makeclasses = ("cc","flags","mpi","fft","jpg","png")

setargs = ("gzip","#gzip","ffmpeg","#ffmpeg","smallbig","bigbig","smallsmall","exceptions","#exceptions")
setargs = ("gzip","#gzip","ffmpeg","#ffmpeg","smallbig","bigbig",
           "smallsmall","exceptions","#exceptions")
actionargs = ("lib-all","file","clean","exe")

gpubuildflag = 0
@@ -85,7 +86,8 @@ def switch2str(switches,switch_order):
def compile_check(compiler,ccflags,warn):
  open("tmpauto.cpp",'w').write("int main(int, char **) {}\n")
  tmp = "%s %s -c tmpauto.cpp" % (compiler,ccflags)
  try: txt = subprocess.check_output(tmp,stderr=subprocess.STDOUT,shell=True).decode()
  try: txt = subprocess.check_output(tmp,stderr=subprocess.STDOUT,
                                     shell=True).decode()
  except subprocess.CalledProcessError as e: txt = e.output
  flag = 1
  if txt or not os.path.isfile("tmpauto.o"):
@@ -105,7 +107,8 @@ def compile_check(compiler,ccflags,warn):
def link_check(linker,linkflags,libs,warn):
  open("tmpauto.cpp",'w').write("int main(int, char **) {}\n")
  tmp = "%s %s -o tmpauto tmpauto.cpp %s" % (linker,linkflags,libs)
  try: txt = subprocess.check_output(tmp,stderr=subprocess.STDOUT,shell=True).decode()
  try: txt = subprocess.check_output(tmp,stderr=subprocess.STDOUT,
                                     shell=True).decode()
  except subprocess.CalledProcessError as e: txt = e.output
  flag = 1
  if txt or not os.path.isfile("tmpauto"):
@@ -532,7 +535,8 @@ class Actions(object):
    
    if caller == "file" or "file" not in self.alist:
      # make certain that 'MAKE/MINE' folder exists.
      subprocess.check_output("mkdir -p %s/MAKE/MINE" % dir.src,stderr=subprocess.STDOUT,shell=True)
      subprocess.check_output("mkdir -p %s/MAKE/MINE" % dir.src,
                              stderr=subprocess.STDOUT,shell=True)
      make.write("%s/MAKE/MINE/Makefile.auto" % dir.src,1)
      print("Created src/MAKE/MINE/Makefile.auto")
      
@@ -859,9 +863,12 @@ class Packages(object):
    if self.plist: print("Installing packages ...")
    for one in self.plist:
      if one == "orig": continue
      subprocess.check_output("cd %s; make %s" % (dir.src,one),stderr=subprocess.STDOUT,shell=True)
      subprocess.check_output("cd %s; make %s" % (dir.src,one),
                              stderr=subprocess.STDOUT,shell=True)
    if self.plist and verbose:
      txt = subprocess.check_output("cd %s; make ps" % dir.src,stderr=subprocess.STDOUT,shell=True).decode()
      txt = subprocess.check_output("cd %s; make ps" % dir.src,
                                    stderr=subprocess.STDOUT,
                                    shell=True).decode()
      print("Package status after installation:")
      print(txt)
      
@@ -871,12 +878,16 @@ class Packages(object):
  def uninstall(self):
    if not self.plist or self.plist[-1] != "orig": return
    print("Restoring packages to original state ...")
    subprocess.check_output("cd %s; make no-all" % dir.src,stderr=subprocess.STDOUT,shell=True)
    subprocess.check_output("cd %s; make no-all" % dir.src,
                            stderr=subprocess.STDOUT,shell=True)
    for one in self.all:
      if self.original[one]:
        subprocess.check_output("cd %s; make yes-%s" % (dir.src,one),stderr=subprocess.STDOUT,shell=True)
        subprocess.check_output("cd %s; make yes-%s" % (dir.src,one),
                                stderr=subprocess.STDOUT,shell=True)
    if verbose:
      txt = subprocess.check_output("cd %s; make ps" % dir.src,stderr=subprocess.STDOUT,shell=True).decode()
      txt = subprocess.check_output("cd %s; make ps" % dir.src,
                                    stderr=subprocess.STDOUT,
                                    shell=True).decode()
      print("Restored package status:")
      print(txt)
      
@@ -970,7 +981,8 @@ class Settings(object):
  def help(self):
    return """
-s set1 set2 ...
  possible settings = gzip #gzip ffmpeg #ffmpeg smallbig bigbig smallsmall exceptions #exceptions
  possible settings = gzip #gzip ffmpeg #ffmpeg
                      smallbig bigbig smallsmall exceptions #exceptions
  alter LAMMPS ifdef settings in Makefile.auto
    only happens if new Makefile.auto is created by use of "file" action
  gzip and #gzip turn on/off LAMMPS_GZIP setting
@@ -1059,7 +1071,8 @@ class ATC(object):
      make.setvar("EXTRAMAKE","Makefile.lammps.%s" % self.lammps)
    make.write("%s/Makefile.auto" % libdir)
    
    subprocess.check_output("cd %s; make -f Makefile.auto clean" % libdir,stderr=subprocess.STDOUT,shell=True)
    subprocess.check_output("cd %s; make -f Makefile.auto clean" %
                            libdir,stderr=subprocess.STDOUT,shell=True)
    if jmake: txt = "cd %s; make -j %d -f Makefile.auto" % (libdir,jmake.n)
    else: txt = "cd %s; make -f Makefile.auto" % libdir
    
@@ -1110,7 +1123,8 @@ class AWPMD(object):
      make.setvar("EXTRAMAKE","Makefile.lammps.%s" % self.lammps)
    make.write("%s/Makefile.auto" % libdir)

    subprocess.check_output("cd %s; make -f Makefile.auto clean" % libdir,stderr=subprocess.STDOUT,shell=True)
    subprocess.check_output("cd %s; make -f Makefile.auto clean" %
                            libdir,stderr=subprocess.STDOUT,shell=True)
    if jmake: txt = "cd %s; make -j %d -f Makefile.auto" % (libdir,jmake.n)
    else: txt = "cd %s; make -f Makefile.auto" % libdir

@@ -1161,7 +1175,8 @@ class COLVARS(object):
      make.setvar("EXTRAMAKE","Makefile.lammps.%s" % self.lammps)
    make.write("%s/Makefile.auto" % libdir)

    subprocess.check_output("cd %s; make -f Makefile.auto clean" % libdir,stderr=subprocess.STDOUT,shell=True)
    subprocess.check_output("cd %s; make -f Makefile.auto clean" %
                            libdir,stderr=subprocess.STDOUT,shell=True)
    if jmake: txt = "cd %s; make -j %d -f Makefile.auto" % (libdir,jmake.n)
    else: txt = "cd %s; make -f Makefile.auto" % libdir

@@ -1213,7 +1228,8 @@ class CUDA(object):
          
  def build(self): 
    libdir = dir.lib + "/cuda"
    subprocess.check_output("cd %s; make clean" % libdir,stderr=subprocess.STDOUT,shell=True)
    subprocess.check_output("cd %s; make clean" % libdir,
                            stderr=subprocess.STDOUT,shell=True)
    if self.mode == "double": n = 2
    elif self.mode == "mixed": n = 3
    elif self.mode == "single": n = 1
@@ -1308,7 +1324,8 @@ class GPU(object):
    make = "make"
    if "shannon" == platform.node(): make = "srun make"

    subprocess.check_output("cd %s; %s -f Makefile.auto clean" % (libdir,make),stderr=subprocess.STDOUT,shell=True)
    subprocess.check_output("cd %s; %s -f Makefile.auto clean" %
                            (libdir,make),stderr=subprocess.STDOUT,shell=True)
    if jmake: txt = "cd %s; %s -j %d -f Makefile.auto" % (libdir,make,jmake.n)
    else: txt = "cd %s; %s -f Makefile.auto" % (libdir,make)

@@ -1359,7 +1376,8 @@ class H5MD(object):
      make.setvar("EXTRAMAKE","Makefile.lammps.%s" % self.lammps)
    make.write("%s/Makefile.auto" % libdir)

    subprocess.check_output("cd %s; make clean" % libdir,stderr=subprocess.STDOUT,shell=True)
    subprocess.check_output("cd %s; make clean" % libdir,
                            stderr=subprocess.STDOUT,shell=True)
    txt = "cd %s; make" % libdir

    # if verbose, print output as build proceeds, else only print if fails
@@ -1409,7 +1427,8 @@ class MEAM(object):
      make.setvar("EXTRAMAKE","Makefile.lammps.%s" % self.lammps)
    make.write("%s/Makefile.auto" % libdir)

    subprocess.check_output("cd %s; make -f Makefile.auto clean" % libdir,stderr=subprocess.STDOUT,shell=True)
    subprocess.check_output("cd %s; make -f Makefile.auto clean" %
                            libdir,stderr=subprocess.STDOUT,shell=True)
    # do not use -j for MEAM build, parallel build does not work
    txt = "cd %s; make -f Makefile.auto" % libdir

@@ -1460,7 +1479,8 @@ class POEMS(object):
      make.setvar("EXTRAMAKE","Makefile.lammps.%s" % self.lammps)
    make.write("%s/Makefile.auto" % libdir)

    subprocess.check_output("cd %s; make -f Makefile.auto clean" % libdir,stderr=subprocess.STDOUT,shell=True)
    subprocess.check_output("cd %s; make -f Makefile.auto clean" % libdir,
                            stderr=subprocess.STDOUT,shell=True)
    if jmake: txt = "cd %s; make -j %d -f Makefile.auto" % (libdir,jmake.n)
    else: txt = "cd %s; make -f Makefile.auto" % libdir

@@ -1508,7 +1528,8 @@ class PYTHON(object):
      subprocess.check_output("cd %s; cp Makefile.lammps.%s Makefile.lammps" %
                              (libdir,self.lammps))
    if not os.path.isfile("%s/Makefile.lammps.%s" % (libdir,self.lammps)):
      error("Unsuccessful creation of lib/python/Makefile.lammps.%s file" % self.lammps)
      error("Unsuccessful creation of lib/python/Makefile.lammps.%s file" %
            self.lammps)
    else: print("Created lib/python/Makefile.lammps file")

# QMMM lib
@@ -1546,7 +1567,8 @@ class QMMM(object):
      make.setvar("EXTRAMAKE","Makefile.lammps.%s" % self.lammps)
    make.write("%s/Makefile.auto" % libdir)

    subprocess.check_output("cd %s; make -f Makefile.auto clean" % libdir,stderr=subprocess.STDOUT,shell=True)
    subprocess.check_output("cd %s; make -f Makefile.auto clean" %
                            libdir,stderr=subprocess.STDOUT,shell=True)
    if jmake: txt = "cd %s; make -j %d -f Makefile.auto" % (libdir,jmake.n)
    else: txt = "cd %s; make -f Makefile.auto" % libdir

@@ -1597,7 +1619,8 @@ class REAX(object):
      make.setvar("EXTRAMAKE","Makefile.lammps.%s" % self.lammps)
    make.write("%s/Makefile.auto" % libdir)

    commands.getoutput("cd %s; make -f Makefile.auto clean" % libdir)
    cmd = "cd %s; make -f Makefile.auto clean" % libdir
    subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
    if jmake: txt = "cd %s; make -j %d -f Makefile.auto" % (libdir,jmake.n)
    else: txt = "cd %s; make -f Makefile.auto" % libdir
    
@@ -1643,7 +1666,8 @@ class VORONOI(object):
    if not self.install: return
    libdir = dir.lib + "/voronoi"
    cmd = "cd %s; python install.py %s" % (libdir,self.install)
    txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True).decode()
    txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,
                                  shell=True).decode()
    if verbose: print(txt)
    print("Created lib/voronoi library")

Loading