Skip to content

Commit

Permalink
regent: Move OpenMP tagging to codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
magnatelee committed Dec 17, 2018
1 parent ff53a5f commit 7cdc14d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
12 changes: 12 additions & 0 deletions language/src/regent/codegen.t
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
13 changes: 1 addition & 12 deletions language/src/regent/std.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions language/src/regent/std_base.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1018,6 +1026,7 @@ do
untyped_ast = false,
definition = false,
cuda = false,
openmp = false,
external = false,
inline = false,
cudakernels = false,
Expand Down

0 comments on commit 7cdc14d

Please sign in to comment.