Skip to content

Commit

Permalink
revert prod_force OMP in #1360 (#1862)
Browse files Browse the repository at this point in the history
* revert prod_force OMP in #1360

Sometimes when box is quite small (i.e. box size < 2 * rcut), the same atom may repeat to appear in the neighbor list. This cause inaccurate results when using OMP.

* do not update pip

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>

* revert pining pip; setting env for setuptools>=64

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
njzjz committed Aug 19, 2022
1 parent 7aea9cf commit acca2a6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,6 @@ jobs:
CC: gcc-${{ matrix.gcc }}
CXX: g++-${{ matrix.gcc }}
TENSORFLOW_VERSION: ${{ matrix.tf }}
SETUPTOOLS_ENABLE_FEATURES: "legacy-editable"
- run: dp --version
- run: pytest --cov=deepmd source/tests && codecov
6 changes: 0 additions & 6 deletions source/lib/src/prod_force.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,14 @@ prod_force_a_cpu(

memset(force, 0, sizeof(FPTYPE) * nall * 3);
// compute force of a frame
#pragma omp parallel
for (int i_idx = start_index; i_idx < start_index + nloc; ++i_idx) {
// deriv wrt center atom
#pragma omp single
for (int aa = 0; aa < ndescrpt; ++aa) {
force[i_idx * 3 + 0] -= net_deriv[i_idx * ndescrpt + aa] * env_deriv[i_idx * ndescrpt * 3 + aa * 3 + 0];
force[i_idx * 3 + 1] -= net_deriv[i_idx * ndescrpt + aa] * env_deriv[i_idx * ndescrpt * 3 + aa * 3 + 1];
force[i_idx * 3 + 2] -= net_deriv[i_idx * ndescrpt + aa] * env_deriv[i_idx * ndescrpt * 3 + aa * 3 + 2];
}
// deriv wrt neighbors
#pragma omp for
for (int jj = 0; jj < nnei; ++jj) {
int j_idx = nlist[i_idx * nnei + jj];
if (j_idx < 0) continue;
Expand Down Expand Up @@ -111,18 +108,15 @@ prod_force_r_cpu(
}

// compute force of a frame
#pragma omp parallel
for (int ii = 0; ii < nloc; ++ii){
int i_idx = ii;
// deriv wrt center atom
#pragma omp single
for (int aa = 0; aa < ndescrpt; ++aa){
force[i_idx * 3 + 0] -= net_deriv[i_idx * ndescrpt + aa] * env_deriv[i_idx * ndescrpt * 3 + aa * 3 + 0];
force[i_idx * 3 + 1] -= net_deriv[i_idx * ndescrpt + aa] * env_deriv[i_idx * ndescrpt * 3 + aa * 3 + 1];
force[i_idx * 3 + 2] -= net_deriv[i_idx * ndescrpt + aa] * env_deriv[i_idx * ndescrpt * 3 + aa * 3 + 2];
}
// deriv wrt neighbors
#pragma omp for
for (int jj = 0; jj < nnei; ++jj){
int j_idx = nlist[i_idx * nnei + jj];
// if (j_idx > nloc) j_idx = j_idx % nloc;
Expand Down

0 comments on commit acca2a6

Please sign in to comment.