Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pyopencl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
pyopencl
Commits
7ad07419
Commit
7ad07419
authored
11 years ago
by
Marko Bencun
Browse files
Options
Downloads
Patches
Plain Diff
wait_for
parent
349497a1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyopencl/cffi_cl.py
+13
-2
13 additions, 2 deletions
pyopencl/cffi_cl.py
src/c_wrapper/wrap_cl.cpp
+36
-30
36 additions, 30 deletions
src/c_wrapper/wrap_cl.cpp
src/c_wrapper/wrap_cl_core.h
+3
-3
3 additions, 3 deletions
src/c_wrapper/wrap_cl_core.h
with
52 additions
and
35 deletions
pyopencl/cffi_cl.py
+
13
−
2
View file @
7ad07419
...
@@ -493,9 +493,15 @@ def enqueue_nd_range_kernel(queue, kernel, global_work_size, local_work_size, gl
...
@@ -493,9 +493,15 @@ def enqueue_nd_range_kernel(queue, kernel, global_work_size, local_work_size, gl
))
))
return
_create_instance
(
Event
,
ptr_event
[
0
])
return
_create_instance
(
Event
,
ptr_event
[
0
])
def
_c_wait_for
(
wait_for
=
None
):
if
wait_for
is
None
:
return
_ffi
.
NULL
,
0
return
_ffi
.
new
(
'
void *[]
'
,
[
ev
.
ptr
for
ev
in
wait_for
]),
len
(
wait_for
)
def
_enqueue_read_buffer
(
queue
,
mem
,
buf
,
device_offset
=
0
,
wait_for
=
None
,
is_blocking
=
True
):
def
_enqueue_read_buffer
(
queue
,
mem
,
buf
,
device_offset
=
0
,
wait_for
=
None
,
is_blocking
=
True
):
c_buf
,
size
=
Buffer
.
_c_buffer_from_obj
(
buf
)
c_buf
,
size
=
Buffer
.
_c_buffer_from_obj
(
buf
)
ptr_event
=
_ffi
.
new
(
'
void **
'
)
ptr_event
=
_ffi
.
new
(
'
void **
'
)
c_wait_for
,
num_wait_for
=
_c_wait_for
(
wait_for
=
wait_for
)
_handle_error
(
_lib
.
_enqueue_read_buffer
(
_handle_error
(
_lib
.
_enqueue_read_buffer
(
ptr_event
,
ptr_event
,
queue
.
ptr
,
queue
.
ptr
,
...
@@ -503,12 +509,14 @@ def _enqueue_read_buffer(queue, mem, buf, device_offset=0, wait_for=None, is_blo
...
@@ -503,12 +509,14 @@ def _enqueue_read_buffer(queue, mem, buf, device_offset=0, wait_for=None, is_blo
c_buf
,
c_buf
,
size
,
size
,
device_offset
,
device_offset
,
c_wait_for
,
num_wait_for
,
bool
(
is_blocking
)
bool
(
is_blocking
)
))
))
return
_create_instance
(
Event
,
ptr_event
[
0
])
return
_create_instance
(
Event
,
ptr_event
[
0
])
def
_enqueue_copy_buffer
(
queue
,
src
,
dst
,
byte_count
=-
1
,
src_offset
=
0
,
dst_offset
=
0
,
wait_for
=
None
):
def
_enqueue_copy_buffer
(
queue
,
src
,
dst
,
byte_count
=-
1
,
src_offset
=
0
,
dst_offset
=
0
,
wait_for
=
None
):
ptr_event
=
_ffi
.
new
(
'
void **
'
)
ptr_event
=
_ffi
.
new
(
'
void **
'
)
c_wait_for
,
num_wait_for
=
_c_wait_for
(
wait_for
=
wait_for
)
_handle_error
(
_lib
.
_enqueue_copy_buffer
(
_handle_error
(
_lib
.
_enqueue_copy_buffer
(
ptr_event
,
ptr_event
,
queue
.
ptr
,
queue
.
ptr
,
...
@@ -516,20 +524,23 @@ def _enqueue_copy_buffer(queue, src, dst, byte_count=-1, src_offset=0, dst_offse
...
@@ -516,20 +524,23 @@ def _enqueue_copy_buffer(queue, src, dst, byte_count=-1, src_offset=0, dst_offse
dst
.
ptr
,
dst
.
ptr
,
byte_count
,
byte_count
,
src_offset
,
src_offset
,
dst_offset
dst_offset
,
c_wait_for
,
num_wait_for
,
))
))
return
_create_instance
(
Event
,
ptr_event
[
0
])
return
_create_instance
(
Event
,
ptr_event
[
0
])
def
_enqueue_write_buffer
(
queue
,
mem
,
hostbuf
,
device_offset
=
0
,
wait_for
=
None
,
is_blocking
=
True
):
def
_enqueue_write_buffer
(
queue
,
mem
,
hostbuf
,
device_offset
=
0
,
wait_for
=
None
,
is_blocking
=
True
):
c_buf
,
size
=
Buffer
.
_c_buffer_from_obj
(
hostbuf
)
c_buf
,
size
=
Buffer
.
_c_buffer_from_obj
(
hostbuf
)
ptr_event
=
_ffi
.
new
(
'
void **
'
)
ptr_event
=
_ffi
.
new
(
'
void **
'
)
_handle_error
(
_lib
.
_enqueue_read_buffer
(
c_wait_for
,
num_wait_for
=
_c_wait_for
(
wait_for
=
wait_for
)
_handle_error
(
_lib
.
_enqueue_write_buffer
(
ptr_event
,
ptr_event
,
queue
.
ptr
,
queue
.
ptr
,
mem
.
ptr
,
mem
.
ptr
,
c_buf
,
c_buf
,
size
,
size
,
device_offset
,
device_offset
,
c_wait_for
,
num_wait_for
,
bool
(
is_blocking
)
bool
(
is_blocking
)
))
))
return
_create_instance
(
Event
,
ptr_event
[
0
])
return
_create_instance
(
Event
,
ptr_event
[
0
])
...
...
This diff is collapsed.
Click to expand it.
src/c_wrapper/wrap_cl.cpp
+
36
−
30
View file @
7ad07419
...
@@ -55,9 +55,6 @@
...
@@ -55,9 +55,6 @@
// }}}
// }}}
#define PYOPENCL_WAITLIST_ARGS \
num_events_in_wait_list, event_wait_list.empty( ) ? NULL : &event_wait_list.front()
#define PYOPENCL_GET_VEC_INFO(WHAT, FIRST_ARG, SECOND_ARG, RES_VEC) \
#define PYOPENCL_GET_VEC_INFO(WHAT, FIRST_ARG, SECOND_ARG, RES_VEC) \
{ \
{ \
size_t size; \
size_t size; \
...
@@ -147,7 +144,20 @@
...
@@ -147,7 +144,20 @@
info.value = (void*)ar; \
info.value = (void*)ar; \
return info; \
return info; \
}
}
// {{{ event helpers --------------------------------------------------------------
#define PYOPENCL_PARSE_WAIT_FOR \
std::vector<cl_event> event_wait_list(num_wait_for); \
{ \
for(unsigned i = 0; i < num_wait_for; ++i) { \
event_wait_list[i] = static_cast<pyopencl::event*>(wait_for[i])->data(); \
} \
}
#define PYOPENCL_WAITLIST_ARGS \
num_wait_for, event_wait_list.empty( ) ? NULL : &event_wait_list.front()
#define PYOPENCL_RETURN_NEW_EVENT(evt) \
#define PYOPENCL_RETURN_NEW_EVENT(evt) \
try \
try \
{ \
{ \
...
@@ -159,6 +169,7 @@
...
@@ -159,6 +169,7 @@
throw; \
throw; \
}
}
// }}}
// {{{ equality testing
// {{{ equality testing
#define PYOPENCL_EQUALITY_TESTS(cls) \
#define PYOPENCL_EQUALITY_TESTS(cls) \
...
@@ -1804,11 +1815,10 @@ generic_info get_info(cl_device_info param_name) const
...
@@ -1804,11 +1815,10 @@ generic_info get_info(cl_device_info param_name) const
void
*
buffer
,
void
*
buffer
,
size_t
size
,
size_t
size
,
size_t
device_offset
,
size_t
device_offset
,
/*py::object py
_wait_for,
*/
void
**
wait_for
,
uint32_t
num
_wait_for
,
bool
is_blocking
)
bool
is_blocking
)
{
{
// TODO
PYOPENCL_PARSE_WAIT_FOR
;
//PYOPENCL_PARSE_WAIT_FOR;
cl_event
evt
;
cl_event
evt
;
// TODO
// TODO
...
@@ -1818,8 +1828,7 @@ generic_info get_info(cl_device_info param_name) const
...
@@ -1818,8 +1828,7 @@ generic_info get_info(cl_device_info param_name) const
mem
.
data
(),
mem
.
data
(),
PYOPENCL_CAST_BOOL
(
is_blocking
),
PYOPENCL_CAST_BOOL
(
is_blocking
),
device_offset
,
size
,
buffer
,
device_offset
,
size
,
buffer
,
0
,
NULL
,
PYOPENCL_WAITLIST_ARGS
,
//PYOPENCL_WAITLIST_ARGS,
&
evt
&
evt
));
));
//);
//);
...
@@ -1834,14 +1843,11 @@ generic_info get_info(cl_device_info param_name) const
...
@@ -1834,14 +1843,11 @@ generic_info get_info(cl_device_info param_name) const
memory_object_holder
&
dst
,
memory_object_holder
&
dst
,
ptrdiff_t
byte_count
,
ptrdiff_t
byte_count
,
size_t
src_offset
,
size_t
src_offset
,
size_t
dst_offset
size_t
dst_offset
,
// ,
void
**
wait_for
,
uint32_t
num_wait_for
/*py::object py_wait_for*/
)
)
{
{
// TODO
PYOPENCL_PARSE_WAIT_FOR
;
// PYOPENCL_PARSE_WAIT_FOR;
if
(
byte_count
<
0
)
if
(
byte_count
<
0
)
{
{
size_t
byte_count_src
=
0
;
size_t
byte_count_src
=
0
;
...
@@ -1860,7 +1866,7 @@ generic_info get_info(cl_device_info param_name) const
...
@@ -1860,7 +1866,7 @@ generic_info get_info(cl_device_info param_name) const
src
.
data
(),
dst
.
data
(),
src
.
data
(),
dst
.
data
(),
src_offset
,
dst_offset
,
src_offset
,
dst_offset
,
byte_count
,
byte_count
,
0
,
NULL
,
//
PYOPENCL_WAITLIST_ARGS,
PYOPENCL_WAITLIST_ARGS
,
&
evt
&
evt
))
))
// );
// );
...
@@ -1874,10 +1880,10 @@ generic_info get_info(cl_device_info param_name) const
...
@@ -1874,10 +1880,10 @@ generic_info get_info(cl_device_info param_name) const
void
*
buffer
,
void
*
buffer
,
size_t
size
,
size_t
size
,
size_t
device_offset
,
size_t
device_offset
,
/*py::object py
_wait_for,
*/
void
**
wait_for
,
uint32_t
num
_wait_for
,
bool
is_blocking
)
bool
is_blocking
)
{
{
//
PYOPENCL_PARSE_WAIT_FOR;
PYOPENCL_PARSE_WAIT_FOR
;
cl_event
evt
;
cl_event
evt
;
// TODO
// TODO
...
@@ -1887,7 +1893,7 @@ generic_info get_info(cl_device_info param_name) const
...
@@ -1887,7 +1893,7 @@ generic_info get_info(cl_device_info param_name) const
mem
.
data
(),
mem
.
data
(),
PYOPENCL_CAST_BOOL
(
is_blocking
),
PYOPENCL_CAST_BOOL
(
is_blocking
),
device_offset
,
size
,
buffer
,
device_offset
,
size
,
buffer
,
0
,
NULL
,
//
PYOPENCL_WAITLIST_ARGS,
PYOPENCL_WAITLIST_ARGS
,
&
evt
&
evt
));
));
//);
//);
...
@@ -2156,30 +2162,30 @@ generic_info get_info(cl_device_info param_name) const
...
@@ -2156,30 +2162,30 @@ generic_info get_info(cl_device_info param_name) const
}
}
::
error
*
_enqueue_read_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_memory_object_holder
,
void
*
buffer
,
size_t
size
,
size_t
device_offset
,
int
is_blocking
)
{
::
error
*
_enqueue_read_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_memory_object_holder
,
void
*
buffer
,
size_t
size
,
size_t
device_offset
,
void
**
wait_for
,
uint32_t
num_wait_for
,
int
is_blocking
)
{
C_HANDLE_ERROR
(
C_HANDLE_ERROR
(
*
ptr_event
=
enqueue_read_buffer
(
*
static_cast
<
pyopencl
::
command_queue
*>
(
ptr_command_queue
),
*
ptr_event
=
enqueue_read_buffer
(
*
static_cast
<
pyopencl
::
command_queue
*>
(
ptr_command_queue
),
*
static_cast
<
pyopencl
::
memory_object_holder
*>
(
ptr_memory_object_holder
),
*
static_cast
<
pyopencl
::
memory_object_holder
*>
(
ptr_memory_object_holder
),
buffer
,
size
,
device_offset
,
(
bool
)
is_blocking
);
buffer
,
size
,
device_offset
,
wait_for
,
num_wait_for
,
(
bool
)
is_blocking
);
)
)
return
0
;
return
0
;
}
}
::
error
*
_enqueue_write_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_memory_object_holder
,
void
*
buffer
,
size_t
size
,
size_t
device_offset
,
int
is_blocking
)
{
::
error
*
_enqueue_write_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_memory_object_holder
,
void
*
buffer
,
size_t
size
,
size_t
device_offset
,
void
**
wait_for
,
uint32_t
num_wait_for
,
int
is_blocking
)
{
C_HANDLE_ERROR
(
C_HANDLE_ERROR
(
*
ptr_event
=
enqueue_write_buffer
(
*
static_cast
<
pyopencl
::
command_queue
*>
(
ptr_command_queue
),
*
ptr_event
=
enqueue_write_buffer
(
*
static_cast
<
pyopencl
::
command_queue
*>
(
ptr_command_queue
),
*
static_cast
<
pyopencl
::
memory_object_holder
*>
(
ptr_memory_object_holder
),
*
static_cast
<
pyopencl
::
memory_object_holder
*>
(
ptr_memory_object_holder
),
buffer
,
size
,
device_offset
,
(
bool
)
is_blocking
);
buffer
,
size
,
device_offset
,
wait_for
,
num_wait_for
,
(
bool
)
is_blocking
);
)
)
return
0
;
return
0
;
}
}
::
error
*
_enqueue_copy_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_src
,
void
*
ptr_dst
,
ptrdiff_t
byte_count
,
size_t
src_offset
,
size_t
dst_offset
)
{
::
error
*
_enqueue_copy_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_src
,
void
*
ptr_dst
,
ptrdiff_t
byte_count
,
size_t
src_offset
,
size_t
dst_offset
,
void
**
wait_for
,
uint32_t
num_wait_for
)
{
C_HANDLE_ERROR
(
C_HANDLE_ERROR
(
*
ptr_event
=
enqueue_copy_buffer
(
*
static_cast
<
pyopencl
::
command_queue
*>
(
ptr_command_queue
),
*
ptr_event
=
enqueue_copy_buffer
(
*
static_cast
<
pyopencl
::
command_queue
*>
(
ptr_command_queue
),
*
static_cast
<
pyopencl
::
memory_object_holder
*>
(
ptr_src
),
*
static_cast
<
pyopencl
::
memory_object_holder
*>
(
ptr_src
),
*
static_cast
<
pyopencl
::
memory_object_holder
*>
(
ptr_dst
),
*
static_cast
<
pyopencl
::
memory_object_holder
*>
(
ptr_dst
),
byte_count
,
src_offset
,
dst_offset
);
byte_count
,
src_offset
,
dst_offset
,
wait_for
,
num_wait_for
);
)
)
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/c_wrapper/wrap_cl_core.h
+
3
−
3
View file @
7ad07419
...
@@ -44,9 +44,9 @@ error *kernel__set_arg_mem_buffer(void *ptr_kernel, cl_uint arg_index, void *ptr
...
@@ -44,9 +44,9 @@ error *kernel__set_arg_mem_buffer(void *ptr_kernel, cl_uint arg_index, void *ptr
long
_hash
(
void
*
ptr_platform
,
class_t
);
long
_hash
(
void
*
ptr_platform
,
class_t
);
error
*
_enqueue_nd_range_kernel
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_kernel
,
cl_uint
work_dim
,
const
size_t
*
global_work_offset
,
const
size_t
*
global_work_size
,
const
size_t
*
local_work_size
);
error
*
_enqueue_nd_range_kernel
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_kernel
,
cl_uint
work_dim
,
const
size_t
*
global_work_offset
,
const
size_t
*
global_work_size
,
const
size_t
*
local_work_size
);
error
*
_enqueue_read_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_memory_object_holder
,
void
*
buffer
,
size_t
size
,
size_t
device_offset
,
int
is_blocking
);
error
*
_enqueue_read_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_memory_object_holder
,
void
*
buffer
,
size_t
size
,
size_t
device_offset
,
void
**
wait_for
,
uint32_t
num_wait_for
,
int
is_blocking
);
error
*
_enqueue_copy_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_src
,
void
*
ptr_dst
,
ptrdiff_t
byte_count
,
size_t
src_offset
,
size_t
dst_offset
);
error
*
_enqueue_copy_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_src
,
void
*
ptr_dst
,
ptrdiff_t
byte_count
,
size_t
src_offset
,
size_t
dst_offset
,
void
**
wait_for
,
uint32_t
num_wait_for
);
error
*
_enqueue_write_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_memory_object_holder
,
void
*
buffer
,
size_t
size
,
size_t
device_offset
,
int
is_blocking
);
error
*
_enqueue_write_buffer
(
void
**
ptr_event
,
void
*
ptr_command_queue
,
void
*
ptr_memory_object_holder
,
void
*
buffer
,
size_t
size
,
size_t
device_offset
,
void
**
wait_for
,
uint32_t
num_wait_for
,
int
is_blocking
);
void
populate_constants
(
void
(
*
add
)(
const
char
*
,
const
char
*
,
long
value
));
void
populate_constants
(
void
(
*
add
)(
const
char
*
,
const
char
*
,
long
value
));
intptr_t
_int_ptr
(
void
*
,
class_t
);
intptr_t
_int_ptr
(
void
*
,
class_t
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment