From 1f0ca085a722c1cd9908ab4ad1ab6987c6282c0f Mon Sep 17 00:00:00 2001 From: Leyuan Wang <laurawly@gmail.com> Date: Tue, 10 Apr 2018 20:37:01 -0700 Subject: [PATCH] Fix device name and Issue #874 (#1096) --- src/runtime/metal/metal_device_api.mm | 2 +- src/runtime/metal/metal_module.mm | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/runtime/metal/metal_device_api.mm b/src/runtime/metal/metal_device_api.mm index 8a2d1fb37..077d2546c 100644 --- a/src/runtime/metal/metal_device_api.mm +++ b/src/runtime/metal/metal_device_api.mm @@ -114,7 +114,7 @@ void MetalWorkspace::Init() { devices.push_back([d retain]); queues.push_back([[d newCommandQueue] retain]); LOG(INFO) << "Intializing Metal device " << i - << ", name=" << d.name; + << ", name=" << [d.name UTF8String]; warp_size.push_back(GetWarpSize(d)); } #endif diff --git a/src/runtime/metal/metal_module.mm b/src/runtime/metal/metal_module.mm index bf7f606c9..4814d986b 100644 --- a/src/runtime/metal/metal_module.mm +++ b/src/runtime/metal/metal_module.mm @@ -82,11 +82,15 @@ class MetalModuleNode final :public runtime::ModuleNode { NSError* err_msg = nil; if (e.lib == nil) { if (fmt_ == "metal") { + MTLCompileOptions *opts = [MTLCompileOptions alloc]; + opts.languageVersion = MTLLanguageVersion2_0; + opts.fastMathEnabled = YES; e.lib = [ w->devices[device_id] newLibraryWithSource:[NSString stringWithUTF8String:data_.c_str()] - options:nil + options:opts error:&err_msg]; + [opts dealloc]; if (err_msg != nil || e.lib == nil) { LOG(FATAL) << "Fail to compile metal lib:" << [[err_msg localizedDescription] UTF8String]; -- GitLab