Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 3,078 of 4,675    |
|    aen@nospicedham.spamtrap.com to All    |
|    more cyles    |
|    23 Nov 17 00:56:50    |
      Hi!              Here is another timing exercise: This one tells me that to create one       permutation from 13! takes an average of 7 cycles. The algorithm is       again from Don Knuth's TAOCP Vol. 2.              Any disagreements?              .intel_syntax noprefix       # as -o posting.o posting.asm       # gcc -static -o posting posting.o       # ./posting gives the output: 7.070950 44030949650 6227020800       # time ./posting gives: real 0m12,992s user 0m12,956s sys 0m,000s       # bc -l       # 12.956*3400000000 gives: 44050400000       .macro TSCStart        rdtsc        shl rdx,32        or rax,rdx        push rax       .endm # TSCStart              .macro TSCEnd        rdtsc        shl rdx,32        or rax,rdx        sub rax,[rsp]        add rsp,8       .endm # TSCEnd               .data       count: .quad 0       format: .string "%f %llu %llu\n"               .text        .globl main        .type main,@function       main: ; _start: nop        sub rsp,8               TSCStart        mov rax,0x0706050403020100        mov rdx,0x0c0b0a0908        call xperm32        TSCEnd        mov rdx,[count]        cvtsi2sd xmm0,rax        cvtsi2sd xmm1,rdx        divsd xmm0,xmm1        mov rdi,offset format        mov rsi,rax        call printf              exit_ok:        xor rdi,rdi        mov rax,60        syscall              N = 13              # Calling sequence: call perm32       # Entry conditions: RDX:RAX = #...3210.       # Exit conditions: All permutations #...3210 are visited.        .balign 16        .type xperm32,@function       xperm32: movq xmm0,rax        movq xmm1,rdx        punpcklqdq xmm0,xmm1        jmp 2f       1:psrldq xmm0,(16-N)        por xmm0,xmm1       2:call visit        movdqa xmm1,xmm0        psrldq xmm1,(N-1)        pslldq xmm0,(17-N)        pshufd xmm7,xmm1,0b1001110        por xmm7,xmm1        movq rax,xmm7        test rax,rax        jnz 1b        mov rdx,1       3:movdqa xmm2,xmm0        psrldq xmm2,15        pslldq xmm0,1        movq rax,xmm2        mov rcx,rdx       4:pslldq xmm2,1        sub rcx,1        jnz 4b        por xmm1,xmm2        cmp rdx,rax        jnz 1b        add rdx,1        pshufd xmm7,xmm0,0b1001110        por xmm7,xmm0        movq rax,xmm7        test rax,rax        jnz 3b        ret               .balign 16        .type visit,@function       visit: inc qword ptr [count]        ret              .end       --       aon              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca