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