Skip to content

Commit

Permalink
revert prod_force OMP in deepmodeling#1360
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
njzjz committed Aug 17, 2022
1 parent 7aea9cf commit d9df710
Showing 1 changed file with 0 additions and 6 deletions.
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 d9df710

Please sign in to comment.