Class MessageDiagnostics
- Namespace
- DotCompute.Abstractions.Messaging
- Assembly
- DotCompute.Abstractions.dll
Diagnostic utilities for debugging Ring Kernel message serialization.
[SuppressMessage("Globalization", "CA1305:Specify IFormatProvider", Justification = "Diagnostic output uses hex/byte formatting which is culture-invariant")]
public static class MessageDiagnostics
- Inheritance
-
MessageDiagnostics
- Inherited Members
Remarks
Provides byte-level inspection of serialized messages to help debug format mismatches between C# MemoryPack serialization and CUDA deserializers.
Properties
IsEnabled
Global flag to enable/disable diagnostic logging. Set to true during development to get byte-level message dumps.
public static bool IsEnabled { get; set; }
Property Value
Methods
CompareByteDumps(ReadOnlySpan<byte>, ReadOnlySpan<byte>, string, string)
Compares two byte arrays and shows differences.
public static string CompareByteDumps(ReadOnlySpan<byte> expected, ReadOnlySpan<byte> actual, string expectedLabel = "Expected", string actualLabel = "Actual")
Parameters
expectedReadOnlySpan<byte>Expected byte data.
actualReadOnlySpan<byte>Actual byte data.
expectedLabelstringLabel for expected data.
actualLabelstringLabel for actual data.
Returns
- string
Comparison report showing differences.
CreateVectorAddRequestSummary(ReadOnlySpan<byte>, bool)
Creates a diagnostic summary for a serialized message including key field values.
public static string CreateVectorAddRequestSummary(ReadOnlySpan<byte> data, bool hasMemoryPackHeader = true)
Parameters
dataReadOnlySpan<byte>The serialized message bytes.
hasMemoryPackHeaderboolWhether the data includes MemoryPack header.
Returns
- string
A summary string with extracted field values.
ExtractFloat(ReadOnlySpan<byte>, int)
Extracts and formats a float value from a byte span at the given offset.
public static float ExtractFloat(ReadOnlySpan<byte> data, int offset)
Parameters
dataReadOnlySpan<byte>The byte data.
offsetintOffset to the float value.
Returns
- float
The float value, or NaN if offset is out of bounds.
ExtractGuid(ReadOnlySpan<byte>, int)
Extracts and formats a Guid value from a byte span at the given offset.
public static Guid ExtractGuid(ReadOnlySpan<byte> data, int offset)
Parameters
dataReadOnlySpan<byte>The byte data.
offsetintOffset to the Guid value.
Returns
- Guid
The Guid value, or Guid.Empty if offset is out of bounds.
FormatAnnotatedDump(ReadOnlySpan<byte>, params (string Name, int Offset, int Size)[])
Formats a message with field annotations based on expected layout.
public static string FormatAnnotatedDump(ReadOnlySpan<byte> data, params (string Name, int Offset, int Size)[] fields)
Parameters
dataReadOnlySpan<byte>The byte data to format.
fields(string Name, int Offset, int Size)[]Array of field annotations (name, offset, size).
Returns
- string
Formatted field-annotated dump.
FormatHexDump(ReadOnlySpan<byte>, string?, int)
Formats a byte array as a hex dump with ASCII representation.
public static string FormatHexDump(ReadOnlySpan<byte> data, string? label = null, int maxBytes = 256)
Parameters
dataReadOnlySpan<byte>The byte data to format.
labelstringOptional label for the dump.
maxBytesintMaximum bytes to display (default 256).
Returns
- string
Formatted hex dump string.
FormatVectorAddRequest(ReadOnlySpan<byte>, bool)
Formats a VectorAddRequest message for debugging.
public static string FormatVectorAddRequest(ReadOnlySpan<byte> data, bool hasMemoryPackHeader = true)
Parameters
dataReadOnlySpan<byte>The serialized message bytes.
hasMemoryPackHeaderboolWhether the data includes MemoryPack's 1-byte member count header.
Returns
- string
Formatted annotated dump.
FormatVectorAddResponse(ReadOnlySpan<byte>, bool)
Formats a VectorAddResponse message for debugging.
public static string FormatVectorAddResponse(ReadOnlySpan<byte> data, bool hasMemoryPackHeader = true)
Parameters
dataReadOnlySpan<byte>The serialized message bytes.
hasMemoryPackHeaderboolWhether the data includes MemoryPack's 1-byte member count header.
Returns
- string
Formatted annotated dump.