Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
8b1a4177
Commit
8b1a4177
authored
Aug 23, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cython.parallel: Use restore exception utility code when code.error_label is used
parent
85d9b64b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
1 deletion
+41
-1
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+9
-1
tests/errors/e_cython_parallel_nogil_env.pyx
tests/errors/e_cython_parallel_nogil_env.pyx
+17
-0
tests/run/sequential_parallel.pyx
tests/run/sequential_parallel.pyx
+15
-0
No files found.
Cython/Compiler/Nodes.py
View file @
8b1a4177
...
...
@@ -6458,6 +6458,7 @@ class ParallelStatNode(StatNode, ParallelNode):
code
.
put_goto
(
code
.
return_label
)
if
self
.
error_label_used
:
code
.
globalstate
.
use_utility_code
(
restore_exception_utility_code
)
code
.
putln
(
" case 4:"
)
self
.
restore_parallel_exception
(
code
)
code
.
put_goto
(
code
.
error_label
)
...
...
@@ -6539,7 +6540,7 @@ class ParallelRangeNode(ParallelStatNode):
is_prange
=
True
nogil
=
Fals
e
nogil
=
Non
e
schedule
=
None
num_threads
=
None
...
...
@@ -6576,6 +6577,10 @@ class ParallelRangeNode(ParallelStatNode):
(
self
.
schedule
,))
def
analyse_expressions
(
self
,
env
):
if
self
.
nogil
:
was_nogil
=
env
.
nogil
env
.
nogil
=
True
if
self
.
target
is
None
:
error
(
self
.
pos
,
"prange() can only be used as part of a for loop"
)
return
...
...
@@ -6627,6 +6632,9 @@ class ParallelRangeNode(ParallelStatNode):
super
(
ParallelRangeNode
,
self
).
analyse_expressions
(
env
)
if
self
.
nogil
:
env
.
nogil
=
was_nogil
def
nogil_check
(
self
,
env
):
names
=
'start'
,
'stop'
,
'step'
,
'target'
nodes
=
self
.
start
,
self
.
stop
,
self
.
step
,
self
.
target
...
...
tests/errors/e_cython_parallel_nogil_env.pyx
0 → 100644
View file @
8b1a4177
# mode: error
from
cython.parallel
import
*
def
psum
(
int
n
):
cdef
double
sum
cdef
int
i
cdef
double
x
,
step
,
t1
,
t2
sum
=
0
step
=
1.0
/
n
for
i
in
prange
(
n
,
nogil
=
True
):
x
=
(
i
)
*
step
sum
+=
4.0
/
(
1.0
+
x
*
x
)
return
sum
*
step
_ERRORS
=
u"""
e_cython_parallel_nogil_env.pyx:12:15: Pythonic division not allowed without gil, consider using cython.cdivision(True)
"""
tests/run/sequential_parallel.pyx
View file @
8b1a4177
...
...
@@ -705,3 +705,18 @@ def outer_parallel_section():
for
i
in
prange
(
10
,
nogil
=
True
):
sum
+=
inner_parallel_section
()
return
sum
cdef
int
nogil_cdef_except_clause
()
nogil
except
0
:
return
1
cdef
void
nogil_cdef_except_star
()
nogil
except
*
:
pass
def
test_nogil_cdef_except_clause
():
"""
>>> test_nogil_cdef_except_clause()
"""
cdef
int
i
for
i
in
prange
(
10
,
nogil
=
True
):
nogil_cdef_except_clause
()
nogil_cdef_except_star
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment