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
36ab0511
Commit
36ab0511
authored
Dec 17, 2018
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test
parent
1b0999f9
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
4063 additions
and
7 deletions
+4063
-7
test.c
test.c
+3447
-1
test.html
test.html
+598
-0
test.py
test.py
+12
-2
test.pyx
test.pyx
+6
-4
No files found.
test.c
View file @
36ab0511
This source diff could not be displayed because it is too large. You can
view the blob
instead.
test.html
0 → 100644
View file @
36ab0511
This diff is collapsed.
Click to expand it.
test.py
View file @
36ab0511
from
distutils.core
import
setup
from
distutils.core
import
setup
from
distutils.extension
import
Extension
from
Cython.Build
import
cythonize
from
Cython.Build
import
cythonize
ext_modules
=
[
Extension
(
'test'
,
[
'test.pyx'
],
extra_compile_args
=
[
'-fopenmp'
],
extra_link_args
=
[
'-fopenmp'
],
)
]
setup
(
setup
(
ext_modules
=
cythonize
(
"test.pyx"
)
ext_modules
=
cythonize
(
ext_modules
)
)
)
test.pyx
View file @
36ab0511
#cython: language_level = 3
#cython: language_level = 3
from
cython.parallel
import
parallel
from
libc.stdio
cimport
printf
from
libc.stdio
cimport
printf
"""
"""
GOAL: implement nogil option in cdef class (extension types)
GOAL: implement nogil option in cdef class (extension types)
...
@@ -53,8 +54,8 @@ cdef class SomeMemory nogil:
...
@@ -53,8 +54,8 @@ cdef class SomeMemory nogil:
It is possible to define native C/Cython methods
It is possible to define native C/Cython methods
that release the GIL (cool...)
that release the GIL (cool...)
"""
"""
pass
while
1
:
# self.a = self.b
self
.
a
+=
1
# Not allowed to define pure Python function in the extension type with nogil option now
# Not allowed to define pure Python function in the extension type with nogil option now
# since we want this extension type is CPython free
# since we want this extension type is CPython free
...
@@ -76,6 +77,7 @@ cdef double bar() nogil: # yet this is what we would like to
...
@@ -76,6 +77,7 @@ cdef double bar() nogil: # yet this is what we would like to
# cdef SomeMemory o = SomeMemory(42.0, 3.14) # for this we need class allocation to handle memory without libpython
# cdef SomeMemory o = SomeMemory(42.0, 3.14) # for this we need class allocation to handle memory without libpython
cdef
SomeMemory
o1
=
SomeMemory
(
1
,
1.0
)
cdef
SomeMemory
o1
=
SomeMemory
(
1
,
1.0
)
cdef
SomeMemory
o2
=
SomeMemory
(
2
,
2.0
)
cdef
SomeMemory
o2
=
SomeMemory
(
2
,
2.0
)
with
nogil
,
parallel
():
o1
.
foo
()
o1
.
foo
()
o2
.
foo
()
o2
.
foo
()
# o.foo() # and we need method selection to be independent of libpython
# o.foo() # and we need method selection to be independent of libpython
...
...
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