| 200 | } |
| 201 | |
| 202 | const ActKernel* checked_act_kernel(Type act, Arith a) noexcept { |
| 203 | const Isa top = best_isa(); |
| 204 | for (int ii = (int) top; ii >= 0; --ii) { |
| 205 | const ActKernel* k = act_kernel(act, a, (Isa) ii); |
| 206 | if (k == nullptr) return nullptr; |
| 207 | Verdicts& vd = verdicts(); |
| 208 | const uint64_t kk = key(1, act, a, k->isa); |
| 209 | bool known = false, ok = false; |
| 210 | { |
| 211 | std::lock_guard<std::mutex> lk(vd.mu); |
| 212 | for (auto& e : vd.v) |
| 213 | if (e.first == kk) known = true, ok = e.second; |
| 214 | } |
| 215 | if (!known) { |
| 216 | std::string why; |
| 217 | ok = check_act(*k, &why); |
| 218 | if (!ok) std::fprintf(stderr, "strata: quant self-check failed, kernel dropped: %s\n", why.c_str()); |
| 219 | std::lock_guard<std::mutex> lk(vd.mu); |
| 220 | vd.v.emplace_back(kk, ok); |
| 221 | } |
| 222 | if (ok) return k; |
| 223 | ii = (int) k->isa; // continue below the failed kernel's level |
| 224 | } |
| 225 | return nullptr; |
| 226 | } |
| 227 | |
| 228 | } // namespace strata::quant |