Skip to content

Commit

Permalink
Clean up the vectorpool, no more than 4 vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
pghysels committed Jul 11, 2024
1 parent d64fa98 commit 32066e6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/misc/Tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,22 @@ namespace strumpack {
void restore(std::vector<scalar_t,NoInit<scalar_t>>& v) {
if (v.empty()) return;
#pragma omp critical
data_.push_back(std::move(v));
{
data_.push_back(std::move(v));
if (data_.size() > 4) {
// remove smallest
int pos = 0;
std::size_t smin = data_[0].size();
for (std::size_t i=1; i<data_.size(); i++) {
auto ps = data_[i].size();
if (ps < smin) {
pos = i;
smin = ps;
}
}
data_.erase(data_.begin()+pos);
}
}
}

#if defined(STRUMPACK_USE_GPU)
Expand Down

0 comments on commit 32066e6

Please sign in to comment.