Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
MTIP
spinifel
Commits
f1134801
Commit
f1134801
authored
Feb 24, 2022
by
Hsing-Yin Chang
Browse files
add parse output script
parent
7d27aec9
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/parseOutput.py
0 → 100644
View file @
f1134801
import
re
import
argparse
import
numpy
as
np
def
parse_output
(
filename
,
num_nodes
,
num_ranks
):
pattern_load
=
re
.
compile
(
"Loaded in \d+\.\d+s"
)
pattern_merge
=
re
.
compile
(
"AC recovered in \d+\.\d+s"
)
pattern_phase
=
re
.
compile
(
"Problem phased in \d+\.\d+s"
)
pattern_slice
=
re
.
compile
(
"slice=\d+\.\d+s"
)
pattern_slice_oh
=
re
.
compile
(
"slice_oh=\d+\.\d+s"
)
pattern_match
=
re
.
compile
(
"match=\d+\.\d+s"
)
pattern_match_oh
=
re
.
compile
(
"match_oh=\d+\.\d+s"
)
pattern_completed
=
re
.
compile
(
"completed in \d+\.\d+s"
)
merge
=
[]
phase
=
[]
slices
=
[]
slice_oh
=
[]
ori_match
=
[]
ori_match_oh
=
[]
completed
=
[]
for
i
,
line
in
enumerate
(
open
(
filename
)):
for
match
in
re
.
findall
(
pattern_load
,
line
):
loading_time
=
float
(
re
.
findall
(
"\d+\.\d+"
,
match
)[
0
])
for
match
in
re
.
findall
(
pattern_merge
,
line
):
merge
.
append
(
float
(
re
.
findall
(
"\d+\.\d+"
,
match
)[
0
]))
for
match
in
re
.
findall
(
pattern_phase
,
line
):
phase
.
append
(
float
(
re
.
findall
(
"\d+\.\d+"
,
match
)[
0
]))
for
match
in
re
.
findall
(
pattern_slice
,
line
):
slices
.
append
(
float
(
re
.
findall
(
"\d+\.\d+"
,
match
)[
0
]))
for
match
in
re
.
findall
(
pattern_slice_oh
,
line
):
slice_oh
.
append
(
float
(
re
.
findall
(
"\d+\.\d+"
,
match
)[
0
]))
for
match
in
re
.
findall
(
pattern_match
,
line
):
ori_match
.
append
(
float
(
re
.
findall
(
"\d+\.\d+"
,
match
)[
0
]))
for
match
in
re
.
findall
(
pattern_match_oh
,
line
):
ori_match_oh
.
append
(
float
(
re
.
findall
(
"\d+\.\d+"
,
match
)[
0
]))
for
match
in
re
.
findall
(
pattern_completed
,
line
):
completed_time
=
float
(
re
.
findall
(
"\d+\.\d+"
,
match
)[
0
])
# merging & phasing are performed independently by each rank
# monitor the longest time
merging_max
,
merging_min
,
merging_mean
,
merging_std
=
np
.
max
(
merge
),
np
.
min
(
merge
),
np
.
mean
(
merge
),
np
.
std
(
merge
)
phasing_max
,
phasing_min
,
phasing_mean
,
phasing_std
=
np
.
max
(
phase
),
np
.
min
(
phase
),
np
.
mean
(
phase
),
np
.
std
(
phase
)
# slicing & orientation matching perform a subset of the task
tot_ranks
=
int
(
num_nodes
*
num_ranks
)
num_gen
=
int
(
len
(
slices
)
/
tot_ranks
)
num_times
=
tot_ranks
*
num_gen
slicing_max
,
slicing_min
,
slicing_mean
,
slicing_std
=
np
.
max
(
slice_oh
)
+
np
.
max
(
slices
),
\
np
.
min
(
slice_oh
)
+
np
.
min
(
slices
),
\
(
np
.
sum
(
slice_oh
)
+
np
.
sum
(
slices
))
/
num_times
,
\
(
np
.
std
(
slice_oh
)
+
np
.
std
(
slices
))
/
num_times
ori_match_max
,
ori_match_min
,
ori_match_mean
,
ori_match_std
=
np
.
max
(
ori_match_oh
)
+
np
.
max
(
ori_match
),
\
np
.
min
(
ori_match_oh
)
+
np
.
min
(
ori_match
),
\
(
np
.
sum
(
ori_match_oh
)
+
np
.
sum
(
ori_match
))
/
num_times
,
\
(
np
.
std
(
ori_match_oh
)
+
np
.
std
(
ori_match
))
/
num_times
print
(
f
"Max/min/mean/std time per generation and total time for
{
num_gen
}
generations in seconds"
)
print
(
f
"Loading time:
{
loading_time
:.
3
f
}
"
)
print
(
f
"Slicing time:
{
slicing_max
:.
3
f
}
/
{
slicing_min
:.
3
f
}
/
{
slicing_mean
:.
3
f
}
/
{
slicing_std
:.
3
f
}
/
{
(
sum
(
slice_oh
)
+
sum
(
slices
))
/
tot_ranks
:.
3
f
}
"
)
print
(
f
"Orientation matching time:
{
ori_match_max
:.
3
f
}
/
{
ori_match_min
:.
3
f
}
/
{
ori_match_mean
:.
3
f
}
/
{
ori_match_std
:.
3
f
}
/
{
(
sum
(
ori_match_oh
)
+
sum
(
ori_match
))
/
tot_ranks
:.
3
f
}
"
)
print
(
f
"Merging time:
{
merging_max
:.
3
f
}
/
{
merging_min
:.
3
f
}
/
{
merging_mean
:.
3
f
}
/
{
merging_std
:.
3
f
}
/
{
sum
(
merge
):.
3
f
}
"
)
print
(
f
"Phasing time:
{
phasing_max
:.
3
f
}
/
{
phasing_min
:.
3
f
}
/
{
phasing_mean
:.
3
f
}
/
{
phasing_std
:.
3
f
}
/
{
sum
(
phase
):.
3
f
}
"
)
print
(
f
"Total time from start to finish for
{
num_gen
}
generations:
{
completed_time
:.
3
f
}
"
)
if
__name__
==
"__main__"
:
parser
=
argparse
.
ArgumentParser
(
description
=
'Process arguments to parseOutput'
)
#positional arguments
parser
.
add_argument
(
'--fname'
,
help
=
'name of output file'
,
type
=
str
)
parser
.
add_argument
(
'--nodes'
,
help
=
'number of nodes'
,
type
=
int
)
parser
.
add_argument
(
'--ranks'
,
help
=
'number of ranks per node'
,
type
=
int
)
args
=
parser
.
parse_args
()
parse_output
(
args
.
fname
,
args
.
nodes
,
args
.
ranks
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment