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
Gwenaël Samain
cython
Commits
6deb4fb4
Commit
6deb4fb4
authored
Oct 29, 2011
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update OpenMP documentation
parent
93a54303
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
3 deletions
+13
-3
docs/src/userguide/external_C_code.rst
docs/src/userguide/external_C_code.rst
+8
-0
docs/src/userguide/parallelism.rst
docs/src/userguide/parallelism.rst
+5
-3
No files found.
docs/src/userguide/external_C_code.rst
View file @
6deb4fb4
...
...
@@ -446,6 +446,14 @@ header::
cdef void my_callback(void *data) with gil:
...
If the callback may be called from another thread then the main thread which may not be a Python thread,
care must be taken to initialize the GIL first, through a call to ``PyEval_InitThreads()``.
The GIL may also be acquired through the ``with nogil`` counterpart ``with gil``::
with gil:
<execute this block with the GIL acquired>
Declaring a function as callable without the GIL
--------------------------------------------------
...
...
docs/src/userguide/parallelism.rst
View file @
6deb4fb4
...
...
@@ -11,6 +11,8 @@ module. To use this kind of parallelism, the GIL must be released
(see :ref:`Releasing the GIL <nogil>`).
It currently supports OpenMP, but later on more backends might be supported.
.. NOTE:: Because the backend is OpenMP, cython.parallel functionality may only be used from the main thread or from OpenMP threads.
__ nogil_
.. function:: prange([start,] stop[, step], nogil=False, schedule=None)
...
...
@@ -76,11 +78,11 @@ __ nogil_
print sum
Example with a
shared numpy array
::
Example with a
typed memoryview (e.g. a NumPy array)
::
from cython.parallel import prange
def func(
np.ndarray[double
] x, double alpha):
def func(
double[:
] x, double alpha):
cdef Py_ssize_t i
for i in prange(x.shape[0]):
...
...
@@ -152,7 +154,7 @@ enable OpenMP. For gcc this can be done as follows in a setup.py::
Breaking
========
The parallel with and prange blocks support break, continue and return in
nogil mode. Additionally, it is valid to use a
with gil
block inside these
nogil mode. Additionally, it is valid to use a
``with gil``
block inside these
blocks, and have exceptions propagate from them.
However, because the blocks use OpenMP, they can not just be left, so the
exiting procedure is best-effort. For prange() this means that the loop
...
...
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