Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags
@ 2024-07-04  1:23 Sean McGovern
  2024-07-04  1:23 ` [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER Sean McGovern
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Sean McGovern @ 2024-07-04  1:23 UTC (permalink / raw)
  To: ffmpeg-devel

---
 configure | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure b/configure
index b28221f258..bbda7a02cb 100755
--- a/configure
+++ b/configure
@@ -5493,7 +5493,7 @@ elif enabled ppc; then
             cpuflags="-mcpu=$cpu"
             disable vsx
         ;;
-        power[7-8]*)
+        power[7-9]*)
             cpuflags="-mcpu=$cpu"
         ;;
         cell)
-- 
2.39.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER
  2024-07-04  1:23 [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags Sean McGovern
@ 2024-07-04  1:23 ` Sean McGovern
  2024-07-04 11:15   ` Rémi Denis-Courmont
  2024-07-07 18:21   ` [FFmpeg-devel] [PATCH] " Sean McGovern
  2024-07-06 19:56 ` [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags Sean McGovern
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 13+ messages in thread
From: Sean McGovern @ 2024-07-04  1:23 UTC (permalink / raw)
  To: ffmpeg-devel

RaptorCS POWER9 (8c4t) @ 2.2GHz:
flac_wasted_32_c: 50.1
flac_wasted_32_vsx: 17.3
---
 libavcodec/flacdsp.c          |  2 ++
 libavcodec/flacdsp.h          |  1 +
 libavcodec/ppc/Makefile       |  2 ++
 libavcodec/ppc/flacdsp_init.c | 38 ++++++++++++++++++++++++++++
 libavcodec/ppc/flacdsp_vsx.c  | 47 +++++++++++++++++++++++++++++++++++
 5 files changed, 90 insertions(+)
 create mode 100644 libavcodec/ppc/flacdsp_init.c
 create mode 100644 libavcodec/ppc/flacdsp_vsx.c

diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
index f5362bf66f..b63d55ddcd 100644
--- a/libavcodec/flacdsp.c
+++ b/libavcodec/flacdsp.c
@@ -156,5 +156,7 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int cha
     ff_flacdsp_init_riscv(c, fmt, channels);
 #elif ARCH_X86
     ff_flacdsp_init_x86(c, fmt, channels);
+#elif ARCH_PPC
+    ff_flacdsp_init_ppc(c, fmt, channels);
 #endif
 }
diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
index 3b7b35a112..941536ef16 100644
--- a/libavcodec/flacdsp.h
+++ b/libavcodec/flacdsp.h
@@ -45,5 +45,6 @@ void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
+void ff_flacdsp_init_ppc(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 
 #endif /* AVCODEC_FLACDSP_H */
diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile
index 10b9ca60da..7f81a8aa34 100644
--- a/libavcodec/ppc/Makefile
+++ b/libavcodec/ppc/Makefile
@@ -2,6 +2,8 @@
 OBJS-$(CONFIG_AUDIODSP)                += ppc/audiodsp.o
 OBJS-$(CONFIG_BLOCKDSP)                += ppc/blockdsp.o
 OBJS-$(CONFIG_FDCTDSP)                 += ppc/fdctdsp.o
+OBJS-$(CONFIG_FLAC_DECODER)            += ppc/flacdsp_init.o
+VSX-OBJS-$(CONFIG_FLAC_DECODER)        += ppc/flacdsp_vsx.o
 OBJS-$(CONFIG_FMTCONVERT)              += ppc/fmtconvert_altivec.o
 OBJS-$(CONFIG_H264CHROMA)              += ppc/h264chroma_init.o
 OBJS-$(CONFIG_H264DSP)                 += ppc/h264dsp.o ppc/hpeldsp_altivec.o
diff --git a/libavcodec/ppc/flacdsp_init.c b/libavcodec/ppc/flacdsp_init.c
new file mode 100644
index 0000000000..526bddddbf
--- /dev/null
+++ b/libavcodec/ppc/flacdsp_init.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2024 Sean McGovern <gseanmcg@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/ppc/cpu.h"
+#include "libavcodec/flacdsp.h"
+
+void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
+
+av_cold void ff_flacdsp_init_ppc(FLACDSPContext *c, enum AVSampleFormat fmt, int channels)
+{
+#if HAVE_VSX
+    if (!PPC_VSX(av_get_cpu_flags()))
+        return;
+
+    c->wasted32 = ff_flac_wasted32_vsx;
+#endif
+}
diff --git a/libavcodec/ppc/flacdsp_vsx.c b/libavcodec/ppc/flacdsp_vsx.c
new file mode 100644
index 0000000000..c31566458c
--- /dev/null
+++ b/libavcodec/ppc/flacdsp_vsx.c
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2024 Sean McGovern <gseanmcg@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/ppc/cpu.h"
+#include "libavutil/ppc/util_altivec.h"
+#include "libavcodec/flacdsp.h"
+
+void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
+
+#if HAVE_VSX
+
+void ff_flac_wasted32_vsx(int32_t *decoded, int wasted, int len)
+{
+    register vec_s32 vec1;
+    const register vec_u32 vec2 = vec_splats((unsigned)wasted);
+    register vec_s32 shifted;
+
+    for (int i = 0; i < len; i+=sizeof(int32_t)) {
+        vec1 = vec_xl(0, decoded);
+        shifted = vec_sl(vec1, vec2);
+        vec_xst(shifted, 0, decoded);
+        decoded += sizeof(int32_t);
+    }
+}
+
+#endif /* HAVE_VSX */
-- 
2.39.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER
  2024-07-04  1:23 ` [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER Sean McGovern
@ 2024-07-04 11:15   ` Rémi Denis-Courmont
  2024-07-04 16:26     ` Sean McGovern
  2024-07-07 18:21   ` [FFmpeg-devel] [PATCH] " Sean McGovern
  1 sibling, 1 reply; 13+ messages in thread
From: Rémi Denis-Courmont @ 2024-07-04 11:15 UTC (permalink / raw)
  To: FFmpeg development discussions and patches



Le 4 juillet 2024 04:23:30 GMT+03:00, Sean McGovern <gseanmcg@gmail.com> a écrit :
>RaptorCS POWER9 (8c4t) @ 2.2GHz:
>flac_wasted_32_c: 50.1
>flac_wasted_32_vsx: 17.3
>---
> libavcodec/flacdsp.c          |  2 ++
> libavcodec/flacdsp.h          |  1 +
> libavcodec/ppc/Makefile       |  2 ++
> libavcodec/ppc/flacdsp_init.c | 38 ++++++++++++++++++++++++++++
> libavcodec/ppc/flacdsp_vsx.c  | 47 +++++++++++++++++++++++++++++++++++
> 5 files changed, 90 insertions(+)
> create mode 100644 libavcodec/ppc/flacdsp_init.c
> create mode 100644 libavcodec/ppc/flacdsp_vsx.c
>
>diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
>index f5362bf66f..b63d55ddcd 100644
>--- a/libavcodec/flacdsp.c
>+++ b/libavcodec/flacdsp.c
>@@ -156,5 +156,7 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int cha
>     ff_flacdsp_init_riscv(c, fmt, channels);
> #elif ARCH_X86
>     ff_flacdsp_init_x86(c, fmt, channels);
>+#elif ARCH_PPC
>+    ff_flacdsp_init_ppc(c, fmt, channels);
> #endif
> }
>diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
>index 3b7b35a112..941536ef16 100644
>--- a/libavcodec/flacdsp.h
>+++ b/libavcodec/flacdsp.h
>@@ -45,5 +45,6 @@ void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
> void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
> void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
> void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
>+void ff_flacdsp_init_ppc(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
> 
> #endif /* AVCODEC_FLACDSP_H */
>diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile
>index 10b9ca60da..7f81a8aa34 100644
>--- a/libavcodec/ppc/Makefile
>+++ b/libavcodec/ppc/Makefile
>@@ -2,6 +2,8 @@
> OBJS-$(CONFIG_AUDIODSP)                += ppc/audiodsp.o
> OBJS-$(CONFIG_BLOCKDSP)                += ppc/blockdsp.o
> OBJS-$(CONFIG_FDCTDSP)                 += ppc/fdctdsp.o
>+OBJS-$(CONFIG_FLAC_DECODER)            += ppc/flacdsp_init.o
>+VSX-OBJS-$(CONFIG_FLAC_DECODER)        += ppc/flacdsp_vsx.o
> OBJS-$(CONFIG_FMTCONVERT)              += ppc/fmtconvert_altivec.o
> OBJS-$(CONFIG_H264CHROMA)              += ppc/h264chroma_init.o
> OBJS-$(CONFIG_H264DSP)                 += ppc/h264dsp.o ppc/hpeldsp_altivec.o
>diff --git a/libavcodec/ppc/flacdsp_init.c b/libavcodec/ppc/flacdsp_init.c
>new file mode 100644
>index 0000000000..526bddddbf
>--- /dev/null
>+++ b/libavcodec/ppc/flacdsp_init.c
>@@ -0,0 +1,38 @@
>+/*
>+ * Copyright (c) 2024 Sean McGovern <gseanmcg@gmail.com>
>+ *
>+ * This file is part of FFmpeg.
>+ *
>+ * FFmpeg is free software; you can redistribute it and/or
>+ * modify it under the terms of the GNU Lesser General Public
>+ * License as published by the Free Software Foundation; either
>+ * version 2.1 of the License, or (at your option) any later version.
>+ *
>+ * FFmpeg is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with FFmpeg; if not, write to the Free Software
>+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>+ */
>+
>+#include "config.h"
>+
>+#include "libavutil/attributes.h"
>+#include "libavutil/cpu.h"
>+#include "libavutil/ppc/cpu.h"
>+#include "libavcodec/flacdsp.h"
>+
>+void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
>+
>+av_cold void ff_flacdsp_init_ppc(FLACDSPContext *c, enum AVSampleFormat fmt, int channels)
>+{
>+#if HAVE_VSX
>+    if (!PPC_VSX(av_get_cpu_flags()))
>+        return;
>+
>+    c->wasted32 = ff_flac_wasted32_vsx;
>+#endif
>+}
>diff --git a/libavcodec/ppc/flacdsp_vsx.c b/libavcodec/ppc/flacdsp_vsx.c
>new file mode 100644
>index 0000000000..c31566458c
>--- /dev/null
>+++ b/libavcodec/ppc/flacdsp_vsx.c
>@@ -0,0 +1,47 @@
>+/*
>+ * Copyright (c) 2024 Sean McGovern <gseanmcg@gmail.com>
>+ *
>+ * This file is part of FFmpeg.
>+ *
>+ * FFmpeg is free software; you can redistribute it and/or
>+ * modify it under the terms of the GNU Lesser General Public
>+ * License as published by the Free Software Foundation; either
>+ * version 2.1 of the License, or (at your option) any later version.
>+ *
>+ * FFmpeg is distributed in the hope that it will be useful,
>+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
>+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>+ * Lesser General Public License for more details.
>+ *
>+ * You should have received a copy of the GNU Lesser General Public
>+ * License along with FFmpeg; if not, write to the Free Software
>+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>+ */
>+
>+#include "config.h"
>+
>+#include "libavutil/attributes.h"
>+#include "libavutil/cpu.h"
>+#include "libavutil/ppc/cpu.h"
>+#include "libavutil/ppc/util_altivec.h"
>+#include "libavcodec/flacdsp.h"
>+
>+void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
>+
>+#if HAVE_VSX
>+
>+void ff_flac_wasted32_vsx(int32_t *decoded, int wasted, int len)
>+{
>+    register vec_s32 vec1;
>+    const register vec_u32 vec2 = vec_splats((unsigned)wasted);
>+    register vec_s32 shifted;
>+
>+    for (int i = 0; i < len; i+=sizeof(int32_t)) {

len in elements, so why is the increment in bytes? Looks like heterogeneous measurement units.

>+        vec1 = vec_xl(0, decoded);
>+        shifted = vec_sl(vec1, vec2);
>+        vec_xst(shifted, 0, decoded);

Judging by other AltiVec code, this lacks unrolling.

>+        decoded += sizeof(int32_t);
>+    }
>+}
>+
>+#endif /* HAVE_VSX */
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER
  2024-07-04 11:15   ` Rémi Denis-Courmont
@ 2024-07-04 16:26     ` Sean McGovern
  2024-07-04 17:45       ` Rémi Denis-Courmont
  0 siblings, 1 reply; 13+ messages in thread
From: Sean McGovern @ 2024-07-04 16:26 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Hi Rémi,

First of all, thanks for the review.

On Thu, Jul 4, 2024, 07:15 Rémi Denis-Courmont <remi@remlab.net> wrote:

>
>
> Le 4 juillet 2024 04:23:30 GMT+03:00, Sean McGovern <gseanmcg@gmail.com>
> a écrit :
> >RaptorCS POWER9 (8c4t) @ 2.2GHz:
> >flac_wasted_32_c: 50.1
> >flac_wasted_32_vsx: 17.3
> >---
> > libavcodec/flacdsp.c          |  2 ++
> > libavcodec/flacdsp.h          |  1 +
> > libavcodec/ppc/Makefile       |  2 ++
> > libavcodec/ppc/flacdsp_init.c | 38 ++++++++++++++++++++++++++++
> > libavcodec/ppc/flacdsp_vsx.c  | 47 +++++++++++++++++++++++++++++++++++
> > 5 files changed, 90 insertions(+)
> > create mode 100644 libavcodec/ppc/flacdsp_init.c
> > create mode 100644 libavcodec/ppc/flacdsp_vsx.c
> >
> >diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
> >index f5362bf66f..b63d55ddcd 100644
> >--- a/libavcodec/flacdsp.c
> >+++ b/libavcodec/flacdsp.c
> >@@ -156,5 +156,7 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum
> AVSampleFormat fmt, int cha
> >     ff_flacdsp_init_riscv(c, fmt, channels);
> > #elif ARCH_X86
> >     ff_flacdsp_init_x86(c, fmt, channels);
> >+#elif ARCH_PPC
> >+    ff_flacdsp_init_ppc(c, fmt, channels);
> > #endif
> > }
> >diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
> >index 3b7b35a112..941536ef16 100644
> >--- a/libavcodec/flacdsp.h
> >+++ b/libavcodec/flacdsp.h
> >@@ -45,5 +45,6 @@ void ff_flacdsp_init(FLACDSPContext *c, enum
> AVSampleFormat fmt, int channels);
> > void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt, int
> channels);
> > void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt,
> int channels);
> > void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int
> channels);
> >+void ff_flacdsp_init_ppc(FLACDSPContext *c, enum AVSampleFormat fmt, int
> channels);
> >
> > #endif /* AVCODEC_FLACDSP_H */
> >diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile
> >index 10b9ca60da..7f81a8aa34 100644
> >--- a/libavcodec/ppc/Makefile
> >+++ b/libavcodec/ppc/Makefile
> >@@ -2,6 +2,8 @@
> > OBJS-$(CONFIG_AUDIODSP)                += ppc/audiodsp.o
> > OBJS-$(CONFIG_BLOCKDSP)                += ppc/blockdsp.o
> > OBJS-$(CONFIG_FDCTDSP)                 += ppc/fdctdsp.o
> >+OBJS-$(CONFIG_FLAC_DECODER)            += ppc/flacdsp_init.o
> >+VSX-OBJS-$(CONFIG_FLAC_DECODER)        += ppc/flacdsp_vsx.o
> > OBJS-$(CONFIG_FMTCONVERT)              += ppc/fmtconvert_altivec.o
> > OBJS-$(CONFIG_H264CHROMA)              += ppc/h264chroma_init.o
> > OBJS-$(CONFIG_H264DSP)                 += ppc/h264dsp.o
> ppc/hpeldsp_altivec.o
> >diff --git a/libavcodec/ppc/flacdsp_init.c b/libavcodec/ppc/flacdsp_init.c
> >new file mode 100644
> >index 0000000000..526bddddbf
> >--- /dev/null
> >+++ b/libavcodec/ppc/flacdsp_init.c
> >@@ -0,0 +1,38 @@
> >+/*
> >+ * Copyright (c) 2024 Sean McGovern <gseanmcg@gmail.com>
> >+ *
> >+ * This file is part of FFmpeg.
> >+ *
> >+ * FFmpeg is free software; you can redistribute it and/or
> >+ * modify it under the terms of the GNU Lesser General Public
> >+ * License as published by the Free Software Foundation; either
> >+ * version 2.1 of the License, or (at your option) any later version.
> >+ *
> >+ * FFmpeg is distributed in the hope that it will be useful,
> >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >+ * Lesser General Public License for more details.
> >+ *
> >+ * You should have received a copy of the GNU Lesser General Public
> >+ * License along with FFmpeg; if not, write to the Free Software
> >+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> >+ */
> >+
> >+#include "config.h"
> >+
> >+#include "libavutil/attributes.h"
> >+#include "libavutil/cpu.h"
> >+#include "libavutil/ppc/cpu.h"
> >+#include "libavcodec/flacdsp.h"
> >+
> >+void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
> >+
> >+av_cold void ff_flacdsp_init_ppc(FLACDSPContext *c, enum AVSampleFormat
> fmt, int channels)
> >+{
> >+#if HAVE_VSX
> >+    if (!PPC_VSX(av_get_cpu_flags()))
> >+        return;
> >+
> >+    c->wasted32 = ff_flac_wasted32_vsx;
> >+#endif
> >+}
> >diff --git a/libavcodec/ppc/flacdsp_vsx.c b/libavcodec/ppc/flacdsp_vsx.c
> >new file mode 100644
> >index 0000000000..c31566458c
> >--- /dev/null
> >+++ b/libavcodec/ppc/flacdsp_vsx.c
> >@@ -0,0 +1,47 @@
> >+/*
> >+ * Copyright (c) 2024 Sean McGovern <gseanmcg@gmail.com>
> >+ *
> >+ * This file is part of FFmpeg.
> >+ *
> >+ * FFmpeg is free software; you can redistribute it and/or
> >+ * modify it under the terms of the GNU Lesser General Public
> >+ * License as published by the Free Software Foundation; either
> >+ * version 2.1 of the License, or (at your option) any later version.
> >+ *
> >+ * FFmpeg is distributed in the hope that it will be useful,
> >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
> >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> >+ * Lesser General Public License for more details.
> >+ *
> >+ * You should have received a copy of the GNU Lesser General Public
> >+ * License along with FFmpeg; if not, write to the Free Software
> >+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> 02110-1301 USA
> >+ */
> >+
> >+#include "config.h"
> >+
> >+#include "libavutil/attributes.h"
> >+#include "libavutil/cpu.h"
> >+#include "libavutil/ppc/cpu.h"
> >+#include "libavutil/ppc/util_altivec.h"
> >+#include "libavcodec/flacdsp.h"
> >+
> >+void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
> >+
> >+#if HAVE_VSX
> >+
> >+void ff_flac_wasted32_vsx(int32_t *decoded, int wasted, int len)
> >+{
> >+    register vec_s32 vec1;
> >+    const register vec_u32 vec2 = vec_splats((unsigned)wasted);
> >+    register vec_s32 shifted;
> >+
> >+    for (int i = 0; i < len; i+=sizeof(int32_t)) {
>
> len in elements, so why is the increment in bytes? Looks like
> heterogeneous measurement units.
>

I wondered about that, this is my first attempt at vectorization -- it
seems I have much to learn.


> >+        vec1 = vec_xl(0, decoded);
> >+        shifted = vec_sl(vec1, vec2);
> >+        vec_xst(shifted, 0, decoded);
>
> Judging by other AltiVec code, this lacks unrolling.
>

Is that correlated with the comment above re: len? Or is it more general
that I should unroll until I've exhausted the available vector registers?


> >+        decoded += sizeof(int32_t);
> >+    }
> >+}
> >+
> >+#endif /* HAVE_VSX */
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>

