| 400 | |
| 401 | template <typename Opr> |
| 402 | Maybe<typename TimedProfiler<Opr>::Result> TimedProfiler<Opr>::profile( |
| 403 | const Param& param, double& timeout) { |
| 404 | mgb_assert(timeout >= 0); |
| 405 | if (!timeout) { |
| 406 | timeout = timeout_setting; |
| 407 | } else if (timeout_setting) { |
| 408 | timeout = std::min(timeout, timeout_setting); |
| 409 | } |
| 410 | param.actual_timeout = timeout ? timeout : std::numeric_limits<double>::infinity(); |
| 411 | auto res = sys::TimedFuncInvoker::ins().invoke( |
| 412 | AlgoChooserFuncId<Opr>::ID, TParam::from_pod(const_cast<Param&>(param)), |
| 413 | timeout); |
| 414 | if (res.valid()) |
| 415 | return res.val().template as_single_pod<Result>(); |
| 416 | return None; |
| 417 | } |
| 418 | |
| 419 | template <typename Opr> |
| 420 | void TimedProfiler<Opr>::prof_init_device(const TParam& raw_param) { |