<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.13.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MetalPerformanceShaders",
  "identifier" : "/documentation/MetalPerformanceShaders/MPSKernel/copy(with:device:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Metal Performance Shaders"
    ],
    "preciseIdentifier" : "c:objc(cs)MPSKernel(im)copyWithZone:device:"
  },
  "title" : "copy(with:device:)"
}
-->

# copy(with:device:)

Makes a copy of this kernel object for a new device.

```
func copy(with zone: NSZone? = nil, device: (any MTLDevice)?) -> Self
```

## Parameters

`zone`

The zone in which to allocate the kernel object.

`device`

The Metal device for the new kernel object.

## Return Value

A copy of this kernel object.

## Discussion

The same kernel objects should not be used to encode separate kernel operations on multiple command buffers from multiple threads. Many kernels have mutable properties that might be changed by another thread while the kernel is being encoded. If you need to use a kernel from multiple threads, make a copy of it for each additional thread using <doc://com.apple.documentation/documentation/Foundation/NSCopying/copy(with:)> or [`copy(with:device:)`](/documentation/MetalPerformanceShaders/MPSKernel/copy(with:device:)). Note that the <doc://com.apple.documentation/documentation/Foundation/NSCopying/copy(with:)> method makes a copy of the kernel object on the same device.

This method fails if the device is not supported. Query the [`MPSSupportsMTLDevice(_:)`](/documentation/MetalPerformanceShaders/MPSSupportsMTLDevice(_:)) function to determine whether the device is supported.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)