首页 > 解决方案 > Concurrent execution of metal compute kernels

问题描述

Lets say, I have around 10 kernels, which I encode in an MTLComputeCommandEncoder and these 10 kernels, run on a set of data under consideration.

I have multiple sets of these data, let's say 5, and I want to execute these 10 kernels on all the separate sets of data. And NO! I cannot combine these data sets into a single data.

A naive approach would be to loop around all the data sets and execute all the 10 kernels on each data set, one after another.

What I'm looking for is a way that I can tell Metal, that these are separate data sets and they can be executed in parallel. That is, instead of encoding 10 kernels, 5 times sequently, I want to run all of them concurrently on the GPU.

CUDA provides Streams to achieve this behaviour. Is there anything similar the Metal provides?

I know there exists MTLDispatchType, setting it to MTLDispatchTypeConcurrent, would mean running my 10 kernels concurrently, but that is not the requirement.

Thanks!

标签: macosgpumetal

解决方案


推荐阅读