JFConversion: Clean-up
This commit is contained in:
@@ -5,16 +5,11 @@
|
||||
#include <iomanip>
|
||||
#include <future>
|
||||
|
||||
#include <numa.h>
|
||||
|
||||
#include "../jungfrau/JFPedestalCalc.h"
|
||||
#include "../common/Logger.h"
|
||||
#include "../jungfrau/JFCalibration.h"
|
||||
#include "../jungfrau/JFConversionFloatingPoint.h"
|
||||
#include "../jungfrau/JFConversionFixedPoint.h"
|
||||
#include "../tests/FPGAUnitTest.h"
|
||||
#include "../jungfrau/jf_packet.h"
|
||||
#include "../jungfrau/ProcessJFPacket.h"
|
||||
|
||||
void test_pedestal(Logger &logger) {
|
||||
size_t nframes = 5000;
|
||||
@@ -92,60 +87,10 @@ template <class T> void test_conversion(Logger &logger) {
|
||||
ntries * nframes * nmodules * RAW_MODULE_SIZE * sizeof(uint16_t) * 1000 * 1000/ ((double) elapsed.count() * 1024 * 1024 * 1024));
|
||||
}
|
||||
|
||||
void test_packet_processing(Logger &logger) {
|
||||
size_t nframes = 128;
|
||||
int64_t nmodules = 8;
|
||||
int64_t ntries = 8;
|
||||
|
||||
std::vector<jf_raw_packet> packets(nframes * nmodules * 128);
|
||||
std::vector<uint16_t> output(nframes * nmodules * CONVERTED_MODULE_SIZE);
|
||||
|
||||
std::vector<uint16_t> input(RAW_MODULE_SIZE);
|
||||
std::string image_path = "../../tests/test_data/mod5_raw0.bin";
|
||||
LoadBinaryFile(image_path, input.data(), RAW_MODULE_SIZE);
|
||||
|
||||
for (int frame = 0; frame < nframes; frame++) {
|
||||
for (int m = 0; m < nmodules; m++) {
|
||||
for (int p = 0; p < 128; p++) {
|
||||
packets.at((frame * 128 + p) * nmodules + m).jf.xCoord = (m * 2);
|
||||
packets.at((frame * 128 + p) * nmodules + m).jf.packetnum = p;
|
||||
packets.at((frame * 128 + p) * nmodules + m).jf.framenum = frame + 1;
|
||||
memcpy(packets.at((frame * 128 + p) * nmodules + m).jf.data, input.data() + 4096 * p, 4096 * sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto start_time = std::chrono::system_clock::now();
|
||||
for (int z = 0; z < ntries; z++) {
|
||||
ThreadSafeFIFO<Completion> c;
|
||||
ThreadSafeFIFO<WorkRequest> wr;
|
||||
ProcessJFPacket process(c, wr, nmodules);
|
||||
|
||||
for (uint32_t i = 0; i < nmodules * nframes; i++)
|
||||
wr.Put(WorkRequest{
|
||||
.ptr = output.data() + i * RAW_MODULE_SIZE,
|
||||
.handle = i
|
||||
});
|
||||
for (auto &packet: packets)
|
||||
process.ProcessPacket(&packet.jf);
|
||||
}
|
||||
auto end_time = std::chrono::system_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::microseconds>(end_time - start_time);
|
||||
|
||||
logger.Info("Packet analysis performance: {:5d} us/module {:5.2f} GB/s", std::lround(elapsed.count() / ((double) (ntries * nframes * nmodules))),
|
||||
ntries * nframes * nmodules * RAW_MODULE_SIZE * sizeof(uint16_t) * 1000 * 1000/ ((double) elapsed.count() * 1024 * 1024 * 1024));
|
||||
}
|
||||
|
||||
int main () {
|
||||
Logger logger("JFCalibrationPerfTest");
|
||||
test_pedestal(logger);
|
||||
|
||||
logger.Info("Floating point conversion");
|
||||
test_conversion<JFConversionFloatingPoint>(logger);
|
||||
|
||||
logger.Info("Fixed point conversion");
|
||||
test_conversion<JFConversionFixedPoint>(logger);
|
||||
|
||||
logger.Info("Packet processing");
|
||||
test_packet_processing(logger);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user