Skip to content

Commit 55a29ba

Browse files
LuLu
authored andcommitted
fix bugs, initialize variables before use
1 parent f3d25c8 commit 55a29ba

File tree

1 file changed

+21
-45
lines changed

1 file changed

+21
-45
lines changed

source/lib/src/NNPInter.cc

Lines changed: 21 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,20 +1043,13 @@ compute (ENERGYTYPE & dener,
10431043
shuffle_nlist (nlist, nnpmap);
10441044
#ifdef USE_CUDA_TOOLKIT
10451045
update_nbor(nlist, nloc);
1046-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1047-
#else
1048-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
1049-
#endif
1050-
1051-
}
1052-
else {
1053-
#ifdef USE_CUDA_TOOLKIT
1054-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1055-
#else
1056-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
10571046
#endif
1058-
10591047
}
1048+
#ifdef USE_CUDA_TOOLKIT
1049+
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1050+
#else
1051+
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
1052+
#endif
10601053
assert (nloc == ret);
10611054
run_model (dener, dforce_, dvirial, session, input_tensors, nnpmap, nghost);
10621055
}
@@ -1116,20 +1109,14 @@ compute (ENERGYTYPE & dener,
11161109
shuffle_nlist (nlist, nnpmap);
11171110
#ifdef USE_CUDA_TOOLKIT
11181111
update_nbor(nlist, nloc);
1119-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1120-
#else
1121-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
1122-
#endif
1123-
1124-
}
1125-
else {
1126-
#ifdef USE_CUDA_TOOLKIT
1127-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1128-
#else
1129-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
11301112
#endif
11311113

11321114
}
1115+
#ifdef USE_CUDA_TOOLKIT
1116+
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1117+
#else
1118+
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
1119+
#endif
11331120
assert (nloc == ret);
11341121
run_model (dener, dforce_, dvirial, datom_energy_, datom_virial_, session, input_tensors, nnpmap, nghost);
11351122
}
@@ -1498,23 +1485,18 @@ compute (vector<ENERGYTYPE> & all_energy,
14981485
shuffle_nlist (nlist, nnpmap);
14991486
#ifdef USE_CUDA_TOOLKIT
15001487
update_nbor(nlist, nloc);
1501-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1502-
#else
1503-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
15041488
#endif
15051489

15061490
}
1507-
else {
1508-
#ifdef USE_CUDA_TOOLKIT
1509-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1510-
#else
1511-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
1512-
#endif
1491+
#ifdef USE_CUDA_TOOLKIT
1492+
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1493+
#else
1494+
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
1495+
#endif
15131496

1514-
}
15151497
all_energy.resize (numb_models);
15161498
all_force.resize (numb_models);
1517-
all_virial.resize (numb_models)
1499+
all_virial.resize (numb_models);
15181500
assert (nloc == ret);
15191501
for (unsigned ii = 0; ii < numb_models; ++ii) {
15201502
run_model (all_energy[ii], all_force[ii], all_virial[ii], sessions[ii], input_tensors, nnpmap, nghost);
@@ -1553,21 +1535,15 @@ compute (vector<ENERGYTYPE> & all_energy,
15531535
shuffle_nlist (nlist, nnpmap);
15541536
#ifdef USE_CUDA_TOOLKIT
15551537
update_nbor(nlist, nloc);
1556-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1557-
#else
1558-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
15591538
#endif
15601539

15611540
}
1562-
else {
1563-
std::vector<std::pair<string, Tensor>> input_tensors;
1564-
#ifdef USE_CUDA_TOOLKIT
1565-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1566-
#else
1567-
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
1568-
#endif
1541+
#ifdef USE_CUDA_TOOLKIT
1542+
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, ilist, jrange, jlist, array_int, array_longlong, array_double, fparam, aparam, nnpmap, nghost);
1543+
#else
1544+
int ret = make_input_tensors (input_tensors, dcoord_, ntypes, datype_, dbox, nlist, fparam, aparam, nnpmap, nghost);
1545+
#endif
15691546

1570-
}
15711547
all_energy.resize (numb_models);
15721548
all_force .resize (numb_models);
15731549
all_virial.resize (numb_models);

0 commit comments

Comments
 (0)