public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "liuhongt at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/112325] Missed vectorization of reduction after unrolling Date: Tue, 27 Feb 2024 06:02:56 +0000 [thread overview] Message-ID: <bug-112325-4-L1LMIcsL4c@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-112325-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112325 --- Comment #9 from Hongtao Liu <liuhongt at gcc dot gnu.org> --- The original case is a little different from the one in PR. It comes from ggml #include <stdint.h> #include <string.h> typedef uint16_t ggml_fp16_t; static float table_f32_f16[1 << 16]; inline static float ggml_lookup_fp16_to_fp32(ggml_fp16_t f) { uint16_t s; memcpy(&s, &f, sizeof(uint16_t)); return table_f32_f16[s]; } typedef struct { ggml_fp16_t d; ggml_fp16_t m; uint8_t qh[4]; uint8_t qs[32 / 2]; } block_q5_1; typedef struct { float d; float s; int8_t qs[32]; } block_q8_1; void ggml_vec_dot_q5_1_q8_1(const int n, float * restrict s, const void * restrict vx, const void * restrict vy) { const int qk = 32; const int nb = n / qk; const block_q5_1 * restrict x = vx; const block_q8_1 * restrict y = vy; float sumf = 0.0; for (int i = 0; i < nb; i++) { uint32_t qh; memcpy(&qh, x[i].qh, sizeof(qh)); int sumi = 0; for (int j = 0; j < qk/2; ++j) { const uint8_t xh_0 = ((qh >> (j + 0)) << 4) & 0x10; const uint8_t xh_1 = ((qh >> (j + 12)) ) & 0x10; const int32_t x0 = (x[i].qs[j] & 0xF) | xh_0; const int32_t x1 = (x[i].qs[j] >> 4) | xh_1; sumi += (x0 * y[i].qs[j]) + (x1 * y[i].qs[j + qk/2]); } sumf += (ggml_lookup_fp16_to_fp32(x[i].d)*y[i].d)*sumi + ggml_lookup_fp16_to_fp32(x[i].m)*y[i].s; } *s = sumf; }
next prev parent reply other threads:[~2024-02-27 6:02 UTC|newest] Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-11-01 2:41 [Bug tree-optimization/112325] New: Missed vectorization after cunrolli wwwhhhyyy333 at gmail dot com 2023-11-01 2:46 ` [Bug tree-optimization/112325] " pinskia at gcc dot gnu.org 2023-11-02 9:51 ` [Bug tree-optimization/112325] Missed vectorization of reduction after unrolling rguenth at gcc dot gnu.org 2023-11-16 8:03 ` liuhongt at gcc dot gnu.org 2023-11-16 8:15 ` liuhongt at gcc dot gnu.org 2023-11-16 9:15 ` rguenth at gcc dot gnu.org 2023-11-17 6:19 ` pinskia at gcc dot gnu.org 2023-11-17 6:21 ` pinskia at gcc dot gnu.org 2023-11-20 2:52 ` cvs-commit at gcc dot gnu.org 2023-11-21 0:34 ` cvs-commit at gcc dot gnu.org 2024-02-27 6:02 ` liuhongt at gcc dot gnu.org [this message] 2024-02-27 6:13 ` liuhongt at gcc dot gnu.org 2024-02-27 7:26 ` liuhongt at gcc dot gnu.org 2024-02-27 7:53 ` rguenther at suse dot de 2024-02-27 7:58 ` rguenther at suse dot de 2024-02-28 7:26 ` liuhongt at gcc dot gnu.org 2024-02-28 8:23 ` rguenther at suse dot de 2024-02-28 8:26 ` liuhongt at gcc dot gnu.org 2024-05-30 5:39 ` cvs-commit at gcc dot gnu.org 2024-05-30 5:40 ` liuhongt at gcc dot gnu.org 2024-05-30 5:45 ` sjames 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-112325-4-L1LMIcsL4c@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: linkBe 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).