Révision 234
TrouNoir/TrouNoir.py (revision 234) | ||
---|---|---|
1 | 1 |
#!/usr/bin/env python |
2 | 2 |
# |
3 |
# TrouNoir model using PyOpenCL
|
|
3 |
# TrouNoir model using PyOpenCL |
|
4 | 4 |
# |
5 |
# CC BY-NC-SA 2019 : <emmanuel.quemener@ens-lyon.fr>
|
|
5 |
# CC BY-NC-SA 2019 : <emmanuel.quemener@ens-lyon.fr> |
|
6 | 6 |
# |
7 | 7 |
# Thanks to Andreas Klockner for PyOpenCL: |
8 | 8 |
# http://mathema.tician.de/software/pyopencl |
9 |
#
|
|
9 |
# |
|
10 | 10 |
# Original code programmed in Fortran 77 in mars 1994 |
11 | 11 |
# for Practical Work of Numerical Simulation |
12 | 12 |
# DEA (old Master2) in astrophysics and spatial techniques in Meudon |
... | ... | |
17 | 17 |
# GPUfication in CUDA under Python in august 2019 |
18 | 18 |
# |
19 | 19 |
# Thanks to : |
20 |
#
|
|
20 |
# |
|
21 | 21 |
# - Herve Aussel for his part of code of black body spectrum |
22 | 22 |
# - Didier Pelat for his help to perform this work |
23 | 23 |
# - Jean-Pierre Luminet for his article published in 1979 |
... | ... | |
102 | 102 |
|
103 | 103 |
BlobOpenCL= """ |
104 | 104 |
|
105 |
#define PI (float)3.14159265359 |
|
105 |
#define PI (float)3.14159265359e0f
|
|
106 | 106 |
#define nbr 256 |
107 | 107 |
|
108 | 108 |
#define EINSTEIN 0 |
... | ... | |
146 | 146 |
#endif |
147 | 147 |
|
148 | 148 |
void calcul(float *us,float *vs,float up,float vp, |
149 |
float h,float m,float b)
|
|
149 |
float h,float m,float b)
|
|
150 | 150 |
{ |
151 | 151 |
float c0,c1,c2,c3,d0,d1,d2,d3; |
152 | 152 |
|
153 | 153 |
c0=h*f(vp); |
154 |
c1=h*f(vp+c0/2.); |
|
155 |
c2=h*f(vp+c1/2.); |
|
154 |
c1=h*f(vp+c0/2.e0f);
|
|
155 |
c2=h*f(vp+c1/2.e0f);
|
|
156 | 156 |
c3=h*f(vp+c2); |
157 | 157 |
d0=h*g(up,m,b); |
158 |
d1=h*g(up+d0/2.,m,b); |
|
159 |
d2=h*g(up+d1/2.,m,b); |
|
158 |
d1=h*g(up+d0/2.e0f,m,b);
|
|
159 |
d2=h*g(up+d1/2.e0f,m,b);
|
|
160 | 160 |
d3=h*g(up+d2,m,b); |
161 | 161 |
|
162 |
*us=up+(c0+2.*c1+2.*c2+c3)/6.;
|
|
163 |
*vs=vp+(d0+2.*d1+2.*d2+d3)/6.;
|
|
162 |
*us=up+(c0+2.e0f*c1+2.e0f*c2+c3)/6.e0f;
|
|
163 |
*vs=vp+(d0+2.e0f*d1+2.e0f*d2+d3)/6.e0f;
|
|
164 | 164 |
} |
165 | 165 |
|
166 | 166 |
void rungekutta(float *ps,float *us,float *vs, |
167 |
float pp,float up,float vp,
|
|
168 |
float h,float m,float b)
|
|
167 |
float pp,float up,float vp,
|
|
168 |
float h,float m,float b)
|
|
169 | 169 |
{ |
170 | 170 |
calcul(us,vs,up,vp,h,m,b); |
171 | 171 |
*ps=pp+h; |
172 | 172 |
} |
173 | 173 |
|
174 | 174 |
float decalage_spectral(float r,float b,float phi, |
175 |
float tho,float m)
|
|
175 |
float tho,float m)
|
|
176 | 176 |
{ |
177 | 177 |
return (sqrt(1-3*m/r)/(1+sqrt(m/pow(r,3))*b*sin(tho)*sin(phi))); |
178 | 178 |
} |
179 | 179 |
|
180 | 180 |
float spectre(float rf,int q,float b,float db, |
181 |
float h,float r,float m,float bss)
|
|
181 |
float h,float r,float m,float bss)
|
|
182 | 182 |
{ |
183 | 183 |
float flx; |
184 | 184 |
|
185 | 185 |
// flx=exp(q*log(r/m))*pow(rf,4)*b*db*h; |
186 |
flx=exp(q*log(r/m)+4.*log(rf))*b*db*h; |
|
186 |
flx=exp(q*log(r/m)+4.e0f*log(rf))*b*db*h;
|
|
187 | 187 |
return(flx); |
188 | 188 |
} |
189 | 189 |
|
190 | 190 |
float spectre_cn(float rf32,float b32,float db32, |
191 |
float h32,float r32,float m32,float bss32)
|
|
191 |
float h32,float r32,float m32,float bss32)
|
|
192 | 192 |
{ |
193 |
|
|
193 |
|
|
194 | 194 |
#define MYFLOAT float |
195 | 195 |
|
196 | 196 |
MYFLOAT rf=(MYFLOAT)(rf32); |
... | ... | |
205 | 205 |
MYFLOAT nu_rec,nu_em,qu,temp_em,flux_int; |
206 | 206 |
int fi,posfreq; |
207 | 207 |
|
208 |
#define planck 6.62e-34 |
|
209 |
#define k 1.38e-23 |
|
210 |
#define c2 9.e16 |
|
211 |
#define temp 3.e7 |
|
212 |
#define m_point 1. |
|
208 |
#define planck 6.62e-34f
|
|
209 |
#define k 1.38e-23f
|
|
210 |
#define c2 9.e16f
|
|
211 |
#define temp 3.e7f
|
|
212 |
#define m_point 1.e0f
|
|
213 | 213 |
|
214 |
#define lplanck (log(6.62)-34.*log(10.))
|
|
215 |
#define lk (log(1.38)-23.*log(10.))
|
|
216 |
#define lc2 (log(9.)+16.*log(10.))
|
|
214 |
#define lplanck (log(6.62e0f)-34.e0f*log(10.e0f))
|
|
215 |
#define lk (log(1.38e0f)-23.e0f*log(10.e0f))
|
|
216 |
#define lc2 (log(9.e0f)+16.e0f*log(10.e0f))
|
|
217 | 217 |
|
218 |
MYFLOAT v=1.-3./r;
|
|
218 |
MYFLOAT v=1.e0f-3.e0f/r;
|
|
219 | 219 |
|
220 |
qu=1./sqrt((1.-3./r)*r)*(sqrt(r)-sqrt(6.)+sqrt(3.)/2.*log((sqrt(r)+sqrt(3.))/(sqrt(r)-sqrt(3.))* 0.17157287525380988 ));
|
|
220 |
qu=1.e0f/sqrt((1.e0f-3.e0f/r)*r)*(sqrt(r)-sqrt(6.e0f)+sqrt(3.e0f)/2.e0f*log((sqrt(r)+sqrt(3.e0f))/(sqrt(r)-sqrt(3.e0f))* 0.17157287525380988e0f ));
|
|
221 | 221 |
|
222 |
temp_em=temp*sqrt(m)*exp(0.25*log(m_point)-0.75*log(r)-0.125*log(v)+0.25*log(fabs(qu)));
|
|
222 |
temp_em=temp*sqrt(m)*exp(0.25e0f*log(m_point)-0.75e0f*log(r)-0.125e0f*log(v)+0.25e0f*log(fabs(qu)));
|
|
223 | 223 |
|
224 |
flux_int=0.; |
|
225 |
flx=0.; |
|
224 |
flux_int=0.e0f;
|
|
225 |
flx=0.e0f;
|
|
226 | 226 |
|
227 | 227 |
for (fi=0;fi<nbr;fi++) |
228 | 228 |
{ |
... | ... | |
230 | 230 |
nu_rec=nu_em*rf; |
231 | 231 |
posfreq=(int)(nu_rec*(MYFLOAT)nbr/bss); |
232 | 232 |
if ((posfreq>0)&&(posfreq<nbr)) |
233 |
{
|
|
233 |
{
|
|
234 | 234 |
// Initial version |
235 |
// flux_int=2.*planck/c2*pow(nu_em,3)/(exp(planck*nu_em/(k*temp_em))-1.);
|
|
235 |
// flux_int=2.*planck/c2*pow(nu_em,3)/(exp(planck*nu_em/(k*temp_em))-1.);
|
|
236 | 236 |
// Version with log used |
237 |
//flux_int=2.*exp(lplanck-lc2+3.*log(nu_em))/(exp(exp(lplanck-lk+log(nu_em/temp_em)))-1.);
|
|
238 |
// flux_int*=pow(rf,3)*b*db*h;
|
|
239 |
//flux_int*=exp(3.*log(rf))*b*db*h;
|
|
240 |
flux_int=2.*exp(lplanck-lc2+3.*log(nu_em))/(exp(exp(lplanck-lk+log(nu_em/temp_em)))-1.)*exp(3.*log(rf))*b*db*h;
|
|
237 |
//flux_int=2.*exp(lplanck-lc2+3.*log(nu_em))/(exp(exp(lplanck-lk+log(nu_em/temp_em)))-1.);
|
|
238 |
// flux_int*=pow(rf,3)*b*db*h;
|
|
239 |
//flux_int*=exp(3.e0f*log(rf))*b*db*h;
|
|
240 |
flux_int=2.e0f*exp(lplanck-lc2+3.e0f*log(nu_em))/(exp(exp(lplanck-lk+log(nu_em/temp_em)))-1.e0f)*exp(3.e0f*log(rf))*b*db*h;
|
|
241 | 241 |
|
242 |
flx+=flux_int;
|
|
243 |
}
|
|
242 |
flx+=flux_int;
|
|
243 |
}
|
|
244 | 244 |
} |
245 | 245 |
|
246 | 246 |
return((float)(flx)); |
247 | 247 |
} |
248 | 248 |
|
249 | 249 |
void impact(float phi,float r,float b,float tho,float m, |
250 |
float *zp,float *fp,
|
|
251 |
int q,float db,
|
|
252 |
float h,int raie)
|
|
250 |
float *zp,float *fp,
|
|
251 |
int q,float db,
|
|
252 |
float h,int raie)
|
|
253 | 253 |
{ |
254 | 254 |
float flx,rf,bss; |
255 | 255 |
|
... | ... | |
257 | 257 |
|
258 | 258 |
if (raie==0) |
259 | 259 |
{ |
260 |
bss=1.e19; |
|
260 |
bss=1.e19f;
|
|
261 | 261 |
flx=spectre_cn(rf,b,db,h,r,m,bss); |
262 | 262 |
} |
263 | 263 |
else |
264 |
{
|
|
265 |
bss=2.; |
|
264 |
{ |
|
265 |
bss=2.e0f;
|
|
266 | 266 |
flx=spectre(rf,q,b,db,h,r,m,bss); |
267 | 267 |
} |
268 |
|
|
269 |
*zp=1./rf; |
|
268 |
|
|
269 |
*zp=1.e0f/rf;
|
|
270 | 270 |
*fp=flx; |
271 | 271 |
|
272 | 272 |
} |
... | ... | |
295 | 295 |
raie=Line; |
296 | 296 |
|
297 | 297 |
float bmx,db,b,h; |
298 |
float rp0,rpp,rps;
|
|
298 |
float rp0,rps; |
|
299 | 299 |
float phi,phd; |
300 | 300 |
uint nh=0; |
301 | 301 |
float zp=0.e0f,fp=0.e0f; |
... | ... | |
356 | 356 |
barrier(CLK_GLOBAL_MEM_FENCE); |
357 | 357 |
|
358 | 358 |
zImage[yi+sizex*xi]=(float)zp; |
359 |
fImage[yi+sizex*xi]=(float)fp;
|
|
359 |
fImage[yi+sizex*xi]=(float)fp; |
|
360 | 360 |
} |
361 | 361 |
|
362 | 362 |
__kernel void Pixel(__global float *zImage,__global float *fImage, |
... | ... | |
385 | 385 |
|
386 | 386 |
float bmx,db,b,h; |
387 | 387 |
float phi,phd,php,nr,r; |
388 |
float zp=0.,fp=0.;
|
|
388 |
float zp=0.e0f,fp=0.e0f;
|
|
389 | 389 |
|
390 | 390 |
// Autosize for image, 25% greater than external radius |
391 |
bmx=1.25*re; |
|
391 |
bmx=1.25e0f*re;
|
|
392 | 392 |
|
393 | 393 |
// Angular step of integration |
394 | 394 |
h=4.e0f*PI/(float)TRACKPOINTS; |
395 | 395 |
|
396 | 396 |
// Step of Impact Parameter |
397 |
db=bmx/(2.e0*(float)ImpactParameter); |
|
397 |
db=bmx/(2.e0f*(float)ImpactParameter);
|
|
398 | 398 |
|
399 | 399 |
// set origin as center of image |
400 |
float x=(float)xi-(float)(sizex/2)+(float)5e-1f; |
|
401 |
float y=(float)yi-(float)(sizey/2)+(float)5e-1f; |
|
400 |
float x=(float)xi-(float)(sizex/2)+(float)5.e-1f;
|
|
401 |
float y=(float)yi-(float)(sizey/2)+(float)5.e-1f;
|
|
402 | 402 |
|
403 | 403 |
// angle extracted from cylindric symmetry |
404 | 404 |
phi=atanp(x,y); |
... | ... | |
422 | 422 |
|
423 | 423 |
if (ni<IdLast[bi]) |
424 | 424 |
{ |
425 |
r=(Trajectories[bi*TRACKPOINTS+ni+1]-Trajectories[bi*TRACKPOINTS+ni])*(nr-ni*1.)+Trajectories[bi*TRACKPOINTS+ni]; |
|
425 |
r=(Trajectories[bi*TRACKPOINTS+ni+1]-Trajectories[bi*TRACKPOINTS+ni])*(nr-ni*1.e0f)+Trajectories[bi*TRACKPOINTS+ni];
|
|
426 | 426 |
} |
427 | 427 |
else |
428 | 428 |
{ |
429 | 429 |
r=Trajectories[bi*TRACKPOINTS+ni]; |
430 | 430 |
} |
431 |
|
|
431 |
|
|
432 | 432 |
if ((r<=re)&&(r>=ri)) |
433 | 433 |
{ |
434 | 434 |
ExitOnImpact=1; |
435 | 435 |
impact(phi,r,b,tho,m,&zp,&fp,q,db,h,raie); |
436 | 436 |
} |
437 |
|
|
437 |
|
|
438 | 438 |
HalfLap++; |
439 | 439 |
} while ((HalfLap<=2)&&(ExitOnImpact==0)); |
440 | 440 |
|
... | ... | |
452 | 452 |
float ExternalRadius,float Angle, |
453 | 453 |
int Line) |
454 | 454 |
{ |
455 |
// Integer Impact Parameter ID
|
|
455 |
// Integer Impact Parameter ID |
|
456 | 456 |
int bi=get_global_id(0); |
457 | 457 |
// Integer points on circle |
458 | 458 |
int i=get_global_id(1); |
... | ... | |
474 | 474 |
|
475 | 475 |
float bmx,db,b,h; |
476 | 476 |
float phi,phd; |
477 |
float zp=0,fp=0;
|
|
477 |
float zp=0.e0f,fp=0.e0f;
|
|
478 | 478 |
|
479 | 479 |
// Autosize for image |
480 |
bmx=1.25*re; |
|
480 |
bmx=1.25e0f*re;
|
|
481 | 481 |
|
482 | 482 |
// Angular step of integration |
483 | 483 |
h=4.e0f*PI/(float)TRACKPOINTS; |
... | ... | |
486 | 486 |
b=(float)bi/(float)bmaxi*bmx; |
487 | 487 |
db=bmx/(2.e0f*(float)bmaxi); |
488 | 488 |
|
489 |
phi=2.*PI/(float)imx*(float)i; |
|
489 |
phi=2.e0f*PI/(float)imx*(float)i;
|
|
490 | 490 |
phd=atanp(cos(phi)*sin(tho),cos(tho)); |
491 | 491 |
int yi=(int)((float)bi*sin(phi))+bmaxi; |
492 | 492 |
int xi=(int)((float)bi*cos(phi))+bmaxi; |
... | ... | |
502 | 502 |
|
503 | 503 |
if (ni<IdLast[bi]) |
504 | 504 |
{ |
505 |
r=(Trajectories[bi*TRACKPOINTS+ni+1]-Trajectories[bi*TRACKPOINTS+ni])*(nr-ni*1.)+Trajectories[bi*TRACKPOINTS+ni]; |
|
505 |
r=(Trajectories[bi*TRACKPOINTS+ni+1]-Trajectories[bi*TRACKPOINTS+ni])*(nr-ni*1.e0f)+Trajectories[bi*TRACKPOINTS+ni];
|
|
506 | 506 |
} |
507 | 507 |
else |
508 | 508 |
{ |
509 |
r=Trajectories[bi*TRACKPOINTS+ni];
|
|
509 |
r=Trajectories[bi*TRACKPOINTS+ni];
|
|
510 | 510 |
} |
511 |
|
|
511 |
|
|
512 | 512 |
if ((r<=re)&&(r>=ri)) |
513 | 513 |
{ |
514 |
ExitOnImpact=1;
|
|
515 |
impact(phi,r,b,tho,m,&zp,&fp,q,db,h,raie);
|
|
514 |
ExitOnImpact=1;
|
|
515 |
impact(phi,r,b,tho,m,&zp,&fp,q,db,h,raie);
|
|
516 | 516 |
} |
517 |
|
|
517 |
|
|
518 | 518 |
HalfLap++; |
519 | 519 |
} while ((HalfLap<=2)&&(ExitOnImpact==0)); |
520 |
|
|
520 |
|
|
521 | 521 |
zImage[yi+2*bmaxi*xi]=zp; |
522 |
fImage[yi+2*bmaxi*xi]=fp;
|
|
522 |
fImage[yi+2*bmaxi*xi]=fp; |
|
523 | 523 |
|
524 | 524 |
barrier(CLK_GLOBAL_MEM_FENCE); |
525 | 525 |
|
... | ... | |
530 | 530 |
float ExternalRadius,float Angle, |
531 | 531 |
int Line) |
532 | 532 |
{ |
533 |
// Integer Impact Parameter ID
|
|
533 |
// Integer Impact Parameter ID |
|
534 | 534 |
int bi=get_global_id(0); |
535 | 535 |
// Integer Impact Parameter Size (half of image) |
536 | 536 |
int bmaxi=get_global_size(0); |
... | ... | |
540 | 540 |
float m,rs,re; |
541 | 541 |
|
542 | 542 |
m=Mass; |
543 |
rs=2.*m; |
|
543 |
rs=2.e0f*m;
|
|
544 | 544 |
re=ExternalRadius; |
545 | 545 |
|
546 | 546 |
float bmx,b,h; |
547 | 547 |
int nh; |
548 | 548 |
|
549 | 549 |
// Autosize for image |
550 |
bmx=1.25*re; |
|
550 |
bmx=1.25e0f*re;
|
|
551 | 551 |
|
552 | 552 |
// Angular step of integration |
553 | 553 |
h=4.e0f*PI/(float)TRACKPOINTS; |
... | ... | |
557 | 557 |
|
558 | 558 |
float up,vp,pp,us,vs,ps; |
559 | 559 |
|
560 |
up=0.; |
|
561 |
vp=1.; |
|
562 |
|
|
563 |
pp=0.; |
|
560 |
up=0.e0f;
|
|
561 |
vp=1.e0f;
|
|
562 |
|
|
563 |
pp=0.e0f;
|
|
564 | 564 |
nh=0; |
565 | 565 |
|
566 | 566 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
567 |
|
|
567 |
|
|
568 | 568 |
// b versus us |
569 | 569 |
float bvus=fabs(b/us); |
570 | 570 |
float bvus0=bvus; |
... | ... | |
585 | 585 |
IdLast[bi]=nh; |
586 | 586 |
|
587 | 587 |
barrier(CLK_GLOBAL_MEM_FENCE); |
588 |
|
|
588 |
|
|
589 | 589 |
} |
590 | 590 |
|
591 | 591 |
__kernel void EachCircle(__global float *zImage,__global float *fImage, |
... | ... | |
593 | 593 |
float ExternalRadius,float Angle, |
594 | 594 |
int Line) |
595 | 595 |
{ |
596 |
// Integer Impact Parameter ID
|
|
597 |
int bi=get_global_id(0);
|
|
598 |
// Integer Impact Parameter Size (half of image) |
|
599 |
int bmaxi=get_global_size(0);
|
|
596 |
// Integer Impact Parameter ID
|
|
597 |
uint bi=(uint)get_global_id(0);
|
|
598 |
// Integer Impact Parameter Size (half of image)
|
|
599 |
uint bmaxi=(uint)get_global_size(0);
|
|
600 | 600 |
|
601 |
float Trajectory[TRACKPOINTS]; |
|
601 |
private float Trajectory[TRACKPOINTS];
|
|
602 | 602 |
|
603 | 603 |
float m,rs,ri,re,tho; |
604 | 604 |
int raie,q; |
605 | 605 |
|
606 | 606 |
m=Mass; |
607 |
rs=2.*m; |
|
607 |
rs=2.e0f*m;
|
|
608 | 608 |
ri=InternalRadius; |
609 | 609 |
re=ExternalRadius; |
610 | 610 |
tho=Angle; |
... | ... | |
612 | 612 |
raie=Line; |
613 | 613 |
|
614 | 614 |
float bmx,db,b,h; |
615 |
int nh; |
|
615 |
uint nh;
|
|
616 | 616 |
|
617 |
|
|
617 | 618 |
// Autosize for image |
618 | 619 |
bmx=1.25e0f*re; |
619 | 620 |
|
... | ... | |
626 | 627 |
|
627 | 628 |
float up,vp,pp,us,vs,ps; |
628 | 629 |
|
629 |
up=0.; |
|
630 |
vp=1.; |
|
631 |
|
|
632 |
pp=0.; |
|
630 |
up=0.e0f;
|
|
631 |
vp=1.e0f;
|
|
632 |
|
|
633 |
pp=0.e0f;
|
|
633 | 634 |
nh=0; |
634 | 635 |
|
635 | 636 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
636 |
|
|
637 |
|
|
637 | 638 |
// b versus us |
638 | 639 |
float bvus=fabs(b/us); |
639 | 640 |
float bvus0=bvus; |
... | ... | |
646 | 647 |
up=us; |
647 | 648 |
vp=vs; |
648 | 649 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
649 |
bvus=fabs(b/us); |
|
650 |
bvus=(float)fabs(b/us);
|
|
650 | 651 |
Trajectory[nh]=bvus; |
651 | 652 |
|
652 | 653 |
} while ((bvus>=rs)&&(bvus<=bvus0)); |
653 | 654 |
|
655 |
|
|
654 | 656 |
for (uint i=(uint)nh+1;i<TRACKPOINTS;i++) { |
655 | 657 |
Trajectory[i]=0.e0f; |
656 | 658 |
} |
657 | 659 |
|
658 |
int imx=(int)(16*bi); |
|
659 | 660 |
|
660 |
for (int i=0;i<imx;i++) |
|
661 |
uint imx=(uint)(16*bi); |
|
662 |
|
|
663 |
for (uint i=0;i<imx;i++) |
|
661 | 664 |
{ |
662 |
float zp=0.,fp=0.;
|
|
663 |
float phi=2.*PI/(float)imx*(float)i; |
|
665 |
float zp=0.e0f,fp=0.e0f;
|
|
666 |
float phi=2.e0f*PI/(float)imx*(float)i;
|
|
664 | 667 |
float phd=atanp(cos(phi)*sin(tho),cos(tho)); |
665 | 668 |
uint yi=(uint)((float)bi*sin(phi)+bmaxi); |
666 | 669 |
uint xi=(uint)((float)bi*cos(phi)+bmaxi); |
667 | 670 |
|
668 |
int HalfLap=0,ExitOnImpact=0,ni; |
|
671 |
uint HalfLap=0,ExitOnImpact=0,ni;
|
|
669 | 672 |
float php,nr,r; |
670 | 673 |
|
671 | 674 |
do |
... | ... | |
676 | 679 |
|
677 | 680 |
if (ni<nh) |
678 | 681 |
{ |
679 |
r=(Trajectory[ni+1]-Trajectory[ni])*(nr-ni*1.)+Trajectory[ni]; |
|
682 |
r=(Trajectory[ni+1]-Trajectory[ni])*(nr-ni*1.e0f)+Trajectory[ni];
|
|
680 | 683 |
} |
681 | 684 |
else |
682 | 685 |
{ |
683 | 686 |
r=Trajectory[ni]; |
684 | 687 |
} |
685 |
|
|
688 |
|
|
686 | 689 |
if ((r<=re)&&(r>=ri)) |
687 | 690 |
{ |
688 | 691 |
ExitOnImpact=1; |
689 | 692 |
impact(phi,r,b,tho,m,&zp,&fp,q,db,h,raie); |
690 | 693 |
} |
691 |
|
|
694 |
|
|
692 | 695 |
HalfLap++; |
693 | 696 |
|
694 | 697 |
} while ((HalfLap<=2)&&(ExitOnImpact==0)); |
695 |
|
|
698 |
|
|
696 | 699 |
zImage[yi+2*bmaxi*xi]=zp; |
697 | 700 |
fImage[yi+2*bmaxi*xi]=fp; |
698 | 701 |
|
699 | 702 |
} |
700 | 703 |
|
701 | 704 |
barrier(CLK_GLOBAL_MEM_FENCE); |
702 |
|
|
705 |
|
|
703 | 706 |
} |
704 | 707 |
|
705 | 708 |
__kernel void Original(__global float *zImage,__global float *fImage, |
... | ... | |
718 | 721 |
int raie,q; |
719 | 722 |
|
720 | 723 |
m=Mass; |
721 |
rs=2.*m; |
|
724 |
rs=2.e0f*m;
|
|
722 | 725 |
ri=InternalRadius; |
723 | 726 |
re=ExternalRadius; |
724 | 727 |
tho=Angle; |
... | ... | |
726 | 729 |
raie=Line; |
727 | 730 |
|
728 | 731 |
float bmx,db,b,h; |
729 |
int nh; |
|
732 |
uint nh;
|
|
730 | 733 |
|
731 | 734 |
// Autosize for image |
732 | 735 |
bmx=1.25e0f*re; |
... | ... | |
734 | 737 |
// Angular step of integration |
735 | 738 |
h=4.e0f*PI/(float)TRACKPOINTS; |
736 | 739 |
|
737 |
// Integer Impact Parameter ID
|
|
740 |
// Integer Impact Parameter ID |
|
738 | 741 |
for (int bi=0;bi<bmaxi;bi++) |
739 | 742 |
{ |
740 | 743 |
// impact parameter |
... | ... | |
743 | 746 |
|
744 | 747 |
float up,vp,pp,us,vs,ps; |
745 | 748 |
|
746 |
up=0.; |
|
747 |
vp=1.; |
|
748 |
|
|
749 |
pp=0.; |
|
749 |
up=0.e0f;
|
|
750 |
vp=1.e0f;
|
|
751 |
|
|
752 |
pp=0.e0f;
|
|
750 | 753 |
nh=0; |
751 | 754 |
|
752 | 755 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
753 |
|
|
756 |
|
|
754 | 757 |
// b versus us |
755 | 758 |
float bvus=fabs(b/us); |
756 | 759 |
float bvus0=bvus; |
... | ... | |
776 | 779 |
|
777 | 780 |
for (int i=0;i<imx;i++) |
778 | 781 |
{ |
779 |
float zp=0,fp=0;
|
|
782 |
float zp=0.e0f,fp=0.e0f;
|
|
780 | 783 |
float phi=2.e0f*PI/(float)imx*(float)i; |
781 | 784 |
float phd=atanp(cos(phi)*sin(tho),cos(tho)); |
782 | 785 |
uint yi=(uint)((float)bi*sin(phi)+bmaxi); |
783 | 786 |
uint xi=(uint)((float)bi*cos(phi)+bmaxi); |
784 | 787 |
|
785 |
int HalfLap=0,ExitOnImpact=0,ni; |
|
788 |
uint HalfLap=0,ExitOnImpact=0,ni;
|
|
786 | 789 |
float php,nr,r; |
787 | 790 |
|
788 | 791 |
do |
... | ... | |
793 | 796 |
|
794 | 797 |
if (ni<nh) |
795 | 798 |
{ |
796 |
r=(Trajectory[ni+1]-Trajectory[ni])*(nr-ni*1.)+Trajectory[ni]; |
|
799 |
r=(Trajectory[ni+1]-Trajectory[ni])*(nr-ni*1.e0f)+Trajectory[ni];
|
|
797 | 800 |
} |
798 | 801 |
else |
799 | 802 |
{ |
800 | 803 |
r=Trajectory[ni]; |
801 | 804 |
} |
802 |
|
|
805 |
|
|
803 | 806 |
if ((r<=re)&&(r>=ri)) |
804 | 807 |
{ |
805 | 808 |
ExitOnImpact=1; |
806 | 809 |
impact(phi,r,b,tho,m,&zp,&fp,q,db,h,raie); |
807 | 810 |
} |
808 |
|
|
811 |
|
|
809 | 812 |
HalfLap++; |
810 |
|
|
813 |
|
|
811 | 814 |
} while ((HalfLap<=2)&&(ExitOnImpact==0)); |
812 |
|
|
815 |
|
|
813 | 816 |
zImage[yi+2*bmaxi*xi]=zp; |
814 | 817 |
fImage[yi+2*bmaxi*xi]=fp; |
815 |
|
|
818 |
|
|
816 | 819 |
} |
817 | 820 |
|
818 |
}
|
|
819 |
|
|
821 |
} |
|
822 |
|
|
820 | 823 |
barrier(CLK_GLOBAL_MEM_FENCE); |
821 |
|
|
824 |
|
|
822 | 825 |
} |
823 | 826 |
""" |
824 | 827 |
|
... | ... | |
874 | 877 |
#endif |
875 | 878 |
|
876 | 879 |
__device__ void calcul(float *us,float *vs,float up,float vp, |
877 |
float h,float m,float b)
|
|
880 |
float h,float m,float b)
|
|
878 | 881 |
{ |
879 | 882 |
float c0,c1,c2,c3,d0,d1,d2,d3; |
880 | 883 |
|
... | ... | |
892 | 895 |
} |
893 | 896 |
|
894 | 897 |
__device__ void rungekutta(float *ps,float *us,float *vs, |
895 |
float pp,float up,float vp,
|
|
896 |
float h,float m,float b)
|
|
898 |
float pp,float up,float vp,
|
|
899 |
float h,float m,float b)
|
|
897 | 900 |
{ |
898 | 901 |
calcul(us,vs,up,vp,h,m,b); |
899 | 902 |
*ps=pp+h; |
900 | 903 |
} |
901 | 904 |
|
902 | 905 |
__device__ float decalage_spectral(float r,float b,float phi, |
903 |
float tho,float m)
|
|
906 |
float tho,float m)
|
|
904 | 907 |
{ |
905 | 908 |
return (sqrt(1-3*m/r)/(1+sqrt(m/pow(r,3))*b*sin(tho)*sin(phi))); |
906 | 909 |
} |
907 | 910 |
|
908 | 911 |
__device__ float spectre(float rf,int q,float b,float db, |
909 |
float h,float r,float m,float bss)
|
|
912 |
float h,float r,float m,float bss)
|
|
910 | 913 |
{ |
911 | 914 |
float flx; |
912 | 915 |
|
... | ... | |
916 | 919 |
} |
917 | 920 |
|
918 | 921 |
__device__ float spectre_cn(float rf32,float b32,float db32, |
919 |
float h32,float r32,float m32,float bss32)
|
|
922 |
float h32,float r32,float m32,float bss32)
|
|
920 | 923 |
{ |
921 |
|
|
924 |
|
|
922 | 925 |
#define MYFLOAT float |
923 | 926 |
|
924 | 927 |
MYFLOAT rf=(MYFLOAT)(rf32); |
... | ... | |
958 | 961 |
nu_rec=nu_em*rf; |
959 | 962 |
posfreq=(int)(nu_rec*(MYFLOAT)nbr/bss); |
960 | 963 |
if ((posfreq>0)&&(posfreq<nbr)) |
961 |
{
|
|
964 |
{
|
|
962 | 965 |
// Initial version |
963 |
// flux_int=2.*planck/c2*pow(nu_em,3)/(exp(planck*nu_em/(k*temp_em))-1.);
|
|
966 |
// flux_int=2.*planck/c2*pow(nu_em,3)/(exp(planck*nu_em/(k*temp_em))-1.);
|
|
964 | 967 |
// Version with log used |
965 |
//flux_int=2.*exp(lplanck-lc2+3.*log(nu_em))/(exp(exp(lplanck-lk+log(nu_em/temp_em)))-1.);
|
|
966 |
// flux_int*=pow(rf,3)*b*db*h;
|
|
967 |
//flux_int*=exp(3.*log(rf))*b*db*h;
|
|
968 |
flux_int=2.*exp(lplanck-lc2+3.*log(nu_em))/(exp(exp(lplanck-lk+log(nu_em/temp_em)))-1.)*exp(3.*log(rf))*b*db*h;
|
|
968 |
//flux_int=2.*exp(lplanck-lc2+3.*log(nu_em))/(exp(exp(lplanck-lk+log(nu_em/temp_em)))-1.);
|
|
969 |
// flux_int*=pow(rf,3)*b*db*h;
|
|
970 |
//flux_int*=exp(3.*log(rf))*b*db*h;
|
|
971 |
flux_int=2.*exp(lplanck-lc2+3.*log(nu_em))/(exp(exp(lplanck-lk+log(nu_em/temp_em)))-1.)*exp(3.*log(rf))*b*db*h;
|
|
969 | 972 |
|
970 |
flx+=flux_int;
|
|
971 |
}
|
|
973 |
flx+=flux_int;
|
|
974 |
}
|
|
972 | 975 |
} |
973 | 976 |
|
974 | 977 |
return((float)(flx)); |
975 | 978 |
} |
976 | 979 |
|
977 | 980 |
__device__ void impact(float phi,float r,float b,float tho,float m, |
978 |
float *zp,float *fp,
|
|
979 |
int q,float db,
|
|
980 |
float h,int raie)
|
|
981 |
float *zp,float *fp,
|
|
982 |
int q,float db,
|
|
983 |
float h,int raie)
|
|
981 | 984 |
{ |
982 | 985 |
float flx,rf,bss; |
983 | 986 |
|
... | ... | |
989 | 992 |
flx=spectre_cn(rf,b,db,h,r,m,bss); |
990 | 993 |
} |
991 | 994 |
else |
992 |
{
|
|
995 |
{ |
|
993 | 996 |
bss=2.; |
994 | 997 |
flx=spectre(rf,q,b,db,h,r,m,bss); |
995 | 998 |
} |
996 |
|
|
999 |
|
|
997 | 1000 |
*zp=1./rf; |
998 | 1001 |
*fp=flx; |
999 | 1002 |
|
... | ... | |
1051 | 1054 |
|
1052 | 1055 |
up=0.; |
1053 | 1056 |
vp=1.; |
1054 |
|
|
1055 | 1057 |
pp=0.; |
1056 | 1058 |
nh=0; |
1057 | 1059 |
|
1058 | 1060 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
1059 |
|
|
1061 |
|
|
1060 | 1062 |
rps=fabs(b/us); |
1061 | 1063 |
rp0=rps; |
1062 | 1064 |
|
... | ... | |
1069 | 1071 |
up=us; |
1070 | 1072 |
vp=vs; |
1071 | 1073 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
1072 |
rpp=rps;
|
|
1074 |
rpp=rps; |
|
1073 | 1075 |
rps=fabs(b/us); |
1074 | 1076 |
ExitOnImpact = ((fmod(pp,PI)<fmod(phd,PI))&&(fmod(ps,PI)>fmod(phd,PI)))&&(rps>ri)&&(rps<re)?1:0; |
1075 | 1077 |
|
... | ... | |
1080 | 1082 |
} |
1081 | 1083 |
else |
1082 | 1084 |
{ |
1083 |
zp=0.; |
|
1084 |
fp=0.; |
|
1085 |
zp=0.e0f;
|
|
1086 |
fp=0.e0f;
|
|
1085 | 1087 |
} |
1086 | 1088 |
|
1087 | 1089 |
__syncthreads(); |
... | ... | |
1108 | 1110 |
int q,raie; |
1109 | 1111 |
|
1110 | 1112 |
m=Mass; |
1111 |
rs=2.*m; |
|
1113 |
rs=2.e0f*m;
|
|
1112 | 1114 |
ri=InternalRadius; |
1113 | 1115 |
re=ExternalRadius; |
1114 | 1116 |
tho=Angle; |
... | ... | |
1120 | 1122 |
int nh; |
1121 | 1123 |
float zp=0,fp=0; |
1122 | 1124 |
// Autosize for image, 25% greater than external radius |
1123 |
bmx=1.25*re; |
|
1125 |
bmx=1.25e0f*re;
|
|
1124 | 1126 |
|
1125 | 1127 |
// Angular step of integration |
1126 | 1128 |
h=4.e0f*PI/(float)TRACKPOINTS; |
1127 | 1129 |
|
1128 | 1130 |
// Step of Impact Parameter |
1129 |
db=bmx/(2.e0*(float)ImpactParameter); |
|
1131 |
db=bmx/(2.e0f*(float)ImpactParameter);
|
|
1130 | 1132 |
|
1131 | 1133 |
// set origin as center of image |
1132 | 1134 |
float x=(float)xi-(float)(sizex/2)+(float)5e-1f; |
... | ... | |
1153 | 1155 |
|
1154 | 1156 |
if (ni<IdLast[bi]) |
1155 | 1157 |
{ |
1156 |
r=(Trajectories[bi*TRACKPOINTS+ni+1]-Trajectories[bi*TRACKPOINTS+ni])*(nr-ni*1.)+Trajectories[bi*TRACKPOINTS+ni]; |
|
1158 |
r=(Trajectories[bi*TRACKPOINTS+ni+1]-Trajectories[bi*TRACKPOINTS+ni])*(nr-ni*1.e0f)+Trajectories[bi*TRACKPOINTS+ni];
|
|
1157 | 1159 |
} |
1158 | 1160 |
else |
1159 | 1161 |
{ |
1160 | 1162 |
r=Trajectories[bi*TRACKPOINTS+ni]; |
1161 | 1163 |
} |
1162 |
|
|
1164 |
|
|
1163 | 1165 |
if ((r<=re)&&(r>=ri)) |
1164 | 1166 |
{ |
1165 | 1167 |
ExitOnImpact=1; |
1166 | 1168 |
impact(phi,r,b,tho,m,&zp,&fp,q,db,h,raie); |
1167 | 1169 |
} |
1168 |
|
|
1170 |
|
|
1169 | 1171 |
HalfLap++; |
1170 | 1172 |
} while ((HalfLap<=2)&&(ExitOnImpact==0)); |
1171 | 1173 |
|
... | ... | |
1181 | 1183 |
float ExternalRadius,float Angle, |
1182 | 1184 |
int Line) |
1183 | 1185 |
{ |
1184 |
// Integer Impact Parameter ID
|
|
1186 |
// Integer Impact Parameter ID |
|
1185 | 1187 |
int bi=blockIdx.x*blockDim.x+threadIdx.x; |
1186 | 1188 |
// Integer points on circle |
1187 | 1189 |
int i=blockIdx.y*blockDim.y+threadIdx.y; |
... | ... | |
1196 | 1198 |
int q,raie; |
1197 | 1199 |
|
1198 | 1200 |
m=Mass; |
1199 |
rs=2.*m; |
|
1201 |
rs=2.e0f*m;
|
|
1200 | 1202 |
ri=InternalRadius; |
1201 | 1203 |
re=ExternalRadius; |
1202 | 1204 |
tho=Angle; |
... | ... | |
1208 | 1210 |
float zp=0,fp=0; |
1209 | 1211 |
|
1210 | 1212 |
// Autosize for image |
1211 |
bmx=1.25*re; |
|
1213 |
bmx=1.25e0f*re;
|
|
1212 | 1214 |
|
1213 | 1215 |
// Angular step of integration |
1214 | 1216 |
h=4.e0f*PI/(float)TRACKPOINTS; |
1215 | 1217 |
|
1216 | 1218 |
// impact parameter |
1217 | 1219 |
b=(float)bi/(float)bmaxi*bmx; |
1218 |
db=bmx/(2.e0*(float)bmaxi); |
|
1220 |
db=bmx/(2.e0f*(float)bmaxi);
|
|
1219 | 1221 |
|
1220 |
phi=2.*PI/(float)imx*(float)i; |
|
1222 |
phi=2.e0f*PI/(float)imx*(float)i;
|
|
1221 | 1223 |
phd=atanp(cos(phi)*sin(tho),cos(tho)); |
1222 | 1224 |
int yi=(int)((float)bi*sin(phi))+bmaxi; |
1223 | 1225 |
int xi=(int)((float)bi*cos(phi))+bmaxi; |
... | ... | |
1233 | 1235 |
|
1234 | 1236 |
if (ni<IdLast[bi]) |
1235 | 1237 |
{ |
1236 |
r=(Trajectories[bi*TRACKPOINTS+ni+1]-Trajectories[bi*TRACKPOINTS+ni])*(nr-ni*1.)+Trajectories[bi*TRACKPOINTS+ni]; |
|
1238 |
r=(Trajectories[bi*TRACKPOINTS+ni+1]-Trajectories[bi*TRACKPOINTS+ni])*(nr-ni*1.e0f)+Trajectories[bi*TRACKPOINTS+ni];
|
|
1237 | 1239 |
} |
1238 | 1240 |
else |
1239 | 1241 |
{ |
1240 |
r=Trajectories[bi*TRACKPOINTS+ni];
|
|
1242 |
r=Trajectories[bi*TRACKPOINTS+ni];
|
|
1241 | 1243 |
} |
1242 |
|
|
1244 |
|
|
1243 | 1245 |
if ((r<=re)&&(r>=ri)) |
1244 | 1246 |
{ |
1245 |
ExitOnImpact=1;
|
|
1246 |
impact(phi,r,b,tho,m,&zp,&fp,q,db,h,raie);
|
|
1247 |
ExitOnImpact=1;
|
|
1248 |
impact(phi,r,b,tho,m,&zp,&fp,q,db,h,raie);
|
|
1247 | 1249 |
} |
1248 |
|
|
1250 |
|
|
1249 | 1251 |
HalfLap++; |
1250 | 1252 |
} while ((HalfLap<=2)&&(ExitOnImpact==0)); |
1251 |
|
|
1253 |
|
|
1252 | 1254 |
zImage[yi+2*bmaxi*xi]=zp; |
1253 |
fImage[yi+2*bmaxi*xi]=fp;
|
|
1255 |
fImage[yi+2*bmaxi*xi]=fp; |
|
1254 | 1256 |
|
1255 | 1257 |
} |
1256 | 1258 |
|
... | ... | |
1259 | 1261 |
float ExternalRadius,float Angle, |
1260 | 1262 |
int Line) |
1261 | 1263 |
{ |
1262 |
// Integer Impact Parameter ID
|
|
1264 |
// Integer Impact Parameter ID |
|
1263 | 1265 |
int bi=blockIdx.x*blockDim.x+threadIdx.x; |
1264 | 1266 |
// Integer Impact Parameter Size (half of image) |
1265 | 1267 |
int bmaxi=gridDim.x*blockDim.x; |
... | ... | |
1270 | 1272 |
int raie,q; |
1271 | 1273 |
|
1272 | 1274 |
m=Mass; |
1273 |
rs=2.*m; |
|
1275 |
rs=2.e0f*m;
|
|
1274 | 1276 |
ri=InternalRadius; |
1275 | 1277 |
re=ExternalRadius; |
1276 | 1278 |
tho=Angle; |
... | ... | |
1283 | 1285 |
float zp,fp; |
1284 | 1286 |
|
1285 | 1287 |
// Autosize for image |
1286 |
bmx=1.25*re; |
|
1288 |
bmx=1.25e0f*re;
|
|
1287 | 1289 |
|
1288 | 1290 |
// Angular step of integration |
1289 | 1291 |
h=4.e0f*PI/(float)TRACKPOINTS; |
... | ... | |
1293 | 1295 |
|
1294 | 1296 |
float up,vp,pp,us,vs,ps; |
1295 | 1297 |
|
1296 |
up=0.; |
|
1297 |
vp=1.; |
|
1298 |
|
|
1299 |
pp=0.; |
|
1298 |
up=0.e0f; |
|
1299 |
vp=1.e0f; |
|
1300 |
pp=0.e0f; |
|
1300 | 1301 |
nh=0; |
1301 | 1302 |
|
1302 | 1303 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
1303 |
|
|
1304 |
|
|
1304 | 1305 |
// b versus us |
1305 | 1306 |
float bvus=fabs(b/us); |
1306 | 1307 |
float bvus0=bvus; |
... | ... | |
1327 | 1328 |
float ExternalRadius,float Angle, |
1328 | 1329 |
int Line) |
1329 | 1330 |
{ |
1330 |
// Integer Impact Parameter ID
|
|
1331 |
// Integer Impact Parameter ID |
|
1331 | 1332 |
int bi=blockIdx.x*blockDim.x+threadIdx.x; |
1332 | 1333 |
|
1333 | 1334 |
// Integer Impact Parameter Size (half of image) |
... | ... | |
1365 | 1366 |
|
1366 | 1367 |
up=0.; |
1367 | 1368 |
vp=1.; |
1368 |
|
|
1369 | 1369 |
pp=0.; |
1370 | 1370 |
nh=0; |
1371 | 1371 |
|
1372 | 1372 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
1373 |
|
|
1373 |
|
|
1374 | 1374 |
// b versus us |
1375 | 1375 |
float bvus=fabs(b/us); |
1376 | 1376 |
float bvus0=bvus; |
... | ... | |
1415 | 1415 |
{ |
1416 | 1416 |
r=Trajectory[ni]; |
1417 | 1417 |
} |
1418 |
|
|
1418 |
|
|
1419 | 1419 |
if ((r<=re)&&(r>=ri)) |
1420 | 1420 |
{ |
1421 | 1421 |
ExitOnImpact=1; |
1422 | 1422 |
impact(phi,r,b,tho,m,&zp,&fp,q,db,h,raie); |
1423 | 1423 |
} |
1424 |
|
|
1424 |
|
|
1425 | 1425 |
HalfLap++; |
1426 | 1426 |
|
1427 | 1427 |
} while ((HalfLap<=2)&&(ExitOnImpact==0)); |
... | ... | |
1432 | 1432 |
fImage[yi+2*bmaxi*xi]=fp; |
1433 | 1433 |
|
1434 | 1434 |
} |
1435 |
|
|
1435 |
|
|
1436 | 1436 |
} |
1437 | 1437 |
|
1438 | 1438 |
__global__ void Original(float *zImage,float *fImage, |
... | ... | |
1451 | 1451 |
int raie,q; |
1452 | 1452 |
|
1453 | 1453 |
m=Mass; |
1454 |
rs=2.*m; |
|
1454 |
rs=2.e0f*m;
|
|
1455 | 1455 |
ri=InternalRadius; |
1456 | 1456 |
re=ExternalRadius; |
1457 | 1457 |
tho=Angle; |
... | ... | |
1467 | 1467 |
// Angular step of integration |
1468 | 1468 |
h=4.e0f*PI/(float)TRACKPOINTS; |
1469 | 1469 |
|
1470 |
// Integer Impact Parameter ID
|
|
1470 |
// Integer Impact Parameter ID |
|
1471 | 1471 |
for (int bi=0;bi<bmaxi;bi++) |
1472 | 1472 |
{ |
1473 | 1473 |
// impact parameter |
... | ... | |
1478 | 1478 |
|
1479 | 1479 |
up=0.; |
1480 | 1480 |
vp=1.; |
1481 |
|
|
1482 | 1481 |
pp=0.; |
1483 | 1482 |
nh=0; |
1484 | 1483 |
|
1485 | 1484 |
rungekutta(&ps,&us,&vs,pp,up,vp,h,m,b); |
1486 |
|
|
1485 |
|
|
1487 | 1486 |
// b versus us |
1488 | 1487 |
float bvus=fabs(b/us); |
1489 | 1488 |
float bvus0=bvus; |
... | ... | |
1532 | 1531 |
{ |
1533 | 1532 |
r=Trajectory[ni]; |
1534 | 1533 |
} |
1535 |
|
|
1534 |
|
|
1536 | 1535 |
if ((r<=re)&&(r>=ri)) |
1537 | 1536 |
{ |
1538 | 1537 |
ExitOnImpact=1; |
1539 | 1538 |
impact(phi,r,b,tho,m,&zp,&fp,q,db,h,raie); |
1540 | 1539 |
} |
1541 |
|
|
1540 |
|
|
1542 | 1541 |
HalfLap++; |
1543 |
|
|
1542 |
|
|
1544 | 1543 |
} while ((HalfLap<=2)&&(ExitOnImpact==0)); |
1545 |
|
|
1544 |
|
|
1546 | 1545 |
zImage[yi+2*bmaxi*xi]=zp; |
1547 | 1546 |
fImage[yi+2*bmaxi*xi]=fp; |
1548 |
|
|
1547 |
|
|
1549 | 1548 |
} |
1550 | 1549 |
|
1551 |
}
|
|
1552 |
|
|
1550 |
} |
|
1551 |
|
|
1553 | 1552 |
} |
1554 | 1553 |
""" |
1555 | 1554 |
return(BlobCUDA) |
1556 |
|
|
1555 |
|
|
1557 | 1556 |
# def ImageOutput(sigma,prefix): |
1558 | 1557 |
# from PIL import Image |
1559 | 1558 |
# Max=sigma.max() |
1560 | 1559 |
# Min=sigma.min() |
1561 |
|
|
1562 | 1560 |
# # Normalize value as 8bits Integer |
1563 | 1561 |
# SigmaInt=(255*(sigma-Min)/(Max-Min)).astype('uint8') |
1564 | 1562 |
# image = Image.fromarray(SigmaInt) |
... | ... | |
1566 | 1564 |
|
1567 | 1565 |
def ImageOutput(sigma,prefix,Colors): |
1568 | 1566 |
import matplotlib.pyplot as plt |
1569 |
start_time=time.time()
|
|
1567 |
start_time=time.time() |
|
1570 | 1568 |
if Colors == 'Red2Yellow': |
1571 | 1569 |
plt.imsave("%s.png" % prefix, sigma, cmap='afmhot') |
1572 | 1570 |
else: |
1573 | 1571 |
plt.imsave("%s.png" % prefix, sigma, cmap='Greys_r') |
1574 | 1572 |
save_time = time.time()-start_time |
1573 |
print("Save image as %s.png file" % prefix) |
|
1575 | 1574 |
print("Save Time : %f" % save_time) |
1576 | 1575 |
|
1577 | 1576 |
def BlackHoleCL(zImage,fImage,InputCL): |
... | ... | |
1610 | 1609 |
for platform in cl.get_platforms(): |
1611 | 1610 |
for device in platform.get_devices(): |
1612 | 1611 |
if Id==Device: |
1612 |
PF4XPU=platform.name |
|
1613 | 1613 |
XPU=device |
1614 | 1614 |
print("CPU/GPU selected: ",device.name.lstrip()) |
1615 | 1615 |
HasXPU=True |
... | ... | |
1617 | 1617 |
|
1618 | 1618 |
if HasXPU==False: |
1619 | 1619 |
print("No XPU #%i found in all of %i devices, sorry..." % (Device,Id-1)) |
1620 |
sys.exit()
|
|
1621 |
|
|
1620 |
sys.exit() |
|
1621 |
|
|
1622 | 1622 |
ctx = cl.Context([XPU]) |
1623 | 1623 |
queue = cl.CommandQueue(ctx, |
1624 | 1624 |
properties=cl.command_queue_properties.PROFILING_ENABLE) |
... | ... | |
1628 | 1628 |
|
1629 | 1629 |
BuildOptions="-DPHYSICS=%i -DSETTRACKPOINTS=%i " % (PhysicsList[Physics],InputCL['TrackPoints']) |
1630 | 1630 |
|
1631 |
print('My Platform is ',platform.name)
|
|
1631 |
print('My Platform is ',PF4XPU)
|
|
1632 | 1632 |
|
1633 |
if 'Intel' in platform.name or 'Experimental' in platform.name or 'Clover' in platform.name or 'Portable' in platform.name :
|
|
1633 |
if 'Intel' in PF4XPU or 'Experimental' in PF4XPU or 'Clover' in PF4XPU or 'Portable' in PF4XPU :
|
|
1634 | 1634 |
print('No extra options for Intel and Clover!') |
1635 | 1635 |
else: |
1636 | 1636 |
BuildOptions = BuildOptions+" -cl-mad-enable" |
... | ... | |
1649 | 1649 |
zImageCL = cl.Buffer(ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=zImage) |
1650 | 1650 |
fImageCL = cl.Buffer(ctx, mf.WRITE_ONLY | mf.COPY_HOST_PTR, hostbuf=fImage) |
1651 | 1651 |
|
1652 |
start_time=time.time()
|
|
1652 |
start_time=time.time() |
|
1653 | 1653 |
|
1654 | 1654 |
if Method=='EachPixel': |
1655 | 1655 |
CLLaunch=BlackHoleCL.EachPixel(queue,(zImage.shape[0],zImage.shape[1]), |
... | ... | |
1810 | 1810 |
IdLastCU = cuda.mem_alloc(IdLast.size*IdLast.dtype.itemsize) |
1811 | 1811 |
cuda.memcpy_htod(IdLastCU, IdLast) |
1812 | 1812 |
|
1813 |
start_time=time.time()
|
|
1813 |
start_time=time.time() |
|
1814 | 1814 |
|
1815 | 1815 |
if Method=='EachPixel': |
1816 | 1816 |
EachPixelCU(zImageCU,fImageCU, |
Formats disponibles : Unified diff