From da4c7e7ed675c3bf405668739c3012d140856109 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:34:42 +0200 Subject: Adding upstream version 126.0. Signed-off-by: Daniel Baumann --- tools/profiler/core/PowerCounters.h | 56 +++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 8 deletions(-) (limited to 'tools/profiler/core/PowerCounters.h') diff --git a/tools/profiler/core/PowerCounters.h b/tools/profiler/core/PowerCounters.h index 2fd8d5892c..df511e87ec 100644 --- a/tools/profiler/core/PowerCounters.h +++ b/tools/profiler/core/PowerCounters.h @@ -19,20 +19,57 @@ class ProcessPower; #if defined(GP_PLAT_amd64_darwin) class RAPL; #endif +#if defined(GP_PLAT_arm64_android) + +/* + * These declarations come from: + * https://cs.android.com/android/platform/superproject/main/+/main:external/perfetto/src/android_internal/power_stats.h;l=34-52;drc=1777bdef274bcfbccd4e6f8b6d00a1bac48a8645 + */ + +struct RailDescriptor { + // Index corresponding to the rail + uint32_t index; + // Name of the rail + char rail_name[64]; + // Name of the subsystem to which this rail belongs + char subsys_name[64]; + // Hardware sampling rate + uint32_t sampling_rate; +}; + +struct RailEnergyData { + // Index corresponding to RailDescriptor.index + uint32_t index; + // Time since device boot(CLOCK_BOOTTIME) in milli-seconds + uint64_t timestamp; + // Accumulated energy since device boot in microwatt-seconds (uWs) + uint64_t energy; +}; +bool GetRailEnergyData(RailEnergyData*, size_t* size_of_arr); +#endif class PowerCounters { public: -#if defined(_MSC_VER) || defined(GP_OS_darwin) || defined(GP_PLAT_amd64_linux) +#if defined(_MSC_VER) || defined(GP_OS_darwin) || \ + defined(GP_PLAT_amd64_linux) || defined(GP_PLAT_arm64_android) explicit PowerCounters(); +#else + explicit PowerCounters(){}; +#endif +#if defined(_MSC_VER) || defined(GP_PLAT_amd64_darwin) || \ + defined(GP_PLAT_arm64_android) ~PowerCounters(); +#else + ~PowerCounters() = default; +#endif +#if defined(_MSC_VER) || defined(GP_PLAT_amd64_darwin) || \ + defined(GP_PLAT_arm64_android) void Sample(); #else - explicit PowerCounters(){}; - ~PowerCounters(){}; void Sample(){}; #endif - using CountVector = mozilla::Vector; + using CountVector = mozilla::Vector, 4>; const CountVector& GetCounters() { return mCounters; } private: @@ -41,11 +78,14 @@ class PowerCounters { #if defined(_MSC_VER) mozilla::Vector> mPowerMeterDevices; #endif -#if defined(GP_PLAT_arm64_darwin) - mozilla::UniquePtr mProcessPower; -#endif #if defined(GP_PLAT_amd64_darwin) - RAPL* mRapl; + mozilla::UniquePtr mRapl; +#endif +#if defined(GP_PLAT_arm64_android) + void* mLibperfettoModule = nullptr; + decltype(&GetRailEnergyData) mGetRailEnergyData = nullptr; + mozilla::Vector mRailDescriptors; + mozilla::Vector mRailEnergyData; #endif }; -- cgit v1.2.3