From: David Hildenbrand <david@redhat.com>
To: Richard Henderson <rth@twiddle.net>,
Richard Henderson <richard.henderson@linaro.org>
Cc: Thomas Huth <thuth@redhat.com>,
qemu-s390x <qemu-s390x@nongnu.org>,
Cornelia Huck <cohuck@redhat.com>,
"qemu-devel@nongnu.org Developers" <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH v1 1/5] s390x/tcg: Implement VECTOR FIND ANY ELEMENT EQUAL
Date: Thu, 23 May 2019 14:59:08 +0200 [thread overview]
Message-ID: <968a70bb-c025-235f-2914-ecb4142ae79b@redhat.com> (raw)
In-Reply-To: <8ea05b5e-9d8d-f514-7336-8d7637188009@redhat.com>
On 23.05.19 14:34, David Hildenbrand wrote:
> On 23.05.19 14:27, Richard Henderson wrote:
>> On 5/23/19 3:50 AM, David Hildenbrand wrote:
>>> /*
>>> * Returns the number of bits composing one element.
>>> */
>>> static uint8_t get_element_bits(uint8_t es)
>>> {
>>> return (1 << es) * BITS_PER_BYTE;
>>> }
>>>
>>> /*
>>> * Returns the bitmask for a single element.
>>> */
>>> static uint64_t get_single_element_mask(uint8_t es)
>>> {
>>> return -1ull >> (64 - get_element_bits(es));
>>> }
>>>
>>> /*
>>> * Returns the bitmask for a single element (excluding the MSB).
>>> */
>>> static uint64_t get_single_element_lsbs_mask(uint8_t es)
>>> {
>>> return -1ull >> (65 - get_element_bits(es));
>>> }
>>>
>>> /*
>>> * Returns the bitmasks for multiple elements (excluding the MSBs).
>>> */
>>> static uint64_t get_element_lsbs_mask(uint8_t es)
>>> {
>>> return dup_const(es, get_single_element_lsbs_mask(es));
>>> }
>>>
>>> static int vfae(void *v1, const void *v2, const void *v3, bool in,
>>> bool rt, bool zs, uint8_t es)
>>> {
>>> const uint64_t mask = get_element_lsbs_mask(es);
>>> const int bits = get_element_bits(es);
>>> uint64_t a0, a1, b0, b1, e0, e1, t0, t1, z0, z1;
>>> uint64_t first_zero = 16;
>>> uint64_t first_equal;
>>> int i;
>>>
>>> a0 = s390_vec_read_element64(v2, 0);
>>> a1 = s390_vec_read_element64(v2, 1);
>>> b0 = s390_vec_read_element64(v3, 0);
>>> b1 = s390_vec_read_element64(v3, 1);
>>> e0 = 0;
>>> e1 = 0;
>>> /* compare against equality with every other element */
>>> for (i = 0; i < 64; i += bits) {
>>> t0 = i ? rol64(b0, i) : b0;
>>> t1 = i ? rol64(b1, i) : b1;
>>> e0 |= zero_search(a0 ^ t0, mask);
>>> e0 |= zero_search(a0 ^ t1, mask);
>>> e1 |= zero_search(a1 ^ t0, mask);
>>> e1 |= zero_search(a1 ^ t1, mask);
>>> }
>>
>> I don't see that this is doing what you want. You're shifting one element of B
>> down, but not broadcasting it so that it is compared against every element of A.
>>
>> I'd expect something like
>>
>> t0 = dup_const(es, b0 >> i);
>> t1 = dup_const(es, b1 >> i);
>>
>> (I also don't see what rol is getting you that shift doesn't.)
>
> Let's assume
>
> a0 = [0, 1, 2, 3]
> a1 = [4, 5, 6, 7]
>
> b0 = [8, 8, 8, 4]
> b1 = [8, 8, 8, 8]
>
> What I would check is
>
> First iteration
>
> a0 == [8, 8, 8, 4] -> no match
> a0 == [8, 8, 8, 8] -> no match
> a1 == [8, 8, 8, 4] -> no match
> a1 == [8, 8, 8, 8] -> no match
>
> Second iteration
>
> a0 == [8, 8, 4, 8] -> no match
> a0 == [8, 8, 8, 8] -> no match
> a1 == [8, 8, 4, 8]
> a1 == [8, 8, 8, 8] -> no match
>
> ...
>
> Last iteration
>
> a0 == [4, 8, 8, 8] -> no match
> a0 == [8, 8, 8, 8] -> no match
> a1 == [4, 8, 8, 8] -> match in first element
> a1 == [8, 8, 8, 8] -> no match
>
> What am i missing?
>
>
I guess I can simplify to
t0 = rol64(b0, i);
t1 = rol64(b1, i);
My approach: Compare all elements of B at a time
Your approach: Compare a single element of B at a time
If I'm not wrong, it boils down to to whether
rol64() or dup_const(es, b0 >> i) is faster ;)
--
Thanks,
David / dhildenb
next prev parent reply other threads:[~2019-05-23 13:22 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-15 20:31 [Qemu-devel] [PATCH v1 0/5] s390x/tcg: Vector Instruction Support Part 3 David Hildenbrand
2019-05-15 20:31 ` [Qemu-devel] [PATCH v1 1/5] s390x/tcg: Implement VECTOR FIND ANY ELEMENT EQUAL David Hildenbrand
2019-05-17 16:16 ` Richard Henderson
2019-05-20 9:51 ` David Hildenbrand
2019-05-22 11:01 ` David Hildenbrand
2019-05-22 11:09 ` Richard Henderson
2019-05-22 11:16 ` David Hildenbrand
2019-05-22 15:59 ` Richard Henderson
2019-05-22 18:16 ` David Hildenbrand
2019-05-22 18:46 ` Richard Henderson
2019-05-23 7:50 ` David Hildenbrand
2019-05-23 12:27 ` Richard Henderson
2019-05-23 12:34 ` David Hildenbrand
2019-05-23 12:59 ` David Hildenbrand [this message]
2019-05-23 13:50 ` Richard Henderson
2019-05-23 10:58 ` Alex Bennée
2019-05-15 20:31 ` [Qemu-devel] [PATCH v1 2/5] s390x/tcg: Implement VECTOR FIND " David Hildenbrand
2019-05-17 16:47 ` Richard Henderson
2019-05-17 17:42 ` Richard Henderson
2019-05-20 9:17 ` David Hildenbrand
2019-05-15 20:31 ` [Qemu-devel] [PATCH v1 3/5] s390x/tcg: Implement VECTOR FIND ELEMENT NOT EQUAL David Hildenbrand
2019-05-17 17:56 ` Richard Henderson
2019-05-20 9:48 ` David Hildenbrand
2019-05-15 20:31 ` [Qemu-devel] [PATCH v1 4/5] s390x/tcg: Implement VECTOR ISOLATE STRING David Hildenbrand
2019-05-17 18:20 ` Richard Henderson
2019-05-15 20:31 ` [Qemu-devel] [PATCH v1 5/5] s390x/tcg: Implement VECTOR STRING RANGE COMPARE David Hildenbrand
2019-05-17 18:37 ` Richard Henderson
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=968a70bb-c025-235f-2914-ecb4142ae79b@redhat.com \
--to=david@redhat.com \
--cc=cohuck@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=rth@twiddle.net \
--cc=thuth@redhat.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).