Skip to content

Commit

Permalink
MetaD: some fixes for the OMP implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocamilloni committed Nov 8, 2020
1 parent 60b819e commit 4052b02
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/bias/MetaD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1546,28 +1546,28 @@ double MetaD::getBiasAndDerivatives(const vector<double>& cv, double* der)
if(!use_Kneighb_) {
#pragma omp parallel num_threads(nt)
{
std::unique_ptr<double[]> omp_deriv(new double[getNumberOfArguments()]);
std::unique_ptr<double[]> omp_deriv(new double[getNumberOfArguments()]());
#pragma omp for reduction(+:bias) nowait
for(unsigned i=rank; i<hills_.size(); i+=stride) {
bias+=evaluateGaussian(cv,hills_[i],omp_deriv.get());
if(nt==1) for(unsigned j=0; j<cv.size(); j++) der[j]+=omp_deriv[j];
if(der) bias+=evaluateGaussian(cv,hills_[i],omp_deriv.get());
else bias+=evaluateGaussian(cv,hills_[i],der);
}
#pragma omp critical
if(nt>1) {
if(der) {
for(unsigned j=0; j<cv.size(); j++) der[j]+=omp_deriv[j];
}
}
} else {
#pragma omp parallel num_threads(nt)
{
std::unique_ptr<double[]> omp_deriv(new double[getNumberOfArguments()]);
std::unique_ptr<double[]> omp_deriv(new double[getNumberOfArguments()]());
#pragma omp for reduction(+:bias) nowait
for(unsigned i=rank; i<neigh_hills_.size(); i+=stride) {
bias+=evaluateGaussian(cv,neigh_hills_[i],omp_deriv.get());
if(nt==1) for(unsigned j=0; j<cv.size(); j++) der[j]+=omp_deriv[j];
if(der) bias+=evaluateGaussian(cv,neigh_hills_[i],omp_deriv.get());
else bias+=evaluateGaussian(cv,neigh_hills_[i],der);
}
#pragma omp critical
if(nt>1) {
if(der) {
for(unsigned j=0; j<cv.size(); j++) der[j]+=omp_deriv[j];
}
}
Expand Down Expand Up @@ -1738,7 +1738,7 @@ void MetaD::calculate()
if(use_Kneighb_) {
double d = difference(i, cv[i], neigh_center_[i]);
double nk_dist2 = d*d/neigh_dev2_[i];
if(nk_dist2>0.6) {neigh_update_=true; break;}
if(nk_dist2>0.6) neigh_update_=true;
}
}
if(getExchangeStep()) neigh_update_=true;
Expand Down

2 comments on commit 4052b02

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found broken examples in automatic/performance-optimization.txt
Found broken examples in automatic/a-trieste-6.txt
Found broken examples in automatic/munster.txt
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/MAZE_MEMETIC_SAMPLING.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_RANDOM_WALK.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in MiscelaneousPP.md

@PlumedBot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found broken examples in automatic/performance-optimization.txt
Found broken examples in automatic/a-trieste-6.txt
Found broken examples in automatic/munster.txt
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/FOURIER_TRANSFORM.tmp
Found broken examples in automatic/FUNCPATHGENERAL.tmp
Found broken examples in automatic/FUNCPATHMSD.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/FUNNEL.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/MAZE_MEMETIC_SAMPLING.tmp
Found broken examples in automatic/MAZE_OPTIMIZER_BIAS.tmp
Found broken examples in automatic/MAZE_RANDOM_ACCELERATION_MD.tmp
Found broken examples in automatic/MAZE_RANDOM_WALK.tmp
Found broken examples in automatic/MAZE_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in MiscelaneousPP.md

Please sign in to comment.