-- Sean McGovern

>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER
  2024-07-04 16:26     ` Sean McGovern
@ 2024-07-04 17:45       ` Rémi Denis-Courmont
  2024-07-06 20:00         ` Sean McGovern
  0 siblings, 1 reply; 13+ messages in thread
From: Rémi Denis-Courmont @ 2024-07-04 17:45 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Le torstaina 4. heinäkuuta 2024, 19.26.19 EEST Sean McGovern a écrit :
> Is that correlated with the comment above re: len? Or is it more general
> that I should unroll until I've exhausted the available vector registers?

You should unroll if it improves bandwidth.

-- 
レミ・デニ-クールモン
http://www.remlab.net/



_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags
  2024-07-04  1:23 [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags Sean McGovern
  2024-07-04  1:23 ` [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER Sean McGovern
@ 2024-07-06 19:56 ` Sean McGovern
  2024-07-12 21:09 ` Sean McGovern
  2024-07-13  8:46 ` Rémi Denis-Courmont
  3 siblings, 0 replies; 13+ messages in thread
From: Sean McGovern @ 2024-07-06 19:56 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Hi,


On Wed, Jul 3, 2024, 21:24 Sean McGovern <gseanmcg@gmail.com> wrote:

> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index b28221f258..bbda7a02cb 100755
> --- a/configure
> +++ b/configure
> @@ -5493,7 +5493,7 @@ elif enabled ppc; then
>              cpuflags="-mcpu=$cpu"
>              disable vsx
>          ;;
> -        power[7-8]*)
> +        power[7-9]*)
>              cpuflags="-mcpu=$cpu"
>          ;;
>          cell)
> --
> 2.39.2
>

Can this piece go ahead without 2/2?

-- Sean McGovern
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER
  2024-07-04 17:45       ` Rémi Denis-Courmont
@ 2024-07-06 20:00         ` Sean McGovern
  2024-07-06 20:17           ` Rémi Denis-Courmont
  0 siblings, 1 reply; 13+ messages in thread
From: Sean McGovern @ 2024-07-06 20:00 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Hi,


On Thu, Jul 4, 2024, 13:54 Rémi Denis-Courmont <remi@remlab.net> wrote:

> Le torstaina 4. heinäkuuta 2024, 19.26.19 EEST Sean McGovern a écrit :
> > Is that correlated with the comment above re: len? Or is it more general
> > that I should unroll until I've exhausted the available vector registers?
>
> You should unroll if it improves bandwidth.
>
> --
> レミ・デニ-クールモン
> http://www.remlab.net/
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>

After adding a 2nd set of load/left shift/store it was diminishing/no
returns for more unrolling. I'll send the updated version later.

Does wasted32 (and I guess wasted33 by proxy) not have to worry about loops
tails? I noticed the other vectorized versions don't do anything special in
that regard.

-- Sean McGovern

>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER
  2024-07-06 20:00         ` Sean McGovern
@ 2024-07-06 20:17           ` Rémi Denis-Courmont
  2024-07-07 16:51             ` Sean McGovern
  0 siblings, 1 reply; 13+ messages in thread
From: Rémi Denis-Courmont @ 2024-07-06 20:17 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Le lauantaina 6. heinäkuuta 2024, 23.00.47 EEST Sean McGovern a écrit :
> Does wasted32 (and I guess wasted33 by proxy) not have to worry about loops
> tails? I noticed the other vectorized versions don't do anything special in
> that regard.

Frankly, RISC-V vectors (like Arm SVE's) are scalable so I don't need to care 
about these details.

It depends if there is padding, and if so if it can be overwritten or only 
read. I don't know about this particular case. Check the x86 code.


-- 
レミ・デニ-クールモン
http://www.remlab.net/



_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER
  2024-07-06 20:17           ` Rémi Denis-Courmont
@ 2024-07-07 16:51             ` Sean McGovern
  0 siblings, 0 replies; 13+ messages in thread
From: Sean McGovern @ 2024-07-07 16:51 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Hi,

On Sat, Jul 6, 2024, 16:18 Rémi Denis-Courmont <remi@remlab.net> wrote:

> Le lauantaina 6. heinäkuuta 2024, 23.00.47 EEST Sean McGovern a écrit :
> > Does wasted32 (and I guess wasted33 by proxy) not have to worry about
> loops
> > tails? I noticed the other vectorized versions don't do anything special
> in
> > that regard.
>
> Frankly, RISC-V vectors (like Arm SVE's) are scalable so I don't need to
> care
> about these details.
>
> It depends if there is padding, and if so if it can be overwritten or only
> read. I don't know about this particular case. Check the x86 code.
>

Naah, the SSE2 version of wasted32 just unrolls it by 4 and call it a day,
so then like you said this is probably either padded or else always a
multiple of 512 bits.


>
> --
> レミ・デニ-クールモン
> http://www.remlab.net/
>
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>

-- Sean McGovern

>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* [FFmpeg-devel] [PATCH] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER
  2024-07-04  1:23 ` [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER Sean McGovern
  2024-07-04 11:15   ` Rémi Denis-Courmont
@ 2024-07-07 18:21   ` Sean McGovern
  2024-07-13  8:51     ` Rémi Denis-Courmont
  1 sibling, 1 reply; 13+ messages in thread
From: Sean McGovern @ 2024-07-07 18:21 UTC (permalink / raw)
  To: ffmpeg-devel

RaptorCS POWER9 (8c4t) @ 2.2GHz:
flac_wasted_32_c: 50.1
flac_wasted_32_vsx: 14.1
---
 libavcodec/flacdsp.c          |  2 ++
 libavcodec/flacdsp.h          |  1 +
 libavcodec/ppc/Makefile       |  2 ++
 libavcodec/ppc/flacdsp_init.c | 38 +++++++++++++++++++++++++
 libavcodec/ppc/flacdsp_vsx.c  | 53 +++++++++++++++++++++++++++++++++++
 5 files changed, 96 insertions(+)
 create mode 100644 libavcodec/ppc/flacdsp_init.c
 create mode 100644 libavcodec/ppc/flacdsp_vsx.c

diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
index f5362bf66f..b63d55ddcd 100644
--- a/libavcodec/flacdsp.c
+++ b/libavcodec/flacdsp.c
@@ -156,5 +156,7 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int cha
     ff_flacdsp_init_riscv(c, fmt, channels);
 #elif ARCH_X86
     ff_flacdsp_init_x86(c, fmt, channels);
+#elif ARCH_PPC
+    ff_flacdsp_init_ppc(c, fmt, channels);
 #endif
 }
diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
index 3b7b35a112..941536ef16 100644
--- a/libavcodec/flacdsp.h
+++ b/libavcodec/flacdsp.h
@@ -45,5 +45,6 @@ void ff_flacdsp_init(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 void ff_flacdsp_init_arm(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 void ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
+void ff_flacdsp_init_ppc(FLACDSPContext *c, enum AVSampleFormat fmt, int channels);
 
 #endif /* AVCODEC_FLACDSP_H */
diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile
index 10b9ca60da..7f81a8aa34 100644
--- a/libavcodec/ppc/Makefile
+++ b/libavcodec/ppc/Makefile
@@ -2,6 +2,8 @@
 OBJS-$(CONFIG_AUDIODSP)                += ppc/audiodsp.o
 OBJS-$(CONFIG_BLOCKDSP)                += ppc/blockdsp.o
 OBJS-$(CONFIG_FDCTDSP)                 += ppc/fdctdsp.o
+OBJS-$(CONFIG_FLAC_DECODER)            += ppc/flacdsp_init.o
+VSX-OBJS-$(CONFIG_FLAC_DECODER)        += ppc/flacdsp_vsx.o
 OBJS-$(CONFIG_FMTCONVERT)              += ppc/fmtconvert_altivec.o
 OBJS-$(CONFIG_H264CHROMA)              += ppc/h264chroma_init.o
 OBJS-$(CONFIG_H264DSP)                 += ppc/h264dsp.o ppc/hpeldsp_altivec.o
diff --git a/libavcodec/ppc/flacdsp_init.c b/libavcodec/ppc/flacdsp_init.c
new file mode 100644
index 0000000000..526bddddbf
--- /dev/null
+++ b/libavcodec/ppc/flacdsp_init.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2024 Sean McGovern <gseanmcg@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/ppc/cpu.h"
+#include "libavcodec/flacdsp.h"
+
+void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
+
+av_cold void ff_flacdsp_init_ppc(FLACDSPContext *c, enum AVSampleFormat fmt, int channels)
+{
+#if HAVE_VSX
+    if (!PPC_VSX(av_get_cpu_flags()))
+        return;
+
+    c->wasted32 = ff_flac_wasted32_vsx;
+#endif
+}
diff --git a/libavcodec/ppc/flacdsp_vsx.c b/libavcodec/ppc/flacdsp_vsx.c
new file mode 100644
index 0000000000..7464108c45
--- /dev/null
+++ b/libavcodec/ppc/flacdsp_vsx.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2024 Sean McGovern <gseanmcg@gmail.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+
+#include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
+#include "libavutil/ppc/cpu.h"
+#include "libavutil/ppc/util_altivec.h"
+#include "libavcodec/flacdsp.h"
+
+void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
+
+#if HAVE_VSX
+
+void ff_flac_wasted32_vsx(int32_t *decoded, int wasted, int len)
+{
+    register vec_s32 vec1, vec2;
+    const register vec_u32 vwasted = vec_splats((unsigned)wasted);
+
+    for (int i = 0; i < len; i+=8 /* increment is by # elements, not bytes */) {
+	/* that said, we have some extra bandwidth so let's unroll it slightly */
+        vec1 = vec_xl(0, decoded);
+        vec2 = vec_xl(16, decoded);
+
+        vec1 = vec_sl(vec1, vwasted);
+        vec2 = vec_sl(vec2, vwasted);
+
+        vec_xst(vec1, 0, decoded);
+        vec_xst(vec2, 16, decoded);
+
+        decoded += 8;
+    }
+}
+
+#endif /* HAVE_VSX */
-- 
2.39.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags
  2024-07-04  1:23 [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags Sean McGovern
  2024-07-04  1:23 ` [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER Sean McGovern
  2024-07-06 19:56 ` [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags Sean McGovern
@ 2024-07-12 21:09 ` Sean McGovern
  2024-07-13  8:46 ` Rémi Denis-Courmont
  3 siblings, 0 replies; 13+ messages in thread
From: Sean McGovern @ 2024-07-12 21:09 UTC (permalink / raw)
  To: FFmpeg development discussions and patches

Hi,


On Wed, Jul 3, 2024, 21:24 Sean McGovern <gseanmcg@gmail.com> wrote:

> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/configure b/configure
> index b28221f258..bbda7a02cb 100755
> --- a/configure
> +++ b/configure
> @@ -5493,7 +5493,7 @@ elif enabled ppc; then
>              cpuflags="-mcpu=$cpu"
>              disable vsx
>          ;;
> -        power[7-8]*)
> +        power[7-9]*)
>              cpuflags="-mcpu=$cpu"
>          ;;
>          cell)
> --
> 2.39.2
>

Hold off on this for now, it is missing the co-requisite changes in
lavu/ppc/cpu.c

Additionally I realize there probably aren't many people who can review PPC
or AltiVec/VSX patches. Should I just keep these to myself for now? I'd
like to do more for the lavc DSP functions as well.

-- Sean McGovern

>
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags
  2024-07-04  1:23 [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags Sean McGovern
                   ` (2 preceding siblings ...)
  2024-07-12 21:09 ` Sean McGovern
@ 2024-07-13  8:46 ` Rémi Denis-Courmont
  3 siblings, 0 replies; 13+ messages in thread
From: Rémi Denis-Courmont @ 2024-07-13  8:46 UTC (permalink / raw)
  To: ffmpeg-devel

Le torstaina 4. heinäkuuta 2024, 4.23.29 EEST Sean McGovern a écrit :
> ---
>  configure | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index b28221f258..bbda7a02cb 100755
> --- a/configure
> +++ b/configure
> @@ -5493,7 +5493,7 @@ elif enabled ppc; then
>              cpuflags="-mcpu=$cpu"
>              disable vsx
>          ;;
> -        power[7-8]*)
> +        power[7-9]*)
>              cpuflags="-mcpu=$cpu"
>          ;;
>          cell)

