xref: /libCEED/benchmarks/postprocess_base.py (revision dd839fb73dfd4a3191bf7b0eef12fe704a18a864)
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    data = dict(
30        file='unknown',
31        backend='unknown',
32        test='unknown',
33        num_procs=0,
34        num_procs_node=0,
35        degree=0,
36        quadrature_pts=0,
37        code='libCEED',
38        )
39
40    runs=[]
41    while True:
42       ##
43       if state%2==0:
44          ##
45          try:
46             line=next(it)
47             i=i+1
48          except StopIteration:
49             break
50          state=state+1
51          ##
52       elif state==1:
53          ##
54          state=0
55          ## Legacy header contains number of MPI tasks
56          if 'Running the tests using a total of' in line:
57             data['num_procs'] = int(line.split('a total of ',1)[1].split(None,1)[0])
58          ## MPI tasks per node
59          elif 'tasks per node' in line:
60             data['num_procs_node'] = int(line.split(' tasks per',1)[0].rsplit(None,1)[1])
61          ## New Benchmark Problem
62          elif "CEED Benchmark Problem" in line:
63             # Starting a new block
64             data = data.copy()
65             runs.append(data)
66             data['file'] = fileinput.filename()
67             data['test'] = line.split()[-2] + " " + line.split('-- ')[1]
68             data['case']='scalar' if (('Problem 1' in line) or ('Problem 3' in line)
69                                      or ('Problem 5' in line)) else 'vector'
70          elif "Hostname" in line:
71              data['hostname'] = line.split(':')[1].strip()
72          elif "Total ranks" in line:
73              data['num_procs'] = int(line.split(':')[1].strip())
74          elif "Ranks per node" in line:
75              data['num_procs_node'] = int(line.split(':')[1].strip())
76          ## Backend
77          elif 'libCEED Backend MemType' in line:
78             data['backend_memtype']=line.split(':')[1].strip()
79          elif 'libCEED Backend' in line:
80             data['backend']=line.split(':')[1].strip()
81          ## P
82          elif 'Basis Nodes' in line:
83             data['degree']=int(line.split(':')[1]) - 1
84          ## Q
85          elif 'Quadrature Points' in line:
86             qpts=int(line.split(':')[1])
87             data['quadrature_pts']=qpts**3
88          ## Total DOFs
89          elif 'Global nodes' in line:
90             data['num_unknowns']=int(line.split(':')[1])
91             if data['case']=='vector':
92                data['num_unknowns']*=3
93          ## Number of elements
94          elif 'Local Elements' in line:
95             data['num_elem']=int(line.split(':')[1].split()[0])*data['num_procs']
96          ## CG Solve Time
97          elif 'Total KSP Iterations' in line:
98              data['ksp_its'] = int(line.split(':')[1].split()[0])
99          elif 'CG Solve Time' in line:
100              data['time_per_it'] = float(line.split(':')[1].split()[0]) / data['ksp_its']
101          ## CG DOFs/Sec
102          elif 'DoFs/Sec in CG' in line:
103             data['cg_iteration_dps']=1e6*float(line.split(':')[1].split()[0])
104          ## End of output
105
106    return pd.DataFrame(runs)
107
108if __name__ == "__main__":
109    runs = read_logs()
110    print('Number of test runs read: %i'%len(runs))
111    print(runs)
112