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
23 typedef __int32
int32_t;
24 typedef unsigned __int32
uint32_t;
25 typedef __int64
int64_t;
26 typedef unsigned __int64
uint64_t;
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"
56 #define PG_LIBRARY_NAME "EnergyLib32"
60 class IntelPowerGadget
67 // Fails if initialization is incomplete
70 // Returns the number of packages on the system
73 // Returns the number of MSRs being tracked
76 // Given a node, returns the temperature
77 int GetCPUFrequency(int);
79 // Returns the TDP of the given node
82 // Returns the maximum temperature for the given node
85 // Returns the current temperature in degrees C
89 // Takes a sample of data. Must be called before
90 // any current data is retrieved.
93 // Gets the timestamp of the most recent sample
96 // returns number of seconds between the last
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
);
122 PRLibrary
*libpowergadget
;
123 IPGInitialize Initialize
;
124 IPGGetNumNodes GetNumNodes
;
125 IPGGetNumMsrs GetNumMsrs
;
126 IPGGetMsrName GetMsrName
;
127 IPGGetMsrFunc GetMsrFunc
;
129 IPGWriteMSR WriteMSR
;
130 IPGGetIAFrequency GetIAFrequency
;
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
;
150 #endif // profiler_IntelPowerGadget_h