Rename zluda_dump to zluda_trace (#456)

* Rename zluda_dump to zluda_trace

* Minor naming fixes
This commit is contained in:
Andrzej Janik
2025-07-31 17:07:03 +02:00
committed by GitHub
parent 4d163a4d9b
commit 49aabffdcc
29 changed files with 234 additions and 234 deletions

228
Cargo.lock generated
View File

@ -1842,119 +1842,6 @@ dependencies = [
"cuda_types", "cuda_types",
] ]
[[package]]
name = "zluda_dump"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"detours-sys",
"dynasm",
"dynasmrt",
"format",
"goblin",
"libc",
"parking_lot",
"paste",
"ptx",
"ptx_parser",
"regex",
"rustc-hash 1.1.0",
"unwrap_or",
"wchar",
"winapi",
"zluda_dump_common",
"zstd-safe",
]
[[package]]
name = "zluda_dump_blas"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"format",
"libloading",
"paste",
"unwrap_or",
"zluda_dump_common",
]
[[package]]
name = "zluda_dump_blaslt"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"format",
"libloading",
"paste",
"unwrap_or",
"zluda_dump_common",
]
[[package]]
name = "zluda_dump_common"
version = "0.1.0"
dependencies = [
"cglue",
"cuda_types",
"dark_api",
"format",
"libloading",
]
[[package]]
name = "zluda_dump_dnn"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"format",
"libloading",
"paste",
"unwrap_or",
"zluda_dump_common",
]
[[package]]
name = "zluda_dump_fft"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"format",
"libloading",
"paste",
"unwrap_or",
"zluda_dump_common",
]
[[package]]
name = "zluda_dump_sparse"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"format",
"libloading",
"paste",
"unwrap_or",
"zluda_dump_common",
]
[[package]] [[package]]
name = "zluda_fft" name = "zluda_fft"
version = "0.0.0" version = "0.0.0"
@ -1971,9 +1858,9 @@ dependencies = [
"detours-sys", "detours-sys",
"tempfile", "tempfile",
"winapi", "winapi",
"zluda_dump",
"zluda_ml", "zluda_ml",
"zluda_redirect", "zluda_redirect",
"zluda_trace",
] ]
[[package]] [[package]]
@ -2001,6 +1888,119 @@ dependencies = [
"cuda_types", "cuda_types",
] ]
[[package]]
name = "zluda_trace"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"detours-sys",
"dynasm",
"dynasmrt",
"format",
"goblin",
"libc",
"parking_lot",
"paste",
"ptx",
"ptx_parser",
"regex",
"rustc-hash 1.1.0",
"unwrap_or",
"wchar",
"winapi",
"zluda_trace_common",
"zstd-safe",
]
[[package]]
name = "zluda_trace_blas"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"format",
"libloading",
"paste",
"unwrap_or",
"zluda_trace_common",
]
[[package]]
name = "zluda_trace_blaslt"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"format",
"libloading",
"paste",
"unwrap_or",
"zluda_trace_common",
]
[[package]]
name = "zluda_trace_common"
version = "0.1.0"
dependencies = [
"cglue",
"cuda_types",
"dark_api",
"format",
"libloading",
]
[[package]]
name = "zluda_trace_dnn"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"format",
"libloading",
"paste",
"unwrap_or",
"zluda_trace_common",
]
[[package]]
name = "zluda_trace_fft"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"format",
"libloading",
"paste",
"unwrap_or",
"zluda_trace_common",
]
[[package]]
name = "zluda_trace_sparse"
version = "0.0.0"
dependencies = [
"cglue",
"cuda_macros",
"cuda_types",
"dark_api",
"format",
"libloading",
"paste",
"unwrap_or",
"zluda_trace_common",
]
[[package]] [[package]]
name = "zopfli" name = "zopfli"
version = "0.8.1" version = "0.8.1"

View File

