μHAL (v2.7.9)
Part of the IPbus software repository
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 
39 #include "uhal/tests/fixtures.hpp"
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 
53 namespace uhal {
54 namespace tests {
55 
56 
57 void 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 
68 void 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 
87  BOOST_CHECK_NO_THROW( report_rx_performance(hw.getClient(), 0x01, 1, 100, true) );
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 
103  BOOST_CHECK_NO_THROW( report_tx_performance(hw.getClient(), 0x01, 262144, 100, true) );
104  }
105 }
106 )
107 
108 
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 
tools.hpp
uhal::HwInterface
A class which bundles a node tree and an IPbus client interface together providing everything you nee...
Definition: HwInterface.hpp:61
fixtures.hpp
uhal::tests::BOOST_CHECK
BOOST_CHECK(!mem.valid())
uhal::ClientInterface
An abstract base class for defining the interface to the various IPbus clients as well as providing t...
Definition: ClientInterface.hpp:100
uhal::tests::PerfTester::runValidationTest
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)
Definition: PerfTester_static.cpp:315
definitions.hpp
uhal::tests::report_tx_performance
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
uhal
Definition: HttpResponseGrammar.hpp:49
uhal::tests::hw
HwInterface hw
Definition: test_rawclient.cpp:93
uhal::tests::measureWriteLatency
double measureWriteLatency(ClientInterface &aClient, uint32_t aBaseAddr, uint32_t aDepth, size_t aNrIterations, bool aDispatchEachIteration, bool aVerbose)
Definition: tools.cpp:111
uhal::tests::DummyHardwareFixture
Definition: fixtures.hpp:135
uhal::HwInterface::getClient
ClientInterface & getClient()
Get the underlying IPbus client.
Definition: HwInterface.cpp:83
uhal::tests::UHAL_TESTS_DEFINE_CLIENT_TEST_CASES
UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(BlockReadWriteTestSuite, block_write_read, DummyHardwareFixture, { std::vector< size_t > lDepths=getBlockUnitTestDepths(quickTest ? N_1MB :N_10MB);for(size_t i=0;i< lDepths.size();i++) { const size_t N=lDepths.at(i);BOOST_TEST_MESSAGE(" N = "<< N);HwInterface hw=getHwInterface();std::vector< uint32_t > xx;xx.reserve(N);for(size_t i=0;i!=N;++i) { xx.push_back(static_cast< uint32_t >(rand()));} hw.getNode("LARGE_MEM").writeBlock(xx);ValVector< uint32_t > mem=hw.getNode("LARGE_MEM").readBlock(N);BOOST_CHECK(!mem.valid());BOOST_CHECK_EQUAL(mem.size(), N);if(N > 0) { BOOST_CHECK_THROW(mem.at(0), uhal::exception::NonValidatedMemory);} BOOST_CHECK_THROW(mem.value(), uhal::exception::NonValidatedMemory);BOOST_CHECK_NO_THROW(hw.dispatch());BOOST_CHECK(mem.valid());BOOST_CHECK_EQUAL(mem.size(), N);if(N< N_10MB) { bool correct_block_write_read=true;std::vector< uint32_t >::const_iterator j=xx.begin();for(ValVector< uint32_t >::const_iterator i(mem.begin());i!=mem.end();++i,++j) { correct_block_write_read=correct_block_write_read &&(*i== *j);} BOOST_CHECK(correct_block_write_read);} } }) UHAL_TESTS_DEFINE_CLIENT_TEST_CASES(BlockReadWriteTestSuite
PerfTester.hxx
uhal.hpp
uhal::tests::DummyHardwareFixture
DummyHardwareFixture
Definition: test_block.cpp:131
uhal::tests::report_rx_performance
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
uhal::tests::BOOST_CHECK_NO_THROW
BOOST_CHECK_NO_THROW(hw.getNode("REG").writeBlock(xx))
uhal::tests::bandwidth_tx
bandwidth_tx
Definition: test_soak.cpp:94
uhal::tests::measureReadLatency
double measureReadLatency(ClientInterface &aClient, uint32_t aBaseAddr, uint32_t aDepth, size_t aNrIterations, bool aDispatchEachIteration, bool aVerbose)
Definition: tools.cpp:67