summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2020-11-07 18:08:09 +0100
committerAndrzej Janik <[email protected]>2020-11-07 18:08:09 +0100
commit7c93997cc9b90886b6371ca3b93e21e7e6ae073d (patch)
treeea290a2f6339935b44aa36cc89b60a09aaae57cd
parent62d14cdffe57134fc89099672ee2954ee413b440 (diff)
downloadZLUDA-7c93997cc9b90886b6371ca3b93e21e7e6ae073d.tar.gz
ZLUDA-7c93997cc9b90886b6371ca3b93e21e7e6ae073d.zip
Append project URL to device name and add few missing CUDA v1 functions
-rw-r--r--notcuda/src/cuda.rs19
-rw-r--r--notcuda/src/impl/device.rs13
2 files changed, 31 insertions, 1 deletions
diff --git a/notcuda/src/cuda.rs b/notcuda/src/cuda.rs
index feeada0..a18ebf9 100644
--- a/notcuda/src/cuda.rs
+++ b/notcuda/src/cuda.rs
@@ -2275,11 +2275,24 @@ pub extern "C" fn cuDevicePrimaryCtxRetain(pctx: *mut CUcontext, dev: CUdevice)
}
#[cfg_attr(not(test), no_mangle)]
+pub extern "C" fn cuDevicePrimaryCtxRelease(dev: CUdevice) -> CUresult {
+ cuDevicePrimaryCtxRelease_v2(dev)
+}
+
+#[cfg_attr(not(test), no_mangle)]
pub extern "C" fn cuDevicePrimaryCtxRelease_v2(dev: CUdevice) -> CUresult {
r#impl::unimplemented()
}
#[cfg_attr(not(test), no_mangle)]
+pub extern "C" fn cuDevicePrimaryCtxSetFlags(
+ dev: CUdevice,
+ flags: ::std::os::raw::c_uint,
+) -> CUresult {
+ cuDevicePrimaryCtxSetFlags_v2(dev, flags)
+}
+
+#[cfg_attr(not(test), no_mangle)]
pub extern "C" fn cuDevicePrimaryCtxSetFlags_v2(
dev: CUdevice,
flags: ::std::os::raw::c_uint,
@@ -2297,6 +2310,12 @@ pub extern "C" fn cuDevicePrimaryCtxGetState(
}
#[cfg_attr(not(test), no_mangle)]
+pub extern "C" fn cuDevicePrimaryCtxReset(dev: CUdevice) -> CUresult {
+ cuDevicePrimaryCtxReset_v2(dev)
+}
+
+
+#[cfg_attr(not(test), no_mangle)]
pub extern "C" fn cuDevicePrimaryCtxReset_v2(dev: CUdevice) -> CUresult {
r#impl::unimplemented()
}
diff --git a/notcuda/src/impl/device.rs b/notcuda/src/impl/device.rs
index db39efd..d4859d3 100644
--- a/notcuda/src/impl/device.rs
+++ b/notcuda/src/impl/device.rs
@@ -11,6 +11,7 @@ use std::{
},
};
+const PROJECT_URL_SUFFIX: &'static str = " [github.com/vosen/notCUDA]";
static mut DEVICES: Option<Vec<Mutex<Device>>> = None;
#[repr(transparent)]
@@ -172,8 +173,18 @@ pub fn get_name(name: *mut c_char, len: i32, dev: Index) -> Result<(), CUresult>
let name_len = (0..256)
.position(|i| unsafe { *name_ptr.add(i) } == 0)
.unwrap_or(256);
- let dst_null_pos = cmp::min((len - 1) as usize, name_len);
+ let mut dst_null_pos = cmp::min((len - 1) as usize, name_len);
unsafe { std::ptr::copy_nonoverlapping(name_ptr, name, dst_null_pos) };
+ if name_len + PROJECT_URL_SUFFIX.len() < (len as usize) {
+ unsafe {
+ std::ptr::copy_nonoverlapping(
+ PROJECT_URL_SUFFIX.as_ptr(),
+ name.add(name_len) as *mut _,
+ PROJECT_URL_SUFFIX.len(),
+ )
+ };
+ dst_null_pos += PROJECT_URL_SUFFIX.len();
+ }
unsafe { *(name.add(dst_null_pos)) = 0 };
Ok(())
}