From 55fbe1abb523fa04cc3017696dfdd8b459dd9edf Mon Sep 17 00:00:00 2001 From: Andrzej Janik Date: Sun, 27 Jun 2021 16:19:04 +0200 Subject: [PATCH] Fix bugs related to replay on Linux --- ptx/src/ptx.lalrpop | 2 +- zluda/src/cuda.rs | 9 +++++++++ zluda/src/impl/os_unix.rs | 5 ++--- zluda_dump/src/os_unix.rs | 5 +++-- zluda_dump/src/replay.py | 2 +- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ptx/src/ptx.lalrpop b/ptx/src/ptx.lalrpop index b697317..18ec4fb 100644 --- a/ptx/src/ptx.lalrpop +++ b/ptx/src/ptx.lalrpop @@ -443,7 +443,7 @@ FnInput: ast::Variable<&'input str> = { } } -pub(crate) FunctionBody: Option>>> = { +FunctionBody: Option>>> = { "{" "}" => { Some(without_none(s)) }, ";" => { None } }; diff --git a/zluda/src/cuda.rs b/zluda/src/cuda.rs index 549a926..16193dd 100644 --- a/zluda/src/cuda.rs +++ b/zluda/src/cuda.rs @@ -2693,6 +2693,15 @@ pub extern "system" fn cuIpcOpenMemHandle( r#impl::unimplemented() } +#[cfg_attr(not(test), no_mangle)] +pub extern "system" fn cuIpcOpenMemHandle_v2( + pdptr: *mut CUdeviceptr, + handle: CUipcMemHandle, + Flags: ::std::os::raw::c_uint, +) -> CUresult { + r#impl::unimplemented() +} + #[cfg_attr(not(test), no_mangle)] pub extern "system" fn cuIpcCloseMemHandle(dptr: CUdeviceptr) -> CUresult { r#impl::unimplemented() diff --git a/zluda/src/impl/os_unix.rs b/zluda/src/impl/os_unix.rs index bf3abcf..90b7011 100644 --- a/zluda/src/impl/os_unix.rs +++ b/zluda/src/impl/os_unix.rs @@ -1,14 +1,13 @@ use std::ffi::c_void; -use std::ptr; pub unsafe fn heap_create() -> *mut c_void { usize::MAX as *mut _ } -pub unsafe fn heap_alloc(heap: *mut c_void, bytes: usize) -> *mut c_void { +pub unsafe fn heap_alloc(_heap: *mut c_void, _bytes: usize) -> *mut c_void { todo!() } -pub unsafe fn heap_free(heap: *mut c_void, alloc: *mut c_void) { +pub unsafe fn heap_free(_heap: *mut c_void, _alloc: *mut c_void) { todo!() } diff --git a/zluda_dump/src/os_unix.rs b/zluda_dump/src/os_unix.rs index 74543dd..affa841 100644 --- a/zluda_dump/src/os_unix.rs +++ b/zluda_dump/src/os_unix.rs @@ -1,9 +1,8 @@ +use crate::cuda::CUuuid; use std::ffi::{c_void, CStr}; const NVCUDA_DEFAULT_PATH: &'static [u8] = b"/usr/lib/x86_64-linux-gnu/libcuda.so.1\0"; -pub fn init() {} - pub unsafe fn load_cuda_library() -> *mut c_void { libc::dlopen( NVCUDA_DEFAULT_PATH.as_ptr() as *const _, @@ -37,6 +36,8 @@ pub fn get_thunk( guid: *const CUuuid, idx: usize, ) -> *const c_void { + use std::mem; + use dynasmrt::{dynasm, DynasmApi}; let mut ops = dynasmrt::x86::Assembler::new().unwrap(); let start = ops.offset(); diff --git a/zluda_dump/src/replay.py b/zluda_dump/src/replay.py index 9c78754..52f250c 100644 --- a/zluda_dump/src/replay.py +++ b/zluda_dump/src/replay.py @@ -60,7 +60,7 @@ def append_debug_buffer(args): def verify_single_dump(input_path, max_block_threads): print(input_path) - kernel_name = path.basename(input_path).split("_", 1)[1] + kernel_name = path.basename(os.path.normpath(input_path)).split("_", 1)[1] with open(path.join(input_path, "launch.txt"), "r") as launch_f: launch_lines = list(map(int, launch_f.readlines())) block = tuple(launch_lines[3:6])