FAQ
Hi,
I haven't used assembly for a while, so it could be something obvious.
I want to create GO wrappers for SSE2 assembly instructions, see the
snippet below. PADDQ and PADDW instructions work fine but when I use PADDD
instruction build fails. What is causing the error?

TEXT ·AddLong2(SB),7,$0-48
     MOVUPD v1+0(FP), X0
     MOVUPD v2+16(FP), X1
     PADDQ X1, X0
     MOVUPD X0, ret+32(FP)
     RET

Thank you,
Serge

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dave Cheney at Dec 27, 2013 at 3:21 am

    On Fri, Dec 27, 2013 at 2:12 PM, wrote:
    Hi,
    I haven't used assembly for a while, so it could be something obvious.
    I want to create GO wrappers for SSE2 assembly instructions, see the snippet
    below. PADDQ and PADDW instructions work fine but when I use PADDD
    instruction build fails. What is causing the error?
    What is the error that you see ?

    Assembly instructions, especially the more esoteric SSE2 ones are
    added on an as needed basis, it is probable that this instruction is
    not known to the assembler.
    TEXT ·AddLong2(SB),7,$0-48
    MOVUPD v1+0(FP), X0
    MOVUPD v2+16(FP), X1
    PADDQ X1, X0
    MOVUPD X0, ret+32(FP)
    RET

    Thank you,
    Serge

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shkarupin at Dec 27, 2013 at 3:39 am
    Dave,
    Thank you. The error is very generic
    ./op_amd64.s:33 syntax error, last name: X1
    FAIL simd [build failed]
    Error: process exited with code 2.
    Line 33 is where instruction PADDD is. If I replace it with PADDQ/PADDW it
    builds fine.

    This snippet fails to build:
    TEXT ·AddInt4(SB),7,$0-48
         MOVUPD v1+0(FP), X0
         MOVUPD v2+16(FP), X1
         PADDD X1, X0
         MOVUPD X0, ret+32(FP)
         RET
    On Thursday, December 26, 2013 9:21:25 PM UTC-6, Dave Cheney wrote:

    On Fri, Dec 27, 2013 at 2:12 PM, <shka...@gmail.com <javascript:>>
    wrote:
    Hi,
    I haven't used assembly for a while, so it could be something obvious.
    I want to create GO wrappers for SSE2 assembly instructions, see the snippet
    below. PADDQ and PADDW instructions work fine but when I use PADDD
    instruction build fails. What is causing the error?
    What is the error that you see ?

    Assembly instructions, especially the more esoteric SSE2 ones are
    added on an as needed basis, it is probable that this instruction is
    not known to the assembler.
    TEXT ·AddLong2(SB),7,$0-48
    MOVUPD v1+0(FP), X0
    MOVUPD v2+16(FP), X1
    PADDQ X1, X0
    MOVUPD X0, ret+32(FP)
    RET

    Thank you,
    Serge

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dmitry Vyukov at Dec 27, 2013 at 5:52 am
    Just in case, if you need just a few of unsupported instructions you
    can code them directly in machine codes.
    For example:

    TEXT runtime<C2><B7>atomicload64(SB), NOSPLIT, $0-8
             MOVL 4(SP), BX
             MOVL 8(SP), AX
             // MOVQ (%EAX), %MM0
             BYTE $0x0f; BYTE $0x6f; BYTE $0x00
             // MOVQ %MM0, 0(%EBX)
             BYTE $0x0f; BYTE $0x7f; BYTE $0x03
             // EMMS
             BYTE $0x0F; BYTE $0x77
             RET

    However, I doubt that such fine-grained functions will give you
    speedup because of function call overhead.

    On Fri, Dec 27, 2013 at 7:39 AM, wrote:
    Dave,
    Thank you. The error is very generic
    ./op_amd64.s:33 syntax error, last name: X1
    FAIL simd [build failed]
    Error: process exited with code 2.
    Line 33 is where instruction PADDD is. If I replace it with PADDQ/PADDW it
    builds fine.

    This snippet fails to build:
    TEXT ·AddInt4(SB),7,$0-48
    MOVUPD v1+0(FP), X0
    MOVUPD v2+16(FP), X1
    PADDD X1, X0
    MOVUPD X0, ret+32(FP)
    RET
    On Thursday, December 26, 2013 9:21:25 PM UTC-6, Dave Cheney wrote:
    On Fri, Dec 27, 2013 at 2:12 PM, wrote:
    Hi,
    I haven't used assembly for a while, so it could be something obvious.
    I want to create GO wrappers for SSE2 assembly instructions, see the
    snippet
    below. PADDQ and PADDW instructions work fine but when I use PADDD
    instruction build fails. What is causing the error?
    What is the error that you see ?

    Assembly instructions, especially the more esoteric SSE2 ones are
    added on an as needed basis, it is probable that this instruction is
    not known to the assembler.
    TEXT ·AddLong2(SB),7,$0-48
    MOVUPD v1+0(FP), X0
    MOVUPD v2+16(FP), X1
    PADDQ X1, X0
    MOVUPD X0, ret+32(FP)
    RET

    Thank you,
    Serge

    --
    You received this message because you are subscribed to the Google
    Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an
    email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shkarupin at Dec 27, 2013 at 1:55 pm
    Makes sense, I'll do some benchmarks. Is there any way to force inlining?
    BTW is there a way to "query" for supported instructions, for example check
    if AVX is supported?
    Thanks!
    On Thursday, December 26, 2013 11:51:41 PM UTC-6, Dmitry Vyukov wrote:

    Just in case, if you need just a few of unsupported instructions you
    can code them directly in machine codes.
    For example:

    TEXT runtime<C2><B7>atomicload64(SB), NOSPLIT, $0-8
    MOVL 4(SP), BX
    MOVL 8(SP), AX
    // MOVQ (%EAX), %MM0
    BYTE $0x0f; BYTE $0x6f; BYTE $0x00
    // MOVQ %MM0, 0(%EBX)
    BYTE $0x0f; BYTE $0x7f; BYTE $0x03
    // EMMS
    BYTE $0x0F; BYTE $0x77
    RET

    However, I doubt that such fine-grained functions will give you
    speedup because of function call overhead.


    On Fri, Dec 27, 2013 at 7:39 AM, <shka...@gmail.com <javascript:>>
    wrote:
    Dave,
    Thank you. The error is very generic
    ./op_amd64.s:33 syntax error, last name: X1
    FAIL simd [build failed]
    Error: process exited with code 2.
    Line 33 is where instruction PADDD is. If I replace it with PADDQ/PADDW it
    builds fine.

    This snippet fails to build:
    TEXT ·AddInt4(SB),7,$0-48
    MOVUPD v1+0(FP), X0
    MOVUPD v2+16(FP), X1
    PADDD X1, X0
    MOVUPD X0, ret+32(FP)
    RET
    On Thursday, December 26, 2013 9:21:25 PM UTC-6, Dave Cheney wrote:
    On Fri, Dec 27, 2013 at 2:12 PM, wrote:
    Hi,
    I haven't used assembly for a while, so it could be something
    obvious.
    I want to create GO wrappers for SSE2 assembly instructions, see the
    snippet
    below. PADDQ and PADDW instructions work fine but when I use PADDD
    instruction build fails. What is causing the error?
    What is the error that you see ?

    Assembly instructions, especially the more esoteric SSE2 ones are
    added on an as needed basis, it is probable that this instruction is
    not known to the assembler.
    TEXT ·AddLong2(SB),7,$0-48
    MOVUPD v1+0(FP), X0
    MOVUPD v2+16(FP), X1
    PADDQ X1, X0
    MOVUPD X0, ret+32(FP)
    RET

    Thank you,
    Serge

    --
    You received this message because you are subscribed to the Google
    Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send
    an
    email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Konstantin Khomoutov at Dec 27, 2013 at 2:24 pm

    On Fri, 27 Dec 2013 05:55:02 -0800 (PST) shkarupin@gmail.com wrote:

    Makes sense, I'll do some benchmarks. Is there any way to force
    inlining? BTW is there a way to "query" for supported instructions,
    for example check if AVX is supported?
    I think the assembler's lexer is the place to look.
    In particular, in the code of Go 1.2, this is the lex.c file of the
    assembler targeting your platform (for instance, ${src}\cmd\8a\lex.c).
    Look for the "itab" symbol or just grep for "PUSH" or something like
    this.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Dmitry Vyukov at Dec 28, 2013 at 10:00 am

    On Fri, Dec 27, 2013 at 5:55 PM, wrote:
    Makes sense, I'll do some benchmarks. Is there any way to force inlining?
    Assembly/C functions are never inlined.
    BTW is there a way to "query" for supported instructions, for example check
    if AVX is supported?
    Use CPUID instruction. There must be an example somewhere in runtime
    related to hashing using new CPU instructions.
    Thanks!
    On Thursday, December 26, 2013 11:51:41 PM UTC-6, Dmitry Vyukov wrote:

    Just in case, if you need just a few of unsupported instructions you
    can code them directly in machine codes.
    For example:

    TEXT runtime<C2><B7>atomicload64(SB), NOSPLIT, $0-8
    MOVL 4(SP), BX
    MOVL 8(SP), AX
    // MOVQ (%EAX), %MM0
    BYTE $0x0f; BYTE $0x6f; BYTE $0x00
    // MOVQ %MM0, 0(%EBX)
    BYTE $0x0f; BYTE $0x7f; BYTE $0x03
    // EMMS
    BYTE $0x0F; BYTE $0x77
    RET

    However, I doubt that such fine-grained functions will give you
    speedup because of function call overhead.

    On Fri, Dec 27, 2013 at 7:39 AM, wrote:
    Dave,
    Thank you. The error is very generic
    ./op_amd64.s:33 syntax error, last name: X1
    FAIL simd [build failed]
    Error: process exited with code 2.
    Line 33 is where instruction PADDD is. If I replace it with PADDQ/PADDW
    it
    builds fine.

    This snippet fails to build:
    TEXT ·AddInt4(SB),7,$0-48
    MOVUPD v1+0(FP), X0
    MOVUPD v2+16(FP), X1
    PADDD X1, X0
    MOVUPD X0, ret+32(FP)
    RET
    On Thursday, December 26, 2013 9:21:25 PM UTC-6, Dave Cheney wrote:
    On Fri, Dec 27, 2013 at 2:12 PM, wrote:
    Hi,
    I haven't used assembly for a while, so it could be something
    obvious.
    I want to create GO wrappers for SSE2 assembly instructions, see the
    snippet
    below. PADDQ and PADDW instructions work fine but when I use PADDD
    instruction build fails. What is causing the error?
    What is the error that you see ?

    Assembly instructions, especially the more esoteric SSE2 ones are
    added on an as needed basis, it is probable that this instruction is
    not known to the assembler.
    TEXT ·AddLong2(SB),7,$0-48
    MOVUPD v1+0(FP), X0
    MOVUPD v2+16(FP), X1
    PADDQ X1, X0
    MOVUPD X0, ret+32(FP)
    RET

    Thank you,
    Serge

    --
    You received this message because you are subscribed to the Google
    Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send
    an
    email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send
    an
    email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shkarupin at Dec 28, 2013 at 5:52 pm
    Guys,
    Thank you! Per Dmitry's suggestion I ran some benchmarks, function call
    turned out to be very significant.
    On Saturday, December 28, 2013 3:59:52 AM UTC-6, Dmitry Vyukov wrote:

    On Fri, Dec 27, 2013 at 5:55 PM, <shka...@gmail.com <javascript:>>
    wrote:
    Makes sense, I'll do some benchmarks. Is there any way to force
    inlining?

    Assembly/C functions are never inlined.
    BTW is there a way to "query" for supported instructions, for example check
    if AVX is supported?
    Use CPUID instruction. There must be an example somewhere in runtime
    related to hashing using new CPU instructions.
    Thanks!
    On Thursday, December 26, 2013 11:51:41 PM UTC-6, Dmitry Vyukov wrote:

    Just in case, if you need just a few of unsupported instructions you
    can code them directly in machine codes.
    For example:

    TEXT runtime<C2><B7>atomicload64(SB), NOSPLIT, $0-8
    MOVL 4(SP), BX
    MOVL 8(SP), AX
    // MOVQ (%EAX), %MM0
    BYTE $0x0f; BYTE $0x6f; BYTE $0x00
    // MOVQ %MM0, 0(%EBX)
    BYTE $0x0f; BYTE $0x7f; BYTE $0x03
    // EMMS
    BYTE $0x0F; BYTE $0x77
    RET

    However, I doubt that such fine-grained functions will give you
    speedup because of function call overhead.

    On Fri, Dec 27, 2013 at 7:39 AM, wrote:
    Dave,
    Thank you. The error is very generic
    ./op_amd64.s:33 syntax error, last name: X1
    FAIL simd [build failed]
    Error: process exited with code 2.
    Line 33 is where instruction PADDD is. If I replace it with
    PADDQ/PADDW
    it
    builds fine.

    This snippet fails to build:
    TEXT ·AddInt4(SB),7,$0-48
    MOVUPD v1+0(FP), X0
    MOVUPD v2+16(FP), X1
    PADDD X1, X0
    MOVUPD X0, ret+32(FP)
    RET
    On Thursday, December 26, 2013 9:21:25 PM UTC-6, Dave Cheney wrote:
    On Fri, Dec 27, 2013 at 2:12 PM, wrote:
    Hi,
    I haven't used assembly for a while, so it could be something
    obvious.
    I want to create GO wrappers for SSE2 assembly instructions, see
    the
    snippet
    below. PADDQ and PADDW instructions work fine but when I use PADDD
    instruction build fails. What is causing the error?
    What is the error that you see ?

    Assembly instructions, especially the more esoteric SSE2 ones are
    added on an as needed basis, it is probable that this instruction is
    not known to the assembler.
    TEXT ·AddLong2(SB),7,$0-48
    MOVUPD v1+0(FP), X0
    MOVUPD v2+16(FP), X1
    PADDQ X1, X0
    MOVUPD X0, ret+32(FP)
    RET

    Thank you,
    Serge

    --
    You received this message because you are subscribed to the Google
    Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send
    an
    email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google
    Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it,
    send
    an
    email to golang-nuts...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 27, '13 at 3:12a
activeDec 28, '13 at 5:52p
posts8
users4
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase