Révision 73
| Pi/GPU/Pi-GPU.py (revision 73) | ||
|---|---|---|
| 68 | 68 |
return (T1*(s+p/N)+c1*N+c2*N*N) |
| 69 | 69 |
|
| 70 | 70 |
KERNEL_CODE_CUDA=""" |
| 71 |
#define TCONG 0 |
|
| 72 |
#define TSHR3 1 |
|
| 73 |
#define TMWC 2 |
|
| 74 |
#define TKISS 3 |
|
| 71 | 75 |
|
| 76 |
#define TINT32 0 |
|
| 77 |
#define TINT64 1 |
|
| 78 |
#define TFP32 2 |
|
| 79 |
#define TFP64 3 |
|
| 80 |
|
|
| 72 | 81 |
// Marsaglia RNG very simple implementation |
| 73 | 82 |
|
| 74 | 83 |
#define znew ((z=36969*(z&65535)+(z>>16))<<16) |
| ... | ... | |
| 233 | 242 |
#define TFP32 2 |
| 234 | 243 |
#define TFP64 3 |
| 235 | 244 |
|
| 236 |
#pragma OPENCL EXTENSION cl_khr_fp64: enable |
|
| 237 |
|
|
| 238 | 245 |
// Marsaglia RNG very simple implementation |
| 239 | 246 |
#define znew ((z=36969*(z&65535)+(z>>16))<<16) |
| 240 | 247 |
#define wnew ((w=18000*(w&65535)+(w>>16))&65535) |
| ... | ... | |
| 249 | 256 |
#define CONGfp CONG * 2.328306435454494e-10f |
| 250 | 257 |
#define SHR3fp SHR3 * 2.328306435454494e-10f |
| 251 | 258 |
|
| 252 |
__kernel void MainLoopGlobal(__global ulong *s,ulong iterations,uint seed_w,uint seed_z)
|
|
| 259 |
ulong MainLoop(ulong iterations,uint seed_z,uint seed_w,size_t work)
|
|
| 253 | 260 |
{
|
| 254 | 261 |
|
| 255 |
// Initialization of RNG numbers |
|
| 256 | 262 |
#if TRNG == TCONG |
| 257 |
uint jcong=seed_z+get_global_id(0);
|
|
| 263 |
uint jcong=seed_z+work;
|
|
| 258 | 264 |
#elif TRNG == TSHR3 |
| 259 |
uint jsr=seed_w+get_global_id(0);
|
|
| 265 |
uint jsr=seed_w+work;
|
|
| 260 | 266 |
#elif TRNG == TMWC |
| 261 |
uint z=seed_z+get_global_id(0);
|
|
| 262 |
uint w=seed_w+get_global_id(0);
|
|
| 267 |
uint z=seed_z+work;
|
|
| 268 |
uint w=seed_w+work;
|
|
| 263 | 269 |
#elif TRNG == TKISS |
| 264 |
uint jcong=seed_z+get_global_id(0);
|
|
| 265 |
uint jsr=seed_w+get_global_id(0);
|
|
| 266 |
uint z=seed_z-get_global_id(0);
|
|
| 267 |
uint w=seed_w-get_global_id(0);
|
|
| 270 |
uint jcong=seed_z+work;
|
|
| 271 |
uint jsr=seed_w+work;
|
|
| 272 |
uint z=seed_z-work;
|
|
| 273 |
uint w=seed_w-work;
|
|
| 268 | 274 |
#endif |
| 269 | 275 |
|
| 270 | 276 |
ulong total=0; |
| 271 | 277 |
|
| 272 |
// Main Loop |
|
| 273 | 278 |
for (ulong i=0;i<iterations;i++) {
|
| 274 | 279 |
|
| 275 |
// |
|
| 276 |
|
|
| 277 | 280 |
#if TYPE == TINT32 |
| 278 |
#define THEONE 1073741824 |
|
| 279 |
#if TRNG == TCONG |
|
| 280 |
uint x=CONG>>17 ; |
|
| 281 |
uint y=CONG>>17 ; |
|
| 282 |
#elif TRNG == TSHR3 |
|
| 283 |
uint x=SHR3>>17 ; |
|
| 284 |
uint y=SHR3>>17 ; |
|
| 285 |
#elif TRNG == TMWC |
|
| 286 |
uint x=MWC>>17 ; |
|
| 287 |
uint y=MWC>>17 ; |
|
| 288 |
#elif TRNG == TKISS |
|
| 289 |
uint x=KISS>>17 ; |
|
| 290 |
uint y=KISS>>17 ; |
|
| 291 |
#endif |
|
| 281 |
#define THEONE 1073741824
|
|
| 282 |
#if TRNG == TCONG
|
|
| 283 |
uint x=CONG>>17 ;
|
|
| 284 |
uint y=CONG>>17 ;
|
|
| 285 |
#elif TRNG == TSHR3
|
|
| 286 |
uint x=SHR3>>17 ;
|
|
| 287 |
uint y=SHR3>>17 ;
|
|
| 288 |
#elif TRNG == TMWC
|
|
| 289 |
uint x=MWC>>17 ;
|
|
| 290 |
uint y=MWC>>17 ;
|
|
| 291 |
#elif TRNG == TKISS
|
|
| 292 |
uint x=KISS>>17 ;
|
|
| 293 |
uint y=KISS>>17 ;
|
|
| 294 |
#endif
|
|
| 292 | 295 |
#elif TYPE == TINT64 |
| 293 |
#define THEONE 4611686018427387904 |
|
| 294 |
#if TRNG == TCONG |
|
| 295 |
ulong x=(ulong)(CONG>>1) ; |
|
| 296 |
ulong y=(ulong)(CONG>>1) ; |
|
| 297 |
#elif TRNG == TSHR3 |
|
| 298 |
ulong x=(ulong)(SHR3>>1) ; |
|
| 299 |
ulong y=(ulong)(SHR3>>1) ; |
|
| 300 |
#elif TRNG == TMWC |
|
| 301 |
ulong x=(ulong)(MWC>>1) ; |
|
| 302 |
ulong y=(ulong)(MWC>>1) ; |
|
| 303 |
#elif TRNG == TKISS |
|
| 304 |
ulong x=(ulong)(KISS>>1) ; |
|
| 305 |
ulong y=(ulong)(KISS>>1) ; |
|
| 306 |
#endif |
|
| 296 |
#define THEONE 4611686018427387904
|
|
| 297 |
#if TRNG == TCONG
|
|
| 298 |
ulong x=(ulong)(CONG>>1) ;
|
|
| 299 |
ulong y=(ulong)(CONG>>1) ;
|
|
| 300 |
#elif TRNG == TSHR3
|
|
| 301 |
ulong x=(ulong)(SHR3>>1) ;
|
|
| 302 |
ulong y=(ulong)(SHR3>>1) ;
|
|
| 303 |
#elif TRNG == TMWC
|
|
| 304 |
ulong x=(ulong)(MWC>>1) ;
|
|
| 305 |
ulong y=(ulong)(MWC>>1) ;
|
|
| 306 |
#elif TRNG == TKISS
|
|
| 307 |
ulong x=(ulong)(KISS>>1) ;
|
|
| 308 |
ulong y=(ulong)(KISS>>1) ;
|
|
| 309 |
#endif
|
|
| 307 | 310 |
#elif TYPE == TFP32 |
| 308 |
#define THEONE 1.0f |
|
| 309 |
#if TRNG == TCONG |
|
| 310 |
float x=CONGfp ; |
|
| 311 |
float y=CONGfp ; |
|
| 312 |
#elif TRNG == TSHR3 |
|
| 313 |
float x=SHR3fp ; |
|
| 314 |
float y=SHR3fp ; |
|
| 315 |
#elif TRNG == TMWC |
|
| 316 |
float x=MWCfp ; |
|
| 317 |
float y=MWCfp ; |
|
| 318 |
#elif TRNG == TKISS |
|
| 311 |
#define THEONE 1.0f
|
|
| 312 |
#if TRNG == TCONG
|
|
| 313 |
float x=CONGfp ;
|
|
| 314 |
float y=CONGfp ;
|
|
| 315 |
#elif TRNG == TSHR3
|
|
| 316 |
float x=SHR3fp ;
|
|
| 317 |
float y=SHR3fp ;
|
|
| 318 |
#elif TRNG == TMWC
|
|
| 319 |
float x=MWCfp ;
|
|
| 320 |
float y=MWCfp ;
|
|
| 321 |
#elif TRNG == TKISS
|
|
| 319 | 322 |
float x=KISSfp ; |
| 320 | 323 |
float y=KISSfp ; |
| 321 |
#endif |
|
| 324 |
#endif
|
|
| 322 | 325 |
#elif TYPE == TFP64 |
| 323 |
#define THEONE 1.0f |
|
| 324 |
#if TRNG == TCONG |
|
| 325 |
double x=(double)CONGfp ; |
|
| 326 |
double y=(double)CONGfp ; |
|
| 327 |
#elif TRNG == TSHR3 |
|
| 328 |
double x=(double)SHR3fp ; |
|
| 329 |
double y=(double)SHR3fp ; |
|
| 330 |
#elif TRNG == TMWC |
|
| 331 |
double x=(double)MWCfp ; |
|
| 332 |
double y=(double)MWCfp ; |
|
| 333 |
#elif TRNG == TKISS |
|
| 334 |
double x=(double)KISSfp ; |
|
| 335 |
double y=(double)KISSfp ; |
|
| 326 |
#pragma OPENCL EXTENSION cl_khr_fp64: enable |
|
| 327 |
#define THEONE 1.0f |
|
| 328 |
#if TRNG == TCONG |
|
| 329 |
double x=(double)CONGfp ; |
|
| 330 |
double y=(double)CONGfp ; |
|
| 331 |
#elif TRNG == TSHR3 |
|
| 332 |
double x=(double)SHR3fp ; |
|
| 333 |
double y=(double)SHR3fp ; |
|
| 334 |
#elif TRNG == TMWC |
|
| 335 |
double x=(double)MWCfp ; |
|
| 336 |
double y=(double)MWCfp ; |
|
| 337 |
#elif TRNG == TKISS |
|
| 338 |
double x=(double)KISSfp ; |
|
| 339 |
double y=(double)KISSfp ; |
|
| 340 |
#endif |
|
| 336 | 341 |
#endif |
| 337 |
#endif |
|
| 338 | 342 |
|
| 339 |
// Matching test |
|
| 340 | 343 |
ulong inside=((x*x+y*y) <= THEONE) ? 1:0; |
| 341 | 344 |
total+=inside; |
| 342 | 345 |
} |
| 346 |
|
|
| 347 |
return(total); |
|
| 348 |
} |
|
| 343 | 349 |
|
| 350 |
__kernel void MainLoopGlobal(__global ulong *s,ulong iterations,uint seed_w,uint seed_z) |
|
| 351 |
{
|
|
| 352 |
ulong total=MainLoop(iterations,seed_z,seed_w,get_global_id(0)); |
|
| 344 | 353 |
barrier(CLK_GLOBAL_MEM_FENCE); |
| 345 |
s[get_global_id(0)]=total; |
|
| 346 |
|
|
| 354 |
s[get_global_id(0)]=total; |
|
| 347 | 355 |
} |
| 348 | 356 |
|
| 357 |
|
|
| 349 | 358 |
__kernel void MainLoopLocal(__global ulong *s,ulong iterations,uint seed_w,uint seed_z) |
| 350 | 359 |
{
|
| 351 |
uint z=seed_z+get_local_id(0); |
|
| 352 |
uint w=seed_w+get_local_id(0); |
|
| 353 |
|
|
| 354 |
ulong total=0; |
|
| 355 |
|
|
| 356 |
for (ulong i=0;i<iterations;i++) {
|
|
| 357 |
|
|
| 358 |
float x=MWCfp ; |
|
| 359 |
float y=MWCfp ; |
|
| 360 |
|
|
| 361 |
// Matching test |
|
| 362 |
ulong inside=((x*x+y*y) <= 1.0f) ? 1:0; |
|
| 363 |
total+=inside; |
|
| 364 |
} |
|
| 360 |
ulong total=MainLoop(iterations,seed_z,seed_w,get_local_id(0)); |
|
| 365 | 361 |
barrier(CLK_LOCAL_MEM_FENCE); |
| 366 | 362 |
s[get_local_id(0)]=total; |
| 367 |
|
|
| 368 | 363 |
} |
| 369 | 364 |
|
| 370 | 365 |
__kernel void MainLoopHybrid(__global ulong *s,ulong iterations,uint seed_w,uint seed_z) |
| 371 | 366 |
{
|
| 372 |
uint z=seed_z+get_global_id(0); |
|
| 373 |
uint w=seed_w+get_global_id(0); |
|
| 374 |
|
|
| 375 |
ulong total=0; |
|
| 376 |
|
|
| 377 |
for (uint i=0;i<iterations;i++) {
|
|
| 378 |
|
|
| 379 |
float x=MWCfp ; |
|
| 380 |
float y=MWCfp ; |
|
| 381 |
|
|
| 382 |
// Matching test |
|
| 383 |
ulong inside=((x*x+y*y) <= 1.0f) ? 1:0; |
|
| 384 |
total+=inside; |
|
| 385 |
} |
|
| 386 |
barrier(CLK_GLOBAL_MEM_FENCE || CLK_GLOBAL_MEM_FENCE); |
|
| 387 |
// s[get_group_id(0)*get_num_groups(0)+get_local_id(0)]=total; |
|
| 367 |
ulong total=MainLoop(iterations,seed_z,seed_w,get_global_id(0)); |
|
| 368 |
barrier(CLK_GLOBAL_MEM_FENCE || CLK_LOCAL_MEM_FENCE); |
|
| 388 | 369 |
s[get_global_id(0)]=total; |
| 389 |
|
|
| 390 | 370 |
} |
| 391 | 371 |
|
| 392 |
__kernel void MainLoopGlobal64(__global ulong *s,ulong iterations,uint seed_w,uint seed_z) |
|
| 393 |
{
|
|
| 394 |
uint z=seed_z+get_global_id(0); |
|
| 395 |
uint w=seed_w+get_global_id(0); |
|
| 396 |
|
|
| 397 |
ulong total=0; |
|
| 398 |
|
|
| 399 |
for (ulong i=0;i<iterations;i++) {
|
|
| 400 |
|
|
| 401 |
double x=(double)MWCfp ; |
|
| 402 |
double y=(double)MWCfp ; |
|
| 403 |
|
|
| 404 |
// Matching test |
|
| 405 |
ulong inside=((x*x+y*y) < 1.0f) ? 1:0; |
|
| 406 |
total+=inside; |
|
| 407 |
} |
|
| 408 |
barrier(CLK_GLOBAL_MEM_FENCE); |
|
| 409 |
s[get_global_id(0)]=total; |
|
| 410 |
|
|
| 411 |
} |
|
| 412 |
|
|
| 413 |
__kernel void MainLoopLocal64(__global ulong *s,ulong iterations,uint seed_w,uint seed_z) |
|
| 414 |
{
|
|
| 415 |
uint z=seed_z+get_local_id(0); |
|
| 416 |
uint w=seed_w+get_local_id(0); |
|
| 417 |
|
|
| 418 |
ulong total=0; |
|
| 419 |
|
|
| 420 |
for (ulong i=0;i<iterations;i++) {
|
|
| 421 |
|
|
| 422 |
double x=(double)MWCfp ; |
|
| 423 |
double y=(double)MWCfp ; |
|
| 424 |
|
|
| 425 |
// Matching test |
|
| 426 |
ulong inside=((x*x+y*y) < 1.0f) ? 1:0; |
|
| 427 |
total+=inside; |
|
| 428 |
} |
|
| 429 |
barrier(CLK_LOCAL_MEM_FENCE); |
|
| 430 |
s[get_local_id(0)]=total; |
|
| 431 |
|
|
| 432 |
} |
|
| 433 |
|
|
| 434 |
__kernel void MainLoopHybrid64(__global ulong *s,ulong iterations,uint seed_w,uint seed_z) |
|
| 435 |
{
|
|
| 436 |
uint z=seed_z+get_global_id(0); |
|
| 437 |
uint w=seed_w+get_global_id(0); |
|
| 438 |
|
|
| 439 |
ulong total=0; |
|
| 440 |
|
|
| 441 |
for (uint i=0;i<iterations;i++) {
|
|
| 442 |
|
|
| 443 |
double x=(double)MWCfp ; |
|
| 444 |
double y=(double)MWCfp ; |
|
| 445 |
|
|
| 446 |
// Matching test |
|
| 447 |
ulong inside=((x*x+y*y) < 1.0f) ? 1:0; |
|
| 448 |
total+=inside; |
|
| 449 |
} |
|
| 450 |
barrier(CLK_LOCAL_MEM_FENCE); |
|
| 451 |
s[get_global_id(0)]=total; |
|
| 452 |
|
|
| 453 |
} |
|
| 454 | 372 |
""" |
| 455 | 373 |
|
| 456 | 374 |
def MetropolisCuda(circle,iterations,steps,jobs,ParaStyle,DoublePrecision): |
| ... | ... | |
| 554 | 472 |
|
| 555 | 473 |
|
| 556 | 474 |
def MetropolisOpenCL(circle,iterations,steps,jobs,ParaStyle,Alu,Device, |
| 557 |
DoublePrecision,RNG,ValueType):
|
|
| 475 |
RNG,ValueType): |
|
| 558 | 476 |
|
| 559 | 477 |
# Initialisation des variables en les CASTant correctement |
| 560 | 478 |
|
| ... | ... | |
| 583 | 501 |
deviceType=cl.device_type.to_string(device.type) |
| 584 | 502 |
if Id==Device and Alu==deviceType and HasXPU==False: |
| 585 | 503 |
XPU=device |
| 586 |
print "CPU/GPU selected: ",device.name |
|
| 504 |
print "CPU/GPU selected: ",device.name.lstrip()
|
|
| 587 | 505 |
HasXPU=True |
| 588 | 506 |
Id=Id+1 |
| 589 | 507 |
if HasXPU==False: |
| ... | ... | |
| 627 | 545 |
# SeedZCL is lattice translated in CL format |
| 628 | 546 |
# SeedWCL is lattice translated in CL format |
| 629 | 547 |
# step is number of iterations |
| 630 |
if DoublePrecision: |
|
| 631 |
CLLaunch=MetropolisCL.MainLoopGlobal64(queue,(jobs,),None, |
|
| 632 |
circleCL, |
|
| 633 |
numpy.uint64(iterationsCL), |
|
| 634 |
numpy.uint32(nprnd(2**30/jobs)), |
|
| 635 |
numpy.uint32(nprnd(2**30/jobs))) |
|
| 636 |
else: |
|
| 637 |
CLLaunch=MetropolisCL.MainLoopGlobal(queue,(jobs,),None, |
|
| 638 |
circleCL, |
|
| 639 |
numpy.uint64(iterationsCL), |
|
| 640 |
numpy.uint32(nprnd(2**30/jobs)), |
|
| 641 |
numpy.uint32(nprnd(2**30/jobs))) |
|
| 548 |
CLLaunch=MetropolisCL.MainLoopGlobal(queue,(jobs,),None, |
|
| 549 |
circleCL, |
|
| 550 |
numpy.uint64(iterationsCL), |
|
| 551 |
numpy.uint32(nprnd(2**30/jobs)), |
|
| 552 |
numpy.uint32(nprnd(2**30/jobs))) |
|
| 642 | 553 |
print "%s with (WorkItems/Threads)=(%i,%i) %s method done" % \ |
| 643 | 554 |
(Alu,jobs,1,ParaStyle) |
| 644 | 555 |
elif ParaStyle=='Hybrid': |
| 645 | 556 |
threads=BestThreadsNumber(jobs) |
| 646 | 557 |
# en OpenCL, necessaire de mettre un Global_id identique au local_id |
| 647 |
if DoublePrecision: |
|
| 648 |
CLLaunch=MetropolisCL.MainLoopHybrid64(queue,(jobs,),(threads,), |
|
| 649 |
circleCL, |
|
| 650 |
numpy.uint64(iterationsCL), |
|
| 651 |
numpy.uint32(nprnd(2**30/jobs)), |
|
| 652 |
numpy.uint32(nprnd(2**30/jobs))) |
|
| 653 |
else: |
|
| 654 |
CLLaunch=MetropolisCL.MainLoopHybrid(queue,(jobs,),(threads,), |
|
| 655 |
circleCL, |
|
| 656 |
numpy.uint64(iterationsCL), |
|
| 657 |
numpy.uint32(nprnd(2**30/jobs)), |
|
| 658 |
numpy.uint32(nprnd(2**30/jobs))) |
|
| 558 |
CLLaunch=MetropolisCL.MainLoopHybrid(queue,(jobs,),(threads,), |
|
| 559 |
circleCL, |
|
| 560 |
numpy.uint64(iterationsCL), |
|
| 561 |
numpy.uint32(nprnd(2**30/jobs)), |
|
| 562 |
numpy.uint32(nprnd(2**30/jobs))) |
|
| 659 | 563 |
|
| 660 | 564 |
print "%s with (WorkItems/Threads)=(%i,%i) %s method done" % \ |
| 661 | 565 |
(Alu,jobs/threads,threads,ParaStyle) |
| 662 | 566 |
else: |
| 663 | 567 |
# en OpenCL, necessaire de mettre un Global_id identique au local_id |
| 664 |
if DoublePrecision: |
|
| 665 |
CLLaunch=MetropolisCL.MainLoopLocal64(queue,(jobs,),(jobs,), |
|
| 666 |
circleCL, |
|
| 667 |
numpy.uint64(iterationsCL), |
|
| 668 |
numpy.uint32(nprnd(2**30/jobs)), |
|
| 669 |
numpy.uint32(nprnd(2**30/jobs))) |
|
| 670 |
else: |
|
| 671 |
CLLaunch=MetropolisCL.MainLoopLocal(queue,(jobs,),(jobs,), |
|
| 672 |
circleCL, |
|
| 673 |
numpy.uint64(iterationsCL), |
|
| 674 |
numpy.uint32(nprnd(2**30/jobs)), |
|
| 675 |
numpy.uint32(nprnd(2**30/jobs))) |
|
| 568 |
CLLaunch=MetropolisCL.MainLoopLocal(queue,(jobs,),(jobs,), |
|
| 569 |
circleCL, |
|
| 570 |
numpy.uint64(iterationsCL), |
|
| 571 |
numpy.uint32(nprnd(2**30/jobs)), |
|
| 572 |
numpy.uint32(nprnd(2**30/jobs))) |
|
| 676 | 573 |
print "%s with %i %s done" % (Alu,jobs,ParaStyle) |
| 677 | 574 |
|
| 678 | 575 |
CLLaunch.wait() |
| ... | ... | |
| 796 | 693 |
Curves=False |
| 797 | 694 |
# Fit is True to print the curves |
| 798 | 695 |
Fit=False |
| 799 |
# DoublePrecision on FP calculus |
|
| 800 |
DoublePrecision=False |
|
| 801 | 696 |
# Marsaglia RNG |
| 802 | 697 |
RNG='KISS' |
| 803 | 698 |
# Value type : INT32, INT64, FP32, FP64 |
| ... | ... | |
| 821 | 716 |
for platform in cl.get_platforms(): |
| 822 | 717 |
for device in platform.get_devices(): |
| 823 | 718 |
deviceType=cl.device_type.to_string(device.type) |
| 824 |
print "Device #%i from %s of type %s : %s" % (Id,platform.vendor,deviceType,device.name.lstrip()) |
|
| 719 |
print "Device #%i from %s of type %s : %s" % (Id,platform.vendor.lstrip(),deviceType,device.name.lstrip())
|
|
| 825 | 720 |
Id=Id+1 |
| 826 | 721 |
|
| 827 | 722 |
|
| ... | ... | |
| 832 | 727 |
elif opt == '-o': |
| 833 | 728 |
OutMetrology=True |
| 834 | 729 |
Metrology='OutMetro' |
| 835 |
elif opt == '-l': |
|
| 836 |
DoublePrecision=True |
|
| 837 | 730 |
elif opt == '-c': |
| 838 | 731 |
Curves=True |
| 839 | 732 |
elif opt == '-f': |
| ... | ... | |
| 878 | 771 |
print "Number of threads on end : %s" % JobEnd |
| 879 | 772 |
print "Number of redo : %s" % Redo |
| 880 | 773 |
print "Metrology done out of CPU/GPU : %r" % OutMetrology |
| 881 |
print "Double Precision in Kernels : %r" % DoublePrecision |
|
| 882 | 774 |
print "Type of Marsaglia RNG used : %s" % RNG |
| 883 | 775 |
print "Type of variable : %s" % ValueType |
| 884 | 776 |
|
| ... | ... | |
| 900 | 792 |
for platform in cl.get_platforms(): |
| 901 | 793 |
for device in platform.get_devices(): |
| 902 | 794 |
deviceType=cl.device_type.to_string(device.type) |
| 903 |
print "Device #%i of type %s : %s" % (Id,deviceType,device.name) |
|
| 795 |
print "Device #%i from %s of type %s : %s" % (Id,platform.vendor.lstrip(),deviceType,device.name.lstrip()) |
|
| 796 |
|
|
| 904 | 797 |
if Id == Device: |
| 905 | 798 |
# Set the Alu as detected Device Type |
| 906 | 799 |
Alu=deviceType |
| ... | ... | |
| 927 | 820 |
start=time.time() |
| 928 | 821 |
if GpuStyle=='CUDA': |
| 929 | 822 |
try: |
| 930 |
a,m,s=MetropolisCuda(circle,Iterations,1,Jobs,ParaStyle, |
|
| 931 |
DoublePrecision) |
|
| 823 |
a,m,s=MetropolisCuda(circle,Iterations,1,Jobs,ParaStyle) |
|
| 932 | 824 |
except: |
| 933 | 825 |
print "Problem with %i // computations on Cuda" % Jobs |
| 934 | 826 |
elif GpuStyle=='OpenCL': |
| 935 | 827 |
try: |
| 936 | 828 |
a,m,s=MetropolisOpenCL(circle,Iterations,1,Jobs,ParaStyle, |
| 937 |
Alu,Device,DoublePrecision,RNG,ValueType)
|
|
| 829 |
Alu,Device,RNG,ValueType) |
|
| 938 | 830 |
except: |
| 939 | 831 |
print "Problem with %i // computations on OpenCL" % Jobs |
| 940 | 832 |
duration=numpy.append(duration,time.time()-start) |
| ... | ... | |
| 947 | 839 |
else: |
| 948 | 840 |
if GpuStyle=='CUDA': |
| 949 | 841 |
try: |
| 950 |
avg,med,std=MetropolisCuda(circle,Iterations,Redo,Jobs,ParaStyle, |
|
| 951 |
DoublePrecision) |
|
| 842 |
avg,med,std=MetropolisCuda(circle,Iterations,Redo,Jobs,ParaStyle) |
|
| 952 | 843 |
except: |
| 953 | 844 |
print "Problem with %i // computations on Cuda" % Jobs |
| 954 | 845 |
elif GpuStyle=='OpenCL': |
| 955 | 846 |
try: |
| 956 | 847 |
avg,med,std=MetropolisOpenCL(circle,Iterations,Redo,Jobs,ParaStyle, |
| 957 |
Alu,Device,DoublePrecision,RNG,ValueType)
|
|
| 848 |
Alu,Device,RNG,ValueType) |
|
| 958 | 849 |
except: |
| 959 | 850 |
print "Problem with %i // computations on OpenCL" % Jobs |
| 960 | 851 |
|
| ... | ... | |
| 966 | 857 |
else: |
| 967 | 858 |
print "Values seem to be wrong..." |
| 968 | 859 |
#THREADS*=2 |
| 969 |
if DoublePrecision: |
|
| 970 |
Precision='DP' |
|
| 971 |
else: |
|
| 972 |
Precision='SP' |
|
| 973 | 860 |
if len(average)!=0: |
| 974 |
numpy.savez("Pi%s_%s_%s_%s_%s_%i_%.8i_Device%i_%s_%s" % (Precision,Alu,GpuStyle,ParaStyle,JobStart,JobEnd,Iterations,Device,Metrology,gethostname()),(ExploredJobs,average,median,stddev))
|
|
| 861 |
numpy.savez("Pi%s_%s_%s_%s_%s_%i_%.8i_Device%i_%s_%s" % (ValueType,Alu,GpuStyle,ParaStyle,JobStart,JobEnd,Iterations,Device,Metrology,gethostname()),(ExploredJobs,average,median,stddev))
|
|
| 975 | 862 |
ToSave=[ ExploredJobs,average,median,stddev ] |
| 976 |
numpy.savetxt("Pi%s_%s_%s_%s_%s_%i_%.8i_Device%i_%s_%s" % (Precision,Alu,GpuStyle,ParaStyle,JobStart,JobEnd,Iterations,Device,Metrology,gethostname()),numpy.transpose(ToSave))
|
|
| 863 |
numpy.savetxt("Pi%s_%s_%s_%s_%s_%i_%.8i_Device%i_%s_%s" % (ValueType,Alu,GpuStyle,ParaStyle,JobStart,JobEnd,Iterations,Device,Metrology,gethostname()),numpy.transpose(ToSave))
|
|
| 977 | 864 |
Jobs+=JobStep |
| 978 | 865 |
|
| 979 | 866 |
if Fit: |
Formats disponibles : Unified diff