graph LR subgraph Graph["Input Graph"] direction LR V["Vertices V"] E["Edges E"] W["Weights w"] end Graph --> CONVERT["Convert to flat arrays\nedges[n_edgesร2] i32\nweights[n_vertices] f32\nseeds[n_trials] i32"] CONVERT --> DEVICE["Upload to GPU"] subgraph GPU["GPU Execution"] direction LR T0["Thread 0\nTrial 0"] T1["Thread 1\nTrial 1"] T2["..."] TN["Thread N-1\nTrial N-1"] end DEVICE --> T0 DEVICE --> T1 DEVICE --> T2 DEVICE --> TN T0 --> MERGE["argmin costs"] T1 --> MERGE T2 --> MERGE TN --> MERGE MERGE --> RESULT["Best Cover"] style Graph fill:#4caf50 style GPU fill:#9c27b0 style MERGE fill:#ff9800 style RESULT fill:#4caf50
graph TB subgraph cudarc["cudarc v0.12.1"] DRV["driver\nCudaDevice, CudaSlice\nCudaFunction, LaunchConfig"] NVRTC["nvrtc\ncompile_ptx()\nCUDA C โ PTX"] end subgraph Our["rand_cover_gpu.rs"] KERN["PITT_KERNEL_CUDA\n(const &str)"] EXEC["try_gpu_execution()\n-#[cfg(feature = cuda)]"] HOST["rand_vertex_cover_gpu()\npublic API"] end KERN --> NVRTC NVRTC --> EXEC DRV --> EXEC HOST --> EXEC style cudarc fill:#2196f3 style Our fill:#ff9800 style KERN fill:#9c27b0
sequenceDiagram participant R as Rust Host participant N as NVRTC participant D as CUDA Driver participant G as GPU R->>R: Convert Graph โ flat arrays R->>D: CudaDevice::new(0) R->>N: compile_ptx(PITT_KERNEL_CUDA) N->>R: Ptx object R->>D: load_ptx(ptx, "mod", &["pitt_kernel"]) R->>D: get_func("mod", "pitt_kernel") D->>R: CudaFunction R->>D: htod_copy(edges, weights, covers, seeds) D->>G: Copy HโD R->>G: launch(func, config, args) loop Each Thread G->>G: Pitt's algorithm end R->>D: synchronize() R->>D: dtoh_sync_copy(covers, costs) D->>R: Copy DโH R->>R: Find best trial (argmin)
graph LR subgraph Features D["default = []"] --> CPU["CPU sequential"] CUDA["cuda"] --> GPU["GPU via cudarc"] R["rayon"] --> CPU end GPU --> CUDA_COMB["cuda + rayon"] CPU --> CUDA_COMB style D fill:#666 style CUDA fill:#9c27b0 style R fill:#2196f3 style GPU fill:#4caf50 style CUDA_COMB fill:#ff9800
graph LR NV["NVIDIA Control Panel"] --> DEV["Developer\nsection"] DEV --> COUNTERS["Manage GPU\nPerformance Counters"] COUNTERS --> ALLOW["Allow access for\nall users"] ALLOW --> REBOOT["Reboot ๐"] style NV fill:#9c27b0 style DEV fill:#2196f3 style COUNTERS fill:#ff9800 style ALLOW fill:#4caf50 style REBOOT fill:#f44336
graph TB subgraph Host["Host Memory"] HF["edges_flat: Vec<i32>\n[n_edges ร 2]"] HFW["weights_flat: Vec<f32>\n[n_vertices]"] HFS["seeds: Vec<u64>\n[num_trials]"] HFC["covers_host: Vec<u32>\n[num_trials ร num_words]"] HFC2["costs_host: Vec<f32>\n[num_trials]"] end subgraph Device["Device Memory"] DF["d_edges: CudaSlice<i32>"] DFW["d_weights: CudaSlice<f32>"] DFS["d_seeds: CudaSlice<u64>"] DFC["d_covers: CudaSlice<u32>"] DFC2["d_costs: CudaSlice<f32>"] end HF -->|"htod_copy()"| DF HFW -->|"htod_copy()"| DFW HFS -->|"htod_copy()"| DFS HFC -->|"htod_copy()"| DFC DFC2 -.->|"alloc_zeros()"| Device DFC -->|"dtoh_sync_copy()"| HFC DFC2 -->|"dtoh_sync_copy()"| HFC2 style Host fill:#4caf50 style Device fill:#9c27b0
graph LR P["๐ Python\nNumba CUDA\nrand_cover_gpu.py"] R["๐ฆ Rust\ncudarc\nrand_cover_gpu.rs"] CUDA["๐ฎ CUDA C\npitt_kernel\n(embedded &str)"] NVRTC["๐ NVRTC\ncompile_ptx()"] PROFILE["๐ ncu\nNsight Compute"] TEST["โ 6 GPU tests\npassing"] P -->|"port"| R R --> CUDA CUDA --> NVRTC NVRTC --> PROFILE PROFILE --> TEST style P fill:#4caf50,color:#fff style R fill:#2196f3,color:#fff style CUDA fill:#9c27b0,color:#fff style NVRTC fill:#ff9800,color:#fff style PROFILE fill:#00bcd4,color:#fff style TEST fill:#4caf50,color:#fff