Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Error using svml in inline ASM

zhang_y_1
Beginner
255 Views

     I try using __svml_sin2 in inline ASM like the way compiler does.  A code snippet as following,

     "vmovupd (%1), %%ymm0\n\t"
     "call __svml_sin4\n\t"
     "vmovupd %%ymm0, (%0)\n\t"
     "sub $1, %%rax\n\t"
     "jnz 3b\n\t"

 

    The program can build. But, the running output values are wrong.

    Then I use GDB to locate the problem. It seems that, the SVMLfunction __svml_sin4 uses the general registers rax,rbx,rcx,rdx and so on, without save the scene. So I want to save the registers modified by SVML myself. The problem is, I do not know exactly which registers are modified. Maybe different SVML function use different registers.

    So, anybody knows how to use the svml in inline assembly correctly? 

    thanks in advance for any answer.

0 Kudos
1 Reply
Georg_Z_Intel
Employee
255 Views

Hello,

you need to save the scratch registers before calling a subroutine. Please note that, depending on the OS and architecture you're using, there is a differentiation of registers:

  • scratch registers: Need to be saved by caller before calling
  • callee save registers: Need not to be saved by a caller (callee has liability to save those if touched)

Please see http://www.agner.org/optimize/calling_conventions.pdf (chapter Register usage).

Edit:
If you want to get rid of those duties, maybe using intrinsics would be a better choice as the compiler does the register magic for you. For more information, please see: http://software.intel.com/en-us/node/462664

Best regards,

Georg Zitzlsberger

0 Kudos
Reply