From 297b27655eaf4a0cfd097b2ae94add4b19fed9eb Mon Sep 17 00:00:00 2001 From: Attila Nagy Date: Fri, 25 Mar 2011 12:53:03 +0200 Subject: 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 --- vp8/encoder/ethreading.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'vp8/encoder/ethreading.c') diff --git a/vp8/encoder/ethreading.c b/vp8/encoder/ethreading.c index 71da1036a..fa6a943d1 100644 --- a/vp8/encoder/ethreading.c +++ b/vp8/encoder/ethreading.c @@ -459,15 +459,15 @@ void vp8cx_create_encoder_threads(VP8_COMP *cpi) cpi->b_multi_threaded = 0; cpi->encoding_thread_count = 0; - cpi->processor_core_count = 32; //vp8_get_proc_core_count(); - if (cpi->processor_core_count > 1 && cpi->oxcf.multi_threaded > 1) + if (cm->processor_core_count > 1 && cpi->oxcf.multi_threaded > 1) { int ithread; int th_count = cpi->oxcf.multi_threaded - 1; - if (cpi->oxcf.multi_threaded > cpi->processor_core_count) - th_count = cpi->processor_core_count - 1; + /* don't allocate more threads than cores available */ + if (cpi->oxcf.multi_threaded > cm->processor_core_count) + th_count = cm->processor_core_count - 1; /* we have th_count + 1 (main) threads processing one row each */ /* no point to have more threads than the sync range allows */ -- cgit v1.2.3 From eb16f00cf25e54f08c5a9ec25a8780ca708a2c3a Mon Sep 17 00:00:00 2001 From: Yunqing Wang Date: Thu, 5 May 2011 10:42:29 -0400 Subject: Fix rare hang in multi-thread encoder on Windows This patch is to fix a rare hang in multi-thread encoder that was only seen on Windows. Thanks for John's help in debugging the problem. More test is needed. Change-Id: Idb11c6d344c2082362a032b34c5a602a1eea62fc --- vp8/encoder/ethreading.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'vp8/encoder/ethreading.c') diff --git a/vp8/encoder/ethreading.c b/vp8/encoder/ethreading.c index c00494dcf..c92a366e8 100644 --- a/vp8/encoder/ethreading.c +++ b/vp8/encoder/ethreading.c @@ -514,6 +514,7 @@ void vp8cx_create_encoder_threads(VP8_COMP *cpi) LPFTHREAD_DATA * lpfthd = &cpi->lpf_thread_data; sem_init(&cpi->h_event_start_lpf, 0, 0); + sem_init(&cpi->h_event_end_picklpf, 0, 0); sem_init(&cpi->h_event_end_lpf, 0, 0); lpfthd->ptr1 = (void *)cpi; @@ -547,6 +548,7 @@ void vp8cx_remove_encoder_threads(VP8_COMP *cpi) sem_destroy(&cpi->h_event_end_encoding); sem_destroy(&cpi->h_event_end_lpf); + sem_destroy(&cpi->h_event_end_picklpf); sem_destroy(&cpi->h_event_start_lpf); //free thread related resources -- cgit v1.2.3