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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
1a91b07e
Commit
1a91b07e
authored
Sep 21, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a pure Python OpenMP test to make sure everything works from pure Python mode.
parent
597358c0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
tests/run/pure_parallel.py
tests/run/pure_parallel.py
+60
-0
No files found.
tests/run/pure_parallel.py
0 → 100644
View file @
1a91b07e
# mode: run
# tag: openmp, pure3.6
import
cython
from
cython.parallel
import
prange
,
parallel
def
prange_regression
(
n
:
cython
.
int
,
data
:
list
):
"""
>>> prange_regression(10, list(range(1, 4)))
19
"""
s
:
cython
.
int
=
0
i
:
cython
.
int
d
:
cython
.
int
[
3
]
=
data
for
i
in
prange
(
n
,
num_threads
=
3
,
nogil
=
True
):
s
+=
d
[
i
%
3
]
return
s
def
prange_with_gil
(
n
:
cython
.
int
,
x
):
"""
>>> sum(3*i for i in range(10))
135
>>> prange_with_gil(10, 3)
135
"""
i
:
cython
.
int
s
:
cython
.
int
=
0
for
i
in
prange
(
n
,
num_threads
=
3
,
nogil
=
True
):
with
cython
.
gil
:
s
+=
x
*
i
return
s
@
cython
.
cfunc
def
use_nogil
(
x
,
i
:
cython
.
int
)
->
cython
.
int
:
cx
:
cython
.
int
=
x
with
cython
.
nogil
:
return
cx
*
i
def
prange_with_gil_call_nogil
(
n
:
cython
.
int
,
x
):
"""
>>> sum(3*i for i in range(10))
135
>>> prange_with_gil(10, 3)
135
"""
i
:
cython
.
int
s
:
cython
.
int
=
0
for
i
in
prange
(
n
,
num_threads
=
3
,
nogil
=
True
):
with
cython
.
gil
:
s
+=
use_nogil
(
x
,
i
)
return
s
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