From 6c831c1ca21a771e5611598e82e0ca53fef15524 Mon Sep 17 00:00:00 2001
From: Claudio Gheller <cgheller@login01.m100.cineca.it>
Date: Thu, 18 Nov 2021 10:11:15 +0100
Subject: [PATCH] bug fix on nbucket

---
 phase_correction.cu | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/phase_correction.cu b/phase_correction.cu
index 4c26890..64e47ba 100644
--- a/phase_correction.cu
+++ b/phase_correction.cu
@@ -26,7 +26,7 @@ __global__ void phase_g(int xaxis,
 	double add_term_real;
 	double add_term_img;
 	double wterm;
-	long arraysize = (long)((xaxis*yaxis*num_w_planes)/nbucket + 1);
+	long arraysize = (long)((xaxis*yaxis*num_w_planes)/nbucket);
 
 	if(gid < arraysize)
 	{
@@ -95,7 +95,8 @@ void phase_correction(double* gridss, double* image_real, double* image_imag, in
 
 #ifdef __CUDACC__
 
-	int nbucket = 32;
+	// WARNING: nbucket MUST be chosen such that xaxis*yaxis*num_w_planes is a multiple of nbucket
+	int nbucket = 1;
         int Nth = NTHREADS;
         long Nbl = (long)((num_w_planes*xaxis*yaxis)/Nth/nbucket) + 1;
         if(NWORKERS == 1) {Nbl = 1; Nth = 1;};
-- 
GitLab