From daee3dcf22cdeb96ec6ec463a86530813e4ea024 Mon Sep 17 00:00:00 2001 From: Sijia Chen Date: Mon, 15 Jun 2015 18:09:39 +0800 Subject: [PATCH 1/2] remove one always-on macro to save code complexity, and use core-1 for multi-threading in real-time --- codec/encoder/core/inc/mt_defs.h | 3 --- codec/encoder/core/src/encoder_ext.cpp | 14 +++++--------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/codec/encoder/core/inc/mt_defs.h b/codec/encoder/core/inc/mt_defs.h index 08fc1bcc..62d8f39f 100644 --- a/codec/encoder/core/inc/mt_defs.h +++ b/codec/encoder/core/inc/mt_defs.h @@ -51,9 +51,6 @@ //#define MT_DEBUG //#define ENABLE_TRACE_MT - -#define DYNAMIC_DETECT_CPU_CORES - #define THRESHOLD_RMSE_CORE8 0.0320f // v1.1: 0.0320f; v1.0: 0.02f #define THRESHOLD_RMSE_CORE4 0.0215f // v1.1: 0.0215f; v1.0: 0.03f #define THRESHOLD_RMSE_CORE2 0.0200f // v1.1: 0.0200f; v1.0: 0.04f diff --git a/codec/encoder/core/src/encoder_ext.cpp b/codec/encoder/core/src/encoder_ext.cpp index 75020c09..d94f0b61 100644 --- a/codec/encoder/core/src/encoder_ext.cpp +++ b/codec/encoder/core/src/encoder_ext.cpp @@ -2395,22 +2395,18 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding iCacheLineSize = 16; // 16 bytes aligned in default #endif//X86_ASM -#if defined(DYNAMIC_DETECT_CPU_CORES) if (pCodingParam->iMultipleThreadIdc > 0) uiCpuCores = pCodingParam->iMultipleThreadIdc; else { if (uiCpuCores == - 0) // cpuid not supported or doesn't expose the number of cores, use high level system API as followed to detect number of pysical/logic processor + 0) { // cpuid not supported or doesn't expose the number of cores, use high level system API as followed to detect number of pysical/logic processor uiCpuCores = DynamicDetectCpuCores(); - // So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, + }// So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, // for client application here it is constrained by maximal to MAX_THREADS_NUM - if (uiCpuCores > MAX_THREADS_NUM) // MAX_THREADS_NUM - uiCpuCores = MAX_THREADS_NUM; // MAX_THREADS_NUM - else if (uiCpuCores < 1) // just for safe - uiCpuCores = 1; + if ((pCodingParam->iUsageType == CAMERA_VIDEO_REAL_TIME) || (pCodingParam->iUsageType == SCREEN_CONTENT_REAL_TIME)) { + uiCpuCores -= 1; // minus 1 for REAL_TIME video, for the processing needed by other threads + } } -#endif//DYNAMIC_DETECT_CPU_CORES - uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM); if (InitSliceSettings (pLogCtx, pCodingParam, uiCpuCores, &iSliceNum)) { From ee4dafaa7071ae57aa9720bd8f80a4d3742bd571 Mon Sep 17 00:00:00 2001 From: Sijia Chen Date: Tue, 16 Jun 2015 17:05:48 +0800 Subject: [PATCH 2/2] remove the core-1 setting for multi-thread, if application has concern of using all thread, it can be done by setting specific value to iMultipleThreadIdc --- codec/encoder/core/src/encoder_ext.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/codec/encoder/core/src/encoder_ext.cpp b/codec/encoder/core/src/encoder_ext.cpp index d94f0b61..df1cbe90 100644 --- a/codec/encoder/core/src/encoder_ext.cpp +++ b/codec/encoder/core/src/encoder_ext.cpp @@ -2403,9 +2403,6 @@ int32_t GetMultipleThreadIdc (SLogContext* pLogCtx, SWelsSvcCodingParam* pCoding uiCpuCores = DynamicDetectCpuCores(); }// So far so many cpu cores up to MAX_THREADS_NUM mean for server platforms, // for client application here it is constrained by maximal to MAX_THREADS_NUM - if ((pCodingParam->iUsageType == CAMERA_VIDEO_REAL_TIME) || (pCodingParam->iUsageType == SCREEN_CONTENT_REAL_TIME)) { - uiCpuCores -= 1; // minus 1 for REAL_TIME video, for the processing needed by other threads - } } uiCpuCores = WELS_CLIP3 (uiCpuCores, 1, MAX_THREADS_NUM);