From e712b7bfe11807f98e982ee298d5213ca5750f61 Mon Sep 17 00:00:00 2001 From: Jinzhe Zeng Date: Thu, 18 Aug 2022 21:25:13 -0400 Subject: [PATCH] revert prod_force OMP in #1360 (#1862) * 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 * revert pining pip; setting env for setuptools>=64 Signed-off-by: Jinzhe Zeng Signed-off-by: Jinzhe Zeng --- .github/workflows/test_python.yml | 1 + source/lib/src/prod_force.cc | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/test_python.yml b/.github/workflows/test_python.yml index f66665c116..962fd8ccab 100644 --- a/.github/workflows/test_python.yml +++ b/.github/workflows/test_python.yml @@ -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 diff --git a/source/lib/src/prod_force.cc b/source/lib/src/prod_force.cc index 626b572b00..7da5cc11e1 100644 --- a/source/lib/src/prod_force.cc +++ b/source/lib/src/prod_force.cc @@ -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; @@ -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;