Community
cancel
Showing results for 
Search instead for 
Did you mean: 
zhang_y_1
Beginner
81 Views

Error using svml in inline ASM

     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
81 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

Reply