Skip to content
Merged
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
2 changes: 2 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
58) PR #3057 for 3056. Demote OpenMP lowering error to warning.

57) PR #3018 for #3017. Fix ArrayType with defined lower bounds, but no upper
bound.

Expand Down
12 changes: 7 additions & 5 deletions src/psyclone/psyir/nodes/omp_directives.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import abc
import itertools
import sympy
import logging

from psyclone.configuration import Config
from psyclone.core import AccessType
Expand Down Expand Up @@ -1384,11 +1385,12 @@ def lower_to_language_level(self):
clause.children]:
break
else:
raise GenerationError(
f"Lowering '{type(self).__name__}' does not support "
f"symbols that need synchronisation unless they are "
f"in a depend clause, but found: "
f"'{sym.name}' which is not in a depend clause.")
logger = logging.getLogger(__name__)
logger.warning(
"Lowering '%s' detected a possible race condition for "
"symbol '%s'. Make sure this is a false WaW dependency"
" or the code includes the necessary "
"synchronisations.", type(self).__name__, sym.name)

self.addchild(private_clause)
self.addchild(fprivate_clause)
Expand Down
32 changes: 18 additions & 14 deletions src/psyclone/tests/psyir/nodes/omp_directives_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

import os
import pytest
import logging
from psyclone.errors import UnresolvedDependencyError
from psyclone.parse.algorithm import parse
from psyclone.psyGen import PSyFactory
Expand Down Expand Up @@ -78,7 +79,7 @@
"gocean1p0")


def test_ompparallel_lowering(fortran_reader, monkeypatch):
def test_ompparallel_lowering(fortran_reader, monkeypatch, caplog):
''' Check that lowering an OMP Parallel region leaves it with the
appropriate begin_string and clauses for the backend to generate
the right code'''
Expand Down Expand Up @@ -141,11 +142,12 @@ def test_ompparallel_lowering(fortran_reader, monkeypatch):
a_sym = Symbol("a")
monkeypatch.setattr(pdir, "infer_sharing_attributes",
lambda: ({}, {}, {a_sym}))
with pytest.raises(GenerationError) as err:
with caplog.at_level(logging.WARNING):
pdir.lower_to_language_level()
assert ("Lowering 'OMPParallelDirective' does not support symbols that "
"need synchronisation unless they are in a depend clause, but "
"found: 'a' which is not in a depend clause." in str(err.value))
assert ("Lowering 'OMPParallelDirective' detected a possible race "
"condition for symbol 'a'. Make sure this is a false WaW "
"dependency or the code includes the necessary synchronisations."
"\n" in caplog.text)

# Also a case which contains the symbol in an input dependency clause.
task_dir = OMPTaskDirective()
Expand All @@ -158,14 +160,15 @@ def test_ompparallel_lowering(fortran_reader, monkeypatch):
task_dir.addchild(in_clause)
pdir.children[0].addchild(task_dir)

with pytest.raises(GenerationError) as err:
with caplog.at_level(logging.WARNING):
pdir.lower_to_language_level()
assert ("Lowering 'OMPParallelDirective' does not support symbols that "
"need synchronisation unless they are in a depend clause, but "
"found: 'a' which is not in a depend clause." in str(err.value))
assert ("Lowering 'OMPParallelDirective' detected a possible race "
"condition for symbol 'a'. Make sure this is a false WaW "
"dependency or the code includes the necessary synchronisations."
"\n" in caplog.text)


def test_omp_parallel_do_lowering(fortran_reader, monkeypatch):
def test_omp_parallel_do_lowering(fortran_reader, monkeypatch, caplog):
''' Check that lowering an OMP Parallel Do leaves it with the
appropriate begin_string and clauses for the backend to generate
the right code'''
Expand Down Expand Up @@ -231,11 +234,12 @@ def test_omp_parallel_do_lowering(fortran_reader, monkeypatch):
# Monkeypatch a case with shared variables that need synchronisation
monkeypatch.setattr(pdir, "infer_sharing_attributes",
lambda: ({}, {}, {Symbol("a")}))
with pytest.raises(GenerationError) as err:
with caplog.at_level(logging.WARNING):
pdir.lower_to_language_level()
assert ("Lowering 'OMPParallelDoDirective' does not support symbols that "
"need synchronisation unless they are in a depend clause, but "
"found: 'a' which is not in a depend clause." in str(err.value))
assert ("Lowering 'OMPParallelDoDirective' detected a possible race "
"condition for symbol 'a'. Make sure this is a false WaW "
"dependency or the code includes the necessary synchronisations."
"\n" in caplog.text)


def test_omp_teams_distribute_parallel_do_strings(
Expand Down
Loading