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