1# Copyright (c) 2014-2017 John Biddiscombe 2# 3# Distributed under the Boost Software License, Version 1.0. (See accompanying 4# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6#!/usr/bin/python 7import optparse 8import itertools 9from io import StringIO 10import csv 11import os 12import re 13import glob 14import math 15import numpy 16from numpy import array 17import matplotlib 18from plot_utils import * 19 20workdir = os.getcwd() 21 22#---------------------------------------------------------------------------- 23if len(args) == 0 : 24 print("No input CSV file given") 25 exit(0) 26 27#---------------------------------------------------------------------------- 28# to plot something not already included, add it to this list 29T_RW_B_NB = {} 30T_B_RW_NB = {} 31 32#---------------------------------------------------------------------------- 33# 34# read results data in and generate arrays/maps of values 35# for each parcelport, threadcount, blocksize, ... 36for csvfile in args : 37 38 print("\nReading file ", csvfile) 39 40 # output file path for svg/png 41 base = os.path.splitext(csvfile)[0] 42 # empty list of graphs we will be fill for exporting 43 graphs_to_save = [] 44 45 # open the CSV file 46 with open(csvfile) as f: 47 io = StringIO(f.read().replace(':', ',')) 48 reader = csv.reader(io) 49 50 # loop over the CSV file lines, 51 # if the CSV output is changed for the test, these offsets will need to be corrected 52 for row in reader: 53 readflag = row[1].strip() in ("read") 54 Network = row[3] 55 Nodes = int(row[5]) 56 Threads = int(row[7]) 57 IOPsize = int(row[11]) 58 IOPs = float(row[13]) 59 BW = float(row[15])/1024.0 60 if (BW==0.0) : 61 BW = 1.0 62 print("read=%i Network=%s Nodes=%4i Threads=%3i IOPsize=%9i IOPs=%6.1f BW=%6.1f" % (readflag, Network, Nodes, Threads, IOPsize, IOPs, BW)) 63 64 # we use a map structure 3 deep with an array at the leaf, 65 # this allows us to store param1, param2, param3, {x,y} 66 # combinations of params cen be plotted against each other 67 # by rearranging the map levels and {x,y} vars. 68 insert_safe(T_RW_B_NB, Threads, readflag, IOPsize, [Nodes,BW]) 69 insert_safe(T_B_RW_NB, Threads, IOPsize, readflag, [Nodes,BW]) 70 71average_map(T_RW_B_NB) 72average_map(T_B_RW_NB) 73 74##------------------------------------------------------------------- 75## PLOT x-axis{Nodes}, y-axis{BW}, 76fig_T_RW_B_NB = plot_configuration(T_RW_B_NB, 77 ["Threads", "Mode", "Block size"], 78 ["Nodes", "BW GB/s"], 79 lambda x: "Read" if (x==1) else "Write", # Plot title 80 lambda x: sizeof_bytes(x), # Legend text 81 lambda x: "Threads = " + str(int(x)), # legend title 82 lambda x,pos: str(int(x)), # X Axis labels 83 [[2,0,12,0.0], [2,0,13,0.0]], # minmax (base, min, max, padding) 84 [0.0, 0.0] # legend offset 85 ) 86graphs_to_save.append([fig_T_RW_B_NB,"fig_T_RW_B_NB"]) 87 88##------------------------------------------------------------------- 89## PLOT x-axis{Nodes}, y-axis{BW}, 90fig_T_B_RW_NB = plot_configuration(T_B_RW_NB, 91 ["Threads", "Block size", "Mode"], 92 ["Nodes", "BW GB/s"], 93 lambda x: sizeof_bytes(x), # Plot title 94 lambda x: "Read" if (x==1) else "Write", # Legend text 95 lambda x: "Threads = " + str(int(x)), # legend title 96 lambda x,pos: str(int(x)), # X Axis labels 97 [[2,0,12,0.0], [2,0,13,0.0]], # minmax (base, min, max, padding) 98 [0.0, 0.0] # legend offset 99 ) 100graphs_to_save.append([fig_T_B_RW_NB,"fig_T_B_RW_NB"]) 101 102##------------------------------------------------------------------- 103# save plots to png and svg 104for fig in graphs_to_save: 105 svg_name = base + "." + fig[1] + ".svg" 106 png_name = base + "." + fig[1] + ".png" 107 print("Writing %s" % svg_name) 108 fig[0].savefig(svg_name) 109 #fig[0].savefig(png_name) 110 111#------------------------------------------------------------------- 112