File indexing completed on 2026-07-26 08:22:17
0001
0002
0003
0004
0005 import matplotlib.pyplot
0006 import pandas
0007 import argparse
0008 import logging
0009 import pathlib
0010 from datetime import datetime
0011
0012 log = logging.getLogger("traccc_plot")
0013
0014
0015 def main():
0016 parser = argparse.ArgumentParser()
0017
0018 parser.add_argument(
0019 "input",
0020 type=pathlib.Path,
0021 help="input CSV database",
0022 )
0023
0024 parser.add_argument(
0025 "output",
0026 type=pathlib.Path,
0027 help="output plot file",
0028 )
0029
0030 parser.add_argument(
0031 "--threshold",
0032 type=float,
0033 help="value in seconds under which to hide kernels",
0034 default=0.001,
0035 )
0036
0037 args = parser.parse_args()
0038
0039 logging.basicConfig(
0040 level=logging.INFO,
0041 format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
0042 )
0043
0044 log.info('Loading CSV database "%s"', args.input)
0045 df = pandas.read_csv(args.input)
0046
0047 valid_kernels = set()
0048
0049 ccs = []
0050
0051 log.info("Filtering kernels with a threshold of %f seconds", args.threshold)
0052
0053 for x in df.iloc:
0054 if x["rec_throughput"] >= args.threshold:
0055 valid_kernels.add(x["kernel"])
0056 if x["cc"] not in ccs:
0057 ccs.append(x["cc"])
0058
0059 log.info(
0060 "Plotting %d kernels over %d Compute Capabilities", len(valid_kernels), len(ccs)
0061 )
0062
0063 sorted_valid_kernels = sorted(list(valid_kernels))
0064
0065 px = 1 / matplotlib.pyplot.rcParams["figure.dpi"]
0066
0067 f, a = matplotlib.pyplot.subplots(1, 1, figsize=(806 * px, 600 * px))
0068
0069 xrange = list(range(len(ccs)))
0070
0071 for x in sorted_valid_kernels:
0072 x_data = []
0073 y_data = []
0074 y_error = []
0075
0076 for y in df.iloc:
0077 if y["kernel"] == x:
0078 x_data.append(ccs.index(y["cc"]))
0079 y_data.append(y["rec_throughput"] * 1000)
0080 y_error.append(y["rec_throughput_dev"] * 1000)
0081
0082 a.errorbar(
0083 x_data, y_data, yerr=y_error, label=x, marker="x", capsize=2, elinewidth=1
0084 )
0085
0086 a.set_xticks(
0087 xrange,
0088 ccs,
0089 )
0090 a.set_xlabel("Compute Capability (PTX Target)")
0091 a.set_ylabel("Reciprocal throughput [ms]")
0092 a.legend(prop={"family": "monospace"})
0093 a.grid(color="lightgray", linewidth=0.5)
0094 f.tight_layout()
0095
0096 log.info('Saving plot to "%s"', args.output)
0097
0098 f.savefig(args.output)
0099
0100
0101 if __name__ == "__main__":
0102 main()