Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SWIFT
SWIFTsim
Commits
0c4ceb01
Commit
0c4ceb01
authored
May 24, 2017
by
Peter W. Draper
Browse files
Threads are not a contiguous range, so handle that
parent
1b2c8ee9
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/analyse_tasks.py
View file @
0c4ceb01
...
...
@@ -59,8 +59,8 @@ SUBTYPES = ["none", "density", "gradient", "force", "grav", "external_grav",
# Read input.
data
=
pl
.
loadtxt
(
infile
)
n
thread
=
int
(
max
(
data
[:,
0
]))
+
1
print
"
Number of
thread
s
:"
,
n
thread
max
thread
=
int
(
max
(
data
[:,
0
]))
+
1
print
"
# Maximum
thread
id
:"
,
max
thread
# Recover the start and end time
full_step
=
data
[
0
,:]
...
...
@@ -77,7 +77,7 @@ data = data[data[:,5] != 0]
# Calculate the time range.
total_t
=
(
toc_step
-
tic_step
)
/
CPU_CLOCK
print
"Data range: "
,
total_t
,
"ms"
print
"
#
Data range: "
,
total_t
,
"ms"
# Correct times to relative values.
start_t
=
float
(
tic_step
)
...
...
@@ -86,7 +86,7 @@ data[:,5] -= start_t
tasks
=
{}
tasks
[
-
1
]
=
[]
for
i
in
range
(
n
thread
):
for
i
in
range
(
max
thread
):
tasks
[
i
]
=
[]
# Gather into by thread data.
...
...
@@ -100,9 +100,12 @@ for line in range(num_lines):
tasks
[
thread
].
append
([
tic
,
toc
,
tasktype
,
subtype
])
# Sort by tic.
for
i
in
range
(
nthread
):
tasks
[
i
]
=
sorted
(
tasks
[
i
],
key
=
lambda
task
:
task
[
0
])
# Sort by tic and gather used thread ids.
threadids
=
[]
for
i
in
range
(
maxthread
):
if
len
(
tasks
[
i
])
>
0
:
tasks
[
i
]
=
sorted
(
tasks
[
i
],
key
=
lambda
task
:
task
[
0
])
threadids
.
append
(
i
)
# Times per task.
print
"# Task times:"
...
...
@@ -110,7 +113,7 @@ print "# {0:<16s}: {1:>7s} {2:>9s} {3:>9s} {4:>9s} {5:>9s} {6:>9s}"\
.
format
(
"type/subtype"
,
"count"
,
"minimum"
,
"maximum"
,
"sum"
,
"mean"
,
"percent"
)
alltasktimes
=
{}
for
i
in
range
(
n
thread
)
:
for
i
in
thread
ids
:
tasktimes
=
{}
for
task
in
tasks
[
i
]:
key
=
TASKTYPES
[
task
[
2
]]
+
"/"
+
SUBTYPES
[
task
[
3
]]
...
...
@@ -141,7 +144,7 @@ for key in sorted(alltasktimes.keys()):
print
"{0:18s}: {1:7d} {2:9.4f} {3:9.4f} {4:9.4f} {5:9.4f} {6:9.2f}"
\
.
format
(
key
,
len
(
alltasktimes
[
key
]),
taskmin
,
taskmax
,
tasksum
,
tasksum
/
len
(
alltasktimes
[
key
]),
tasksum
/
(
n
thread
*
total_t
)
*
100.0
)
tasksum
/
(
len
(
thread
ids
)
*
total_t
)
*
100.0
)
print
# Dead times.
...
...
@@ -149,7 +152,7 @@ print "# Deadtimes:"
print
"# no. : {0:>9s} {1:>9s} {2:>9s} {3:>9s} {4:>9s} {5:>9s}"
\
.
format
(
"count"
,
"minimum"
,
"maximum"
,
"sum"
,
"mean"
,
"percent"
)
alldeadtimes
=
[]
for
i
in
range
(
n
thread
)
:
for
i
in
thread
ids
:
deadtimes
=
[]
last
=
0
for
task
in
tasks
[
i
]:
...
...
@@ -173,7 +176,7 @@ deadsum = sum(alldeadtimes)
print
"all : {0:9d} {1:9.4f} {2:9.4f} {3:9.4f} {4:9.4f} {5:9.2f}"
\
.
format
(
len
(
alldeadtimes
),
deadmin
,
deadmax
,
deadsum
,
deadsum
/
len
(
alldeadtimes
),
deadsum
/
(
n
thread
*
total_t
)
*
100.0
)
deadsum
/
(
len
(
thread
ids
)
*
total_t
)
*
100.0
)
print
...
...
examples/analyse_tasks_MPI.py
View file @
0c4ceb01
...
...
@@ -67,8 +67,8 @@ if args.verbose:
nranks
=
int
(
max
(
data
[:,
0
]))
+
1
print
"# Number of ranks:"
,
nranks
n
thread
=
int
(
max
(
data
[:,
1
]))
+
1
print
"#
Number of
thread
s
:"
,
n
thread
max
thread
=
int
(
max
(
data
[:,
1
]))
+
1
print
"#
Maximum
thread
id
:"
,
max
thread
# Avoid start and end times of zero.
sdata
=
data
[
data
[:,
5
]
!=
0
]
...
...
@@ -101,7 +101,7 @@ for rank in range(nranks):
tasks
=
{}
tasks
[
-
1
]
=
[]
for
i
in
range
(
n
thread
):
for
i
in
range
(
max
thread
):
tasks
[
i
]
=
[]
# Gather into by thread data.
...
...
@@ -115,9 +115,11 @@ for rank in range(nranks):
tasks
[
thread
].
append
([
tic
,
toc
,
tasktype
,
subtype
])
# Sort by tic.
for
i
in
range
(
nthread
):
# Sort by tic and gather used threads.
threadids
=
[]
for
i
in
range
(
maxthread
):
tasks
[
i
]
=
sorted
(
tasks
[
i
],
key
=
lambda
task
:
task
[
0
])
threadids
.
append
(
i
)
# Times per task.
print
"# Task times:"
...
...
@@ -125,7 +127,7 @@ for rank in range(nranks):
.
format
(
"type/subtype"
,
"count"
,
"minimum"
,
"maximum"
,
"sum"
,
"mean"
,
"percent"
)
alltasktimes
=
{}
for
i
in
range
(
n
thread
)
:
for
i
in
thread
ids
:
tasktimes
=
{}
for
task
in
tasks
[
i
]:
key
=
TASKTYPES
[
task
[
2
]]
+
"/"
+
SUBTYPES
[
task
[
3
]]
...
...
@@ -156,7 +158,7 @@ for rank in range(nranks):
print
"{0:18s}: {1:7d} {2:9.4f} {3:9.4f} {4:9.4f} {5:9.4f} {6:9.2f}"
\
.
format
(
key
,
len
(
alltasktimes
[
key
]),
taskmin
,
taskmax
,
tasksum
,
tasksum
/
len
(
alltasktimes
[
key
]),
tasksum
/
(
n
thread
*
total_t
)
*
100.0
)
tasksum
/
(
len
(
thread
ids
)
*
total_t
)
*
100.0
)
print
# Dead times.
...
...
@@ -164,7 +166,7 @@ for rank in range(nranks):
print
"# no. : {0:>9s} {1:>9s} {2:>9s} {3:>9s} {4:>9s} {5:>9s}"
\
.
format
(
"count"
,
"minimum"
,
"maximum"
,
"sum"
,
"mean"
,
"percent"
)
alldeadtimes
=
[]
for
i
in
range
(
n
thread
)
:
for
i
in
thread
ids
:
deadtimes
=
[]
last
=
0
for
task
in
tasks
[
i
]:
...
...
@@ -188,7 +190,7 @@ for rank in range(nranks):
print
"all : {0:9d} {1:9.4f} {2:9.4f} {3:9.4f} {4:9.4f} {5:9.2f}"
\
.
format
(
len
(
alldeadtimes
),
deadmin
,
deadmax
,
deadsum
,
deadsum
/
len
(
alldeadtimes
),
deadsum
/
(
n
thread
*
total_t
)
*
100.0
)
deadsum
/
(
len
(
thread
ids
)
*
total_t
)
*
100.0
)
print
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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