Table of Contents

Class KernelValidationResult

Namespace
Orleans.GpuBridge.Abstractions.Models.Compilation
Assembly
Orleans.GpuBridge.Abstractions.dll

Represents the result of kernel validation, indicating whether a method or source code can be successfully compiled as a GPU kernel.

public sealed record KernelValidationResult : IEquatable<KernelValidationResult>
Inheritance
KernelValidationResult
Implements
Inherited Members

Examples

// Successful validation
var successResult = new KernelValidationResult(
    IsValid: true,
    Warnings: new[] { "Consider using shared memory for better performance" });

// Failed validation with detailed feedback
var failureResult = new KernelValidationResult(
    IsValid: false,
    ErrorMessage: "Kernel contains unsupported dynamic memory allocation",
    UnsupportedFeatures: new[] { 
        "Dynamic memory allocation (new, malloc)",
        "Recursive function calls",
        "Exception handling (try/catch)"
    });

// Validation with warnings but no errors
var warningResult = new KernelValidationResult(
    IsValid: true,
    Warnings: new[] {
        "High register usage may reduce occupancy",
        "Uncoalesced memory access pattern detected"
    });

Remarks

This record provides comprehensive feedback about kernel validation, enabling developers to understand not only whether compilation will succeed, but also what specific issues need to be addressed.

Validation typically checks for: - Supported language constructs and API calls - Memory access patterns and synchronization - Resource usage constraints - Platform-specific limitations - Type compatibility and marshalling requirements

Even when validation succeeds (IsValid is true), it's important to review warnings as they may indicate performance issues or potential portability problems.

Constructors

KernelValidationResult(bool, string?, IReadOnlyList<string>?, IReadOnlyList<string>?)

Represents the result of kernel validation, indicating whether a method or source code can be successfully compiled as a GPU kernel.

public KernelValidationResult(bool IsValid, string? ErrorMessage = null, IReadOnlyList<string>? Warnings = null, IReadOnlyList<string>? UnsupportedFeatures = null)

Parameters

IsValid bool

Indicates whether the kernel is valid and can be compiled successfully. A value of true means the kernel passed all validation checks and is suitable for GPU compilation. A value of false indicates that one or more validation errors prevent successful compilation.

ErrorMessage string

The primary error message if validation failed, or null if validation succeeded. This message describes the most critical issue that prevents compilation. Should be clear and actionable, helping developers understand how to fix the validation failure. Only populated when IsValid is false.

Warnings IReadOnlyList<string>

A collection of warning messages about potential issues with the kernel. Warnings don't prevent compilation but may indicate suboptimal code patterns, deprecated features, or potential runtime issues. May be present even when IsValid is true. Default is null.

UnsupportedFeatures IReadOnlyList<string>

A collection of specific language features or constructs used in the kernel that are not supported by the target GPU backend. This provides detailed information about which parts of the code need to be modified for successful compilation. Default is null.

Examples

// Successful validation
var successResult = new KernelValidationResult(
    IsValid: true,
    Warnings: new[] { "Consider using shared memory for better performance" });

// Failed validation with detailed feedback
var failureResult = new KernelValidationResult(
    IsValid: false,
    ErrorMessage: "Kernel contains unsupported dynamic memory allocation",
    UnsupportedFeatures: new[] { 
        "Dynamic memory allocation (new, malloc)",
        "Recursive function calls",
        "Exception handling (try/catch)"
    });

// Validation with warnings but no errors
var warningResult = new KernelValidationResult(
    IsValid: true,
    Warnings: new[] {
        "High register usage may reduce occupancy",
        "Uncoalesced memory access pattern detected"
    });

Remarks

This record provides comprehensive feedback about kernel validation, enabling developers to understand not only whether compilation will succeed, but also what specific issues need to be addressed.

Validation typically checks for: - Supported language constructs and API calls - Memory access patterns and synchronization - Resource usage constraints - Platform-specific limitations - Type compatibility and marshalling requirements

Even when validation succeeds (IsValid is true), it's important to review warnings as they may indicate performance issues or potential portability problems.

Properties

ErrorMessage

The primary error message if validation failed, or null if validation succeeded. This message describes the most critical issue that prevents compilation. Should be clear and actionable, helping developers understand how to fix the validation failure. Only populated when IsValid is false.

public string? ErrorMessage { get; init; }

Property Value

string

HasUnsupportedFeatures

Gets a value indicating whether the validation result identifies unsupported features.

public bool HasUnsupportedFeatures { get; }

Property Value

bool

true if there are one or more unsupported features identified; otherwise, false.

HasWarnings

Gets a value indicating whether the validation result has any warnings.

public bool HasWarnings { get; }

Property Value

bool

true if there are one or more warnings; otherwise, false.

IsValid

Indicates whether the kernel is valid and can be compiled successfully. A value of true means the kernel passed all validation checks and is suitable for GPU compilation. A value of false indicates that one or more validation errors prevent successful compilation.

public bool IsValid { get; init; }

Property Value

bool

IssueCount

Gets the total number of issues (warnings + unsupported features) identified.

public int IssueCount { get; }

Property Value

int

The sum of warning count and unsupported feature count. Does not include the error message in the count.

UnsupportedFeatures

A collection of specific language features or constructs used in the kernel that are not supported by the target GPU backend. This provides detailed information about which parts of the code need to be modified for successful compilation. Default is null.

public IReadOnlyList<string>? UnsupportedFeatures { get; init; }

Property Value

IReadOnlyList<string>

Warnings

A collection of warning messages about potential issues with the kernel. Warnings don't prevent compilation but may indicate suboptimal code patterns, deprecated features, or potential runtime issues. May be present even when IsValid is true. Default is null.

public IReadOnlyList<string>? Warnings { get; init; }

Property Value

IReadOnlyList<string>