1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
pub use cl3::event::*;
use cl3::types::{cl_event, cl_int, cl_uint, cl_ulong};
use libc::intptr_t;
pub struct Event {
event: cl_event,
}
impl Drop for Event {
fn drop(&mut self) {
release_event(self.event).unwrap();
}
}
impl Event {
pub fn new(event: cl_event) -> Self {
Self { event }
}
pub fn get(&self) -> cl_event {
self.event
}
pub fn wait(&self) -> Result<(), cl_int> {
let events = [self.event];
wait_for_events(&events)
}
pub fn command_execution_status(&self) -> Result<cl_int, cl_int> {
Ok(get_event_info(self.event, EventInfo::CL_EVENT_COMMAND_EXECUTION_STATUS)?.to_int())
}
pub fn command_type(&self) -> Result<cl_uint, cl_int> {
Ok(get_event_info(self.event, EventInfo::CL_EVENT_COMMAND_TYPE)?.to_uint())
}
pub fn reference_count(&self) -> Result<cl_uint, cl_int> {
Ok(get_event_info(self.event, EventInfo::CL_EVENT_REFERENCE_COUNT)?.to_uint())
}
pub fn command_queue(&self) -> Result<intptr_t, cl_int> {
Ok(get_event_info(self.event, EventInfo::CL_EVENT_COMMAND_QUEUE)?.to_ptr())
}
pub fn context(&self) -> Result<intptr_t, cl_int> {
Ok(get_event_info(self.event, EventInfo::CL_EVENT_CONTEXT)?.to_ptr())
}
pub fn profiling_command_queued(&self) -> Result<cl_ulong, cl_int> {
Ok(
get_event_profiling_info(self.event, ProfilingInfo::CL_PROFILING_COMMAND_QUEUED)?
.to_ulong(),
)
}
pub fn profiling_command_submit(&self) -> Result<cl_ulong, cl_int> {
Ok(
get_event_profiling_info(self.event, ProfilingInfo::CL_PROFILING_COMMAND_SUBMIT)?
.to_ulong(),
)
}
pub fn profiling_command_start(&self) -> Result<cl_ulong, cl_int> {
Ok(
get_event_profiling_info(self.event, ProfilingInfo::CL_PROFILING_COMMAND_START)?
.to_ulong(),
)
}
pub fn profiling_command_end(&self) -> Result<cl_ulong, cl_int> {
Ok(
get_event_profiling_info(self.event, ProfilingInfo::CL_PROFILING_COMMAND_END)?
.to_ulong(),
)
}
pub fn profiling_command_complete(&self) -> Result<cl_ulong, cl_int> {
Ok(
get_event_profiling_info(self.event, ProfilingInfo::CL_PROFILING_COMMAND_COMPLETE)?
.to_ulong(),
)
}
}