1d13e9b48SJed Brown#!/usr/bin/env python3 2d13e9b48SJed Brown# Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC. 3d13e9b48SJed Brown# Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. 4d13e9b48SJed Brown# All Rights reserved. See files LICENSE and NOTICE for details. 5d13e9b48SJed Brown# 6d13e9b48SJed Brown# This file is part of CEED, a collection of benchmarks, miniapps, software 7d13e9b48SJed Brown# libraries and APIs for efficient high-order finite element and spectral 8d13e9b48SJed Brown# element discretizations for exascale applications. For more information and 9*3d8e8822SJeremy L Thompson# source code availability see http://github.com/ceed 10d13e9b48SJed Brown# 11d13e9b48SJed Brown# The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 12d13e9b48SJed Brown# a collaborative effort of two U.S. Department of Energy organizations (Office 13d13e9b48SJed Brown# of Science and the National Nuclear Security Administration) responsible for 14d13e9b48SJed Brown# the planning and preparation of a capable exascale ecosystem, including 15d13e9b48SJed Brown# software, applications, hardware, advanced system engineering and early 16d13e9b48SJed Brown# testbed platforms, in support of the nation's exascale computing imperative. 17d13e9b48SJed Brown 18d13e9b48SJed Brownimport pandas as pd 19d13e9b48SJed Brownimport fileinput 20d13e9b48SJed Brownimport pprint 21d13e9b48SJed Brown 22dec49e00SJed Brown# Read all input files specified on the command line, or stdin and parse 23dec49e00SJed Brown# the content, storing it as a pandas dataframe 24dec49e00SJed Brown 25dec49e00SJed Brown 26d13e9b48SJed Browndef read_logs(files=None): 27aa2aa0aeSJed Brown """Read all input files and return pandas DataFrame""" 28aa2aa0aeSJed Brown data_default = dict( 29dd839fb7SJed Brown file='unknown', 30dd839fb7SJed Brown backend='unknown', 31aa2aa0aeSJed Brown backend_memtype='unknown', 32aa2aa0aeSJed Brown hostname='unknown', 33dd839fb7SJed Brown test='unknown', 34dd839fb7SJed Brown num_procs=0, 35dd839fb7SJed Brown num_procs_node=0, 36dd839fb7SJed Brown degree=0, 37dd839fb7SJed Brown quadrature_pts=0, 38dd839fb7SJed Brown code='libCEED', 39dd839fb7SJed Brown ) 40aa2aa0aeSJed Brown data = data_default.copy() 41dd839fb7SJed Brown 42d13e9b48SJed Brown runs = [] 43aa2aa0aeSJed Brown for line in fileinput.input(files): 44dec49e00SJed Brown # Legacy header contains number of MPI tasks 45dd839fb7SJed Brown if 'Running the tests using a total of' in line: 46aa2aa0aeSJed Brown data = data_default.copy() 47dec49e00SJed Brown data['num_procs'] = int( 48dec49e00SJed Brown line.split( 49dec49e00SJed Brown 'a total of ', 50dec49e00SJed Brown 1)[1].split( 51dec49e00SJed Brown None, 52dec49e00SJed Brown 1)[0]) 53dec49e00SJed Brown # MPI tasks per node 54d13e9b48SJed Brown elif 'tasks per node' in line: 55dec49e00SJed Brown data['num_procs_node'] = int( 56dec49e00SJed Brown line.split( 57dec49e00SJed Brown ' tasks per', 58dec49e00SJed Brown 1)[0].rsplit( 59dec49e00SJed Brown None, 60dec49e00SJed Brown 1)[1]) 61dec49e00SJed Brown # New Benchmark Problem 62d13e9b48SJed Brown elif "CEED Benchmark Problem" in line: 63dd839fb7SJed Brown # Starting a new block 64dd839fb7SJed Brown data = data.copy() 65dd839fb7SJed Brown runs.append(data) 66dd839fb7SJed Brown data['file'] = fileinput.filename() 67d13e9b48SJed Brown data['test'] = line.split()[-2] + " " + line.split('-- ')[1] 68aa2aa0aeSJed Brown data['bp'] = data['test'].rsplit()[-1] 69d13e9b48SJed Brown data['case'] = 'scalar' if (('Problem 1' in line) or ('Problem 3' in line) 70d13e9b48SJed Brown or ('Problem 5' in line)) else 'vector' 71dd839fb7SJed Brown elif "Hostname" in line: 72dd839fb7SJed Brown data['hostname'] = line.split(':')[1].strip() 73dd839fb7SJed Brown elif "Total ranks" in line: 74dd839fb7SJed Brown data['num_procs'] = int(line.split(':')[1].strip()) 75aa2aa0aeSJed Brown elif "Ranks per compute node" in line: 76dd839fb7SJed Brown data['num_procs_node'] = int(line.split(':')[1].strip()) 77dec49e00SJed Brown # Backend 78d13e9b48SJed Brown elif 'libCEED Backend MemType' in line: 79d13e9b48SJed Brown data['backend_memtype'] = line.split(':')[1].strip() 80d13e9b48SJed Brown elif 'libCEED Backend' in line: 81d13e9b48SJed Brown data['backend'] = line.split(':')[1].strip() 82dec49e00SJed Brown # P 83d13e9b48SJed Brown elif 'Basis Nodes' in line: 84d13e9b48SJed Brown data['degree'] = int(line.split(':')[1]) - 1 85dec49e00SJed Brown # Q 86d13e9b48SJed Brown elif 'Quadrature Points' in line: 87aa2aa0aeSJed Brown data['quadrature_pts'] = int(line.split(':')[1]) 88dec49e00SJed Brown # Total DOFs 89d13e9b48SJed Brown elif 'Global nodes' in line: 90d13e9b48SJed Brown data['num_unknowns'] = int(line.split(':')[1]) 91d13e9b48SJed Brown if data['case'] == 'vector': 92d13e9b48SJed Brown data['num_unknowns'] *= 3 93aa2aa0aeSJed Brown elif 'Global DOFs' in line: # Legacy 94aa2aa0aeSJed Brown data['num_unknowns'] = int(line.split(':')[1]) 95dec49e00SJed Brown # Number of elements 96d13e9b48SJed Brown elif 'Local Elements' in line: 97dec49e00SJed Brown data['num_elem'] = int( 98dec49e00SJed Brown line.split(':')[1].split()[0]) * data['num_procs'] 99aa2aa0aeSJed Brown elif 'DoF per node' in line: 100aa2aa0aeSJed Brown data['dof_per_node'] = int(line.split(':')[1]) 101dec49e00SJed Brown # CG Solve Time 102d13e9b48SJed Brown elif 'Total KSP Iterations' in line: 103d13e9b48SJed Brown data['ksp_its'] = int(line.split(':')[1].split()[0]) 104d13e9b48SJed Brown elif 'CG Solve Time' in line: 105dec49e00SJed Brown data['time_per_it'] = float( 106dec49e00SJed Brown line.split(':')[1].split()[0]) / data['ksp_its'] 107dec49e00SJed Brown # CG DOFs/Sec 108aa2aa0aeSJed Brown elif 'DoFs/Sec in CG' in line or 'DOFs/Sec in CG' in line: 109dec49e00SJed Brown data['cg_iteration_dps'] = 1e6 * \ 110dec49e00SJed Brown float(line.split(':')[1].split()[0]) 111dec49e00SJed Brown # End of output 112d13e9b48SJed Brown 113d13e9b48SJed Brown return pd.DataFrame(runs) 114d13e9b48SJed Brown 115dec49e00SJed Brown 116d13e9b48SJed Brownif __name__ == "__main__": 117d13e9b48SJed Brown runs = read_logs() 118aa2aa0aeSJed Brown print(runs) # Print summary (about 10 lines) 119aa2aa0aeSJed Brown print('First entry:\n', runs.iloc[0]) 120aa2aa0aeSJed Brown print('Last entry:\n', runs.iloc[-1]) 121