I have a CUDA kernel that computes the Page Ranks using a Push-based traversal. I am trying to convert it to one that follows a Pull-based traversal strategy but I am always getting wrong results. What am I doing wrong? (Assume for simplicity that this is an undirected graph)
This is the CUDA kernel that does the Push-based Page rank:
__global__ void pr_kernel(unsigned int numNodes,
unsigned int from,
unsigned long numPartitionedEdges,
unsigned int *activeNodes,
unsigned long *activeNodesPointer,
OutEdge *edgeList,
unsigned int *outDegree,
float *dist,
float *delta,
float acc)
{
unsigned int tId = blockDim.x * blockIdx.x + threadIdx.x;
if(tId < numNodes)
{
unsigned int id = activeNodes[from + tId];
unsigned int degree = outDegree[id];
float thisDelta = delta[id];
if(thisDelta > acc)
{
dist[id] += thisDelta;
if(degree != 0)
{
float sourcePR = ((float) thisDelta / degree) * 0.85;
unsigned long thisfrom = activeNodesPointer[from+tId]-numPartitionedEdges;
unsigned long thisto = thisfrom + degree;
for(unsigned long i=thisfrom; i<thisto; i++)
{
atomicAdd(&delta[edgeList[i].end], sourcePR);
}
}
atomicAdd(&delta[id], -thisDelta);
}
}
}
And the following is my version of Pull-based Page-rank (which is giving wrong results):
__global__ void pr_pull(unsigned int numNodes,
unsigned int from,
unsigned long numPartitionedEdges,
unsigned int *activeNodes,
unsigned long *activeNodesPointer,
OutEdge *edgeList,
unsigned int *outDegree,
float *dist,
float *delta,
float acc)
{
unsigned int tId = blockDim.x * blockIdx.x + threadIdx.x;
if(tId < numNodes)
{
unsigned int id = activeNodes[from + tId];
unsigned int degree = outDegree[id];
float thisDelta = delta[id];
if(thisDelta > acc)
{
float receivedPR = thisDelta * 0.85;
unsigned long thisfrom = activeNodesPointer[from+tId]-numPartitionedEdges;
unsigned long thisto = thisfrom + degree;
for(unsigned long i=thisfrom; i<thisto; i++)
{
delta[id] += ((float)receivedPR / outDegree[edgeList[i].end]);
}
dist[id] += thisDelta;
delta[id] -= thisDelta;
}
}
}
Implementation of pr_kernel is taken from Subway