clflush() in i3 or i7 processors

后端 未结 1 1571
心在旅途
心在旅途 2021-01-15 21:35

Is it possible to use the clflush instruction/function in i3/i7 processors to the flush the cache and check if the cache is empty or not?? If so - please suggest a correct f

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-15 22:03

    rdtsc isn't a serializing instruction, as such the measurement is not accurate. As a quick hack you can insert a cpuid call, taking care to update the clobber list too:

    asm volatile ("cpuid; rdtsc" : "=a" (a), "=d" (d) : : "ebx", "ecx");
    

    At least for me, that changed the output to match expectations.

    0 讨论(0)
提交回复
热议问题