From 67d4bbff66fdbb11694f837aa9056e85447a6268 Mon Sep 17 00:00:00 2001 From: Cedric Nugteren Date: Sun, 23 Apr 2017 17:59:16 +0200 Subject: Added an option to the database script to remove tuning results from the database --- scripts/database/database.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'scripts/database') diff --git a/scripts/database/database.py b/scripts/database/database.py index f1af634b..e398aa30 100755 --- a/scripts/database/database.py +++ b/scripts/database/database.py @@ -63,12 +63,28 @@ def remove_mismatched_arguments(database): assert len(group_by_arguments) == 1 +def remove_database_entries(database, remove_if_matches_fields): + assert len(remove_if_matches_fields.keys()) > 0 + + def remove_this_entry(section): + for key in remove_if_matches_fields.keys(): + if section[key] != remove_if_matches_fields[key]: + return False + return True + + old_length = len(database["sections"]) + database["sections"] = [x for x in database["sections"] if not remove_this_entry(x)] + new_length = len(database["sections"]) + print("[database] Removed %d entries from the database" % (old_length - new_length)) + + def main(argv): # Parses the command-line arguments parser = argparse.ArgumentParser() parser.add_argument("source_folder", help="The folder with JSON files to parse to add to the database") parser.add_argument("clblast_root", help="Root of the CLBlast sources") + parser.add_argument("-r", "--remove_device", type=str, default=None, help="Removes all entries for a specific device") parser.add_argument("-v", "--verbose", action="store_true", help="Increase verbosity of the script") cl_args = parser.parse_args(argv) @@ -117,6 +133,12 @@ def main(argv): if len(glob.glob(json_files)) >= 1: io.save_database(database, database_filename) + # Removes database entries before continuing + if cl_args.remove_device is not None: + print("[database] Removing all results for device '%s'" % cl_args.remove_device) + remove_database_entries(database, {"device": cl_args.remove_device}) + io.save_database(database, database_filename) + # Retrieves the best performing results print("[database] Calculating the best results per device/kernel...") database_best_results = bests.get_best_results(database) -- cgit v1.2.3