Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

import logging
from psyclone.transformations import TransformationError
from psyclone.psyir.nodes import (Loop, CodeBlock)
from psyclone.psyir.nodes import (Loop, UnknownDirective)
from transmute_psytrans.transmute_functions import (
set_pure_subroutines,
get_outer_loops,
mark_explicit_privates,
get_compiler,
first_priv_red_init,
match_lhs_assignments,
Expand Down Expand Up @@ -53,22 +52,6 @@
]


class CompilerDirective():
"""
Custom compiler directive class to avoid an issue
with fparser.two.Fortran2003.Directive that will
be resolved in an upcoming fparser release.
"""
def __init__(self, directive):
self.directive = directive

def tofortran(self):
"""
Return directive with prefix
"""
return "!DIR$ " + self.directive


def trans(psyir):
"""
Apply OpenMP and Compiler Directives
Expand All @@ -92,10 +75,6 @@ def trans(psyir):
except (TransformationError, IndexError) as err:
logging.warning("Parallelisation of the 1st region failed: %s", err)

# Declare private symbols for the last loop nest explicitly,
# PSyclone misses one
mark_explicit_privates(outer_loops[2], private_variables)

# Parallelise the second region and insert compiler directives
# Add redundant variable initialisation to work around a known
# PSyclone issue when using CCE
Expand All @@ -109,16 +88,14 @@ def trans(psyir):
# Insert before OpenMP directives to avoid PSyclone errors
if get_compiler() == "cce":
for loop in outer_loops[2].walk(Loop)[3:5]:
cblock = CodeBlock([CompilerDirective("NOFISSION")],
CodeBlock.Structure.STATEMENT)
dir = UnknownDirective(" NOFISSION", "DIR")
insert_at = loop.parent.children.index(loop)
loop.parent.children.insert(insert_at, cblock)
loop.parent.children.insert(insert_at, dir)

for loop in outer_loops[2].walk(Loop)[13:16]:
cblock = CodeBlock([CompilerDirective("IVDEP")],
CodeBlock.Structure.STATEMENT)
dir = UnknownDirective(" IVDEP", "DIR")
insert_at = loop.parent.children.index(loop)
loop.parent.children.insert(insert_at, cblock)
loop.parent.children.insert(insert_at, dir)

for loop in outer_loops[2].walk(Loop)[2:7]:
# Check if any eligible variables appear in subroutine
Expand All @@ -129,7 +106,8 @@ def trans(psyir):
options = {}
if len(ignore_deps_vars) > 0:
options["ignore_dependencies_for"] = ignore_deps_vars
OMP_DO_LOOP_TRANS_STATIC.apply(loop, options)
OMP_DO_LOOP_TRANS_STATIC.apply(loop, options=options,
force_private=private_variables)

for loop in outer_loops[2].walk(Loop)[8:13:2]:
# Check if any eligible variables appear on the LHS of
Expand All @@ -139,7 +117,8 @@ def trans(psyir):
if len(ignore_deps_vars) > 0:
options["ignore_dependencies_for"] = ignore_deps_vars

OMP_DO_LOOP_TRANS_STATIC.apply(loop, options)
OMP_DO_LOOP_TRANS_STATIC.apply(loop, options=options,
force_private=private_variables)

except (TransformationError, IndexError) as err:
logging.warning("Parallelisation of the 2nd region failed: %s", err)
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import logging
from psyclone.transformations import TransformationError
from psyclone.psyir.nodes import (Loop, CodeBlock)
from psyclone.psyir.nodes import (Loop, UnknownDirective)
from transmute_psytrans.transmute_functions import (
set_pure_subroutines,
get_outer_loops,
Expand Down Expand Up @@ -52,22 +52,6 @@
]


class CompilerDirective():
"""
Custom compiler directive class to avoid an issue
with fparser.two.Fortran2003.Directive that will
be resolved in an upcoming fparser release.
"""
def __init__(self, directive):
self.directive = directive

def tofortran(self):
"""
Return directive with prefix
"""
return "!DIR$ " + self.directive


def trans(psyir):
"""
Apply OpenMP and Compiler Directives
Expand Down Expand Up @@ -104,16 +88,14 @@ def trans(psyir):
# Insert before OpenMP directives to avoid PSyclone errors
if get_compiler() == "cce":
for loop in outer_loops[2].walk(Loop)[3:5]:
cblock = CodeBlock([CompilerDirective("NOFISSION")],
CodeBlock.Structure.STATEMENT)
dir = UnknownDirective(" NOFISSION", "DIR")
insert_at = loop.parent.children.index(loop)
loop.parent.children.insert(insert_at, cblock)
loop.parent.children.insert(insert_at, dir)

