Commit a2266711 authored by Stefan Behnel's avatar Stefan Behnel

Clean up insertion points after use in prange code since they conflict with...

Clean up insertion points after use in prange code since they conflict with the deep-copying that with-statements use for their finally-clause.
Closes GH-2780.
parent 272efcf6
......@@ -8439,9 +8439,10 @@ class ParallelStatNode(StatNode, ParallelNode):
Make any used temporaries private. Before the relevant code block
code.start_collecting_temps() should have been called.
"""
if self.is_parallel:
c = self.privatization_insertion_point
self.privatization_insertion_point = None
if self.is_parallel:
self.temps = temps = code.funcstate.stop_collecting_temps()
privates, firstprivates = [], []
for temp, type in sorted(temps):
......@@ -8532,8 +8533,10 @@ class ParallelStatNode(StatNode, ParallelNode):
If compiled without OpenMP support (at the C level), then we still have
to acquire the GIL to decref any object temporaries.
"""
if self.error_label_used:
begin_code = self.begin_of_parallel_block
self.begin_of_parallel_block = None
if self.error_label_used:
end_code = code
begin_code.putln("#ifdef _OPENMP")
......@@ -8746,6 +8749,8 @@ class ParallelStatNode(StatNode, ParallelNode):
the for loop.
"""
c = self.begin_of_parallel_control_block_point
self.begin_of_parallel_control_block_point = None
self.begin_of_parallel_control_block_point_after_decls = None
# Firstly, always prefer errors over returning, continue or break
if self.error_label_used:
......@@ -9096,8 +9101,6 @@ class ParallelRangeNode(ParallelStatNode):
self.setup_parallel_control_flow_block(code) # parallel control flow block
self.control_flow_var_code_point = code.insertion_point()
# Note: nsteps is private in an outer scope if present
code.putln("%(nsteps)s = (%(stop)s - %(start)s + %(step)s - %(step)s/abs(%(step)s)) / %(step)s;" % fmt_dict)
......
......@@ -754,3 +754,19 @@ def test_pointer_temps(double x):
f = &arr[0]
return f[0]
def test_prange_in_with(int x, ctx):
"""
>>> from contextlib import contextmanager
>>> @contextmanager
... def ctx(l): yield l
>>> test_prange_in_with(4, ctx([0]))
6
"""
cdef int i
with ctx as l:
for i in prange(x, nogil=True):
with gil:
l[0] += i
return l[0]
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