Пример #1
0
    bool getCompressorShortedFault(void *pcm_pointer, int32_t *status) {
        PCM *module = (PCM *)pcm_pointer;
        bool value;

        *status = module->GetCompressorShortedFault(value);

        return value;
    }
Пример #2
0
    float getCompressorCurrent(void *pcm_pointer, int32_t *status) {
        PCM *module = (PCM *)pcm_pointer;
        float value;

        *status = module->GetCompressorCurrent(value);

        return value;
    }
Пример #3
0
    bool getCompressorCurrentTooHighStickyFault(void *pcm_pointer, int32_t *status) {
        PCM *module = (PCM *)pcm_pointer;
        bool value;

        *status = module->GetCompressorCurrentTooHighStickyFault(value);

        return value;
    }
Пример #4
0
    bool getClosedLoopControl(void *pcm_pointer, int32_t *status) {
        PCM *module = (PCM *)pcm_pointer;
        bool value;

        *status = module->GetClosedLoopControl(value);

        return value;
    }
Пример #5
0
    bool getPressureSwitch(void *pcm_pointer, int32_t *status) {
        PCM *module = (PCM *)pcm_pointer;
        bool value;

        *status = module->GetPressure(value);

        return value;
    }
Пример #6
0
    bool getCompressorNotConnectedStickyFault(void *pcm_pointer, int32_t *status) {
        PCM *module = (PCM *)pcm_pointer;
        bool value;

        *status = module->GetCompressorNotConnectedStickyFault(value);

        return value;
    }
Пример #7
0
int main(int argc, char** argv)
{
    // Args
    var arg(argc, argv);

    // Read the waveform from file
    PCM pcm;
    ind fi = arg.index("-f");
    var wav = fi ? arg[fi+1] : "arctic_a0001.wav";
    var a = pcm.read(wav);

    // Frame it
    int frameSize = 256;
    int framePeriod = 128;
    var f = pcm.frame(a, frameSize, framePeriod);

    // Window the frames
    var w = nuttall(frameSize);
    f *= w;

    // Choose the output type
    ind ti = arg.index("-t");
    var t = ti ? arg[ti+1] : "spec";
    var p;
    if (t == "spec")
    {
        // Fourier transform
        lube::DFT dft(frameSize);
        var s = dft(f);

        // Periodogram
        p = lube::norm(s);
    }
    else if (t == "ar")
    {
        // LP spectrum
        int order = arorder(pcm.rate());
        Autocorrelation ac(frameSize);
        var af = ac(f);
        Levinson ar(order);
        var lf = ar(af);
        Gain gain(order);
        var g = gain(af, lf);
        Spectrum s(order, 129);
        p = s(lf, g);
    }

    // Plot
    var gnu;
    gnu.push("plot \"-\" matrix with image");
    gnu.push(lube::log(p+1e-8));
    file gnuf("gnuplot");
    gnuf.write(lube::nil, gnu);

    return 0;
}
Пример #8
0
/**
 * \brief handles signals that lead to update of configuration
 * such as SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU
 */
