-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make AoS and SoA share the matrix44 and transform3 tpyes
- Loading branch information
1 parent
7968a97
commit 05f9fa0
Showing
15 changed files
with
356 additions
and
538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
# Algebra plugins library, part of the ACTS project | ||
# | ||
# (c) 2024 CERN for the benefit of the ACTS project | ||
# | ||
# Mozilla Public License Version 2.0 | ||
|
||
# python includes | ||
import argparse | ||
import logging | ||
import json | ||
import pandas as pd | ||
import os | ||
import sys | ||
from datetime import datetime | ||
import pathlib | ||
|
||
""" Parse commandline arguments """ | ||
def parse_arguments(): | ||
#----------------------------------------------------------------arg parsing | ||
|
||
parser = argparse.ArgumentParser(description = "Compare benchmarks") | ||
parser.add_argument("--debug", "-d", | ||
help=("Enables debug output"), | ||
action="store_true") | ||
parser.add_argument("--logfile", | ||
help=("Write log in file"), | ||
default = "", type=str) | ||
parser.add_argument("--input", "-i", nargs='+', | ||
help=("Input material scan data file."), | ||
default = "", type=str) | ||
parser.add_argument("--outdir", "-o", | ||
help=("Output directory for plots."), | ||
default = "./material_plots/", type=str) | ||
parser.add_argument("--output_format", "-of", | ||
help=("Format of the plot files (svg|png|pdf)."), | ||
default = "png", type=str) | ||
|
||
args = parser.parse_args() | ||
|
||
#---------------------------------------------------------------------config | ||
|
||
# Check output path | ||
if not os.path.isdir(args.outdir): | ||
os.mkdir(args.outdir, 0o755) | ||
outdir = args.outdir | ||
|
||
# Check input data files | ||
if len(args.input) == 0: | ||
logging.error(f"Please specify an input data file!") | ||
sys.exit(1) | ||
|
||
for input_file in args.input: | ||
if not os.path.isfile(input_file): | ||
logging.error(f"Data file does not exist! ({input_file})") | ||
sys.exit(1) | ||
|
||
if not args.output_format in ["svg", "png", "pdf"]: | ||
logging.error(f"Unknown output file format: {args.output_format}") | ||
sys.exit(1) | ||
|
||
# Set log level | ||
logLevel = logging.INFO | ||
if args.debug: | ||
logLevel = logging.DEBUG | ||
|
||
# Check logfile path | ||
if args.logfile != "": | ||
logDirName = os.path.dirname(args.logfile) | ||
|
||
if logDirName != "" and not os.path.isdir(logDirName): | ||
os.mkdir(logDirName, 0o755) | ||
|
||
if not os.path.isfile(args.logfile): | ||
with open(args.logfile, 'x'): pass | ||
|
||
# Write log in logfile | ||
logging.basicConfig(filename=args.logfile, | ||
format=("%(levelname)s (%(module)s):" | ||
" %(message)s"), level=logLevel) | ||
else: | ||
# Write log to terminal | ||
logging.basicConfig(format=("%(levelname)s (%(module)s):" | ||
" %(message)s"), level=logLevel) | ||
|
||
logging.info("\n--------------------------------------------------------\n" | ||
"Plotting benchmarks - "+\ | ||
str(datetime.now().strftime("%d/%m/%Y %H:%M"))+\ | ||
"\n->files: " + str(len(args.input)) +\ | ||
"\n--------------------------------------------------------\n") | ||
|
||
return args | ||
|
||
#----------------------------------------------------------------prepare data | ||
|
||
"""Read benchmark data into pandas frame""" | ||
def read_data(args): | ||
|
||
benchmarks = {} | ||
for input_file in args.input: | ||
with open(input_file, 'r') as file: | ||
extension = pathlib.Path(input_file).suffix | ||
name = input_file.removesuffix(extension) | ||
try: | ||
json_data = json.load(file) | ||
benchmarks[name] = pd.DataFrame(json_data["benchmarks"]) | ||
except ValueError: | ||
logging.error('Could not parse the benchmark data') | ||
exit(1) | ||
|
||
benchmarks[name]['label'] = benchmarks[name]['name'].apply(lambda x: x.split("/")[0].split("_")[1:]) | ||
|
||
return benchmarks | ||
|
||
|
||
"""Display the benchmark data""" | ||
def plot_benchmarks(data, args): | ||
x = np.arange(len(data[0] / 3)) # Always three entries per benchmark case | ||
width = 0.15 # the width of the bars | ||
|
||
# Reorganize into benchmark families | ||
families = {} | ||
for plugin in data: | ||
for index, row in df.sort_values(by=['family_index']).iterrows(): | ||
print(row['familiy_index']) | ||
|
||
|
||
bars_eigen = ax.bar(x - 1.5*width, eigen, width, label='eigen', yerr=eigen_err) | ||
bars_AoS = ax.bar(x - 0.5*width, AoS, width, label='AoS', yerr=AoS_err) | ||
bars_hybrid = ax.bar(x + 0.5*width, hybrid, width, label='hybrid', yerr=hybrid_err) | ||
bars_horiz = ax.bar(x + 1.5*width, horiz, width, label='horiz', yerr=horiz_err) | ||
|
||
|
||
fig, ax = plt.subplots() | ||
|
||
# Add some text for labels, title and custom x-axis tick labels, etc. | ||
ax.set_ylabel('speedup') | ||
ax.set_title('speed up relative to Eigen sse(double) - preliminary') | ||
ax.set_xticks(x) | ||
ax.set_xticklabels(labels) | ||
ax.legend() | ||
|
||
autolabel(bars_eigen, ax) | ||
autolabel(bars_AoS, ax) | ||
autolabel(bars_hybrid, ax) | ||
autolabel(bars_horiz, ax) | ||
|
||
fig.tight_layout() | ||
|
||
plot_file_name = "./aggregate_plots/speedup_comparision.png" | ||
fig.savefig(plot_file_name, dpi=100) | ||
fig.clf() | ||
plt.close(fig) | ||
|
||
|
||
def main(): | ||
args = parse_arguments() | ||
data = read_data(args) | ||
plot_benchmarks(data, args) | ||
|
||
print(data['vc_aos_vector_bench']) | ||
|
||
#------------------------------------------------------------------------------- | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
||
#------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.