public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hubicka at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/108376] TSVC s1279 runs 40% faster with aocc than gcc at zen4
Date: Sat, 14 Jan 2023 22:30:56 +0000	[thread overview]
Message-ID: <bug-108376-4-NHQWBKal8A@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-108376-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108376

--- Comment #3 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
If I make the arrays random then GCC code is indeed faster:
#include <math.h>
#include <malloc.h>

typedef float real_t;
#define iterations 1000000
#define LEN_1D 32000
#define LEN_2D 256
real_t a[LEN_1D],b[LEN_1D],c[LEN_1D],d[LEN_1D],e[LEN_1D];
real_t aa[LEN_2D][LEN_2D];
real_t bb[LEN_2D][LEN_2D];
real_t cc[LEN_2D][LEN_2D];
real_t qq;
int
main(void)
{
//    reductions
//    if to max reduction

    real_t x;
    for (int i = 0; i < LEN_1D; i++)
    {
       a[i]=(rand() %5) - 3;
       b[i]=(rand() %6) - 3;
    }
    for (int nl = 0; nl < iterations; nl++) {
        for (int i = 0; i < LEN_1D; i++) {
            if (a[i] < (real_t)0.) {
                if (b[i] > a[i]) {
                    c[i] += d[i] * e[i];
                }
            }
        }
        //dummy(a, b, c, d, e, aa, bb, cc, 0.);
    }

    return x;
}

jh@alberti:~/tsvc/bin> ~/aocc-compiler-4.0.0/bin/clang -Ofast s1279.c
-march=native
s1279.c:23:14: warning: implicit declaration of function 'rand' is invalid in
C99 [-Wimplicit-function-declaration]
       a[i]=(rand() %5) - 3;
             ^
1 warning generated.
jh@alberti:~/tsvc/bin> time ./a.out

real    0m5.638s
user    0m5.636s
sys     0m0.000s
jh@alberti:~/tsvc/bin> ~/trunk-install/bin/gcc -Ofast s1279.c -march=native
s1279.c: In function 'main':
s1279.c:23:14: warning: implicit declaration of function 'rand'
[-Wimplicit-function-declaration]
   23 |        a[i]=(rand() %5) - 3;
      |              ^~~~
jh@alberti:~/tsvc/bin> time ./a.out

real    0m2.791s
user    0m2.790s
sys     0m0.000s


sorry for wrong code, just for reference the loop compiles as:
.L4:
        xorl    %eax, %eax
        .p2align 4
        .p2align 3
.L3:
        vmovaps a(%rax), %ymm2
        vmovaps b(%rax), %ymm3
        vmovaps c(%rax), %ymm6
        addq    $32, %rax
        vmovaps c-32(%rax), %ymm0
        vmovaps e-32(%rax), %ymm4
        vcmpps  $1, %ymm1, %ymm2, %k1
        vcmpps  $14, %ymm2, %ymm3, %k1{%k1}
        vfmadd231ps     d-32(%rax), %ymm4, %ymm0{%k1}
        vfmadd231ps     d-32(%rax), %ymm4, %ymm0
        vblendmps       %ymm0, %ymm6, %ymm0{%k1}
        vmovaps %ymm0, c-32(%rax)
        cmpq    $128000, %rax
        jne     .L3
        decl    %edx
        jne     .L4

  parent reply	other threads:[~2023-01-14 22:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11 18:56 [Bug middle-end/108376] New: " hubicka at gcc dot gnu.org
2023-01-11 20:21 ` [Bug middle-end/108376] " amonakov at gcc dot gnu.org
2023-01-12 10:34 ` rguenth at gcc dot gnu.org
2023-01-14 22:30 ` hubicka at gcc dot gnu.org [this message]
2024-02-09 13:47 ` rguenth at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-108376-4-NHQWBKal8A@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).