# GPU Resident Input Example

This example demonstrates GPU-resident operators with a data ready handler for external sensor inputs. A registered data ready handler is executed in the GPU itself.

## Overview

The example creates a GPU-resident pipeline that processes data generated by a separate data ready handler fragment. It includes:

- **SourceGpuOp**: A GPU-resident operator with an output port
- **ComputeGpuOp**: Operators that launch CUDA kernels to add 5 to each array element
- **SinkGpuOp**: Verifies results using a CUDA kernel

Data Ready Handler Fragment operator:
- **InputGpuOp**: A data ready handler that generates input data on the GPU and signals input data readiness

## Key Features

- **Data Ready Handler**: Demonstrates how to integrate external input sources with GPU-resident graph execution
- **CUDA Kernels**: All computation and verification happens on the GPU through custom CUDA kernels
- **Device Memory Management**: Shows proper use of device memory ports between GPU-resident operators
- **Performance Measurement**: Demonstrates how to enable, collect, and report performance metrics for GPU-resident graph execution

## Performance Measurement

The example includes basic performance measurement capabilities of the GPU-resident graph execution. The measured execution times are the times an iteration of the GPU-resident graph takes on the GPU. As the graph is GPU-resident, no times are measured on the CPU.

```cpp
// Enable performance measurement with sample collection (10,000 samples)
app->gpu_resident().enable_perf_measurement(10000);

// After execution, print performance metrics
app->gpu_resident().print_perf_metrics(100, 100);

// Save detailed performance results to CSV file
app->gpu_resident().save_perf_results_as_csv();
```

This allows profiling of GPU-resident graph execution to understand timing characteristics and predictability of the application.

## Platform support and CUDA driver compatibility

GPU-resident execution relies on CUDA graph capture APIs (for example, `cudaStreamBeginCaptureToGraph`) that require CUDA Runtime 12.3+ support from the installed NVIDIA driver.

- Verify driver/runtime compatibility with `nvidia-smi` (the reported CUDA version must be at least 12.3).
- IGX Orin dGPU systems running IGX OS 1.x typically use R535 drivers (CUDA 12.2 compatibility), so this example is not supported on that default host configuration.
- On unsupported systems, startup can fail with:
  - `API call is not supported in the installed CUDA driver (36)`
- An optional workaround on IGX OS 1.x is to install [CUDA forward-compat components from the CUDA repository](https://docs.nvidia.com/deploy/cuda-compatibility/forward-compatibility.html). This can make the example run, but it diverges from the default IGX OS 1.x package set and is not fully validated for all deployments.
