Software Tuning, Performance Optimization & Platform Monitoring
Discussion regarding monitoring and software tuning methodologies, Performance Monitoring Unit (PMU) of Intel microprocessors, and platform updating.

[PCM] Measuring memory traffic, good practice ?

Jeremie_Lagraviere
472 Views

Hi everyone, 

In a very simple code, these dayz, I am measuring the memory traffic, and I would like to be sure that my code is correct, and delivers relatively accurate results:

int main(void)                                    
{
	PCM * m = PCM::getInstance();
	if (m->program() != PCM::Success)
	{
		cout << "Intel PCM does not Work";
		exit(0);
	}

	SystemCounterState before_sstate = getSystemCounterState();

	//some code to measure

	SystemCounterState after_sstate = getSystemCounterState();

	cout << "Bytes read: ";
	cout << getBytesReadFromMC(before_sstate,after_sstate) / double(1024ULL * 1024ULL * 1024ULL) << endl;


	printf("done !");
	m->cleanup();
	exit(EXIT_SUCCESS);
}

Also, I would like to know if there is cleaner way to end my Intel PCM code ? I ask this, because sometimes I have to reset the PMU by calling (for instance), pcm.x -r

Thanks in advance for your help :)

0 Kudos
3 Replies
Roman_D_Intel
Employee
472 Views

Hi Jeremie,

the way you end PCM measurement looks clean. Sometimes other programs (not PCM) using performance counters that run in parallel may disturb your measurements. Are you using Linux? An example of such program is Linux perf. However, PCM can be compiled in a mode that uses Linux perf to program core performance counters, this will avoid possible collisions. Uncomment "#CXXFLAGS += -DPCM_USE_PERF" in the Makefile to enable this mode. 

Best regards,

Roman

0 Kudos
Jeremie_Lagraviere
472 Views

Thanks for your reply :)

So, if I am using Linux, it is more accurate to use Intel PCM compiled with the DPCM_USE_PERF ?

Other question:

In my code, above, what about the accuracy ? I mean, what about the sampling rate, etc.

I did not specify anything in the code about the sampling rate, is it normal ? what is the default sampling rate of Intel PCM ?

0 Kudos
Roman_D_Intel
Employee
472 Views

yes, please use PCM_USE_PERF.

PCM does *NOT* use sampling. It uses "counting mode". That means the counters are read once in each getSystemCounterState call and then the difference between their values is computed.

Roman

0 Kudos
Reply