Permalink
Browse files

Fix test runner and make nsteps private

  • Loading branch information...
1 parent 35d5e23 commit b48900fd486a3291f4c005ec4ae62ae2b69aa228 @markflorisson markflorisson committed May 4, 2011
Showing with 21 additions and 13 deletions.
  1. +1 −0 .hgignore
  2. +12 −12 Cython/Compiler/Nodes.py
  3. +8 −1 runtests.py
View
@@ -11,6 +11,7 @@ Cython/Runtime/refnanny.c
BUILD/
build/
dist/
+.git/
.gitrev
.coverage
*.orig
View
@@ -5754,6 +5754,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']
@@ -5936,6 +5939,8 @@ def generate_execution_code(self, code):
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 */")
@@ -6138,13 +6143,7 @@ def generate_execution_code(self, code):
# '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)
@@ -6161,9 +6160,6 @@ def generate_execution_code(self, 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):
code.putln("#ifdef _OPENMP")
@@ -6182,6 +6178,12 @@ def generate_loop(self, code, fmt_dict):
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 */")
@@ -6192,8 +6194,6 @@ def generate_loop(self, code, fmt_dict):
code.end_block()
-
-
#------------------------------------------------------------------------------------
#
# Runtime support code
View
@@ -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

0 comments on commit b48900f

Please sign in to comment.