[x265] [PATCH] Fix cpu capability issue

Ponsanthini Arunachalam ponsanthini.arunachalam at multicorewareinc.com
Fri Oct 4 08:22:27 UTC 2024


Please find the updated patch below :
>From 555108b18ded7b92d57b6060cd5e82593e0e3c5b Mon Sep 17 00:00:00 2001
From: Ponsanthini <ponsanthini.arunachalam at muticorewareinc.com>
Date: Fri, 4 Oct 2024 08:13:35 +0000
Subject: [PATCH] Fix cpu capability issue

---
 source/CMakeLists.txt | 4 ++++
 source/common/cpu.cpp | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index d1fe38559..cd19050c3 100755
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -479,6 +479,10 @@ else()
     option(ENABLE_ASSEMBLY "Enable use of assembly coded primitives" OFF)
 endif()

+if(ENABLE_ASSEMBLY)
+   add_definitions(-DENABLE_ASSEMBLY)
+endif()
+
 option(CHECKED_BUILD "Enable run-time sanity checks (debugging)" OFF)
 if(CHECKED_BUILD)
     add_definitions(-DCHECKED_BUILD=1)
diff --git a/source/common/cpu.cpp b/source/common/cpu.cpp
index aab360c17..c1fa928e4 100644
--- a/source/common/cpu.cpp
+++ b/source/common/cpu.cpp
@@ -396,6 +396,7 @@ uint32_t cpu_detect(bool /*benableavx512*/)
 {
     int flags = 0;

+#ifdef ENABLE_ASSEMBLY
     #if HAVE_NEON
          flags |= X265_CPU_NEON;
     #endif
@@ -411,6 +412,7 @@ uint32_t cpu_detect(bool /*benableavx512*/)
     #if HAVE_SVE2
          flags |= X265_CPU_SVE2;
     #endif
+#endif

     return flags;
 }
@@ -442,6 +444,7 @@ uint32_t cpu_detect(bool /*benableavx512*/)

     int flags = 0;

+#ifdef ENABLE_ASSEMBLY
     #if HAVE_NEON
          flags |= X265_CPU_NEON;    // All of ARM64 has NEON
     #endif
@@ -457,6 +460,7 @@ uint32_t cpu_detect(bool /*benableavx512*/)
     #if HAVE_SVE2 && defined(PF_ARM_SVE2_INSTRUCTIONS_AVAILABLE)
          flags |=
IsProcessorFeaturePresent(PF_ARM_SVE2_INSTRUCTIONS_AVAILABLE) ?
X265_CPU_SVE2 : 0;
     #endif
+#endif

     return flags;
 } // end of Windows+Aarch64
@@ -473,6 +477,7 @@ uint32_t cpu_detect(bool /*benableavx512*/)

     int flags = 0;

+#ifdef ENABLE_ASSEMBLY
     #if HAVE_NEON
          flags |= X265_CPU_NEON;    // All of ARM64 has NEON
     #endif
@@ -488,6 +493,7 @@ uint32_t cpu_detect(bool /*benableavx512*/)
     #if HAVE_SVE2
          flags |= (hwcaps2 & HWCAP2_SVE2 ? X265_CPU_SVE2 : 0);
     #endif
+#endif

     return flags;
 }
-- 
2.34.1


On Mon, Sep 30, 2024 at 1:13 PM Ponsanthini Arunachalam <
ponsanthini.arunachalam at multicorewareinc.com> wrote:

> From d76788127f6a142ff41a8df19a0f9e74290689a8 Mon Sep 17 00:00:00 2001
> From: Ponsanthini <ponsanthini.arunachalam at muticorewareinc.com>
> Date: Mon, 30 Sep 2024 07:29:25 +0000
> Subject: [PATCH] Fix cpu capability issue
>
> ---
>  source/CMakeLists.txt |  4 ++++
>  source/common/cpu.cpp | 30 ++++++++++++++++--------------
>  2 files changed, 20 insertions(+), 14 deletions(-)
>
> diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
> index d1fe38559..3ec82c810 100755
> --- a/source/CMakeLists.txt
> +++ b/source/CMakeLists.txt
> @@ -479,6 +479,10 @@ else()
>      option(ENABLE_ASSEMBLY "Enable use of assembly coded primitives" OFF)
>  endif()
>
> +if(ENABLE_ASSEMBLY)
> +    add_definitions(-DENABLE_ASSEMBLY)
> +endif()
> +
>  option(CHECKED_BUILD "Enable run-time sanity checks (debugging)" OFF)
>  if(CHECKED_BUILD)
>      add_definitions(-DCHECKED_BUILD=1)
> diff --git a/source/common/cpu.cpp b/source/common/cpu.cpp
> index 4f4376184..e31647293 100644
> --- a/source/common/cpu.cpp
> +++ b/source/common/cpu.cpp
> @@ -455,20 +455,22 @@ uint32_t cpu_detect(bool benableavx512)
>
>      int flags = 0;
>
> -    #if HAVE_NEON
> -         flags |= X265_CPU_NEON;    // All of ARM64 has NEON
> -    #endif
> -    #if HAVE_NEON_DOTPROD
> -         flags |= (hwcaps & HWCAP_ASIMDDP ? X265_CPU_NEON_DOTPROD : 0);
> -    #endif
> -    #if HAVE_NEON_I8MM
> -         flags |= (hwcaps2 & HWCAP2_I8MM ? X265_CPU_NEON_I8MM : 0);
> -    #endif
> -    #if HAVE_SVE
> -         flags |= (hwcaps & HWCAP_SVE ? X265_CPU_SVE : 0);
> -    #endif
> -    #if HAVE_SVE2
> -         flags |= (hwcaps2 & HWCAP2_SVE2 ? X265_CPU_SVE2 : 0);
> +    #ifdef ENABLE_ASSEMBLY
> +        #if HAVE_NEON
> +             flags |= X265_CPU_NEON;
> +        #endif
> +        #if HAVE_NEON_DOTPROD
> +             flags |= X265_CPU_NEON_DOTPROD;
> +        #endif
> +        #if HAVE_NEON_I8MM
> +             flags |= X265_CPU_NEON_I8MM;
> +        #endif
> +        #if HAVE_SVE
> +             flags |= X265_CPU_SVE;
> +        #endif
> +        #if HAVE_SVE2
> +             flags |= X265_CPU_SVE2;
> +        #endif
>      #endif
>
>      return flags;
> --
> 2.34.1
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20241004/70f8b097/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v3-0001-Fix-cpu-capability-issue.patch
Type: application/octet-stream
Size: 2188 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20241004/70f8b097/attachment-0001.obj>


More information about the x265-devel mailing list