Article

Getting Different Types of GPUs

Obtain, identify, and choose suitable GPUs for your app.

Overview

Every GPU that's available on a Mac is represented by a MTLDevice. A user can have multiple GPUs built in or connected to their system, and you can use one or many of these GPUs for your app's graphics rendering or compute processing workloads. Query the list of devices available to a system, identify the GPU types, and choose the best option (or options) for your app.

Getting the List of Available Devices

Call the MTLCopyAllDevicesWithObserver(_:_:) function to get a list of all the Metal devices available to a system and register an observer that's called whenever this list changes (or may change due to a safe disconnect request).

let devicesWithObserver = MTLCopyAllDevicesWithObserver(handler: { (device, name) in
    self.handleExternalGPUEvents(device: device, notification: name)
})
deviceList = devicesWithObserver.devices
deviceObserver = devicesWithObserver.observer

To deregister the observer, call the MTLRemoveDeviceObserver(_:) function.

Identify the GPU Types

Three GPU types could be present in any given system: external, integrated, and discrete. To identify the GPU types, query these MTLDevice properties:

  • isLowPower. This property returns true for an integrated GPU and false for a discrete GPU.

  • isRemovable. This property returns true for an external GPU. Otherwise, this property returns false.

guard let devices = deviceList else { return }
        
var externalGPUs = [MTLDevice]()
var integratedGPUs = [MTLDevice]()
var discreteGPUs = [MTLDevice]()
        
for device in devices {
    if device.isRemovable {
        externalGPUs.append(device)
    } else if device.isLowPower {
        integratedGPUs.append(device)
    } else {
        discreteGPUs.append(device)
    }
}

Choose a Suitable GPU for Your Workloads

Different types of GPUs have different power and bandwidth characteristics.

GPU Type

Processing Power

Power Consumption

Bandwidth

Integrated

Low

Low

High

Discrete

Medium

Medium

High

External

High

High

Low

Given a system with multiple GPUs, you can use different types of GPUs for different types of workloads in your app.

Use an integrated GPU for:

  • Executing simple graphics or compute workloads with minimal GPU processing needs

  • Conserving power (namely, battery life)

Use a discrete GPU for:

  • Rendering medium- to high-complexity graphics scenes (with or without compute processing)

  • Rendering low- to medium-resolution graphics content (with or without compute processing)

  • Satisfying high per-frame bandwidth demands between GPUs or displays

Use an external GPU for:

  • Processing compute workloads with high ALU complexity

  • Rendering high-complexity graphics scenes (with or without compute processing)

  • Rendering high-resolution graphics content (with or without compute processing)

  • Satisfying low to medium per-frame bandwidth demands between GPUs or displays

See Also

Selecting GPUs on Mac

Device Selection and Fallback for Graphics Rendering

Demonstrates how to work with multiple GPUs and efficiently render to a display.

Device Selection and Fallback for Compute Processing

Demonstrates how to work with multiple GPUs and efficiently execute a compute-intensive simulation.

About External GPUs

Learn how to support external GPUs in your macOS apps and games.

About Multi-GPU and Multi-Display Setups

Learn about the different ways that a user can connect external GPUs and external displays to a Mac computer.

About GPU Bandwidth

Learn about some of the main factors that affect bandwidth between a GPU and a system on a Mac.

Handling External GPU Additions and Removals

Register and respond to external GPU notifications initiated by a user.

Getting the GPU that Drives a View's Display

Keep up to date with the optimal device for your display.