From 74fa8d1af7ca6d2e5027ff979064f8450601c66b Mon Sep 17 00:00:00 2001 From: Daniele Rapetti <5535617+Iximiel@users.noreply.github.com> Date: Tue, 9 Jul 2024 15:48:54 +0200 Subject: [PATCH 1/2] I get ~ 3% improvement if I use MPI with 5000 atoms run astyle --- src/colvar/CoordinationBase.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/colvar/CoordinationBase.cpp b/src/colvar/CoordinationBase.cpp index 9a6cd66eee..e7ab51611c 100644 --- a/src/colvar/CoordinationBase.cpp +++ b/src/colvar/CoordinationBase.cpp @@ -149,17 +149,21 @@ void CoordinationBase::calculate() const unsigned nn=nl->size(); if(nt*stride*10>nn) nt=1; + const unsigned elementsPerRank = std::ceil(double(nn)/stride); + const unsigned int start= rank*elementsPerRank; + const unsigned int end = ((start + elementsPerRank)< nn)?(start + elementsPerRank): nn; + #pragma omp parallel num_threads(nt) { std::vector omp_deriv(getPositions().size()); Tensor omp_virial; #pragma omp for reduction(+:ncoord) nowait - for(unsigned int i=rank; igetClosePair(i).first; - unsigned i1=nl->getClosePair(i).second; + const unsigned i0=nl->getClosePair(i).first; + const unsigned i1=nl->getClosePair(i).second; if(getAbsoluteIndex(i0)==getAbsoluteIndex(i1)) continue; @@ -187,7 +191,8 @@ void CoordinationBase::calculate() } #pragma omp critical if(nt>1) { - for(unsigned i=0; i Date: Wed, 24 Jul 2024 23:23:57 +0200 Subject: [PATCH 2/2] changelog --- CHANGES/v2.9.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES/v2.9.md b/CHANGES/v2.9.md index 2e69f926d8..414f2893e5 100644 --- a/CHANGES/v2.9.md +++ b/CHANGES/v2.9.md @@ -61,4 +61,5 @@ Changes from version 2.8 which are relevant for users: ## Version 2.9.2 (tba) - Patch for GROMACS 2023 updated to the latest version - new patch for GROMACS 2024 + - Small optimization of \ref COORDINATION and related collective variables (\issue{1096}).