Fix incorrect use of 32-bit types for threading bitmaps on AArch64 by
adding the appropriate AArch64 architecture #ifdef. This now allows
up to 64 threads per pool on AArch64. Add an error check in thread pool
creation when the number of threads is larger than 64.
---
source/CMakeLists.txt | 2 +-
source/common/threadpool.cpp | 10 +++++++---
source/common/threadpool.h | 2 +-
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 2e3beaaf3..0a3762c45 100755
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -87,6 +87,7 @@ elseif(ARMMATCH GREATER "-1")
elseif(ARM64MATCH GREATER "-1")
message(STATUS "Detected ARM64 target processor")
set(ARM64 1)
+ add_definitions(-DX265_ARCH_ARM64=1)
option(AARCH64_WARNINGS_AS_ERRORS "Build with -Werror for AArch64
Intrinsics files" OFF)
@@ -316,7 +317,6 @@ if(GCC)
endif()
if(ARM64)
set(CPU_HAS_NEON 1)
- add_definitions(-DX265_ARCH_ARM64=1)
if (AARCH64_RUNTIME_CPU_DETECT)
add_definitions(-DAARCH64_RUNTIME_CPU_DETECT=1)
diff --git a/source/common/threadpool.cpp b/source/common/threadpool.cpp
index 6bde73c1d..6048a5679 100644
--- a/source/common/threadpool.cpp
+++ b/source/common/threadpool.cpp
@@ -42,7 +42,7 @@
#include <cstdlib>
#endif
-#if X86_64
+#if X86_64 || X265_ARCH_ARM64
#ifdef __GNUC__
@@ -639,8 +639,12 @@ ThreadPool::ThreadPool()
bool ThreadPool::create(int numThreads, int maxProviders, uint64_t nodeMask)
{
- X265_CHECK(numThreads <= MAX_POOL_THREADS, "a single thread pool cannot
have more than MAX_POOL_THREADS threads\n");
-
+ if (numThreads > MAX_POOL_THREADS)
+ {
+ x265_log(NULL, X265_LOG_ERROR,
+ "a single thread pool cannot have more than MAX_POOL_THREADS
threads\n");
+ return false;
+ }
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
memset(&m_groupAffinity, 0, sizeof(GROUP_AFFINITY));
for (int i = 0; i < getNumaNodeCount(); i++)
diff --git a/source/common/threadpool.h b/source/common/threadpool.h
index 04e35528e..a1649e5ef 100644
--- a/source/common/threadpool.h
+++ b/source/common/threadpool.h
@@ -34,7 +34,7 @@ class ThreadPool;
class WorkerThread;
class BondedTaskGroup;
-#if X86_64
+#if X86_64 || X265_ARCH_ARM64
typedef uint64_t sleepbitmap_t;
#else
typedef uint32_t sleepbitmap_t;
--
2.50.1 (Apple Git-155)
>From 5c54b2c269650ceec586e6df204eb0fc0394d7cd Mon Sep 17 00:00:00 2001
Message-ID:
<5c54b2c269650ceec586e6df204eb0fc0394d7cd.1778784911.git.luis.ho...@arm.com>
From: Luis Horna Carranza <[email protected]>
Date: Mon, 27 Apr 2026 16:01:35 -0500
Subject: [PATCH] AArch64: Use 64-bit types for threading bitmaps
Fix incorrect use of 32-bit types for threading bitmaps on AArch64 by
adding the appropriate AArch64 architecture #ifdef. This now allows
up to 64 threads per pool on AArch64. Add an error check in thread pool
creation when the number of threads is larger than 64.
---
source/CMakeLists.txt | 2 +-
source/common/threadpool.cpp | 10 +++++++---
source/common/threadpool.h | 2 +-
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt
index 2e3beaaf3..0a3762c45 100755
--- a/source/CMakeLists.txt
+++ b/source/CMakeLists.txt
@@ -87,6 +87,7 @@ elseif(ARMMATCH GREATER "-1")
elseif(ARM64MATCH GREATER "-1")
message(STATUS "Detected ARM64 target processor")
set(ARM64 1)
+ add_definitions(-DX265_ARCH_ARM64=1)
option(AARCH64_WARNINGS_AS_ERRORS "Build with -Werror for AArch64
Intrinsics files" OFF)
@@ -316,7 +317,6 @@ if(GCC)
endif()
if(ARM64)
set(CPU_HAS_NEON 1)
- add_definitions(-DX265_ARCH_ARM64=1)
if (AARCH64_RUNTIME_CPU_DETECT)
add_definitions(-DAARCH64_RUNTIME_CPU_DETECT=1)
diff --git a/source/common/threadpool.cpp b/source/common/threadpool.cpp
index 6bde73c1d..6048a5679 100644
--- a/source/common/threadpool.cpp
+++ b/source/common/threadpool.cpp
@@ -42,7 +42,7 @@
#include <cstdlib>
#endif
-#if X86_64
+#if X86_64 || X265_ARCH_ARM64
#ifdef __GNUC__
@@ -639,8 +639,12 @@ ThreadPool::ThreadPool()
bool ThreadPool::create(int numThreads, int maxProviders, uint64_t nodeMask)
{
- X265_CHECK(numThreads <= MAX_POOL_THREADS, "a single thread pool cannot
have more than MAX_POOL_THREADS threads\n");
-
+ if (numThreads > MAX_POOL_THREADS)
+ {
+ x265_log(NULL, X265_LOG_ERROR,
+ "a single thread pool cannot have more than MAX_POOL_THREADS
threads\n");
+ return false;
+ }
#if defined(_WIN32_WINNT) && _WIN32_WINNT >= _WIN32_WINNT_WIN7
memset(&m_groupAffinity, 0, sizeof(GROUP_AFFINITY));
for (int i = 0; i < getNumaNodeCount(); i++)
diff --git a/source/common/threadpool.h b/source/common/threadpool.h
index 04e35528e..a1649e5ef 100644
--- a/source/common/threadpool.h
+++ b/source/common/threadpool.h
@@ -34,7 +34,7 @@ class ThreadPool;
class WorkerThread;
class BondedTaskGroup;
-#if X86_64
+#if X86_64 || X265_ARCH_ARM64
typedef uint64_t sleepbitmap_t;
#else
typedef uint32_t sleepbitmap_t;
--
2.50.1 (Apple Git-155)
_______________________________________________
x265-devel mailing list
[email protected]
https://mailman.videolan.org/listinfo/x265-devel