Questions tagged [rdtsc]

RDTSC is the x86 read time stamp counter instruction.

RDTSC is the x86 read time stamp counter instruction often used for high resolution timing.

See How to Benchmark Code Execution Times on Intel® IA-32 and IA-64 Instruction Set Architectures.

Get CPU cycle count? has info on various caveats of using it: on modern x86, it measures reference cycles, not actual core clock cycles. (And also shows how to access it from C++.)

The earliest CPUs to support RDTSC had fixed clock frequency, and some OSes found it was more useful as a low-overhead time source time-of-day functions, so CPU vendors eventually changed it to be how it is now: a fixed-frequency nonstop counter.

It can be out-of-sync across different cores. (Some CPUs avoid that for cores in the same physical package.)

137 questions
0
votes
1 answer

Error: can't find a register in class 'AREG' while reloading ASM

When I have executed this code with b and c variables, then the program will execute but it generates no output. There is some logical error, which does not print the time in output. __inline__ uint64_t timestamp(void) { unsigned long a, b; …
Rahat Ali
  • 19
  • 3
0
votes
1 answer

The use of rdtsc() in my program to obtain the number of clock cycles for single- and double-word operations?

In theory the cost of double-word addition/subtraction is taken 2 times of a single-word. Similarly, the cost ratio of single-word multiplication to addition is taken as 3. I have written the following C program using GCC on Ubuntu LTS 14.04 to…
user110219
  • 153
  • 10
0
votes
1 answer

Can rdtsc be easily patched out?

Many, many, many programs created in the era just before multi-core processors, use the instruction rdtsc to get precise data. This is a serious problem in programs that are multi-threaded, as they might end with conflicting values, and many…
speeder
  • 6,197
  • 5
  • 34
  • 51
0
votes
0 answers

Using RDTSC (profiling) NASM syntax gives an increasing value everytime

I am trying to profile a 8086 code using NASM with AFD debugger. I am trying to use RDTSC(0x0f31) instruction , but values I obtain by subtracting new time stamp from the old one are quite huge and are always increasing . I don't know what the…
0
votes
2 answers

Delphi - join 2 integer in a Int64

I'm working with Delphi and Assembly, so, i had a problem. I used a instruction(RDTSC) in Assembly of getting a 64-bits read time-stamp, the instruction put the numbers separately in two registers EAX and EDX. But it's ok, i get it with Delphi…
Victor Melo
  • 188
  • 1
  • 13
0
votes
0 answers

rdtscp() without returning the core ID?

I was reading the following Q: Which inline assembly code is correct for rdtscp? where it describes the following C++ to call rdtscp: static inline uint64_t rdtscp( uint32_t & aux ) { uint64_t rax,rdx; asm volatile ( "rdtscp\n" : "=a" (rax),…
user997112
  • 29,025
  • 43
  • 182
  • 361
0
votes
2 answers

Equivalent of mkl_get_clocks_frequency() for non-intel compilers

I use _rdtsc() in Intel compilers to get time stamp counter. I use _rdtsc() in conjunction with mkl_get_clocks_frequency(), to convert time stamp counter readings to seconds. Both of them are specific to Intel compilers. While, I have an equivalent…
arbitUser1401
  • 575
  • 2
  • 8
  • 25
0
votes
1 answer

RDTSC on Intel Celeron 64-bit Assembly program

I wrote a small random digit program that makes use of RDTSC to give me the randomness. I wrote it on Linux Mint 17 using FASM. The problem is, it works perfectly on AMD FX 64bit PC but the exact piece of code fail (or hangs) on Intel Celeron…
royalfinest
  • 155
  • 1
  • 8
0
votes
1 answer

How to call two functions one after another with minimum delay?

I implemented a fast function which returns time (using rdtsc), let's call it fast_time(). I have for reference the original function which uses a system call, let's call it system_time(). My program uses fast_time() but in a separate thread I'm…
e271p314
  • 3,841
  • 7
  • 36
  • 61
0
votes
1 answer

How to reset the rdtsc when using in an assembly file. I need to read in the before and after clock cycle data

Does the rdtsc stop when it is used in the assembly file? Is there a flagged raised? And how do i reset it? I have read the first clock stamp into the rdx register. But when I try to print the clock cycle again after waiting for a few seconds it is…
0
votes
1 answer

rdtsc code that shows performance impacts from memory characterstics such as TLB miss

I was trying to understand rdtsc() and I came across the following code from http://www.mcs.anl.gov/~kazutomo/rdtsc.html.The text explaining the code reads "The next short benchmark code may show you some performance impacts from memory…
liv2hak
  • 14,472
  • 53
  • 157
  • 270
0
votes
2 answers

reading timestampcounter showing strange values

I have the following C file rdtsc.c that demonstrates the use of rdtsc() in C.I have conditional compile for both 64-bit versions and 32-bit versions. #include #ifdef X86_64 static inline unsigned long long tick() { unsigned long…
liv2hak
  • 14,472
  • 53
  • 157
  • 270
0
votes
2 answers

How can I count how many clock cycles it takes for the rdtsc instruction to execute?

I know that the unsigned long long gets stored in eax/edx but I'm wondering how can I find out how many clock cycles it takes to execute a single rdtsc instruction? EDIT: Does something like this work? .globl rdtsc rdtsc: rdtsc movl %eax,…
-1
votes
1 answer

RDTSC (profiling) NASM syntax

I want to calculate the clock cycles of CPU required to run my program using rdtsc instruction as it is required in my assignment. What should be the syntax to use rdtsc instructions in "AFD"? I'm using rdtsc instruction as it is but "AFD"…
-1
votes
1 answer

Alpha equivalent for x86's RDTSC?

I have following code which runs perfectly in x86/linux. I want to convert this code into ALPHA using gcc cross compiler. It is generating errors like the following: unknown register name 'eax' in 'asm' I couldnt find proper sources to do on my…
1 2 3
9
10