aboutsummaryrefslogtreecommitdiffhomepage
path: root/level_zero
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2020-07-31 01:48:03 +0200
committerAndrzej Janik <[email protected]>2020-07-31 01:48:03 +0200
commit9ed3dc54f25a8f0a476218d4a973759bd67eb0c6 (patch)
tree7a5c4c8d3c2ed51c70bc0165461576462b1a38ad /level_zero
parent66fa0706a473a4263334a3440402967b9178b177 (diff)
downloadZLUDA-9ed3dc54f25a8f0a476218d4a973759bd67eb0c6.tar.gz
ZLUDA-9ed3dc54f25a8f0a476218d4a973759bd67eb0c6.zip
Refactor unused code, add residency control
Diffstat (limited to 'level_zero')
-rw-r--r--level_zero/src/ze.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/level_zero/src/ze.rs b/level_zero/src/ze.rs
index 5df6323..4f120de 100644
--- a/level_zero/src/ze.rs
+++ b/level_zero/src/ze.rs
@@ -708,10 +708,10 @@ impl<'a> Kernel<'a> {
Self(x, PhantomData)
}
- pub fn new(module: &'a Module, name: &CStr) -> Result<Self> {
+ pub fn new_resident(module: &'a Module, name: &CStr) -> Result<Self> {
let desc = sys::ze_kernel_desc_t {
version: sys::ze_kernel_desc_version_t::ZE_KERNEL_DESC_VERSION_CURRENT,
- flags: sys::ze_kernel_flag_t::ZE_KERNEL_FLAG_NONE,
+ flags: sys::ze_kernel_flag_t::ZE_KERNEL_FLAG_FORCE_RESIDENCY,
pKernelName: name.as_ptr() as *const _,
};
let mut result = ptr::null_mut();
@@ -719,6 +719,21 @@ impl<'a> Kernel<'a> {
Ok(Self(result, PhantomData))
}
+ pub fn set_attribute_bool(
+ &mut self,
+ attr: sys::ze_kernel_attribute_t,
+ value: bool,
+ ) -> Result<()> {
+ let ze_bool: sys::ze_bool_t = if value { 1 } else { 0 };
+ check!(sys::zeKernelSetAttribute(
+ self.0,
+ attr,
+ mem::size_of::<sys::ze_bool_t>() as u32,
+ &ze_bool as *const _ as *const _
+ ));
+ Ok(())
+ }
+
pub fn set_arg_buffer<T: 'a, Buff: Into<BufferPtr<'a, T>>>(
&self,
index: u32,