Runtime detection of available processor cores.
Detect the number of available cores and limit the thread allocation accordingly. On decoder side limit the number of threads to the max number of token partition. Core detetction works on Windows and Posix platforms, which define _SC_NPROCESSORS_ONLN or _SC_NPROC_ONLN. Change-Id: I76cbe37c18d3b8035e508b7a1795577674efc078
This commit is contained in:
@@ -429,12 +429,18 @@ void vp8_decoder_create_threads(VP8D_COMP *pbi)
|
||||
|
||||
pbi->b_multithreaded_rd = 0;
|
||||
pbi->allocated_decoding_thread_count = 0;
|
||||
core_count = (pbi->max_threads > 16) ? 16 : pbi->max_threads;
|
||||
|
||||
/* limit decoding threads to the max number of token partitions */
|
||||
core_count = (pbi->max_threads > 8) ? 8 : pbi->max_threads;
|
||||
|
||||
/* limit decoding threads to the available cores */
|
||||
if (core_count > pbi->common.processor_core_count)
|
||||
core_count = pbi->common.processor_core_count;
|
||||
|
||||
if (core_count > 1)
|
||||
{
|
||||
pbi->b_multithreaded_rd = 1;
|
||||
pbi->decoding_thread_count = core_count -1;
|
||||
pbi->decoding_thread_count = core_count - 1;
|
||||
|
||||
CHECK_MEM_ERROR(pbi->h_decoding_thread, vpx_malloc(sizeof(pthread_t) * pbi->decoding_thread_count));
|
||||
CHECK_MEM_ERROR(pbi->h_event_start_decoding, vpx_malloc(sizeof(sem_t) * pbi->decoding_thread_count));
|
||||
|
||||
Reference in New Issue
Block a user