]> AND Private Git Repository - book_gpu.git/blobdiff - BookGPU/Chapters/chapter10/optiSE.cu
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
new
[book_gpu.git] / BookGPU / Chapters / chapter10 / optiSE.cu
index 9033d98cef1c1faaa9f06394cd4bb9c83cb8f808..e6761902ddc9ee356dd81f8e509bde423274f00f 100644 (file)
@@ -1,24 +1,24 @@
 extern __shared__ volatile double sData[];
 __global__ void
 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;
        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;
                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;
                        }
                                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);
                        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); 
                                xScore = cVal*rsqrt(locSum); 
-                               if(fabs(maxScore) < fabs(xScore)){
+                               if (fabs(maxScore) < fabs(xScore)) {
                                        maxIdx = bid;
                                        maxScore = xScore;
                                }
                                        maxIdx = bid;
                                        maxScore = xScore;
                                }
@@ -28,7 +28,7 @@ selectInVar(int m, int n, double *c, double *AN, uint pitchAN, uint *resIdx, dou
                bid += gridDim.x;
        }
        // Write the result into global memory
                bid += gridDim.x;
        }
        // Write the result into global memory
-       if (tid == 0){
+       if (tid == 0) {
                resIdx[blockIdx.x] = maxIdx;    
                resVal[blockIdx.x] = maxScore;
        }
                resIdx[blockIdx.x] = maxIdx;    
                resVal[blockIdx.x] = maxScore;
        }