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