Skip to main content
Last updated December 22, 2011 15:09, by amreladawy
Feedicon  


Introduction

jPCM is based on Intel PCM C++ code. The currently used version is 1.7. PCM code is being slightly modified foe the following reasons:

  1. Get the code compiled (This was tired on ubuntu 11.10)
  2. Provide an easier way for integration. (The JNI interface is a separate C++ project named pcmJNI)


The changes are listed in the following sections. Each section represents a file within the PCM C++ code.

PCM_Win\windirver.h

Only line number 22 is modified to fix compilation error.

Old Line

  #include "cpucounters.h"

New Line

 #include "..\cpucounters.h"


cpucounters.cpp

Changes introduced in this file in order to propagate the error messages to be thornw as Java exception JpcmException. Currently PCM code prints out the errors on the console. In order to send these notifications back to pcmJNI these error messages are loaded into the member variable errorMessage.

Source Code (From line 621 to line 628)

        std::cerr << "Can not access CPUs Model Specific Registers (MSRs)." << std::endl;
        #ifdef _MSC_VER
        std::cerr << "You must have signed msr.sys driver in your current directory and have administrator rights to run this program." << std::endl;
        #else
        std::cerr << "Try to execute 'modprobe msr' as root user and then" << std::endl;
        std::cerr << "you also must have read and write permissions for /dev/cpu/*/msr devices (the 'chown' command can help)." << std::endl;

Modified Code (From line 623 to line 640)

 std::string temp =
 "Can not access CPUs Model Specific Registers (MSRs). ";
 errorMessage = temp;
 std::cerr << temp << std::endl;
 #ifdef _MSC_VER
 temp= "You must have signed msr.sys driver in your current directory and have administrator rights to run this program.";
 std::cerr << temp << std::endl;
 errorMessage= errorMessage+temp;
 #else
 std::cerr << temp << std::endl;
 temp = "Try to execute 'modprobe msr' as root user and then";
 errorMessage = errorMessage + temp;
 std::cerr << temp << std::endl;
 temp =
 "you also must have read and write permissions for /dev/cpu/*/msr devices (the 'chown' command can help).";
 errorMessage = errorMessage + temp;
 std::cerr << temp << std::endl;


Source Code (From line 703 to line 723)

Modified Code (From line 717 to line 743)


cpucounters.h

pcmJNI requires cpu info to be exposed from PCM code. in order to do that few getters are exposed to do so these lines are added in line 260 as following:

  int32 getCpuFamily();
  int32 getCpuModel();
  uint32 getCoreGenCounterNumMax();
  uint32 getCoreGenCounterNumUsed();
  uint32 getCoreGenCounterWidth();
  uint32 getCoreFixedCounterNumMax();
  uint32 getCoreFixedCounterNumUsed();
  uint32 getCoreFixedCounterWidth();
  uint32 getUncoreGenCounterNumMax();
  uint32 getUncoreGenCounterNumUsed();
  uint32 getUncoreGenCounterWidth();
  uint32 getUncoreFixedCounterNumMax();
  uint32 getUncoreFixedCounterNumUsed();
  uint32 getUncoreFixedCounterWidth();
  uint32 getPerfmonConfigAnythread();
  uint32 getPerfmonVersion();
  
  uint64 getQpiSpeed();


Also the line 411, the modifier protected is converted to public in order to expose the properties inside the BasicCounter. This is easier than creating getter methods.

Makefile

  1. The Makefile has been modified in order to fix build error on ubuntu. The option -lpthread is changed to -pthread and added whenever needed.
  2. New build target is added to create shared library to be used by pcmJNI and JpcmBean.jar
 
 
Close
loading
Please Confirm
Close