IMO, the CPU should just be passed as, well, CPU by default - like AArch64 
already does. PPC does not have that many CPU types. But generally speaking, 
keeping up with all CPU model names that GCC and Clang seems like a very vain 
and fruitless exercise.

Of course we can keep special case matching for *existing* special values that 
FFmpeg has historically accepted, but lets maybe stop adding new ones?

-- 
レミ・デニ-クールモン
http://www.remlab.net/



_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [FFmpeg-devel] [PATCH] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER
  2024-07-07 18:21   ` [FFmpeg-devel] [PATCH] " Sean McGovern
@ 2024-07-13  8:51     ` Rémi Denis-Courmont
  0 siblings, 0 replies; 13+ messages in thread
From: Rémi Denis-Courmont @ 2024-07-13  8:51 UTC (permalink / raw)
  To: ffmpeg-devel

Le sunnuntaina 7. heinäkuuta 2024, 21.21.26 EEST Sean McGovern a écrit :
> RaptorCS POWER9 (8c4t) @ 2.2GHz:
> flac_wasted_32_c: 50.1
> flac_wasted_32_vsx: 14.1
> ---
>  libavcodec/flacdsp.c          |  2 ++
>  libavcodec/flacdsp.h          |  1 +
>  libavcodec/ppc/Makefile       |  2 ++
>  libavcodec/ppc/flacdsp_init.c | 38 +++++++++++++++++++++++++
>  libavcodec/ppc/flacdsp_vsx.c  | 53 +++++++++++++++++++++++++++++++++++
>  5 files changed, 96 insertions(+)
>  create mode 100644 libavcodec/ppc/flacdsp_init.c
>  create mode 100644 libavcodec/ppc/flacdsp_vsx.c
> 
> diff --git a/libavcodec/flacdsp.c b/libavcodec/flacdsp.c
> index f5362bf66f..b63d55ddcd 100644
> --- a/libavcodec/flacdsp.c
> +++ b/libavcodec/flacdsp.c
> @@ -156,5 +156,7 @@ av_cold void ff_flacdsp_init(FLACDSPContext *c, enum
> AVSampleFormat fmt, int cha ff_flacdsp_init_riscv(c, fmt, channels);
>  #elif ARCH_X86
>      ff_flacdsp_init_x86(c, fmt, channels);
> +#elif ARCH_PPC
> +    ff_flacdsp_init_ppc(c, fmt, channels);
>  #endif
>  }
> diff --git a/libavcodec/flacdsp.h b/libavcodec/flacdsp.h
> index 3b7b35a112..941536ef16 100644
> --- a/libavcodec/flacdsp.h
> +++ b/libavcodec/flacdsp.h
> @@ -45,5 +45,6 @@ void ff_flacdsp_init(FLACDSPContext *c, enum
> AVSampleFormat fmt, int channels); void ff_flacdsp_init_arm(FLACDSPContext
> *c, enum AVSampleFormat fmt, int channels); void
> ff_flacdsp_init_riscv(FLACDSPContext *c, enum AVSampleFormat fmt, int
> channels); void ff_flacdsp_init_x86(FLACDSPContext *c, enum AVSampleFormat
> fmt, int channels); +void ff_flacdsp_init_ppc(FLACDSPContext *c, enum
> AVSampleFormat fmt, int channels);
> 
>  #endif /* AVCODEC_FLACDSP_H */
> diff --git a/libavcodec/ppc/Makefile b/libavcodec/ppc/Makefile
> index 10b9ca60da..7f81a8aa34 100644
> --- a/libavcodec/ppc/Makefile
> +++ b/libavcodec/ppc/Makefile
> @@ -2,6 +2,8 @@
>  OBJS-$(CONFIG_AUDIODSP)                += ppc/audiodsp.o
>  OBJS-$(CONFIG_BLOCKDSP)                += ppc/blockdsp.o
>  OBJS-$(CONFIG_FDCTDSP)                 += ppc/fdctdsp.o
> +OBJS-$(CONFIG_FLAC_DECODER)            += ppc/flacdsp_init.o
> +VSX-OBJS-$(CONFIG_FLAC_DECODER)        += ppc/flacdsp_vsx.o
>  OBJS-$(CONFIG_FMTCONVERT)              += ppc/fmtconvert_altivec.o
>  OBJS-$(CONFIG_H264CHROMA)              += ppc/h264chroma_init.o
>  OBJS-$(CONFIG_H264DSP)                 += ppc/h264dsp.o
> ppc/hpeldsp_altivec.o diff --git a/libavcodec/ppc/flacdsp_init.c
> b/libavcodec/ppc/flacdsp_init.c new file mode 100644
> index 0000000000..526bddddbf
> --- /dev/null
> +++ b/libavcodec/ppc/flacdsp_init.c
> @@ -0,0 +1,38 @@
> +/*
> + * Copyright (c) 2024 Sean McGovern <gseanmcg@gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA + */
> +
> +#include "config.h"
> +
> +#include "libavutil/attributes.h"
> +#include "libavutil/cpu.h"
> +#include "libavutil/ppc/cpu.h"
> +#include "libavcodec/flacdsp.h"
> +
> +void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
> +
> +av_cold void ff_flacdsp_init_ppc(FLACDSPContext *c, enum AVSampleFormat
> fmt, int channels) +{
> +#if HAVE_VSX
> +    if (!PPC_VSX(av_get_cpu_flags()))
> +        return;
> +
> +    c->wasted32 = ff_flac_wasted32_vsx;
> +#endif
> +}
> diff --git a/libavcodec/ppc/flacdsp_vsx.c b/libavcodec/ppc/flacdsp_vsx.c
> new file mode 100644
> index 0000000000..7464108c45
> --- /dev/null
> +++ b/libavcodec/ppc/flacdsp_vsx.c
> @@ -0,0 +1,53 @@
> +/*
> + * Copyright (c) 2024 Sean McGovern <gseanmcg@gmail.com>
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA + */
> +
> +#include "config.h"
> +
> +#include "libavutil/attributes.h"
> +#include "libavutil/cpu.h"
> +#include "libavutil/ppc/cpu.h"
> +#include "libavutil/ppc/util_altivec.h"
> +#include "libavcodec/flacdsp.h"
> +
> +void ff_flac_wasted32_vsx(int32_t *, int wasted, int len);
> +
> +#if HAVE_VSX
> +
> +void ff_flac_wasted32_vsx(int32_t *decoded, int wasted, int len)
> +{
> +    register vec_s32 vec1, vec2;
> +    const register vec_u32 vwasted = vec_splats((unsigned)wasted);
> +
> +    for (int i = 0; i < len; i+=8 /* increment is by # elements, not bytes

You could do:

for (int32_t *const end = decoded + len; decoded < end; decoded += 8)

to keep just one counter rather than two. That said, maybe the C compiler 
performs that optimisation automatically anyway (?).

> */) {
> +	/* that said, we have some extra bandwidth so let's unroll it
> slightly */
> +        vec1 = vec_xl(0, decoded);
> +        vec2 = vec_xl(16, decoded);
> +
> +        vec1 = vec_sl(vec1, vwasted);
> +        vec2 = vec_sl(vec2, vwasted);
> +
> +        vec_xst(vec1, 0, decoded);
> +        vec_xst(vec2, 16, decoded);
> +
> +        decoded += 8;
> +    }
> +}
> +
> +#endif /* HAVE_VSX */


-- 
レミ・デニ-クールモン
http://www.remlab.net/



_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-07-13  8:51 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-04  1:23 [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags Sean McGovern
2024-07-04  1:23 ` [FFmpeg-devel] [PATCH 2/2] lavc/flacdsp: implement wasted32 DSP function for VSX on POWER Sean McGovern
2024-07-04 11:15   ` Rémi Denis-Courmont
2024-07-04 16:26     ` Sean McGovern
2024-07-04 17:45       ` Rémi Denis-Courmont
2024-07-06 20:00         ` Sean McGovern
2024-07-06 20:17           ` Rémi Denis-Courmont
2024-07-07 16:51             ` Sean McGovern
2024-07-07 18:21   ` [FFmpeg-devel] [PATCH] " Sean McGovern
2024-07-13  8:51     ` Rémi Denis-Courmont
2024-07-06 19:56 ` [FFmpeg-devel] [PATCH 1/2] configure: permit POWER9 cpu flags Sean McGovern
2024-07-12 21:09 ` Sean McGovern
2024-07-13  8:46 ` Rémi Denis-Courmont

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git