Commit 55ddc084 authored by Mark Florisson's avatar Mark Florisson Committed by Vitja Makarov

Fix test runner and make nsteps private

parent 594b1bf1
......@@ -11,6 +11,7 @@ Cython/Runtime/refnanny.c
BUILD/
build/
dist/
.git/
.gitrev
.coverage
*.orig
......
......@@ -5760,6 +5760,9 @@ class ParallelStatNode(StatNode, ParallelNode):
#pragma omp for
We need this to determine the sharing attributes.
privatization_insertion_point a code insertion point used to make temps
private (esp. the "nsteps" temp)
"""
child_attrs = ['body']
......@@ -5942,6 +5945,8 @@ class ParallelWithBlockNode(ParallelStatNode):
code.put(
'private(%s)' % ', '.join([e.cname for e in self.privates]))
self.privatization_insertion_point = code.insertion_point()
code.putln("")
code.putln("#endif /* _OPENMP */")
......@@ -6144,13 +6149,7 @@ class ParallelRangeNode(ParallelStatNode):
# 'with gil' block. For now, just abort
code.putln("if (%(step)s == 0) abort();" % fmt_dict)
# Guard for never-ending loops: prange(0, 10, -1) or prange(10, 0, 1)
# range() returns [] in these cases
code.put("if ( (%(start)s < %(stop)s && %(step)s > 0) || "
"(%(start)s > %(stop)s && %(step)s < 0) ) " % fmt_dict)
code.begin_block()
code.putln_openmp("#pragma omp critical")
# Note: nsteps is private in an outer scope if present
code.putln("%(nsteps)s = (%(stop)s - %(start)s) / %(step)s;" % fmt_dict)
self.generate_loop(code, fmt_dict)
......@@ -6167,9 +6166,6 @@ class ParallelRangeNode(ParallelStatNode):
self.release_closure_privates(code)
# end the 'if' block that guards against infinite loops
code.end_block()
def generate_loop(self, code, fmt_dict):
code.putln("#ifdef _OPENMP")
......@@ -6188,6 +6184,12 @@ class ParallelRangeNode(ParallelStatNode):
if self.schedule:
code.put(" schedule(%s)" % self.schedule)
if self.parent:
c = self.parent.privatization_insertion_point
c.put(" private(%(nsteps)s)" % fmt_dict)
self.privatization_insertion_point = code.insertion_point()
code.putln("")
code.putln("#endif /* _OPENMP */")
......@@ -6198,8 +6200,6 @@ class ParallelRangeNode(ParallelStatNode):
code.end_block()
#------------------------------------------------------------------------------------
#
# Runtime support code
......
......@@ -109,13 +109,18 @@ def get_openmp_compiler_flags(language):
else:
cc = sysconfig.get_config_var('CC')
# For some reason, cc can be e.g. 'gcc -pthread'
cc = cc.split()[0]
matcher = re.compile(r"gcc version (\d+\.\d+)").search
try:
import subprocess
except ImportError:
try:
in_, out, err = os.popen(cc + " -v")
except EnvironmentError, e:
except EnvironmentError:
# Be compatible with Python 3
_, e, _ = sys.exc_info()
warnings.warn("Unable to find the %s compiler: %s: %s" %
(language, os.strerror(e.errno), cc))
return None
......@@ -126,6 +131,8 @@ def get_openmp_compiler_flags(language):
p = subprocess.Popen([cc, "-v"], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
except EnvironmentError, e:
# Be compatible with Python 3
_, e, _ = sys.exc_info()
warnings.warn("Unable to find the %s compiler: %s: %s" %
(language, os.strerror(e.errno), cc))
return None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment