Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final changes #5

Merged
merged 1 commit into from
Nov 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 7 additions & 30 deletions parallel-edge.cu
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ __global__ void betweennessCentralityKernel(Graph *graph, float *bwCentrality, i

if(idx == 0) {
s = -1;
printf("Progress... %3d%%", 0);
// printf("Progress... %3d%%", 0);
}
__syncthreads();

Expand All @@ -81,14 +81,13 @@ __global__ void betweennessCentralityKernel(Graph *graph, float *bwCentrality, i
if (idx == 0)
{
++s;
printf("\rProgress... %5.2f%%", (s+1)*100.0/nodeCount);
// printf("\rProgress... %5.2f%%", (s+1)*100.0/nodeCount);
done = false;
current_depth = -1;
}
__syncthreads();


//Initialize distance and sigma
for (int i = idx; i < nodeCount; i += blockDim.x)
{
if (i == s)
Expand All @@ -108,7 +107,6 @@ __global__ void betweennessCentralityKernel(Graph *graph, float *bwCentrality, i

while (!done)
{
// TODO: Check if Needed
__syncthreads();

if (threadIdx.x == 0){
Expand All @@ -117,8 +115,8 @@ __global__ void betweennessCentralityKernel(Graph *graph, float *bwCentrality, i
done = true;
__syncthreads();

//TODO: Check if 2*graph->edgeCount + 1
for (int i = idx; i < (2*(graph->edgeCount)); i += blockDim.x) //For each edge...

for (int i = idx; i < (2*(graph->edgeCount)); i += blockDim.x)
{
int v = graph->edgeList1[i];
if (distance[v] == current_depth)
Expand All @@ -139,11 +137,6 @@ __global__ void betweennessCentralityKernel(Graph *graph, float *bwCentrality, i
}

__syncthreads();
// if(idx == 0){
// for(int w=0; w<nodeCount; ++w)
// printf("Root %d : BC[%d] = %f\n", s, w, bwCentrality[w]);
// printf("\n===========================\n");
// }


// Reverse BFS
Expand All @@ -154,7 +147,7 @@ __global__ void betweennessCentralityKernel(Graph *graph, float *bwCentrality, i
}
__syncthreads();

for (int i = idx; i < (2*(graph->edgeCount)); i += blockDim.x) //For each edge...
for (int i = idx; i < (2*(graph->edgeCount)); i += blockDim.x)
{
int v = graph->edgeList1[i];
if(distance[v] == current_depth)
Expand All @@ -166,36 +159,20 @@ __global__ void betweennessCentralityKernel(Graph *graph, float *bwCentrality, i
{
if (sigma[w] != 0) {
atomicAdd(dependency + v, (sigma[v] * 1.0 / sigma[w]) * (1 + dependency[w]));
// printf("v: %d, w: %d, sv: %d, sw: %d, dep[w]: %f\n", v, w, sigma[v], sigma[w], dependency[w]);
}
// dependency[v] += (sigma[v] * 1.0 / sigma[w]) * (1 + dependency[w]);

}
// }
// if (v != s)
// {
// // Each shortest path is counted twice. So, each partial shortest path dependency is halved.
// atomicAdd(bwCentrality + v, dependency[v] / 2);
// // bwCentrality[v] += dependency[v] / 2;
// }

}
}
__syncthreads();


// __syncthreads();
// if(idx == 0){
// for(int w=0; w<nodeCount; ++w)
// printf("Root %d : dep[%d] = %f\n", s, w, dependency[w]);
// printf("\n===========================\n");
// }
}

for(int v=idx; v<nodeCount; v+=blockDim.x){
if (v != s)
{
// Each shortest path is counted twice. So, each partial shortest path dependency is halved.
bwCentrality[v] += dependency[v] / 2;
// printf("")
}
}
__syncthreads();
Expand Down
14 changes: 6 additions & 8 deletions parallel-vertex.cu
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ __global__ void betweennessCentralityKernel(Graph *graph, double *bwCentrality,

if(idx == 0) {
s = -1;
printf("Progress... %3d%%", 0);
// printf("Progress... %3d%%", 0);
}
__syncthreads();

Expand All @@ -76,13 +76,12 @@ __global__ void betweennessCentralityKernel(Graph *graph, double *bwCentrality,
if(idx == 0)
{
++s;
printf("\rProgress... %5.2f%%", (s+1)*100.0/nodeCount);
// printf("\rProgress... %5.2f%%", (s+1)*100.0/nodeCount);
done = false;
current_depth = -1;
}
__syncthreads();

//Initialize distance and sigma
for(int v=idx; v<nodeCount; v+=blockDim.x)
{
if(v == s)
Expand All @@ -99,9 +98,8 @@ __global__ void betweennessCentralityKernel(Graph *graph, double *bwCentrality,
}
__syncthreads();

// Calculate the number of shortest paths and the
// distance from s (the root) to each vertex


// BFS
while(!done)
{
if(idx == 0){
Expand All @@ -110,7 +108,7 @@ __global__ void betweennessCentralityKernel(Graph *graph, double *bwCentrality,
done = true;
__syncthreads();

for(int v=idx; v<nodeCount; v+=blockDim.x) //For each vertex...
for(int v=idx; v<nodeCount; v+=blockDim.x)
{
if(distance[v] == current_depth)
{
Expand Down Expand Up @@ -140,7 +138,7 @@ __global__ void betweennessCentralityKernel(Graph *graph, double *bwCentrality,
}
__syncthreads();

for(int v=idx; v<nodeCount; v+=blockDim.x) //For each vertex...
for(int v=idx; v<nodeCount; v+=blockDim.x)
{
if(distance[v] == current_depth)
{
Expand Down
Loading