Commit 4dd190a7 authored by Mark Florisson's avatar Mark Florisson

Shut up as much compiler warnings as possible through firstprivate

parent a3e838e3
......@@ -6146,8 +6146,20 @@ class ParallelRangeNode(ParallelStatNode):
# Note: nsteps is private in an outer scope if present
code.putln("%(nsteps)s = (%(stop)s - %(start)s) / %(step)s;" % fmt_dict)
# The target iteration variable might not be initialized, do it only if
# we are executing at least 1 iteration, otherwise we should leave the
# target unaffected. The target iteration variable is firstprivate to
# shut up compiler warnings caused by lastprivate, as the compiler
# erroneously believes that nsteps may be <= 0, leaving the private
# target index uninitialized
code.putln("if (%(nsteps)s > 0)" % fmt_dict)
code.begin_block()
code.putln("%(target)s = 0;" % fmt_dict)
self.generate_loop(code, fmt_dict)
code.end_block()
# And finally, release our privates and write back any closure
# variables
for temp in start_stop_step:
......@@ -6173,6 +6185,8 @@ class ParallelRangeNode(ParallelStatNode):
if op and op in "+*-&^|" and entry != self.target.entry:
code.put(" reduction(%s:%s)" % (op, entry.cname))
else:
if entry == self.target.entry:
code.put(" firstprivate(%s)" % entry.cname)
code.put(" lastprivate(%s)" % entry.cname)
if self.schedule:
......
......@@ -2,7 +2,7 @@
cimport cython.parallel
from cython.parallel import prange, threadid
from libc.stdlib cimport malloc, free
from libc.stdlib cimport malloc, free, abort
from libc.stdio cimport puts
import sys
......@@ -67,11 +67,7 @@ def test_propagation():
def test_unsigned_operands():
"""
This test is disabled, as this currently does not work (neither does it
for 'for i from x < i < y:'. I'm not sure we should strife to support
this, at least the C compiler gives a warning.
test_unsigned_operands()
>>> test_unsigned_operands()
10
"""
cdef int i
......@@ -83,6 +79,8 @@ def test_unsigned_operands():
for i in prange(start, stop, step, nogil=True):
steps_taken += 1
if steps_taken > 10:
abort()
return steps_taken
......
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