Skip to content
Snippets Groups Projects
Commit d9d97fab authored by Yichao Yu's avatar Yichao Yu
Browse files

check cb availability only when needed

parent 9865abe9
No related branches found
No related tags found
No related merge requests found
...@@ -918,17 +918,6 @@ class Kernel(_Common): ...@@ -918,17 +918,6 @@ class Kernel(_Common):
class Event(_Common): class Event(_Common):
_id = 'event' _id = 'event'
@classmethod
def _create(cls, ptr):
self = _Common._create.__func__(cls, ptr)
try:
if (self.context._get_cl_version() >= (1, 1) and
get_cl_header_version() >= (1, 1)):
_lib.event__set_support_cb(ptr, 1);
except:
pass
return self
def __init__(self): def __init__(self):
pass pass
......
...@@ -16,7 +16,7 @@ extern template void print_buf<cl_context>(std::ostream&, const cl_context*, ...@@ -16,7 +16,7 @@ extern template void print_buf<cl_context>(std::ostream&, const cl_context*,
class context : public clobj<cl_context> { class context : public clobj<cl_context> {
public: public:
PYOPENCL_DEF_CL_CLASS(CONTEXT); PYOPENCL_DEF_CL_CLASS(CONTEXT);
void get_version(cl_context ctx, int *major, int *minor); static void get_version(cl_context ctx, int *major, int *minor);
PYOPENCL_INLINE PYOPENCL_INLINE
context(cl_context ctx, bool retain) context(cl_context ctx, bool retain)
: clobj(ctx) : clobj(ctx)
......
...@@ -64,7 +64,13 @@ release_private_use_cb(event *evt) ...@@ -64,7 +64,13 @@ release_private_use_cb(event *evt)
// is already completed. // is already completed.
if (status <= CL_COMPLETE) if (status <= CL_COMPLETE)
return false; return false;
return evt->support_cb; cl_context ctx;
pyopencl_call_guarded(clGetEventInfo, evt, CL_EVENT_CONTEXT,
size_arg(ctx), nullptr);
int major;
int minor;
context::get_version(ctx, &major, &minor);
return (major > 1) || (major >= 1 && minor >= 1);
} catch (const clerror &e) { } catch (const clerror &e) {
cleanup_print_error(e.code(), e.what()); cleanup_print_error(e.code(), e.what());
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment