mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-04-20 08:24:44 +00:00
Append project URL to device name and add few missing CUDA v1 functions
This commit is contained in:
parent
62d14cdffe
commit
7c93997cc9
2 changed files with 31 additions and 1 deletions
|
@ -2274,11 +2274,24 @@ pub extern "C" fn cuDevicePrimaryCtxRetain(pctx: *mut CUcontext, dev: CUdevice)
|
|||
r#impl::device::primary_ctx_retain(pctx.decuda(), dev.decuda()).encuda()
|
||||
}
|
||||
|
||||
#[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,
|
||||
|
@ -2296,6 +2309,12 @@ pub extern "C" fn cuDevicePrimaryCtxGetState(
|
|||
r#impl::device::primary_ctx_get_state(dev.decuda(), flags, active).encuda()
|
||||
}
|
||||
|
||||
#[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()
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue