X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/book_gpu.git/blobdiff_plain/d74981733767eca78dbbe5be810b9b2e239e8aee..cdcc8368664a64aed4169db27a06df9d0c9d6527:/BookGPU/Chapters/chapter10/optiSE.cu diff --git a/BookGPU/Chapters/chapter10/optiSE.cu b/BookGPU/Chapters/chapter10/optiSE.cu index 9033d98..e676190 100644 --- a/BookGPU/Chapters/chapter10/optiSE.cu +++ b/BookGPU/Chapters/chapter10/optiSE.cu @@ -1,24 +1,24 @@ 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; } @@ -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 - if (tid == 0){ + if (tid == 0) { resIdx[blockIdx.x] = maxIdx; resVal[blockIdx.x] = maxScore; }