Commit 93c2d084 authored by Stefan Behnel's avatar Stefan Behnel

modernise setup.py example in OpenMP docs

parent d9a5b060
......@@ -160,48 +160,37 @@ It currently supports OpenMP, but later on more backends might be supported.
Returns the id of the thread. For n threads, the ids will range from 0 to
n-1.
Compiling
=========
To actually use the OpenMP support, you need to tell the C or C++ compiler to
enable OpenMP. For gcc this can be done as follows in a setup.py::
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
from Cython.Build import cythonize
ext_module = Extension(
ext_modules = [
Extension(
"hello",
["hello.pyx"],
extra_compile_args=['-fopenmp'],
extra_link_args=['-fopenmp'],
)
]
setup(
name = 'Hello world app',
cmdclass = {'build_ext': build_ext},
ext_modules = [ext_module],
name='hello-parallel-world',
ext_modules=cythonize(ext_modules),
)
For Microsoft Visual C++ compiler::
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_module = Extension(
"hello",
["hello.pyx"],
extra_compile_args=['/openmp'],
)
For Microsoft Visual C++ compiler, use ``'/openmp'`` instead of ``'-fopenmp'``.
setup(
name = 'Hello world app',
cmdclass = {'build_ext': build_ext},
ext_modules = [ext_module],
)
Breaking out of loops
=====================
The parallel with and prange blocks support the statements break, continue and
return in nogil mode. Additionally, it is valid to use a ``with gil`` block
inside these blocks, and have exceptions propagate from them.
......
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