eGospodarka.pl
eGospodarka.pl poleca

eGospodarka.plGrupypl.comp.programmingIle cykli zajmuje mnożenie liczb 64-bitowych? › Re: Ile cykli zajmuje mnożenie liczb 64-bitowych?
  • X-Received: by 2002:a25:1c02:0:b0:b8e:e0db:5b9d with SMTP id
    c2-20020a251c02000000b00b8ee0db5b9dmr14816210ybc.12.1684156217472; Mon,
    15 May 2023 06:10:17 -0700 (PDT)
    X-Received: by 2002:a25:1c02:0:b0:b8e:e0db:5b9d with SMTP id
    c2-20020a251c02000000b00b8ee0db5b9dmr14816210ybc.12.1684156217472; Mon,
    15 May 2023 06:10:17 -0700 (PDT)
    Path: news-archive.icm.edu.pl!news.icm.edu.pl!newsfeed.pionier.net.pl!2.eu.feeder.erj
    e.net!feeder.erje.net!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.
    farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-
    me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google
    .com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
    Newsgroups: pl.comp.programming
    Date: Mon, 15 May 2023 06:10:17 -0700 (PDT)
    In-Reply-To: <u3t721$32043$2@dont-email.me>
    Injection-Info: google-groups.googlegroups.com; posting-host=92.67.160.10;
    posting-account=5sNFBgoAAAAxlae8lv99mPyGsDs6ynwB
    NNTP-Posting-Host: 92.67.160.10
    References: <9...@g...com>
    <u3o5jn$248lr$1@dont-email.me>
    <a...@g...com>
    <f...@g...com>
    <u3q9gj$2jdsa$1@dont-email.me>
    <c...@g...com>
    <u3t721$32043$2@dont-email.me>
    User-Agent: G2/1.0
    MIME-Version: 1.0
    Message-ID: <c...@g...com>
    Subject: Re: Ile cykli zajmuje mnożenie liczb 64-bitowych?
    From: "o...@g...com" <o...@g...com>
    Injection-Date: Mon, 15 May 2023 13:10:17 +0000
    Content-Type: text/plain; charset="UTF-8"
    Content-Transfer-Encoding: quoted-printable
    X-Received-Bytes: 2512
    Xref: news-archive.icm.edu.pl pl.comp.programming:215951
    [ ukryj nagłówki ]

    A gdyby użyć tego:

    https://godbolt.org

    Jak wrzucam sobie tam kod:

    #include <cstdint>

    inline uint64_t rotl(const uint64_t x, int k) {
    return (x << k) | (x >> (64 - k));
    }


    uint64_t s[2] = {1,2};

    uint64_t next(void) {
    const uint64_t s0 = s[0];
    uint64_t s1 = s[1];
    const uint64_t result = s0 + s1;

    s1 ^= s0;
    s[0] = rotl(s0, 24) ^ s1 ^ (s1 << 16); // a, b
    s[1] = rotl(s1, 37); // c

    return result;
    }

    To ma sens analiza tego:

    movq s(%rip), %rax
    movq s+8(%rip), %rsi
    movq %rax, %rdx
    movq %rax, %rcx
    addq %rsi, %rax
    xorq %rsi, %rdx
    rolq $24, %rcx
    movq %rdx, %rdi
    xorq %rdx, %rcx
    rorq $27, %rdx
    salq $16, %rdi
    movq %rdx, s+8(%rip)
    xorq %rdi, %rcx
    movq %rcx, s(%rip)
    ret

    Jak rozumiem wszystko to są standardowe nazwy instrukcji? Więc wystarczy zsumować ich
    cykle? Mogę założyć, że movq to 2 cykle, xorq to 1 cykl, salq to 1 cykl?

Podziel się

Poleć ten post znajomemu poleć

Wydrukuj ten post drukuj


Następne wpisy z tego wątku

Najnowsze wątki z tej grupy


Najnowsze wątki

Szukaj w grupach

Eksperci egospodarka.pl

1 1 1

Wpisz nazwę miasta, dla którego chcesz znaleźć jednostkę ZUS.

Wzory dokumentów

Bezpłatne wzory dokumentów i formularzy.
Wyszukaj i pobierz za darmo: