Files
b210-k7-fpga/lib/rfnoc/crossbar/crossbar_tb/gen_load_latency_graph.py
T
+18 6b67702ad7 Merge FPGA repository back into UHD repository
The FPGA codebase was removed from the UHD repository in 2014 to reduce
the size of the repository. However, over the last half-decade, the
split between the repositories has proven more burdensome than it has
been helpful. By merging the FPGA code back, it will be possible to
create atomic commits that touch both FPGA and UHD codebases. Continuous
integration testing is also simplified by merging the repositories,
because it was previously difficult to automatically derive the correct
UHD branch when testing a feature branch on the FPGA repository.

This commit also updates the license files and paths therein.

We are therefore merging the repositories again. Future development for
FPGA code will happen in the same repository as the UHD host code and
MPM code.

== Original Codebase and Rebasing ==

The original FPGA repository will be hosted for the foreseeable future
at its original local location: https://github.com/EttusResearch/fpga/

It can be used for bisecting, reference, and a more detailed history.

The final commit from said repository to be merged here is
05003794e2da61cabf64dd278c45685a7abad7ec. This commit is tagged as
v4.0.0.0-pre-uhd-merge.

If you have changes in the FPGA repository that you want to rebase onto
the UHD repository, simply run the following commands:

- Create a directory to store patches (this should be an empty
  directory):

    mkdir ~/patches

- Now make sure that your FPGA codebase is based on the same state as
  the code that was merged:

    cd src/fpga # Or wherever your FPGA code is stored
    git rebase v4.0.0.0-pre-uhd-merge

  Note: The rebase command may look slightly different depending on what
  exactly you're trying to rebase.

- Create a patch set for your changes versus v4.0.0.0-pre-uhd-merge:

    git format-patch v4.0.0.0-pre-uhd-merge -o ~/patches

  Note: Make sure that only patches are stored in your output directory.
  It should otherwise be empty. Make sure that you picked the correct
  range of commits, and only commits you wanted to rebase were exported
  as patch files.

