有人能举例说明如何用金属识别可用的计算设备,如cpu和gpu吗?非常感谢
答案 0 :(得分:5)
Metal
仅适用于GPU。也就是说,有一个名为MTLCopyAllDevices()
的函数可以返回系统拥有的所有GPU。这是一个关于如何在OS X操场上运行它以查看我的系统具有哪些兼容设备的快速示例。
编辑:
在Objective-C
中,这看起来很相似。首先导入<Metal/Metal.h>
:
@implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { NSArray *devices = MTLCopyAllDevices(); for (id device in devices) { NSLog(@"%@", [device name]); } } @end