mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-04-20 00:14:45 +00:00
Rename everything
This commit is contained in:
parent
0415f873ae
commit
eb7c9aeeee
32 changed files with 76 additions and 60 deletions
|
@ -4,9 +4,9 @@ members = [
|
|||
"level_zero-sys",
|
||||
"level_zero",
|
||||
"spirv_tools-sys",
|
||||
"notcuda",
|
||||
#"notcuda_inject",
|
||||
#"notcuda_redirect",
|
||||
"zluda",
|
||||
#"zluda_inject",
|
||||
#"zluda_redirect",
|
||||
"ptx",
|
||||
]
|
||||
|
||||
|
|
16
ltrace.txt
Normal file
16
ltrace.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
LD_LIBRARY_PATH=/media/vosen/01D3D293C1C33E60/dev/ZLUDA/target/debug_run/ ltrace -x 'cu*@libcuda*' -L /home/vosen/cuda-samples-dbg/bin/x86_64/linux/debug/vectorAdd
|
||||
LD_LIBRARY_PATH=/media/vosen/01D3D293C1C33E60/dev/ZLUDA/target/debug_run/ gdb /home/vosen/cuda-samples-dbg/bin/x86_64/linux/debug/vectorAdd
|
||||
|
||||
/usr/local/cuda-11.0/bin/nvcc vectorAdd2.cu -I../../common/inc/ -lcudart -lcuda -o vectorAdd2 -g -O0
|
||||
|
||||
/usr/local/cuda-11.0/bin/fatbinary --create="vectorAdd_temp.fatbin" -64 "--image3=kind=ptx,sm=52,file=vectorAdd3.ptx" --compress false
|
||||
|
||||
cd /home/vosen/cuda-samples-dbg/0_Simple/vectorAdd
|
||||
/usr/local/cuda-11.0/bin/fatbinary --create vectorAdd_temp.fatbin -64 --image3 kind=ptx,sm=52,file=vectorAdd3.big.ptx --compress true
|
||||
|
||||
LD_LIBRARY_PATH=/media/vosen/01D3D293C1C33E60/dev/ZLUDA/target/debug_run/ ./geekbench_x86_64 --no-upload --compute-list
|
||||
LD_LIBRARY_PATH=/media/vosen/01D3D293C1C33E60/dev/ZLUDA/target/debug_run/ ./geekbench_x86_64 --no-upload --compute CUDA
|
||||
|
||||
LD_LIBRARY_PATH=/media/vosen/01D3D293C1C33E60/dev/ZLUDA/target/debug_run/ ./geekbench_x86_64 --no-upload --compute OpenCL --compute-platform-id 1
|
||||
|
||||
LI_DumpBuffersForKernel=lens_blur_gpu CLI_DumpBuffersBeforeEnqueue=1 CLI_DumpBuffersAfterEnqueue=1 ~/opencl-intercept-layer/build/cliloader/cliloader -c ./geekbench_x86_64 --no-upload --compute OpenCL --compute-platform-id 1 &> log.txt
|
|
@ -1,9 +1,9 @@
|
|||
// Every time this file changes it must te rebuilt:
|
||||
// ocloc -file notcuda_ptx_impl.cl -64 -options "-cl-std=CL2.0 -Dcl_intel_bit_instructions" -out_dir . -device kbl -output_no_suffix -spv_only
|
||||
// ocloc -file zluda_ptx_impl.cl -64 -options "-cl-std=CL2.0 -Dcl_intel_bit_instructions" -out_dir . -device kbl -output_no_suffix -spv_only
|
||||
// Additionally you should strip names:
|
||||
// spirv-opt --strip-debug notcuda_ptx_impl.spv -o notcuda_ptx_impl.spv
|
||||
// spirv-opt --strip-debug zluda_ptx_impl.spv -o zluda_ptx_impl.spv
|
||||
|
||||
#define FUNC(NAME) __notcuda_ptx_impl__ ## NAME
|
||||
#define FUNC(NAME) __zluda_ptx_impl__ ## NAME
|
||||
|
||||
#define atomic_inc(NAME, SUCCESS, FAILURE, SCOPE, SPACE) \
|
||||
uint FUNC(NAME)(SPACE uint* ptr, uint threshold) { \
|
|
@ -10,7 +10,7 @@
|
|||
%67 = OpExtInstImport "OpenCL.std"
|
||||
OpMemoryModel Physical64 OpenCL
|
||||
OpEntryPoint Kernel %12 "assertfail"
|
||||
OpDecorate %1 LinkageAttributes "__notcuda_ptx_impl____assertfail" Import
|
||||
OpDecorate %1 LinkageAttributes "__zluda_ptx_impl____assertfail" Import
|
||||
%void = OpTypeVoid
|
||||
%ulong = OpTypeInt 64 0
|
||||
%_ptr_Function_ulong = OpTypePointer Function %ulong
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
%47 = OpExtInstImport "OpenCL.std"
|
||||
OpMemoryModel Physical64 OpenCL
|
||||
OpEntryPoint Kernel %1 "atom_inc"
|
||||
OpDecorate %38 LinkageAttributes "__notcuda_ptx_impl__atom_relaxed_gpu_generic_inc" Import
|
||||
OpDecorate %42 LinkageAttributes "__notcuda_ptx_impl__atom_relaxed_gpu_global_inc" Import
|
||||
OpDecorate %38 LinkageAttributes "__zluda_ptx_impl__atom_relaxed_gpu_generic_inc" Import
|
||||
OpDecorate %42 LinkageAttributes "__zluda_ptx_impl__atom_relaxed_gpu_global_inc" Import
|
||||
%void = OpTypeVoid
|
||||
%uint = OpTypeInt 32 0
|
||||
%_ptr_Generic_uint = OpTypePointer Generic %uint
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
%40 = OpExtInstImport "OpenCL.std"
|
||||
OpMemoryModel Physical64 OpenCL
|
||||
OpEntryPoint Kernel %1 "bfe"
|
||||
OpDecorate %34 LinkageAttributes "__notcuda_ptx_impl__bfe_u32" Import
|
||||
OpDecorate %34 LinkageAttributes "__zluda_ptx_impl__bfe_u32" Import
|
||||
%void = OpTypeVoid
|
||||
%uint = OpTypeInt 32 0
|
||||
%43 = OpTypeFunction %uint %uint %uint %uint
|
||||
|
|
|
@ -170,9 +170,9 @@ fn test_ptx_assert<'a, T: From<u8> + ze::SafeRepr + Debug + Copy + PartialEq>(
|
|||
let mut errors = Vec::new();
|
||||
let ast = ptx::ModuleParser::new().parse(&mut errors, ptx_text)?;
|
||||
assert!(errors.len() == 0);
|
||||
let notcuda_module = translate::to_spirv_module(ast)?;
|
||||
let zluda_module = translate::to_spirv_module(ast)?;
|
||||
let name = CString::new(name)?;
|
||||
let result = run_spirv(name.as_c_str(), notcuda_module, input, output)
|
||||
let result = run_spirv(name.as_c_str(), zluda_module, input, output)
|
||||
.map_err(|err| DisplayError { err })?;
|
||||
assert_eq!(result.as_slice(), output);
|
||||
Ok(())
|
||||
|
@ -331,7 +331,7 @@ fn test_spvtxt_assert<'a>(
|
|||
} else {
|
||||
Cow::Owned(spirv_module.spirv.disassemble())
|
||||
};
|
||||
if let Ok(dump_path) = env::var("NOTCUDA_TEST_SPIRV_DUMP_DIR") {
|
||||
if let Ok(dump_path) = env::var("ZLUDA_TEST_SPIRV_DUMP_DIR") {
|
||||
let mut path = PathBuf::from(dump_path);
|
||||
if let Ok(()) = fs::create_dir_all(&path) {
|
||||
path.push(spirv_file_name);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
%34 = OpExtInstImport "OpenCL.std"
|
||||
OpMemoryModel Physical64 OpenCL
|
||||
OpEntryPoint Kernel %1 "shl_link_hack"
|
||||
OpDecorate %29 LinkageAttributes "__notcuda_ptx_impl__atom_relaxed_gpu_generic_inc" Import
|
||||
OpDecorate %29 LinkageAttributes "__zluda_ptx_impl__atom_relaxed_gpu_generic_inc" Import
|
||||
%void = OpTypeVoid
|
||||
%uint = OpTypeInt 32 0
|
||||
%_ptr_Generic_uint = OpTypePointer Generic %uint
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::{
|
|||
|
||||
use rspirv::binary::Assemble;
|
||||
|
||||
static NOTCUDA_PTX_IMPL: &'static [u8] = include_bytes!("../lib/notcuda_ptx_impl.spv");
|
||||
static ZLUDA_PTX_IMPL: &'static [u8] = include_bytes!("../lib/zluda_ptx_impl.spv");
|
||||
|
||||
quick_error! {
|
||||
#[derive(Debug)]
|
||||
|
@ -506,7 +506,7 @@ pub fn to_spirv_module<'a>(ast: ast::Module<'a>) -> Result<Module, TranslateErro
|
|||
spirv,
|
||||
kernel_info,
|
||||
should_link_ptx_impl: if must_link_ptx_impl {
|
||||
Some(NOTCUDA_PTX_IMPL)
|
||||
Some(ZLUDA_PTX_IMPL)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
|
@ -1226,7 +1226,7 @@ fn translate_function<'a>(
|
|||
) -> Result<Option<Function<'a>>, TranslateError> {
|
||||
let import_as = match &f.func_directive {
|
||||
ast::MethodDecl::Func(_, "__assertfail", _) => {
|
||||
Some("__notcuda_ptx_impl____assertfail".to_owned())
|
||||
Some("__zluda_ptx_impl____assertfail".to_owned())
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
|
@ -1667,7 +1667,7 @@ fn to_ptx_impl_atomic_call(
|
|||
let scope = ptx_scope_name(details.scope);
|
||||
let space = ptx_space_name(details.space);
|
||||
let fn_name = format!(
|
||||
"__notcuda_ptx_impl__atom_{}_{}_{}_{}",
|
||||
"__zluda_ptx_impl__atom_{}_{}_{}_{}",
|
||||
semantics, scope, space, op
|
||||
);
|
||||
// TODO: extract to a function
|
||||
|
@ -1757,7 +1757,7 @@ fn to_ptx_impl_bfe_call(
|
|||
typ: ast::IntType,
|
||||
arg: ast::Arg4<ExpandedArgParams>,
|
||||
) -> ExpandedStatement {
|
||||
let prefix = "__notcuda_ptx_impl__";
|
||||
let prefix = "__zluda_ptx_impl__";
|
||||
let suffix = match typ {
|
||||
ast::IntType::U32 => "bfe_u32",
|
||||
ast::IntType::U64 => "bfe_u64",
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
[package]
|
||||
name = "notcuda"
|
||||
name = "zluda"
|
||||
version = "0.0.0"
|
||||
authors = ["Andrzej Janik <vosen@vosen.pl>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
name = "notcuda"
|
||||
name = "zluda"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
|
@ -8,7 +8,7 @@ use std::{
|
|||
sync::atomic::{AtomicU32, Ordering},
|
||||
};
|
||||
|
||||
const PROJECT_URL_SUFFIX: &'static str = " [github.com/vosen/notCUDA]";
|
||||
const PROJECT_URL_SUFFIX: &'static str = " [github.com/vosen/ZLUDA]";
|
||||
|
||||
#[repr(transparent)]
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
|
|
@ -1,6 +1,6 @@
|
|||
#![allow(non_snake_case)]
|
||||
|
||||
use crate::cuda as notcuda;
|
||||
use crate::cuda as zluda;
|
||||
use crate::cuda::CUstream;
|
||||
use crate::cuda::CUuuid;
|
||||
use crate::{
|
||||
|
@ -18,8 +18,8 @@ macro_rules! cuda_driver_test {
|
|||
($func:ident) => {
|
||||
paste! {
|
||||
#[test]
|
||||
fn [<$func _notcuda>]() {
|
||||
$func::<crate::r#impl::test::NotCuda>()
|
||||
fn [<$func _zluda>]() {
|
||||
$func::<crate::r#impl::test::Zluda>()
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -46,58 +46,58 @@ pub trait CudaDriverFns {
|
|||
fn cuStreamDestroy_v2(stream: CUstream) -> CUresult;
|
||||
}
|
||||
|
||||
pub struct NotCuda();
|
||||
pub struct Zluda();
|
||||
|
||||
impl CudaDriverFns for NotCuda {
|
||||
impl CudaDriverFns for Zluda {
|
||||
fn cuInit(_flags: c_uint) -> CUresult {
|
||||
notcuda::cuInit(_flags as _)
|
||||
zluda::cuInit(_flags as _)
|
||||
}
|
||||
|
||||
fn cuCtxCreate_v2(pctx: *mut *mut c_void, flags: c_uint, dev: c_int) -> CUresult {
|
||||
notcuda::cuCtxCreate_v2(pctx as *mut _, flags, CUdevice(dev))
|
||||
zluda::cuCtxCreate_v2(pctx as *mut _, flags, CUdevice(dev))
|
||||
}
|
||||
|
||||
fn cuCtxDestroy_v2(ctx: *mut c_void) -> CUresult {
|
||||
notcuda::cuCtxDestroy_v2(ctx as *mut _)
|
||||
zluda::cuCtxDestroy_v2(ctx as *mut _)
|
||||
}
|
||||
|
||||
fn cuCtxPopCurrent_v2(pctx: *mut *mut c_void) -> CUresult {
|
||||
notcuda::cuCtxPopCurrent_v2(pctx as *mut _)
|
||||
zluda::cuCtxPopCurrent_v2(pctx as *mut _)
|
||||
}
|
||||
|
||||
fn cuCtxGetApiVersion(ctx: *mut c_void, version: *mut c_uint) -> CUresult {
|
||||
notcuda::cuCtxGetApiVersion(ctx as *mut _, version)
|
||||
zluda::cuCtxGetApiVersion(ctx as *mut _, version)
|
||||
}
|
||||
|
||||
fn cuCtxGetCurrent(pctx: *mut *mut c_void) -> CUresult {
|
||||
notcuda::cuCtxGetCurrent(pctx as *mut _)
|
||||
zluda::cuCtxGetCurrent(pctx as *mut _)
|
||||
}
|
||||
fn cuMemAlloc_v2(dptr: *mut *mut c_void, bytesize: usize) -> CUresult {
|
||||
notcuda::cuMemAlloc_v2(dptr as *mut _, bytesize)
|
||||
zluda::cuMemAlloc_v2(dptr as *mut _, bytesize)
|
||||
}
|
||||
|
||||
fn cuDeviceGetUuid(uuid: *mut CUuuid, dev: c_int) -> CUresult {
|
||||
notcuda::cuDeviceGetUuid(uuid, CUdevice(dev))
|
||||
zluda::cuDeviceGetUuid(uuid, CUdevice(dev))
|
||||
}
|
||||
|
||||
fn cuDevicePrimaryCtxGetState(dev: c_int, flags: *mut c_uint, active: *mut c_int) -> CUresult {
|
||||
notcuda::cuDevicePrimaryCtxGetState(CUdevice(dev), flags, active)
|
||||
zluda::cuDevicePrimaryCtxGetState(CUdevice(dev), flags, active)
|
||||
}
|
||||
|
||||
fn cuStreamGetCtx(hStream: CUstream, pctx: *mut *mut c_void) -> CUresult {
|
||||
notcuda::cuStreamGetCtx(hStream, pctx as _)
|
||||
zluda::cuStreamGetCtx(hStream, pctx as _)
|
||||
}
|
||||
|
||||
fn cuStreamCreate(stream: *mut CUstream, flags: c_uint) -> CUresult {
|
||||
notcuda::cuStreamCreate(stream, flags)
|
||||
zluda::cuStreamCreate(stream, flags)
|
||||
}
|
||||
|
||||
fn cuMemFree_v2(dptr: *mut c_void) -> CUresult {
|
||||
notcuda::cuMemFree_v2(CUdeviceptr(dptr as _))
|
||||
zluda::cuMemFree_v2(CUdeviceptr(dptr as _))
|
||||
}
|
||||
|
||||
fn cuStreamDestroy_v2(stream: CUstream) -> CUresult {
|
||||
notcuda::cuStreamDestroy_v2(stream)
|
||||
zluda::cuStreamDestroy_v2(stream)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
[package]
|
||||
name = "notcuda_inject"
|
||||
name = "zluda_inject"
|
||||
version = "0.0.0"
|
||||
authors = ["Andrzej Janik <vosen@vosen.pl>"]
|
||||
edition = "2018"
|
||||
|
||||
[[bin]]
|
||||
name = "notcuda"
|
||||
name = "zluda"
|
||||
path = "src/main.rs"
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
notcuda_redirect = { path = "../notcuda_redirect" }
|
||||
zluda_redirect = { path = "../zluda_redirect" }
|
||||
winapi = { version = "0.3", features = ["processthreadsapi", "std", "synchapi"] }
|
||||
detours-sys = "0.1"
|
||||
clap = "2.33"
|
|
@ -20,11 +20,11 @@ use clap::{App, AppSettings, Arg};
|
|||
mod win;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let matches = App::new("notCUDA injector")
|
||||
let matches = App::new("ZLUDA injector")
|
||||
.setting(AppSettings::TrailingVarArg)
|
||||
.arg(
|
||||
Arg::with_name("EXE")
|
||||
.help("Path to the executable to be injected with notCUDA")
|
||||
.help("Path to the executable to be injected with ZLUDA")
|
||||
.required(true),
|
||||
)
|
||||
.arg(
|
||||
|
@ -67,7 +67,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
ptr::null(),
|
||||
&mut startup_info as *mut _,
|
||||
&mut proc_info as *mut _,
|
||||
"notcuda_redirect.dll\0".as_ptr() as *const i8,
|
||||
"zluda_redirect.dll\0".as_ptr() as *const i8,
|
||||
Option::None
|
||||
),
|
||||
|x| x != 0
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "notcuda_redirect"
|
||||
name = "zluda_redirect"
|
||||
version = "0.0.0"
|
||||
authors = ["Andrzej Janik <vosen@vosen.pl>"]
|
||||
edition = "2018"
|
|
@ -19,8 +19,8 @@ use winapi::um::winbase::lstrcmpiW;
|
|||
use winapi::um::winnt::{DLL_PROCESS_ATTACH, DLL_PROCESS_DETACH, HANDLE, LPCWSTR};
|
||||
|
||||
const NVCUDA_PATH: &[u16] = wch_c!(r"C:\WINDOWS\system32\nvcuda.dll");
|
||||
const NOTCUDA_DLL: &[u16] = wch!(r"nvcuda.dll");
|
||||
static mut NOTCUDA_PATH: Option<Vec<u16>> = None;
|
||||
const ZLUDA_DLL: &[u16] = wch!(r"nvcuda.dll");
|
||||
static mut ZLUDA_PATH: Option<Vec<u16>> = None;
|
||||
|
||||
static mut LOAD_LIBRARY_EX: unsafe extern "system" fn(
|
||||
lpLibFileName: LPCWSTR,
|
||||
|
@ -30,13 +30,13 @@ static mut LOAD_LIBRARY_EX: unsafe extern "system" fn(
|
|||
|
||||
#[allow(non_snake_case)]
|
||||
#[no_mangle]
|
||||
unsafe extern "system" fn NotCudaLoadLibraryExW(
|
||||
unsafe extern "system" fn ZludaLoadLibraryExW(
|
||||
lpLibFileName: LPCWSTR,
|
||||
hFile: HANDLE,
|
||||
dwFlags: DWORD,
|
||||
) -> HMODULE {
|
||||
let nvcuda_file_name = if lstrcmpiW(lpLibFileName, NVCUDA_PATH.as_ptr()) == 0 {
|
||||
NOTCUDA_PATH.as_ref().unwrap().as_ptr()
|
||||
ZLUDA_PATH.as_ref().unwrap().as_ptr()
|
||||
} else {
|
||||
lpLibFileName
|
||||
};
|
||||
|
@ -48,15 +48,15 @@ unsafe extern "system" fn NotCudaLoadLibraryExW(
|
|||
unsafe extern "system" fn DllMain(_: *const u8, dwReason: u32, _: *const u8) -> i32 {
|
||||
if dwReason == DLL_PROCESS_ATTACH {
|
||||
DetourRestoreAfterWith();
|
||||
match get_notcuda_dll_path() {
|
||||
Some((path, len)) => set_notcuda_dll_path(path, len),
|
||||
match get_zluda_dll_path() {
|
||||
Some((path, len)) => set_zluda_dll_path(path, len),
|
||||
None => return FALSE,
|
||||
}
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourAttach(
|
||||
std::mem::transmute(&mut LOAD_LIBRARY_EX),
|
||||
NotCudaLoadLibraryExW as *mut _,
|
||||
ZludaLoadLibraryExW as *mut _,
|
||||
);
|
||||
DetourTransactionCommit();
|
||||
} else if dwReason == DLL_PROCESS_DETACH {
|
||||
|
@ -64,14 +64,14 @@ unsafe extern "system" fn DllMain(_: *const u8, dwReason: u32, _: *const u8) ->
|
|||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourDetach(
|
||||
std::mem::transmute(&mut LOAD_LIBRARY_EX),
|
||||
NotCudaLoadLibraryExW as *mut _,
|
||||
ZludaLoadLibraryExW as *mut _,
|
||||
);
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
TRUE
|
||||
}
|
||||
|
||||
fn get_notcuda_dll_path() -> Option<(*const u16, usize)> {
|
||||
fn get_zluda_dll_path() -> Option<(*const u16, usize)> {
|
||||
let guid = guid! {"C225FC0C-00D7-40B8-935A-7E342A9344C1"};
|
||||
let mut module = std::ptr::null_mut();
|
||||
loop {
|
||||
|
@ -90,16 +90,16 @@ fn get_notcuda_dll_path() -> Option<(*const u16, usize)> {
|
|||
None
|
||||
}
|
||||
|
||||
unsafe fn set_notcuda_dll_path(path: *const u16, len: usize) {
|
||||
unsafe fn set_zluda_dll_path(path: *const u16, len: usize) {
|
||||
let len = len as usize;
|
||||
let mut result = Vec::<u16>::with_capacity(len + NOTCUDA_DLL.len() + 2);
|
||||
let mut result = Vec::<u16>::with_capacity(len + ZLUDA_DLL.len() + 2);
|
||||
for i in 0..len {
|
||||
result.push(*path.add(i));
|
||||
}
|
||||
result.push(0x5c); // \
|
||||
for c in NOTCUDA_DLL.iter().copied() {
|
||||
for c in ZLUDA_DLL.iter().copied() {
|
||||
result.push(c);
|
||||
}
|
||||
result.push(0);
|
||||
NOTCUDA_PATH = Some(result);
|
||||
ZLUDA_PATH = Some(result);
|
||||
}
|
Loading…
Add table
Reference in a new issue