I'm working on an automatic instruction scheduler. I need the latencies of Pentium III, Pentium 4 and Althon XP instructions. What would be really cool is if I had some functions which could accurately approximate these numbers, so I don't need to hand-write tables with thousands of elements...

Does anyone know if such functions exist? For example with a good understanding of the mirco-instructions and the pipeline architecture I believe it must be possible to make good predictions.

Another option, which I think would be even better, is to actually measure them. This would immediately make it processor independent and future-proof. Any idea's what would be the best method to do this? What's worrying me most is that many instructions would just crash the program. Also, can I 'measure' what issue ports and execution units are used?
Posted on 2003-07-06 14:13:28 by C0D1F1ED
I solved part of the problem. What was giving me most trouble was the call instruction. Finally I found out I could measure its latency like this:

DD temp
mov temp, esp

call label1
call label2

mov esp, temp

But I can't figure out a way to test what issue ports and execution units are used which is processor independent...

Anyone done anything like this before?
Posted on 2003-07-08 11:32:17 by C0D1F1ED
Posted on 2003-07-08 18:25:15 by bitRAKE
YOU COULD Use rdtsc. that mesures in clock accuracy. now on older cpu 4 INC after another might take just 4 clocks other its 2 and others its 1, depends on the cpu, pipes. and there are so many combos. and stalls,mops, and bounderies. etc you would have to find a book the person who designed the cpu wrote in order to know every thing. however i think that rdtsc will work fine for you if you know what cpu yer on.
Posted on 2003-07-08 19:46:48 by Qages
I'm already using RDTSC, but what exactly am I measuring with that? Clock cycles, ok, but it's probably influenced by things like Hyper-Threading? So is there a better way of measuring latency and/or troughput? Can the MSR's tell me what execution unit is used? Thanks.
Posted on 2003-07-11 06:37:57 by C0D1F1ED

Are you using RDTSC correctly according to this link? Ratch

Posted on 2003-07-11 10:15:12 by Ratch