1 extern __shared__ volatile double sData[];
3 selectInVar(int m, int n, double *c, double *AN, uint pitchAN, 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 column
10 if(isPotentialEnteringVar(bid)){ // Do the local processing
11 while(i < m) { // Each thread process multiple elements
12 val = AN[i+bid*pitchAN];
16 // Reduce the value using the shared memory
18 if (tid == 0){ // Is this the best variable encoutered ?
19 // on tid=0 locSum eqals the s.e. 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;