Révision 152 Pi/XPU/PiXPU.py
| PiXPU.py (revision 152) | ||
|---|---|---|
| 425 | 425 |
print("GPU selected %s" % XPU.name())
|
| 426 | 426 |
|
| 427 | 427 |
|
| 428 |
# import pycuda.driver as cuda |
|
| 429 |
# from pycuda.compiler import SourceModule |
|
| 430 |
# import pycuda.autoinit |
|
| 431 |
|
|
| 432 | 428 |
except ImportError: |
| 433 | 429 |
print("Platform does not seem to support CUDA")
|
| 434 | 430 |
|
| 435 |
Context=XPU.make_context() |
|
| 436 | 431 |
circle=numpy.zeros(blocks*threads).astype(numpy.uint64) |
| 437 | 432 |
circleCU = cuda.InOut(circle) |
| 438 | 433 |
#circleCU = cuda.mem_alloc(circle.size*circle.dtype.itemize) |
| 439 | 434 |
#cuda.memcpy_htod(circleCU, circle) |
| 440 | 435 |
|
| 436 |
Context=XPU.make_context() |
|
| 437 |
|
|
| 441 | 438 |
try: |
| 439 |
#mod = SourceModule(KernelCodeCuda(),options=['--compiler-options','-DTRNG=%i -DTYPE=%s' % (Marsaglia[RNG],Computing[ValueType])]) |
|
| 442 | 440 |
mod = SourceModule(KernelCodeCuda(),options=['--compiler-options','-DTRNG=%i -DTYPE=%s' % (Marsaglia[RNG],Computing[ValueType])]) |
| 443 | 441 |
except: |
| 444 | 442 |
print("Compilation seems to broke")
|
| 445 |
|
|
| 443 |
|
|
| 446 | 444 |
MetropolisBlocksCU=mod.get_function("MainLoopBlocks")
|
| 447 | 445 |
MetropolisThreadsCU=mod.get_function("MainLoopThreads")
|
| 448 | 446 |
MetropolisHybridCU=mod.get_function("MainLoopHybrid")
|
| ... | ... | |
| 474 | 472 |
|
| 475 | 473 |
OutputCU={'Inside':sum(circle),'NewIterations':numpy.uint64(iterationsCU*jobs),'Duration':MyDuration}
|
| 476 | 474 |
print(OutputCU) |
| 475 |
Context.pop() |
|
| 477 | 476 |
|
| 478 |
Context.detach() |
|
| 477 |
#Context.detach()
|
|
| 479 | 478 |
return(OutputCU) |
| 480 | 479 |
|
| 481 | 480 |
def MetropolisOpenCL(InputCL): |
| ... | ... | |
| 652 | 651 |
# BlocksBlocks in first number of Blocks to explore |
| 653 | 652 |
BlocksBegin=1 |
| 654 | 653 |
# BlocksEnd is last number of Blocks to explore |
| 655 |
BlocksEnd=16
|
|
| 654 |
BlocksEnd=1 |
|
| 656 | 655 |
# BlocksStep is the step of Blocks to explore |
| 657 | 656 |
BlocksStep=1 |
| 658 | 657 |
# ThreadsBlocks in first number of Blocks to explore |
| ... | ... | |
| 788 | 787 |
for platform in cl.get_platforms(): |
| 789 | 788 |
for device in platform.get_devices(): |
| 790 | 789 |
#deviceType=cl.device_type.to_string(device.type) |
| 791 |
deviceType="*PU"
|
|
| 790 |
deviceType="xPU"
|
|
| 792 | 791 |
print("Device #%i from %s of type %s : %s" % (Id,platform.vendor.lstrip().rstrip(),deviceType,device.name.lstrip().rstrip()))
|
| 793 | 792 |
|
| 794 | 793 |
if Id in Devices: |
| ... | ... | |
| 882 | 881 |
Duration=OutputCU['Duration'] |
| 883 | 882 |
except: |
| 884 | 883 |
print("Problem with (%i,%i) // computations on Cuda" % (Blocks,Threads))
|
| 884 |
try: |
|
| 885 |
pycuda.context.pop() |
|
| 886 |
except: |
|
| 887 |
pass |
|
| 885 | 888 |
elif GpuStyle=='OpenCL': |
| 886 | 889 |
try: |
| 887 | 890 |
InputCL={}
|
Formats disponibles : Unified diff