from nsim.setup import get_exec_path from mesh_gen import get_meshinfo import os filename_in = "perf.dat" filename = "perf-ext.dat" gnuplot_filename = "plot.gnp" # Get mesh info from the file lines_left = get_meshinfo() def tonum(x): try: return int(x) except: return float(x) # Read timing data f = open(filename_in, "r") lines_right = f.read().splitlines()[1:] f.close() print lines_left, lines_right lines = [line_left + " " + line_right for line_left, line_right in zip(lines_left, lines_right)] # Write the timings data complemented with the column "nodes per mesh" f = open(filename, "w") f.write("\n".join(lines)) # Now write the Gnuplot file to plot the data row0 = [tonum(x) for x in lines[0].split()]
"\n".join([" ".join([str(c) for c in cols]) for cols in data])) f.close() ref_data = extract_data(ref_filename) header = extract_header(ref_filename) + "\n" whole_data = [] # whole_data[nr_cpus][mesh_nr][simulation_section_nr] for filename in filenames: data = extract_data(filename) out_data = [[float(x)/ref_x for x, ref_x in zip(row, ref_row)] for row, ref_row in zip(data, ref_data)] whole_data.append(out_data) write_data("rel_" + filename, out_data, header=header) meshinfo = get_meshinfo() heading = header.split() nr_meshes = len(whole_data[0]) nr_sects = len(whole_data[0][0]) nr_cpus = len(whole_data) for sec in range(nr_sects): h = heading[sec] if h.startswith("num"): continue f = open("sec-%s.dat" % h, "w") for mesh in range(nr_meshes): for cpu in range(nr_cpus): nr_nodes = meshinfo[mesh] speedup = 1.0/whole_data[cpu][mesh][sec]