Révision 105
| Pi/XPU/PiXPU.py (revision 105) | ||
|---|---|---|
| 67 | 67 |
print "Duration %s" % Duration |
| 68 | 68 |
print "Rate %s" % Rate |
| 69 | 69 |
|
| 70 |
|
|
| 71 |
|
|
| 70 | 72 |
def DictionariesAPI(): |
| 71 | 73 |
Marsaglia={'CONG':0,'SHR3':1,'MWC':2,'KISS':3}
|
| 72 | 74 |
Computing={'INT32':0,'INT64':1,'FP32':2,'FP64':3}
|
| ... | ... | |
| 452 | 454 |
|
| 453 | 455 |
return(numpy.mean(MyDuration),numpy.median(MyDuration),numpy.std(MyDuration),numpy.min(MyDuration),numpy.max(MyDuration),numpy.mean(iterationsNew/MyDuration),numpy.median(iterationsNew/MyDuration),numpy.std(iterationsNew/MyDuration),numpy.max(iterationsNew/MyDuration),numpy.max(iterationsNew/MyDuration)) |
| 454 | 456 |
|
| 455 |
def MetropolisOpenCL(circle,iterations,steps,blocks,threads,Device, |
|
| 456 |
RNG,ValueType): |
|
| 457 |
#def MetropolisOpenCL(circle,iterations,steps,blocks,threads,Device, |
|
| 458 |
# RNG,ValueType): |
|
| 459 |
def MetropolisOpenCL(MetroParamCL): |
|
| 457 | 460 |
|
| 458 | 461 |
import pyopencl as cl |
| 462 |
|
|
| 463 |
iterations=MetroParamCL['Iterations'] |
|
| 464 |
steps=MetroParamCL['Steps'] |
|
| 465 |
blocks=MetroParamCL['Blocks'] |
|
| 466 |
threads=MetroParamCL['Threads'] |
|
| 467 |
Device=MetroParamCL['Device'] |
|
| 468 |
RNG=MetroParamCL['RNG'] |
|
| 469 |
ValueType=MetroParamCL['ValueType'] |
|
| 470 |
|
|
| 471 |
print iterations,steps,blocks,threads,Device,RNG,ValueType |
|
| 459 | 472 |
|
| 460 | 473 |
Marsaglia,Computing=DictionariesAPI() |
| 461 | 474 |
|
| ... | ... | |
| 785 | 798 |
print "Problem with (%i,%i) // computations on Cuda" % (Blocks,Threads) |
| 786 | 799 |
elif GpuStyle=='OpenCL': |
| 787 | 800 |
try: |
| 788 |
Inside,NewIterations,DurationItem=MetropolisOpenCL(circle,Iterations,1,Blocks,Threads,Devices[0],RNG,ValueType) |
|
| 801 |
MetroParamCL={}
|
|
| 802 |
MetroParamCL['Iterations']=Iterations |
|
| 803 |
MetroParamCL['Steps']=1 |
|
| 804 |
MetroParamCL['Blocks']=Blocks |
|
| 805 |
MetroParamCL['Threads']=Threads |
|
| 806 |
MetroParamCL['Device']=Devices[0] |
|
| 807 |
MetroParamCL['RNG']=RNG |
|
| 808 |
MetroParamCL['ValueType']=ValueType |
|
| 809 |
|
|
| 810 |
Inside,NewIterations,DurationItem=MetropolisOpenCL(MetroParamCL) |
|
| 789 | 811 |
except: |
| 790 | 812 |
print "Problem with (%i,%i) // computations on OpenCL" % (Blocks,Threads) |
| 791 | 813 |
Duration=numpy.append(Duration,time.time()-start) |
| ... | ... | |
| 798 | 820 |
print "Problem with (%i,%i) // computations on Cuda" % (Blocks,Threads) |
| 799 | 821 |
elif GpuStyle=='OpenCL': |
| 800 | 822 |
try: |
| 801 |
|
|
| 802 |
Inside,NewIterations,Duration=MetropolisOpenCL(circle,Iterations,Redo,Blocks,Threads,Devices[0],RNG,ValueType) |
|
| 823 |
MetroParamCL={}
|
|
| 824 |
MetroParamCL['Iterations']=Iterations |
|
| 825 |
MetroParamCL['Steps']=Redo |
|
| 826 |
MetroParamCL['Blocks']=Blocks |
|
| 827 |
MetroParamCL['Threads']=Threads |
|
| 828 |
MetroParamCL['Device']=Devices[0] |
|
| 829 |
MetroParamCL['RNG']=RNG |
|
| 830 |
MetroParamCL['ValueType']=ValueType |
|
| 831 |
Inside,NewIterations,Duration=MetropolisOpenCL(MetroParamCL) |
|
| 803 | 832 |
except: |
| 804 | 833 |
print "Problem with (%i,%i) // computations on OpenCL" % (Blocks,Threads) |
| 805 | 834 |
Rate=NewIterations/Duration |
Formats disponibles : Unified diff