X-Git-Url: http://git.euphorik.ch/?p=GPU.git;a=blobdiff_plain;f=WCudaMSE%2FStudent_Cuda%2Fsrc%2Fcpp%2Fcore%2F01c_Saucisson%2FSaucisson.cu;h=4d887a9f80bcdd30bdc74f0f76b8dd1f64f22b6f;hp=3ec1cd35faccad8a34b19cf19d61e98c7682d0c5;hb=6664817ed89b0b616044da35a3eb8f715e0813d9;hpb=ee885ed84f2ff3d5fb1e7ac41fa3c8879314ee36 diff --git a/WCudaMSE/Student_Cuda/src/cpp/core/01c_Saucisson/Saucisson.cu b/WCudaMSE/Student_Cuda/src/cpp/core/01c_Saucisson/Saucisson.cu index 3ec1cd3..4d887a9 100644 --- a/WCudaMSE/Student_Cuda/src/cpp/core/01c_Saucisson/Saucisson.cu +++ b/WCudaMSE/Student_Cuda/src/cpp/core/01c_Saucisson/Saucisson.cu @@ -27,7 +27,7 @@ void reductionIntraThread(int n, float deltaX, float* tabSM) { const float i = s + 1; const float xi = -1 + i * deltaX; - threadResult += sqrtf(1-xi*xi); + threadResult += sqrtf(1 - xi * xi); s += NB_THREAD; } @@ -78,7 +78,7 @@ void reductionInterBlock(float* tabSM, float* ptrResult) const int TID_LOCAL = Indice1D::tidLocal(); if (TID_LOCAL == 0) { - atomicAdd(ptrResult, float(tabSM[0])); + atomicAdd(ptrResult, tabSM[0]); } } @@ -107,13 +107,13 @@ void saucisson(int n, float deltaX, float* ptrResult) bool saucisson() { - cout << "saucisson() ..." << endl; + cout << endl << "saucisson() ..." << endl; // Nombre d'échantillon. Au-delà, la qualité du résultat n'est pas meilleure. Il faudrait employé des doubles à la place de floats. const int N = 100000; // Allocation coté GPU en global memory (GM). - float* ptrDevResult = 0; + float* ptrDevResult; HANDLE_ERROR(cudaMalloc(&ptrDevResult, sizeof(float))); HANDLE_ERROR(cudaMemset(ptrDevResult, 0, sizeof(float)));