aboutsummaryrefslogtreecommitdiffhomepage
path: root/zluda_dump/src
diff options
context:
space:
mode:
Diffstat (limited to 'zluda_dump/src')
-rw-r--r--zluda_dump/src/format.rs163
-rw-r--r--zluda_dump/src/lib.rs8
-rw-r--r--zluda_dump/src/os_unix.rs4
-rw-r--r--zluda_dump/src/trace.rs10
4 files changed, 133 insertions, 52 deletions
diff --git a/zluda_dump/src/format.rs b/zluda_dump/src/format.rs
index 380e52d..7bfa060 100644
--- a/zluda_dump/src/format.rs
+++ b/zluda_dump/src/format.rs
@@ -1,11 +1,10 @@
+use cuda_base::cuda_derive_display_trait;
use std::{
ffi::{c_void, CStr},
fmt::LowerHex,
mem, ptr, slice,
};
-use cuda_base::cuda_derive_display_trait;
-
pub(crate) trait CudaDisplay {
fn write(
&self,
@@ -494,6 +493,59 @@ impl CudaDisplay
}
}
+impl CudaDisplay for cuda_types::CUgraphNodeParams_st {
+ fn write(
+ &self,
+ _fn_name: &'static str,
+ _index: usize,
+ _writer: &mut (impl std::io::Write + ?Sized),
+ ) -> std::io::Result<()> {
+ todo!()
+ }
+}
+
+impl CudaDisplay for cuda_types::CUlaunchConfig_st {
+ fn write(
+ &self,
+ _fn_name: &'static str,
+ _index: usize,
+ _writer: &mut (impl std::io::Write + ?Sized),
+ ) -> std::io::Result<()> {
+ todo!()
+ }
+}
+
+impl CudaDisplay for cuda_types::CUeglFrame_st {
+ fn write(
+ &self,
+ _fn_name: &'static str,
+ _index: usize,
+ _writer: &mut (impl std::io::Write + ?Sized),
+ ) -> std::io::Result<()> {
+ todo!()
+ }
+}
+
+impl CudaDisplay for cuda_types::CUdevResource_st {
+ fn write(
+ &self,
+ _fn_name: &'static str,
+ _index: usize,
+ _writer: &mut (impl std::io::Write + ?Sized),
+ ) -> std::io::Result<()> {
+ todo!()
+ }
+}
+impl CudaDisplay for cuda_types::CUlaunchAttribute_st {
+ fn write(
+ &self,
+ _fn_name: &'static str,
+ _index: usize,
+ _writer: &mut (impl std::io::Write + ?Sized),
+ ) -> std::io::Result<()> {
+ todo!()
+ }
+}
impl<T: CudaDisplay> CudaDisplay for *mut T {
fn write(
&self,
@@ -585,27 +637,7 @@ pub fn write_cuGraphKernelNodeGetAttribute(
CudaDisplay::write(&hNode, "cuGraphKernelNodeGetAttribute", 0, writer)?;
writer.write_all(b", attr: ")?;
CudaDisplay::write(&attr, "cuGraphKernelNodeGetAttribute", 1, writer)?;
- match attr {
- cuda_types::CUkernelNodeAttrID::CU_KERNEL_NODE_ATTRIBUTE_ACCESS_POLICY_WINDOW => {
- writer.write_all(b", value_out: ")?;
- CudaDisplay::write(
- unsafe { &(*value_out).accessPolicyWindow },
- "cuGraphKernelNodeGetAttribute",
- 2,
- writer,
- )?;
- }
- cuda_types::CUkernelNodeAttrID::CU_KERNEL_NODE_ATTRIBUTE_COOPERATIVE => {
- writer.write_all(b", value_out: ")?;
- CudaDisplay::write(
- unsafe { &(*value_out).cooperative },
- "cuGraphKernelNodeGetAttribute",
- 2,
- writer,
- )?;
- }
- _ => return writer.write_all(b", ...) "),
- }
+ write_launch_attribute(writer, "cuGraphKernelNodeGetAttribute", 2, attr, value_out)?;
writer.write_all(b") ")
}
@@ -630,28 +662,73 @@ pub fn write_cuStreamGetAttribute(
CudaDisplay::write(&hStream, "cuStreamGetAttribute", 0, writer)?;
writer.write_all(b", attr: ")?;
CudaDisplay::write(&attr, "cuStreamGetAttribute", 1, writer)?;
- match attr {
- cuda_types::CUstreamAttrID::CU_STREAM_ATTRIBUTE_ACCESS_POLICY_WINDOW => {
+ write_launch_attribute(writer, "cuStreamGetAttribute", 2, attr, value_out)?;
+ writer.write_all(b") ")
+}
+
+fn write_launch_attribute(
+ writer: &mut (impl std::io::Write + ?Sized),
+ fn_name: &'static str,
+ index: usize,
+ attribute: cuda_types::CUlaunchAttributeID,
+ value_out: *mut cuda_types::CUstreamAttrValue,
+) -> std::io::Result<()> {
+ match attribute {
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_ACCESS_POLICY_WINDOW => {
writer.write_all(b", value_out: ")?;
CudaDisplay::write(
unsafe { &(*value_out).accessPolicyWindow },
- "cuStreamGetAttribute",
- 2,
+ fn_name,
+ index,
writer,
- )?;
+ )
}
- cuda_types::CUstreamAttrID::CU_STREAM_ATTRIBUTE_SYNCHRONIZATION_POLICY => {
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_COOPERATIVE => {
writer.write_all(b", value_out: ")?;
- CudaDisplay::write(
- unsafe { &(*value_out).syncPolicy },
- "cuStreamGetAttribute",
- 2,
- writer,
- )?;
+ CudaDisplay::write(unsafe { &(*value_out).cooperative }, fn_name, index, writer)
+ }
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_SYNCHRONIZATION_POLICY => {
+ writer.write_all(b", value_out: ")?;
+ CudaDisplay::write(unsafe { &(*value_out).syncPolicy }, fn_name, index, writer)
+ }
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_CLUSTER_DIMENSION => {
+ writer.write_all(b", value_out: ")?;
+ CudaDisplay::write(unsafe { &(*value_out).clusterDim }, fn_name, index, writer)
+ }
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_CLUSTER_SCHEDULING_POLICY_PREFERENCE => {
+ writer.write_all(b", value_out: ")?;
+ CudaDisplay::write(unsafe { &(*value_out).clusterSchedulingPolicyPreference }, fn_name, index, writer)
+ }
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_STREAM_SERIALIZATION => {
+ writer.write_all(b", value_out: ")?;
+ CudaDisplay::write(unsafe { &(*value_out).programmaticStreamSerializationAllowed }, fn_name, index, writer)
+ }
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_PROGRAMMATIC_EVENT => {
+ writer.write_all(b", value_out: ")?;
+ CudaDisplay::write(unsafe { &(*value_out).programmaticEvent }, fn_name, index, writer)
+ }
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_PRIORITY => {
+ writer.write_all(b", value_out: ")?;
+ CudaDisplay::write(unsafe { &(*value_out).priority }, fn_name, index, writer)
+ }
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN_MAP => {
+ writer.write_all(b", value_out: ")?;
+ CudaDisplay::write(unsafe { &(*value_out).memSyncDomainMap }, fn_name, index, writer)
+ }
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_MEM_SYNC_DOMAIN => {
+ writer.write_all(b", value_out: ")?;
+ CudaDisplay::write(unsafe { &(*value_out).memSyncDomain }, fn_name, index, writer)
}
- _ => return writer.write_all(b", ...) "),
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_LAUNCH_COMPLETION_EVENT => {
+ writer.write_all(b", value_out: ")?;
+ CudaDisplay::write(unsafe { &(*value_out).launchCompletionEvent }, fn_name, index, writer)
+ }
+ cuda_types::CUlaunchAttributeID::CU_LAUNCH_ATTRIBUTE_DEVICE_UPDATABLE_KERNEL_NODE => {
+ writer.write_all(b", value_out: ")?;
+ CudaDisplay::write(unsafe { &(*value_out).deviceUpdatableKernelNode }, fn_name, index, writer)
+ }
+ _ => writer.write_all(b", ... "),
}
- writer.write_all(b") ")
}
#[allow(non_snake_case)]
@@ -737,7 +814,17 @@ cuda_derive_display_trait!(
CUstreamBatchMemOpParams_union_CUstreamMemOpWaitValueParams_st,
CUstreamBatchMemOpParams_union_CUstreamMemOpWriteValueParams_st,
CUuuid_st,
- HGPUNV
+ HGPUNV,
+ EGLint,
+ EGLSyncKHR,
+ EGLImageKHR,
+ EGLStreamKHR,
+ CUasyncNotificationInfo_st,
+ CUgraphNodeParams_st,
+ CUeglFrame_st,
+ CUdevResource_st,
+ CUlaunchAttribute_st,
+ CUlaunchConfig_st
],
[
cuCtxCreate_v3,
diff --git a/zluda_dump/src/lib.rs b/zluda_dump/src/lib.rs
index 04fc36e..f3801b8 100644
--- a/zluda_dump/src/lib.rs
+++ b/zluda_dump/src/lib.rs
@@ -1,6 +1,4 @@
-use cuda_types::{
- CUdevice, CUdevice_attribute, CUfunction, CUjit_option, CUmodule, CUresult, CUuuid,
-};
+use cuda_types::*;
use paste::paste;
use side_by_side::CudaDynamicFns;
use std::io;
@@ -205,10 +203,10 @@ impl Settings {
}
};
let libcuda_path = match env::var("ZLUDA_CUDA_LIB") {
- Err(env::VarError::NotPresent) => os::LIBCUDA_DEFAULT_PATH.to_owned(),
+ Err(env::VarError::NotPresent) => os::LIBCUDA_DEFAULT_PATH.to_string(),
Err(e) => {
logger.log(log::LogEntry::ErrorBox(Box::new(e) as _));
- os::LIBCUDA_DEFAULT_PATH.to_owned()
+ os::LIBCUDA_DEFAULT_PATH.to_string()
}
Ok(env_string) => env_string,
};
diff --git a/zluda_dump/src/os_unix.rs b/zluda_dump/src/os_unix.rs
index e1e516b..a4f29b2 100644
--- a/zluda_dump/src/os_unix.rs
+++ b/zluda_dump/src/os_unix.rs
@@ -1,8 +1,8 @@
-use crate::cuda::CUuuid;
+use cuda_types::CUuuid;
use std::ffi::{c_void, CStr, CString};
use std::mem;
-pub(crate) const LIBCUDA_DEFAULT_PATH: &'static str = b"/usr/lib/x86_64-linux-gnu/libcuda.so.1\0";
+pub(crate) const LIBCUDA_DEFAULT_PATH: &str = "/usr/lib/x86_64-linux-gnu/libcuda.so.1";
pub unsafe fn load_library(libcuda_path: &str) -> *mut c_void {
let libcuda_path = CString::new(libcuda_path).unwrap();
diff --git a/zluda_dump/src/trace.rs b/zluda_dump/src/trace.rs
index 59a0a0f..9002aca 100644
--- a/zluda_dump/src/trace.rs
+++ b/zluda_dump/src/trace.rs
@@ -1,6 +1,3 @@
-use ptx::{ast::PtxError, Token};
-use ptx::{DisplayParseError, ModuleParserExt};
-
use crate::{dark_api, log, Settings};
use cuda_types::CUmodule;
use std::{
@@ -172,7 +169,7 @@ impl StateTracker {
submodule_index: Option<usize>,
module_text: &str,
) {
- let (_ast, errors) = ptx::ModuleParser::parse_unchecked(module_text);
+ let errors = ptx_parser::parse_for_errors(module_text);
if !errors.is_empty() {
fn_logger.log(log::LogEntry::ModuleParsingError(
DumpWriter::get_file_name(module_index, version, submodule_index, "log"),
@@ -232,7 +229,7 @@ impl DumpWriter {
module_index: usize,
version: Option<usize>,
submodule_index: Option<usize>,
- errors: &[ptx::ParseError<usize, Token<'input>, PtxError>],
+ errors: &[ptx_parser::PtxError<'input>],
) -> io::Result<()> {
let mut log_file = match &self.dump_dir {
None => return Ok(()),
@@ -246,8 +243,7 @@ impl DumpWriter {
));
let mut file = File::create(log_file)?;
for error in errors {
- let pretty_print_error = unsafe { DisplayParseError::new(error, module_text) };
- writeln!(file, "{}", pretty_print_error)?;
+ writeln!(file, "{}", error)?;
}
Ok(())
}