diff mbox series

[FFmpeg-devel,v3] libsvtav1: Add logical_processors option

Message ID 20210227000023.803497-1-ccom@randomderp.com
State Superseded
Headers show
Series [FFmpeg-devel,v3] libsvtav1: Add logical_processors option
Related show

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Christopher Degawa Feb. 27, 2021, midnight UTC
From: Christopher Degawa <christopher.degawa@intel.com>

Used for limiting the size of memory buffers and threads for a target
logical processor count, but does not set thread affinity or limit the
amount of threads used, although thread affinities can be controlled
with an additional parameters, it is prefered to add them until
a svtav1-params option or similar is added

Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
---
 doc/encoders.texi      | 5 +++++
 libavcodec/libsvtav1.c | 7 +++++++
 2 files changed, 12 insertions(+)

Comments

Marvin Scholz Feb. 27, 2021, 12:03 a.m. UTC | #1
On 27 Feb 2021, at 1:00, Christopher Degawa wrote:

> From: Christopher Degawa <christopher.degawa@intel.com>
>
> Used for limiting the size of memory buffers and threads for a target
> logical processor count, but does not set thread affinity or limit the
> amount of threads used, although thread affinities can be controlled
> with an additional parameters, it is prefered to add them until
> a svtav1-params option or similar is added
>
> Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
> ---
>  doc/encoders.texi      | 5 +++++
>  libavcodec/libsvtav1.c | 7 +++++++
>  2 files changed, 12 insertions(+)
>
> diff --git a/doc/encoders.texi b/doc/encoders.texi
> index c9c8785afb..e3b5ae8bab 100644
> --- a/doc/encoders.texi
> +++ b/doc/encoders.texi
> @@ -1795,6 +1795,11 @@ Set log2 of the number of rows of tiles to use 
> (0-6).
>  @item tile_columns
>  Set log2 of the number of columns of tiles to use (0-4).
>
> +@item logical_processors
> +Number of logical processors to run the encoder on, threads are 
> managed by the OS scheduler.
> +Used for limiting the size of memory buffers and threads for a target 
> logical processor count.
> +Does not set thread affinity or limit threads.
> +

Maybe I am reading this wrong or not understanding but this says it is
used for limiting threads and then in the next sentence says it does
not limit threads?

It is quite confusing.

>  @end table
>
>  @section libkvazaar
> diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
> index eb6043bcac..087b14099f 100644
> --- a/libavcodec/libsvtav1.c
> +++ b/libavcodec/libsvtav1.c
> @@ -71,6 +71,8 @@ typedef struct SvtContext {
>
>      int tile_columns;
>      int tile_rows;
> +
> +    unsigned logical_processors;
>  } SvtContext;
>
>  static const struct {
> @@ -218,6 +220,8 @@ static int 
> config_enc_params(EbSvtAv1EncConfiguration *param,
>      param->tile_columns = svt_enc->tile_columns;
>      param->tile_rows    = svt_enc->tile_rows;
>
> +    param->logical_processors = svt_enc->logical_processors;
> +
>      return 0;
>  }
>
> @@ -533,6 +537,9 @@ static const AVOption options[] = {
>      { "tile_columns", "Log2 of number of tile columns to use", 
> OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
>      { "tile_rows", "Log2 of number of tile rows to use", 
> OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE},
>
> +    { "logical_processors", "Number of logical processors to run the 
> encoder on, used to limit the size of memory buffers and threads 
> used", OFFSET(logical_processors),
> +      AV_OPT_TYPE_INT, { .i64 = 0 }, 0,  INT_MAX, VE },
> +
>      {NULL},
>  };
>
> -- 
> 2.25.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
Christopher Degawa Feb. 27, 2021, 12:09 a.m. UTC | #2
> Maybe I am reading this wrong or not understanding but this says it is
> used for limiting threads and then in the next sentence says it does
> not limit threads?
>
> It is quite confusing.
>
it's confusing for me too, but the idea is that it doesn't set n threads,
but it can be used to make it so instead of t * nproc threads, you can make
it t * logical_processor amount of threads
diff mbox series

Patch

diff --git a/doc/encoders.texi b/doc/encoders.texi
index c9c8785afb..e3b5ae8bab 100644
--- a/doc/encoders.texi
+++ b/doc/encoders.texi
@@ -1795,6 +1795,11 @@  Set log2 of the number of rows of tiles to use (0-6).
 @item tile_columns
 Set log2 of the number of columns of tiles to use (0-4).
 
+@item logical_processors
+Number of logical processors to run the encoder on, threads are managed by the OS scheduler.
+Used for limiting the size of memory buffers and threads for a target logical processor count.
+Does not set thread affinity or limit threads.
+
 @end table
 
 @section libkvazaar
diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index eb6043bcac..087b14099f 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -71,6 +71,8 @@  typedef struct SvtContext {
 
     int tile_columns;
     int tile_rows;
+
+    unsigned logical_processors;
 } SvtContext;
 
 static const struct {
@@ -218,6 +220,8 @@  static int config_enc_params(EbSvtAv1EncConfiguration *param,
     param->tile_columns = svt_enc->tile_columns;
     param->tile_rows    = svt_enc->tile_rows;
 
+    param->logical_processors = svt_enc->logical_processors;
+
     return 0;
 }
 
@@ -533,6 +537,9 @@  static const AVOption options[] = {
     { "tile_columns", "Log2 of number of tile columns to use", OFFSET(tile_columns), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, VE},
     { "tile_rows", "Log2 of number of tile rows to use", OFFSET(tile_rows), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 6, VE},
 
+    { "logical_processors", "Number of logical processors to run the encoder on, used to limit the size of memory buffers and threads used", OFFSET(logical_processors),
+      AV_OPT_TYPE_INT, { .i64 = 0 }, 0,  INT_MAX, VE },
+
     {NULL},
 };