git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@6710 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
21
src/comm.cpp
21
src/comm.cpp
@ -37,6 +37,10 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
#ifdef LMP_OPENMP
|
||||||
|
#include "omp.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
#define BUFFACTOR 1.5
|
#define BUFFACTOR 1.5
|
||||||
@ -68,7 +72,24 @@ Comm::Comm(LAMMPS *lmp) : Pointers(lmp)
|
|||||||
cutghostuser = 0.0;
|
cutghostuser = 0.0;
|
||||||
ghost_velocity = 0;
|
ghost_velocity = 0;
|
||||||
|
|
||||||
|
// use of OpenMP threads
|
||||||
|
// query OpenMP for number of threads/process set by user at run-time
|
||||||
|
// need to be in a parallel area for this operation
|
||||||
|
|
||||||
nthreads = 1;
|
nthreads = 1;
|
||||||
|
#ifdef LMP_OPENMP
|
||||||
|
#pragma omp parallel default(shared)
|
||||||
|
{
|
||||||
|
#pragma omp master
|
||||||
|
{ nthreads = omp_get_num_threads(); }
|
||||||
|
}
|
||||||
|
if (me == 0) {
|
||||||
|
if (screen)
|
||||||
|
fprintf(screen," using %d OpenMP thread(s) per MPI task\n",nthreads);
|
||||||
|
if (logfile)
|
||||||
|
fprintf(logfile," using %d OpenMP thread(s) per MPI task\n",nthreads);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// initialize comm buffers & exchange memory
|
// initialize comm buffers & exchange memory
|
||||||
|
|
||||||
|
|||||||
@ -46,6 +46,10 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "memory.h"
|
#include "memory.h"
|
||||||
|
|
||||||
|
#ifdef LMP_OPENMP
|
||||||
|
#include "omp.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace LAMMPS_NS;
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
#define MAXLINE 2048
|
#define MAXLINE 2048
|
||||||
@ -1136,10 +1140,25 @@ void Input::package()
|
|||||||
delete [] fixarg;
|
delete [] fixarg;
|
||||||
|
|
||||||
} else if (strcmp(arg[0],"omp") == 0) {
|
} else if (strcmp(arg[0],"omp") == 0) {
|
||||||
|
|
||||||
|
#ifdef LMP_OPENMP
|
||||||
if (narg != 2) error->all("Illegal package command");
|
if (narg != 2) error->all("Illegal package command");
|
||||||
comm->nthreads = atoi(arg[1]);
|
comm->nthreads = atoi(arg[1]);
|
||||||
if (comm->nthreads < 1) error->all("Illegal package command");
|
if (comm->nthreads < 1) error->all("Illegal package command");
|
||||||
|
|
||||||
|
omp_set_num_threads(nthr);
|
||||||
|
if (me == 0) {
|
||||||
|
if (screen)
|
||||||
|
fprintf(screen," reset %d OpenMP thread(s) per MPI task\n",
|
||||||
|
comm->nthreads);
|
||||||
|
if (logfile)
|
||||||
|
fprintf(logfile," reset %d OpenMP thread(s) per MPI task\n",
|
||||||
|
comm->nthreads);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
error->all("Cannot use package omp command with no OpenMP support");
|
||||||
|
#endif
|
||||||
|
|
||||||
} else error->all("Illegal package command");
|
} else error->all("Illegal package command");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user