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
5446584a
Commit
5446584a
authored
10 years ago
by
Yichao Yu
Browse files
Options
Downloads
Patches
Plain Diff
enqueue_*_buffer_rect c functions
parent
2824839a
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/c_wrapper/wrap_cl_core.h
+28
-0
28 additions, 0 deletions
pyopencl/c_wrapper/wrap_cl_core.h
src/c_wrapper/buffer.cpp
+95
-0
95 additions, 0 deletions
src/c_wrapper/buffer.cpp
src/c_wrapper/utils.h
+5
-0
5 additions, 0 deletions
src/c_wrapper/utils.h
with
128 additions
and
0 deletions
pyopencl/c_wrapper/wrap_cl_core.h
+
28
−
0
View file @
5446584a
...
...
@@ -173,6 +173,34 @@ error *enqueue_fill_buffer(clobj_t *_evt, clobj_t _queue, clobj_t _mem,
void
*
pattern
,
size_t
psize
,
size_t
offset
,
size_t
size
,
const
clobj_t
*
_wait_for
,
uint32_t
num_wait_for
);
error
*
enqueue_read_buffer_rect
(
clobj_t
*
evt
,
clobj_t
_queue
,
clobj_t
_mem
,
void
*
buf
,
const
size_t
*
_buf_orig
,
size_t
buf_orig_l
,
const
size_t
*
_host_orig
,
size_t
host_orig_l
,
const
size_t
*
_reg
,
size_t
reg_l
,
const
size_t
*
_buf_pitches
,
size_t
buf_pitches_l
,
const
size_t
*
_host_pitches
,
size_t
host_pitches_l
,
const
clobj_t
*
_wait_for
,
uint32_t
num_wait_for
,
int
block
,
void
*
pyobj
);
error
*
enqueue_write_buffer_rect
(
clobj_t
*
evt
,
clobj_t
_queue
,
clobj_t
_mem
,
void
*
buf
,
const
size_t
*
_buf_orig
,
size_t
buf_orig_l
,
const
size_t
*
_host_orig
,
size_t
host_orig_l
,
const
size_t
*
_reg
,
size_t
reg_l
,
const
size_t
*
_buf_pitches
,
size_t
buf_pitches_l
,
const
size_t
*
_host_pitches
,
size_t
host_pitches_l
,
const
clobj_t
*
_wait_for
,
uint32_t
num_wait_for
,
int
block
,
void
*
pyobj
);
error
*
enqueue_copy_buffer_rect
(
clobj_t
*
evt
,
clobj_t
_queue
,
clobj_t
_src
,
clobj_t
_dst
,
const
size_t
*
_src_orig
,
size_t
src_orig_l
,
const
size_t
*
_dst_orig
,
size_t
dst_orig_l
,
const
size_t
*
_reg
,
size_t
reg_l
,
const
size_t
*
_src_pitches
,
size_t
src_pitches_l
,
const
size_t
*
_dst_pitches
,
size_t
dst_pitches_l
,
const
clobj_t
*
_wait_for
,
uint32_t
num_wait_for
);
// enqueue_*_image*
error
*
enqueue_read_image
(
clobj_t
*
event
,
clobj_t
queue
,
clobj_t
mem
,
const
size_t
*
origin
,
size_t
origin_l
,
...
...
This diff is collapsed.
Click to expand it.
src/c_wrapper/buffer.cpp
+
95
−
0
View file @
5446584a
...
...
@@ -152,6 +152,7 @@ enqueue_fill_buffer(clobj_t *evt, clobj_t _queue, clobj_t _mem, void *pattern,
const
auto
wait_for
=
buf_from_class
<
event
>
(
_wait_for
,
num_wait_for
);
auto
queue
=
static_cast
<
command_queue
*>
(
_queue
);
auto
mem
=
static_cast
<
memory_object
*>
(
_mem
);
// TODO debug print pattern
return
c_handle_error
([
&
]
{
retry_mem_error
([
&
]
{
pyopencl_call_guarded
(
...
...
@@ -160,3 +161,97 @@ enqueue_fill_buffer(clobj_t *evt, clobj_t _queue, clobj_t _mem, void *pattern,
});
});
}
// {{{ rectangular transfers
#if PYOPENCL_CL_VERSION >= 0x1010
error
*
enqueue_read_buffer_rect
(
clobj_t
*
evt
,
clobj_t
_queue
,
clobj_t
_mem
,
void
*
buf
,
const
size_t
*
_buf_orig
,
size_t
buf_orig_l
,
const
size_t
*
_host_orig
,
size_t
host_orig_l
,
const
size_t
*
_reg
,
size_t
reg_l
,
const
size_t
*
_buf_pitches
,
size_t
buf_pitches_l
,
const
size_t
*
_host_pitches
,
size_t
host_pitches_l
,
const
clobj_t
*
_wait_for
,
uint32_t
num_wait_for
,
int
block
,
void
*
pyobj
)
{
const
auto
wait_for
=
buf_from_class
<
event
>
(
_wait_for
,
num_wait_for
);
auto
queue
=
static_cast
<
command_queue
*>
(
_queue
);
auto
mem
=
static_cast
<
memory_object
*>
(
_mem
);
ConstBuffer
<
size_t
,
3
>
buf_orig
(
_buf_orig
,
buf_orig_l
);
ConstBuffer
<
size_t
,
3
>
host_orig
(
_host_orig
,
host_orig_l
);
ConstBuffer
<
size_t
,
3
>
reg
(
_reg
,
reg_l
,
1
);
ConstBuffer
<
size_t
,
2
>
buf_pitches
(
_buf_pitches
,
buf_pitches_l
);
ConstBuffer
<
size_t
,
2
>
host_pitches
(
_host_pitches
,
host_pitches_l
);
return
c_handle_error
([
&
]
{
retry_mem_error
([
&
]
{
pyopencl_call_guarded
(
clEnqueueReadBufferRect
,
queue
,
mem
,
bool
(
block
),
buf_orig
,
host_orig
,
reg
,
buf_pitches
[
0
],
buf_pitches
[
1
],
host_pitches
[
0
],
host_pitches
[
1
],
buf
,
wait_for
,
nanny_event_out
(
evt
,
pyobj
));
});
});
}
error
*
enqueue_write_buffer_rect
(
clobj_t
*
evt
,
clobj_t
_queue
,
clobj_t
_mem
,
void
*
buf
,
const
size_t
*
_buf_orig
,
size_t
buf_orig_l
,
const
size_t
*
_host_orig
,
size_t
host_orig_l
,
const
size_t
*
_reg
,
size_t
reg_l
,
const
size_t
*
_buf_pitches
,
size_t
buf_pitches_l
,
const
size_t
*
_host_pitches
,
size_t
host_pitches_l
,
const
clobj_t
*
_wait_for
,
uint32_t
num_wait_for
,
int
block
,
void
*
pyobj
)
{
const
auto
wait_for
=
buf_from_class
<
event
>
(
_wait_for
,
num_wait_for
);
auto
queue
=
static_cast
<
command_queue
*>
(
_queue
);
auto
mem
=
static_cast
<
memory_object
*>
(
_mem
);
ConstBuffer
<
size_t
,
3
>
buf_orig
(
_buf_orig
,
buf_orig_l
);
ConstBuffer
<
size_t
,
3
>
host_orig
(
_host_orig
,
host_orig_l
);
ConstBuffer
<
size_t
,
3
>
reg
(
_reg
,
reg_l
,
1
);
ConstBuffer
<
size_t
,
2
>
buf_pitches
(
_buf_pitches
,
buf_pitches_l
);
ConstBuffer
<
size_t
,
2
>
host_pitches
(
_host_pitches
,
host_pitches_l
);
return
c_handle_error
([
&
]
{
retry_mem_error
([
&
]
{
pyopencl_call_guarded
(
clEnqueueWriteBufferRect
,
queue
,
mem
,
bool
(
block
),
buf_orig
,
host_orig
,
reg
,
buf_pitches
[
0
],
buf_pitches
[
1
],
host_pitches
[
0
],
host_pitches
[
1
],
buf
,
wait_for
,
nanny_event_out
(
evt
,
pyobj
));
});
});
}
error
*
enqueue_copy_buffer_rect
(
clobj_t
*
evt
,
clobj_t
_queue
,
clobj_t
_src
,
clobj_t
_dst
,
const
size_t
*
_src_orig
,
size_t
src_orig_l
,
const
size_t
*
_dst_orig
,
size_t
dst_orig_l
,
const
size_t
*
_reg
,
size_t
reg_l
,
const
size_t
*
_src_pitches
,
size_t
src_pitches_l
,
const
size_t
*
_dst_pitches
,
size_t
dst_pitches_l
,
const
clobj_t
*
_wait_for
,
uint32_t
num_wait_for
)
{
const
auto
wait_for
=
buf_from_class
<
event
>
(
_wait_for
,
num_wait_for
);
auto
queue
=
static_cast
<
command_queue
*>
(
_queue
);
auto
src
=
static_cast
<
memory_object
*>
(
_src
);
auto
dst
=
static_cast
<
memory_object
*>
(
_dst
);
ConstBuffer
<
size_t
,
3
>
src_orig
(
_src_orig
,
src_orig_l
);
ConstBuffer
<
size_t
,
3
>
dst_orig
(
_dst_orig
,
dst_orig_l
);
ConstBuffer
<
size_t
,
3
>
reg
(
_reg
,
reg_l
,
1
);
ConstBuffer
<
size_t
,
2
>
src_pitches
(
_src_pitches
,
src_pitches_l
);
ConstBuffer
<
size_t
,
2
>
dst_pitches
(
_dst_pitches
,
dst_pitches_l
);
return
c_handle_error
([
&
]
{
retry_mem_error
([
&
]
{
pyopencl_call_guarded
(
clEnqueueCopyBufferRect
,
queue
,
src
,
dst
,
src_orig
,
dst_orig
,
reg
,
src_pitches
[
0
],
src_pitches
[
1
],
dst_pitches
[
0
],
dst_pitches
[
1
],
wait_for
,
event_out
(
evt
));
});
});
}
#endif
// }}}
This diff is collapsed.
Click to expand it.
src/c_wrapper/utils.h
+
5
−
0
View file @
5446584a
...
...
@@ -231,6 +231,11 @@ public:
{
return
m_buf
;
}
PYOPENCL_INLINE
T
&
operator
[](
int
i
)
const
{
return
this
->
get
()[
i
];
}
PYOPENCL_INLINE
size_t
len
()
const
noexcept
{
...
...
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