diff --git a/.pick_status.json b/.pick_status.json index 21ed21c742b..d3c63a891b4 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4194,7 +4194,7 @@ "description": "rusticl/program: implement CL_INVALID_PROGRAM_EXECUTABLE check in clGetProgramInfo", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/gallium/frontends/rusticl/api/program.rs b/src/gallium/frontends/rusticl/api/program.rs index 5c4ecc5d61f..37739e8ef18 100644 --- a/src/gallium/frontends/rusticl/api/program.rs +++ b/src/gallium/frontends/rusticl/api/program.rs @@ -25,6 +25,22 @@ use std::sync::Arc; unsafe impl CLInfo for cl_program { fn query(&self, q: cl_program_info, v: CLInfoValue) -> CLResult { let prog = Program::ref_from_raw(*self)?; + + // CL_INVALID_PROGRAM_EXECUTABLE if param_name is CL_PROGRAM_NUM_KERNELS, + // CL_PROGRAM_KERNEL_NAMES, CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT, or + // CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT and a successful program executable has not been + // built for at least one device in the list of devices associated with program. + if matches!( + q, + CL_PROGRAM_NUM_KERNELS + | CL_PROGRAM_KERNEL_NAMES + | CL_PROGRAM_SCOPE_GLOBAL_CTORS_PRESENT + | CL_PROGRAM_SCOPE_GLOBAL_DTORS_PRESENT + ) && !prog.build_info().has_successful_build() + { + return Err(CL_INVALID_PROGRAM_EXECUTABLE); + } + match q { CL_PROGRAM_BINARIES => { let input = v.input::<*mut u8>()?; diff --git a/src/gallium/frontends/rusticl/core/program.rs b/src/gallium/frontends/rusticl/core/program.rs index a493f0e2f55..e1df01ce6cf 100644 --- a/src/gallium/frontends/rusticl/core/program.rs +++ b/src/gallium/frontends/rusticl/core/program.rs @@ -219,6 +219,10 @@ impl ProgramBuild { nir.unwrap() } + + pub fn has_successful_build(&self) -> bool { + self.builds.values().any(|b| b.is_success()) + } } #[derive(Default)] @@ -231,6 +235,12 @@ pub struct ProgramDevBuild { pub kernels: HashMap>, } +impl ProgramDevBuild { + fn is_success(&self) -> bool { + self.status == CL_BUILD_SUCCESS as cl_build_status + } +} + fn prepare_options(options: &str, dev: &Device) -> Vec { let mut options = options.to_owned(); if !options.contains("-cl-std=") {