Bug 1073336 part 5 - Add AnimationPlayerCollection::PlayerUpdated; r=dbaron
[gecko.git] / tools / profiler / IntelPowerGadget.h
blob4a24215b629e4bd98860c16e2ba04d86ec0e177a
1 /*
2 * Copyright 2013, Intel Corporation
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * Author: Joe Olivas <joseph.k.olivas@intel.com>
19 #ifndef profiler_IntelPowerGadget_h
20 #define profiler_IntelPowerGadget_h
22 #ifdef _MSC_VER
23 typedef __int32 int32_t;
24 typedef unsigned __int32 uint32_t;
25 typedef __int64 int64_t;
26 typedef unsigned __int64 uint64_t;
27 #else
28 #include <stdint.h>
29 #endif
30 #include "prlink.h"
32 typedef int (*IPGInitialize) ();
33 typedef int (*IPGGetNumNodes) (int *nNodes);
34 typedef int (*IPGGetNumMsrs) (int *nMsr);
35 typedef int (*IPGGetMsrName) (int iMsr, wchar_t *szName);
36 typedef int (*IPGGetMsrFunc) (int iMsr, int *pFuncID);
37 typedef int (*IPGReadMSR) (int iNode, unsigned int address, uint64_t *value);
38 typedef int (*IPGWriteMSR) (int iNode, unsigned int address, uint64_t value);
39 typedef int (*IPGGetIAFrequency) (int iNode, int *freqInMHz);
40 typedef int (*IPGGetTDP) (int iNode, double *TDP);
41 typedef int (*IPGGetMaxTemperature) (int iNode, int *degreeC);
42 typedef int (*IPGGetThresholds) (int iNode, int *degree1C, int *degree2C);
43 typedef int (*IPGGetTemperature) (int iNode, int *degreeC);
44 typedef int (*IPGReadSample) ();
45 typedef int (*IPGGetSysTime) (void *pSysTime);
46 typedef int (*IPGGetRDTSC) (uint64_t *pTSC);
47 typedef int (*IPGGetTimeInterval) (double *pOffset);
48 typedef int (*IPGGetBaseFrequency) (int iNode, double *pBaseFrequency);
49 typedef int (*IPGGetPowerData) (int iNode, int iMSR, double *pResult, int *nResult);
50 typedef int (*IPGStartLog) (wchar_t *szFileName);
51 typedef int (*IPGStopLog) ();
53 #if defined(__x86_64__) || defined(__x86_64) || defined(_M_AMD64)
54 #define PG_LIBRARY_NAME "EnergyLib64"
55 #else
56 #define PG_LIBRARY_NAME "EnergyLib32"
57 #endif
60 class IntelPowerGadget
62 public:
64 IntelPowerGadget();
65 ~IntelPowerGadget();
67 // Fails if initialization is incomplete
68 bool Init();
70 // Returns the number of packages on the system
71 int GetNumberNodes();
73 // Returns the number of MSRs being tracked
74 int GetNumberMsrs();
76 // Given a node, returns the temperature
77 int GetCPUFrequency(int);
79 // Returns the TDP of the given node
80 double GetTdp(int);
82 // Returns the maximum temperature for the given node
83 int GetMaxTemp(int);
85 // Returns the current temperature in degrees C
86 // of the given node
87 int GetTemp(int);
89 // Takes a sample of data. Must be called before
90 // any current data is retrieved.
91 int TakeSample();
93 // Gets the timestamp of the most recent sample
94 uint64_t GetRdtsc();
96 // returns number of seconds between the last
97 // two samples
98 double GetInterval();
100 // Returns the base frequency for the given node
101 double GetCPUBaseFrequency(int node);
103 // Returns the combined package power for all
104 // packages on the system for the last sample.
105 double GetTotalPackagePowerInWatts();
106 double GetPackagePowerInWatts(int node);
108 // Returns the combined CPU power for all
109 // packages on the system for the last sample.
110 // If the reading is not available, returns 0.0
111 double GetTotalCPUPowerInWatts();
112 double GetCPUPowerInWatts(int node);
114 // Returns the combined GPU power for all
115 // packages on the system for the last sample.
116 // If the reading is not available, returns 0.0
117 double GetTotalGPUPowerInWatts();
118 double GetGPUPowerInWatts(int node);
120 private:
122 PRLibrary *libpowergadget;
123 IPGInitialize Initialize;
124 IPGGetNumNodes GetNumNodes;
125 IPGGetNumMsrs GetNumMsrs;
126 IPGGetMsrName GetMsrName;
127 IPGGetMsrFunc GetMsrFunc;
128 IPGReadMSR ReadMSR;
129 IPGWriteMSR WriteMSR;
130 IPGGetIAFrequency GetIAFrequency;
131 IPGGetTDP GetTDP;
132 IPGGetMaxTemperature GetMaxTemperature;
133 IPGGetThresholds GetThresholds;
134 IPGGetTemperature GetTemperature;
135 IPGReadSample ReadSample;
136 IPGGetSysTime GetSysTime;
137 IPGGetRDTSC GetRDTSC;
138 IPGGetTimeInterval GetTimeInterval;
139 IPGGetBaseFrequency GetBaseFrequency;
140 IPGGetPowerData GetPowerData;
141 IPGStartLog StartLog;
142 IPGStopLog StopLog;
144 int packageMSR;
145 int cpuMSR;
146 int freqMSR;
147 int tempMSR;
150 #endif // profiler_IntelPowerGadget_h