Skip to content

Commit

Permalink
fix: sizeof(stdfsend) is always sizeof(double)
Browse files Browse the repository at this point in the history
style: fix typo in print_summary
  • Loading branch information
Cloudac7 committed Dec 5, 2023
1 parent 2b82104 commit eefb767
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion source/api_cc/src/common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ void deepmd::print_summary(const std::string& pre) {
std::cout << pre << "source branch: " + global_git_branch << "\n";
std::cout << pre << "source commit: " + global_git_hash << "\n";
std::cout << pre << "source commit at: " + global_git_date << "\n";
std::cout << pre << "surpport model ver.:" + global_model_version << "\n";
std::cout << pre << "supported model ver.:" + global_model_version << "\n";
#if defined(GOOGLE_CUDA)
std::cout << pre << "build variant: cuda"
<< "\n";
Expand Down
17 changes: 11 additions & 6 deletions source/lmp/pair_deepmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ PairDeepMD::PairDeepMD(LAMMPS *lmp)
cutoff = 0.;
numb_types = 0;
numb_types_spin = 0;
max_nlocal = 0;
numb_models = 0;
out_freq = 0;
out_each = 0;
Expand Down Expand Up @@ -783,16 +784,17 @@ void PairDeepMD::compute(int eflag, int vflag) {
// Gather std_f and tags
tagint *tag = atom->tag;
int nprocs = comm->nprocs;
int newntotal = atom->natoms;
if (newntotal > sizeof(stdfsend)) {
// Grow arrays if necessary
if (nlocal > max_nlocal) {
max_nlocal = nlocal;
memory->destroy(stdfsend);
memory->destroy(stdfrecv);
memory->destroy(tagsend);
memory->destroy(tagrecv);
memory->create(stdfsend, newntotal, "deepmd:stdfsendall");
memory->create(stdfrecv, newntotal, "deepmd:stdfrecvall");
memory->create(tagsend, newntotal, "deepmd:tagsendall");
memory->create(tagrecv, newntotal, "deepmd:tagrecvall");
memory->create(stdfsend, nlocal, "deepmd:stdfsendall");
memory->create(stdfrecv, nlocal, "deepmd:stdfrecvall");
memory->create(tagsend, nlocal, "deepmd:tagsendall");
memory->create(tagrecv, nlocal, "deepmd:tagrecvall");

Check warning on line 797 in source/lmp/pair_deepmd.cpp

View check run for this annotation

Codecov / codecov/patch

source/lmp/pair_deepmd.cpp#L789-L797

Added lines #L789 - L797 were not covered by tests
}
for (int ii = 0; ii < nlocal; ii++) {
tagsend[ii] = tag[ii];
Expand Down Expand Up @@ -1290,6 +1292,9 @@ void PairDeepMD::init_style() {
if (out_each == 1) {
int ntotal = atom->natoms;
int nprocs = comm->nprocs;
if (ntotal > max_nlocal) {
max_nlocal = ntotal;
}
memory->create(counts, nprocs, "deepmd:counts");
memory->create(displacements, nprocs, "deepmd:displacements");
memory->create(stdfsend, ntotal, "deepmd:stdfsendall");
Expand Down
1 change: 1 addition & 0 deletions source/lmp/pair_deepmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class PairDeepMD : public Pair {
std::string out_file;
int dim_fparam;
int dim_aparam;
int max_nlocal;
int out_each;
int out_rel;
int out_rel_v;
Expand Down

0 comments on commit eefb767

Please sign in to comment.