Repository navigation
Description
While looking at implementing the executionTime promise in Dawn some questions came up about it's intended behavior in some edge cases, with the big one being how should the API behave if the device has no timestamp query support. (As a concrete example: some Mali GPUs don't support timestamp queries at all.)
This is currently specced as a required feature, so we need to determine how to proceed for cases where it can't be implemented with timestamp queries or Metal's gpuBeginTime/gpuEndTime. For the record, this DID come up initially when initially designing the API, and was covered in the call on 2020-03-23. The relevant notes are:
AE: if on Vulkan the precision is 0 bits, what happens?
CW: we just provide garbage.
KR: Vulkan has writeTimestamp but the precision is up to the driver, all the way up to 0 meaningful bits of precision.
YH: for renderpass timestamp, if we return GPU timestamp may need more work on this. Lot of impl details, fragmentation. Ticks vs. nanoseconds. Nanoseconds might have different time base. Also time might be reset to 0. Lot of details. Don’t think a real GPU timestamp makes sense. Can gather more data.
MM: returning garbage is probably OK, as long as developer knows they should ignore those fields.
CW: can just return Inf, or something.
KN: or time on CPU, but probably not helpful.
CW: Let’s move on and make further comments on the issue / PR
So the general feeling at the time was that returning nonsensical/erroneous results was OK. This was based on, as discussed earlier in that conversation, the idea that the primary use case would be development-time debugging. But I'd personally advocate against that view. If these numbers are commonly available then developers will definitely try to use them in realtime for scaling workloads or similar side effects. The number of devices where this API won't be reasonably supported is going to be fairly low, and as such it will be easy for developers to accidentally write code that is dependent on it at runtime which breaks unexpectedly on a small number of devices. For example, if the API is specced to return 0 as it's "garbage" value and the application is using that to scale the amount of work it's doing each frame it may massively increase the per-frame workload with the mistaken impression that it's taking effectively no time to do the work.
The options that come to mind for addressing this are:
- Make
executionTimeoptional, similar to timestamps (though presumably more widely supported) - Require that
executionTimereport estimates based on CPU-timing for devices which don't support GPU-side measurement.
Activity
kainino0x commentedon May 26, 2021
For the record: It's hard to check for timestamp query support on vulkan.gpuinfo.org, so I had to look at individual reports to determine what devices didn't support it. Turned out I was searching wrong and there are Mali GPUs (slightly newer ones) which do have timestamp query support, e.g.:
http://vulkan.gpuinfo.org/displayreport.php?id=4871#queuefamilies
http://vulkan.gpuinfo.org/displayreport.php?id=5741#queuefamilies
http://vulkan.gpuinfo.org/displayreport.php?id=9711#queuefamilies
Kangz commentedon May 28, 2021
It would be quite unfortunate for
executionTimeto be optional because it is meant to be the always-available option that browsers can tamper with easily. @toji makes a good point that there's a risk that pages could use this and break in various ways if the browser returns the "nonsensical" value (whether it is 0, NaN, Inf or -1).Would there be an option to make it more explicit to the application that it needs to handle the case where the value is garbage? Like:
kvark commentedon Oct 4, 2021
I did some investigation on which devices report 0 bits of precision in https://github.com/kainino0x/query-gpuinfo-data/pull/1, and it appears to be Mali-GXX. They seem to otherwise not be filtered out. So the trade-off here is: if we have
executionTime, we'll expose the Metal API almost directly, which is useful, and also implementable on most other platforms, except for Mali-G devices. If we don't have this API, we'll force the users to use an optional feature, and in addition they'd have to download the data by mapping the buffer.Kangz commentedon Nov 5, 2021
This feature has been removed in #2214 in part due to this question so this issue can be closed.
Make F32Interval unittests more idiomatic (gpuweb#1773)