Index: TrouNoir.py
===================================================================
--- TrouNoir.py	(revision 218)
+++ TrouNoir.py	(revision 219)
@@ -806,10 +806,14 @@
                       float ExternalRadius,float Angle,
                       int Line)
 {
-  uint xi=(uint)blockIdx.x;
-  uint yi=(uint)blockIdx.y;
-  uint sizex=(uint)gridDim.x*blockDim.x;
-  uint sizey=(uint)gridDim.y*blockDim.y;
+   uint xi=(uint)(blockIdx.x*blockDim.x+threadIdx.x);
+   uint yi=(uint)(blockIdx.y*blockDim.y+threadIdx.y);
+   uint sizex=(uint)gridDim.x*blockDim.x;
+   uint sizey=(uint)gridDim.y*blockDim.y;
+//  uint xi=(uint)blockIdx.x;
+//  uint yi=(uint)blockIdx.y;
+//  uint sizex=(uint)gridDim.x*blockDim.x;
+//  uint sizey=(uint)gridDim.y*blockDim.y;
 
   // Perform trajectory for each pixel
 
@@ -892,14 +896,24 @@
                        int Line)
 {
    // Integer Impact Parameter ID 
-   int bi=blockIdx.x;
+   int bi=blockIdx.x*blockDim.x+threadIdx.x;
    // Integer points on circle
-   int i=blockIdx.y;
+   int i=blockIdx.y*blockDim.y+threadIdx.y;
    // Integer Impact Parameter Size (half of image)
    int bmaxi=gridDim.x*blockDim.x;
    // Integer Points on circle
    int imx=gridDim.y*blockDim.y;
 
+
+   // Integer Impact Parameter ID 
+//   int bi=blockIdx.x;
+   // Integer points on circle
+//   int i=blockIdx.y;
+   // Integer Impact Parameter Size (half of image)
+//   int bmaxi=gridDim.x*blockDim.x;
+   // Integer Points on circle
+//   int imx=gridDim.y*blockDim.y;
+
    // Perform trajectory for each pixel
 
   float m,rs,ri,re,tho;
@@ -971,7 +985,8 @@
                            int Line)
 {
   // Integer Impact Parameter ID 
-  int bi=blockIdx.x;
+  //  int bi=blockIdx.x;
+  int bi=blockIdx.x*blockDim.x+threadIdx.x;
   // Integer Impact Parameter Size (half of image)
   int bmaxi=gridDim.x*blockDim.x;
 
@@ -1182,8 +1197,8 @@
 
     zMaxPosition=numpy.where(zImage[:,:]==zImage.max())
     fMaxPosition=numpy.where(fImage[:,:]==fImage.max())
-    print("Z max @(%i,%i) : %f" % (zMaxPosition[0][0],zMaxPosition[1][0],zImage.max()))
-    print("Flux max @(%i,%i) : %f\n" % (fMaxPosition[0][0],fMaxPosition[1][0],fImage.max()))
+    print("Z max @(%i,%i) : %f" % (zMaxPosition[1][0],zMaxPosition[0][0],zImage.max()))
+    print("Flux max @(%i,%i) : %f\n" % (fMaxPosition[1][0],fMaxPosition[0][0],fImage.max()))
     zImageCL.release()
     fImageCL.release()
 
@@ -1268,7 +1283,8 @@
                     numpy.float32(ExternalRadius),
                     numpy.float32(Angle),
                     numpy.int32(Line),
-                    grid=(zImage.shape[0]/32,zImage.shape[1]/32),block=(32,32,1))
+                    grid=(zImage.shape[0]/32,zImage.shape[1]/32),
+                    block=(32,32,1))
     elif Method=='TrajectoCircle':
         TrajectoryCU(TrajectoriesCU,IdLastCU,
                      numpy.uint32(Trajectories.shape[1]),
@@ -1277,7 +1293,8 @@
                      numpy.float32(ExternalRadius),
                      numpy.float32(Angle),
                      numpy.int32(Line),
-                     grid=(Trajectories.shape[0],1),block=(1,1,1))
+                     grid=(Trajectories.shape[0]/32,1),
+                     block=(32,1,1))
         
         CircleCU(TrajectoriesCU,IdLastCU,zImageCU,fImageCU,
                  numpy.uint32(Trajectories.shape[1]),
@@ -1286,7 +1303,8 @@
                  numpy.float32(ExternalRadius),
                  numpy.float32(Angle),
                  numpy.int32(Line),
-                 grid=(Trajectories.shape[0],zImage.shape[0]*4),block=(1,1,1))
+                 grid=(Trajectories.shape[0]/32,zImage.shape[0]*4/32),
+                 block=(32,32,1))
     else:
         TrajectoryCU(TrajectoriesCU,IdLastCU,
                      numpy.uint32(Trajectories.shape[1]),
@@ -1295,7 +1313,8 @@
                      numpy.float32(ExternalRadius),
                      numpy.float32(Angle),
                      numpy.int32(Line),
-                     grid=(Trajectories.shape[0],1),block=(1,1,1))
+                     grid=(Trajectories.shape[0]/32,1),
+                     block=(32,1,1))
         
         PixelCU(zImageCU,fImageCU,TrajectoriesCU,IdLastCU,
                 numpy.uint32(Trajectories.shape[0]),
@@ -1305,7 +1324,8 @@
                 numpy.float32(ExternalRadius),
                 numpy.float32(Angle),
                 numpy.int32(Line),
-                grid=(zImage.shape[0],zImage.shape[1],1),block=(1,1,1))
+                grid=(zImage.shape[0]/32,zImage.shape[1]/32,1),
+                block=(32,32,1))
     
 
     compute = time.time()-start_time
@@ -1318,8 +1338,8 @@
 
     zMaxPosition=numpy.where(zImage[:,:]==zImage.max())
     fMaxPosition=numpy.where(fImage[:,:]==fImage.max())
-    print("Z max @(%i,%i) : %f" % (zMaxPosition[0][0],zMaxPosition[1][0],zImage.max()))
-    print("Flux max @(%i,%i) : %f\n" % (fMaxPosition[0][0],fMaxPosition[1][0],fImage.max()))
+    print("Z max @(%i,%i) : %f" % (zMaxPosition[1][0],zMaxPosition[0][0],zImage.max()))
+    print("Flux max @(%i,%i) : %f\n" % (fMaxPosition[1][0],fMaxPosition[0][0],fImage.max()))
 
     Context.pop()
     
