Pony
Pony

Reputation: 129

How to identify the available computational devices with metal in iphone or mac

Could anyone present an example to illustrate how to identify the available computational devices, such as cpu and gpu, with metal? Thanks a lot

Upvotes: 4

Views: 879

Answers (1)

gpu3d
gpu3d

Reputation: 1184

Metal only works on GPUs. That said, there is a function named MTLCopyAllDevices() that returns all the GPUs your system has. Here is a quick example on how I run this in a OS X playground to see what compatible devices my system has.

enter image description here

EDIT:

In Objective-C this would look similar. Just import <Metal/Metal.h> first:

@implementation AppDelegate

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

    NSArray *devices = MTLCopyAllDevices();
    for (id device in devices) {
        NSLog(@"%@", [device name]);
    }
}

@end

Upvotes: 5

Related Questions