[PATCH] VP8 luma(16) inner-MB H/V loopfilter MMX/SSE2
Hi, as per $subj. All tested to be identical to C reference. If wanted, I can try to share parts of the filter code with the simple loopfilter, but I'm a little scared that it'll turn into massive spaghetti so I didn't do it yet. All speeds measured on a CoreDuo 2GHz, OSX10.6, gcc 4.2.1-5646 (Apple build). V loopfilter (this is the simple one, just loopfilter + store): mmxext: 638 cycles sse2: 612 mmx: 640 C: 4156 I.e. SIMD is 6.5-7x faster. You also notice that sse2 isn't that much faster, as was the case in previous optimization attempts for other functions also. On real SSE2 CPUs, this should be a lot faster than on my shitty CPU. H loopfilter (MMX/SSE2: 8x8/8x16 transpose, V loopfilter, 4x4 transpose+store) mmx: 844 cycles C: 3457 mmxext: 830 sse2: 948 You'll notice that the sse2 is significantly slower here, my rough guess is that this is because of my shitty CPU which pretty much emulates xmm-ops through mmx-ops, so it doesn't add a lot of benefit other than not having to setup the loop for doing the second 8 pixels, combined with the added complexity of a 8x16 transpose before the actual filter. I'm betting that on an actual sse2-supporting CPU (Jason?), this would still be faster, but we might want to put this under a FF_MM_SSE2_NOT_SHITTY flag or something along those lines. If you think my code is shitty, comments are welcome also. ;-). I'll be working on the MBedge luma loopfilter next, and will leave the chroma ones for last since I might change function prototypes a little... Ronald
On Sun, 11 Jul 2010, Ronald S. Bultje wrote:
You'll notice that the sse2 is significantly slower here, my rough guess is that this is because of my shitty CPU which pretty much emulates xmm-ops through mmx-ops, so it doesn't add a lot of benefit other than not having to setup the loop for doing the second 8 pixels, combined with the added complexity of a 8x16 transpose before the actual filter. I'm betting that on an actual sse2-supporting CPU (Jason?), this would still be faster, but we might want to put this under a FF_MM_SSE2_NOT_SHITTY flag or something along those lines. If you think my code is shitty, comments are welcome also. ;-).
Rather than special-casing most of the functions, we at x264 declared that Core1 doesn't have sse2, and changed the cpuid parser accordingly. If you want to support the few cases where sse2 is slightly faster than mmx, I recommend picking a different flag for that and applying it only when you've tested on Core1, so that FF_MM_SSE2 can be trusted to dwim in the usual case. --Loren Merritt
On Sun, Jul 11, 2010 at 04:52:04PM +0000, Loren Merritt wrote:
On Sun, 11 Jul 2010, Ronald S. Bultje wrote:
You'll notice that the sse2 is significantly slower here, my rough guess is that this is because of my shitty CPU which pretty much emulates xmm-ops through mmx-ops, so it doesn't add a lot of benefit other than not having to setup the loop for doing the second 8 pixels, combined with the added complexity of a 8x16 transpose before the actual filter. I'm betting that on an actual sse2-supporting CPU (Jason?), this would still be faster, but we might want to put this under a FF_MM_SSE2_NOT_SHITTY flag or something along those lines. If you think my code is shitty, comments are welcome also. ;-).
Rather than special-casing most of the functions, we at x264 declared that Core1 doesn't have sse2, and changed the cpuid parser accordingly. If you want to support the few cases where sse2 is slightly faster than mmx, I recommend picking a different flag for that and applying it only when you've tested on Core1, so that FF_MM_SSE2 can be trusted to dwim in the usual case.
--Loren Merritt
cpuid.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 7ba0916766645e2de9330e9ba8f30d815da14c91 cpuid.diff
do we have any float SSE2 code that this could affect negatively? if not iam ok with this patch [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
hi, On Jul 11, 2010, at 12:59 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Sun, Jul 11, 2010 at 04:52:04PM +0000, Loren Merritt wrote:
On Sun, 11 Jul 2010, Ronald S. Bultje wrote:
You'll notice that the sse2 is significantly slower here, my rough guess is that this is because of my shitty CPU which pretty much emulates xmm-ops through mmx-ops, so it doesn't add a lot of benefit other than not having to setup the loop for doing the second 8 pixels, combined with the added complexity of a 8x16 transpose before the actual filter. I'm betting that on an actual sse2-supporting CPU (Jason?), this would still be faster, but we might want to put this under a FF_MM_SSE2_NOT_SHITTY flag or something along those lines. If you think my code is shitty, comments are welcome also. ;-).
Rather than special-casing most of the functions, we at x264 declared that Core1 doesn't have sse2, and changed the cpuid parser accordingly. If you want to support the few cases where sse2 is slightly faster than mmx, I recommend picking a different flag for that and applying it only when you've tested on Core1, so that FF_MM_SSE2 can be trusted to dwim in the usual case.
--Loren Merritt
cpuid.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 7ba0916766645e2de9330e9ba8f30d815da14c91 cpuid.diff
do we have any float SSE2 code that this could affect negatively? if not iam ok with this patch
All other vp8 sse2 funcs are faster than mmx on my core1, so we might want to actually test a little before applying this? Otherwise ok for me. Ronald
On Sun, 11 Jul 2010, Michael Niedermayer wrote:
On Sun, Jul 11, 2010 at 04:52:04PM +0000, Loren Merritt wrote:
On Sun, 11 Jul 2010, Ronald S. Bultje wrote:
You'll notice that the sse2 is significantly slower here, my rough guess is that this is because of my shitty CPU which pretty much emulates xmm-ops through mmx-ops, so it doesn't add a lot of benefit other than not having to setup the loop for doing the second 8 pixels, combined with the added complexity of a 8x16 transpose before the actual filter. I'm betting that on an actual sse2-supporting CPU (Jason?), this would still be faster, but we might want to put this under a FF_MM_SSE2_NOT_SHITTY flag or something along those lines. If you think my code is shitty, comments are welcome also. ;-).
Rather than special-casing most of the functions, we at x264 declared that Core1 doesn't have sse2, and changed the cpuid parser accordingly. If you want to support the few cases where sse2 is slightly faster than mmx, I recommend picking a different flag for that and applying it only when you've tested on Core1, so that FF_MM_SSE2 can be trusted to dwim in the usual case.
--Loren Merritt
cpuid.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 7ba0916766645e2de9330e9ba8f30d815da14c91 cpuid.diff
do we have any float SSE2 code that this could affect negatively? if not iam ok with this patch
ff_lpc_compute_autocorr_sse2 --Loren Merritt
Hi, On Sun, Jul 11, 2010 at 2:47 PM, Loren Merritt <lorenm at u.washington.edu> wrote:
On Sun, 11 Jul 2010, Michael Niedermayer wrote:
On Sun, Jul 11, 2010 at 04:52:04PM +0000, Loren Merritt wrote:
On Sun, 11 Jul 2010, Ronald S. Bultje wrote:
You'll notice that the sse2 is significantly slower here, my rough guess is that this is because of my shitty CPU which pretty much emulates xmm-ops through mmx-ops, so it doesn't add a lot of benefit other than not having to setup the loop for doing the second 8 pixels, combined with the added complexity of a 8x16 transpose before the actual filter. I'm betting that on an actual sse2-supporting CPU (Jason?), this would still be faster, but we might want to put this under a FF_MM_SSE2_NOT_SHITTY flag or something along those lines. If you think my code is shitty, comments are welcome also. ;-).
Rather than special-casing most of the functions, we at x264 declared that Core1 doesn't have sse2, and changed the cpuid parser accordingly. If you want to support the few cases where sse2 is slightly faster than mmx, I recommend picking a different flag for that and applying it only when you've tested on Core1, so that FF_MM_SSE2 can be trusted to dwim in the usual case.
--Loren Merritt
?cpuid.c | ? 14 +++++++++++++- ?1 file changed, 13 insertions(+), 1 deletion(-) 7ba0916766645e2de9330e9ba8f30d815da14c91 ?cpuid.diff
do we have any float SSE2 code that this could affect negatively? if not iam ok with this patch
ff_lpc_compute_autocorr_sse2
Attached patch implements FF_MM_SSE2/3SLOW for this purpose. Ronald
On Sun, 18 Jul 2010, Ronald S. Bultje wrote:
On Sun, Jul 11, 2010 at 2:47 PM, Loren Merritt <lorenm at u.washington.edu> wrote:
On Sun, 11 Jul 2010, Michael Niedermayer wrote:
On Sun, Jul 11, 2010 at 04:52:04PM +0000, Loren Merritt wrote:
Rather than special-casing most of the functions, we at x264 declared that Core1 doesn't have sse2, and changed the cpuid parser accordingly. If you want to support the few cases where sse2 is slightly faster than mmx, I recommend picking a different flag for that and applying it only when you've tested on Core1, so that FF_MM_SSE2 can be trusted to dwim in the usual case.
?cpuid.c | ? 14 +++++++++++++- ?1 file changed, 13 insertions(+), 1 deletion(-) 7ba0916766645e2de9330e9ba8f30d815da14c91 ?cpuid.diff
do we have any float SSE2 code that this could affect negatively? if not iam ok with this patch
ff_lpc_compute_autocorr_sse2
Attached patch implements FF_MM_SSE2/3SLOW for this purpose.
ok if you've tested it (I haven't). --Loren Merritt
Hi, On Sun, Jul 18, 2010 at 4:11 PM, Loren Merritt <lorenm at u.washington.edu> wrote:
On Sun, 18 Jul 2010, Ronald S. Bultje wrote:
On Sun, Jul 11, 2010 at 2:47 PM, Loren Merritt <lorenm at u.washington.edu> wrote:
On Sun, 11 Jul 2010, Michael Niedermayer wrote:
On Sun, Jul 11, 2010 at 04:52:04PM +0000, Loren Merritt wrote:
Rather than special-casing most of the functions, we at x264 declared that Core1 doesn't have sse2, and changed the cpuid parser accordingly. If you want to support the few cases where sse2 is slightly faster than mmx, I recommend picking a different flag for that and applying it only when you've tested on Core1, so that FF_MM_SSE2 can be trusted to dwim in the usual case.
?cpuid.c | ? 14 +++++++++++++- ?1 file changed, 13 insertions(+), 1 deletion(-) 7ba0916766645e2de9330e9ba8f30d815da14c91 ?cpuid.diff
do we have any float SSE2 code that this could affect negatively? if not iam ok with this patch
ff_lpc_compute_autocorr_sse2
Attached patch implements FF_MM_SSE2/3SLOW for this purpose.
ok if you've tested it (I haven't).
What would I test exactly? I've tested that the function pointers don't get assigned (so expected behaviour) on my core1, unless I put it under SSE2SLOW|SSE2. I have tested the improved speed for all VP8 functions under SSE2SLOW|SSE2, but haven't tested the LPC function (I am taking your word for that one). I also haven't tested any other functions to see if SSE2SLOW could help. Michael, are you ok with the new flags FF_MM_SSE2/3SLOW? Ronald
On Sun, Jul 18, 2010 at 02:21:12PM -0400, Ronald S. Bultje wrote:
Hi,
On Sun, Jul 11, 2010 at 2:47 PM, Loren Merritt <lorenm at u.washington.edu> wrote:
On Sun, 11 Jul 2010, Michael Niedermayer wrote:
On Sun, Jul 11, 2010 at 04:52:04PM +0000, Loren Merritt wrote:
On Sun, 11 Jul 2010, Ronald S. Bultje wrote:
You'll notice that the sse2 is significantly slower here, my rough guess is that this is because of my shitty CPU which pretty much emulates xmm-ops through mmx-ops, so it doesn't add a lot of benefit other than not having to setup the loop for doing the second 8 pixels, combined with the added complexity of a 8x16 transpose before the actual filter. I'm betting that on an actual sse2-supporting CPU (Jason?), this would still be faster, but we might want to put this under a FF_MM_SSE2_NOT_SHITTY flag or something along those lines. If you think my code is shitty, comments are welcome also. ;-).
Rather than special-casing most of the functions, we at x264 declared that Core1 doesn't have sse2, and changed the cpuid parser accordingly. If you want to support the few cases where sse2 is slightly faster than mmx, I recommend picking a different flag for that and applying it only when you've tested on Core1, so that FF_MM_SSE2 can be trusted to dwim in the usual case.
--Loren Merritt
?cpuid.c | ? 14 +++++++++++++- ?1 file changed, 13 insertions(+), 1 deletion(-) 7ba0916766645e2de9330e9ba8f30d815da14c91 ?cpuid.diff
do we have any float SSE2 code that this could affect negatively? if not iam ok with this patch
ff_lpc_compute_autocorr_sse2
Attached patch implements FF_MM_SSE2/3SLOW for this purpose. [...] @@ -108,13 +112,25 @@ rval |= FF_MM_MMX2; }
+ if (!strncmp(vendor.c, "GenuineIntel", 12) && + family == 6 && (model == 9 || model == 13 || model == 14)) { + /* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and 6/14 (core1 "yonah") + * theoretically support sse2, but it's usually slower than mmx, + * so let's just pretend they don't. */
+ if (rval & FF_MM_SSE2) rval |= FF_MM_SSE2SLOW; + if (rval & FF_MM_SSE3) rval |= FF_MM_SSE3SLOW; + rval &= ~(FF_MM_SSE2|FF_MM_SSE3);
if (rval & FF_MM_SSE2) rval ^= FF_MM_SSE2SLOW | FF_MM_SSE2; ... ok otherwise [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Many that live deserve death. And some that die deserve life. Can you give it to them? Then do not be too eager to deal out death in judgement. For even the very wise cannot see all ends. -- Gandalf
Hi, On Mon, Jul 19, 2010 at 2:19 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
On Sun, Jul 18, 2010 at 02:21:12PM -0400, Ronald S. Bultje wrote:
On Sun, Jul 11, 2010 at 2:47 PM, Loren Merritt <lorenm at u.washington.edu> wrote:
On Sun, 11 Jul 2010, Michael Niedermayer wrote:
On Sun, Jul 11, 2010 at 04:52:04PM +0000, Loren Merritt wrote:
On Sun, 11 Jul 2010, Ronald S. Bultje wrote:
You'll notice that the sse2 is significantly slower here, my rough guess is that this is because of my shitty CPU which pretty much emulates xmm-ops through mmx-ops, so it doesn't add a lot of benefit other than not having to setup the loop for doing the second 8 pixels, combined with the added complexity of a 8x16 transpose before the actual filter. I'm betting that on an actual sse2-supporting CPU (Jason?), this would still be faster, but we might want to put this under a FF_MM_SSE2_NOT_SHITTY flag or something along those lines. If you think my code is shitty, comments are welcome also. ;-).
Rather than special-casing most of the functions, we at x264 declared that Core1 doesn't have sse2, and changed the cpuid parser accordingly. If you want to support the few cases where sse2 is slightly faster than mmx, I recommend picking a different flag for that and applying it only when you've tested on Core1, so that FF_MM_SSE2 can be trusted to dwim in the usual case.
--Loren Merritt
?cpuid.c | ? 14 +++++++++++++- ?1 file changed, 13 insertions(+), 1 deletion(-) 7ba0916766645e2de9330e9ba8f30d815da14c91 ?cpuid.diff
do we have any float SSE2 code that this could affect negatively? if not iam ok with this patch
ff_lpc_compute_autocorr_sse2
Attached patch implements FF_MM_SSE2/3SLOW for this purpose. [...] @@ -108,13 +112,25 @@ ? ? ? ? ? ? ?rval |= FF_MM_MMX2; ? ? ?}
+ ? ?if (!strncmp(vendor.c, "GenuineIntel", 12) && + ? ? ? ?family == 6 && (model == 9 || model == 13 || model == 14)) { + ? ? ? ?/* 6/9 (pentium-m "banias"), 6/13 (pentium-m "dothan"), and 6/14 (core1 "yonah") + ? ? ? ? * theoretically support sse2, but it's usually slower than mmx, + ? ? ? ? * so let's just pretend they don't. */
+ ? ? ? ?if (rval & FF_MM_SSE2) rval |= FF_MM_SSE2SLOW; + ? ? ? ?if (rval & FF_MM_SSE3) rval |= FF_MM_SSE3SLOW; + ? ? ? ?rval &= ~(FF_MM_SSE2|FF_MM_SSE3);
if (rval & FF_MM_SSE2) rval ^= FF_MM_SSE2SLOW | FF_MM_SSE2; ...
ok otherwise
Applied with the suggested modification. Ronald
On Sun, Jul 11, 2010 at 8:53 AM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
Hi,
as per $subj. All tested to be identical to C reference. If wanted, I can try to share parts of the filter code with the simple loopfilter, but I'm a little scared that it'll turn into massive spaghetti so I didn't do it yet.
+ mova m4, m1 + SWAP 4, 1 This pattern seems to be repeated a lot... I fail to see the point. Swapping two registers with the same contents doesn't do anything significant. For the following: + mova m4, [rsp+mmsize] + pxor m3, m3 + psubusb m0, m4 + psubusb m1, m4 + psubusb m7, m4 + psubusb m6, m4 + pcmpeqb m0, m3 ; abs(p3-p2) <= I + pcmpeqb m1, m3 ; abs(p2-p1) <= I + pcmpeqb m7, m3 ; abs(q3-q2) <= I + pcmpeqb m6, m3 ; abs(q2-q1) <= I + pand m0, m1 + pand m7, m6 + pand m0, m7 The following should be faster with mmxext/sse2: mova m4, [rsp+mmsize] pxor m3, m3 pmaxub m0, m1 pmaxub m6, m7 pmaxub m0, m6 psubusb m0, m4 pcmpeqb m0, m3 + mova m6, [rsp+mmsize*3] + pxor m7, m7 + pand m0, m6 + pand m1, m6 + pavgb m0, m7 ; a + psubusb m1, [pb_1] + pavgb m1, m7 ; -a + psubusb m5, m0 + paddusb m5, m1 ; q1-a + psubusb m2, m1 + paddusb m2, m0 ; p1+a pavgb is mmxext/sse2 only. -Eli
Hi Eli, On Sun, Jul 11, 2010 at 2:20 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
On Sun, Jul 11, 2010 at 8:53 AM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
as per $subj. All tested to be identical to C reference. If wanted, I can try to share parts of the filter code with the simple loopfilter, but I'm a little scared that it'll turn into massive spaghetti so I didn't do it yet.
+ ? ?mova ? ? ? ? ? ? m4, m1 + ? ?SWAP ? ? ? ? ? ? ?4, 1
This pattern seems to be repeated a lot... I fail to see the point. Swapping two registers with the same contents doesn't do anything significant.
What I've been told is that for a mova x, y, the x (dest) is available one cycle after the source, so using y (src) directly after is preferred over using x directly after. In this function, I'm trying to organize it such that m2-m5 are (at least in the source) consistently referring to p1/p0/q0/q1, hence the SWAP.
For the following: + ? ?mova ? ? ? ? ? ? m4, [rsp+mmsize] + ? ?pxor ? ? ? ? ? ? m3, m3 + ? ?psubusb ? ? ? ? ?m0, m4 + ? ?psubusb ? ? ? ? ?m1, m4 + ? ?psubusb ? ? ? ? ?m7, m4 + ? ?psubusb ? ? ? ? ?m6, m4 + ? ?pcmpeqb ? ? ? ? ?m0, m3 ? ? ? ?; abs(p3-p2) <= I + ? ?pcmpeqb ? ? ? ? ?m1, m3 ? ? ? ?; abs(p2-p1) <= I + ? ?pcmpeqb ? ? ? ? ?m7, m3 ? ? ? ?; abs(q3-q2) <= I + ? ?pcmpeqb ? ? ? ? ?m6, m3 ? ? ? ?; abs(q2-q1) <= I + ? ?pand ? ? ? ? ? ? m0, m1 + ? ?pand ? ? ? ? ? ? m7, m6 + ? ?pand ? ? ? ? ? ? m0, m7
The following should be faster with mmxext/sse2:
? ?mova ? ? ? ? ? ? m4, [rsp+mmsize] ? ?pxor ? ? ? ? ? ? m3, m3 ? ?pmaxub ? ? ? ? ?m0, m1 ? ?pmaxub ? ? ? ? ?m6, m7 ? ?pmaxub ? ? ? ? ?m0, m6 ? ?psubusb ? ? ? ? ?m0, m4 ? ?pcmpeqb ? ? ? ? ?m0, m3
Indeed, and I've extended that a bit also, that's quite a big win, >10 cycles.
+ ? ?mova ? ? ? ? ? ? m6, [rsp+mmsize*3] + ? ?pxor ? ? ? ? ? ? m7, m7 + ? ?pand ? ? ? ? ? ? m0, m6 + ? ?pand ? ? ? ? ? ? m1, m6 + ? ?pavgb ? ? ? ? ? ?m0, m7 ? ? ? ?; a + ? ?psubusb ? ? ? ? ?m1, [pb_1] + ? ?pavgb ? ? ? ? ? ?m1, m7 ? ? ? ?; -a + ? ?psubusb ? ? ? ? ?m5, m0 + ? ?paddusb ? ? ? ? ?m5, m1 ? ? ? ?; q1-a + ? ?psubusb ? ? ? ? ?m2, m1 + ? ?paddusb ? ? ? ? ?m2, m0 ? ? ? ?; p1+a
pavgb is mmxext/sse2 only.
Indeed again, I've replaced the MMX version with a slightly slower code. New version attached, still bitexact for everything, thanks for the comments so far. Ronald.
On Sun, Jul 11, 2010 at 4:02 PM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
Hi Eli,
On Sun, Jul 11, 2010 at 2:20 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
On Sun, Jul 11, 2010 at 8:53 AM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
as per $subj. All tested to be identical to C reference. If wanted, I can try to share parts of the filter code with the simple loopfilter, but I'm a little scared that it'll turn into massive spaghetti so I didn't do it yet.
+ ? ?mova ? ? ? ? ? ? m4, m1 + ? ?SWAP ? ? ? ? ? ? ?4, 1
This pattern seems to be repeated a lot... I fail to see the point. Swapping two registers with the same contents doesn't do anything significant.
What I've been told is that for a mova x, y, the x (dest) is available one cycle after the source, so using y (src) directly after is preferred over using x directly after. In this function, I'm trying to organize it such that m2-m5 are (at least in the source) consistently referring to p1/p0/q0/q1, hence the SWAP.
For the following: + ? ?mova ? ? ? ? ? ? m4, [rsp+mmsize] + ? ?pxor ? ? ? ? ? ? m3, m3 + ? ?psubusb ? ? ? ? ?m0, m4 + ? ?psubusb ? ? ? ? ?m1, m4 + ? ?psubusb ? ? ? ? ?m7, m4 + ? ?psubusb ? ? ? ? ?m6, m4 + ? ?pcmpeqb ? ? ? ? ?m0, m3 ? ? ? ?; abs(p3-p2) <= I + ? ?pcmpeqb ? ? ? ? ?m1, m3 ? ? ? ?; abs(p2-p1) <= I + ? ?pcmpeqb ? ? ? ? ?m7, m3 ? ? ? ?; abs(q3-q2) <= I + ? ?pcmpeqb ? ? ? ? ?m6, m3 ? ? ? ?; abs(q2-q1) <= I + ? ?pand ? ? ? ? ? ? m0, m1 + ? ?pand ? ? ? ? ? ? m7, m6 + ? ?pand ? ? ? ? ? ? m0, m7
The following should be faster with mmxext/sse2:
? ?mova ? ? ? ? ? ? m4, [rsp+mmsize] ? ?pxor ? ? ? ? ? ? m3, m3 ? ?pmaxub ? ? ? ? ?m0, m1 ? ?pmaxub ? ? ? ? ?m6, m7 ? ?pmaxub ? ? ? ? ?m0, m6 ? ?psubusb ? ? ? ? ?m0, m4 ? ?pcmpeqb ? ? ? ? ?m0, m3
Indeed, and I've extended that a bit also, that's quite a big win, >10 cycles.
+ ? ?mova ? ? ? ? ? ? m6, [rsp+mmsize*3] + ? ?pxor ? ? ? ? ? ? m7, m7 + ? ?pand ? ? ? ? ? ? m0, m6 + ? ?pand ? ? ? ? ? ? m1, m6 + ? ?pavgb ? ? ? ? ? ?m0, m7 ? ? ? ?; a + ? ?psubusb ? ? ? ? ?m1, [pb_1] + ? ?pavgb ? ? ? ? ? ?m1, m7 ? ? ? ?; -a + ? ?psubusb ? ? ? ? ?m5, m0 + ? ?paddusb ? ? ? ? ?m5, m1 ? ? ? ?; q1-a + ? ?psubusb ? ? ? ? ?m2, m1 + ? ?paddusb ? ? ? ? ?m2, m0 ? ? ? ?; p1+a
pavgb is mmxext/sse2 only.
Indeed again, I've replaced the MMX version with a slightly slower code.
New version attached, still bitexact for everything, thanks for the comments so far.
Ronald.
FYI, pavgusb is 3dnow and does the exact same thing as pavgb, so you can template a 3dnow version by %defining pavgb accordingly. Dark Shikari
On Sun, Jul 11, 2010 at 4:02 PM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
Hi Eli,
On Sun, Jul 11, 2010 at 2:20 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
+ ? ?mova ? ? ? ? ? ? m4, m1 + ? ?SWAP ? ? ? ? ? ? ?4, 1
This pattern seems to be repeated a lot... I fail to see the point. Swapping two registers with the same contents doesn't do anything significant.
What I've been told is that for a mova x, y, the x (dest) is available one cycle after the source, so using y (src) directly after is preferred over using x directly after. In this function, I'm trying to organize it such that m2-m5 are (at least in the source) consistently referring to p1/p0/q0/q1, hence the SWAP.
Oh, okay, that makes sense. -Eli
On Sun, Jul 11, 2010 at 8:53 AM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
You'll notice that the sse2 is significantly slower here, my rough guess is that this is because of my shitty CPU which pretty much emulates xmm-ops through mmx-ops, so it doesn't add a lot of benefit other than not having to setup the loop for doing the second 8 pixels, combined with the added complexity of a 8x16 transpose before the actual filter. I'm betting that on an actual sse2-supporting CPU (Jason?), this would still be faster, but we might want to put this under a FF_MM_SSE2_NOT_SHITTY flag or something along those lines. If you think my code is shitty, comments are welcome also. ;-).
On my Mobile Core i5, the SSE2 version has the expected performance gain vs. the mmxext version (55% of the time for the vertical version, 65% of the time for the horizontal version). -Eli
Hi Eli On Jul 11, 2010, at 3:52 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
On Sun, Jul 11, 2010 at 8:53 AM, Ronald S. Bultje <rsbultje at gmail.com> wrote:
You'll notice that the sse2 is significantly slower here, my rough guess is that this is because of my shitty CPU which pretty much emulates xmm-ops through mmx-ops, so it doesn't add a lot of benefit other than not having to setup the loop for doing the second 8 pixels, combined with the added complexity of a 8x16 transpose before the actual filter. I'm betting that on an actual sse2-supporting CPU (Jason?), this would still be faster, but we might want to put this under a FF_MM_SSE2_NOT_SHITTY flag or something along those lines. If you think my code is shitty, comments are welcome also. ;-).
On my Mobile Core i5, the SSE2 version has the expected performance gain vs. the mmxext version (55% of the time for the vertical version, 65% of the time for the horizontal version).
Thanks for taking the time to test, this is approximately what I'd expect. Watching the game now, will look at your other comments later, thanks for those also. Ronald
participants (5)
-
darkshikari@gmail.com -
eli.friedman@gmail.com -
lorenm@u.washington.edu -
michaelni@gmx.at -
rsbultje@gmail.com