Index: PiXpuThreads.py
===================================================================
--- PiXpuThreads.py	(revision 126)
+++ PiXpuThreads.py	(revision 127)
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 
 #
 # Pi-by-MonteCarlo using PyCUDA/PyOpenCL
@@ -33,16 +33,14 @@
 class threadWithReturn(Thread):
     def __init__(self, *args, **kwargs):
         super(threadWithReturn, self).__init__(*args, **kwargs)
-
         self._return = None
 
     def run(self):
-        if self._Thread__target is not None:
-            self._return = self._Thread__target(*self._Thread__args, **self._Thread__kwargs)
+        if self._target is not None:
+            self._return = self._target(*self._args, **self._kwargs)
 
     def join(self, *args, **kwargs):
         super(threadWithReturn, self).join(*args, **kwargs)
-
         return self._return
 
 if __name__=='__main__':
@@ -86,7 +84,7 @@
     try:
         opts, args = getopt.getopt(sys.argv[1:],"hocg:i:b:e:s:f:l:t:r:d:m:v:",["gpustyle=","iterations=","blocksBegin=","blocksEnd=","blocksStep=","threadsFirst=","threadsLast=","threadssTep=","redo=","device=","marsaglia=","valuetype="])
     except getopt.GetoptError:
-        print HowToUse % sys.argv[0]
+        print(HowToUse % sys.argv[0])
         sys.exit(2)
 
     # List of Devices
@@ -95,9 +93,9 @@
         
     for opt, arg in opts:
         if opt == '-h':
-            print HowToUse % sys.argv[0]
+            print(HowToUse % sys.argv[0])
 
-            print "\nInformations about devices detected under OpenCL:"
+            print("\nInformations about devices detected under OpenCL:")
             # For PyOpenCL import
             try:
                 import pyopencl as cl
@@ -105,13 +103,13 @@
                 for platform in cl.get_platforms():
                     for device in platform.get_devices():
                         deviceType=cl.device_type.to_string(device.type)
-                        print "Device #%i from %s of type %s : %s" % (Id,platform.vendor.lstrip(),deviceType,device.name.lstrip())
+                        print("Device #%i from %s of type %s : %s" % (Id,platform.vendor.lstrip(),deviceType,device.name.lstrip()))
                         Id=Id+1
 
                 print
                 sys.exit()
             except ImportError:
-                print "Your platform does not seem to support OpenCL"
+                print("Your platform does not seem to support OpenCL")
         
         elif opt == '-o':
             OutMetrology=True
@@ -143,19 +141,19 @@
         elif opt in ("-r", "--redo"):
             Redo = int(arg)
 
-    print "Devices Identification : %s" % Devices
-    print "GpuStyle used : %s" % GpuStyle
-    print "Iterations : %s" % Iterations
-    print "Number of Blocks on begin : %s" % BlocksBegin
-    print "Number of Blocks on end : %s" % BlocksEnd
-    print "Step on Blocks : %s" % BlocksStep
-    print "Number of Threads on begin : %s" % ThreadsBegin
-    print "Number of Threads on end : %s" % ThreadsEnd
-    print "Step on Threads : %s" % ThreadsStep
-    print "Number of redo : %s" % Redo
-    print "Metrology done out of XPU : %r" % OutMetrology
-    print "Type of Marsaglia RNG used : %s" % RNG
-    print "Type of variable : %s" % ValueType
+    print("Devices Identification : %s" % Devices)
+    print("GpuStyle used : %s" % GpuStyle)
+    print("Iterations : %s" % Iterations)
+    print("Number of Blocks on begin : %s" % BlocksBegin)
+    print("Number of Blocks on end : %s" % BlocksEnd)
+    print("Step on Blocks : %s" % BlocksStep)
+    print("Number of Threads on begin : %s" % ThreadsBegin)
+    print("Number of Threads on end : %s" % ThreadsEnd)
+    print("Step on Threads : %s" % ThreadsStep)
+    print("Number of redo : %s" % Redo)
+    print("Metrology done out of XPU : %r" % OutMetrology)
+    print("Type of Marsaglia RNG used : %s" % RNG)
+    print("Type of variable : %s" % ValueType)
 
     if GpuStyle=='CUDA':
         try:
@@ -165,7 +163,7 @@
             import pycuda.autoinit
             from pycuda.compiler import SourceModule
         except ImportError:
-            print "Platform does not seem to support CUDA"
+            print("Platform does not seem to support CUDA")
 
     if GpuStyle=='OpenCL':
         try:
@@ -175,19 +173,19 @@
             for platform in cl.get_platforms():
                 for device in platform.get_devices():
                     deviceType=cl.device_type.to_string(device.type)
-                    print "Device #%i from %s of type %s : %s" % (Id,platform.vendor.lstrip().rstrip(),deviceType,device.name.lstrip().rstrip())
+                    print("Device #%i from %s of type %s : %s" % (Id,platform.vendor.lstrip().rstrip(),deviceType,device.name.lstrip().rstrip()))
 
                     if Id in Devices:
                     # Set the Alu as detected Device Type
                         Alu[Id]=deviceType
                     Id=Id+1
         except ImportError:
