From ac20d1ab41d63096f60cdeac54d1f76cb60b5dff Mon Sep 17 00:00:00 2001 From: Steve Plimpton Date: Mon, 18 Mar 2019 09:52:16 -0600 Subject: [PATCH] fix corner-case issue with hyper communication, also timer --- src/REPLICA/fix_hyper_local.cpp | 12 ++++++++++-- src/REPLICA/hyper.cpp | 11 ++++++++--- src/comm_brick.cpp | 18 ++++++++---------- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/src/REPLICA/fix_hyper_local.cpp b/src/REPLICA/fix_hyper_local.cpp index 21ad2cd86a..be4a642ebb 100644 --- a/src/REPLICA/fix_hyper_local.cpp +++ b/src/REPLICA/fix_hyper_local.cpp @@ -1261,16 +1261,24 @@ void FixHyperLocal::unpack_reverse_comm(int n, int *list, double *buf) { int i,j,k,m; - m = 0; + // return if n = 0 + // b/c if there are no atoms (n = 0), the message will not have + // been sent by Comm::reverse_comm_fix() or reverse_comm_fix_variable() + // so must not read nonzero from first buf location (would be zero anyway) + + if (n == 0) return; // STRAIN // unpack maxstrain vector // nonzero # of entries, each has offset to which atom in receiver's list // use MAX, b/c want maximum abs value strain for each atom's bonds - + + m = 0; + if (commflag == STRAIN) { int offset; int nonzero = (int) ubuf(buf[m++]).i; // # of atoms with values + for (int iatom = 0; iatom < nonzero; iatom++) { offset = (int) ubuf(buf[m++]).i; // offset into list for which atom j = list[offset]; diff --git a/src/REPLICA/hyper.cpp b/src/REPLICA/hyper.cpp index 0d8de6d060..5d820b2e27 100644 --- a/src/REPLICA/hyper.cpp +++ b/src/REPLICA/hyper.cpp @@ -181,9 +181,6 @@ void Hyper::command(int narg, char **arg) if (hyperenable) fix_hyper->init_hyper(); - timer->barrier_start(); - time_start = timer->get_wall(Timer::TOTAL); - // perform initial minimization and bond list creation int nevent = 0; @@ -198,6 +195,14 @@ void Hyper::command(int narg, char **arg) if (hyperenable) fix_hyper->build_bond_list(0); fix_event->restore_state_quench(); + // reset stats and timers to skip HD setup + + nbuild = ndanger = 0; + time_dynamics = time_quench = 0.0; + + timer->barrier_start(); + time_start = timer->get_wall(Timer::TOTAL); + // main loop: dynamics, store state, quench, check event, restore state int ecount; diff --git a/src/comm_brick.cpp b/src/comm_brick.cpp index 64b21e41c9..330551aaed 100644 --- a/src/comm_brick.cpp +++ b/src/comm_brick.cpp @@ -1046,10 +1046,6 @@ void CommBrick::reverse_comm_fix(Fix *fix, int size) reverse communication invoked by a Fix with variable size data query fix for pack size to insure buf_send is big enough handshake sizes before each Irecv/Send to insure buf_recv is big enough - this removes the if tests on sendnum and recvnum to make MPI calls, - as in reverse_comm_fix(), b/c the caller may still want to - exchange a message even if the send/recv swap has no atoms, - e.g. a reduced count = 0 of atoms to send/recv, as in fix hyper/local ------------------------------------------------------------------------- */ void CommBrick::reverse_comm_fix_variable(Fix *fix) @@ -1074,12 +1070,14 @@ void CommBrick::reverse_comm_fix_variable(Fix *fix) &nrecv,1,MPI_INT,sendproc[iswap],0,world, MPI_STATUS_IGNORE); - if (nrecv > maxrecv) grow_recv(nrecv); - MPI_Irecv(buf_recv,maxrecv,MPI_DOUBLE,sendproc[iswap],0, - world,&request); - - MPI_Send(buf_send,nsend,MPI_DOUBLE,recvproc[iswap],0,world); - MPI_Wait(&request,MPI_STATUS_IGNORE); + if (sendnum[iswap]) { + if (nrecv > maxrecv) grow_recv(nrecv); + MPI_Irecv(buf_recv,maxrecv,MPI_DOUBLE,sendproc[iswap],0, + world,&request); + } + if (recvnum[iswap]) + MPI_Send(buf_send,nsend,MPI_DOUBLE,recvproc[iswap],0,world); + if (sendnum[iswap]) MPI_Wait(&request,MPI_STATUS_IGNORE); buf = buf_recv; } else buf = buf_send;