Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some add-ons for potential application in the PEX context #1916

Merged
merged 13 commits into from
Nov 28, 2024
Merged
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