-            print "Platform does not seem to support OpenCL"
+            print("Platform does not seem to support OpenCL")
 
-    print Devices,Alu
+    print(Devices,Alu)
             
-    BlocksList=xrange(BlocksBegin,BlocksEnd+BlocksStep,BlocksStep)
-    ThreadsList=xrange(ThreadsBegin,ThreadsEnd+ThreadsStep,ThreadsStep)
+    BlocksList=range(BlocksBegin,BlocksEnd+BlocksStep,BlocksStep)
+    ThreadsList=range(ThreadsBegin,ThreadsEnd+ThreadsStep,ThreadsStep)
     
     ExploredJobs=numpy.array([]).astype(numpy.uint32)
     ExploredBlocks=numpy.array([]).astype(numpy.uint32)
@@ -234,14 +232,14 @@
                         try:
                             MyThread=threadWithReturn(target=MetropolisCUDA, args=(InputCL,))
                         except:
-                            print "Problem with (%i,%i) // computations on Cuda" % (Blocks,Threads)
+                            print("Problem with (%i,%i) // computations on Cuda" % (Blocks,Threads))
                     elif GpuStyle=='OpenCL':
                         try:
                             MyThread=threadWithReturn(target=MetropolisOpenCL, args=(InputCL,))
                         except:
-                            print "Problem with (%i,%i) // computations on OpenCL" % (Blocks,Threads)            
+                            print("Problem with (%i,%i) // computations on OpenCL" % (Blocks,Threads)            )
                     
-                    print "Start on #%i device..." % Device
+                    print("Start on #%i device..." % Device)
                     MyThread.start()
                     MyThreads.append(MyThread)
 
@@ -251,7 +249,7 @@
                     OutputCL=MyThread.join()
                     NewIterations+=OutputCL['NewIterations']
                     Inside+=OutputCL['Inside']
-                print "Pi equals:",4./NewIterations*Inside
+                print("Pi equals:",4./NewIterations*Inside)
 
                 Duration=numpy.append(Duration,time.time()-time_start)
                 Rate=numpy.append(Rate,NewIterations/Duration[-1])
@@ -271,14 +269,14 @@
                     try:
                         MyThread=threadWithReturn(target=MetropolisCUDA, args=(InputCL,))
                     except:
-                        print "Problem with (%i,%i) // computations on Cuda" % (Blocks,Threads)
+                        print("Problem with (%i,%i) // computations on Cuda" % (Blocks,Threads))
                 elif GpuStyle=='OpenCL':
                     try:
                         MyThread=threadWithReturn(target=MetropolisOpenCL, args=(InputCL,))
                     except:
-                        print "Problem with (%i,%i) // computations on OpenCL" % (Blocks,Threads)            
+                        print("Problem with (%i,%i) // computations on OpenCL" % (Blocks,Threads))
                     
-                print "Start on #%i device..." % Device
+                print("Start on #%i device..." % Device)
                 MyThread.start()
                 MyThreads.append(MyThread)
 
@@ -289,7 +287,7 @@
                 NewIterations+=OutputCL['NewIterations']
                 Inside+=OutputCL['Inside']
             Duration=time.time()-time_start
-            print "Pi equals:",4./NewIterations*Inside
+            print("Pi equals:",4./NewIterations*Inside)
             Rate=1./Duration*NewIterations
             
         avgD=numpy.append(avgD,numpy.average(Duration))
@@ -303,7 +301,7 @@
         minR=numpy.append(minR,numpy.min(Rate))
         maxR=numpy.append(maxR,numpy.max(Rate))
 
-        print "%.2f %.2f %.2f %.2f %.2f %i %i %i %i %i" % (avgD[-1],medD[-1],stdD[-1],minD[-1],maxD[-1],avgR[-1],medR[-1],stdR[-1],minR[-1],maxR[-1])
+        print("%.2f %.2f %.2f %.2f %.2f %i %i %i %i %i" % (avgD[-1],medD[-1],stdD[-1],minD[-1],maxD[-1],avgR[-1],medR[-1],stdR[-1],minR[-1],maxR[-1]))
         
         numpy.savez("Pi_%s_%s_%s_%s_%s_%s_%s_%s_%.8i_Device%i_%s_%s" % (ValueType,RNG,Alu[Devices[0]],GpuStyle,BlocksBegin,BlocksEnd,ThreadsBegin,ThreadsEnd,Iterations,Devices[0],Metrology,gethostname()),(ExploredBlocks,ExploredThreads,avgD,medD,stdD,minD,maxD,avgR,medR,stdR,minR,maxR))
         ToSave=[ ExploredBlocks,ExploredThreads,avgD,medD,stdD,minD,maxD,avgR,medR,stdR,minR,maxR ]
