2

I am reading AMD and Intel manuals and find that when masked and unmasked exceptions coexist, the SIMD execution unit will give priority to the unmasked exceptions (before or after calculation) and then process the masked exceptions, but is it also to set the flag bit for unmasked exceptions first, and then set the flag bit for masked exceptions after the exception handler of #XM has resolved all unmasked exceptions? In this way, the exception handler of #XM only needs to resolve the unmasked exception reported by MXCSR.

Or the SIMD execution unit will give priority to setting the exception flags in MXCSR regardless of whether they are masked or not once it finds a floating-point exception, which will cause the #XM handler can check both the masked and unmasked flags in MXCSR, then directly correct the masked exception to avoid triggering the next time instruction is executed.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
ShelterRin
  • 183
  • 5
  • Have you tried it on any real hardware? Should be straightforward to create a test case, e.g. under Linux with a SIGFPE handler that prints or records the MXCSR state. Or even using a debugger to examine MXCSR at that point. (That's separate from figuring out if the manuals guarantee how it will work on other past / future CPUs, but finding it works one way would rule out any interpretation that says it can't, unless that's a CPU bug or a mistake in the test method.) – Peter Cordes Sep 23 '21 at 11:41
  • @PeterCordes Thank you very much for your order and attention. My computer is under repair and I have been unable to get out because of the virus... This problem was suddenly realized by me. If all the flags are really set at the same time, then the floating point exception Being masked doesn’t seem so important anymore. – ShelterRin Sep 23 '21 at 12:21
  • If the bits were set in two different steps, the CPU would have to keep track of the fact that it had set half the bits already and still needs to set the other half. But I am not aware of any such mechanism. All bits being set at once looks a lot more like what you would expect to happen. And I'm not sure what you mean by “process the masked exceptions.” Masked exceptions are not processed. That's the whole point of the exception mask. – fuz Sep 23 '21 at 12:47
  • @fuz Sorry for the inaccuracy of my word, this is the default response of the execution unit. It is true that this mechanism is not that important, but I wonder why this mask mechanism exists. For example, I mask a floating-point exception in the hope that the execution unit will use the default response without interrupting the instruction flow, but if the exception flag is set independently of the mask mechanism, I can handle both the mask exceptions and unmasked exceptions by a #XM, which is a bit of conflict with the response I hoped before. – ShelterRin Sep 23 '21 at 13:40
  • @臧御琛 The important part is that if only masked exceptions occur, no #XM is generated. This means you can *disable* floating point exceptions that you do not care about. Think about it like disabling interrupts. If you disable interrupts, the interrupt source still signals an interrupt, but the processor does not do anything with it. – fuz Sep 23 '21 at 14:31

0 Answers0