[dpdk-dev] Question regarding rte_rdtsc_precise()
Jun Han
junhanece at gmail.com
Mon Mar 24 22:03:55 CET 2014
I have a question regarding rte_rdtsc_precise() function. I was not getting
an expected number from the normal rte_rdtsc(), and hence changed to
rte_rdtsc_precise() function and am getting a different value, which seems
to be producing a number close to my expectation.
Q1. However, I wanted to ask if how I am using the function is correct. I
am attaching a code snippet below. Is this the correct way to use
rte_rdtsc_precise() or if I need other things (e.g., adding lfence before
and after for instance?)
begin = rte_rdtsc_precise();
.... do something...
total_time = rte_rdtsc_precise() - begin;
printf("%g cyc\n",(double)total_time);
Q2. Am I correct that the rte_rdtsc_precise() makes the rdtsc a serializing
instruction?
Q3. I found from some sources online that there needs to be about ~ 1000
cycles between consecutive rdtsc() calls to get a more accurate measurement
[1]. Is this true? If so, is this necessary for your rte_rdtsc_precise()?
[1] http://software.intel.com/en-us/forums/topic/305287
"For best results, make sure you have at least ~1,000 clocks worth of
instructions between consecutive rdtsc calls."
Thank you.
More information about the dev
mailing list