@ -23,13 +23,13 @@ members = [
"zluda_blaslt", "zluda_blaslt",
"zluda_common", "zluda_common",
"zluda_dnn", "zluda_dnn",
"zluda_dump", "zluda_trace",
"zluda_dump_blas", "zluda_trace_blas",
"zluda_dump_blaslt", "zluda_trace_blaslt",
"zluda_dump_common", "zluda_trace_common",
"zluda_dump_dnn", "zluda_trace_dnn",
"zluda_dump_fft", "zluda_trace_fft",
"zluda_dump_sparse", "zluda_trace_sparse",
"zluda_fft", "zluda_fft",
"zluda_inject", "zluda_inject",
"zluda_ml", "zluda_ml",

View File

@ -332,10 +332,10 @@ dark_api! {
} }
} }
// Purely for internal use by ZLUDA dump // Purely for internal use by ZLUDA trace
dark_api! { dark_api! {
zluda_dump; zluda_trace;
"{0B7A5827-AF98-46AB-A951-22D19BDF5C08}" => ZLUDA_DUMP_INTERNAL[1] { "{0B7A5827-AF98-46AB-A951-22D19BDF5C08}" => ZLUDA_TRACE_INTERNAL[1] {
#[noformat] #[noformat]
[0] = logged_call( [0] = logged_call(
fn_name: cglue::slice::CSliceRef<'static, u8>, fn_name: cglue::slice::CSliceRef<'static, u8>,

View File

@ -385,7 +385,7 @@ pub(crate) unsafe fn get_proc_address_v2(
flags: cuda_types::cuda::cuuint64_t, flags: cuda_types::cuda::cuuint64_t,
symbol_status: Option<&mut cuda_types::cuda::CUdriverProcAddressQueryResult>, symbol_status: Option<&mut cuda_types::cuda::CUdriverProcAddressQueryResult>,
) -> CUresult { ) -> CUresult {
// This implementation is mostly the same as cuGetProcAddress_v2 in zluda_dump. We may want to factor out the duplication at some point. // This implementation is mostly the same as cuGetProcAddress_v2 in zluda_trace. We may want to factor out the duplication at some point.
fn raw_match(name: &[u8], flag: u64, version: i32) -> *mut ::core::ffi::c_void { fn raw_match(name: &[u8], flag: u64, version: i32) -> *mut ::core::ffi::c_void {
use crate::*; use crate::*;
include!("../../../zluda_bindgen/src/process_table.rs") include!("../../../zluda_bindgen/src/process_table.rs")

View File

@ -1,4 +1,4 @@
// TODO: remove duplication with zluda_dump // TODO: remove duplication with zluda_trace
#[link(name = "pthread")] #[link(name = "pthread")]
unsafe extern "C" { unsafe extern "C" {
fn pthread_self() -> std::os::unix::thread::RawPthread; fn pthread_self() -> std::os::unix::thread::RawPthread;

View File

@ -1,4 +1,4 @@
// TODO: remove duplication with zluda_dump // TODO: remove duplication with zluda_trace
#[link(name = "kernel32")] #[link(name = "kernel32")]
unsafe extern "system" { unsafe extern "system" {
fn GetCurrentThreadId() -> u32; fn GetCurrentThreadId() -> u32;

View File

@ -1,26 +0,0 @@
[package]
name = "zluda_dump_sparse"
version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2021"
[lib]
name = "zluda_dump_sparse"
crate-type = ["cdylib"]
[dependencies]
format = { path = "../format" }
dark_api = { path = "../dark_api" }
cuda_macros = { path = "../cuda_macros" }
cuda_types = { path = "../cuda_types" }
zluda_dump_common = { path = "../zluda_dump_common" }
libloading = "0.8"
paste = "1.0"
unwrap_or = "1.0.1"
cglue = "0.3.5"
[package.metadata.zluda]
linux_symlinks = [
"dump/libcusparse.so",
"dump/libcusparse.so.12"
]

View File

@ -17,7 +17,7 @@ detours-sys = { path = "../detours-sys" }
[dev-dependencies] [dev-dependencies]
# all of those are used in integration tests # all of those are used in integration tests
zluda_redirect = { path = "../zluda_redirect" } zluda_redirect = { path = "../zluda_redirect" }
zluda_dump = { path = "../zluda_dump" } zluda_trace = { path = "../zluda_trace" }
zluda_ml = { path = "../zluda_ml" } zluda_ml = { path = "../zluda_ml" }
[package.metadata.zluda] [package.metadata.zluda]

View File

@ -3,49 +3,49 @@ use std::{env, io, path::PathBuf, process::Command};
#[test] #[test]
fn direct_cuinit() -> io::Result<()> { fn direct_cuinit() -> io::Result<()> {
run_process_and_check_for_zluda_dump("direct_cuinit") run_process_and_check_for_zluda_trace("direct_cuinit")
} }
#[test] #[test]
fn do_cuinit_early() -> io::Result<()> { fn do_cuinit_early() -> io::Result<()> {
run_process_and_check_for_zluda_dump("do_cuinit_early") run_process_and_check_for_zluda_trace("do_cuinit_early")
} }
#[test] #[test]
fn do_cuinit_late() -> io::Result<()> { fn do_cuinit_late() -> io::Result<()> {
run_process_and_check_for_zluda_dump("do_cuinit_late") run_process_and_check_for_zluda_trace("do_cuinit_late")
} }
#[test] #[test]
fn do_cuinit_late_clr() -> io::Result<()> { fn do_cuinit_late_clr() -> io::Result<()> {
run_process_and_check_for_zluda_dump("do_cuinit_late_clr") run_process_and_check_for_zluda_trace("do_cuinit_late_clr")
} }
#[test] #[test]
fn indirect_cuinit() -> io::Result<()> { fn indirect_cuinit() -> io::Result<()> {
run_process_and_check_for_zluda_dump("indirect_cuinit") run_process_and_check_for_zluda_trace("indirect_cuinit")
} }
#[test] #[test]
fn subprocess() -> io::Result<()> { fn subprocess() -> io::Result<()> {
run_process_and_check_for_zluda_dump("subprocess") run_process_and_check_for_zluda_trace("subprocess")
} }
fn run_process_and_check_for_zluda_dump(name: &'static str) -> io::Result<()> { fn run_process_and_check_for_zluda_trace(name: &'static str) -> io::Result<()> {
let zluda_with_exe = PathBuf::from(env!("CARGO_BIN_EXE_zluda_with")); let zluda_with_exe = PathBuf::from(env!("CARGO_BIN_EXE_zluda_with"));
let mut zluda_dump_dll = zluda_with_exe.parent().unwrap().to_path_buf(); let mut zluda_trace_dll = zluda_with_exe.parent().unwrap().to_path_buf();
zluda_dump_dll.push("zluda_dump.dll"); zluda_trace_dll.push("zluda_trace.dll");
let helpers_dir = env!("HELPERS_OUT_DIR"); let helpers_dir = env!("HELPERS_OUT_DIR");
let exe_under_test = format!("{}{}{}.exe", helpers_dir, std::path::MAIN_SEPARATOR, name); let exe_under_test = format!("{}{}{}.exe", helpers_dir, std::path::MAIN_SEPARATOR, name);
let mut test_cmd = Command::new(&zluda_with_exe); let mut test_cmd = Command::new(&zluda_with_exe);
let test_cmd = test_cmd let test_cmd = test_cmd
.arg("--nvcuda") .arg("--nvcuda")
.arg(&zluda_dump_dll) .arg(&zluda_trace_dll)
.arg("--") .arg("--")
.arg(&exe_under_test); .arg(&exe_under_test);
let test_output = test_cmd.output()?; let test_output = test_cmd.output()?;
assert!(test_output.status.success()); assert!(test_output.status.success());
let stderr_text = String::from_utf8(test_output.stderr).unwrap(); let stderr_text = String::from_utf8(test_output.stderr).unwrap();
assert!(stderr_text.contains("ZLUDA_DUMP")); assert!(stderr_text.contains("ZLUDA_TRACE"));
Ok(()) Ok(())
} }

View File

@ -16,6 +16,6 @@ cuda_types = { path = "../cuda_types" }
linux_symlinks = [ linux_symlinks = [
"libnvidia-ml.so", "libnvidia-ml.so",
"libnvidia-ml.so.1", "libnvidia-ml.so.1",
"dump/libnvidia-ml.so", "trace/libnvidia-ml.so",
"dump/libnvidia-ml.so.1", "trace/libnvidia-ml.so.1",
] ]

View File

@ -1,17 +1,17 @@
[package] [package]
name = "zluda_dump" name = "zluda_trace"
version = "0.0.0" version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"] authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2021" edition = "2021"
[lib] [lib]
name = "zluda_dump" name = "zluda_trace"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
ptx = { path = "../ptx" } ptx = { path = "../ptx" }
ptx_parser = { path = "../ptx_parser" } ptx_parser = { path = "../ptx_parser" }
zluda_dump_common = { path = "../zluda_dump_common" } zluda_trace_common = { path = "../zluda_trace_common" }
format = { path = "../format" } format = { path = "../format" }
dark_api = { path = "../dark_api" } dark_api = { path = "../dark_api" }
regex = "1.4" regex = "1.4"
@ -38,8 +38,8 @@ libc = "0.2"
[package.metadata.zluda] [package.metadata.zluda]
linux_symlinks = [ linux_symlinks = [
"dump/libcuda.so", "trace/libcuda.so",
"dump/libcuda.so.1", "trace/libcuda.so.1",
"dump_nvidia/libcuda.so", "trace_nvidia/libcuda.so",
"dump_nvidia/libcuda.so.1", "trace_nvidia/libcuda.so.1",
] ]

View File

@ -141,11 +141,11 @@ macro_rules! override_fn_full {
} }
} }
static INTERNAL_TABLE: ::dark_api::zluda_dump::CudaDarkApiGlobalTable = static INTERNAL_TABLE: ::dark_api::zluda_trace::CudaDarkApiGlobalTable =
::dark_api::zluda_dump::CudaDarkApiGlobalTable::new::<InternalTableImpl>(); ::dark_api::zluda_trace::CudaDarkApiGlobalTable::new::<InternalTableImpl>();
struct InternalTableImpl; struct InternalTableImpl;
impl ::dark_api::zluda_dump::CudaDarkApi for InternalTableImpl { impl ::dark_api::zluda_trace::CudaDarkApi for InternalTableImpl {
unsafe extern "system" fn logged_call( unsafe extern "system" fn logged_call(
fn_name: cglue::slice::CSliceRef<'static, u8>, fn_name: cglue::slice::CSliceRef<'static, u8>,
args: ::dark_api::FnFfiRef<::dark_api::ByteVecFfi>, args: ::dark_api::FnFfiRef<::dark_api::ByteVecFfi>,
@ -166,7 +166,7 @@ impl ::dark_api::zluda_dump::CudaDarkApi for InternalTableImpl {
} }
static EXPORT_TABLE: ::dark_api::cuda::CudaDarkApiGlobalTable = static EXPORT_TABLE: ::dark_api::cuda::CudaDarkApiGlobalTable =
::dark_api::cuda::CudaDarkApiGlobalTable::new::<DarkApiDump>(); ::dark_api::cuda::CudaDarkApiGlobalTable::new::<DarkApiTrace>();
macro_rules! dark_api_fn_redirect_log { macro_rules! dark_api_fn_redirect_log {
( (
@ -178,7 +178,7 @@ macro_rules! dark_api_fn_redirect_log {
unsafe extern "system" fn $fn_( unsafe extern "system" fn $fn_(
$($arg_id: $arg_type),* $($arg_id: $arg_type),*
) -> $ret_type { ) -> $ret_type {
use zluda_dump_common::ReprUsize; use zluda_trace_common::ReprUsize;
let original_fn = { let original_fn = {
let dark_api = DARK_API_STATE.lock().unwrap(); let dark_api = DARK_API_STATE.lock().unwrap();
let (original_table, _) = dark_api let (original_table, _) = dark_api
@ -233,7 +233,7 @@ macro_rules! dark_api_fn_redirect_log_post {
unsafe extern "system" fn $fn_( unsafe extern "system" fn $fn_(
$($arg_id: $arg_type),* $($arg_id: $arg_type),*
) -> $ret_type { ) -> $ret_type {
use zluda_dump_common::ReprUsize; use zluda_trace_common::ReprUsize;
let original_fn = { let original_fn = {
let dark_api = DARK_API_STATE.lock().unwrap(); let dark_api = DARK_API_STATE.lock().unwrap();
let (original_table, _) = dark_api let (original_table, _) = dark_api
@ -278,9 +278,9 @@ macro_rules! dark_api_fn_redirect_log_post {
}; };
} }
struct DarkApiDump; struct DarkApiTrace;
impl DarkApiDump { impl DarkApiTrace {
fn get_module_from_cubin_post( fn get_module_from_cubin_post(
module: *mut cuda_types::cuda::CUmodule, module: *mut cuda_types::cuda::CUmodule,
fatbinc_wrapper: *const cuda_types::dark_api::FatbincWrapper, fatbinc_wrapper: *const cuda_types::dark_api::FatbincWrapper,
@ -375,7 +375,7 @@ impl DarkApiDump {
} }
} }
impl ::dark_api::cuda::CudaDarkApi for DarkApiDump { impl ::dark_api::cuda::CudaDarkApi for DarkApiTrace {
dark_api_fn_redirect_log! { dark_api_fn_redirect_log! {
CUDART_INTERFACE { CUDART_INTERFACE {
[2] = cudart_interface_fn2( [2] = cudart_interface_fn2(
@ -900,7 +900,7 @@ impl GlobalState2 {
// This function is at the core of the logging mechanism. // This function is at the core of the logging mechanism.
// How it works: // How it works:
// When user calls a CUDA function, we want to log the call and its arguments. So in a dump // When user calls a CUDA function, we want to log the call and its arguments. So in a trace
// library every public CUDA function will call this function like so: // library every public CUDA function will call this function like so:
// cuMemAlloc_v2(args) -> under_lock("cuMemAlloc_v2", Some(args), ...) // cuMemAlloc_v2(args) -> under_lock("cuMemAlloc_v2", Some(args), ...)
// That sounds simple enough, but there are some exotic requirements we have to fulfill: // That sounds simple enough, but there are some exotic requirements we have to fulfill:
@ -908,11 +908,11 @@ impl GlobalState2 {
// functions. We need to be able to log all of these calls hierarchically // functions. We need to be able to log all of these calls hierarchically
// * Thread-safety: CUDA functions can be called from multiple threads // * Thread-safety: CUDA functions can be called from multiple threads
// * Error-handling: If we fail internally for whatever reason (e.g. we can't load the CUDA // * Error-handling: If we fail internally for whatever reason (e.g. we can't load the CUDA
// library, the dump directory is not writable, etc.), we need to log this // library, the trace directory is not writable, etc.), we need to log this
// error no matter what // error no matter what
// Because of that the function is split into three phases: // Because of that the function is split into three phases:
// * Pre-call: // * Pre-call:
// We need to load the settings (location of the CUDA libary, dump directory, etc.), write the // We need to load the settings (location of the CUDA libary, trace directory, etc.), write the
// function name and its arguments to logging buffer. This whole phase is covered by a drop // function name and its arguments to logging buffer. This whole phase is covered by a drop
// guard which will flush the log buffer in case of panic // guard which will flush the log buffer in case of panic
// * Call: // * Call:
@ -1281,15 +1281,15 @@ impl Settings {
} }
fn read_and_init_dump_dir() -> Result<Option<PathBuf>, Box<dyn Error>> { fn read_and_init_dump_dir() -> Result<Option<PathBuf>, Box<dyn Error>> {
let dir = match env::var("ZLUDA_DUMP_DIR") { let dir = match env::var("ZLUDA_LOG_DIR") {
Ok(dir) => dir, Ok(dir) => dir,
Err(env::VarError::NotPresent) => return Ok(None), Err(env::VarError::NotPresent) => return Ok(None),
Err(err) => return Err(Box::new(err) as Box<_>), Err(err) => return Err(Box::new(err) as Box<_>),
}; };
Ok(Some(Self::create_dump_directory(dir)?)) Ok(Some(Self::create_trace_directory(dir)?))
} }
fn create_dump_directory(dir: String) -> io::Result<PathBuf> { fn create_trace_directory(dir: String) -> io::Result<PathBuf> {
let mut main_dir = PathBuf::from(dir); let mut main_dir = PathBuf::from(dir);
let current_exe = env::current_exe()?; let current_exe = env::current_exe()?;
let file_name_base = current_exe.file_name().unwrap().to_string_lossy(); let file_name_base = current_exe.file_name().unwrap().to_string_lossy();

View File

@ -14,7 +14,7 @@ use std::io::Write;
use std::path::PathBuf; use std::path::PathBuf;
use std::str::Utf8Error; use std::str::Utf8Error;
const LOG_PREFIX: &[u8] = b"[ZLUDA_DUMP] "; const LOG_PREFIX: &[u8] = b"[ZLUDA_TRACE] ";
pub(crate) struct Writer { pub(crate) struct Writer {
// Fallible emitter is an optional emitter to the file system, we might lack // Fallible emitter is an optional emitter to the file system, we might lack
@ -346,7 +346,7 @@ impl Display for ErrorEntry {
ErrorEntry::CreatedDumpDirectory(dir) => { ErrorEntry::CreatedDumpDirectory(dir) => {
write!( write!(
f, f,
"Created dump directory {} ", "Created trace directory {} ",
dir.as_os_str().to_string_lossy() dir.as_os_str().to_string_lossy()
) )
} }

View File

@ -20,12 +20,12 @@ pub unsafe fn get_proc_address(handle: *mut c_void, func: &CStr) -> *mut c_void
macro_rules! os_log { macro_rules! os_log {
($format:tt) => { ($format:tt) => {
{ {
eprintln!("[ZLUDA_DUMP] {}", format!($format)); eprintln!("[ZLUDA_TRACE] {}", format!($format));
} }
}; };
($format:tt, $($obj: expr),+) => { ($format:tt, $($obj: expr),+) => {
{ {
eprintln!("[ZLUDA_DUMP] {}", format!($format, $($obj,)+)); eprintln!("[ZLUDA_TRACE] {}", format!($format, $($obj,)+));
} }
}; };
} }

View File

@ -104,10 +104,10 @@ macro_rules! os_log {
pub fn __log_impl(s: String) { pub fn __log_impl(s: String) {
let log_to_stderr = std::io::stderr().as_raw_handle() != ptr::null_mut(); let log_to_stderr = std::io::stderr().as_raw_handle() != ptr::null_mut();
if log_to_stderr { if log_to_stderr {
eprintln!("[ZLUDA_DUMP] {}", s); eprintln!("[ZLUDA_TRACE] {}", s);
} else { } else {
let mut win_str = String::with_capacity("[ZLUDA_DUMP] ".len() + s.len() + 2); let mut win_str = String::with_capacity("[ZLUDA_TRACE] ".len() + s.len() + 2);
win_str.push_str("[ZLUDA_DUMP] "); win_str.push_str("[ZLUDA_TRACE] ");
win_str.push_str(&s); win_str.push_str(&s);
win_str.push_str("\n\0"); win_str.push_str("\n\0");
unsafe { OutputDebugStringA(win_str.as_ptr() as *const _) }; unsafe { OutputDebugStringA(win_str.as_ptr() as *const _) };

View File

@ -198,7 +198,7 @@ impl StateTracker {
} }
} }
// This structs writes out information about CUDA execution to the dump dir // This structs writes out information about CUDA execution to the trace dir
struct DumpWriter { struct DumpWriter {
dump_dir: Option<PathBuf>, dump_dir: Option<PathBuf>,
} }

View File

@ -1,11 +1,11 @@
[package] [package]
name = "zluda_dump_fft" name = "zluda_trace_blas"
version = "0.0.0" version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"] authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2021" edition = "2021"
[lib] [lib]
name = "zluda_dump_fft" name = "zluda_trace_blas"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
@ -13,7 +13,7 @@ format = { path = "../format" }
dark_api = { path = "../dark_api" } dark_api = { path = "../dark_api" }
cuda_macros = { path = "../cuda_macros" } cuda_macros = { path = "../cuda_macros" }
cuda_types = { path = "../cuda_types" } cuda_types = { path = "../cuda_types" }
zluda_dump_common = { path = "../zluda_dump_common" } zluda_trace_common = { path = "../zluda_trace_common" }
libloading = "0.8" libloading = "0.8"
paste = "1.0" paste = "1.0"
unwrap_or = "1.0.1" unwrap_or = "1.0.1"
@ -21,6 +21,6 @@ cglue = "0.3.5"
[package.metadata.zluda] [package.metadata.zluda]
linux_symlinks = [ linux_symlinks = [
"dump/libcufft.so", "trace/libcublas.so",
"dump/libcufft.so.11" "trace/libcublas.so.12"
] ]

View File

@ -17,12 +17,12 @@ macro_rules! unimplemented {
#[allow(improper_ctypes)] #[allow(improper_ctypes)]
#[allow(improper_ctypes_definitions)] #[allow(improper_ctypes_definitions)]
pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type { pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
use ::zluda_dump_common::ReprUsize; use ::zluda_trace_common::ReprUsize;
let internal_error_untyped: usize = <$ret_type as ReprUsize>::INTERNAL_ERROR; let internal_error_untyped: usize = <$ret_type as ReprUsize>::INTERNAL_ERROR;
let internal_error: $ret_type = ReprUsize::from_usize(internal_error_untyped); let internal_error: $ret_type = ReprUsize::from_usize(internal_error_untyped);
let maybe_fn_ptr = (&*LIBRARY).as_ref().and_then(|lib| lib.get::<unsafe extern $abi fn ( $($arg_type),* ) -> $ret_type>(concat!( stringify!($fn_name), "\0").as_bytes()).ok()); let maybe_fn_ptr = (&*LIBRARY).as_ref().and_then(|lib| lib.get::<unsafe extern $abi fn ( $($arg_type),* ) -> $ret_type>(concat!( stringify!($fn_name), "\0").as_bytes()).ok());
let fn_ptr = unwrap_or::unwrap_some_or!(maybe_fn_ptr, return internal_error); let fn_ptr = unwrap_or::unwrap_some_or!(maybe_fn_ptr, return internal_error);
let export_table = unwrap_or::unwrap_some_or!(::zluda_dump_common::get_export_table(), return internal_error); let export_table = unwrap_or::unwrap_some_or!(::zluda_trace_common::get_export_table(), return internal_error);
let format_args = dark_api::FnFfiWrapper(|| { let format_args = dark_api::FnFfiWrapper(|| {
let mut writer = Vec::new(); let mut writer = Vec::new();
let formatter = paste::paste! { ::format:: [< write_ $fn_name>] }; let formatter = paste::paste! { ::format:: [< write_ $fn_name>] };

View File

@ -1,11 +1,11 @@
[package] [package]
name = "zluda_dump_blaslt" name = "zluda_trace_blaslt"
version = "0.0.0" version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"] authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2021" edition = "2021"
[lib] [lib]
name = "zluda_dump_blaslt" name = "zluda_trace_blaslt"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
@ -13,7 +13,7 @@ format = { path = "../format" }
dark_api = { path = "../dark_api" } dark_api = { path = "../dark_api" }
cuda_macros = { path = "../cuda_macros" } cuda_macros = { path = "../cuda_macros" }
cuda_types = { path = "../cuda_types" } cuda_types = { path = "../cuda_types" }
zluda_dump_common = { path = "../zluda_dump_common" } zluda_trace_common = { path = "../zluda_trace_common" }
libloading = "0.8" libloading = "0.8"
paste = "1.0" paste = "1.0"
unwrap_or = "1.0.1" unwrap_or = "1.0.1"
@ -21,6 +21,6 @@ cglue = "0.3.5"
[package.metadata.zluda] [package.metadata.zluda]
linux_symlinks = [ linux_symlinks = [
"dump/libcublasLt.so", "trace/libcublasLt.so",
"dump/libcublasLt.so.12" "trace/libcublasLt.so.12"
] ]

View File

@ -17,12 +17,12 @@ macro_rules! unimplemented {
#[allow(improper_ctypes)] #[allow(improper_ctypes)]
#[allow(improper_ctypes_definitions)] #[allow(improper_ctypes_definitions)]
pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type { pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
use ::zluda_dump_common::ReprUsize; use ::zluda_trace_common::ReprUsize;
let internal_error_untyped: usize = <$ret_type as ReprUsize>::INTERNAL_ERROR; let internal_error_untyped: usize = <$ret_type as ReprUsize>::INTERNAL_ERROR;
let internal_error: $ret_type = ReprUsize::from_usize(internal_error_untyped); let internal_error: $ret_type = ReprUsize::from_usize(internal_error_untyped);
let maybe_fn_ptr = (&*LIBRARY).as_ref().and_then(|lib| lib.get::<unsafe extern $abi fn ( $($arg_type),* ) -> $ret_type>(concat!( stringify!($fn_name), "\0").as_bytes()).ok()); let maybe_fn_ptr = (&*LIBRARY).as_ref().and_then(|lib| lib.get::<unsafe extern $abi fn ( $($arg_type),* ) -> $ret_type>(concat!( stringify!($fn_name), "\0").as_bytes()).ok());
let fn_ptr = unwrap_or::unwrap_some_or!(maybe_fn_ptr, return internal_error); let fn_ptr = unwrap_or::unwrap_some_or!(maybe_fn_ptr, return internal_error);
let export_table = unwrap_or::unwrap_some_or!(::zluda_dump_common::get_export_table(), return internal_error); let export_table = unwrap_or::unwrap_some_or!(::zluda_trace_common::get_export_table(), return internal_error);
let format_args = dark_api::FnFfiWrapper(|| { let format_args = dark_api::FnFfiWrapper(|| {
let mut writer = Vec::new(); let mut writer = Vec::new();
let formatter = paste::paste! { ::format:: [< write_ $fn_name>] }; let formatter = paste::paste! { ::format:: [< write_ $fn_name>] };

View File

@ -1,5 +1,5 @@
[package] [package]
name = "zluda_dump_common" name = "zluda_trace_common"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"

View File

@ -7,21 +7,21 @@ use cuda_types::{
use dark_api::ByteVecFfi; use dark_api::ByteVecFfi;
use std::{ffi::c_void, num::NonZero, ptr, sync::LazyLock}; use std::{ffi::c_void, num::NonZero, ptr, sync::LazyLock};
pub fn get_export_table() -> Option<::dark_api::zluda_dump::ZludaDumpInternal> { pub fn get_export_table() -> Option<::dark_api::zluda_trace::ZludaTraceInternal> {
static CU_GET_EXPORT_TABLE: LazyLock< static CU_GET_EXPORT_TABLE: LazyLock<
Result< Result<
unsafe extern "system" fn(*mut *const ::core::ffi::c_void, *const CUuuid) -> CUresult, unsafe extern "system" fn(*mut *const ::core::ffi::c_void, *const CUuuid) -> CUresult,
libloading::Error, libloading::Error,
>, >,
> = LazyLock::new(|| unsafe { get_dump_table_impl() }); > = LazyLock::new(|| unsafe { get_export_table_impl() });
let cu_get_export_table = CU_GET_EXPORT_TABLE.as_ref().ok()?; let cu_get_export_table = CU_GET_EXPORT_TABLE.as_ref().ok()?;
let mut ptr = ptr::null(); let mut ptr = ptr::null();
unsafe { (cu_get_export_table)(&mut ptr, &::dark_api::zluda_dump::ZludaDumpInternal::GUID) } unsafe { (cu_get_export_table)(&mut ptr, &::dark_api::zluda_trace::ZludaTraceInternal::GUID) }
.ok()?; .ok()?;
Some(unsafe { ::dark_api::zluda_dump::ZludaDumpInternal::new(ptr) }) Some(unsafe { ::dark_api::zluda_trace::ZludaTraceInternal::new(ptr) })
} }
unsafe fn get_dump_table_impl() -> Result< unsafe fn get_export_table_impl() -> Result<
unsafe extern "system" fn(*mut *const ::core::ffi::c_void, *const CUuuid) -> CUresult, unsafe extern "system" fn(*mut *const ::core::ffi::c_void, *const CUuuid) -> CUresult,
libloading::Error, libloading::Error,
> { > {
@ -60,7 +60,7 @@ pub(crate) mod os {
use libloading::os; use libloading::os;
pub fn open_driver() -> Result<libloading::Library, libloading::Error> { pub fn open_driver() -> Result<libloading::Library, libloading::Error> {
unsafe { os::windows::Library::open_already_loaded("nvcuda").map(Into::into) } os::windows::Library::open_already_loaded("nvcuda").map(Into::into)
} }
} }

View File

@ -1,11 +1,11 @@
[package] [package]
name = "zluda_dump_dnn" name = "zluda_trace_dnn"
version = "0.0.0" version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"] authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2021" edition = "2021"
[lib] [lib]
name = "zluda_dump_dnn" name = "zluda_trace_dnn"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
@ -13,7 +13,7 @@ format = { path = "../format" }
dark_api = { path = "../dark_api" } dark_api = { path = "../dark_api" }
cuda_macros = { path = "../cuda_macros" } cuda_macros = { path = "../cuda_macros" }
cuda_types = { path = "../cuda_types" } cuda_types = { path = "../cuda_types" }
zluda_dump_common = { path = "../zluda_dump_common" } zluda_trace_common = { path = "../zluda_trace_common" }
libloading = "0.8" libloading = "0.8"
paste = "1.0" paste = "1.0"
unwrap_or = "1.0.1" unwrap_or = "1.0.1"
@ -21,6 +21,6 @@ cglue = "0.3.5"
[package.metadata.zluda] [package.metadata.zluda]
linux_symlinks = [ linux_symlinks = [
"dump/libcudnn.so", "trace/libcudnn.so",
"dump/libcudnn.so.9" "trace/libcudnn.so.9"
] ]

View File

@ -17,12 +17,12 @@ macro_rules! unimplemented {
#[allow(improper_ctypes)] #[allow(improper_ctypes)]
#[allow(improper_ctypes_definitions)] #[allow(improper_ctypes_definitions)]
pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type { pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
use ::zluda_dump_common::ReprUsize; use ::zluda_trace_common::ReprUsize;
let internal_error_untyped: usize = <$ret_type as ReprUsize>::INTERNAL_ERROR; let internal_error_untyped: usize = <$ret_type as ReprUsize>::INTERNAL_ERROR;
let internal_error: $ret_type = ReprUsize::from_usize(internal_error_untyped); let internal_error: $ret_type = ReprUsize::from_usize(internal_error_untyped);
let maybe_fn_ptr = (&*LIBRARY).as_ref().and_then(|lib| lib.get::<unsafe extern $abi fn ( $($arg_type),* ) -> $ret_type>(concat!( stringify!($fn_name), "\0").as_bytes()).ok()); let maybe_fn_ptr = (&*LIBRARY).as_ref().and_then(|lib| lib.get::<unsafe extern $abi fn ( $($arg_type),* ) -> $ret_type>(concat!( stringify!($fn_name), "\0").as_bytes()).ok());
let fn_ptr = unwrap_or::unwrap_some_or!(maybe_fn_ptr, return internal_error); let fn_ptr = unwrap_or::unwrap_some_or!(maybe_fn_ptr, return internal_error);
let export_table = unwrap_or::unwrap_some_or!(::zluda_dump_common::get_export_table(), return internal_error); let export_table = unwrap_or::unwrap_some_or!(::zluda_trace_common::get_export_table(), return internal_error);
let format_args = dark_api::FnFfiWrapper(|| { let format_args = dark_api::FnFfiWrapper(|| {
let mut writer = Vec::new(); let mut writer = Vec::new();
let formatter = paste::paste! { ::format:: [< write_ $fn_name>] }; let formatter = paste::paste! { ::format:: [< write_ $fn_name>] };

View File

@ -1,11 +1,11 @@
[package] [package]
name = "zluda_dump_blas" name = "zluda_trace_fft"
version = "0.0.0" version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"] authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2021" edition = "2021"
[lib] [lib]
name = "zluda_dump_blas" name = "zluda_trace_fft"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
@ -13,7 +13,7 @@ format = { path = "../format" }
dark_api = { path = "../dark_api" } dark_api = { path = "../dark_api" }
cuda_macros = { path = "../cuda_macros" } cuda_macros = { path = "../cuda_macros" }
cuda_types = { path = "../cuda_types" } cuda_types = { path = "../cuda_types" }
zluda_dump_common = { path = "../zluda_dump_common" } zluda_trace_common = { path = "../zluda_trace_common" }
libloading = "0.8" libloading = "0.8"
paste = "1.0" paste = "1.0"
unwrap_or = "1.0.1" unwrap_or = "1.0.1"
@ -21,6 +21,6 @@ cglue = "0.3.5"
[package.metadata.zluda] [package.metadata.zluda]
linux_symlinks = [ linux_symlinks = [
"dump/libcublas.so", "trace/libcufft.so",
"dump/libcublas.so.12" "trace/libcufft.so.11"
] ]

View File

@ -17,12 +17,12 @@ macro_rules! unimplemented {
#[allow(improper_ctypes)] #[allow(improper_ctypes)]
#[allow(improper_ctypes_definitions)] #[allow(improper_ctypes_definitions)]
pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type { pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
use ::zluda_dump_common::ReprUsize; use ::zluda_trace_common::ReprUsize;
let internal_error_untyped: usize = <$ret_type as ReprUsize>::INTERNAL_ERROR; let internal_error_untyped: usize = <$ret_type as ReprUsize>::INTERNAL_ERROR;
let internal_error: $ret_type = ReprUsize::from_usize(internal_error_untyped); let internal_error: $ret_type = ReprUsize::from_usize(internal_error_untyped);
let maybe_fn_ptr = (&*LIBRARY).as_ref().and_then(|lib| lib.get::<unsafe extern $abi fn ( $($arg_type),* ) -> $ret_type>(concat!( stringify!($fn_name), "\0").as_bytes()).ok()); let maybe_fn_ptr = (&*LIBRARY).as_ref().and_then(|lib| lib.get::<unsafe extern $abi fn ( $($arg_type),* ) -> $ret_type>(concat!( stringify!($fn_name), "\0").as_bytes()).ok());
let fn_ptr = unwrap_or::unwrap_some_or!(maybe_fn_ptr, return internal_error); let fn_ptr = unwrap_or::unwrap_some_or!(maybe_fn_ptr, return internal_error);
let export_table = unwrap_or::unwrap_some_or!(::zluda_dump_common::get_export_table(), return internal_error); let export_table = unwrap_or::unwrap_some_or!(::zluda_trace_common::get_export_table(), return internal_error);
let format_args = dark_api::FnFfiWrapper(|| { let format_args = dark_api::FnFfiWrapper(|| {
let mut writer = Vec::new(); let mut writer = Vec::new();
let formatter = paste::paste! { ::format:: [< write_ $fn_name>] }; let formatter = paste::paste! { ::format:: [< write_ $fn_name>] };

View File

@ -0,0 +1,26 @@
[package]
name = "zluda_trace_sparse"
version = "0.0.0"
authors = ["Andrzej Janik <vosen@vosen.pl>"]
edition = "2021"
[lib]
name = "zluda_trace_sparse"
crate-type = ["cdylib"]
[dependencies]
format = { path = "../format" }
dark_api = { path = "../dark_api" }
cuda_macros = { path = "../cuda_macros" }
cuda_types = { path = "../cuda_types" }
zluda_trace_common = { path = "../zluda_trace_common" }
libloading = "0.8"
paste = "1.0"
unwrap_or = "1.0.1"
cglue = "0.3.5"
[package.metadata.zluda]
linux_symlinks = [
"trace/libcusparse.so",
"trace/libcusparse.so.12"
]

View File

@ -17,12 +17,12 @@ macro_rules! unimplemented {
#[allow(improper_ctypes)] #[allow(improper_ctypes)]
#[allow(improper_ctypes_definitions)] #[allow(improper_ctypes_definitions)]
pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type { pub unsafe extern $abi fn $fn_name ( $( $arg_id : $arg_type),* ) -> $ret_type {
use ::zluda_dump_common::ReprUsize; use ::zluda_trace_common::ReprUsize;
let internal_error_untyped: usize = <$ret_type as ReprUsize>::INTERNAL_ERROR; let internal_error_untyped: usize = <$ret_type as ReprUsize>::INTERNAL_ERROR;
let internal_error: $ret_type = ReprUsize::from_usize(internal_error_untyped); let internal_error: $ret_type = ReprUsize::from_usize(internal_error_untyped);
let maybe_fn_ptr = (&*LIBRARY).as_ref().and_then(|lib| lib.get::<unsafe extern $abi fn ( $($arg_type),* ) -> $ret_type>(concat!( stringify!($fn_name), "\0").as_bytes()).ok()); let maybe_fn_ptr = (&*LIBRARY).as_ref().and_then(|lib| lib.get::<unsafe extern $abi fn ( $($arg_type),* ) -> $ret_type>(concat!( stringify!($fn_name), "\0").as_bytes()).ok());
let fn_ptr = unwrap_or::unwrap_some_or!(maybe_fn_ptr, return internal_error); let fn_ptr = unwrap_or::unwrap_some_or!(maybe_fn_ptr, return internal_error);
let export_table = unwrap_or::unwrap_some_or!(::zluda_dump_common::get_export_table(), return internal_error); let export_table = unwrap_or::unwrap_some_or!(::zluda_trace_common::get_export_table(), return internal_error);
let format_args = dark_api::FnFfiWrapper(|| { let format_args = dark_api::FnFfiWrapper(|| {
let mut writer = Vec::new(); let mut writer = Vec::new();
let formatter = paste::paste! { ::format:: [< write_ $fn_name>] }; let formatter = paste::paste! { ::format:: [< write_ $fn_name>] };