* [FFmpeg-devel] [PATCH] hwcontext_opencl: choose the first device if multiple devices are available
@ 2024-01-17 7:36 Xiang, Haihao
2024-01-22 20:32 ` Mark Thompson
0 siblings, 1 reply; 4+ messages in thread
From: Xiang, Haihao @ 2024-01-17 7:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Haihao Xiang
From: Haihao Xiang <haihao.xiang@intel.com>
This makes '-init_hw_device opencl' work in a multiple-device system.
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
---
doc/ffmpeg.texi | 5 +++++
libavutil/hwcontext_opencl.c | 9 ++++-----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 7246a46d2f..edda0d5d9b 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1424,6 +1424,8 @@ Choose the GPU subdevice with type @samp{dxva2} and create QSV device with @samp
The set of devices can also be filtered using the key-value pairs to find only
devices matching particular platform or device strings.
+If more than one matching device found, choose the first one from the set of devices.
+
The strings usable as filters are:
@table @option
@item platform_profile
@@ -1444,6 +1446,9 @@ The indices and filters must together uniquely select a device.
Examples:
@table @emph
+@item -init_hw_device opencl
+Choose the first device on the first platform.
+
@item -init_hw_device opencl:0.1
Choose the second device on the first platform.
diff --git a/libavutil/hwcontext_opencl.c b/libavutil/hwcontext_opencl.c
index 247834aaf6..98e35919bf 100644
--- a/libavutil/hwcontext_opencl.c
+++ b/libavutil/hwcontext_opencl.c
@@ -515,7 +515,7 @@ static int opencl_device_create_internal(AVHWDeviceContext *hwdev,
return err;
found = 0;
- for (p = 0; p < nb_platforms; p++) {
+ for (p = nb_platforms - 1; p >= 0; p--) {
const char *platform_name;
if (selector->platform_index >= 0 &&
@@ -546,7 +546,7 @@ static int opencl_device_create_internal(AVHWDeviceContext *hwdev,
if (err < 0)
continue;
- for (d = 0; d < nb_devices; d++) {
+ for (d = nb_devices - 1; d >= 0; d--) {
const char *device_name;
if (selector->device_index >= 0 &&
@@ -588,9 +588,8 @@ static int opencl_device_create_internal(AVHWDeviceContext *hwdev,
goto fail;
}
if (found > 1) {
- av_log(hwdev, AV_LOG_ERROR, "More than one matching device found.\n");
- err = AVERROR(ENODEV);
- goto fail;
+ av_log(hwdev, AV_LOG_VERBOSE,
+ "More than one matching device found, choose the first device.\n");
}
if (!props) {
--
2.34.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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] hwcontext_opencl: choose the first device if multiple devices are available
2024-01-17 7:36 [FFmpeg-devel] [PATCH] hwcontext_opencl: choose the first device if multiple devices are available Xiang, Haihao
@ 2024-01-22 20:32 ` Mark Thompson
2024-01-23 2:52 ` Xiang, Haihao
0 siblings, 1 reply; 4+ messages in thread
From: Mark Thompson @ 2024-01-22 20:32 UTC (permalink / raw)
To: ffmpeg-devel
On 17/01/2024 07:36, Xiang, Haihao wrote:
> From: Haihao Xiang <haihao.xiang@intel.com>
>
> This makes '-init_hw_device opencl' work in a multiple-device system.
Under what circumstances is this more useful than the existing behaviour which prompts the user to select the device they intend?
There is no particular ordering to devices, the first one is just random. Having your process fail with an opaque message (because the device picked lacks some operation) or run many times slower than expected (because the smallest device happened to be first in the list) or do something different on a machine which looks the same (because it has an extra driver for something else) rather than just saying up front that there are multiple devices and the user needs to pick seems worse to me, since it is much harder to see where the problem is.
Thanks,
- 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-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] hwcontext_opencl: choose the first device if multiple devices are available
2024-01-22 20:32 ` Mark Thompson
@ 2024-01-23 2:52 ` Xiang, Haihao
2024-01-30 6:32 ` Xiang, Haihao
0 siblings, 1 reply; 4+ messages in thread
From: Xiang, Haihao @ 2024-01-23 2:52 UTC (permalink / raw)
To: ffmpeg-devel
On Ma, 2024-01-22 at 20:32 +0000, Mark Thompson wrote:
> On 17/01/2024 07:36, Xiang, Haihao wrote:
> > From: Haihao Xiang <haihao.xiang@intel.com>
> >
> > This makes '-init_hw_device opencl' work in a multiple-device system.
>
> Under what circumstances is this more useful than the existing behaviour which
> prompts the user to select the device they intend?
@item -init_hw_device
@var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
My understanding is that only @var{type} is mandatory, @var{device} (and others)
is optional, indeed '-init_hw_device opencl' works well in a single-device
system, however the same command doesn't work in a multiple-device system. It is
not a good experience for me.
>
> There is no particular ordering to devices, the first one is just random.
> Having your process fail with an opaque message (because the device picked
> lacks some operation) or run many times slower than expected (because the
> smallest device happened to be first in the list) or do something different on
> a machine which looks the same (because it has an extra driver for something
> else) rather than just saying up front that there are multiple devices and the
> user needs to pick seems worse to me, since it is much harder to see where the
> problem is.
I understand your concern, how about making the default works while prompting a
warning about the device selection ?
Thanks
Haihao
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH] hwcontext_opencl: choose the first device if multiple devices are available
2024-01-23 2:52 ` Xiang, Haihao
@ 2024-01-30 6:32 ` Xiang, Haihao
0 siblings, 0 replies; 4+ messages in thread
From: Xiang, Haihao @ 2024-01-30 6:32 UTC (permalink / raw)
To: ffmpeg-devel
On Di, 2024-01-23 at 02:52 +0000, Xiang, Haihao wrote:
> On Ma, 2024-01-22 at 20:32 +0000, Mark Thompson wrote:
> > On 17/01/2024 07:36, Xiang, Haihao wrote:
> > > From: Haihao Xiang <haihao.xiang@intel.com>
> > >
> > > This makes '-init_hw_device opencl' work in a multiple-device system.
> >
> > Under what circumstances is this more useful than the existing behaviour
> > which
> > prompts the user to select the device they intend?
>
> @item -init_hw_device
> @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
>
> My understanding is that only @var{type} is mandatory, @var{device} (and
> others)
> is optional, indeed '-init_hw_device opencl' works well in a single-device
> system, however the same command doesn't work in a multiple-device system. It
> is
> not a good experience for me.
>
> >
> > There is no particular ordering to devices, the first one is just random.
> > Having your process fail with an opaque message (because the device picked
> > lacks some operation) or run many times slower than expected (because the
> > smallest device happened to be first in the list) or do something different
> > on
> > a machine which looks the same (because it has an extra driver for something
> > else) rather than just saying up front that there are multiple devices and
> > the
> > user needs to pick seems worse to me, since it is much harder to see where
> > the
> > problem is.
>
> I understand your concern, how about making the default works while prompting
> a
> warning about the device selection ?
Hi Mark,
Do you have more comments ?
Thanks
Haihao
_______________________________________________
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".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-01-30 6:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-17 7:36 [FFmpeg-devel] [PATCH] hwcontext_opencl: choose the first device if multiple devices are available Xiang, Haihao
2024-01-22 20:32 ` Mark Thompson
2024-01-23 2:52 ` Xiang, Haihao
2024-01-30 6:32 ` Xiang, Haihao
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git