         
syntax = "proto2";
package NV.RuleSystem;
import "ProfilerSection/ProfilerSection.proto";
// =============================================================================
// MESSAGE
// Simple message that stores a single string
//
// TYPES
// None         - No message available
// Ok           - Informative, non-actionable message
// Warning      - Non-fatal warnings, e.g. about as missing metrics
// Error        - Execution errors/failures during rule execution,
//                e.g. syntax error in Python script
// Optimization - Message about performance optimization potential;
//                should be actionable
// =============================================================================
enum RuleResultMessageType
{
    None = 0;
    Ok = 1;
    Warning = 2;
    Error = 3;
    Optimization = 4;
}
message RuleResultMessage
{
    required string Message = 1;
    required RuleResultMessageType Type = 2;
    optional int32 Id = 3;
    optional string Name = 4;
}
message RuleResultProposal
{
    required string Identifier = 1;
}
// =============================================================================
// RULE TABLE
// Dynamically generated table with an abitrary number of columns and rows
// that can store integer, double or string data.
//
// RuleResultTable
// Contains the data of the table in form of a list of columns, as well as
// the configuration options of the table as a whole.
// Style config options will apply to all elements of the table, but can be
// overridden by more specific configs.
// 
// RuleResultTableColumn
// Contains the data of a single column, where the Type field indicates which
// of the data fields is set.
// The Config applies only to the specific column and overrides any global settings.
// Style options can be specified for header and data cells separately.
// =============================================================================
enum RuleResultTableElementType
{
    Invalid = 0; // Use for any Python type that cannot be converted to int, float or str
    Double = 1;
    Int = 2;
    String = 3;
    Custom = 4; // Any Python type that is not int, float or str, but can be converted to str
}
message RuleResultTableStyle
{
    optional bool IsBold = 1;
    optional bool IsItalic = 2;
}
message RuleResultTableSortInfo
{
    required uint32 ColumnIndex = 1;
    optional bool IsAscending = 2;
}
message RuleResultTableConfig
{
    optional string Title = 1;
    optional string Description = 2;
    optional RuleResultTableSortInfo SortBy = 3;
    optional RuleResultTableStyle Style = 4;
}
message RuleResultTableConfigColumn
{
    optional string Tooltip = 1;
    optional double RelativeWidth = 2;
    optional RuleResultTableStyle HeaderStyle = 3;
    optional RuleResultTableStyle DataStyle = 4;
}
message RuleResultTableColumn
{
    // Name of the column
    required string Name = 1;
    // Type of all the elements in the column
    required RuleResultTableElementType Type = 2;
    // Number of elements in the column
    required uint64 Size = 3;
    // Serialized data of the column; use the Type to unpack the data
    repeated string StringData = 4;
    repeated double DoubleData = 5;
    repeated int64 IntData = 6;
    // Configuration option of the column (including header and data)
    optional RuleResultTableConfigColumn Config = 7;
}
message RuleResultTable
{
    // Columns of the table, holding the data
    repeated RuleResultTableColumn Columns = 2;
    // Configuration option of the table as a whole
    optional RuleResultTableConfig Config = 1;
}
// =============================================================================
// POTENTIAL SPEEDUP
// Stores SpeedupType and Value of the estimated maximal achievable speedup
//
// TYPE
// Unknown - not set
// Local - value represents increase in hardware efficiency in isolated context
// Global - value represents decrease in overall kernel runtime
// 
// VALUE
// Expected to be in the range [0, 100], as it represents a percentage
// =============================================================================
enum RuleResultSpeedupType
{
    Unknown = 0;
    Local = 1;
    Global = 2;
}
message RuleResultSpeedup
{
    optional RuleResultSpeedupType SpeedupType = 1;
    optional double Value = 2;
}
enum RuleResultFocusSeverity
{
    Default = 0;
    Low = 1;
    High = 2;
}
message RuleResultFocusMetric
{
    optional int32 MessageId = 1;
    optional string MetricName = 2;
    optional double MetricValue = 3;
    optional RuleResultFocusSeverity Severity = 4;
    optional string Info = 5;
}
// =============================================================================
// SOURCEMARKER
// Icon and tooltip text that gets shown on lines in the Source Page
// =============================================================================
enum MarkerKind
{
    SASS = 0;
    Source = 1;
}
message SourceMarker
{
    optional MarkerKind Kind = 1;
    oneof source_location
    {
        uint32 LineNumber = 2;
        uint64 Address = 3;
    }
    optional string Tooltip = 4;
    optional RuleResultMessageType Type = 5;
    optional string FileName = 6;
}
// =============================================================================
// BODY ITEM
// A single body item
// =============================================================================
message RuleResultBodyItem
{
    optional RuleResultMessage Message = 1;
    // Deprecated in favor of RuleResultTable
    optional NV.Profiler.ProfilerSectionTable Table = 2;
    optional NV.Profiler.ProfilerSectionBarChart BarChart = 3;
    optional NV.Profiler.ProfilerSectionHistogramChart HistogramChart = 4;
    optional NV.Profiler.ProfilerSectionLineChart LineChart = 5;
    optional RuleResultProposal Proposal = 6;
    optional NV.Profiler.ProfilerSectionRooflineChart RooflineChart = 7;
    repeated RuleResultFocusMetric FocusMetrics = 8;
    optional NV.Profiler.ProfilerSourceMetricTable SourceMetricTable = 9;
    optional RuleResultSpeedup Speedup = 10;
    optional NV.Profiler.ProfilerSuffixTable SuffixTable = 11;
    repeated RuleResultTable RuleTables = 12;
}
// =============================================================================
// BODY
// Any number of items that are shows when the results are expanded
// =============================================================================
message RuleResultBody
{
    repeated RuleResultBodyItem Items = 1;
}
// =============================================================================
// RESULT
// =============================================================================
message RuleResult
{
    required string Identifier = 1;
    required string DisplayName = 2;
    optional RuleResultBody Body = 3;
    optional string SectionIdentifier = 4;
    repeated SourceMarker SourceMarkers = 5;
}
message RuleResults
{
    repeated RuleResult RuleResults = 1;
}
