#include <gpr/linalg/CanonicalTriangular.h>
|
| static double * | acquire (std::size_t bytes) |
| static void | release (double *storage, std::size_t bytes) noexcept |
64-byte aligned blocks reused by the tile kernels of one thread. A tile copy is taken at every kernel call, and allocating each one costs about as much as the arithmetic of a small tile, so released blocks return here and the next copy of at most that size reuses one.
Definition at line 134 of file CanonicalTriangular.h.
◆ acquire()
| double * gpr::linalg::canonical::AlignedBlockCache::acquire |
( |
std::size_t | bytes | ) |
|
|
inlinestatic |
Definition at line 136 of file CanonicalTriangular.h.
137 {
138 auto& blocks = instance().blocks_;
139 auto best = blocks.end();
140 for (auto it = blocks.begin(); it != blocks.end(); ++it)
141 if (it->first >= bytes &&
142 (best == blocks.end() || it->first < best->first))
143 best = it;
144 if (best != blocks.end()) {
145 double* storage = best->second;
146 blocks.erase(best);
147 return storage;
148 }
149 return static_cast<double*>(std::aligned_alloc(64, bytes));
150 }
◆ release()
| void gpr::linalg::canonical::AlignedBlockCache::release |
( |
double * | storage, |
|
|
std::size_t | bytes ) |
|
inlinestaticnoexcept |
Definition at line 151 of file CanonicalTriangular.h.
152 {
153 if (storage == nullptr) return;
154 auto& blocks = instance().blocks_;
155 if (blocks.size() >= max_blocks) {
156
157 auto smallest = blocks.begin();
158 for (auto it = blocks.begin(); it != blocks.end(); ++it)
159 if (it->first < smallest->first) smallest = it;
160 if (smallest->first >= bytes) {
161 std::free(storage);
162 return;
163 }
164 std::free(smallest->second);
165 blocks.erase(smallest);
166 }
167 blocks.emplace_back(bytes, storage);
168 }
The documentation for this class was generated from the following file: