8 ms·
I don't understand. Shouldn't Intel be using the CPUID feature detection system they created? https://software.intel.com/en-us/articles/how-to-detect-new-instr
by jchw 7y ago
I don't understand. Shouldn't Intel be using the CPUID feature detection system they created?
https://software.intel.com/en-us/articles/how-to-detect-new-instruction-support-in-the-4th-generation-intel-core-processor-family https://software.intel.com/en-us/articles/how-to-detect-new-...
They don't need to test to see if it works on AMD. The processor advertises it. In their own words:
> It is important to understand that a new instruction is supported on a particular processor only if the corresponding CPUID feature flag is set. Applications must not assume support of any instruction set extension simply based on, for example, checking a CPU model or family and must instead always check for _all_ the feature CPUID bits of the instructions being used.
Indeed, my 3900X has the AVX2 flag flipped. So why would it not get used?
I don't think the precision loss argument really holds water. If you can't trust their AVX2 implementation, why can you trust any other instruction on the CPU to not have similar problems?
Unless I am misunderstanding something, it really looks like they're not following their own advice and artificially limiting the use of AVX2 to only Intel processors.
edit: Also, we really have no reason to trust Intel's honesty. Don't forget:
https://web.archive.org/web/20110312082557/http://www.compilerreimbursementprogram.com/ https://web.archive.org/web/20110312082557/http://www.compil...
- creato 7y agoMany instructions (that likely see heavy use in MKL) are approximations, the exact implementation and behavior of these approximations varies across platforms (including possibly architecture versions). The docs you quoted describes the necessary conditions for using an instruction to avoid crashes/illegal instruction issues. That doesn't cover these kinds of more subtle differences that exist. For example, I just made a plot of |1/x - rcpps(x)|: https://snipboard.io/Rei74t.jpg https://snipboard.io/Rei74t.jpg
- jchw 7y agoI'm very much not buying it. Although of course an instruction for something like approximations can vary across different micro-architectures and vendors, there has to be some definition for what the baseline is. Without it, the instruction may as well output junk. Indeed, I just checked and Intel's "Intel 64 and IA-32 Architectures Software Developer’s Manual" contains a bound on the error of the approximation in rcpps: The relative error for this approximation is: |Relative Error| ≤ 1.5 ∗ 2^−12 In fact, the document goes on to further define a lot of the behavior of the instruction in edge cases. Because that's kind of important for an architecture. If the extended instruction set did different things on every different processor, it would be useless. So I don't think this is really the issue. I don't think Intel MKL defines what the error is for many operations, so it is presumably not defined, and therefore it'd be hard for AMD's implementation to run afoul. It's also not going to be reproducibility/consistency, since they cover this in a separate issue: https://software.intel.com/en-us/articles/consistency-of-floating-point-results-using-the-intel-compiler https://software.intel.com/en-us/articles/consistency-of-flo...
- creato 7y agoThat's the maximum error. The error is often much less than that (as the plot shows). Code might unintentionally be relying on the error being much smaller than the spec requires, and on another architecture, the instruction might not meet this (unintentional!) requirement. Of course an issue stemming from something like this is rare/unlikely. But Intel also can't assume that the consequences for a related error are small. It seems like most people commenting irately about this in this thread are hobbyists or are otherwise working on low consequence software. Yeah, for these uses, it would probably make sense for intel to just look at the CPUID and leave it at that. But they can't know that, and they aren't optimizing solely for these use cases.
- jchw 7y agoI am suggesting that if Intel does not care about their code running on AMD processors, then it should not arbitrarily change behavior based on the presence of the string “GenuineIntel.” End of story. But I suspect Intel does care, in the sense that they certainly care about how they perform and benchmark against AMD. Let’s put it another way. What happens if Intel enables AVX2 for AMD and it doesn’t work? 1. Precision is not as good as intel? 1.a. Many developers care and it impacts AMD negatively. (Probably nothing happens since nothing is actually broken per se.) 1.b. Few developers care and it suggests Intel is not optimizing for the best performance trade-off. 2. Programs using MKL crash on AMD processors. 2.a. There is a bug in MKL: it probably gets fixed with little fanfare. 2.b. There is a bug on AMD processors, and it probably gets fixed in microcode. 3. AMD processors produce wrong results. There seems like there can only be one outcome here, and it’s probably worse for AMD than Intel. The Intel FDIV bug proves that people take these things very seriously. At best it could be fixed in microcode, and at absolute worst AVX2 could be disabled entirely in an update. The best argument for why Intel would still rationally avoid AVX2 on AMD outside of the above is to ensure their customer’s code runs correctly on AMD processors. However, there’s still some problems: - They have to contend with their own processors, too. If they write code they know depends on non-public details of the architecture, they could very well break themselves. - What is the definition for “break?” Intel surely has test suites for their software, but just because the software’s precision may be worse (still pure conjecture) when running under AMD does not suggest it is broken. All we can say is that users may rely on the behavior of precision on their specific configuration, but the problem is that’s not specific to AMD. Intel alludes to the fact that precision can be different amongst Intel processors in several places on MKL’s documentation. Nothing stops someone from improperly relying on this. By playing fast and loose with specifying an architecture then writing software that disregards it, I’m not sure how defensible a position Intel is sitting in from pretty much any perspective. > “otherwise working on low consequence software” No offense but it is hard to respectfully respond to something like this, even though I know it wasn't directed at me personally. I hope you don’t think about coworkers with this mindset.
- tagrun 7y agoAnd how exactly does that plot show that AMD's AVX instructions are faulty?
- creato 7y agoIt doesn't. It shows that the behavior of instructions like this is very unpredictable and subtle, and that code using it that was tested on one processor might not behave the same on another processor. It doesn't mean one is faulty and the other is not.
- jchw 7y agoA processor would be faulty if the error or behavior fell outside of the architecture specification. The behavior is not unpredictable because the behavior is defined by a specification.
- tagrun 7y agoI completely disagree. Your plot doesn't show CPU instructions are unpredictable (which is not correct). Yes, IEEE floats are not the same as real numbers (which is what your plot is showing): they have inherent precision errors, and float operations are not even associative. That being said, IEEE floats are carefully and consistently defined, and are perfect predictable. The unpredictability you claim is not due to stochastic errors or faulty implementation of CPU vendors, they're a part of the IEEE definition and are deterministic.
- creato 7y agoThe '1/x' part of this experiment is described by an IEEE spec. The reciprocal instructions are not. This experiment doesn't cover the difference between theoretical real numbers and float computations, it's the difference between two different ways of working with floats. One of them is IEEE specified, the other is not. In practice, using these kinds of instructions (which are not specified by IEEE) can give massive performance advantages.
- 7y ago
- BeeOnRope 7y agoYour argument might be worth considering if Intel didn't use the same "cripple AMD" check across a lot of other libraries and their own compiler too - where there are no such "numerical approximation" concerns. They've been doing it long before MKL [1]. --- [1] https://www.agner.org/optimize/blog/read.php?i=49 https://www.agner.org/optimize/blog/read.php?i=49