Commit 69f59517 authored by rusty1s's avatar rusty1s
Browse files

graclus gpu done

parent 8c15ed64
...@@ -22,14 +22,10 @@ void THCTensor_graclus(THCState *state, THCudaLongTensor *self, THCudaLongTensor ...@@ -22,14 +22,10 @@ void THCTensor_graclus(THCState *state, THCudaLongTensor *self, THCudaLongTensor
THCudaLongTensor *cumDegree = THCudaLongTensor_newWithSize1d(state, nNodes); THCudaLongTensor *cumDegree = THCudaLongTensor_newWithSize1d(state, nNodes);
THCudaLongTensor_cumsum(state, cumDegree, degree, 0); THCudaLongTensor_cumsum(state, cumDegree, degree, 0);
THCTensor_color(state, self); while(!THCTensor_color(state, self)) {
THCTensor_propose(state, self, prop, row, col, degree, cumDegree); THCTensor_propose(state, self, prop, row, col, degree, cumDegree);
THCTensor_response(state, self, prop, row, col, degree, cumDegree); THCTensor_response(state, self, prop, row, col, degree, cumDegree);
};
/* while(!THCTensor_assignColor(state, self)) { */
/* THCTensor_propose(state, self, prop, row, col, degree, cumDegree); */
/* THCTensor_response(state, self, prop, row, col, degree, cumDegree); */
/* }; */
THCudaLongTensor_free(state, prop); THCudaLongTensor_free(state, prop);
THCudaLongTensor_free(state, degree); THCudaLongTensor_free(state, degree);
......
...@@ -16,20 +16,18 @@ __global__ void responseKernel(int64_t *color, int64_t *prop, int64_t *row, int6 ...@@ -16,20 +16,18 @@ __global__ void responseKernel(int64_t *color, int64_t *prop, int64_t *row, int6
int64_t *degree, int64_t *cumDegree, 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 = cumDegree[i] - degree[i]; e < cumDegree[i]; e++) { for (ptrdiff_t e = cumDegree[i] - degree[i]; e < cumDegree[i]; e++) {
/* c = col[e]; */ c = col[e];
/* neighborColor = color[c]; */ if (isDead && color[c] < 0) { isDead = false; } // Unmatched neighbor found.
/* if (neighborColor == -1 && prop[c] == i) { // Blue neighbor found which proposed to node i. */ if (color[c] == -1 && prop[c] == i) { // Match first blue neighbor who proposed to i.
/* minValue = min(i, c); */ color[i] = min(i, c);
/* color[i] = minValue; */ color[c] = min(i, c);
/* color[c] = minValue; */ break;
/* break; */ }
/* } */
/* if (neighborColor < 0) isDead = false; */
} }
/* if (isDead && color[i] < 0) color[i] = i; // Mark node as dead. */ if (isDead) { color[i] = i; } // Mark node as dead.
} }
} }
......
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