Floating Point ABI

Floating Point ABI

Hello

I noticed in the latest CilkPlus ABI specification (https://www.cilkplus.org/sites/default/files/open_specifications/CilkPlu...), it says that the caller to the library must set the floating point flags (top of page 8). This is what the LLVM implementation of CilkPlus and its runtime do, but the current Intel version of the run-time has the code to save the floating point status registers that is in LLVM's code generator and not the runtime from the LLVM repository. Please could you tell me whether:
a) The floating point status flags should be set/saved by the caller
b) The floating point status flags should be set/saved by the callee
c) There's something I've overlooked

The ABI says:
"/**

* Architecture

-

specific floating point state. mxcsr and fpcsr should be

* set when CILK_SETJMP is called in client code. Note that the Win64

* jmpbuf for the Intel64 architecture already contains this information

* so there is no need

to use these fields on that OS/architecture.

*/"

The Intel runtime has:

__asm__ ( "stmxcsr %0\n\t"
    "fnstcw %1" : : "m" ((sf).mxcsr), "m" ((sf).fpcsr));");
The LLVM runtime does not have this, but the CilkPlus specific file in the LLVM code generator has equivalent code.

 

Thanks

 

Nick Tomlinson

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

ABI V1 requires that the floating point state be preserved before the setjmp call. This allows us to restore it on a steal so that if some aspect of floating point handling has been changed we can handle it properly. Ideally the instructions to do this should be inlined by the compiler when it generates the setjmp call, as the Intel compiler does.

We added a function to save the floating point state for those cases where it's difficult to add the instructions. If that function is missing from the LLVM repository, we need to update that version. If you need a version immediately, you can use the latest version at https://www.cilkplus.org/download#runtime-sources . While it doesn't have the gmake files, it should be compatible with the version bundled with the LLVM distribution.

   - Barry

One more point.  I'm not sure if LLVM/CLang is generating ABI 0 or ABI 1 frames.  If it's generating ABI 0 frames, then it isn't required to save the floating point state, and in fact, there's nowhere to save it to.

On the other hand, if it is generating ABI 1 frames, and it's not saving the floating point state, the runtime will attempt to restore that state (which is random trash from the stack) and likely generate an error.

   - Barry

Leave a Comment

Please sign in to add a comment. Not a member? Join today