Skip to content

Commit

Permalink
Optimisations in adjacency matrix calculator
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth Aneurin Tribello authored and Gareth Aneurin Tribello committed Jul 10, 2024
1 parent b9b8969 commit d15c12f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/adjmat/AdjacencyMatrixBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ void AdjacencyMatrixBase::updateNeighbourList() {
}
threecells.buildCellLists( ltmp_pos2, threeblocks, getPbc() );
}
// And finally work out maximum number of columns to use
maxcol = nlist[0];
for(unsigned i=1; i<getConstPntrToComponent(0)->getShape()[0]; ++i) {
if( nlist[i]>maxcol ) maxcol = nlist[i];
}
}

void AdjacencyMatrixBase::getAdditionalTasksRequired( ActionWithVector* action, std::vector<unsigned>& atasks ) {
Expand All @@ -249,16 +254,6 @@ void AdjacencyMatrixBase::getAdditionalTasksRequired( ActionWithVector* action,
}
}

unsigned AdjacencyMatrixBase::getNumberOfColumns() const {
unsigned maxcol=nlist[0];
for(unsigned i=1; i<getConstPntrToComponent(0)->getShape()[0]; ++i) {
if( nlist[i]>maxcol ) maxcol = nlist[i];
}
// This triggers appropriate storage of symmetric matrices which can only have
// a maximumum of shape[1]-1 non-zero elements
return maxcol;
}

unsigned AdjacencyMatrixBase::retrieveNeighbours( const unsigned& current, std::vector<unsigned> & indices ) const {
unsigned natoms=nlist[current]; indices[0]=current;
unsigned lstart = getConstPntrToComponent(0)->getShape()[0] + current*(1+natoms_per_list); plumed_dbg_assert( nlist[lstart]==current );
Expand Down
6 changes: 6 additions & 0 deletions src/adjmat/AdjacencyMatrixBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class AdjacencyMatrixBase : public ActionWithMatrix {
LinkCells linkcells, threecells;
std::vector<unsigned> ablocks, threeblocks;
double nl_cut, nl_cut2;
unsigned maxcol;
unsigned nl_stride;
unsigned natoms_per_list;
std::vector<unsigned> nlist;
Expand Down Expand Up @@ -106,6 +107,11 @@ void AdjacencyMatrixBase::addBoxDerivatives( const Tensor& vir, MultiValue& myva
myvals.addDerivative( w_index, nbase+8, vir(2,2) );
}

inline
unsigned AdjacencyMatrixBase::getNumberOfColumns() const {
return maxcol;
}


}
}
Expand Down

1 comment on commit d15c12f

@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/ANGLES.tmp
Found broken examples in automatic/ANN.tmp
Found broken examples in automatic/CAVITY.tmp
Found broken examples in automatic/CLASSICAL_MDS.tmp
Found broken examples in automatic/CLUSTER_DIAMETER.tmp
Found broken examples in automatic/CLUSTER_DISTRIBUTION.tmp
Found broken examples in automatic/CLUSTER_PROPERTIES.tmp
Found broken examples in automatic/CONSTANT.tmp
Found broken examples in automatic/CONTACT_MATRIX.tmp
Found broken examples in automatic/CONTACT_MATRIX_PROPER.tmp
Found broken examples in automatic/COORDINATIONNUMBER.tmp
Found broken examples in automatic/DFSCLUSTERING.tmp
Found broken examples in automatic/DISTANCE_FROM_CONTOUR.tmp
Found broken examples in automatic/EDS.tmp
Found broken examples in automatic/EMMI.tmp
Found broken examples in automatic/ENVIRONMENTSIMILARITY.tmp
Found broken examples in automatic/FIND_CONTOUR.tmp
Found broken examples in automatic/FIND_CONTOUR_SURFACE.tmp
Found broken examples in automatic/FIND_SPHERICAL_CONTOUR.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.tmp
Found broken examples in automatic/FUNNEL_PS.tmp
Found broken examples in automatic/GHBFIX.tmp
Found broken examples in automatic/GPROPERTYMAP.tmp
Found broken examples in automatic/HBOND_MATRIX.tmp
Found broken examples in automatic/INCLUDE.tmp
Found broken examples in automatic/INCYLINDER.tmp
Found broken examples in automatic/INENVELOPE.tmp
Found broken examples in automatic/INTERPOLATE_GRID.tmp
Found broken examples in automatic/LOCAL_AVERAGE.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_SIMULATED_ANNEALING.tmp
Found broken examples in automatic/MAZE_STEERED_MD.tmp
Found broken examples in automatic/METATENSOR.tmp
Found broken examples in automatic/MULTICOLVARDENS.tmp
Found broken examples in automatic/OUTPUT_CLUSTER.tmp
Found broken examples in automatic/PAMM.tmp
Found broken examples in automatic/PCA.tmp
Found broken examples in automatic/PCAVARS.tmp
Found broken examples in automatic/PIV.tmp
Found broken examples in automatic/PLUMED.tmp
Found broken examples in automatic/PYCVINTERFACE.tmp
Found broken examples in automatic/PYTHONFUNCTION.tmp
Found broken examples in automatic/Q3.tmp
Found broken examples in automatic/Q4.tmp
Found broken examples in automatic/Q6.tmp
Found broken examples in automatic/QUATERNION.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_LINEAR_PROJ.tmp
Found broken examples in automatic/SIZESHAPE_POSITION_MAHA_DIST.tmp
Found broken examples in automatic/SPRINT.tmp
Found broken examples in automatic/TETRAHEDRALPORE.tmp
Found broken examples in automatic/TORSIONS.tmp
Found broken examples in automatic/WHAM_WEIGHTS.tmp
Found broken examples in AnalysisPP.md
Found broken examples in CollectiveVariablesPP.md
Found broken examples in MiscelaneousPP.md

Please sign in to comment.