"src/vscode:/vscode.git/clone" did not exist on "65f9439b569b1e7e2854cfa0274ee3f7f50b43a0"
Commit 6a01b87b authored by rusty1s's avatar rusty1s
Browse files

rename to degree

parent bef9c595
...@@ -15,20 +15,20 @@ void THCGreedy(THCState *state, THCudaLongTensor *cluster, THCudaLongTensor *row ...@@ -15,20 +15,20 @@ void THCGreedy(THCState *state, THCudaLongTensor *cluster, THCudaLongTensor *row
THCudaLongTensor_fill(state, cluster, -1); THCudaLongTensor_fill(state, cluster, -1);
THCudaLongTensor *prop = THCudaLongTensor_newClone(state, cluster); THCudaLongTensor *prop = THCudaLongTensor_newClone(state, cluster);
THCudaLongTensor *deg = THCudaLongTensor_newWithSize1d(state, nNodes); THCudaLongTensor *degree = THCudaLongTensor_newWithSize1d(state, nNodes);
THCudaLongTensor_degree(state, deg, row); THCudaLongTensor_degree(state, degree, row);
THCudaLongTensor *cumDeg = THCudaLongTensor_newWithSize1d(state, nNodes); THCudaLongTensor *cumDegree = THCudaLongTensor_newWithSize1d(state, nNodes);
THCudaLongTensor_cumsum(state, cumDeg, deg, 0); THCudaLongTensor_cumsum(state, cumDegree, degree, 0);
while(!THCGreedy_assignColor(state, cluster)) { while(!THCGreedy_assignColor(state, cluster)) {
THCGreedy_propose(state, cluster, prop, row, col, deg, cumDeg); THCGreedy_propose(state, cluster, prop, row, col, degree, cumDegree);
THCGreedy_response(state, cluster, prop, row, col, deg, cumDeg); THCGreedy_response(state, cluster, prop, row, col, degree, cumDegree);
}; };
THCudaLongTensor_free(state, prop); THCudaLongTensor_free(state, prop);
THCudaLongTensor_free(state, deg); THCudaLongTensor_free(state, degree);
THCudaLongTensor_free(state, cumDeg); THCudaLongTensor_free(state, cumDegree);
} }
#include "generic/THCGreedy.cu" #include "generic/THCGreedy.cu"
......
#include "common.cuh" #include "common.cuh"
__global__ void proposeKernel(int64_t *color, int64_t *prop, int64_t *row, int64_t *col, __global__ void proposeKernel(int64_t *color, int64_t *prop, int64_t *row, int64_t *col,
int64_t *deg, int64_t *cumDeg, ptrdiff_t nNodes) { int64_t *degree, int64_t *cumDegree, ptrdiff_t nNodes) {
KERNEL_LOOP(i, nNodes) { KERNEL_LOOP(i, nNodes) {
if (color[i] != -1) continue; // Only visit blue nodes. if (color[i] != -1) continue; // Only visit blue nodes.
ptrdiff_t c; ptrdiff_t c;
for (ptrdiff_t e = cumDeg[i] - deg[i]; e < cumDeg[i]; e++) { for (ptrdiff_t e = cumDegree[i] - degree[i]; e < cumDegree[i]; e++) {
c = col[e]; c = col[e];
if (color[c] == -2) { // Red neighbor found. if (color[c] == -2) { // Red neighbor found.
prop[i] = c; // Propose! prop[i] = c; // Propose neighbor.
break; break;
} }
} }
...@@ -17,14 +17,10 @@ __global__ void proposeKernel(int64_t *color, int64_t *prop, int64_t *row, int64 ...@@ -17,14 +17,10 @@ __global__ void proposeKernel(int64_t *color, int64_t *prop, int64_t *row, int64
} }
void THCGreedy_propose(THCState *state, THCudaLongTensor *color, THCudaLongTensor *prop, void THCGreedy_propose(THCState *state, THCudaLongTensor *color, THCudaLongTensor *prop,
THCudaLongTensor *row, THCudaLongTensor *col, THCudaLongTensor *deg, THCudaLongTensor *row, THCudaLongTensor *col, THCudaLongTensor *degree,
THCudaLongTensor *cumDeg) { THCudaLongTensor *cumDegree) {
ptrdiff_t nNodes = THCudaLongTensor_nElement(state, color); KERNEL_RUN(proposeKernel, THCudaLongTensor_nElement(state, color),
int64_t *colorData = THCudaLongTensor_data(state, color); THCudaLongTensor_data(state, color), THCudaLongTensor_data(state, prop),
int64_t *propData = THCudaLongTensor_data(state, prop); THCudaLongTensor_data(state, row), THCudaLongTensor_data(state, col),
int64_t *rowData = THCudaLongTensor_data(state, row); THCudaLongTensor_data(state, degree), THCudaLongTensor_data(state, cumDegree))
int64_t *colData = THCudaLongTensor_data(state, col);
int64_t *degData = THCudaLongTensor_data(state, deg);
int64_t *cumDegData = THCudaLongTensor_data(state, cumDeg);
KERNEL_RUN(proposeKernel, nNodes, colorData, propData, rowData, colData, degData, cumDegData);
} }
#include "common.cuh" #include "common.cuh"
__global__ void responseKernel(int64_t *color, int64_t *prop, int64_t *row, int64_t *col, __global__ void responseKernel(int64_t *color, int64_t *prop, int64_t *row, int64_t *col,
int64_t *deg, int64_t *cumDeg, ptrdiff_t nNodes) { int64_t *degree, int64_t *cumDegree, ptrdiff_t nNodes) {
KERNEL_LOOP(i, nNodes) { KERNEL_LOOP(i, nNodes) {
if (color[i] != -2) continue; // Only visit red nodes. if (color[i] != -2) continue; // Only visit red nodes.
ptrdiff_t c; int64_t neighborColor, minValue; ptrdiff_t c; int64_t neighborColor, minValue;
bool isDead = true; bool isDead = true;
for (ptrdiff_t e = cumDeg[i] - deg[i]; e < cumDeg[i]; e++) { for (ptrdiff_t e = cumDegree[i] - degree[i]; e < cumDegree[i]; e++) {
c = col[e]; c = col[e];
neighborColor = color[c]; neighborColor = color[c];
if (neighborColor == -1 && prop[c] == i) { // Blue neighbor found which proposed to node i. if (neighborColor == -1 && prop[c] == i) { // Blue neighbor found which proposed to node i.
...@@ -22,14 +22,10 @@ __global__ void responseKernel(int64_t *color, int64_t *prop, int64_t *row, int6 ...@@ -22,14 +22,10 @@ __global__ void responseKernel(int64_t *color, int64_t *prop, int64_t *row, int6
} }
void THCGreedy_response(THCState *state, THCudaLongTensor *color, THCudaLongTensor *prop, void THCGreedy_response(THCState *state, THCudaLongTensor *color, THCudaLongTensor *prop,
THCudaLongTensor *row, THCudaLongTensor *col, THCudaLongTensor *deg, THCudaLongTensor *row, THCudaLongTensor *col, THCudaLongTensor *degree,
THCudaLongTensor *cumDeg) { THCudaLongTensor *cumDegree) {
ptrdiff_t nNodes = THCudaLongTensor_nElement(state, color); KERNEL_RUN(responseKernel, THCudaLongTensor_nElement(state, color),
int64_t *colorData = THCudaLongTensor_data(state, color); THCudaLongTensor_data(state, color), THCudaLongTensor_data(state, prop),
int64_t *propData = THCudaLongTensor_data(state, prop); THCudaLongTensor_data(state, row), THCudaLongTensor_data(state, col),
int64_t *rowData = THCudaLongTensor_data(state, row); THCudaLongTensor_data(state, degree), THCudaLongTensor_data(state, cumDegree))
int64_t *colData = THCudaLongTensor_data(state, col);
int64_t *degData = THCudaLongTensor_data(state, deg);
int64_t *cumDegData = THCudaLongTensor_data(state, cumDeg);
KERNEL_RUN(responseKernel, nNodes, colorData, propData, rowData, colData, degData, cumDegData);
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment