Reputation: 129
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
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.
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