5#include "flutter/fml/platform/android/cpu_affinity.h"
8#include <sys/resource.h>
14#include "flutter/fml/logging.h"
27 std::vector<CpuIndexAndSpeed> cpu_speeds;
29 for (
auto i = 0u; i < cpu_count; i++) {
30 auto path =
"/sys/devices/system/cpu/cpu" + std::to_string(i) +
31 "/cpufreq/cpuinfo_max_freq";
33 if (speed.has_value()) {
34 cpu_speeds.push_back({.index = i, .speed = speed.value()});
42 auto count = std::thread::hardware_concurrency();
69 return sched_setaffinity(gettid(),
sizeof(set), &set) == 0;
A class that computes the correct CPU indices for a requested CPU affinity.
const std::vector< size_t > & GetIndices(CpuAffinity affinity) const
Return the set of CPU indices for the requested CPU affinity.
bool IsValid() const
The class is valid if it has more than one CPU index and a distinct set of efficiency or performance ...
#define FML_DCHECK(condition)
@ kEfficiency
Request CPU affinity for the efficiency cores.
std::optional< int64_t > ReadIntFromFile(const std::string &path)
static CPUSpeedTracker * gCPUTracker
std::optional< size_t > AndroidEfficiencyCoreCount()
Android specific implementation of EfficiencyCoreCount.
bool AndroidRequestAffinity(CpuAffinity affinity)
Android specific implementation of RequestAffinity.
std::once_flag gCPUTrackerFlag
void InitCPUInfo(size_t cpu_count)