| 554 | const std::string& CpuInfo::model_name() const { return impl_->model_name; } |
| 555 | |
| 556 | int64_t CpuInfo::CacheSize(CacheLevel level) const { |
| 557 | constexpr int64_t kDefaultCacheSizes[] = { |
| 558 | 32 * 1024, // Level 1: 32K |
| 559 | 256 * 1024, // Level 2: 256K |
| 560 | 3072 * 1024, // Level 3: 3M |
| 561 | }; |
| 562 | static_assert( |
| 563 | sizeof(kDefaultCacheSizes) / sizeof(kDefaultCacheSizes[0]) == kCacheLevels, ""); |
| 564 | |
| 565 | static_assert(static_cast<int>(CacheLevel::L1) == 0, ""); |
| 566 | const int i = static_cast<int>(level); |
| 567 | if (impl_->cache_sizes[i] > 0) return impl_->cache_sizes[i]; |
| 568 | if (i == 0) return kDefaultCacheSizes[0]; |
| 569 | // l3 may be not available, return maximum of l2 or default size |
| 570 | return std::max(kDefaultCacheSizes[i], impl_->cache_sizes[i - 1]); |
| 571 | } |
| 572 | |
| 573 | bool CpuInfo::IsSupported(int64_t flags) const { |
| 574 | return (impl_->hardware_flags & flags) == flags; |
no outgoing calls