μHAL (v2.8.17)
Part of the IPbus software repository
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
test_soak.cpp
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 Tom Williams, Rutherford Appleton Laboratory, Oxfordshire
30 email: tom.williams <AT> cern.ch
31
32---------------------------------------------------------------------------
33*/
34
35#include "uhal/uhal.hpp"
36
40#include "uhal/tests/tools.hpp"
41
42#include <boost/test/unit_test.hpp>
43#include <boost/filesystem.hpp>
44
45#include <vector>
46#include <algorithm>
47#include <string>
48#include <iostream>
49#include <cstdlib>
50#include <typeinfo>
51
52
53namespace uhal {
54namespace tests {
55
56
57void report_rx_performance(ClientInterface& aClient, const uint32_t aBaseAddr, const uint32_t aDepth, const size_t aNrIterations, const bool aDispatchEachIteration)
58{
59 double totalSeconds = measureReadLatency(aClient, aBaseAddr, aDepth, aNrIterations, aDispatchEachIteration, false);
60 double totalPayloadKB = aNrIterations * aDepth * 4. / 1024.;
61 double dataRateKB_s = totalPayloadKB/totalSeconds;
62 std::cout << " --> " << aNrIterations << " reads, each " << aDepth << " x 32-bit words, took " << totalSeconds << " seconds" << std::endl
63 << "Total IPbus payload received = " << totalPayloadKB << " KB\n"
64 << "Average read bandwidth = " << dataRateKB_s << " KB/s" << std::endl;
65}
66
67
68void report_tx_performance(ClientInterface& aClient, const uint32_t aBaseAddr, const uint32_t aDepth, const size_t aNrIterations, const bool aDispatchEachIteration)
69{
70 double totalSeconds = measureWriteLatency(aClient, aBaseAddr, aDepth, aNrIterations, aDispatchEachIteration, false);
71 double totalPayloadKB = aNrIterations * aDepth * 4. / 1024.;
72 double dataRateKB_s = totalPayloadKB/totalSeconds;
73 std::cout << " --> " << aNrIterations << " writes, each " << aDepth << " x 32-bit words, took " << totalSeconds << " seconds" << std::endl
74 << "Total IPbus payload received = " << totalPayloadKB << " KB\n"
75 << "Average read bandwidth = " << dataRateKB_s << " KB/s" << std::endl;
76
77}
78
79
81{
82 if (quickTest)
83 BOOST_TEST_MESSAGE(" *** Skipping soak tests since '--quick' flag was used ***");
84 else {
85 HwInterface hw = getHwInterface();
86
88 BOOST_CHECK_NO_THROW( report_rx_performance(hw.getClient(), 0x01, 262144, 100, true) );
89 }
90}
91)
92
93
95{
96 if (quickTest)
97 BOOST_TEST_MESSAGE(" *** Skipping soak tests since '--quick' flag was used ***");
98 else {
99
100 HwInterface hw = getHwInterface();
101
104 }
105}
106)
107
108
109UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(SoakTestSuite, quick_soak, DummyHardwareFixture,
110{
111 if (quickTest)
112 BOOST_TEST_MESSAGE(" *** Skipping soak tests since '--quick' flag was used ***");
113 else {
114 HwInterface hw = getHwInterface();
115
116 std::vector<ClientInterface*> lClients;
117 lClients.push_back(&hw.getClient());
118
119 BOOST_CHECK( PerfTester::runValidationTest(lClients, 0x1000, 1024, 2000, false, false) );
120 }
121}
122)
123
124
125} // end ns tests
126} // end ns uhal
127
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
Definition: HwInterface.hpp:56
ClientInterface & getClient()
Get the underlying IPbus client.
Definition: HwInterface.cpp:78
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)
None tests(nox.Session session)
Definition: noxfile.py:19
BOOST_CHECK_NO_THROW(hw.getNode("REG").writeBlock(xx))
BOOST_CHECK(!mem.valid())
HwInterface hw
double measureReadLatency(ClientInterface &aClient, uint32_t aBaseAddr, uint32_t aDepth, size_t aNrIterations, bool aDispatchEachIteration, bool aVerbose)
Definition: tools.cpp:68
void report_rx_performance(ClientInterface &aClient, const uint32_t aBaseAddr, const uint32_t aDepth, const size_t aNrIterations, const bool aDispatchEachIteration)
Definition: test_soak.cpp:57
void report_tx_performance(ClientInterface &aClient, const uint32_t aBaseAddr, const uint32_t aDepth, const size_t aNrIterations, const bool aDispatchEachIteration)
Definition: test_soak.cpp:68
double measureWriteLatency(ClientInterface &aClient, uint32_t aBaseAddr, uint32_t aDepth, size_t aNrIterations, bool aDispatchEachIteration, bool aVerbose)
Definition: tools.cpp:105
#define UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(test_suite_name, test_case_name, test_fixture, test_case_contents)
Definition: definitions.hpp:53