void sigSTOP_handler(int signum)
{
    PCM *m = PCM::getInstance();
    int runState = m->getRunState();
    std::string state = (runState==1 ? "suspend" : "continue");
    std::cerr << "DEBUG: caught signal to " << state << " execution." << std::endl; // debug of signals only
    if(runState==1) {
    // stop counters and sleep... almost forever;
        m->setRunState(0);
        sleep(INT_MAX);
    } else {
    // resume
        m->setRunState(1);
        alarm(1);
    }
    return;
}
Пример #9
0
void pcmInit() {
  std::cout << "Initializing PCM" << std::endl;
  PCM* m = PCM::getInstance();
  m->disableJKTWorkaround();
  
  switch( m->program() ) { 
    case PCM::Success:
      std::cout << "PCM Initialized" << std::endl;
			return;
  
    case PCM::PMUBusy:
      std::cout << "PCM::PMU Busy!" << std::endl;
      m->resetPMU();
			return;
  
    default:
      return;
	}
}
Пример #10
0
int32_t initpcm() {

	int ret = -1;
	PCM *m = PCM::getInstance();

	PCM::CustomCoreEventDescription para[4];

	if (m != NULL) {
		para[0].event_number = MEM_UOP_RETIRED;
		para[0].umask_value = LOADS;

		para[1].event_number = MEM_LOAD_UOPS_RETIRED_EVENT;
		para[1].umask_value = L1_HIT;

		para[2].event_number = MEM_LOAD_UOPS_RETIRED_EVENT;
		para[2].umask_value = L2_HIT;

		para[3].event_number = MEM_LOAD_UOPS_RETIRED_EVENT;
		para[3].umask_value = LLC_HIT;

		ret = m->program(PCM::CUSTOM_CORE_EVENTS, para);
	}
	return ret;
}
Пример #11
0
int main(int argc, char * argv[])
{
    std::cout << "\n Intel(r) Performance Counter Monitor " << INTEL_PCM_VERSION << std::endl;
    std::cout << "\n Power Monitoring Utility\n Copyright (c) 2011-2012 Intel Corporation\n";
    
    int imc_profile = 0;
    int pcu_profile = 0;
    int delay = -1;
	char * ext_program = NULL;

	freq_band[0] = default_freq_band[0];
	freq_band[1] = default_freq_band[1];
	freq_band[2] = default_freq_band[2];


	int my_opt = -1;
	while ((my_opt = getopt(argc, argv, "m:p:a:b:c:")) != -1)
	{
		switch(my_opt)
		{
			case 'm':
				imc_profile = atoi(optarg);
				break;
			case 'p':
				pcu_profile = atoi(optarg);
				break;
			case 'a':
				freq_band[0] = atoi(optarg);
				break;
			case 'b':
				freq_band[1] = atoi(optarg);
				break;
			case 'c':
				freq_band[2] = atoi(optarg);
				break;
			default:
				print_usage(argv[0]);
				return -1;
		}
	}

	 if (optind >= argc)
	 {
		 print_usage(argv[0]);
		 return -1;
	 }

    delay = atoi(argv[optind]);
	if(delay == 0) 
		ext_program = argv[optind];
	else
		delay = (delay<0)?1:delay;

	#ifdef _MSC_VER
    // Increase the priority a bit to improve context switching delays on Windows
    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);

    TCHAR driverPath[1024];
    GetCurrentDirectory(1024, driverPath);
    wcscat(driverPath, L"\\msr.sys");

    // WARNING: This driver code (msr.sys) is only for testing purposes, not for production use
    Driver drv;
    // drv.stop();     // restart driver (usually not needed)
    if (!drv.start(driverPath))
    {
		std::cout << "Can not access CPU performance counters" << std::endl;
		std::cout << "You must have signed msr.sys driver in your current directory and have administrator rights to run this program" << std::endl;
        return -1;
    }
    #endif

    PCM * m = PCM::getInstance();
    m->disableJKTWorkaround();

    if(!(m->hasPCICFGUncore()))
    {
       std::cout <<"Unsupported processor model ("<<m->getCPUModel()<<"). Only models "<<PCM::JAKETOWN<<" (JAKETOWN), " << PCM::IVYTOWN<< " (IVYTOWN)  are supported."<< std::endl;
       return -1;
    }

    if(PCM::Success != m->programServerUncorePowerMetrics(imc_profile,pcu_profile,freq_band))
    {
	  #ifdef _MSC_VER
		std::cout << "You must have signed msr.sys driver in your current directory and have administrator rights to run this program" << std::endl;
      #elif defined(__linux__)
      std::cout << "You need to be root and loaded 'msr' Linux kernel module to execute the program. You may load the 'msr' module with 'modprobe msr'. \n";
      #endif
      return -1;
    }
    ServerUncorePowerState * BeforeState = new ServerUncorePowerState[m->getNumSockets()];
	ServerUncorePowerState * AfterState = new ServerUncorePowerState[m->getNumSockets()];
	uint64 BeforeTime = 0, AfterTime = 0;
    
    std::cout << std::dec << std::endl;
    std::cout.precision(2);
    std::cout << std::fixed;
    std::cout << "\nMC counter group: "<<imc_profile << std::endl;
    std::cout << "PCU counter group: "<<pcu_profile << std::endl; 
	if(pcu_profile == 0)
	   std::cout << "Freq bands [0/1/2]: "<<freq_band[0]*100 << " MHz; "<< freq_band[1]*100 << " MHz; "<<freq_band[2]*100 << " MHz; "<<std::endl; 
    if(!ext_program) 
		std::cout << "Update every "<<delay<<" seconds"<< std::endl;

    uint32 i = 0;

	BeforeTime = m->getTickCount();
    for(i=0; i<m->getNumSockets(); ++i)
      BeforeState[i] = m->getServerUncorePowerState(i); 
 
    while(1)
    {
      std::cout << "----------------------------------------------------------------------------------------------"<<std::endl;
      
	  #ifdef _MSC_VER
	  int delay_ms = delay * 1000;
	  // compensate slow Windows console output
	  if(AfterTime) delay_ms -= (int)(m->getTickCount() - BeforeTime);
	  if(delay_ms < 0) delay_ms = 0;
      #else
	  int delay_ms = delay * 1000;
      #endif

	  if(ext_program)
		MySystem(ext_program);
	  else
		MySleepMs(delay_ms);

	  AfterTime = m->getTickCount();
      for(i=0; i<m->getNumSockets(); ++i)
        AfterState[i] = m->getServerUncorePowerState(i);
     
	  std::cout << "Time elapsed: "<<AfterTime-BeforeTime<<" ms\n";
	  std::cout << "Called sleep function for "<<delay_ms<<" ms\n";
      for(uint32 socket=0;socket<m->getNumSockets();++socket)
      {
	for(uint32 port=0;port<m->getQPILinksPerSocket();++port)
	{
	  std::cout << "S"<<socket<<"P"<<port
	    << "; QPIClocks: "<< getQPIClocks(port,BeforeState[socket],AfterState[socket])
	    << "; L0p Tx Cycles: "<< 100.*getNormalizedQPIL0pTxCycles(port,BeforeState[socket],AfterState[socket])<< "%"
	    << "; L1 Cycles: "    << 100.*getNormalizedQPIL1Cycles(port,BeforeState[socket],AfterState[socket])<< "%"
	    << "\n";
	}
	for(uint32 channel=0;channel<m->getMCChannelsPerSocket();++channel)
	{
	  if(imc_profile <= 3 && imc_profile >= 0)
	  {
              std::cout << "S"<<socket<<"CH"<<channel <<"; DRAMClocks: "<< getDRAMClocks(channel,BeforeState[socket],AfterState[socket])
                 << "; Rank"<<getFirstRank(imc_profile)<<" CKE Off Residency: "<< std::setw(3) << 
				100.*getCKEOffResidency(channel,getFirstRank(imc_profile),BeforeState[socket],AfterState[socket])<<"%"
		<< "; Rank"<<getFirstRank(imc_profile)<<" CKE Off Average Cycles: "<< 
				getCKEOffAverageCycles(channel,getFirstRank(imc_profile),BeforeState[socket],AfterState[socket])
		<< "; Rank"<<getFirstRank(imc_profile)<<" Cycles per transition: "<< 
				getCyclesPerTransition(channel,getFirstRank(imc_profile),BeforeState[socket],AfterState[socket])
                << "\n";

              std::cout << "S"<<socket<<"CH"<<channel <<"; DRAMClocks: "<< getDRAMClocks(channel,BeforeState[socket],AfterState[socket])
                << "; Rank"<<getSecondRank(imc_profile)<<" CKE Off Residency: "<< std::setw(3) <<
			100.*getCKEOffResidency(channel,getSecondRank(imc_profile),BeforeState[socket],AfterState[socket])<<"%"
                << "; Rank"<<getSecondRank(imc_profile)<<" CKE Off Average Cycles: "<< 
			getCKEOffAverageCycles(channel,getSecondRank(imc_profile),BeforeState[socket],AfterState[socket])
                << "; Rank"<<getSecondRank(imc_profile)<<" Cycles per transition: "<< 
			getCyclesPerTransition(channel,getSecondRank(imc_profile),BeforeState[socket],AfterState[socket])
                << "\n";

               
	  } else if(imc_profile == 4)
	  {
	      std::cout << "S"<<socket<<"CH"<<channel
		<< "; DRAMClocks: "<< getDRAMClocks(channel,BeforeState[socket],AfterState[socket])
		<< "; Self-refresh cycles: "<< getSelfRefreshCycles(channel,BeforeState[socket],AfterState[socket])
		<< "; Self-refresh transitions: "<< getSelfRefreshTransitions(channel,BeforeState[socket],AfterState[socket])
		<< "\n";
	  }
	}
	    switch(pcu_profile)
        {
        case 0:
          std::cout << "S"<<socket
             << "; PCUClocks: "<< getPCUClocks(BeforeState[socket],AfterState[socket])
             << "; Freq band 0/1/2 cycles: "<< 100.*getNormalizedPCUCounter(1,BeforeState[socket],AfterState[socket])<<"%"
             << "; "<< 100.*getNormalizedPCUCounter(2,BeforeState[socket],AfterState[socket])<<"%"
             << "; "<< 100.*getNormalizedPCUCounter(3,BeforeState[socket],AfterState[socket])<<"%"
             << "\n";
			break;

		case 1:
          std::cout << "S"<<socket
             << "; PCUClocks: "<< getPCUClocks(BeforeState[socket],AfterState[socket])
             << "; core C0/C3/C6-state residency: "<< getNormalizedPCUCounter(1,BeforeState[socket],AfterState[socket])
             << "; "<< getNormalizedPCUCounter(2,BeforeState[socket],AfterState[socket])
             << "; "<< getNormalizedPCUCounter(3,BeforeState[socket],AfterState[socket])
             << "\n";
		  break;

		case 2:
          std::cout << "S"<<socket
             << "; PCUClocks: "<< getPCUClocks(BeforeState[socket],AfterState[socket])
             << "; Internal prochot cycles: "<< getNormalizedPCUCounter(1,BeforeState[socket],AfterState[socket])*100. <<" %"
             << "; External prochot cycles:" << getNormalizedPCUCounter(2,BeforeState[socket],AfterState[socket])*100. <<" %"
             << "; Thermal freq limit cycles:" << getNormalizedPCUCounter(3,BeforeState[socket],AfterState[socket])*100. <<" %"
             << "\n";
		  break;

		case 3:
          std::cout << "S"<<socket
             << "; PCUClocks: "<< getPCUClocks(BeforeState[socket],AfterState[socket])
             << "; Thermal freq limit cycles: "<< getNormalizedPCUCounter(1,BeforeState[socket],AfterState[socket])*100. <<" %"
             << "; Power freq limit cycles:" << getNormalizedPCUCounter(2,BeforeState[socket],AfterState[socket])*100. <<" %"
             << "; Clipped freq limit cycles:" << getNormalizedPCUCounter(3,BeforeState[socket],AfterState[socket])*100. <<" %"
             << "\n";
		  break;

		case 4:
          std::cout << "S"<<socket
             << "; PCUClocks: "<< getPCUClocks(BeforeState[socket],AfterState[socket])
             << "; OS freq limit cycles: "<< getNormalizedPCUCounter(1,BeforeState[socket],AfterState[socket])*100. <<" %"
             << "; Power freq limit cycles:" << getNormalizedPCUCounter(2,BeforeState[socket],AfterState[socket])*100. <<" %"
			 << "; Clipped freq limit cycles:" << getNormalizedPCUCounter(3,BeforeState[socket],AfterState[socket])*100. <<" %"
             << "\n";
		  break;
                case 5:
          std::cout << "S"<<socket
             << "; PCUClocks: "<< getPCUClocks(BeforeState[socket],AfterState[socket])
             << "; Frequency transition count: "<< getPCUCounter(1,BeforeState[socket],AfterState[socket]) <<" "
             << "; Cycles spent changing frequency: " << getNormalizedPCUCounter(2,BeforeState[socket],AfterState[socket])*100. <<" %"
             << "\n";
                  break;

        }

        std::cout << "S"<<socket
              << "; Consumed energy units: "<< getConsumedEnergy(BeforeState[socket],AfterState[socket])
              << "; Consumed Joules: "<< getConsumedJoules(BeforeState[socket],AfterState[socket])
			  << "; Watts: "<< 1000.*getConsumedJoules(BeforeState[socket],AfterState[socket])/double(AfterTime-BeforeTime)
              << "; Thermal headroom below TjMax: " << AfterState[socket].getPackageThermalHeadroom()
              << "\n";
        std::cout << "S"<<socket
              << "; Consumed DRAM energy units: "<< getDRAMConsumedEnergy(BeforeState[socket],AfterState[socket])
              << "; Consumed DRAM Joules: "<< getDRAMConsumedJoules(BeforeState[socket],AfterState[socket])
                          << "; DRAM Watts: "<< 1000.*getDRAMConsumedJoules(BeforeState[socket],AfterState[socket])/double(AfterTime-BeforeTime)
              << "\n";


      }
      std::swap(BeforeState,AfterState);
	  std::swap(BeforeTime,AfterTime);

	  if(ext_program)
	  {
		  std::cout << "----------------------------------------------------------------------------------------------"<<std::endl;
		  break;
	  }
    }

	delete [] BeforeState;
    delete [] AfterState;
}
Пример #12
0
PCM::PCM(const PCM& pcm)
  : functional::DirectAudio<PCM, sound::Sound>(pcm.a(), pcm.b(), pcm.settings()), _this(pcm._this) {}
Пример #13
0
    void setClosedLoopControl(void *pcm_pointer, bool value, int32_t *status) {
        PCM *module = (PCM *)pcm_pointer;

        *status = module->SetClosedLoopControl(value);
    }
Пример #14
0
    void clearAllPCMStickyFaults(void *pcm_pointer, int32_t *status) {
        PCM *module = (PCM *)pcm_pointer;

        *status = module->ClearStickyFaults();
    }
Пример #15
0
CoreCounterState getCoreCounterState(int32_t tid) {                                       
  PCM * inst = PCM::getInstance();
  CoreCounterState result;
  if (inst) result = inst->getCoreCounterState(tid);
  return result;
}