Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/db/db/db.pro
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ SOURCES = \
dbCommonReader.cc \
dbCompoundOperation.cc \
dbEdge.cc \
dbEdgeNeighborhood.cc \
dbEdgePair.cc \
dbEdgePairFilters.cc \
dbEdgePairRelations.cc \
Expand Down Expand Up @@ -119,6 +120,7 @@ SOURCES = \
gsiDeclDbCommonStreamOptions.cc \
gsiDeclDbCompoundOperation.cc \
gsiDeclDbEdge.cc \
gsiDeclDbEdgeNeighborhood.cc \
gsiDeclDbEdgePair.cc \
gsiDeclDbEdgePairs.cc \
gsiDeclDbEdgeProcessor.cc \
Expand Down Expand Up @@ -249,6 +251,7 @@ HEADERS = \
dbCommonReader.h \
dbCompoundOperation.h \
dbEdge.h \
dbEdgeNeighborhood.h \
dbEdgePair.h \
dbEdgePairFilters.h \
dbEdgePairRelations.h \
Expand Down
30 changes: 20 additions & 10 deletions src/db/db/dbCompoundOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ class DB_PUBLIC CompoundRegionOperationNode
virtual db::Coord computed_dist () const = 0;

virtual std::string generated_description () const;
virtual bool wants_caching () const { return true; }

private:
std::string m_description;
Expand All @@ -276,23 +277,32 @@ class DB_PUBLIC CompoundRegionOperationNode
{
// TODO: confine caching to those nodes which need it.

std::pair<bool, std::vector<std::unordered_set<TR> > *> cp = cache->get<TR> (this);
if (wants_caching ()) {

if (! cp.first) {
std::pair<bool, std::vector<std::unordered_set<TR> > *> cp = cache->get<TR> (this);

std::vector<std::unordered_set<TR> > uncached_results;
uncached_results.resize (results.size ());
if (! cp.first) {

do_compute_local (cache, layout, cell, interactions, uncached_results, proc);
std::vector<std::unordered_set<TR> > uncached_results;
uncached_results.resize (results.size ());

cp.second->swap (uncached_results);
do_compute_local (cache, layout, cell, interactions, uncached_results, proc);

}
cp.second->swap (uncached_results);

}

tl_assert (results.size () == cp.second->size ());
for (size_t r = 0; r < results.size (); ++r) {
results[r].insert ((*cp.second)[r].begin (), (*cp.second)[r].end ());
}

} else {

do_compute_local (cache, layout, cell, interactions, results, proc);

tl_assert (results.size () == cp.second->size ());
for (size_t r = 0; r < results.size (); ++r) {
results[r].insert ((*cp.second)[r].begin (), (*cp.second)[r].end ());
}

}
};

Expand Down
Loading
Loading