Révision 228
TrouNoir/TrouNoir.py (revision 228) | ||
---|---|---|
285 | 285 |
int q,raie; |
286 | 286 |
|
287 | 287 |
m=Mass; |
288 |
rs=2.*m; |
|
288 |
rs=2.e0f*m;
|
|
289 | 289 |
ri=InternalRadius; |
290 | 290 |
re=ExternalRadius; |
291 | 291 |
tho=Angle; |
... | ... | |
295 | 295 |
float bmx,db,b,h; |
296 | 296 |
float rp0,rpp,rps; |
297 | 297 |
float phi,phd; |
298 |
int nh;
|
|
299 |
float zp=0.,fp=0.;
|
|
298 |
uint nh=0;
|
|
299 |
float zp=0.e0f,fp=0.e0f;
|
|
300 | 300 |
|
301 | 301 |
// Autosize for image |
302 |
bmx=1.25*re; |
|
302 |
bmx=1.25e0f*re;
|
|
303 | 303 |
|
304 | 304 |
h=4.e0f*PI/(float)TRACKPOINTS; |
305 | 305 |
|
306 | 306 |
// set origin as center of image |
307 |
float x=(float)xi-(float)(sizex/2)+(float)5e-1f; |
|
308 |
float y=(float)yi-(float)(sizey/2)+(float)5e-1f; |
|
307 |
float x=(float)xi-(float)(sizex/2)+(float)5.e-1f;
|
|
308 |
float y=(float)yi-(float)(sizey/2)+(float)5.e-1f;
|
|
309 | 309 |
// angle extracted from cylindric symmetry |
310 | 310 |
phi=atanp(x,y); |
311 | 311 |
phd=atanp(cos(phi)*sin(tho),cos(tho)); |
312 | 312 |
|
313 |
|
|
313 | 314 |
float up,vp,pp,us,vs,ps; |
314 | 315 |
|
315 | 316 |
// impact parameter |
... | ... | |
317 | 318 |
// step of impact parameter; |
318 | 319 |
db=bmx/(float)(sizex); |
319 | 320 |
|
320 |
up=0.; |
|
321 |
vp=1.; |
|
322 |
|
|
323 |
pp=0.; |
|
324 |
nh=0; |
|
321 |
up=0.e0f; |
|
322 |
vp=1.e0f; |
|
323 |
pp=0.e0f; |
|
325 | 324 |
|
326 | 325 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
327 | 326 |
|
... | ... | |
336 | 335 |
pp=ps; |
337 | 336 |
up=us; |
338 | 337 |
vp=vs; |
339 |
rpp=rps; |
|
340 | 338 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
341 | 339 |
rps=fabs(b/us); |
342 | 340 |
ExitOnImpact = ((fmod(pp,PI)<fmod(phd,PI))&&(fmod(ps,PI)>fmod(phd,PI)))&&(rps>=ri)&&(rps<=re)?1:0; |
343 | 341 |
|
344 |
} while ((rps>=rs)&&(rps<=rp0)&&(ExitOnImpact==0)); |
|
342 |
} while ((rps>=rs)&&(rps<=rp0)&&(ExitOnImpact==0)&&(nh<TRACKPOINTS));
|
|
345 | 343 |
|
344 |
|
|
346 | 345 |
if (ExitOnImpact==1) { |
347 |
impact(phi,rpp,b,tho,m,&zp,&fp,q,db,h,raie);
|
|
346 |
impact(phi,rps,b,tho,m,&zp,&fp,q,db,h,raie);
|
|
348 | 347 |
} |
349 | 348 |
else |
350 | 349 |
{ |
351 |
zp=0.; |
|
352 |
fp=0.; |
|
350 |
zp=0.e0f;
|
|
351 |
fp=0.e0f;
|
|
353 | 352 |
} |
354 | 353 |
|
355 | 354 |
barrier(CLK_GLOBAL_MEM_FENCE); |
... | ... | |
1625 | 1624 |
|
1626 | 1625 |
# BlackHoleCL = cl.Program(ctx,KERNEL_CODE.substitute(kernel_params)).build() |
1627 | 1626 |
|
1628 |
BuildOptions="-cl-mad-enable -DPHYSICS=%i -DSETTRACKPOINTS=%i " % (PhysicsList[Physics],InputCL['TrackPoints'])
|
|
1627 |
BuildOptions="-DPHYSICS=%i -DSETTRACKPOINTS=%i " % (PhysicsList[Physics],InputCL['TrackPoints']) |
|
1629 | 1628 |
|
1629 |
print('My Platform is ',platform.name) |
|
1630 |
|
|
1631 |
if 'Intel' in platform.name or 'Experimental' in platform.name or 'Clover' in platform.name or 'Portable' in platform.name : |
|
1632 |
print('No extra options for Intel and Clover!') |
|
1633 |
else: |
|
1634 |
BuildOptions = BuildOptions+" -cl-mad-enable" |
|
1635 |
|
|
1636 |
print(BuildOptions) |
|
1637 |
|
|
1630 | 1638 |
BlackHoleCL = cl.Program(ctx,BlobOpenCL).build(options = BuildOptions) |
1631 | 1639 |
|
1632 | 1640 |
# Je recupere les flag possibles pour les buffers |
1633 | 1641 |
mf = cl.mem_flags |
1634 | 1642 |
|
1635 |
TrajectoriesCL = cl.Buffer(ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=Trajectories) |
|
1643 |
if Method=='TrajectoPixel' or Method=='TrajectoCircle': |
|
1644 |
TrajectoriesCL = cl.Buffer(ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=Trajectories) |
|
1645 |
IdLastCL = cl.Buffer(ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=IdLast) |
|
1646 |
|
|
1636 | 1647 |
zImageCL = cl.Buffer(ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=zImage) |
1637 | 1648 |
fImageCL = cl.Buffer(ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=fImage) |
1638 |
IdLastCL = cl.Buffer(ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=IdLast) |
|
1639 | 1649 |
|
1640 | 1650 |
start_time=time.time() |
1641 | 1651 |
|
... | ... | |
1695 | 1705 |
numpy.float32(Angle), |
1696 | 1706 |
numpy.int32(Line)) |
1697 | 1707 |
|
1698 |
CLLaunch=BlackHoleCL.Pixel(queue,(zImage.shape[0], |
|
1699 |
zImage.shape[1]),None, |
|
1708 |
CLLaunch=BlackHoleCL.Pixel(queue,(zImage.shape[0],zImage.shape[1]),None, |
|
1700 | 1709 |
zImageCL,fImageCL,TrajectoriesCL,IdLastCL, |
1701 | 1710 |
numpy.uint32(Trajectories.shape[0]), |
1702 |
numpy.float32(Mass),
|
|
1703 |
numpy.float32(InternalRadius),
|
|
1704 |
numpy.float32(ExternalRadius),
|
|
1705 |
numpy.float32(Angle),
|
|
1706 |
numpy.int32(Line))
|
|
1711 |
numpy.float32(Mass), |
|
1712 |
numpy.float32(InternalRadius), |
|
1713 |
numpy.float32(ExternalRadius), |
|
1714 |
numpy.float32(Angle), |
|
1715 |
numpy.int32(Line)) |
|
1707 | 1716 |
CLLaunch.wait() |
1708 | 1717 |
|
1709 | 1718 |
compute = time.time()-start_time |
1710 | 1719 |
|
1711 | 1720 |
cl.enqueue_copy(queue,zImage,zImageCL).wait() |
1712 | 1721 |
cl.enqueue_copy(queue,fImage,fImageCL).wait() |
1713 |
cl.enqueue_copy(queue,Trajectories,TrajectoriesCL).wait() |
|
1714 |
cl.enqueue_copy(queue,IdLast,IdLastCL).wait() |
|
1722 |
if Method=='TrajectoPixel' or Method=='TrajectoCircle': |
|
1723 |
cl.enqueue_copy(queue,Trajectories,TrajectoriesCL).wait() |
|
1724 |
cl.enqueue_copy(queue,IdLast,IdLastCL).wait() |
|
1715 | 1725 |
elapsed = time.time()-start_time |
1716 | 1726 |
print("\nCompute Time : %f" % compute) |
1717 | 1727 |
print("Elapsed Time : %f\n" % elapsed) |
... | ... | |
1723 | 1733 |
zImageCL.release() |
1724 | 1734 |
fImageCL.release() |
1725 | 1735 |
|
1726 |
TrajectoriesCL.release() |
|
1727 |
IdLastCL.release() |
|
1736 |
if Method=='TrajectoPixel' or Method=='TrajectoCircle': |
|
1737 |
TrajectoriesCL.release() |
|
1738 |
IdLastCL.release() |
|
1728 | 1739 |
|
1729 | 1740 |
return(elapsed) |
1730 | 1741 |
|
Formats disponibles : Unified diff