X-Git-Url: https://bilbo.iut-bm.univ-fcomte.fr/and/gitweb/book_gpu.git/blobdiff_plain/1a01129f963257afbf1ca4effbb4e6e1f378cefa..refs/heads/master:/BookGPU/Chapters/chapter11/code4.cu diff --git a/BookGPU/Chapters/chapter11/code4.cu b/BookGPU/Chapters/chapter11/code4.cu index 6eb646d..2a091d3 100644 --- a/BookGPU/Chapters/chapter11/code4.cu +++ b/BookGPU/Chapters/chapter11/code4.cu @@ -1,9 +1,11 @@ template -__device__ Tx Aver(Tx z,int i,int j, Tx *z) {return (z-z[j+1])/(j-i+1);} +__device__ Tx Aver(Tx z,int i,int j, Tx *z) + { return (z-z[j+1])/(j-i+1); } template __global__ void monotonizekernel(Tx *y, Tx *z, Tx *u, int *key, int n) -{ int i = threadIdx.x + blockIdx.x * blockDim.x; +{ + int i = threadIdx.x + blockIdx.x * blockDim.x; if(i -void MonotonizeData(Tx *y, int n, Tx *u) { +void MonotonizeData(Tx *y, int n, Tx *u) +{ thrust::less_equal binary_pred; thrust::maximum binary_op2; thrust::device_vector z_d(n+1); @@ -35,9 +38,9 @@ void MonotonizeData(Tx *y, int n, Tx *u) { thrust::fill(u_d, u_d+n, -1e100); thrust::fill(keys_d.begin(), keys_d.end(), 0); - thrust::reverse_iterator< typename thrust::device_vector::iterator > y_reverse_b(y_d+n), y_reverse_end(y_d), z_reverse_b(z_d.end()); + thrust::reverse_iterator< typename thrust::device_vector::iterator> y_reverse_b(y_d+n), y_reverse_end(y_d), z_reverse_b(z_d.end()); - thrust::inclusive_scan(y_reverse_b, y_reverse_end, z_reverse_b+1); + thrust::inclusive_scan(y_reverse_b,y_reverse_end,z_reverse_b+1); monotonizekernel<<>>(y, thrust::raw_pointer_cast(&z_d[0]), u, thrust::raw_pointer_cast(&keys_d[0]), n );