From 84ac086146b710ed87de20c136b197fe204b2742 Mon Sep 17 00:00:00 2001 From: Andrzej Janik Date: Sat, 21 Nov 2020 00:27:37 +0100 Subject: Fix problems with linking --- level_zero/src/ze.rs | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'level_zero/src/ze.rs') diff --git a/level_zero/src/ze.rs b/level_zero/src/ze.rs index 321e492..253ba4b 100644 --- a/level_zero/src/ze.rs +++ b/level_zero/src/ze.rs @@ -257,9 +257,15 @@ impl Module { ctx: &mut Context, d: &Device, binaries: &[&'a [u8]], + opts: Option<&CStr>, ) -> (Result, Option) { - let ocl_program = match Self::build_link_spirv_impl(binaries) { - Err(_) => return (Err(sys::ze_result_t::ZE_RESULT_ERROR_UNKNOWN), None), + let ocl_program = match Self::build_link_spirv_impl(binaries, opts) { + Err(_) => { + return ( + Err(sys::ze_result_t::ZE_RESULT_ERROR_MODULE_LINK_FAILURE), + None, + ) + } Ok(prog) => prog, }; match ocl_core::get_program_info(&ocl_program, ocl_core::ProgramInfo::Binaries) { @@ -271,7 +277,10 @@ impl Module { } } - fn build_link_spirv_impl<'a>(binaries: &[&'a [u8]]) -> ocl_core::Result { + fn build_link_spirv_impl<'a>( + binaries: &[&'a [u8]], + opts: Option<&CStr>, + ) -> ocl_core::Result { let platforms = ocl_core::get_platform_ids()?; let (platform, device) = platforms .iter() @@ -305,7 +314,22 @@ impl Module { for binary in binaries { programs.push(ocl_core::create_program_with_il(&ocl_ctx, binary, None)?); } - let options = CString::default(); + let options = match opts { + Some(o) => o.to_owned(), + None => CString::default(), + }; + for program in programs.iter() { + ocl_core::compile_program( + program, + Some(&[device]), + &options, + &[], + &[], + None, + None, + None, + )?; + } ocl_core::link_program::( &ocl_ctx, Some(&[device]), -- cgit v1.2.3