Skip to content

Commit

Permalink
First step in removing old implementation of derivatives calculated i…
Browse files Browse the repository at this point in the history
…n forward loop
  • Loading branch information
Gareth Aneurin Tribello committed Sep 12, 2024
1 parent 9d4c4e5 commit 6ca7a9a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
12 changes: 2 additions & 10 deletions src/core/ActionWithVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ void ActionWithVector::runAllTasks() {
}
// Get the total number of streamed quantities that we need
unsigned nquants=0, nmatrices=0, maxcol=0;
getNumberOfStreamedQuantities( getLabel(), nquants, nmatrices, maxcol );
setupStreamedComponents( getLabel(), nquants, nmatrices, maxcol );
// Get size for buffer
unsigned bufsize=0; getSizeOfBuffer( nactive_tasks, bufsize );
if( buffer.size()!=bufsize ) buffer.resize( bufsize );
Expand Down Expand Up @@ -674,17 +674,9 @@ void ActionWithVector::getNumberOfTasks( unsigned& ntasks ) {
}

void ActionWithVector::setupStreamedComponents( const std::string& headstr, unsigned& nquants, unsigned& nmat, unsigned& maxcol ) {
for(unsigned i=0; i<getNumberOfArguments(); ++i) {
if( !getPntrToArgument(i)->ignoreStoredValue(headstr) ) { getPntrToArgument(i)->streampos=nquants; nquants++; }
}
for(int i=0; i<getNumberOfComponents(); ++i) { getPntrToComponent(i)->streampos=nquants; nquants++; }
}

void ActionWithVector::getNumberOfStreamedQuantities( const std::string& headstr, unsigned& nquants, unsigned& nmat, unsigned& maxcol ) {
setupStreamedComponents( headstr, nquants, nmat, maxcol );
if( action_to_do_after ) action_to_do_after->getNumberOfStreamedQuantities( headstr, nquants, nmat, maxcol );
}

void ActionWithVector::getSizeOfBuffer( const unsigned& nactive_tasks, unsigned& bufsize ) {
for(int i=0; i<getNumberOfComponents(); ++i) {
getPntrToComponent(i)->bufstart=bufsize;
Expand Down Expand Up @@ -816,7 +808,7 @@ bool ActionWithVector::checkForForces() {

// Now determine how big the multivalue needs to be
unsigned nquants=0, nmatrices=0, maxcol=0;
getNumberOfStreamedQuantities( getLabel(), nquants, nmatrices, maxcol );
setupStreamedComponents( getLabel(), nquants, nmatrices, maxcol );
// Recover the number of derivatives we require (this should be equal to the number of forces)
unsigned nderiv=0; getNumberOfStreamedDerivatives( nderiv, NULL );
if( !action_to_do_after && arg_deriv_starts.size()>0 ) {
Expand Down
6 changes: 2 additions & 4 deletions src/core/ActionWithVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ class ActionWithVector:
void gatherForces( const unsigned& i, const MultiValue& myvals, std::vector<double>& forces ) const ;
/// Get the size of the buffer array that holds the data we are gathering over the MPI loop
void getSizeOfBuffer( const unsigned& nactive_tasks, unsigned& bufsize );
/// Get the number of quantities in the stream
void getNumberOfStreamedQuantities( const std::string& headstr, unsigned& nquants, unsigned& nmat, unsigned& maxcol );
/// Get the number of stored values in the stream
bool getNumberOfStoredValues( Value* startat, unsigned& nvals, const unsigned& astart, const std::vector<Value*>& stopat );
/// Add this action to the recursive chain
Expand Down Expand Up @@ -110,8 +108,6 @@ class ActionWithVector:
void updateTaskListReductionStatus();
/// Run all calculations in serial
bool runInSerial() const ;
/// Get the list of tasks that are active
std::vector<unsigned>& getListOfActiveTasks( ActionWithVector* action );
/// Check if the arguments of this action depend on thearg
bool argumentDependsOn( const std::string& headstr, ActionWithVector* faction, Value* thearg );
/// This sets up the arguments at the start of the calculation
Expand Down Expand Up @@ -142,6 +138,8 @@ class ActionWithVector:
/// Return a pointer to the first action in the chain
const ActionWithVector* getFirstActionInChain() const ;
ActionWithVector* getFirstActionInChain();
/// Get the list of tasks that are active
virtual std::vector<unsigned>& getListOfActiveTasks( ActionWithVector* action );
/// This is overridden in ActionWithMatrix
virtual void getAllActionLabelsInMatrixChain( std::vector<std::string>& matchain ) const {}
/// Get the number of derivatives in the stream
Expand Down

0 comments on commit 6ca7a9a

Please sign in to comment.