@@ -39,6 +39,7 @@ import (
3939 "go.opentelemetry.io/ebpf-profiler/host"
4040 "go.opentelemetry.io/ebpf-profiler/libpf"
4141 "go.opentelemetry.io/ebpf-profiler/metrics"
42+ "go.opentelemetry.io/ebpf-profiler/parcagpu"
4243 otelreporter "go.opentelemetry.io/ebpf-profiler/reporter"
4344 "go.opentelemetry.io/ebpf-profiler/times"
4445 "go.opentelemetry.io/ebpf-profiler/tracehandler"
@@ -349,6 +350,11 @@ func mainWithExitCode() flags.ExitCode {
349350 }
350351 }
351352
353+ // Remove CUDA tracer if it isn't enabled.
354+ if ! f .InstrumentCudaLaunch {
355+ includeTracers .Disable (tracertypes .CUDATracer )
356+ }
357+
352358 // Load relabel configs from the config file (if provided)
353359 var relabelConfigs []* relabel.Config
354360 if f .ConfigPath == "" {
@@ -443,6 +449,7 @@ func mainWithExitCode() flags.ExitCode {
443449 CollectCustomLabels : f .CollectCustomLabels ,
444450 OffCPUThreshold : uint32 (f .OffCPUThreshold * math .MaxUint32 ),
445451 IncludeEnvVars : includeEnvVars ,
452+ InstrumentCudaLaunch : f .InstrumentCudaLaunch ,
446453 })
447454 metrics .SetReporter (parcaReporter )
448455 if err != nil {
@@ -518,6 +525,12 @@ func mainWithExitCode() flags.ExitCode {
518525 return flags .Failure ("Failed to start map monitors: %v" , err )
519526 }
520527
528+ if f .InstrumentCudaLaunch {
529+ // GPU processor will consume traces and filter out GPU samples awaiting
530+ // timing information.
531+ traceCh = parcagpu .Start (ctx , traceCh , trc .GetEbpfMaps ()["cuda_timing_events" ])
532+ }
533+
521534 if _ , err := tracehandler .Start (ctx , rep , trc .TraceProcessor (),
522535 traceCh , intervals , traceHandlerCacheSize ); err != nil {
523536 return flags .Failure ("Failed to start trace handler: %v" , err )
0 commit comments