It still works after some tweaking ;) Always looking forward to new material! Metal has really interested me the last few years. I'm using Swift btw!
-
-
Replying to @jippoew
Cool! So the chief thing to understand is that you can encode as much work as you want into a single command buffer; dependencies (between kernels) will be resolved automatically.
1 reply 0 retweets 0 likes -
The practical upshot of this is that you can try to encode kernels in-place, while providing a backup copy allocator to minimize allocations, but chaining from the output of one kernel to the input of another—even within one command buffer—should “just work.”
1 reply 0 retweets 0 likes -
All of this goes out the window if you’re using MTLHeap, where accesses are noted less granularly, but I suspect that for now you’re not using heaps?
2 replies 0 retweets 0 likes -
Sorry for reviving the ancient thread, but I’m looking for a way to chain MPS kernels on heap sub-allocated resources. Any hints?
1 reply 0 retweets 0 likes -
The key thing to remember is that you’re responsible for tracking dependencies between resources that might alias. I seem to recall another tweet from you that mentioned fences; are you using them? Have you consulted this sample? https://developer.apple.com/documentation/metal/resource_objects/image_filter_graph_with_heaps_and_fences …
1 reply 0 retweets 0 likes -
Yeah, the problem is that MPS kernels don’t provide you with MPSComputeComandEncoder, but instead encode themselves into command buffer. That’s why I’m lost at how to ensure chaining order on heap sub-allocated resources. Is there a way to feed MPS a fence to use?
1 reply 0 retweets 0 likes -
Sorry, that wasn’t the sample I intended. I think what you want are MTLEvents, which are command buffer-level objects that allow more flexible specification of sync boundaries for heap-allocated and non-tracked resources: https://developer.apple.com/documentation/metal/advanced_command_setup/image_filter_graph_with_heaps_and_events …
1 reply 0 retweets 0 likes -
Oh I see, so I can encode MTLEvents in between MPS kernels so that they are chained in a serial order. Do you think it will introduce comparable overhead as device-memory resources with automatic hazard tracking?
2 replies 0 retweets 0 likes -
Could you please also clarify if the time of calling `makeAliasable()` actually matters? In the docs there is a mention that "if you use heap as a stack, no fragmentation occurs". But I never saw any example of "heap as a stack usage", what does it mean?
2 replies 0 retweets 0 likes
I think the “heap-as-stack” metaphor means that if you only ever alloc/free from the “tail” of the heap (as opposed to freeing a resource that occupies some region in the middle middle), subsequent allocations won’t leave gaps.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.