gpu: verify lifetimes of descriptor memory, investigate alternatives to copying strategy #183

Closed
opened 2022-03-17 18:11:48 +00:00 by emidoots · 1 comment
emidoots commented 2022-03-17 18:11:48 +00:00 (Migrated from github.com)

In a few places we have to copy descriptors & structs before passing into the native implementation because our interface is not always ABI compatible with webgpu.h:

https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/hexops/mach%24%40webgpu+file:gpu+page_allocator&patternType=literal

We're currently using a pretty gnarly approach: we use stack space if the data we have to copy is small enough, and heap-allocate otherwise. Obviously, the memory is always gone (stack or not) once the function returns. It's not exactly clear from webgpu.h what the lifetime of certain memory is, as there are no docs. I believe descriptors must live only until the function which takes the descriptor returns, but this needs to be confirmed.

  • Confirm all memory lifetimes are valid
  • Identify if there is a better / more optimal strategy for achieving ABI compatibility so no copying is needed.
  • "The gpu.Queue was going out of scope before the callback got called, so the wrapper callback couldn't call the gpu.Queue.WorkDoneCallback it held" from this matrix chat
In a few places we have to copy descriptors & structs before passing into the native implementation because our interface is not always ABI compatible with `webgpu.h`: https://sourcegraph.com/search?q=context:global+repo:%5Egithub%5C.com/hexops/mach%24%40webgpu+file:gpu+page_allocator&patternType=literal We're currently using a pretty gnarly approach: we use stack space if the data we have to copy is small enough, and heap-allocate otherwise. Obviously, the memory is always gone (stack or not) once the function returns. It's not exactly clear from `webgpu.h` what the lifetime of certain memory is, as there are no docs. I believe descriptors must live only until the function which takes the descriptor returns, but this needs to be confirmed. - [ ] Confirm all memory lifetimes are valid - [ ] Identify if there is a better / more optimal strategy for achieving ABI compatibility so no copying is needed. - [ ] "The `gpu.Queue` was going out of scope before the callback got called, so the wrapper callback couldn't call the `gpu.Queue.WorkDoneCallback` it held" from [this matrix chat](https://matrix.to/#/!bIJeTLtOHucXQpqIcH:matrix.org/$AZSS1Q2njUjiH4lRbH7KvsaEyqqUITJT0SHQPInHWjc?via=matrix.org&via=mozilla.org&via=pythons.space)
emidoots commented 2022-07-26 06:46:40 +00:00 (Migrated from github.com)
https://github.com/hexops/mach/pull/403
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach#183
No description provided.