- Go to the UHD repository and apply the patches:

    cd src/uhd # Or wherever your UHD repository is stored
    git am --directory fpga ~/patches/*
    rm -rf ~/patches # This is for cleanup

== Contributors ==

The following people have contributed mainly to these files (this list
is not complete):

Co-authored-by: Alex Williams <alex.williams@ni.com>
Co-authored-by: Andrej Rode <andrej.rode@ettus.com>
Co-authored-by: Ashish Chaudhari <ashish@ettus.com>
Co-authored-by: Ben Hilburn <ben.hilburn@ettus.com>
Co-authored-by: Ciro Nishiguchi <ciro.nishiguchi@ni.com>
Co-authored-by: Daniel Jepson <daniel.jepson@ni.com>
Co-authored-by: Derek Kozel <derek.kozel@ettus.com>
Co-authored-by: EJ Kreinar <ej@he360.com>
Co-authored-by: Humberto Jimenez <humberto.jimenez@ni.com>
Co-authored-by: Ian Buckley <ian.buckley@gmail.com>
Co-authored-by: Jörg Hofrichter <joerg.hofrichter@ni.com>
Co-authored-by: Jon Kiser <jon.kiser@ni.com>
Co-authored-by: Josh Blum <josh@joshknows.com>
Co-authored-by: Jonathon Pendlum <jonathan.pendlum@ettus.com>
Co-authored-by: Martin Braun <martin.braun@ettus.com>
Co-authored-by: Matt Ettus <matt@ettus.com>
Co-authored-by: Michael West <michael.west@ettus.com>
Co-authored-by: Moritz Fischer <moritz.fischer@ettus.com>
Co-authored-by: Nick Foster <nick@ettus.com>
Co-authored-by: Nicolas Cuervo <nicolas.cuervo@ettus.com>
Co-authored-by: Paul Butler <paul.butler@ni.com>
Co-authored-by: Paul David <paul.david@ettus.com>
Co-authored-by: Ryan Marlow <ryan.marlow@ettus.com>
Co-authored-by: Sugandha Gupta <sugandha.gupta@ettus.com>
Co-authored-by: Sylvain Munaut <tnt@246tNt.com>
Co-authored-by: Trung Tran <trung.tran@ettus.com>
Co-authored-by: Vidush Vishwanath <vidush.vishwanath@ettus.com>
Co-authored-by: Wade Fife <wade.fife@ettus.com>


Original-commit: bafa9d95453387814ef25e6b6256ba8db2df612f
2020-01-28 09:35:36 -08:00

169 lines
6.6 KiB
Python
Executable File

#!/usr/bin/env python3
#
# Copyright 2018 Ettus Research, A National Instruments Company
#
# SPDX-License-Identifier: LGPL-3.0-or-later
#
# Description
# Parses the output files generated by crossbar_tb and outputs
# a load-latency graph and a expected-actual throughput graph
import os, sys
import argparse
import time
import glob
import csv
import re
import numpy as np
import matplotlib
#matplotlib.use('Agg')
import matplotlib.pyplot as plt
def get_options():
parser = argparse.ArgumentParser(description='Generate Load Latency Graphs')
parser.add_argument('datadir', type=str, default='.', help='Location of packet capture files generated by testbench')
return parser.parse_args()
TRAFFIC_PATTERNS = {'U':'UNIFORM', 'O':'UNIFORM_OTHERS', 'N':'NEIGHBOR', 'L':'LOOPBACK', 'S':'SEQUENTIAL', 'C':'BIT_COMPLEMENT', 'R':'RANDOM_PERM'}
class InfoFile():
def __init__(self, filename):
# Extract test info from filename
m = re.search(r".*/info_inj([0-9]+)_lpp([0-9]+)_traffic(.)_sess([0-9]+)\.csv", filename)
if m is None:
raise ValueError('Incorrect filename format: %s'%(filename))
self.inj_rate = int(m.group(1))
self.lpp = int(m.group(2))
self.traffic_patt = TRAFFIC_PATTERNS[m.group(3)]
self.session = int(m.group(4))
self.tx_pkts = 0
self.rx_pkts = 0
self.duration = 0
self.errs = 0
self.nodes = 0
with open(filename, 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
isheader = True
for row in reader:
if isheader:
isheader = False
if row != ['Impl', 'Node', 'TxPkts', 'RxPkts', 'Duration', 'ErrRoute', 'ErrData']:
raise ValueError('Incorrect header: %s'%(filename))
else:
self.impl = row[0]
self.tx_pkts = self.tx_pkts + int(row[2])
self.rx_pkts = self.tx_pkts + int(row[3])
self.duration = self.duration + int(row[4])
self.errs = self.errs + int(row[5]) + int(row[6])
self.nodes = self.nodes + 1
self.real_inj_rate = (100.0 * self.tx_pkts * self.lpp) / self.duration
class PktFile():
def __init__(self, filename):
# Extract test info from filename
m = re.search(r".*/pkts_node([0-9]+)_inj([0-9]+)_lpp([0-9]+)_traffic(.)_sess([0-9]+)\.csv", filename)
if m is None:
raise ValueError('Incorrect filename format: %s'%(filename))
self.node = int(m.group(1))
self.inj_rate = int(m.group(2))
self.lpp = int(m.group(3))
self.traffic_patt = TRAFFIC_PATTERNS[m.group(4)]
self.session = int(m.group(5))
self.latencies = []
with open(filename, 'r') as csvfile:
reader = csv.reader(csvfile, delimiter=',')
isheader = True
for row in reader:
if isheader:
isheader = False
if row != ['Src', 'Dst', 'Seqno', 'Error', 'Latency']:
raise ValueError('Incorrect header: %s'%(filename))
else:
self.latencies.append(int(row[4]))
########################################################################
# main
########################################################################
if __name__=='__main__':
options = get_options()
if (not os.path.isdir(options.datadir)):
print('ERROR: Data director %s does not exist'%(options.datadir))
sys.exit(1)
info_db = dict()
info_files = glob.glob(os.path.join(options.datadir, 'info*.csv'))
router_impl = ''
lines_per_pkt = 0
for ifile in info_files:
print('INFO: Reading %s...'%(ifile))
tmp = InfoFile(ifile)
router_impl = tmp.impl # Assume that all files have the same impl
lines_per_pkt = tmp.lpp # Assume that all files have the same LPP
info_db[(tmp.lpp, tmp.traffic_patt, tmp.inj_rate)] = tmp
pkt_db = dict()
pkts_files = glob.glob(os.path.join(options.datadir, 'pkts*.csv'))
for pfile in pkts_files:
print('INFO: Reading %s...'%(pfile))
tmp = PktFile(pfile)
config_key = (tmp.lpp, tmp.traffic_patt)
if config_key not in pkt_db:
pkt_db[config_key] = dict()
if tmp.inj_rate not in pkt_db[config_key]:
pkt_db[config_key][tmp.inj_rate] = []
pkt_db[config_key][tmp.inj_rate].extend(tmp.latencies)
# Write load-latency plots to file
actual_inj_rate_db = dict()
for config in sorted(pkt_db):
(lpp, traffic_patt) = config
ll_file = 'load-latency_%s_traffic-%s_lpp-%d.png'%(router_impl, traffic_patt, lpp)
print('INFO: Writing file ' + ll_file + '...')
percentile = [0, 25, 50, 75, 90, 95, 99, 99.9, 100]
plt.figure()
plt.title('Load Latency Graph for %s\n(Traffic: %s, LPP: %d)'%(router_impl, traffic_patt, lpp))
for p in percentile:
plot_data = dict()
for inj_rate in pkt_db[config]:
real_inj_rate = info_db[(lpp, traffic_patt, inj_rate)].real_inj_rate
plot_data[real_inj_rate] = np.percentile(pkt_db[config][inj_rate], p)
latencies = []
rates = []
for inj_rate in sorted(plot_data):
rates.append(inj_rate)
latencies.append(plot_data[inj_rate])
plt.plot(rates, latencies, label='$P_{%.1f}$'%(p))
plt.xlabel('Load (%)')
plt.xticks(range(0, 110, 10))
plt.ylabel('Latency (cycles)')
plt.grid(True)
plt.legend()
plt.savefig(os.path.join(options.datadir, ll_file), dpi=120)
# Generate actual inj_rate graph
real_inj_rates = []
for inj_rate in sorted(pkt_db[config]):
real_inj_rates.append(info_db[(lpp, traffic_patt, inj_rate)].real_inj_rate)
actual_inj_rate_db[config] = (sorted(pkt_db[config]), real_inj_rates)
# Write offered vs actual injection rate plots to file
injrate_file = 'injection-rate_%s_lpp-%d.png'%(router_impl, lines_per_pkt)
print('INFO: Writing file ' + injrate_file + '...')
plt.figure()
plt.title('Max Injection Rate Graph for %s'%(router_impl))
for config in actual_inj_rate_db:
(x, y) = actual_inj_rate_db[config]
plt.plot(x, y, label=str(config))
plt.xlabel('Offered Injection Rate (%)')
plt.xticks(range(0, 110, 10))
plt.ylabel('Accepted Injection Rate (%)')
plt.yticks(range(0, 110, 10))
plt.grid(True)
plt.legend()
plt.savefig(os.path.join(options.datadir, injrate_file), dpi=120)