extern __shared__ volatile double sData[];
__global__ void
-selectInVar(int m, int n, double *c, double *AN, uint pitchAN, uint *resIdx, double *resVal)
-{
+selectInVar(int m, int n, double *c, double *AN, uint pitchAN,
+ uint *resIdx, double *resVal) {
uint i, maxIdx = -1, bid = blockIdx.x;
double val, locSum, xScore, maxScore = 0.0;
- while(bid < n){ // Processing multiple column
+ while (bid < n) { // Processing multiple columns
i = threadIdx.x;
locSum = 0.0;
- if(isPotentialEnteringVar(bid)){ // Do the local processing
- while(i < m) { // Each thread process multiple elements
+ if (isPotentialEnteringVar(bid)) { // Do the local processing
+ while (i < m) { // Each thread processes multiple elements
val = AN[i+bid*pitchAN];
locSum += val*val;
i += blockDim.x;
}
- // Reduce the value using the shared memory
+ // Reduce the value using shared memory
reduceSum(locSum);
- if (tid == 0){ // Is this the best variable encoutered ?
- // on tid=0 locSum eqals the s.e. coeffcient
+ if (tid == 0){ // Is this the best variable encountered ?
+ // on tid=0 locSum equals the steepest edge coeffcient
xScore = cVal*rsqrt(locSum);
- if(fabs(maxScore) < fabs(xScore)){
+ if (fabs(maxScore) < fabs(xScore)) {
maxIdx = bid;
maxScore = xScore;
}
bid += gridDim.x;
}
// Write the result into global memory
- if (tid == 0){
+ if (tid == 0) {
resIdx[blockIdx.x] = maxIdx;
resVal[blockIdx.x] = maxScore;
}