Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to write cpu clock prefetch code

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how to write cpu clock prefetch code". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to write cpu clock prefetch code".

Test the effect of prefetching and always check the effect with CPU. According to the experiment, it is found that the prefetching address works better at about ten lines of code before the address is used.

The code is as follows:

# include

# define MAX_LEN 1000000

Static inline void prefetchnta (void * addr) / / prefetch part

{

_ _ asm__ ("movl% 0,% eax":: "a" (addr))

_ _ asm__ (".byte 0x0f, 0x18, 0x00")

}

Inline unsigned long long GetCPUTickCount ()

{

Unsigned long high42 = 0

Unsigned long low32 = 0

_ _ asm__ ("RDTSC": "= a" (low32), "= d" (high42))

Unsigned long long counter = high42

Counter = (counter

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report