| 25 | } |
| 26 | |
| 27 | Path Context::GetRuntimeEnabledPaths() { |
| 28 | // This function should always return the same value on a given machine. |
| 29 | // When runtime_enabled_paths_ has its initial value kNone, it performs |
| 30 | // some platform detection to resolve it to specific Path values. |
| 31 | |
| 32 | // Fast path: already resolved. |
| 33 | if (runtime_enabled_paths_ != Path::kNone) { |
| 34 | return runtime_enabled_paths_; |
| 35 | } |
| 36 | |
| 37 | // Need to resolve now. Start by considering all paths enabled. |
| 38 | runtime_enabled_paths_ = kAllPaths; |
| 39 | |
| 40 | #if RUY_PLATFORM(ARM) |
| 41 | // Now selectively disable paths that aren't supported on this machine. |
| 42 | if ((runtime_enabled_paths_ & Path::kNeonDotprod) != Path::kNone) { |
| 43 | if (!DetectDotprod()) { |
| 44 | runtime_enabled_paths_ = runtime_enabled_paths_ ^ Path::kNeonDotprod; |
| 45 | // Sanity check. |
| 46 | RUY_DCHECK((runtime_enabled_paths_ & Path::kNeonDotprod) == Path::kNone); |
| 47 | } |
| 48 | } |
| 49 | #endif |
| 50 | |
| 51 | // Sanity check. We can't possibly have disabled all paths, as some paths |
| 52 | // are universally available (kReference, kStandardCpp). |
| 53 | RUY_DCHECK(runtime_enabled_paths_ != Path::kNone); |
| 54 | return runtime_enabled_paths_; |
| 55 | } |
| 56 | |
| 57 | } // namespace ruy |