         
syntax = "proto2";
package NV.Profiler;
// enable arenas for better allocation performance
option cc_enable_arenas = true;
// Array of 3 for dimensions and work offset. Rather than making a coords, and a separate dimensions message.
// Please be careful if you need to modify this, as it is used in the report file.
message Uint64x3
{
    optional uint64 X = 1;
    optional uint64 Y = 2;
    optional uint64 Z = 3;
}
enum APIType
{
    APIType_CUDA = 0;
    APIType_OpenCL = 1;
    APIType_Direct3D = 2;
    APIType_OpenGL = 3;
}
// Required to be in sync with NvGpuArch's SassLevel
enum SourceSassLevel
{
    SourceSassLevel_Unset = 0;
    SourceSassLevel_Sass1 = 1;
    SourceSassLevel_Sass2 = 2;
    SourceSassLevel_Sass3 = 3;
    SourceSassLevel_Sass4 = 4;
    SourceSassLevel_Sass5 = 5;
    SourceSassLevel_Sass6 = 6;
    SourceSassLevel_Sass7 = 7;
    SourceSassLevel_Sass8 = 8;
}
message LaunchData
{
    required uint32 ProcessID = 2;
    required uint32 ThreadID = 3;
    required uint64 APICallID = 4;
    required APIType API = 5;
    required uint64 KernelID = 6;
    required string KernelMangledName = 7;
    required string KernelFunctionName = 8;
    required string KernelDemangledName = 9;
    required uint64 ProgramHandle = 10;
    required uint64 ContextHandle = 11;
    required uint64 DeviceID = 12;
    required uint32 WorkDimensions = 13;
    required Uint64x3 GlobalWorkOffset = 14;
    required Uint64x3 GridSize = 15;
    required Uint64x3 BlockSize = 16;
    optional uint32 ContextID = 17;
    optional uint32 StreamID = 18;
    // NVTX renamed CUDA context and stream
    optional string ContextName = 19;
    optional string StreamName = 20;
}
message SourceData
{
    optional uint64 Reference = 1;
    optional string Code = 2;
    optional bytes Intermediate = 3;
    optional bytes Binary = 4;
    optional SourceSassLevel SassLevel = 5;
    optional uint32 SMRevision = 6;
    optional uint32 BinaryFlags = 7;
}
message LopMetricConfig
{
    required string Spec = 1;
    required string Metric = 2;
    required string Unit = 3;
}
message MetricExpansion
{
    required string Metric = 1;
    repeated string Expansions = 2;
}
message ReplayLoopConfig
{
    // next experiment
    required uint32 StartExperimentIdx = 1;
    // next pass within this experiment
    required uint32 StartExperimentPassIdx = 2;
}
message ExperimentConfig
{
    // current pass within the experiment for non-multi-pass data collectors
    required uint32 CurrentPassIndex = 1;
    // current pass within the experiment for multi-pass data collectors
    required uint32 CurrentMultiPassDataCollectorIndex = 2;
}
message LopReplayConfig
{
    // the next LOP pass index, see NVPW_CUDA_Profiler_SetConfig_Params
    required uint32 NextPassIndex = 1;
    // the next LOP nesting level, see NVPW_CUDA_Profiler_SetConfig_Params
    required uint32 NextNestingLevel = 2;
}
message LopRealtimeReplaySamplingParameterFuncMapEntry
{
    required uint64 PC = 1;
    required uint64 Func = 2;
    required uint64 FuncSize = 3;
}
message LopRealtimeReplaySamplingParameter
{
    optional uint64 SamplingInterval = 1;
    optional uint64 PerfmonBufferSizeInBytes = 2;
    optional uint64 ScratchBufferSizeInBytes = 3;
    optional uint64 MaximumScratchBufferSizeInBytes = 4;
    optional uint64 NumVarDataRecords = 5;
    optional uint64 VarDataBufferSizeInBytes = 6;
    optional uint64 MaximumVarDataBufferSizeInBytes = 7;
    repeated LopRealtimeReplaySamplingParameterFuncMapEntry FuncMapEntries = 8;
}
message LopRealtimeReplayConfig
{
    optional uint64 PassIndex = 1;
    optional LopRealtimeReplaySamplingParameter SamplingParameter = 2;
}
message PrePassFunctionInfo
{
    required uint32 FunctionIndex = 1;
    required string FunctionName = 2;
    // for cross-checking that the function matches
    required uint32 ModuleSize = 3;
    optional uint64 ModuleHashKey = 4;
}
message PrePassInfo
{
    // id of the global entry function
    required PrePassFunctionInfo EntryFunctionInfo = 1;
    // id of the executed function
    required PrePassFunctionInfo FunctionInfo = 2;
}
message FunctionBase
{
    required uint64 SymbolIndex = 1;
    required uint64 EntryPc = 2;
}
message SwCounterReplayConfig
{
    repeated FunctionBase FunctionBase = 1;
    optional uint32 PassIndex = 2;
    repeated PrePassInfo PrePassInfo = 3;
}
message AppReplayConfig
{
    // Configures the state of the replay loop
    required ReplayLoopConfig ReplayLoopConfig = 1;
    // Configures the state of the current experiment
    required ExperimentConfig ExperimentConfig = 2;
    // Stores the modules unique id
    required uint64 ProgramUniqueId = 3;
    optional bool FinalPass = 4;
    // LOP specific replay information
    optional LopReplayConfig LopReplayConfigCtx = 5;
    optional LopReplayConfig LopReplayConfigDev = 6;
    // LOP-Realtime specific replay information
    optional LopRealtimeReplayConfig LopRealtimeReplayConfig = 7;
    // SW Counter specific replay information
    optional SwCounterReplayConfig SwCounterReplayConfig = 8;
    // Flag stating if source data was already sent for this kernel launch
    optional bool SourceSent = 9;
}
message CounterDataLop
{
    optional bytes ConfigImage = 1;
    optional bytes CounterDataImage = 2;
    optional uint32 NumPasses = 3;
    repeated LopMetricConfig MetricConfigs = 4;
}
message CounterData
{
    required string ChipName = 1;
    optional CounterDataLop LopDataCtx = 2;
    optional CounterDataLop LopDataDev = 3;
    repeated MetricExpansion MetricExpansions = 4; // temporary, until metrics are evaluated on the host
    // Set only if in application replay mode
    optional AppReplayConfig AppReplayConfig = 5;
}
