本文整理汇总了C++中Comm::borders方法的典型用法代码示例。如果您正苦于以下问题:C++ Comm::borders方法的具体用法?C++ Comm::borders怎么用?C++ Comm::borders使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comm
的用法示例。
在下文中一共展示了Comm::borders方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
force.cutforce = in.force_cut;
thermo.nstat = in.thermo_nstat;
if(me == 0)
printf("# Create System:\n");
if(in.datafile) {
read_lammps_data(atom, comm, neighbor, integrate, thermo, in.datafile, in.units);
MMD_float volume = atom.box.xprd * atom.box.yprd * atom.box.zprd;
in.rho = 1.0 * atom.natoms / volume;
force.setup();
} else {
create_box(atom, in.nx, in.ny, in.nz, in.rho);
comm.setup(neighbor.cutneigh, atom);
neighbor.setup(atom);
integrate.setup();
force.setup();
create_atoms(atom, in.nx, in.ny, in.nz, in.rho);
thermo.setup(in.rho, integrate, atom, in.units);
create_velocity(in.t_request, atom, thermo);
}
if(me == 0)
printf("# Done .... \n");
if(me == 0) {
fprintf(stdout, "# " VARIANT_STRING " output ...\n");
fprintf(stdout, "# Systemparameters: \n");
fprintf(stdout, "\t# MPI processes: %i\n", neighbor.threads->mpi_num_threads);
fprintf(stdout, "\t# OpenMP threads: %i\n", neighbor.threads->omp_num_threads);
fprintf(stdout, "\t# Inputfile: %s\n", input_file == 0 ? "in.lj.miniMD" : input_file);
fprintf(stdout, "\t# Datafile: %s\n", in.datafile ? in.datafile : "None");
fprintf(stdout, "\t# ForceStyle: %s\n", in.forcetype == FORCELJ ? "LJ" : "EAM");
fprintf(stdout, "\t# Units: %s\n", in.units == 0 ? "LJ" : "METAL");
fprintf(stdout, "\t# Atoms: %i\n", atom.natoms);
fprintf(stdout, "\t# System size: %2.2lf %2.2lf %2.2lf (unit cells: %i %i %i)\n", atom.box.xprd, atom.box.yprd, atom.box.zprd, in.nx, in.ny, in.nz);
fprintf(stdout, "\t# Density: %lf\n", in.rho);
fprintf(stdout, "\t# Force cutoff: %lf\n", force.cutforce);
fprintf(stdout, "\t# Neigh cutoff: %lf\n", neighbor.cutneigh);
fprintf(stdout, "\t# Half neighborlists: %i\n", neighbor.halfneigh);
fprintf(stdout, "\t# Neighbor bins: %i %i %i\n", neighbor.nbinx, neighbor.nbiny, neighbor.nbinz);
fprintf(stdout, "\t# Neighbor frequency: %i\n", neighbor.every);
fprintf(stdout, "\t# Timestep size: %lf\n", integrate.dt);
fprintf(stdout, "\t# Thermo frequency: %i\n", thermo.nstat);
fprintf(stdout, "\t# Ghost Newton: %i\n", ghost_newton);
fprintf(stdout, "\t# Use SSE intrinsics: %i\n", force.use_sse);
fprintf(stdout, "\t# Do safe exchange: %i\n", comm.do_safeexchange);
fprintf(stdout, "\t# Size of float: %i\n\n",sizeof(MMD_float));
}
comm.exchange(atom);
comm.borders(atom);
atom.d_x->upload();
atom.d_v->upload();
//atom.d_vold->upload();
neighbor.build(atom);
if (me == 0) printf("# Starting dynamics ...\n");
if (me == 0) printf("# Timestep T U P Time\n");
thermo.compute(0,atom,neighbor,force,timer,comm);
force.compute(atom,neighbor,comm.me);
timer.barrier_start(TIME_TOTAL);
integrate.run(atom,force,neighbor,comm,thermo,timer);
timer.barrier_stop(TIME_TOTAL);
int natoms;
MPI_Allreduce(&atom.nlocal,&natoms,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
thermo.compute(-1,atom,neighbor,force,timer,comm);
if(me == 0) {
double time_other=timer.array[TIME_TOTAL]-timer.array[TIME_FORCE]-timer.array[TIME_NEIGH]-timer.array[TIME_COMM];
printf("\n\n");
printf("# Performance Summary:\n");
printf("# MPI_proc OMP_threads nsteps natoms t_total t_force t_neigh t_comm t_other performance perf/thread grep_string t_extra\n");
printf("%i %i %i %i %lf %lf %lf %lf %lf %lf %lf PERF_SUMMARY %lf\n\n\n",
nprocs,num_threads,integrate.ntimes,natoms,
timer.array[TIME_TOTAL],timer.array[TIME_FORCE],timer.array[TIME_NEIGH],timer.array[TIME_COMM],time_other,
1.0*natoms*integrate.ntimes/timer.array[TIME_TOTAL],1.0*natoms*integrate.ntimes/timer.array[TIME_TOTAL]/nprocs/num_threads,timer.array[TIME_TEST]);
}
if(yaml_output)
output(in,atom,force,neighbor,comm,thermo,integrate,timer,screen_yaml);
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
delete opencl;
return 0;
}
示例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
//.........这里部分代码省略.........
create_atoms(atom, in.nx, in.ny, in.nz, in.rho);
thermo.setup(in.rho, integrate, atom, in.units);
create_velocity(in.t_request, atom, thermo);
}
if(me == 0)
printf("# Done .... \n");
if(me == 0) {
fprintf(stdout, "# " VARIANT_STRING " output ...\n");
fprintf(stdout, "# Run Settings: \n");
fprintf(stdout, "\t# MPI processes: %i\n", neighbor.threads->mpi_num_threads);
fprintf(stdout, "\t# OpenMP threads: %i\n", neighbor.threads->omp_num_threads);
fprintf(stdout, "\t# Inputfile: %s\n", input_file == 0 ? "in.lj.miniMD" : input_file);
fprintf(stdout, "\t# Datafile: %s\n", in.datafile ? in.datafile : "None");
fprintf(stdout, "# Physics Settings: \n");
fprintf(stdout, "\t# ForceStyle: %s\n", in.forcetype == FORCELJ ? "LJ" : "EAM");
fprintf(stdout, "\t# Force Parameters: %2.2lf %2.2lf\n",in.epsilon,in.sigma);
fprintf(stdout, "\t# Units: %s\n", in.units == 0 ? "LJ" : "METAL");
fprintf(stdout, "\t# Atoms: %i\n", atom.natoms);
fprintf(stdout, "\t# System size: %2.2lf %2.2lf %2.2lf (unit cells: %i %i %i)\n", atom.box.xprd, atom.box.yprd, atom.box.zprd, in.nx, in.ny, in.nz);
fprintf(stdout, "\t# Density: %lf\n", in.rho);
fprintf(stdout, "\t# Force cutoff: %lf\n", force->cutforce);
fprintf(stdout, "\t# Timestep size: %lf\n", integrate.dt);
fprintf(stdout, "# Technical Settings: \n");
fprintf(stdout, "\t# Neigh cutoff: %lf\n", neighbor.cutneigh);
fprintf(stdout, "\t# Half neighborlists: %i\n", neighbor.halfneigh);
fprintf(stdout, "\t# Neighbor bins: %i %i %i\n", neighbor.nbinx, neighbor.nbiny, neighbor.nbinz);
fprintf(stdout, "\t# Neighbor frequency: %i\n", neighbor.every);
fprintf(stdout, "\t# Sorting frequency: %i\n", integrate.sort_every);
fprintf(stdout, "\t# Thermo frequency: %i\n", thermo.nstat);
fprintf(stdout, "\t# Ghost Newton: %i\n", ghost_newton);
fprintf(stdout, "\t# Use intrinsics: %i\n", force->use_sse);
fprintf(stdout, "\t# Do safe exchange: %i\n", comm.do_safeexchange);
fprintf(stdout, "\t# Size of float: %i\n\n", (int) sizeof(MMD_float));
}
comm.exchange(atom);
if(sort>0)
atom.sort(neighbor);
comm.borders(atom);
force->evflag = 1;
#pragma omp parallel
{
neighbor.build(atom);
force->compute(atom, neighbor, comm, me);
}
if(neighbor.halfneigh && neighbor.ghost_newton)
comm.reverse_communicate(atom);
if(me == 0) printf("# Starting dynamics ...\n");
if(me == 0) printf("# Timestep T U P Time\n");
#pragma omp parallel
{
thermo.compute(0, atom, neighbor, force, timer, comm);
}
timer.barrier_start(TIME_TOTAL);
integrate.run(atom, force, neighbor, comm, thermo, timer);
timer.barrier_stop(TIME_TOTAL);
int natoms;
MPI_Allreduce(&atom.nlocal, &natoms, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD);
force->evflag = 1;
force->compute(atom, neighbor, comm, me);
if(neighbor.halfneigh && neighbor.ghost_newton)
comm.reverse_communicate(atom);
thermo.compute(-1, atom, neighbor, force, timer, comm);
if(me == 0) {
double time_other = timer.array[TIME_TOTAL] - timer.array[TIME_FORCE] - timer.array[TIME_NEIGH] - timer.array[TIME_COMM];
printf("\n\n");
printf("# Performance Summary:\n");
printf("# MPI_proc OMP_threads nsteps natoms t_total t_force t_neigh t_comm t_other performance perf/thread grep_string t_extra\n");
printf("%i %i %i %i %lf %lf %lf %lf %lf %lf %lf PERF_SUMMARY %lf\n\n\n",
nprocs, num_threads, integrate.ntimes, natoms,
timer.array[TIME_TOTAL], timer.array[TIME_FORCE], timer.array[TIME_NEIGH], timer.array[TIME_COMM], time_other,
1.0 * natoms * integrate.ntimes / timer.array[TIME_TOTAL], 1.0 * natoms * integrate.ntimes / timer.array[TIME_TOTAL] / nprocs / num_threads, timer.array[TIME_TEST]);
}
if(yaml_output)
output(in, atom, force, neighbor, comm, thermo, integrate, timer, screen_yaml);
delete force;
MPI_Barrier(MPI_COMM_WORLD);
MPI_Finalize();
return 0;
}