mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
rusticl/event: wrong but non crashing impl of clWaitForEvents
Signed-off-by: Karol Herbst <kherbst@redhat.com> Acked-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15439>
This commit is contained in:
parent
3baf270316
commit
ebfffa1dae
2 changed files with 36 additions and 3 deletions
|
|
@ -7,6 +7,7 @@ use crate::core::queue::*;
|
|||
|
||||
use self::rusticl_opencl_gen::*;
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::ptr;
|
||||
use std::sync::Arc;
|
||||
|
||||
|
|
@ -40,6 +41,39 @@ pub fn create_user_event(context: cl_context) -> CLResult<cl_event> {
|
|||
Ok(cl_event::from_arc(Event::new_user(c)))
|
||||
}
|
||||
|
||||
pub fn wait_for_events(num_events: cl_uint, event_list: *const cl_event) -> CLResult<()> {
|
||||
let evs = cl_event::get_arc_vec_from_arr(event_list, num_events)?;
|
||||
|
||||
// CL_INVALID_VALUE if num_events is zero or event_list is NULL.
|
||||
if evs.is_empty() {
|
||||
return Err(CL_INVALID_VALUE);
|
||||
}
|
||||
|
||||
// CL_INVALID_CONTEXT if events specified in event_list do not belong to the same context.
|
||||
let contexts: HashSet<_> = evs.iter().map(|e| &e.context).collect();
|
||||
if contexts.len() != 1 {
|
||||
return Err(CL_INVALID_CONTEXT);
|
||||
}
|
||||
|
||||
// TODO better impl
|
||||
let mut err = false;
|
||||
for e in evs {
|
||||
if let Some(q) = &e.queue {
|
||||
q.flush(true)?;
|
||||
}
|
||||
|
||||
err |= e.status() < 0;
|
||||
}
|
||||
|
||||
// CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST if the execution status of any of the events
|
||||
// in event_list is a negative integer value.
|
||||
if err {
|
||||
return Err(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_and_queue(
|
||||
q: Arc<Queue>,
|
||||
cmd_type: cl_command_type,
|
||||
|
|
|
|||
|
|
@ -824,9 +824,8 @@ extern "C" fn cl_get_kernel_work_group_info(
|
|||
))
|
||||
}
|
||||
|
||||
extern "C" fn cl_wait_for_events(_num_events: cl_uint, _event_list: *const cl_event) -> cl_int {
|
||||
println!("cl_wait_for_events not implemented");
|
||||
CL_OUT_OF_HOST_MEMORY
|
||||
extern "C" fn cl_wait_for_events(num_events: cl_uint, event_list: *const cl_event) -> cl_int {
|
||||
match_err!(wait_for_events(num_events, event_list))
|
||||
}
|
||||
|
||||
extern "C" fn cl_get_event_info(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue