Make misc fixes (#41)

* Update ze_loader.lib to the newest version
* Export _ptsz/_ptds for which we have a legacy stream implementations
* Stop producing build logs if we are not looking at them anyway
This commit is contained in:
Andrzej Janik 2021-02-22 01:29:03 +01:00 committed by GitHub
commit a906c350f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 124 additions and 8 deletions

View file

@ -270,7 +270,7 @@ impl Module {
};
match ocl_core::get_program_info(&ocl_program, ocl_core::ProgramInfo::Binaries) {
Ok(ocl_core::ProgramInfoResult::Binaries(binaries)) => {
let (module, build_log) = Self::build_native(ctx, d, &binaries[0]);
let (module, build_log) = Self::build_native_logged(ctx, d, &binaries[0]);
(module, Some(build_log))
}
_ => return (Err(sys::ze_result_t::ZE_RESULT_ERROR_UNKNOWN), None),
@ -346,12 +346,21 @@ impl Module {
d: &Device,
bin: &[u8],
opts: Option<&CStr>,
) -> (Result<Self>, BuildLog) {
) -> Result<Self> {
Module::new(ctx, true, d, bin, opts)
}
pub fn build_native(ctx: &mut Context, d: &Device, bin: &[u8]) -> (Result<Self>, BuildLog) {
Module::new(ctx, false, d, bin, None)
pub fn build_spirv_logged(
ctx: &mut Context,
d: &Device,
bin: &[u8],
opts: Option<&CStr>,
) -> (Result<Self>, BuildLog) {
Module::new_logged(ctx, true, d, bin, opts)
}
pub fn build_native_logged(ctx: &mut Context, d: &Device, bin: &[u8]) -> (Result<Self>, BuildLog) {
Module::new_logged(ctx, false, d, bin, None)
}
fn new(
@ -360,6 +369,35 @@ impl Module {
d: &Device,
bin: &[u8],
opts: Option<&CStr>,
) -> Result<Self> {
let desc = sys::ze_module_desc_t {
stype: sys::ze_structure_type_t::ZE_STRUCTURE_TYPE_MODULE_DESC,
pNext: ptr::null(),
format: if spirv {
sys::ze_module_format_t::ZE_MODULE_FORMAT_IL_SPIRV
} else {
sys::ze_module_format_t::ZE_MODULE_FORMAT_NATIVE
},
inputSize: bin.len(),
pInputModule: bin.as_ptr(),
pBuildFlags: opts.map(|s| s.as_ptr() as *const _).unwrap_or(ptr::null()),
pConstants: ptr::null(),
};
let mut result: sys::ze_module_handle_t = ptr::null_mut();
let err = unsafe { sys::zeModuleCreate(ctx.0, d.0, &desc, &mut result, ptr::null_mut()) };
if err != crate::sys::ze_result_t::ZE_RESULT_SUCCESS {
Result::Err(err)
} else {
Ok(Module(result))
}
}
fn new_logged(
ctx: &mut Context,
spirv: bool,
d: &Device,
bin: &[u8],
opts: Option<&CStr>,
) -> (Result<Self>, BuildLog) {
let desc = sys::ze_module_desc_t {
stype: sys::ze_structure_type_t::ZE_STRUCTURE_TYPE_MODULE_DESC,