From: Richard Henderson <richard.henderson@linaro.org>
To: Stephen Long <steplong@quicinc.com>, qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, apazos@quicinc.com
Subject: Re: [PATCH] target/arm: Implement SVE2 FMMLA
Date: Tue, 21 Apr 2020 20:21:41 -0700 [thread overview]
Message-ID: <d6e4b681-751f-cc36-0453-38db6635c227@linaro.org> (raw)
In-Reply-To: <20200420151044.12186-1-steplong@quicinc.com>
On 4/20/20 8:10 AM, Stephen Long wrote:
> +#define DO_FP_MATRIX_MUL(NAME, TYPE, H) \
> +void HELPER(NAME)(void *vd, void *va, void *vn, void *vm, \
> + void *status, uint32_t desc) \
> +{ \
> + intptr_t s, i, j; \
> + intptr_t opr_sz = simd_oprsz(desc) / (sizeof(TYPE) >> 2); \
> + \
> + for (s = 0; s < opr_sz; ++s) { \
> + TYPE *n = vn + s * (sizeof(TYPE) >> 2); \
> + TYPE *m = vm + s * (sizeof(TYPE) >> 2); \
> + TYPE *a = va + s * (sizeof(TYPE) >> 2); \
> + TYPE *d = vd + s * (sizeof(TYPE) >> 2); \
> + \
> + for (i = 0; i < 1; ++i) { \
> + for (j = 0; j < 1; ++j) { \
> + TYPE addend = a[H(2*i + j)]; \
> + \
> + TYPE nn0 = n[H(2*i)]; \
> + TYPE mm0 = m[H(2*j)]; \
> + TYPE prod0 = TYPE##_mul(nn0, mm0, status); \
> + \
> + TYPE nn1 = n[H4(2*i + 1)]; \
> + TYPE mm1 = m[H4(2*j + 1)]; \
> + TYPE prod1 = TYPE##_mul(nn1, mm1, status); \
> + \
> + TYPE sum = TYPE##_add(prod0, prod1, status); \
> + d[H(2*i + j)] = TYPE##_add(sum, addend, status); \
> + } \
> + } \
This has a read-after-write problem, when D overlaps any of the inputs. You
need to read all of the inputs before writing anything.
It might be easiest to just unroll these two inner loops:
TYPE n00 = n[0], n01 = n[1], n10 = n[2], n11 = n[3];
TYPE m00 = m[0], m01 = m[1], m10 = m[2], m11 = m[3];
TYPE p0, p1;
// i = 0, j = 0
p0 = mul(n00, m00, status);
p1 = mul(n01, m01, status);
a[0] = add(a[0], add(p0, p1, status), status);
// i = 0, j = 1
p0 = mul(n00, m10, status);
p1 = mul(n01, m11, status);
a[1] = add(a[1], add(p0, p1, status), status);
...
r~
prev parent reply other threads:[~2020-04-22 3:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 15:10 [PATCH] target/arm: Implement SVE2 FMMLA Stephen Long
2020-04-22 3:21 ` Richard Henderson [this message]
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=d6e4b681-751f-cc36-0453-38db6635c227@linaro.org \
--to=richard.henderson@linaro.org \
--cc=apazos@quicinc.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=steplong@quicinc.com \
/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 NNTP newsgroup(s).