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
4a422db7
Commit
4a422db7
authored
10 years ago
by
Yichao Yu
Browse files
Options
Downloads
Patches
Plain Diff
nanny_event
parent
a9152419
Loading
Loading
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pyopencl/_cffi.py
+1
-1
1 addition, 1 deletion
pyopencl/_cffi.py
src/c_wrapper/pyhelper.cpp
+6
-2
6 additions, 2 deletions
src/c_wrapper/pyhelper.cpp
src/c_wrapper/wrap_cl.cpp
+45
-3
45 additions, 3 deletions
src/c_wrapper/wrap_cl.cpp
with
52 additions
and
6 deletions
pyopencl/_cffi.py
+
1
−
1
View file @
4a422db7
...
...
@@ -182,6 +182,6 @@ def _get_insert_func(obj):
return
_insert
def
_find_obj
(
_id
):
return
_pyref
[
_id
]
return
_pyref
.
get
(
_id
,
None
)
_lib
.
set_deref
(
_py_deref
)
This diff is collapsed.
Click to expand it.
src/c_wrapper/pyhelper.cpp
+
6
−
2
View file @
4a422db7
...
...
@@ -4,11 +4,15 @@
namespace
pyopencl
{
static
std
::
atomic
<
unsigned
long
>
pyobj_id
=
ATOMIC_VAR_INIT
(
0
ul
);
static
std
::
atomic
<
unsigned
long
>
pyobj_id
=
ATOMIC_VAR_INIT
(
1
ul
);
unsigned
long
next_obj_id
()
{
return
std
::
atomic_fetch_add
(
&
pyobj_id
,
1ul
);
unsigned
long
id
;
do
{
id
=
std
::
atomic_fetch_add
(
&
pyobj_id
,
1ul
);
}
while
(
id
==
0
);
return
id
;
}
static
int
...
...
This diff is collapsed.
Click to expand it.
src/c_wrapper/wrap_cl.cpp
+
45
−
3
View file @
4a422db7
...
...
@@ -743,15 +743,57 @@ public:
}
}
virtual
void
wait
()
const
finished
()
{}
void
wait
()
{
pyopencl_call_guarded
(
clWaitForEvents
,
1
,
&
data
());
finished
();
}
};
class
nanny_event
:
public
event
{
private:
unsigned
int
m_ward
;
public:
nanny_event
(
cl_event
evt
,
bool
retain
,
void
(
*
reffunc
)(
unsigned
long
)
=
0
)
:
event
(
evt
,
retain
),
m_ward
(
0
)
{
if
(
reffunc
)
{
m_ward
=
next_obj_id
();
reffunc
(
m_ward
);
}
}
~
nanny_event
()
{
if
(
m_ward
)
{
wait
();
}
}
unsigned
int
get_ward
()
const
{
return
m_ward
;
}
void
finished
()
{
// No lock needed because multiple release is safe here.
unsigned
long
ward
=
m_ward
;
m_ward
=
0
;
python_deref
(
ward
);
}
};
static
inline
event
*
new_event
(
cl_event
evt
)
new_event
(
cl_event
evt
,
void
(
*
reffunc
)(
unsigned
long
)
=
0
)
{
return
pyopencl_convert_obj
(
event
,
clReleaseEvent
,
evt
);
if
(
reffunc
)
{
return
pyopencl_convert_obj
(
nanny_event
,
clReleaseEvent
,
evt
,
reffunc
);
}
else
{
return
pyopencl_convert_obj
(
event
,
clReleaseEvent
,
evt
);
}
}
// }}}
...
...
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