diff options
author | Andrzej Janik <[email protected]> | 2021-08-07 16:53:26 +0200 |
---|---|---|
committer | Andrzej Janik <[email protected]> | 2021-08-07 16:53:26 +0200 |
commit | 44decaf396e70051aa9c49b94d9db84c11b60084 (patch) | |
tree | 6f15e3375988f7c50e2d71cafa848c21cb670c85 | |
parent | 407664600ae443a2fc60da7e0c20dd819c58c8ca (diff) | |
download | ZLUDA-44decaf396e70051aa9c49b94d9db84c11b60084.tar.gz ZLUDA-44decaf396e70051aa9c49b94d9db84c11b60084.zip |
Use raw interop for building programs
-rw-r--r-- | zluda/src/impl/module.rs | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/zluda/src/impl/module.rs b/zluda/src/impl/module.rs index 0c77446..54acb14 100644 --- a/zluda/src/impl/module.rs +++ b/zluda/src/impl/module.rs @@ -135,7 +135,7 @@ impl SpirvModule { } #[cfg(not(target_os = "linux"))] - fn compile_amd1( + fn compile_amd( device_name: &str, spirv_il: &[u8], ptx_lib: Option<(&'static [u8], &'static [u8])>, @@ -276,7 +276,25 @@ impl SpirvModule { let ocl_program = if is_amd { let binary_prog = Self::compile_amd(device_name, byte_il, self.should_link_ptx_impl).unwrap(); - ocl_core::create_program_with_binary(ctx, &[dev], &[&binary_prog[..]])? + let device = dev.as_raw(); + let binary_len = binary_prog.len(); + let binary = binary_prog.as_ptr(); + let mut binary_status = 0; + let mut errcode_ret = 0; + let program = unsafe { + ocl_core::ffi::clCreateProgramWithBinary( + ctx.as_ptr(), + 1, + &device, + &binary_len, + &binary, + &mut binary_status, + &mut errcode_ret, + ) + }; + assert_eq!(binary_status, 0, "clCreateProgramWithBinary"); + assert_eq!(errcode_ret, 0, "clCreateProgramWithBinary"); + unsafe { ocl_core::Program::from_raw_create_ptr(program) } } else { Self::compile_intel( ctx, |