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
300120ee
Commit
300120ee
authored
Apr 16, 2011
by
Mark Florisson
Committed by
Vitja Makarov
May 05, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OpenMP header pxd
parent
c0d92368
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
74 additions
and
22 deletions
+74
-22
Cython/Includes/openmp.pxd
Cython/Includes/openmp.pxd
+49
-0
tests/run/parallel.pyx
tests/run/parallel.pyx
+25
-22
No files found.
Cython/Includes/openmp.pxd
0 → 100644
View file @
300120ee
cdef
extern
from
"omp.h"
:
ctypedef
struct
omp_lock_t
ctypedef
struct
omp_nest_lock_t
ctypedef
enum
omp_sched_t
:
omp_sched_static
=
1
,
omp_sched_dynamic
=
2
,
omp_sched_guided
=
3
,
omp_sched_auto
=
4
extern
void
omp_set_num_threads
(
int
)
extern
int
omp_get_num_threads
()
extern
int
omp_get_max_threads
()
extern
int
omp_get_thread_num
()
extern
int
omp_get_num_procs
()
extern
int
omp_in_parallel
()
extern
void
omp_set_dynamic
(
int
)
extern
int
omp_get_dynamic
()
extern
void
omp_set_nested
(
int
)
extern
int
omp_get_nested
()
extern
void
omp_init_lock
(
omp_lock_t
*
)
extern
void
omp_destroy_lock
(
omp_lock_t
*
)
extern
void
omp_set_lock
(
omp_lock_t
*
)
extern
void
omp_unset_lock
(
omp_lock_t
*
)
extern
int
omp_test_lock
(
omp_lock_t
*
)
extern
void
omp_init_nest_lock
(
omp_nest_lock_t
*
)
extern
void
omp_destroy_nest_lock
(
omp_nest_lock_t
*
)
extern
void
omp_set_nest_lock
(
omp_nest_lock_t
*
)
extern
void
omp_unset_nest_lock
(
omp_nest_lock_t
*
)
extern
int
omp_test_nest_lock
(
omp_nest_lock_t
*
)
extern
double
omp_get_wtime
()
extern
double
omp_get_wtick
()
void
omp_set_schedule
(
omp_sched_t
,
int
)
void
omp_get_schedule
(
omp_sched_t
*
,
int
*
)
int
omp_get_thread_limit
()
void
omp_set_max_active_levels
(
int
)
int
omp_get_max_active_levels
()
int
omp_get_level
()
int
omp_get_ancestor_thread_num
(
int
)
int
omp_get_team_size
(
int
)
int
omp_get_active_level
()
tests/run/parallel.pyx
View file @
300120ee
...
...
@@ -4,6 +4,7 @@
cimport
cython.parallel
from
cython.parallel
import
prange
,
threadid
cimport
openmp
from
libc.stdlib
cimport
malloc
,
free
from
libc.stdio
cimport
puts
cimport
numpy
as
np
...
...
@@ -67,23 +68,24 @@ def test_nested_prange():
return
sum
# threadsavailable test, disable this for now as it won't compile
#def test_parallel():
# """
# >>> test_parallel()
# """
# cdef int *buf = <int *> malloc(sizeof(int) * threadsavailable())
#
# if buf == NULL:
# raise MemoryError
#
# with nogil, cython.parallel.parallel:
# buf[threadid()] = threadid()
#
# for i in range(threadsavailable()):
# assert buf[i] == i
#
# free(buf)
def
test_parallel
():
"""
>>> test_parallel()
"""
cdef
int
maxthreads
=
openmp
.
omp_get_max_threads
()
cdef
int
*
buf
=
<
int
*>
malloc
(
sizeof
(
int
)
*
maxthreads
)
if
buf
==
NULL
:
raise
MemoryError
with
nogil
,
cython
.
parallel
.
parallel
:
buf
[
threadid
()]
=
threadid
()
for
i
in
range
(
maxthreads
):
assert
buf
[
i
]
==
i
free
(
buf
)
def
test_unsigned_operands
():
"""
...
...
@@ -230,3 +232,4 @@ def test_parallel_numpy_arrays():
for
i
in
x
:
print
x
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