Commit 6a0a8e98 by Tianqi Chen Committed by GitHub

[WEB] update web runtime to latest emcc (#742)

parent 5f1816db
...@@ -29,8 +29,10 @@ INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include - ...@@ -29,8 +29,10 @@ INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include -
CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC
FRAMEWORKS = FRAMEWORKS =
OBJCFLAGS = -fno-objc-arc OBJCFLAGS = -fno-objc-arc
EMCC_FLAGS= -s RESERVED_FUNCTION_POINTERS=2 -s NO_EXIT_RUNTIME=1 -s MAIN_MODULE=1 -DDMLC_LOG_STACK_TRACE=0\ EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
-std=c++11 -Oz $(INCLUDE_FLAGS) -Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\
-s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap','getValue','setValue','addFunction']"\
$(INCLUDE_FLAGS)
# llvm configuration # llvm configuration
ifdef LLVM_CONFIG ifdef LLVM_CONFIG
......
...@@ -26,13 +26,16 @@ def create_js(output, ...@@ -26,13 +26,16 @@ def create_js(output,
The compile string. The compile string.
""" """
cmd = [cc] cmd = [cc]
cmd += ["-s", "RESERVED_FUNCTION_POINTERS=2"]
cmd += ["-s", "NO_EXIT_RUNTIME=1"]
cmd += ["-Oz"] cmd += ["-Oz"]
cmd += ["-o", output] if not side_module:
if side_module: cmd += ["-s", "RESERVED_FUNCTION_POINTERS=2"]
cmd += ["-s", "NO_EXIT_RUNTIME=1"]
extra_methods = ['cwrap', 'getValue', 'setValue', 'addFunction']
cfg = "[" + (','.join("\'%s\'" % x for x in extra_methods)) + "]"
cmd += ["-s", "EXTRA_EXPORTED_RUNTIME_METHODS=" + cfg]
else:
cmd += ["-s", "SIDE_MODULE=1"] cmd += ["-s", "SIDE_MODULE=1"]
cmd += ["-o", output]
objects = [objects] if isinstance(objects, str) else objects objects = [objects] if isinstance(objects, str) else objects
with_runtime = False with_runtime = False
for obj in objects: for obj in objects:
...@@ -47,9 +50,8 @@ def create_js(output, ...@@ -47,9 +50,8 @@ def create_js(output,
if options: if options:
cmd += options cmd += options
args = ' '.join(cmd)
proc = subprocess.Popen( proc = subprocess.Popen(
args, shell=True, cmd,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
(out, _) = proc.communicate() (out, _) = proc.communicate()
......
...@@ -493,7 +493,8 @@ var tvm_runtime = tvm_runtime || {}; ...@@ -493,7 +493,8 @@ var tvm_runtime = tvm_runtime || {};
} }
var fptrInvokeCallback = null; var fptrInvokeCallback = null;
var fptrFreeCallback = null; var fptrFreeCallback = null;
if (typeof Runtime !== "undefined") { if (typeof Runtime !== "undefined" &&
typeof Runtime.addFunction !== "undefined") {
fptrInvokeCallback = Runtime.addFunction(invokeCallback); fptrInvokeCallback = Runtime.addFunction(invokeCallback);
fptrFreeCallback = Runtime.addFunction(freeCallback); fptrFreeCallback = Runtime.addFunction(freeCallback);
} }
...@@ -513,7 +514,8 @@ var tvm_runtime = tvm_runtime || {}; ...@@ -513,7 +514,8 @@ var tvm_runtime = tvm_runtime || {};
*/ */
this.convertFunc = function(f) { this.convertFunc = function(f) {
if (isPackedFunc(f)) return f; if (isPackedFunc(f)) return f;
CHECK(fptrInvokeCallback !== null, "Emscripten Runtime is not available"); CHECK(fptrInvokeCallback !== null,
"Emscripten Runtime addFunction is not available");
var fid; var fid;
if (freeFuncId.length != 0) { if (freeFuncId.length != 0) {
fid = freeFuncId.pop(); fid = freeFuncId.pop();
...@@ -1086,7 +1088,11 @@ var tvm_runtime = tvm_runtime || {}; ...@@ -1086,7 +1088,11 @@ var tvm_runtime = tvm_runtime || {};
this.create = function(Module) { this.create = function(Module) {
var tvm = {}; var tvm = {};
tvm.Module = Module; tvm.Module = Module;
tvm.Runtime = Module.Runtime; if (typeof Module.addFunction !== "undefined") {
tvm.Runtime = Module;
} else {
tvm.Runtime = Module.Runtime;
}
TVMRuntime.apply(tvm); TVMRuntime.apply(tvm);
return tvm; return tvm;
}; };
......
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