Commit 1f0ca085 by Leyuan Wang Committed by Tianqi Chen

Fix device name and Issue #874 (#1096)

parent 6f2ef9dc
...@@ -114,7 +114,7 @@ void MetalWorkspace::Init() { ...@@ -114,7 +114,7 @@ void MetalWorkspace::Init() {
devices.push_back([d retain]); devices.push_back([d retain]);
queues.push_back([[d newCommandQueue] retain]); queues.push_back([[d newCommandQueue] retain]);
LOG(INFO) << "Intializing Metal device " << i LOG(INFO) << "Intializing Metal device " << i
<< ", name=" << d.name; << ", name=" << [d.name UTF8String];
warp_size.push_back(GetWarpSize(d)); warp_size.push_back(GetWarpSize(d));
} }
#endif #endif
......
...@@ -82,11 +82,15 @@ class MetalModuleNode final :public runtime::ModuleNode { ...@@ -82,11 +82,15 @@ class MetalModuleNode final :public runtime::ModuleNode {
NSError* err_msg = nil; NSError* err_msg = nil;
if (e.lib == nil) { if (e.lib == nil) {
if (fmt_ == "metal") { if (fmt_ == "metal") {
MTLCompileOptions *opts = [MTLCompileOptions alloc];
opts.languageVersion = MTLLanguageVersion2_0;
opts.fastMathEnabled = YES;
e.lib = [ e.lib = [
w->devices[device_id] w->devices[device_id]
newLibraryWithSource:[NSString stringWithUTF8String:data_.c_str()] newLibraryWithSource:[NSString stringWithUTF8String:data_.c_str()]
options:nil options:opts
error:&err_msg]; error:&err_msg];
[opts dealloc];
if (err_msg != nil || e.lib == nil) { if (err_msg != nil || e.lib == nil) {
LOG(FATAL) << "Fail to compile metal lib:" LOG(FATAL) << "Fail to compile metal lib:"
<< [[err_msg localizedDescription] UTF8String]; << [[err_msg localizedDescription] UTF8String];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment