diff options
author | Andrzej Janik <[email protected]> | 2021-02-22 01:29:03 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-02-22 01:29:03 +0100 |
commit | a906c350f2261dd6b4801870e5642ef56da66268 (patch) | |
tree | de7634e281315cc973da0270d435d9302c64bb72 /level_zero | |
parent | ab690c6491c52178706e389c4edfce2c5f093683 (diff) | |
download | ZLUDA-a906c350f2261dd6b4801870e5642ef56da66268.tar.gz ZLUDA-a906c350f2261dd6b4801870e5642ef56da66268.zip |
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
Diffstat (limited to 'level_zero')
-rw-r--r-- | level_zero/src/ze.rs | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/level_zero/src/ze.rs b/level_zero/src/ze.rs index c56321a..ce675eb 100644 --- a/level_zero/src/ze.rs +++ b/level_zero/src/ze.rs @@ -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,
|