1
1
#!/usr/bin/env python
2
2
# coding: utf-8
3
3
#
4
- # Copyright (C) 2016-2023 European Synchrotron Radiation Facility, Grenoble, France
4
+ # Copyright (C) 2016-2024 European Synchrotron Radiation Facility, Grenoble, France
5
5
#
6
6
# Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
# of this software and associated documentation files (the "Software"), to deal
24
24
"Benchmark for Azimuthal integration of PyFAI"
25
25
26
26
__author__ = "Jérôme Kieffer"
27
- __date__ = "20/12/2023 "
27
+ __date__ = "25/04/2024 "
28
28
__license__ = "MIT"
29
- __copyright__ = "2012-2017 European Synchrotron Radiation Facility, Grenoble, France"
29
+ __copyright__ = "2012-2024 European Synchrotron Radiation Facility, Grenoble, France"
30
30
31
31
from collections import OrderedDict
32
32
import json
39
39
import fabio
40
40
import os .path as op
41
41
from math import ceil
42
+ import numpy
42
43
43
- # To use use the locally build version of PyFAI, use ../bootstrap.py
44
-
45
- from .. import load
44
+ from .. import load , detector_factory
46
45
from ..azimuthalIntegrator import AzimuthalIntegrator
47
46
from ..method_registry import IntegrationMethod , Method
48
47
from ..utils import mathutil
@@ -62,35 +61,22 @@ def update_fig(*args, **kwargs):
62
61
def update_fig (* args , ** kwargs ):
63
62
pass
64
63
65
- ds_list = ["Pilatus1M.poni" ,
66
- "Pilatus2M.poni" ,
67
- "Eiger4M.poni" ,
68
- "Pilatus6M.poni" ,
69
- "Eiger9M.poni" ,
70
- "Mar3450.poni" ,
71
- "Fairchild.poni" ]
72
-
73
64
detector_names = ["Pilatus1M" ,
74
65
"Pilatus2M" ,
75
66
"Eiger4M" ,
76
67
"Pilatus6M" ,
77
68
"Eiger9M" ,
78
69
"Mar3450" ,
79
- "Fairchild" ,]
70
+ "Fairchild" , ]
80
71
81
- data_sizes = [1.023183 ,
82
- 2.476525 ,
83
- 4.48569 ,
84
- 6.224001 ,
85
- 10.138296 ,
86
- 11.9025 ,
87
- 16.777216 ,
88
- ] #Mpixels
72
+ ds_list = [d + ".poni" for d in detector_names ]
89
73
74
+ data_sizes = [numpy .prod (detector_factory (d ).shape ) * 1e-6
75
+ for d in detector_names ]
90
76
91
77
datasets = {"Fairchild.poni" : "Fairchild.edf" ,
92
- "halfccd.poni" : "halfccd.edf" ,
93
- "Frelon2k.poni" : "Frelon2k.edf" ,
78
+ # "halfccd.poni": "halfccd.edf",
79
+ # "Frelon2k.poni": "Frelon2k.edf",
94
80
"Pilatus6M.poni" : "Pilatus6M.cbf" ,
95
81
"Pilatus1M.poni" : "Pilatus1M.edf" ,
96
82
"Mar3450.poni" : "LaB6_260210.mar3450" ,
@@ -99,7 +85,6 @@ def update_fig(*args, **kwargs):
99
85
"Eiger9M.poni" :"Eiger9M.h5"
100
86
}
101
87
102
-
103
88
PONIS = { i : UtilsTest .getimage (i ) for i in ds_list }
104
89
105
90
# Handle to the Bench instance: allows debugging from outside if needed
@@ -138,7 +123,6 @@ def get_device(self):
138
123
res = None
139
124
if "ai" in dir (self ):
140
125
if "engines" in dir (self .ai ):
141
- from ..method_registry import Method
142
126
for method in self .ai .engines :
143
127
if isinstance (method , Method ) and method .impl == "opencl" :
144
128
res = self .ai .engines [method ].engine .ctx .devices [0 ]
@@ -249,9 +233,12 @@ def __init__(self, nbr=10, repeat=1, memprofile=False, unit="2th_deg", max_size=
249
233
self .LIMIT = 8
250
234
self .repeat = repeat
251
235
self .nbr = nbr
252
- self .results = OrderedDict ()
253
- self .meth = []
254
236
self ._cpu = None
237
+ self .results = {"host" : platform .node (),
238
+ "argv" : sys .argv ,
239
+ "cpu" : self .get_cpu (),
240
+ "gpu" : self .get_gpu ()}
241
+ self .meth = []
255
242
self .fig = None
256
243
self .ax = None
257
244
self .starttime = time .perf_counter ()
@@ -521,10 +508,10 @@ def bench_2d(self, method="splitBBox", check=False, opencl=None):
521
508
if check :
522
509
module = sys .modules .get (AzimuthalIntegrator .__module__ )
523
510
if module :
524
- if "lut" in method .algo_lower : # Edgar
511
+ if "lut" in method .algo_lower : # Edgar
525
512
# if "lut" in method:
526
513
key = module .EXT_LUT_ENGINE
527
- elif "csr" in method .algo_lower : # Edgar
514
+ elif "csr" in method .algo_lower : # Edgar
528
515
# elif "csr" in method:
529
516
key = module .EXT_CSR_ENGINE
530
517
else :
@@ -619,7 +606,7 @@ def bench_gpu1d(self, devicetype="gpu", useFp64=True, platformid=None, deviceid=
619
606
620
607
def save (self , filename = None ):
621
608
if filename is None :
622
- filename = f"benchmark{ time .strftime ('%Y%m%d-%H%M%S' )} .json"
609
+ filename = f"benchmark- { time .strftime ('%Y%m%d-%H%M%S' )} .json"
623
610
self .update_mp ()
624
611
json .dump (self .results , open (filename , "w" ), indent = 4 )
625
612
if self .fig is not None :
@@ -638,7 +625,7 @@ def init_curve(self):
638
625
print ("Already initialized" )
639
626
return
640
627
if pyplot and ((sys .platform in ["win32" , "darwin" ]) or ("DISPLAY" in os .environ )):
641
- self .fig , self .ax = pyplot .subplots (figsize = (12 ,6 ))
628
+ self .fig , self .ax = pyplot .subplots (figsize = (12 , 6 ))
642
629
self .fig .show ()
643
630
self .ax .set_autoscale_on (False )
644
631
self .ax .set_xlabel ("Image size in mega-pixels" )
@@ -689,7 +676,7 @@ def new_curve(self, results, label, style="-", marker="x"):
689
676
self .ax .legend (
690
677
handles = handles ,
691
678
loc = 'center left' ,
692
- bbox_to_anchor = (1.05 ,0.5 ),
679
+ bbox_to_anchor = (1.05 , 0.5 ),
693
680
fontsize = 10 ,
694
681
)
695
682
self .fig .subplots_adjust (right = 0.5 )
@@ -790,7 +777,7 @@ def run_benchmark(number=10, repeat=1, memprof=False, max_size=1000,
790
777
ocl_devices = []
791
778
if ocl :
792
779
try :
793
- ocl_devices = [(int (i ), int (j )) for i ,j in devices ]
780
+ ocl_devices = [(int (i ), int (j )) for i , j in devices ]
794
781
except Exception as err :
795
782
# print(f"{type(err)}: {err}\ndevices is not a list of 2-tuple of integrers, parsing the list")
796
783
ocl_devices = []
0 commit comments