|
@@ -40,6 +40,7 @@ class ModelverseKernel(object):
|
|
|
self.taskname = taskname
|
|
|
if taskname not in self.request_handlers:
|
|
|
self.request_handlers[taskname] = {}
|
|
|
+ self.jit.cache.setdefault(taskname, {})
|
|
|
if operation not in self.request_handlers[taskname]:
|
|
|
# Create the generator for the function to execute
|
|
|
self.request_handlers[taskname][operation] = RequestHandler()
|
|
@@ -221,9 +222,13 @@ class ModelverseKernel(object):
|
|
|
if str_value:
|
|
|
# Is a global
|
|
|
prev = \
|
|
|
- " " * nested_indent + "%s, = yield [('RD', [_globs, '%s'])]\n" % (str_value, str_value) + \
|
|
|
- " " * nested_indent + "%s, = yield [('RD', [%s, 'value'])]\n" % (str_value, str_value) + \
|
|
|
- " " * nested_indent + "%s = {'id': %s}\n" % (str_value, str_value)
|
|
|
+ " " * nested_indent + "%s = _mvk.jit.cache[_taskname].get('%s', None)\n" % (str_value, str_value) + \
|
|
|
+ " " * nested_indent + "if %s is None:\n" % str_value + \
|
|
|
+ " " * (nested_indent + 1) + "print('cache miss for %s')\n" % str_value + \
|
|
|
+ " " * (nested_indent + 1) + "%s, = yield [('RD', [_globs, '%s'])]\n" % (str_value, str_value) + \
|
|
|
+ " " * (nested_indent + 1) + "%s, = yield [('RD', [%s, 'value'])]\n" % (str_value, str_value) + \
|
|
|
+ " " * (nested_indent + 1) + "%s = {'id': %s}\n" % (str_value, str_value) + \
|
|
|
+ " " * (nested_indent + 1) + "_mvk.jit.cache[_taskname]['%s'] = %s\n" % (str_value, str_value)
|
|
|
instruction = str_value
|
|
|
|
|
|
if self.jit.get_global_body_id(str_value) is None:
|
|
@@ -259,7 +264,8 @@ class ModelverseKernel(object):
|
|
|
" " * nested_indent + "if 'id' not in %s:\n" % instruction_var + \
|
|
|
" " * (nested_indent + 1) + "%s['id'], = yield [('CNV', [%s['value']])]\n" % (instruction_var, instruction_var) + \
|
|
|
" " * nested_indent + "yield [('CD', [_var, 'value', %s['id']]), ('DE', [_old_edge])]\n" % instruction_var + \
|
|
|
- " " * nested_indent + "_mvk.jit.register_global('%s', %s['id'])\n" % (instruction_var, instruction_var)
|
|
|
+ " " * nested_indent + "_mvk.jit.cache[_taskname]['%s'] = %s\n" % (instruction_var, instruction_var)
|
|
|
+ #" " * nested_indent + "_mvk.jit.register_global('%s', %s['id'])\n" % (instruction_var, instruction_var) + \
|
|
|
|
|
|
elif inst_type["value"] == "call":
|
|
|
func_name, = yield [("RD", [inst, "func"])]
|
|
@@ -422,6 +428,7 @@ class ModelverseKernel(object):
|
|
|
if result is None:
|
|
|
result = {'id': None, 'value': None}
|
|
|
|
|
|
+ # TODO this can move inside "store" branch?
|
|
|
if "id" not in result:
|
|
|
result['id'], = yield [("CNV", [result['value']])]
|
|
|
|