1a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Copyright (c) 2014, Intel Corporation 2a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// All rights reserved. 3a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// 4a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Redistribution and use in source and binary forms, with or without 5a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// modification, are permitted provided that the following conditions are 6a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// met: 7a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// 8a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// * Redistributions of source code must retain the above copyright 9a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// notice, this list of conditions and the following disclaimer. 10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// * Redistributions in binary form must reproduce the above 11a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// copyright notice, this list of conditions and the following disclaimer 12a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// in the documentation and/or other materials provided with the 13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// distribution. 14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// * Neither the name of Intel Corporation nor the names of its 15a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// contributors may be used to endorse or promote products derived from 16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// this software without specific prior written permission. 17a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// 18a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 30a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <Windows.h> 31a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)#include <string> 32a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 33a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGInitialize) (); 34a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetNumNodes) (int *nNodes); 35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetNumMsrs) (int *nMsr); 36a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetMsrName) (int iMsr, wchar_t *szName); 37a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetMsrFunc) (int iMsr, int *funcID); 38a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetIAFrequency) (int iNode, int *freqInMHz); 39a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetTDP) (int iNode, double *TDP); 40a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetMaxTemperature) (int iNode, int *degreeC); 41a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetTemperature) (int iNode, int *degreeC); 42a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGReadSample) (); 43a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetSysTime) (SYSTEMTIME *pSysTime); 44a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetRDTSC) (UINT64 *TSC); 45a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetTimeInterval) (double *offset); 46a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetBaseFrequency) (int iNode, double *baseFrequency); 47a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGGetPowerData) (int iNode, int iMSR, double *result, int *nResult); 48a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGStartLog) (wchar_t *szFileName); 49a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)typedef bool (*IPGStopLog) (); 50a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 51a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class CIntelPowerGadgetLib 52a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles){ 53a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)public: 54a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) CIntelPowerGadgetLib(void); 55a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) ~CIntelPowerGadgetLib(void); 56a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 57a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool IntelEnergyLibInitialize(void); 58a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetNumNodes(int * nNodes); 59a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetNumMsrs(int *nMsrs); 60a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetMsrName(int iMsr, wchar_t *szName); 61a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetMsrFunc(int iMsr, int *funcID); 62a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetIAFrequency(int iNode, int *freqInMHz); 63a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetTDP(int iNode, double *TDP); 64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetMaxTemperature(int iNode, int *degreeC); 65a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetTemperature(int iNode, int *degreeC); 66a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool ReadSample(); 67a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetSysTime(SYSTEMTIME *sysTime); 68a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetRDTSC(UINT64 *TSC); 69a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetTimeInterval(double *offset); 70a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetBaseFrequency(int iNode, double *baseFrequency); 71a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool GetPowerData(int iNode, int iMSR, double *results, int *nResult); 72a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool StartLog(wchar_t *szFilename); 73a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) bool StopLog(); 745f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) std::string GetLastError(); 75a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 76a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)private: 77a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGInitialize pInitialize; 78a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetNumNodes pGetNumNodes; 79a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetNumMsrs pGetNumMsrs; 80a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetMsrName pGetMsrName; 81a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetMsrFunc pGetMsrFunc; 82a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetIAFrequency pGetIAFrequency; 83a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetTDP pGetTDP; 84a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetMaxTemperature pGetMaxTemperature; 85a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetTemperature pGetTemperature; 86a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGReadSample pReadSample; 87a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetSysTime pGetSysTime; 88a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetRDTSC pGetRDTSC; 89a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetTimeInterval pGetTimeInterval; 90a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetBaseFrequency pGetBaseFrequency; 91a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGGetPowerData pGetPowerData; 92a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGStartLog pStartLog; 93a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) IPGStopLog pStopLog; 94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}; 95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles) 96