From 7cdc14da2dbb4d5e3c981fd4970a67a9cc8d2c39 Mon Sep 17 00:00:00 2001 From: Wonchan Lee Date: Mon, 17 Dec 2018 12:40:24 -0800 Subject: [PATCH] regent: Move OpenMP tagging to codegen --- language/src/regent/codegen.t | 12 ++++++++++++ language/src/regent/std.t | 13 +------------ language/src/regent/std_base.t | 9 +++++++++ 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/language/src/regent/codegen.t b/language/src/regent/codegen.t index 15fa041b58..7ad8942274 100644 --- a/language/src/regent/codegen.t +++ b/language/src/regent/codegen.t @@ -10188,6 +10188,18 @@ function codegen.top(cx, node) cpu_variant:set_ast(node) std.register_variant(cpu_variant) + -- Mark the variant as OpenMP variant when at least one OpenMP loop exists + if std.config["openmp"] then + ast.traverse_node_postorder( + function(node) + if node:is(ast.typed.stat) and + node.annotations.openmp:is(ast.annotation.Demand) + then + cpu_variant:set_is_openmp(true) + end + end, node) + end + if node.annotations.cuda:is(ast.annotation.Demand) then if not cudahelper.check_cuda_available() then report.warn(node, diff --git a/language/src/regent/std.t b/language/src/regent/std.t index 870c192ca7..9208accadd 100644 --- a/language/src/regent/std.t +++ b/language/src/regent/std.t @@ -3645,18 +3645,7 @@ function std.setup(main_task, extra_setup_thunk, task_wrappers, registration_nam local proc_types = {c.LOC_PROC, c.IO_PROC} - -- Check if this is an OpenMP task. - local openmp = false - ast.traverse_node_postorder( - function(node) - if node:is(ast.typed.stat) and - node.annotations.openmp:is(ast.annotation.Demand) - then - openmp = true - end - end, - variant:has_ast() and variant:get_ast()) - if openmp then + if variant:is_openmp() then if std.config["openmp-strict"] then proc_types = {c.OMP_PROC} else diff --git a/language/src/regent/std_base.t b/language/src/regent/std_base.t index af05efbbbf..e9071b4634 100644 --- a/language/src/regent/std_base.t +++ b/language/src/regent/std_base.t @@ -827,6 +827,14 @@ function base.variant:is_cuda() return self.cuda end +function base.variant:set_is_openmp(openmp) + self.openmp = openmp +end + +function base.variant:is_openmp() + return self.openmp +end + function base.variant:set_is_external(external) self.external = external end @@ -1018,6 +1026,7 @@ do untyped_ast = false, definition = false, cuda = false, + openmp = false, external = false, inline = false, cudakernels = false,