diff --git a/gstlal-inspiral/bin/gstlal_inspiral_flopulator b/gstlal-inspiral/bin/gstlal_inspiral_flopulator index 1ab8bdb606fd2a3535c0ac13763e7434cf3d902d..2a500b238d3f5fd201bd427b0d1af60cc6db1c85 100755 --- a/gstlal-inspiral/bin/gstlal_inspiral_flopulator +++ b/gstlal-inspiral/bin/gstlal_inspiral_flopulator @@ -20,8 +20,10 @@ import numpy +import os import sys from gstlal import svd_bank +import h5py #FIXME hack to deal with pre ER5 / post ER5 bank file formats, remove when not an issue try: @@ -29,13 +31,24 @@ try: except AttributeError: banks = [svd_bank.read_bank(sys.argv[1])] +svdbin = sys.argv[1].split('_')[0].split('-')[1] +print("SVD BIN: ", svdbin) + +outpath = sys.argv[2] + +hf = h5py.File(outpath, 'a') +g1 = hf.create_group(f'{svdbin}') + totalMFLOPS=0 averageMFLOPS=0 totalMT = 0 +totalUT = 0 for i, bank in enumerate(banks): - print "" + g = hf.create_group(f'{svdbin}/subbank-{i}') + + print("") rT = [f.rate for f in bank.bank_fragments] r = numpy.array(sorted(list(set(rT)))) rT = numpy.array(rT) @@ -44,12 +57,16 @@ for i, bank in enumerate(banks): MT = [f.mix_matrix.shape[1] for f in bank.bank_fragments][0] NT = numpy.array([(f.end - f.start) * f.rate for f in bank.bank_fragments]) - print "\nSUB BANK %d" % i - print "--->\tUnique sampling rates: ",r - print "--->\tSampling rate for a given time slice: ",rT - print "--->\tTotal SVD filters for a given time slice: ",UT - print "--->\tNumber of SVD filter samples: ",NT - print "--->\tTotal real templates (e.g. twice number of complex templates): ",MT + print("\nSUB BANK %d" % i) + print("--->\tUnique sampling rates: ",r) + print("--->\tSampling rate for a given time slice: ",rT) + print("--->\tTotal SVD filters for a given time slice: ",UT) + print("--->\tNumber of SVD filter samples: ",NT) + print("--->\tTotal real templates (e.g. twice number of complex templates): ",MT) + + g.create_dataset('sample-rates', data=rT) + g.create_dataset('num-svd-filters', data=UT) + g.create_dataset('num-real-templates', data=MT) # 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 resample = (r * 16 * 2 * MT).sum() @@ -63,17 +80,23 @@ for i, bank in enumerate(banks): # get FLOPs per *complex* template (note the divide by 2) totalMT += MT / 2 - print "--->\tMFLOPS from resampling: ", resample / 1000.**2 - print "--->\tMFLOPS from filtering: ", filter / 1000.**2 - print "--->\tMFLOPS from reconstruction: ", reconstruct / 1000.**2 - print "--->\tMFLOPS from addition: ", add / 1000.**2 + totalUT += UT.sum() + print("--->\tMFLOPS from resampling: ", resample / 1000.**2) + print("--->\tMFLOPS from filtering: ", filter / 1000.**2) + print("--->\tMFLOPS from reconstruction: ", reconstruct / 1000.**2) + print("--->\tMFLOPS from addition: ", add / 1000.**2) MFLOPs = resample / 1000.**2 + filter / 1000.**2 + reconstruct / 1000.**2 + add / 1000.**2 totalMFLOPS += MFLOPs - print "--->\tTotal MFLOPS: ", MFLOPs - print "--->\tMFLOPS per complex template: ", MFLOPs / (MT / 2.) + print("--->\tTotal MFLOPS: ", MFLOPs) + print("--->\tMFLOPS per complex template: ", MFLOPs / (MT / 2.)) + print("--->\tRatio number SVD filters to number real input templates: ", UT.sum() / MT) + + g.create_dataset('total-mflops', data=MFLOPs) averageMFLOPS = totalMFLOPS / totalMT print("--\nAverage MFLOPS per template:", averageMFLOPS) +print("--\nAverage Ratio number SVD filters to number real input templates: ", totalUT / totalMT / 2) +hf.close()