μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PerfTester.hxx
Go to the documentation of this file.
1/*
2---------------------------------------------------------------------------
3
4 This file is part of uHAL.
5
6 uHAL is a hardware access library and programming framework
7 originally developed for upgrades of the Level-1 trigger of the CMS
8 experiment at CERN.
9
10 uHAL is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 uHAL is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with uHAL. If not, see <http://www.gnu.org/licenses/>.
22
23 Marc Magrans de Abril, CERN
24 email: marc.magrans.de.abril <AT> cern.ch
25
26 Andrew Rose, Imperial College, London
27 email: awr01 <AT> imperial.ac.uk
28
29---------------------------------------------------------------------------
30*/
31
32#ifndef _uhal_tests_PerfTester_hpp_
33#define _uhal_tests_PerfTester_hpp_
34
44// C++ headers
45#include <vector>
46#include <string>
47
48// Linux C++ headers
49#include <sys/time.h>
50
51// uHAL headers
52#include "uhal/uhal.hpp"
53
54namespace uhal
55{
56 namespace tests
57 {
59 {
60 public:
61
63 PerfTester();
64
67
69
72 int run ( int argc, char* argv[] );
73
74
75 private:
76
77 // PRIVATE TYPEDEFS
78
80 typedef uint32_t U32;
81
83 typedef std::vector< U32 > U32Vec;
84
87
89 typedef std::vector< std::string > StringVec;
90
92 typedef void ( PerfTester::*PtrToTestFunc ) ();
93
95 typedef std::map<std::string, PtrToTestFunc> TestFuncMap;
96
98 typedef std::map<std::string, std::string> TestDescMap;
99
101 typedef std::shared_ptr<uhal::ClientInterface> ClientPtr;
102
104 typedef std::vector< ClientPtr > ClientVec;
105
106
107 // PRIVATE MEMBER VARIABLES
108
113 std::string m_testName;
114 uint64_t m_iterations;
115 std::string m_baseAddrStr;
116 boost::uint32_t m_baseAddr;
117 boost::uint32_t m_bandwidthTestDepth;
121
122
123 // PRIVATE MEMBER FUNCTIONS - Test infrastructure
124
126 void outputHelpText ( const std::string& argDescriptions ) const;
127
129 void outputTestDescriptionsList() const;
130
132 bool badInput() const;
133
135 void outputUserChoices() const;
136
138 void buildClients();
139
141 void outputStandardResults ( double totalSeconds ) const;
142
144 static uint32_t getRandomBlockSize ( const uint32_t maxSize );
145
147 static U32Vec getRandomBuffer ( unsigned size );
148
150 bool buffersEqual ( const U32Vec& writeBuffer, const U32ValVec& readBuffer ) const;
151
153 static bool validation_test_single_write_read ( uhal::ClientInterface& c, const uint32_t addr, const bool perTransactionDispatch, const bool aVerbose );
154
156 static bool validation_test_block_write_read ( uhal::ClientInterface& c, const uint32_t addr, const uint32_t depth, const bool perTransactionDispatch, const bool aVerbose );
157
159 static bool validation_test_write_rmwbits_read ( uhal::ClientInterface& c, const uint32_t addr, const bool perTransactionDispatch, const bool aVerbose );
160
162 static bool validation_test_write_rmwsum_read ( uhal::ClientInterface& c, const uint32_t addr, const bool perTransactionDispatch, const bool aVerbose );
163
164 // PRIVATE MEMBER FUNCTIONS - IPbus test functions that users can run
165
166 void bandwidthRxTest();
167 void bandwidthTxTest();
168 void validationTest();
169
170 public:
171
172 static bool runValidationTest(const std::vector<ClientInterface*>& aClients, const uint32_t aBaseAddr, const uint32_t aDepth, const size_t aNrIterations, const bool aDispatchEachIteration, const bool aVerbose);
173
174 private:
175 void sandbox();
176
177 // PRIVATE CLASSES
178
180 {
181 public:
183 virtual ~QueuedTransaction() { }
184
185 virtual bool check_values() = 0;
186 };
187
188
190 {
191 public:
192 QueuedBlockRead ( const uint32_t addr, const ValVector<uint32_t>& valVector, std::vector<uint32_t>::const_iterator expectedValuesIt );
194
195 virtual bool check_values();
196
197 private:
198 // PRIVATE MEMBER DATA
199 uint32_t m_depth, m_addr;
201 std::vector<uint32_t> m_expected;
202 };
203
204
206 {
207 public:
208 QueuedBlockWrite ( const uint32_t addr, const uint32_t depth, const ValHeader& valHeader );
210
211 virtual bool check_values();
212
213 private:
214 // PRIVATE MEMBER DATA
215 uint32_t m_depth, m_addr;
217 };
218
219
221 {
222 public:
223 QueuedRmwBits ( const uint32_t addr, const uint32_t a, const uint32_t b, const ValWord<uint32_t>& valWord, const uint32_t expected );
225 virtual bool check_values();
226
227 private:
228 const uint32_t m_addr, m_and, m_or;
230 const uint32_t m_expected;
231 };
232
233
235 {
236 public:
237 QueuedRmwSum ( const uint32_t addr, const uint32_t a, const ValWord<uint32_t>& valWord, const uint32_t expected );
239 virtual bool check_values();
240
241 private:
242 const uint32_t m_addr, m_addend;
244 const uint32_t m_expected;
245 };
246
247 }; /* End of class PerfTester */
248
249 } /* End of namespace tests */
250
251} /* End of namespace uhal */
252
253#endif /* _uhal_tests_PerfTester_hpp_ */
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
A class which wraps a single word of data and marks whether or not it is valid.
Definition: ValMem.hpp:147
A class which wraps a block of data and marks whether or not it is valid.
Definition: ValMem.hpp:273
A class which wraps a single word of data and marks whether or not it is valid.
Definition: ValMem.hpp:189
bool badInput() const
Returns true if the user has entered bad command line arguments.
Definition: PerfTester.cxx:209
void sandbox()
An area for a user-definable test.
Definition: PerfTester.cxx:359
void outputUserChoices() const
Outputs the user's choices to screen.
Definition: PerfTester.cxx:228
void bandwidthTxTest()
Write bandwidth test.
Definition: PerfTester.cxx:321
static bool validation_test_single_write_read(uhal::ClientInterface &c, const uint32_t addr, const bool perTransactionDispatch, const bool aVerbose)
Validation test – single-register write/read-back.
TestFuncMap m_testFuncMap
Maps test name to test function.
Definition: PerfTester.hxx:110
std::map< std::string, PtrToTestFunc > TestFuncMap
Typedef for a map that links the name of a test to the function that performs it.
Definition: PerfTester.hxx:95
std::string m_baseAddrStr
Base addr of reg/ram the test will use. Use a string as workaround for hex input via boost::program_o...
Definition: PerfTester.hxx:115
PerfTester()
Constructor - takes no arguments, does nothing.
Definition: PerfTester.cxx:59
void outputHelpText(const std::string &argDescriptions) const
Outputs the standard help text to screen.
Definition: PerfTester.cxx:179
void buildClients()
Constructs and sets up the appropriate IPbusClient for use in the test.
Definition: PerfTester.cxx:247
void bandwidthRxTest()
Read bandwidth test.
Definition: PerfTester.cxx:294
bool m_includeConnect
Include (e.g. TCP) connect time in reported bandwidth/latency.
Definition: PerfTester.hxx:120
ClientVec m_clients
Vector of low-level uHAL clients.
Definition: PerfTester.hxx:112
bool m_perIterationDispatch
Perform a network dispatch every iteration flag.
Definition: PerfTester.hxx:119
std::vector< ClientPtr > ClientVec
Typedef for a vector of raw client interfaces.
Definition: PerfTester.hxx:104
static bool validation_test_write_rmwbits_read(uhal::ClientInterface &c, const uint32_t addr, const bool perTransactionDispatch, const bool aVerbose)
Validation test – write, RMW bits, read.
std::map< std::string, std::string > TestDescMap
Typedef for a map that links the name of a test to its description.
Definition: PerfTester.hxx:98
StringVec m_deviceURIs
Vector of individual connection URI strings.
Definition: PerfTester.hxx:111
std::vector< std::string > StringVec
A vector of strings.
Definition: PerfTester.hxx:89
uint64_t m_iterations
Number of test iterations.
Definition: PerfTester.hxx:114
int run(int argc, char *argv[])
Pass in the two command-line parameter variables, this will define the test that then gets run.
Definition: PerfTester.cxx:92
std::vector< U32 > U32Vec
A vector of unsigned 32-bit words.
Definition: PerfTester.hxx:83
static bool validation_test_write_rmwsum_read(uhal::ClientInterface &c, const uint32_t addr, const bool perTransactionDispatch, const bool aVerbose)
Validation test – write, RMW sum, read.
uint32_t U32
An unsigned 32-bit word.
Definition: PerfTester.hxx:80
TestDescMap m_testDescMap
Maps test name to test description.
Definition: PerfTester.hxx:109
bool buffersEqual(const U32Vec &writeBuffer, const U32ValVec &readBuffer) const
Compares a write buffer with one or more ValVec read responses.
Definition: PerfTester.cxx:286
static bool validation_test_block_write_read(uhal::ClientInterface &c, const uint32_t addr, const uint32_t depth, const bool perTransactionDispatch, const bool aVerbose)
Validation test – block write/read-back.
void outputTestDescriptionsList() const
Outputs the test names and descriptions to screen.
Definition: PerfTester.cxx:193
void validationTest()
Historic basic firmware/software validation test.
Definition: PerfTester.cxx:348
static U32Vec getRandomBuffer(unsigned size)
Returns a buffer of random numbers.
std::string m_testName
Holds the test name.
Definition: PerfTester.hxx:113
void outputStandardResults(double totalSeconds) const
Outputs a standard result set to screen - provide it with the number of seconds the test took.
Definition: PerfTester.cxx:273
static uint32_t getRandomBlockSize(const uint32_t maxSize)
Returns a random uint32_t in the range [0,maxSize], with 1/x probability distribution – so that p(x=0...
std::shared_ptr< uhal::ClientInterface > ClientPtr
Typedef for a ClientInterface shared_ptr.
Definition: PerfTester.hxx:101
static bool runValidationTest(const std::vector< ClientInterface * > &aClients, const uint32_t aBaseAddr, const uint32_t aDepth, const size_t aNrIterations, const bool aDispatchEachIteration, const bool aVerbose)
boost::uint32_t m_baseAddr
The m_baseAddrStr as converted into an actual unsigned value.
Definition: PerfTester.hxx:116
~PerfTester()
Destructor.
Definition: PerfTester.hxx:66
uhal::ValVector< U32 > U32ValVec
A Validated Vector of U32.
Definition: PerfTester.hxx:86
bool m_verbose
Verbosity true/false flag.
Definition: PerfTester.hxx:118
boost::uint32_t m_bandwidthTestDepth
The depth of read/write used in bandwidth tests.
Definition: PerfTester.hxx:117
void(PerfTester::* PtrToTestFunc)()
Function pointer typedef to a test function.
Definition: PerfTester.hxx:92
None tests(nox.Session session)
Definition: noxfile.py:19
ClientInterface * c