| 128 | |
| 129 | template<GlobalSampler _gs, typename _DocIter> |
| 130 | void sampleGlobalLevel(ThreadPool* pool, _ModelState*, _RandGen* rgs, _DocIter first, _DocIter last) const |
| 131 | { |
| 132 | if (this->globalStep < this->burnIn || !this->optimInterval || (this->globalStep + 1) % this->optimInterval != 0) return; |
| 133 | |
| 134 | if (pool && pool->getNumWorkers() > 1) |
| 135 | { |
| 136 | std::vector<std::future<void>> res; |
| 137 | const size_t chStride = pool->getNumWorkers() * 8; |
| 138 | size_t dist = std::distance(first, last); |
| 139 | for (size_t ch = 0; ch < chStride; ++ch) |
| 140 | { |
| 141 | auto b = first, e = first; |
| 142 | std::advance(b, dist * ch / chStride); |
| 143 | std::advance(e, dist * (ch + 1) / chStride); |
| 144 | res.emplace_back(pool->enqueue([&, ch, chStride](size_t threadId, _DocIter b, _DocIter e) |
| 145 | { |
| 146 | for (auto doc = b; doc != e; ++doc) |
| 147 | { |
| 148 | updateBeta(*doc, rgs[threadId]); |
| 149 | } |
| 150 | }, b, e)); |
| 151 | } |
| 152 | for (auto& r : res) r.get(); |
| 153 | } |
| 154 | else |
| 155 | { |
| 156 | for (auto doc = first; doc != last; ++doc) |
| 157 | { |
| 158 | updateBeta(*doc, rgs[0]); |
| 159 | } |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | int restoreFromTrainingError(const exc::TrainingError& e, ThreadPool& pool, _ModelState* localData, _RandGen* rgs) |
| 164 | { |
nothing calls this directly
no test coverage detected