[FFmpeg-devel] [PATCH 4/5] avcodec/libsvtav1: support cores and socket options for svt av1
From: Limin Wang Signed-off-by: Limin Wang --- doc/encoders.texi | 9 + libavcodec/libsvtav1.c | 9 + 2 files changed, 18 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 2f5457f..da0b68d 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1747,6 +1747,15 @@ 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 cores +Set the number of logical processor which encoder threads run on. Default is: 0 +which is unset. If cores and socket are not set, threads are managed by OS thread +scheduler. + +@item socket +Set which target socket to run on. For multiple socket systems, this can specify which +socket the encoder runs on. Default is: -1 which is unset. + @end table @section libkvazaar diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 3e3b907..78e0ee5 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -71,6 +71,9 @@ typedef struct SvtContext { int tile_columns; int tile_rows; + +int cores; +int socket; } SvtContext; static const struct { @@ -204,6 +207,10 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, param->tile_columns = svt_enc->tile_columns; param->tile_rows= svt_enc->tile_rows; +if (svt_enc->cores > 0) +param->logical_processors = svt_enc->cores; +if (svt_enc->socket >= 0) +param->target_socket = svt_enc->socket; return 0; } @@ -519,6 +526,8 @@ 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}, +{ "cores", "Number of logical cores, 0: unset", OFFSET(cores), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE}, +{ "socket", "Target socket to run on. -1: unset", OFFSET(socket), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, {NULL}, }; -- 1.8.3.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-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/5] avcodec/libsvtav1: support cores and socket options for svt av1
On 01/08/2020 12:22, lance.lmw...@gmail.com wrote: From: Limin Wang Signed-off-by: Limin Wang --- doc/encoders.texi | 9 + libavcodec/libsvtav1.c | 9 + 2 files changed, 18 insertions(+) diff --git a/doc/encoders.texi b/doc/encoders.texi index 2f5457f..da0b68d 100644 --- a/doc/encoders.texi +++ b/doc/encoders.texi @@ -1747,6 +1747,15 @@ 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 cores +Set the number of logical processor which encoder threads run on. Default is: 0 +which is unset. If cores and socket are not set, threads are managed by OS thread +scheduler. + +@item socket +Set which target socket to run on. For multiple socket systems, this can specify which +socket the encoder runs on. Default is: -1 which is unset. + @end table @section libkvazaar diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c index 3e3b907..78e0ee5 100644 --- a/libavcodec/libsvtav1.c +++ b/libavcodec/libsvtav1.c @@ -71,6 +71,9 @@ typedef struct SvtContext { int tile_columns; int tile_rows; + +int cores; +int socket; } SvtContext; static const struct { @@ -204,6 +207,10 @@ static int config_enc_params(EbSvtAv1EncConfiguration *param, param->tile_columns = svt_enc->tile_columns; param->tile_rows= svt_enc->tile_rows; +if (svt_enc->cores > 0) +param->logical_processors = svt_enc->cores; +if (svt_enc->socket >= 0) +param->target_socket = svt_enc->socket; return 0; } @@ -519,6 +526,8 @@ 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}, +{ "cores", "Number of logical cores, 0: unset", OFFSET(cores), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE}, I think you'd be better using the standard option -threads (AVCodecContext.thread_count) rather than inventing a special one for this encoder only. +{ "socket", "Target socket to run on. -1: unset", OFFSET(socket), AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, This sort of thing has always been supported by OS-level tools, so it's not obvious to me that a special crude option here is helpful. Why would you use this rather than your favourite OS-level tool? E.g. the Linux tools (taskset, numactl) and APIs (sched_setaffinity(), set_mempolicy()) are more flexible than this option and also work on all other encoders. {NULL}, }; - Mark ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/5] avcodec/libsvtav1: support cores and socket options for svt av1
On 8/1/2020 8:22 AM, lance.lmw...@gmail.com wrote: > From: Limin Wang > > Signed-off-by: Limin Wang > --- > doc/encoders.texi | 9 + > libavcodec/libsvtav1.c | 9 + > 2 files changed, 18 insertions(+) > > diff --git a/doc/encoders.texi b/doc/encoders.texi > index 2f5457f..da0b68d 100644 > --- a/doc/encoders.texi > +++ b/doc/encoders.texi > @@ -1747,6 +1747,15 @@ 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 cores > +Set the number of logical processor which encoder threads run on. Default > is: 0 > +which is unset. If cores and socket are not set, threads are managed by OS > thread > +scheduler. > + > +@item socket > +Set which target socket to run on. For multiple socket systems, this can > specify which > +socket the encoder runs on. Default is: -1 which is unset. > + > @end table > > @section libkvazaar > diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c > index 3e3b907..78e0ee5 100644 > --- a/libavcodec/libsvtav1.c > +++ b/libavcodec/libsvtav1.c > @@ -71,6 +71,9 @@ typedef struct SvtContext { > > int tile_columns; > int tile_rows; > + > +int cores; > +int socket; > } SvtContext; > > static const struct { > @@ -204,6 +207,10 @@ static int config_enc_params(EbSvtAv1EncConfiguration > *param, > > param->tile_columns = svt_enc->tile_columns; > param->tile_rows= svt_enc->tile_rows; > +if (svt_enc->cores > 0) > +param->logical_processors = svt_enc->cores; > +if (svt_enc->socket >= 0) > +param->target_socket = svt_enc->socket; > > return 0; > } > @@ -519,6 +526,8 @@ 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}, > +{ "cores", "Number of logical cores, 0: unset", OFFSET(cores), > AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE}, > +{ "socket", "Target socket to run on. -1: unset", OFFSET(socket), > AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, > > {NULL}, > }; There's a WIP merge request that attempts to introduce a threads option that maps well with our AVCodecContext->threads field in https://github.com/OpenVisualCloud/SVT-AV1/pull/1367, so i personally think it's best to wait for it instead. Also, there's work to introduce a key=value option parsing API, which would let us add a x264-params style option and avoid adding a hundred options for every single EbSvtAv1EncConfiguration field. ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-devel] [PATCH 4/5] avcodec/libsvtav1: support cores and socket options for svt av1
On Sat, Aug 01, 2020 at 10:15:02AM -0300, James Almer wrote: > On 8/1/2020 8:22 AM, lance.lmw...@gmail.com wrote: > > From: Limin Wang > > > > Signed-off-by: Limin Wang > > --- > > doc/encoders.texi | 9 + > > libavcodec/libsvtav1.c | 9 + > > 2 files changed, 18 insertions(+) > > > > diff --git a/doc/encoders.texi b/doc/encoders.texi > > index 2f5457f..da0b68d 100644 > > --- a/doc/encoders.texi > > +++ b/doc/encoders.texi > > @@ -1747,6 +1747,15 @@ 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 cores > > +Set the number of logical processor which encoder threads run on. Default > > is: 0 > > +which is unset. If cores and socket are not set, threads are managed by OS > > thread > > +scheduler. > > + > > +@item socket > > +Set which target socket to run on. For multiple socket systems, this can > > specify which > > +socket the encoder runs on. Default is: -1 which is unset. > > + > > @end table > > > > @section libkvazaar > > diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c > > index 3e3b907..78e0ee5 100644 > > --- a/libavcodec/libsvtav1.c > > +++ b/libavcodec/libsvtav1.c > > @@ -71,6 +71,9 @@ typedef struct SvtContext { > > > > int tile_columns; > > int tile_rows; > > + > > +int cores; > > +int socket; > > } SvtContext; > > > > static const struct { > > @@ -204,6 +207,10 @@ static int config_enc_params(EbSvtAv1EncConfiguration > > *param, > > > > param->tile_columns = svt_enc->tile_columns; > > param->tile_rows= svt_enc->tile_rows; > > +if (svt_enc->cores > 0) > > +param->logical_processors = svt_enc->cores; > > +if (svt_enc->socket >= 0) > > +param->target_socket = svt_enc->socket; > > > > return 0; > > } > > @@ -519,6 +526,8 @@ 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}, > > +{ "cores", "Number of logical cores, 0: unset", OFFSET(cores), > > AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, VE}, > > +{ "socket", "Target socket to run on. -1: unset", OFFSET(socket), > > AV_OPT_TYPE_INT, {.i64 = -1}, -1, INT_MAX, VE}, > > > > {NULL}, > > }; > > There's a WIP merge request that attempts to introduce a threads option > that maps well with our AVCodecContext->threads field in > https://github.com/OpenVisualCloud/SVT-AV1/pull/1367, so i personally > think it's best to wait for it instead. Sorry, I haven't notice that, threads have no knowledge for socket or numa node, it'll depend on system tool to finished it. I recall x265 have pools option also. > > Also, there's work to introduce a key=value option parsing API, which > would let us add a x264-params style option and avoid adding a hundred > options for every single EbSvtAv1EncConfiguration field. So, please wait for the svt-params options for the new options. > ___ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". -- Thanks, Limin Wang ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".