Metal GPU Work Won't Stop

Is there any way to stop GPU work running that is scheduled using metal?

Long shader calculations don't stop when application is stopped in Xcode and continue to take up GPU time and affect the display.

Why is this functionality not available when Swift Tasks are able to be canceled?

Answered by DTS Engineer in 826980022

There's no supported way for you to cancel a task while it is running on the GPU with the APIs currently available. If you'd like us to consider adding the necessary functionality, please file an enhancement request using Feedback Assistant. Once you file the request, please post the FB number here.

If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

Perhaps if you can tell us more about your particular use case we can advise you about alternate solutions.

There's no supported way for you to cancel a task while it is running on the GPU with the APIs currently available. If you'd like us to consider adding the necessary functionality, please file an enhancement request using Feedback Assistant. Once you file the request, please post the FB number here.

If you're not familiar with how to file enhancement requests, take a look at Bug Reporting: How and Why?

Perhaps if you can tell us more about your particular use case we can advise you about alternate solutions.

Hello,

I wanted to add a few things to consider for a bug report and also things we recommend for better understanding the issues (and potentially identifying solutions).

Re: "Long shader calculations don't stop when application is stopped in Xcode and continue to take up GPU time and affect the display." it's unclear what this means and the systems impacted.

Please describe what you're trying to do as a series of steps, and include when/how the display is affected. If an app being debugged in Xcode is stopped and the process isn't terminated (in a reasonable amount of time) this is unexpected behavior.

-- Otherwise one of the problems you're likely trying to solve is optimizing expensive shaders tanking GPU performance (see resources below).

Note: You can pause the execution of the a shader or kernel in the Metal Debugger and inspect its performance characteristics on a line-by-line basis making it straightforward to identify costly calls and computations.

Note: Terminating the app in Xcode while the Metal Debugger is active is expected to behave the same as if it were inactive.

To gain a better understanding of your workload and it's performance we recommend:

Analyzing the performance of your Metal app

Metal debugger

Optimizing GPU performance

-- Re: "Why is this functionality not available when Swift Tasks are able to be canceled?" a Swift Task is executed on the CPU whereas Metal shaders and kernels are executed on the GPU.

See Performing Calculations on a GPU.

Metal GPU Work Won't Stop
 
 
Q