Mercurial > cgi-bin > hgwebdir.cgi > VMS > 2__runs_and_data
comparison scripts/overhead_result_calc.py @ 27:2ef6476f3628
movie
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Fri, 01 Feb 2013 18:17:21 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a7230a874fbf |
|---|---|
| 1 #! /usr/bin/env python | |
| 2 # -*- coding: utf-8 -*- | |
| 3 | |
| 4 import sys | |
| 5 from re import search | |
| 6 import datetime | |
| 7 from os.path import basename | |
| 8 | |
| 9 """ | |
| 10 This script generates a graph that represents the overhead | |
| 11 involved in synchronisation operations | |
| 12 """ | |
| 13 | |
| 14 usage=""" | |
| 15 This generates an output file for each value of number-of-threads that give the number of all runs. | |
| 16 As an input it expects a result file which is generated by the overhead_result_calc.py script. | |
| 17 The file extension of the result file has to be ".meas". | |
| 18 It is expected that the output directory's path is meaningful, such as machine-name, date, and so on | |
| 19 Usage: | |
| 20 %s [result files] [path to output dir] | |
| 21 """ % sys.argv[0] | |
| 22 | |
| 23 if len(sys.argv) < 3: | |
| 24 print usage | |
| 25 sys.exit(0) | |
| 26 | |
| 27 result_filenames = sys.argv[1:-1] | |
| 28 output_dir_path = sys.argv[-1] | |
| 29 | |
| 30 for result_filename in result_filenames: | |
| 31 #open input file | |
| 32 try: | |
| 33 result_file = open(result_filename,"r") | |
| 34 except: | |
| 35 print "Cannot open result file %s" % result_filename | |
| 36 sys.exit(1) | |
| 37 | |
| 38 #parse(evaluate) result file | |
| 39 try: | |
| 40 exec(result_file.read()) | |
| 41 except: | |
| 42 print "Cannot parse result file: %s" % result_filename | |
| 43 result_file.close() | |
| 44 sys.exit(1) | |
| 45 result_file.close() | |
| 46 | |
| 47 #check for file extension | |
| 48 result_filename = basename(result_filename) | |
| 49 if search("\.meas$",result_filename) == None: | |
| 50 print "Wrong file extension! Has to be '.meas'" | |
| 51 sys.exit(1) | |
| 52 | |
| 53 output = output_dir_path + "/" + result_filename.replace(".meas",".result") | |
| 54 #open gnuplot output | |
| 55 try: | |
| 56 gnuplot_output = open(output,"w") | |
| 57 except IOError: | |
| 58 print "Cannot open output file %s" % output | |
| 59 result_file.close() | |
| 60 sys.exit(1) | |
| 61 | |
| 62 table_header = "# %20s\t%20s\t%20s\t%20s\t%20s\t%20s\t%20s\t%20s\n" % ( | |
| 63 "<iters per task>", | |
| 64 "<total exe cycles>", | |
| 65 "<total work cyc>", | |
| 66 "<one task cyc>", | |
| 67 "<total overhead cyc>", | |
| 68 "<num syncs>", | |
| 69 "<overhead per Sync cyc>", | |
| 70 "<Exe/Work ratio>") | |
| 71 | |
| 72 #write header to file | |
| 73 gnuplot_output.writelines(["# Output file name: %s\n" % data_filename, | |
| 74 "# Date of Run: %s\n" % date_of_run, | |
| 75 "# Number of Cores: %d\n" % NUM_CORES, | |
| 76 "# Number of Threads: %f per Core, %d total\n" % (threads_per_core, totalThreads), | |
| 77 table_header, | |
| 78 "# " + (len(table_header)-3)*"-" + "\n"]) | |
| 79 | |
| 80 #Now print the results out | |
| 81 for workload_iterations_in_task in ITERS_PER_TASK_TABLE: | |
| 82 results = array_of_results[workload_iterations_in_task] | |
| 83 | |
| 84 #take shortest run | |
| 85 results.sort(lambda x,y: cmp(x["total_exe_cycles"],y["total_exe_cycles"])) | |
| 86 total_workcycles = results[0]["total_workcycles"] | |
| 87 total_exe_cycles = results[0]["total_exe_cycles"] | |
| 88 #exeCycles_workCycles_ratio = results[0]["exeCycles_workCycles_ratio"] | |
| 89 | |
| 90 #Calculate numbers | |
| 91 overhead = total_exe_cycles - total_workcycles | |
| 92 total_syncs = totalThreads * TASKS_PER_THREAD * 2 | |
| 93 overhead_per_sync = float(overhead) / float(total_syncs) | |
| 94 cycles_of_task = float(total_workcycles) / float(TASKS_PER_THREAD * totalThreads) | |
| 95 overhead_per_core = float(overhead) / NUM_CORES | |
| 96 workcycles_per_core = total_workcycles / NUM_CORES | |
| 97 | |
| 98 # The 2 is in there because we have two sync operations in one per outer iteration | |
| 99 exeCycles_workCycles_ratio = float(total_workcycles+float(overhead)/2)/float(total_workcycles) | |
| 100 | |
| 101 gnuplot_output.write("%20d\t%20d\t%20d\t%20f\t%20d\t%20d\t%20f\t%20f\n" % ( | |
| 102 workload_iterations_in_task, | |
| 103 total_exe_cycles, | |
| 104 total_workcycles, | |
| 105 cycles_of_task, | |
| 106 overhead, | |
| 107 total_syncs, | |
| 108 overhead_per_sync, | |
| 109 exeCycles_workCycles_ratio)) | |
| 110 | |
| 111 gnuplot_output.close(); |
