Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Simple PCIe FMC carrier SPEC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Simple PCIe FMC carrier SPEC
Commits
e5879288
Commit
e5879288
authored
Jul 06, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw: add tools to measure throughput
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
5545419e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
+56
-0
spec_dma_throughput.py
software/tools/spec_dma_throughput.py
+56
-0
No files found.
software/tools/spec_dma_throughput.py
0 → 100755
View file @
e5879288
#!/usr/bin/python3
import
os
import
re
import
argparse
import
math
from
matplotlib
import
pyplot
from
PySPEC
import
PySPEC
def
dma_time_get
(
trace
):
start
=
re
.
search
(
r"([0-9]+\.[0-9]{6}): gn412x_dma_start_task"
,
trace
,
re
.
MULTILINE
)
assert
start
is
not
None
,
trace
assert
len
(
start
.
groups
())
==
1
end
=
re
.
search
(
r"([0-9]+\.[0-9]{6}): gn412x_dma_irq_handler"
,
trace
,
re
.
MULTILINE
)
assert
end
is
not
None
,
trace
assert
len
(
end
.
groups
())
==
1
return
round
(
float
(
end
.
group
(
1
))
-
float
(
start
.
group
(
1
)),
6
)
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'DMA Throughput'
)
parser
.
add_argument
(
'--pci-id'
,
dest
=
'pciid'
,
required
=
True
,
help
=
'SPEC PCI ID to use'
)
parser
.
add_argument
(
'--min'
,
default
=
4
*
1024
,
type
=
int
,
help
=
'Minimum transfer size in Bytes (default: 4096 Bytes). It is rounded to the lower power of 2.'
)
parser
.
add_argument
(
'--max'
,
default
=
4
*
1024
*
1024
,
type
=
int
,
help
=
'Maximum transfer size in Bytes (default: 4194304 Bytes). It is rounded to the lower power of 2.'
)
args
=
parser
.
parse_args
()
tracing_path
=
"/sys/kernel/debug/tracing"
with
open
(
os
.
path
.
join
(
tracing_path
,
"current_tracer"
),
"w"
)
as
f
:
f
.
write
(
"function"
)
with
open
(
os
.
path
.
join
(
tracing_path
,
"set_ftrace_filter"
),
"w"
)
as
f
:
f
.
write
(
"gn412x_dma_irq_handler
\n
gn412x_dma_start_task"
)
with
open
(
os
.
path
.
join
(
tracing_path
,
"trace"
),
"w"
)
as
f
:
f
.
write
(
""
)
spec
=
PySPEC
(
args
.
pciid
)
throughput
=
[]
sizes
=
[
2
**
x
for
x
in
range
(
int
(
math
.
log2
(
args
.
min
)),
int
(
math
.
log2
(
args
.
max
))
+
1
)]
for
size
in
sizes
:
with
open
(
os
.
path
.
join
(
tracing_path
,
"trace"
),
"w"
)
as
f
:
f
.
write
(
""
)
with
spec
.
dma
(
size
)
as
dma
:
dma
.
read
(
0
,
size
)
with
open
(
os
.
path
.
join
(
tracing_path
,
"trace"
),
"r"
)
as
f
:
throughput
.
append
((
float
(
size
)
/
1024
/
1024
)
/
dma_time_get
(
f
.
read
()))
print
(
"{:d} Bytes -> {:f} MBps"
.
format
(
size
,
throughput
[
-
1
]))
pyplot
.
title
(
"DMA throughput at different block sizes"
)
pyplot
.
xlabel
(
"DMA Size in Bytes"
)
pyplot
.
ylabel
(
"Throughput in MBps"
)
pyplot
.
plot
(
sizes
,
throughput
)
pyplot
.
show
()
if
__name__
==
"__main__"
:
main
()
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