Skip to main content

gpu_pagerank

Function gpu_pagerank 

Source
pub async fn gpu_pagerank(
    device: &GpuDevice,
    buffers: &GpuCsrBuffers,
    out_degrees: &[u32],
    max_iterations: usize,
    damping: f32,
) -> Result<GpuPageRankResult>
Expand description

Run GPU PageRank algorithm

§Arguments

  • device - GPU device
  • buffers - CSR graph buffers
  • out_degrees - Out-degree for each node (computed from CSR)
  • max_iterations - Maximum number of iterations (typically 20)
  • damping - Damping factor (typically 0.85)

§Errors

Returns error if:

  • GPU shader compilation fails
  • Buffer creation fails
  • Shader dispatch fails
  • Result readback fails

§Example

let device = GpuDevice::new().await?;
let mut graph = CsrGraph::new();
// ... add edges ...

let buffers = GpuCsrBuffers::from_csr_graph(&device, &graph)?;
let out_degrees: Vec<u32> = (0..graph.num_nodes())
    .map(|i| graph.outgoing_neighbors(i).len() as u32)
    .collect();
let result = gpu_pagerank(&device, &buffers, &out_degrees, 20, 0.85).await?;

println!("Node 0 score: {:?}", result.score(0));