xref: /libCEED/benchmarks/postprocess_base.py (revision d13e9b485390d2a242cbc549de647bb7b44f1cad)
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
24def read_logs(files=None):
25    it=fileinput.input(files)
26    state = 0
27    line=''
28    i=0
29    mesh_p=0
30    config='unknown'
31    backend='unknown'
32    test='unknown'
33    num_procs=0
34    num_procs_node=0
35    lnfmt='%05i'
36    data={}
37    runs=[]
38    while True:
39       ##
40       if state%2==0:
41          ##
42          try:
43             line=next(it)
44             i=i+1
45          except StopIteration:
46             break
47          state=state+1
48          ##
49       elif state==1:
50          ##
51          state=0
52          if 'Reading configuration' in line:
53             ##
54             ## This is the beginning of a new file.
55             ##
56             config=line.split()[2]
57             num_procs=0
58             num_procs_node=0
59          ## Number of MPI tasks
60          elif 'Running the tests using a total of' in line:
61             num_procs=int(line.split('a total of ',1)[1].split(None,1)[0])
62          ## MPI tasks per node
63          elif 'tasks per node' in line:
64             num_procs_node=int(line.split(' tasks per',1)[0].rsplit(None,1)[1])
65          elif line == 'Running test:\n':
66             ##
67             ## This is the beginning of a new run.
68             ##
69
70             ## Add last row
71             if 'cg_iteration_dps' in data:
72                runs.append(data)
73             ## New row
74             data={}
75             data['file']=fileinput.filename()
76             data['config']=config
77             data['backend']=backend
78             data['test']=test
79             data['num_procs']=num_procs
80             data['num_procs_node']=num_procs_node
81             data['degree']=mesh_p
82             data['quadrature_pts']=mesh_p
83             data['code']="libCEED"
84             test_=test.rsplit('/',1)[-1]
85             data['case']='scalar'
86          ## Benchmark Problem
87          elif "CEED Benchmark Problem" in line:
88             data['test'] = line.split()[-2] + " " + line.split('-- ')[1]
89             data['case']='scalar' if (('Problem 1' in line) or ('Problem 3' in line)
90                                      or ('Problem 5' in line)) else 'vector'
91          ## Backend
92          elif 'libCEED Backend MemType' in line:
93             data['backend_memtype']=line.split(':')[1].strip()
94          elif 'libCEED Backend' in line:
95             data['backend']=line.split(':')[1].strip()
96          ## P
97          elif 'Basis Nodes' in line:
98             data['degree']=int(line.split(':')[1]) - 1
99          ## Q
100          elif 'Quadrature Points' in line:
101             qpts=int(line.split(':')[1])
102             data['quadrature_pts']=qpts**3
103          ## Total DOFs
104          elif 'Global nodes' in line:
105             data['num_unknowns']=int(line.split(':')[1])
106             if data['case']=='vector':
107                data['num_unknowns']*=3
108          ## Number of elements
109          elif 'Local Elements' in line:
110             data['num_elem']=int(line.split(':')[1].split()[0])*data['num_procs']
111          ## CG Solve Time
112          elif 'Total KSP Iterations' in line:
113              data['ksp_its'] = int(line.split(':')[1].split()[0])
114          elif 'CG Solve Time' in line:
115              data['time_per_it'] = float(line.split(':')[1].split()[0]) / data['ksp_its']
116          ## CG DOFs/Sec
117          elif 'DoFs/Sec in CG' in line:
118             data['cg_iteration_dps']=1e6*float(line.split(':')[1].split()[0])
119          ## End of output
120
121    ## Add last row
122    if 'cg_iteration_dps' in data:
123       runs.append(data)
124
125    return pd.DataFrame(runs)
126
127if __name__ == "__main__":
128    runs = read_logs()
129    print('Number of test runs read: %i'%len(runs))
130