forked from lijiext/lammps
git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@14828 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
parent
3e4ce842ff
commit
32509da721
|
@ -613,7 +613,7 @@ Syntax: Make.py switch args ...
|
|||
-atc, -awpmd, -colvars, -cuda, -gpu, -h5md,
|
||||
-meam, -poems, -python, -qmmm, -reax, -voronoi
|
||||
switches for build and makefile options:
|
||||
-intel, -kokkos, -cc, -mpi, -fft, -jpg, -png
|
||||
-intel, -kokkos, -cc, -flags, -mpi, -fft, -jpg, -png
|
||||
"""
|
||||
|
||||
# jmake switch
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "fix_colvars.h"
|
||||
|
||||
#include "colvarmodule.h"
|
||||
#include "colvar.h"
|
||||
#include "colvarbias.h"
|
||||
#include "colvaratoms.h"
|
||||
#include "colvarproxy.h"
|
||||
#include "colvarproxy_lammps.h"
|
||||
|
@ -109,11 +111,20 @@ colvarproxy_lammps::colvarproxy_lammps(LAMMPS_NS::LAMMPS *lmp,
|
|||
if (restart_output_prefix_str.rfind(".*") != std::string::npos)
|
||||
restart_output_prefix_str.erase(restart_output_prefix_str.rfind(".*"),2);
|
||||
|
||||
#if defined(_OPENMP)
|
||||
if (smp_thread_id() == 0) {
|
||||
omp_init_lock(&smp_lock_state);
|
||||
}
|
||||
#endif
|
||||
|
||||
// initialize multi-replica support, if available
|
||||
if (replica_enabled()) {
|
||||
MPI_Comm_rank(inter_comm, &inter_me);
|
||||
MPI_Comm_size(inter_comm, &inter_num);
|
||||
}
|
||||
|
||||
if (cvm::debug())
|
||||
log("Done initializing the colvars proxy object.\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -320,6 +331,80 @@ int colvarproxy_lammps::backup_file(char const *filename)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined(_OPENMP)
|
||||
|
||||
|
||||
// SMP support
|
||||
|
||||
int colvarproxy_lammps::smp_enabled()
|
||||
{
|
||||
return COLVARS_OK;
|
||||
}
|
||||
|
||||
|
||||
int colvarproxy_lammps::smp_colvars_loop()
|
||||
{
|
||||
colvarmodule *cv = this->colvars;
|
||||
#pragma omp parallel for
|
||||
for (size_t i = 0; i < cv->colvars_smp.size(); i++) {
|
||||
if (cvm::debug()) {
|
||||
cvm::log("Calculating colvar \""+cv->colvars_smp[i]->name+"\" on thread "+cvm::to_str(smp_thread_id())+"\n");
|
||||
}
|
||||
cv->colvars_smp[i]->calc_cvcs(cv->colvars_smp_items[i], 1);
|
||||
}
|
||||
return cvm::get_error();
|
||||
}
|
||||
|
||||
|
||||
int colvarproxy_lammps::smp_biases_loop()
|
||||
{
|
||||
colvarmodule *cv = this->colvars;
|
||||
#pragma omp parallel for
|
||||
for (size_t i = 0; i < cv->biases.size(); i++) {
|
||||
if (cvm::debug()) {
|
||||
cvm::log("Calculating bias \""+cv->biases[i]->name+"\" on thread "+cvm::to_str(smp_thread_id())+"\n");
|
||||
}
|
||||
cv->biases[i]->update();
|
||||
}
|
||||
return cvm::get_error();
|
||||
}
|
||||
|
||||
|
||||
int colvarproxy_lammps::smp_thread_id()
|
||||
{
|
||||
return omp_get_thread_num();
|
||||
}
|
||||
|
||||
|
||||
int colvarproxy_lammps::smp_num_threads()
|
||||
{
|
||||
return omp_get_max_threads();
|
||||
}
|
||||
|
||||
|
||||
int colvarproxy_lammps::smp_lock()
|
||||
{
|
||||
omp_set_lock(&smp_lock_state);
|
||||
return COLVARS_OK;
|
||||
}
|
||||
|
||||
|
||||
int colvarproxy_lammps::smp_trylock()
|
||||
{
|
||||
return omp_test_lock(&smp_lock_state) ? COLVARS_OK : COLVARS_ERROR;
|
||||
}
|
||||
|
||||
|
||||
int colvarproxy_lammps::smp_unlock()
|
||||
{
|
||||
omp_unset_lock(&smp_lock_state);
|
||||
return COLVARS_OK;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
// multi-replica support
|
||||
|
||||
void colvarproxy_lammps::replica_comm_barrier() {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
#include "colvarmodule.h"
|
||||
#include "colvarproxy.h"
|
||||
#include "colvarvalue.h"
|
||||
|
||||
#include "lammps.h"
|
||||
#include "domain.h"
|
||||
|
@ -16,8 +17,12 @@
|
|||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
#if defined(_OPENMP)
|
||||
#include <omp.h>
|
||||
#endif
|
||||
|
||||
#ifndef COLVARPROXY_VERSION
|
||||
#define COLVARPROXY_VERSION "2016-02-28"
|
||||
#define COLVARPROXY_VERSION "2016-04-08"
|
||||
#endif
|
||||
|
||||
/* struct for packed data communication of coordinates and forces. */
|
||||
|
@ -130,6 +135,22 @@ class colvarproxy_lammps : public colvarproxy {
|
|||
|
||||
// implementation of optional methods from base class
|
||||
public:
|
||||
|
||||
#if defined(_OPENMP)
|
||||
// SMP support
|
||||
int smp_enabled();
|
||||
int smp_colvars_loop();
|
||||
int smp_biases_loop();
|
||||
int smp_thread_id();
|
||||
int smp_num_threads();
|
||||
protected:
|
||||
omp_lock_t smp_lock_state;
|
||||
public:
|
||||
int smp_lock();
|
||||
int smp_trylock();
|
||||
int smp_unlock();
|
||||
#endif
|
||||
|
||||
// Multi-replica support
|
||||
// Indicate if multi-replica support is available and active
|
||||
virtual bool replica_enabled() { return (inter_comm != MPI_COMM_NULL); }
|
||||
|
|
Loading…
Reference in New Issue