3 # Copyright (C) 2014 Chad Hanna, Miguel Fernandez
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version.
10 # This program is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13 # Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with this program; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # A program to compute the LLOID filtering costs of an SVD bank as produced by gstlal_svd_bank
25 from gstlal
import svd_bank
27 #FIXME hack to deal with pre ER5 / post ER5 bank file formats, remove when not an issue
29 banks = svd_bank.read_banks(sys.argv[1])
30 except AttributeError:
31 banks = [svd_bank.read_bank(sys.argv[1])]
37 for i, bank in enumerate(banks):
40 rT = [f.rate for f in bank.bank_fragments]
41 r = numpy.array(sorted(list(set(rT))))
44 UT = numpy.array([f.mix_matrix.shape[0] for f in bank.bank_fragments])
45 MT = [f.mix_matrix.shape[1] for f in bank.bank_fragments][0]
46 NT = numpy.array([(f.end - f.start) * f.rate for f in bank.bank_fragments])
48 print
"\nSUB BANK %d" % i
49 print
"--->\tUnique sampling rates: ",r
50 print
"--->\tSampling rate for a given time slice: ",rT
51 print
"--->\tTotal SVD filters for a given time slice: ",UT
52 print
"--->\tNumber of SVD filter samples: ",NT
53 print
"--->\tTotal real templates (e.g. twice number of complex templates): ",MT
55 # Convolution of a 16 sample filter requires a multiply-add per sample point of data for each sample of the filter for each physical template
56 resample = (r * 16 * 2 * MT).sum()
58 # Convolution of a NT sample filter requires a multiply-add per sample point of data for each sample of the filter for each svd template
59 filter = (NT * rT * UT * 2).sum()
61 reconstruct = (MT * UT * rT * 2).sum()
65 # get FLOPs per *complex* template (note the divide by 2)
67 print
"--->\tMFLOPS from resampling: ", resample / 1000.**2
68 print
"--->\tMFLOPS from filtering: ", filter / 1000.**2
69 print
"--->\tMFLOPS from reconstruction: ", reconstruct / 1000.**2
70 print
"--->\tMFLOPS from addition: ", add / 1000.**2
72 MFLOPs = resample / 1000.**2 + filter / 1000.**2 + reconstruct / 1000.**2 + add / 1000.**2
75 print
"--->\tTotal MFLOPS: ", MFLOPs
76 print
"--->\tMFLOPS per complex template: ", MFLOPs / (MT / 2.)
78 averageMFLOPS = totalMFLOPS / totalMT
79 print
"--\nAverage MFLOPS per template:", averageMFLOPS