Révision 202
Splutter/GPU/SplutterGPU.py (revision 202) | ||
---|---|---|
384 | 384 |
|
385 | 385 |
for i in range(steps): |
386 | 386 |
|
387 |
start_time=time.time() |
|
387 | 388 |
Splutter[:]=0 |
388 | 389 |
|
389 | 390 |
print Splutter,len(Splutter) |
... | ... | |
427 | 428 |
stop.record() |
428 | 429 |
stop.synchronize() |
429 | 430 |
|
430 |
elapsed = start.time_till(stop)*1e-3 |
|
431 |
# elapsed = start.time_till(stop)*1e-3 |
|
432 |
elapsed = time.time()-start_time |
|
431 | 433 |
|
432 | 434 |
print Splutter,sum(Splutter) |
433 | 435 |
MySplutter[i]=numpy.median(Splutter) |
... | ... | |
459 | 461 |
# Default Device selection based on ALU Type |
460 | 462 |
for platform in cl.get_platforms(): |
461 | 463 |
for device in platform.get_devices(): |
462 |
deviceType=cl.device_type.to_string(device.type) |
|
464 |
#deviceType=cl.device_type.to_string(device.type)
|
|
463 | 465 |
deviceMemory=device.max_mem_alloc_size |
464 | 466 |
if deviceMemory>MaxMemoryXPU: |
465 | 467 |
MaxMemoryXPU=deviceMemory |
466 | 468 |
if deviceMemory<MinMemoryXPU or MinMemoryXPU==0: |
467 | 469 |
MinMemoryXPU=deviceMemory |
468 |
if deviceType=="GPU" and Alu=="GPU" and not HasXPU:
|
|
470 |
if not HasXPU:
|
|
469 | 471 |
XPU=device |
470 |
print "GPU selected with Allocable Memory %i: %s" % (deviceMemory,device.name)
|
|
472 |
print "XPU selected with Allocable Memory %i: %s" % (deviceMemory,device.name)
|
|
471 | 473 |
HasXPU=True |
472 | 474 |
MemoryXPU=deviceMemory |
473 |
if deviceType=="CPU" and Alu=="CPU" and not HasXPU: |
|
474 |
XPU=device |
|
475 |
print "CPU selected with Allocable Memory %i: %s" % (deviceMemory,device.name) |
|
476 |
HasXPU=True |
|
477 |
MemoryXPU=deviceMemory |
|
478 | 475 |
|
479 | 476 |
else: |
480 | 477 |
print "Enter XPU selector based on device number & ALU type" |
... | ... | |
483 | 480 |
# Primary Device selection based on Device Id |
484 | 481 |
for platform in cl.get_platforms(): |
485 | 482 |
for device in platform.get_devices(): |
486 |
deviceType=cl.device_type.to_string(device.type) |
|
483 |
#deviceType=cl.device_type.to_string(device.type)
|
|
487 | 484 |
deviceMemory=device.max_mem_alloc_size |
488 | 485 |
if deviceMemory>MaxMemoryXPU: |
489 | 486 |
MaxMemoryXPU=deviceMemory |
490 | 487 |
if deviceMemory<MinMemoryXPU or MinMemoryXPU==0: |
491 | 488 |
MinMemoryXPU=deviceMemory |
492 |
if Id==Device and Alu==deviceType and HasXPU==False:
|
|
489 |
if Id==Device and HasXPU==False: |
|
493 | 490 |
XPU=device |
494 | 491 |
print "CPU/GPU selected with Allocable Memory %i: %s" % (deviceMemory,device.name) |
495 | 492 |
HasXPU=True |
... | ... | |
540 | 537 |
|
541 | 538 |
print Splutter,len(Splutter) |
542 | 539 |
|
540 |
h2d_time=time.time() |
|
543 | 541 |
SplutterCL = cl.Buffer(ctx, mf.WRITE_ONLY|mf.COPY_HOST_PTR,hostbuf=Splutter) |
542 |
print('From Host to Device time %f' % (time.time()-h2d_time)) |
|
544 | 543 |
|
544 |
start_time=time.time() |
|
545 | 545 |
if ParaStyle=='Blocks': |
546 | 546 |
# Call OpenCL kernel |
547 | 547 |
# (1,) is Global work size (only 1 work size) |
... | ... | |
592 | 592 |
print "%s with %i %s done" % (Alu,jobs,ParaStyle) |
593 | 593 |
|
594 | 594 |
CLLaunch.wait() |
595 |
d2h_time=time.time() |
|
595 | 596 |
cl.enqueue_copy(queue, Splutter, SplutterCL).wait() |
597 |
print('From Device to Host %f' % (time.time()-d2h_time)) |
|
598 |
|
|
599 |
# elapsed = 1e-9*(CLLaunch.profile.end - CLLaunch.profile.start) |
|
600 |
elapsed = time.time()-start_time |
|
601 |
print('Elapsed compute time %f' % elapsed) |
|
596 | 602 |
|
597 |
elapsed = 1e-9*(CLLaunch.profile.end - CLLaunch.profile.start) |
|
598 |
|
|
599 | 603 |
MyDuration[i]=elapsed |
600 |
print Splutter,sum(Splutter) |
|
604 |
#print Splutter,sum(Splutter)
|
|
601 | 605 |
#MySplutter[i]=numpy.median(Splutter) |
602 | 606 |
#print numpy.mean(Splutter)*len(Splutter),MySplutter[i]*len(Splutter),numpy.std(Splutter) |
603 | 607 |
|
... | ... | |
731 | 735 |
Id=1 |
732 | 736 |
for platform in cl.get_platforms(): |
733 | 737 |
for device in platform.get_devices(): |
734 |
deviceType=cl.device_type.to_string(device.type) |
|
738 |
#deviceType=cl.device_type.to_string(device.type)
|
|
735 | 739 |
deviceMemory=device.max_mem_alloc_size |
736 |
print "Device #%i from %s of type %s with memory %i : %s" % (Id,platform.vendor,deviceType,deviceMemory,device.name.lstrip())
|
|
740 |
print "Device #%i from %s with memory %i : %s" % (Id,platform.vendor,deviceMemory,device.name.lstrip())
|
|
737 | 741 |
Id=Id+1 |
738 | 742 |
|
739 | 743 |
|
... | ... | |
805 | 809 |
Id=1 |
806 | 810 |
for platform in cl.get_platforms(): |
807 | 811 |
for device in platform.get_devices(): |
808 |
deviceType=cl.device_type.to_string(device.type) |
|
809 |
print "Device #%i of type %s : %s" % (Id,deviceType,device.name)
|
|
812 |
#deviceType=cl.device_type.to_string(device.type)
|
|
813 |
print "Device #%i : %s" % (Id,device.name)
|
|
810 | 814 |
if Id == Device: |
811 | 815 |
# Set the Alu as detected Device Type |
812 |
Alu=deviceType
|
|
816 |
Alu='xPU'
|
|
813 | 817 |
Id=Id+1 |
814 | 818 |
except ImportError: |
815 | 819 |
print "Platform does not seem to support CUDA" |
Formats disponibles : Unified diff