本文整理汇总了C++中Comm::exchange方法的典型用法代码示例。如果您正苦于以下问题:C++ Comm::exchange方法的具体用法?C++ Comm::exchange怎么用?C++ Comm::exchange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comm
的用法示例。
在下文中一共展示了Comm::exchange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv)
{
//Common miniMD settings
In in;
in.datafile = NULL;
int me=0; //local MPI rank
int nprocs=1; //number of MPI ranks
int num_threads=32; //number of Threads per Block threads
int num_steps=-1; //number of timesteps (if -1 use value from lj.in)
int system_size=-1; //size of the system (if -1 use value from lj.in)
int check_safeexchange=0; //if 1 complain if atom moves further than 1 subdomain length between exchanges
int do_safeexchange=0; //if 1 use safe exchange mode [allows exchange over multiple subdomains]
int use_sse=0; //setting for SSE variant of miniMD only
int screen_yaml=0; //print yaml output to screen also
int yaml_output=0; //print yaml output
int halfneigh=0; //1: use half neighborlist; 0: use full neighborlist; -1: use original miniMD version half neighborlist force
char* input_file = NULL;
int ghost_newton = 0;
int skip_gpu = 999;
int neighbor_size = -1;
//OpenCL specific
int platform = 0;
int device = 0;
int subdevice = -1;
int ppn = 2;
int use_tex = 0;
int threads_per_atom = 1;
int map_device=0;
for(int i = 0; i < argc; i++) {
if((strcmp(argv[i], "-i") == 0) || (strcmp(argv[i], "--input_file") == 0)) {
input_file = argv[++i];
continue;
}
if((strcmp(argv[i],"-p")==0)||(strcmp(argv[i],"--platform")==0)) {platform=atoi(argv[++i]); continue;}
if((strcmp(argv[i],"-d")==0)||(strcmp(argv[i],"--device")==0)) {device=atoi(argv[++i]); continue;}
if((strcmp(argv[i],"-sd")==0)||(strcmp(argv[i],"--subdevice")==0)) {subdevice=atoi(argv[++i]); continue;}
if((strcmp(argv[i],"-sd_map")==0)||(strcmp(argv[i],"--subdevice_mapping")==0)) {subdevice=1-me%ppn; continue;}
if((strcmp(argv[i],"-ng")==0)||(strcmp(argv[i],"--num_gpus")==0)) {ppn=atoi(argv[++i]); continue;}
if((strcmp(argv[i],"-dm")==0)||(strcmp(argv[i],"--device_map")==0)) {map_device=1; continue;}
}
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &me);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
if(map_device) {device = me%ppn; if(device>=skip_gpu) device++;}
OpenCLWrapper* opencl = new OpenCLWrapper;
if( me == 0)
printf("# Platforms: %i\n",opencl->num_platforms);
printf("# Proc: %i using device %i\n",me,device);
opencl->Init(argc,argv,device,device+1,NULL,platform,subdevice);
int error = 0;
if(input_file == NULL)
error = input(in, "in.lj.miniMD");
else
error = input(in, input_file);
if (error)
{
MPI_Finalize();
exit(0);
}
for(int i=0;i<argc;i++)
{
if((strcmp(argv[i],"-t")==0)||(strcmp(argv[i],"--num_threads")==0)) {num_threads=atoi(argv[++i]); continue;}
if((strcmp(argv[i],"-n")==0)||(strcmp(argv[i],"--nsteps")==0)) {num_steps=atoi(argv[++i]); continue;}
if((strcmp(argv[i],"-s")==0)||(strcmp(argv[i],"--size")==0)) {system_size=atoi(argv[++i]); continue;}
if((strcmp(argv[i],"--half_neigh")==0)) {halfneigh=atoi(argv[++i]); continue;}
if((strcmp(argv[i],"-sse")==0)) {use_sse=atoi(argv[++i]); continue;}
if((strcmp(argv[i],"--check_exchange")==0)) {check_safeexchange=1; continue;}
if((strcmp(argv[i],"-o")==0)||(strcmp(argv[i],"--yaml_output")==0)) {yaml_output=atoi(argv[++i]); continue;}
if((strcmp(argv[i],"--yaml_screen")==0)) {screen_yaml=1; continue;}
if((strcmp(argv[i], "-f") == 0) || (strcmp(argv[i], "--data_file") == 0)) {
if(in.datafile == NULL) in.datafile = new char[1000];
strcpy(in.datafile, argv[++i]);
continue;
}
if((strcmp(argv[i], "-u") == 0) || (strcmp(argv[i], "--units") == 0)) {
in.units = strcmp(argv[++i], "metal") == 0 ? 1 : 0;
continue;
}
if((strcmp(argv[i], "-p") == 0) || (strcmp(argv[i], "--force") == 0)) {
in.forcetype = strcmp(argv[++i], "eam") == 0 ? FORCEEAM : FORCELJ;
continue;
}
if((strcmp(argv[i], "-gn") == 0) || (strcmp(argv[i], "--ghost_newton") == 0)) {
ghost_newton = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "--skip_gpu") == 0)) {
skip_gpu = atoi(argv[++i]);
continue;
}
//.........这里部分代码省略.........
示例2: run
void Integrate::run(Atom &atom, Force* force, Neighbor &neighbor,
Comm &comm, Thermo &thermo, Timer &timer)
{
int i, n;
comm.timer = &timer;
timer.array[TIME_TEST] = 0.0;
int check_safeexchange = comm.check_safeexchange;
mass = atom.mass;
dtforce = dtforce / mass;
//Use OpenMP threads only within the following loop containing the main loop.
//Do not use OpenMP for setup and postprocessing.
#pragma omp parallel private(i,n)
{
for(n = 0; n < ntimes; n++) {
#pragma omp barrier
x = &atom.x[0][0];
v = &atom.v[0][0];
f = &atom.f[0][0];
xold = &atom.xold[0][0];
nlocal = atom.nlocal;
initialIntegrate();
#pragma omp barrier
#pragma omp master
timer.stamp();
if((n + 1) % neighbor.every) {
#pragma omp barrier
comm.communicate(atom);
#pragma omp master
timer.stamp(TIME_COMM);
#pragma omp barrier
} else {
//these routines are not yet ported to OpenMP
{
if(check_safeexchange) {
#pragma omp master
{
double d_max = 0;
for(i = 0; i < atom.nlocal; i++) {
double dx = (x[3 * i + 0] - xold[3 * i + 0]);
if(dx > atom.box.xprd) dx -= atom.box.xprd;
if(dx < -atom.box.xprd) dx += atom.box.xprd;
double dy = (x[3 * i + 1] - xold[3 * i + 1]);
if(dy > atom.box.yprd) dy -= atom.box.yprd;
if(dy < -atom.box.yprd) dy += atom.box.yprd;
double dz = (x[3 * i + 2] - xold[3 * i + 2]);
if(dz > atom.box.zprd) dz -= atom.box.zprd;
if(dz < -atom.box.zprd) dz += atom.box.zprd;
double d = dx * dx + dy * dy + dz * dz;
if(d > d_max) d_max = d;
}
d_max = sqrt(d_max);
if((d_max > atom.box.xhi - atom.box.xlo) || (d_max > atom.box.yhi - atom.box.ylo) || (d_max > atom.box.zhi - atom.box.zlo))
printf("Warning: Atoms move further than your subdomain size, which will eventually cause lost atoms.\n"
"Increase reneighboring frequency or choose a different processor grid\n"
"Maximum move distance: %lf; Subdomain dimensions: %lf %lf %lf\n",
d_max, atom.box.xhi - atom.box.xlo, atom.box.yhi - atom.box.ylo, atom.box.zhi - atom.box.zlo);
}
}
//int tid = omp_get_thread_num();
//printf("Check B: %i %i %i\n",comm.me,tid,n);
#pragma omp master
timer.stamp_extra_start();
comm.exchange(atom);
comm.borders(atom);
#pragma omp master
{
timer.stamp_extra_stop(TIME_TEST);
timer.stamp(TIME_COMM);
}
if(check_safeexchange)
for(int i = 0; i < 3 * atom.nlocal; i++) atom.xold[i] = atom.x[i];
//.........这里部分代码省略.........
示例3: main
int main(int argc, char** argv)
{
In in;
in.datafile = NULL;
int me = 0; //local MPI rank
int nprocs = 1; //number of MPI ranks
int num_threads = 1; //number of OpenMP threads
int num_steps = -1; //number of timesteps (if -1 use value from lj.in)
int system_size = -1; //size of the system (if -1 use value from lj.in)
int nx = -1;
int ny = -1;
int nz = -1;
int check_safeexchange = 0; //if 1 complain if atom moves further than 1 subdomain length between exchanges
int do_safeexchange = 0; //if 1 use safe exchange mode [allows exchange over multiple subdomains]
int use_sse = 0; //setting for SSE variant of miniMD only
int screen_yaml = 0; //print yaml output to screen also
int yaml_output = 0; //print yaml output
int halfneigh = 1; //1: use half neighborlist; 0: use full neighborlist; -1: use original miniMD version half neighborlist force
int teams = 1;
int device = 0;
int neighbor_size = -1;
char* input_file = NULL;
int ghost_newton = 1;
int sort = -1;
for(int i = 0; i < argc; i++) {
if((strcmp(argv[i], "-i") == 0) || (strcmp(argv[i], "--input_file") == 0)) {
input_file = argv[++i];
continue;
}
}
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &me);
MPI_Comm_size(MPI_COMM_WORLD, &nprocs);
int error = 0;
if(input_file == NULL)
error = input(in, "in.lj.miniMD");
else
error = input(in, input_file);
if(error) {
MPI_Finalize();
exit(0);
}
for(int i = 0; i < argc; i++) {
if((strcmp(argv[i], "-t") == 0) || (strcmp(argv[i], "--num_threads") == 0)) {
num_threads = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "--teams") == 0)) {
teams = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "-n") == 0) || (strcmp(argv[i], "--nsteps") == 0)) {
num_steps = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "-s") == 0) || (strcmp(argv[i], "--size") == 0)) {
system_size = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "-nx") == 0)) {
nx = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "-ny") == 0)) {
ny = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "-nz") == 0)) {
nz = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "-b") == 0) || (strcmp(argv[i], "--neigh_bins") == 0)) {
neighbor_size = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "--half_neigh") == 0)) {
halfneigh = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "-sse") == 0)) {
use_sse = atoi(argv[++i]);
continue;
}
if((strcmp(argv[i], "--check_exchange") == 0)) {
//.........这里部分代码省略.........