[botan-devel] Set the cpu speed in the environment or command line for ./botan speed

Jack Lloyd jack at randombit.net
Thu Mar 8 08:48:04 EST 2018


On Thu, Mar 08, 2018 at 12:52:16PM +0000, Uri Blumenthal wrote:
> I'd like to see something like --cpu-clock-speed, instead of or in addition to the --cpu-clock-ratio.
> 
> Reason: for some CPUs one *cannot accurately* measure their clocks, so an approach that requires knowing *both* the measured and the claimed clocks is bound to fail. Which is why what @noloader is asking for makes perfect sense.

I am not understanding how a specified clock speed would be at all
useful.

speed measures intervals based on wall time (whatever clock_gettime or
std::chrono::system_clock returns). Whenever a timer starts or stops,
it also gets the value of the cycle counter (if it is available). So
if initial cycle counter was C1 and finish cycle counter was C2, and
our interval was (wall clock) 1 second, then we know the clock ticks
at (C2-C1) Hz.

So the only question would be, if the clocks Hz matches the "clock
speed" of the machine, ie the rate of instruction dispatch. That just
affects reporting, where we convert "cycle counts as the machine
reports them" to "cycles as you the human expect them to be on this
machine". Which is what the ratio is for.

Imagine having --cpu-clock-speed instead of a ratio. Say the user sets
it to 1000 (ie the CPU clock ticks 1000 times per second).  Again we
measure a 1 second wall clock time interval. We find the cycle counter
had values C1 at start and C2 at end. Say they had values 500 and
2000. Then we know (as with prior) that the clock ticks at 1500 times
per second. But the user has claimed it ticks at 1000 times per
second. Which would imply that 1.5 seconds had passed, instead of the
1 second we measured on the clock. I don't see what one could do at
this point besides spit out an error since obviously something is
incorrect.

Now, something like --cpu-clock-speed would be very useful *IF* our
native measurement of operations was in cycles, and then we were
converting that to time intervals. But the speed util doesn't work
that way.

Maybe I'm missing something, if so let me know!

Jack



More information about the botan-devel mailing list