如何确定SSE预取指令大小? [英] How to determine SSE prefetch instruction size?

查看:132
本文介绍了如何确定SSE预取指令大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用包含用于SSE预取指令的内联汇编的代码。预处理程序常数确定是否使用32、64或128字节预取的指令。该应用程序在各种平台上使用,到目前为止,我不得不在每种情况下都进行研究,这是给定CPU的最佳选择。我知道这是缓存行大小。是否可以自动获取此信息?

I am working with code which contains inline assembly for SSE prefetch instructions. A preprocessor constant determines whether the instructions for 32-, 64- or 128-bye prefetches are used. The application is used on a wide variety of platforms, and so far I have had to investigate in each case which is the best option for the given CPU. I understand that this is the cache line size. Is this information obtainable automatically? It doesn't seem to be explicitly present in /proc/cpuinfo.

推荐答案

我认为您的问题与此有关href = https://stackoverflow.com/questions/794632/programmatically-get-the-cache-line-size>问题个。我认为很明显-除非您可以依赖操作系统或库功能-您将要使用CPUID指令,但是问题就变成了您要查找的信息是什么。 -当然,AMD和Intel的实现无需达成共识。该页面建议使用Cpuid.1.EBX [15:8]( (例如BH),以便在Intel上查找并在AMD上运行80000005h。另外,在Intel上,CPUID.2 ...似乎包含相关信息,但解析所需的信息似乎很痛苦。

I think your question is related to this question or this one. I think it is clear that - unless you can rely on a OS or library-function - you will want to use the CPUID instruction, but the question then becomes exactly what information you are looking for. - And of course, AMD's and Intel's implementations don't need to agree. This page suggests using Cpuid.1.EBX[15:8] (i.e., BH) for finding out on Intel and function 80000005h on AMD. In addition, on Intel, CPUID.2... seems to contain the relevant information, but it looks like a real pain to parse out the desired information.

我认为,据我所读,AMD和Intel CPUID指令都将支持 CPUID.1.EBX [15:8] ,该指令将返回CLFLUSH指令使用的QUADWORDs中的一个高速缓存行的大小(并非在所有处理器上都存在,所以我不知道您是否总会在这里找到某些东西)。 因此,在执行CPUID.1之后,您必须将BH乘以8才能获得以字节为单位的高速缓存行大小。这取决于我的隐含假设(请问任何人都可以说它是否真的有效吗? ),对于CLFLUSH和PREFETCHh指令,一个缓存行大小的定义始终是相同的。

I think, from what I've read, both AMD and Intel CPUID instructions will support CPUID.1.EBX[15:8], which returns the size of one cache line in QUADWORDs as used by the CLFLUSH instruction (which isn't present on all processors, so I don't know whether you'll always find something there). So, after executing CPUID.1, you'd have to multiply BH by 8 to get the cache line size in bytes. This hinges on my implicit assumption (please can anyone say whether it is really valid?) that the definition of one cache line size is always the same for CLFLUSH and PREFETCHh instructions.

此外,英特尔的手册指出,PREFETCHh只是一个提示,但是,如果它预取任何内容,它将始终是32字节。

Also, Intel's manuals states that PREFETCHh is only a hint, but that, if it prefetches anything, it will always be a minimum of 32 bytes.

EDIT1:
关于PREFETCHh优化使用的另一个有用资源(即使没有直接回答您的问题)是英特尔的优化手册。 此处

这篇关于如何确定SSE预取指令大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