1 extern __shared__ volatile double sData[];
3 selectInVar(int m, int n, double *c, double *AN, uint pitchAN,
4 uint *resIdx, double *resVal) {
5 uint i, maxIdx = -1, bid = blockIdx.x;
6 double val, locSum, xScore, maxScore = 0.0;
7 while (bid < n) { // Processing multiple columns
10 if (isPotentialEnteringVar(bid)) { // Do the local processing
11 while (i < m) { // Each thread processes multiple elements
12 val = AN[i+bid*pitchAN];
16 // Reduce the value using shared memory
18 if (tid == 0){ // Is this the best variable encountered ?
19 // on tid=0 locSum equals the steepest edge coeffcient
20 xScore = cVal*rsqrt(locSum);
21 if (fabs(maxScore) < fabs(xScore)) {
30 // Write the result into global memory
32 resIdx[blockIdx.x] = maxIdx;
33 resVal[blockIdx.x] = maxScore;