X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/book_gpu.git/blobdiff_plain/88ce161b6f410c4d12b011560d4be74f23c4c471..a2aa3f0f91a668ee6e799bad0f4de90b7b2be452:/BookGPU/Chapters/chapter11/code1.cu?ds=sidebyside diff --git a/BookGPU/Chapters/chapter11/code1.cu b/BookGPU/Chapters/chapter11/code1.cu index 3b77cc2..5598fcc 100644 --- a/BookGPU/Chapters/chapter11/code1.cu +++ b/BookGPU/Chapters/chapter11/code1.cu @@ -1,7 +1,6 @@ template -__global__ void CalculateCoefficientsKnots( Tx *u, Ty *v, double *b, double *c, - double *t, double *alpha, double *beta, double *gamma, int N ) +__global__ void CalculateCoefficientsKnots( Tx *u, Ty *v, double *b, double *c, double *t, double *alpha, double *beta, double *gamma, int N ) { int tid = threadIdx.x + blockIdx.x * blockDim.x; int s = tid*2; @@ -25,12 +24,13 @@ __global__ void CalculateCoefficientsKnots( Tx *u, Ty *v, double *b, double *c, else h[s+1]=0.5*(u[tid+1] + u[tid]); //calculate coefficients - double dtemp = (2*b[tid] - c[tid+1])+((c[tid+1] - c[tid])*(h[s+1] - u[tid]))/fmax(1e-10,(u[tid+1] - u[tid])); + double dtemp = (2*b[tid] - c[tid+1])+((c[tid+1] - c[tid])* + (h[s+1] - u[tid]))/ fmax(1e-10,(u[tid+1] - u[tid])); alpha[s]=v[tid]; beta[s]=c[tid]; gamma[s]=(dtemp - c[tid])/(2*fmax(1e-10,(h[s+1] - u[tid]))); alpha[s+1]=v[tid] + c[tid]*(h[s+1] - u[tid]) + (dtemp - c[tid])*(h[s+1] - u[tid])/2; - gamma[s+1]=(c[tid+1] - dtemp)/(2*fmax(1e-10,(u[tid+1] - h[s+1]))); + gamma[s+1]=(c[tid+1]-dtemp)/(2*fmax(1e-10,(u[tid+1]-h[s+1]))); beta[s+1]=dtemp; } tid += blockDim.x * gridDim.x; s = tid*2;