for loop in outer_loops[2].walk(Loop)[13:16]:
cblock = CodeBlock([CompilerDirective("IVDEP")],
CodeBlock.Structure.STATEMENT)
dir = UnknownDirective(" IVDEP", "DIR")
insert_at = loop.parent.children.index(loop)
loop.parent.children.insert(insert_at, cblock)
loop.parent.children.insert(insert_at, dir)

for loop in outer_loops[2].walk(Loop)[2:7]:
# Check if any eligible variables appear in subroutine
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@

import logging
from psyclone.transformations import TransformationError
from psyclone.psyir.nodes import (Loop, CodeBlock)
from psyclone.psyir.nodes import (Loop, UnknownDirective)
from transmute_psytrans.transmute_functions import (
set_pure_subroutines,
get_outer_loops,
mark_explicit_privates,
get_compiler,
first_priv_red_init,
match_lhs_assignments,
Expand Down Expand Up @@ -53,22 +52,6 @@
]


class CompilerDirective():
"""
Custom compiler directive class to avoid an issue
with fparser.two.Fortran2003.Directive that will
be resolved in an upcoming fparser release.
"""
def __init__(self, directive):
self.directive = directive

def tofortran(self):
"""
Return directive with prefix
"""
return "!DIR$ " + self.directive


def trans(psyir):
"""
Apply OpenMP and Compiler Directives
Expand All @@ -92,10 +75,6 @@ def trans(psyir):
except (TransformationError, IndexError) as err:
logging.warning("Parallelisation of the 1st region failed: %s", err)

# Declare private symbols for the last loop nest explicitly,
# PSyclone misses one
mark_explicit_privates(outer_loops[2], private_variables)

# Parallelise the second region and insert compiler directives
# Add redundant variable initialisation to work around a known
# PSyclone issue when using CCE
Expand All @@ -109,16 +88,14 @@ def trans(psyir):
# Insert before OpenMP directives to avoid PSyclone errors
if get_compiler() == "cce":
for loop in outer_loops[2].walk(Loop)[3:5]:
cblock = CodeBlock([CompilerDirective("NOFISSION")],
CodeBlock.Structure.STATEMENT)
dir = UnknownDirective(" NOFISSION", "DIR")
insert_at = loop.parent.children.index(loop)
loop.parent.children.insert(insert_at, cblock)
loop.parent.children.insert(insert_at, dir)

for loop in outer_loops[2].walk(Loop)[13:16]:
cblock = CodeBlock([CompilerDirective("IVDEP")],
CodeBlock.Structure.STATEMENT)
dir = UnknownDirective(" IVDEP", "DIR")
insert_at = loop.parent.children.index(loop)
loop.parent.children.insert(insert_at, cblock)
loop.parent.children.insert(insert_at, dir)

for loop in outer_loops[2].walk(Loop)[2:7]:
# Check if any eligible variables appear in subroutine
Expand All @@ -129,7 +106,8 @@ def trans(psyir):
options = {}
if len(ignore_deps_vars) > 0:
options["ignore_dependencies_for"] = ignore_deps_vars
OMP_DO_LOOP_TRANS_STATIC.apply(loop, options)
OMP_DO_LOOP_TRANS_STATIC.apply(loop, options=options,
force_private=private_variables)

for loop in outer_loops[2].walk(Loop)[8:13:2]:
# Check if any eligible variables appear on the LHS of
Expand All @@ -139,7 +117,8 @@ def trans(psyir):
if len(ignore_deps_vars) > 0:
options["ignore_dependencies_for"] = ignore_deps_vars

OMP_DO_LOOP_TRANS_STATIC.apply(loop, options)
OMP_DO_LOOP_TRANS_STATIC.apply(loop, options=options,
force_private=private_variables)

except (TransformationError, IndexError) as err:
logging.warning("Parallelisation of the 2nd region failed: %s", err)