Ahh, that post is crazy-old! I’m working on new material, but it’s not ready yet. Are you using Obj-C or Swift?
-
-
Replying to @warrenm
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!
1 reply 0 retweets 0 likes -
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
Difficult to say. On the one hand, by going manual, you’re reducing the work done by the framework/driver. On the other, it might be tricky to place events and order work optimally. Best to ask a profiler.
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.