[FFmpeg-devel] [PATCH 2/2] Add mutithread function for dnn_backend_native_layer_conv2d.c
Michael Niedermayer
michael at niedermayer.cc
Thu Sep 3 23:15:21 EEST 2020
On Thu, Sep 03, 2020 at 11:57:24PM +0800, xujunzz at sjtu.edu.cn wrote:
> From: Xu Jun <xujunzz at sjtu.edu.cn>
>
> Use pthread to multithread dnn_execute_layer_conv2d.
> Can be tested with command "./ffmpeg_g -i input.png -vf \
> format=yuvj420p,dnn_processing=dnn_backend=native:model= \
> espcn.model:input=x:output=y:options=conv2d_threads=23 \
> -y sr_native.jpg -benchmark"
>
> before patch: utime=11.238s stime=0.005s rtime=11.248s
> after patch: utime=20.817s stime=0.047s rtime=1.051s
> on my 3900X 12c24t @4.2GHz
>
> About the increase of utime, it's because that CPU HyperThreading
> technology makes logical cores twice of physical cores while cpu's
> counting performance improves less than double. And utime sums
> all cpu's logical cores' runtime. As a result, using threads num
> near cpu's logical core's number will double utime, while reduce
> rtime less than half for HyperThreading CPUs.
>
> Signed-off-by: Xu Jun <xujunzz at sjtu.edu.cn>
> ---
> .../dnn/dnn_backend_native_layer_conv2d.c | 92 ++++++++++++++++---
> 1 file changed, 81 insertions(+), 11 deletions(-)
[...]
> +typedef struct thread_param{
> + thread_common_param *thread_common_param;
> + int thread_index
semicolon missing
[...]
> + //join threads, res gets function return
> + for (int i = 0; i < thread_num; i++){
> + pthread_join(thread_id[i], &res);
this should be under something like HAVE_PTHREAD_CANCEL
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20200903/41b6bd84/attachment.sig>
More information about the ffmpeg-devel
mailing list