Commit b48900fd authored by Mark Florisson's avatar Mark Florisson

Fix test runner and make nsteps private

parent 35d5e233
...@@ -11,6 +11,7 @@ Cython/Runtime/refnanny.c ...@@ -11,6 +11,7 @@ Cython/Runtime/refnanny.c
BUILD/ BUILD/
build/ build/
dist/ dist/
.git/
.gitrev .gitrev
.coverage .coverage
*.orig *.orig
......
...@@ -5754,6 +5754,9 @@ class ParallelStatNode(StatNode, ParallelNode): ...@@ -5754,6 +5754,9 @@ class ParallelStatNode(StatNode, ParallelNode):
#pragma omp for #pragma omp for
We need this to determine the sharing attributes. 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'] child_attrs = ['body']
...@@ -5936,6 +5939,8 @@ class ParallelWithBlockNode(ParallelStatNode): ...@@ -5936,6 +5939,8 @@ class ParallelWithBlockNode(ParallelStatNode):
code.put( code.put(
'private(%s)' % ', '.join([e.cname for e in self.privates])) 'private(%s)' % ', '.join([e.cname for e in self.privates]))
self.privatization_insertion_point = code.insertion_point()
code.putln("") code.putln("")
code.putln("#endif /* _OPENMP */") code.putln("#endif /* _OPENMP */")
...@@ -6138,13 +6143,7 @@ class ParallelRangeNode(ParallelStatNode): ...@@ -6138,13 +6143,7 @@ class ParallelRangeNode(ParallelStatNode):
# 'with gil' block. For now, just abort # 'with gil' block. For now, just abort
code.putln("if (%(step)s == 0) abort();" % fmt_dict) code.putln("if (%(step)s == 0) abort();" % fmt_dict)
# Guard for never-ending loops: prange(0, 10, -1) or prange(10, 0, 1) # Note: nsteps is private in an outer scope if present
# 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")
code.putln("%(nsteps)s = (%(stop)s - %(start)s) / %(step)s;" % fmt_dict) code.putln("%(nsteps)s = (%(stop)s - %(start)s) / %(step)s;" % fmt_dict)
self.generate_loop(code, fmt_dict) self.generate_loop(code, fmt_dict)
...@@ -6161,9 +6160,6 @@ class ParallelRangeNode(ParallelStatNode): ...@@ -6161,9 +6160,6 @@ class ParallelRangeNode(ParallelStatNode):
self.release_closure_privates(code) self.release_closure_privates(code)
# end the 'if' block that guards against infinite loops
code.end_block()
def generate_loop(self, code, fmt_dict): def generate_loop(self, code, fmt_dict):
code.putln("#ifdef _OPENMP") code.putln("#ifdef _OPENMP")
...@@ -6182,6 +6178,12 @@ class ParallelRangeNode(ParallelStatNode): ...@@ -6182,6 +6178,12 @@ class ParallelRangeNode(ParallelStatNode):
if self.schedule: if self.schedule:
code.put(" schedule(%s)" % 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("")
code.putln("#endif /* _OPENMP */") code.putln("#endif /* _OPENMP */")
...@@ -6192,8 +6194,6 @@ class ParallelRangeNode(ParallelStatNode): ...@@ -6192,8 +6194,6 @@ class ParallelRangeNode(ParallelStatNode):
code.end_block() code.end_block()
#------------------------------------------------------------------------------------ #------------------------------------------------------------------------------------
# #
# Runtime support code # Runtime support code
......
...@@ -109,13 +109,18 @@ def get_openmp_compiler_flags(language): ...@@ -109,13 +109,18 @@ def get_openmp_compiler_flags(language):
else: else:
cc = sysconfig.get_config_var('CC') 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 matcher = re.compile(r"gcc version (\d+\.\d+)").search
try: try:
import subprocess import subprocess
except ImportError: except ImportError:
try: try:
in_, out, err = os.popen(cc + " -v") 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" % warnings.warn("Unable to find the %s compiler: %s: %s" %
(language, os.strerror(e.errno), cc)) (language, os.strerror(e.errno), cc))
return None return None
...@@ -126,6 +131,8 @@ def get_openmp_compiler_flags(language): ...@@ -126,6 +131,8 @@ def get_openmp_compiler_flags(language):
p = subprocess.Popen([cc, "-v"], stdout=subprocess.PIPE, p = subprocess.Popen([cc, "-v"], stdout=subprocess.PIPE,
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
except EnvironmentError, e: except EnvironmentError, e:
# Be compatible with Python 3
_, e, _ = sys.exc_info()
warnings.warn("Unable to find the %s compiler: %s: %s" % warnings.warn("Unable to find the %s compiler: %s: %s" %
(language, os.strerror(e.errno), cc)) (language, os.strerror(e.errno), cc))
return None 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