Skip to content

Commit b2cbe4a

Browse files
authored
Merge pull request #230 from sy-c/master
v1.14.2
2 parents ee78b66 + df97d91 commit b2cbe4a

20 files changed

+120
-13
lines changed

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,11 @@ add_executable(
404404
${SOURCE_DIR}/testROC.cxx
405405
$<TARGET_OBJECTS:objReadoutUtils>
406406
)
407+
add_executable(
408+
o2-readout-test-roc-find
409+
${SOURCE_DIR}/testROCfind.cxx
410+
$<TARGET_OBJECTS:objReadoutUtils>
411+
)
407412
endif()
408413

409414
# a test program to test ZMQ client
@@ -477,7 +482,7 @@ endif ()
477482
# set include and libraries for all
478483
set(executables o2-readout-exe o2-readout-receiver o2-readout-test-fmq-tx o2-readout-test-fmq-rx o2-readout-test-fmq-perf-tx o2-readout-test-fmq-perf-rx o2-readout-test-memorybanks o2-readout-rawreader o2-readout-test-lib-monitoring)
479484
if (ReadoutCard_FOUND)
480-
list (APPEND executables o2-readout-test-roc)
485+
list (APPEND executables o2-readout-test-roc o2-readout-test-roc-find)
481486
endif()
482487
if (${ZMQ_FOUND})
483488
list (APPEND executables o2-readout-test-zmq-client o2-readout-test-zmq-server o2-readout-eventdump)

doc/configurationParameters.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ The parameters related to 3rd-party libraries are described here for convenience
4848
| consumer-* | filterEquipmentIdsInclude | string | | Defines a filter based on equipment ids. Only data belonging to the equipments in this list (coma separated values) are accepted. If empty, all equipment ids are fine. |
4949
| consumer-* | filterLinksExclude | string | | Defines a filter based on link ids. All data belonging to the links in this list (coma separated values) are rejected. |
5050
| consumer-* | filterLinksInclude | string | | Defines a filter based on link ids. Only data belonging to the links in this list (coma separated values) are accepted. If empty, all link ids are fine. |
51+
| consumer-* | name | string| | Name used to identify this consumer (in logs). By default, it takes the name of the configuration section, consumer-xxx |
52+
| consumer-* | numaNode | int | -1 | If set (>=0), memory / thread will try to use given NUMA node. |
5153
| consumer-* | stopOnError | int | 0 | If 1, readout will stop automatically on consumer error. |
5254
| consumer-data-sampling-* | address | string | ipc:///tmp/readout-pipe-1 | Address of the data sampling. |
5355
| consumer-FairMQChannel-* | checkResources | string | | Check beforehand if unmanaged region would fit in given list of resources. Comma-separated list of items to be checked: eg /dev/shm, MemFree, MemAvailable. (any filesystem path, and any /proc/meminfo entry).|
5456
| consumer-FairMQChannel-* | disableSending | int | 0 | If set, no data is output to FMQ channel. Used for performance test to create FMQ shared memory segment without pushing the data. |
55-
| consumer-FairMQChannel-* | enablePackedCopy | int | 0 | If set, the same superpage may be reused (space allowing) for the copy of multiple HBF (instead of a separate one for each copy). This allows a reduced memoryPoolNumberOfPages. |
57+
| consumer-FairMQChannel-* | enablePackedCopy | int | 1 | If set, the same superpage may be reused (space allowing) for the copy of multiple HBF (instead of a separate one for each copy). This allows a reduced memoryPoolNumberOfPages. |
5658
| consumer-FairMQChannel-* | enableRawFormat | int | 0 | If 0, data is pushed 1 STF header + 1 part per HBF. If 1, data is pushed in raw format without STF headers, 1 FMQ message per data page. If 2, format is 1 STF header + 1 part per data page.|
5759
| consumer-FairMQChannel-* | fmq-address | string | ipc:///tmp/pipe-readout | Address of the FMQ channel. Depends on transportType. c.f. FairMQ::FairMQChannel.h |
5860
| consumer-FairMQChannel-* | fmq-name | string | readout | Name of the FMQ channel. c.f. FairMQ::FairMQChannel.h |
@@ -63,6 +65,7 @@ The parameters related to 3rd-party libraries are described here for convenience
6365
| consumer-FairMQChannel-* | memoryPoolNumberOfPages | int | 100 | c.f. same parameter in bank-*. |
6466
| consumer-FairMQChannel-* | memoryPoolPageSize | bytes | 128k | c.f. same parameter in bank-*. |
6567
| consumer-FairMQChannel-* | sessionName | string | default | Name of the FMQ session. c.f. FairMQ::FairMQChannel.h |
68+
| consumer-FairMQChannel-* | threads | int | 0 | If set, a pool of thread is created for the data processing. |
6669
| consumer-FairMQChannel-* | unmanagedMemorySize | bytes | | Size of the memory region to be created. c.f. FairMQ::FairMQUnmanagedRegion.h. If not set, no special FMQ memory region is created. |
6770
| consumer-fileRecorder-* | bytesMax | bytes | 0 | Maximum number of bytes to write to each file. Data pages are never truncated, so if writing the full page would exceed this limit, no data from that page is written at all and file is closed. If zero (default), no maximum size set.|
6871
| consumer-fileRecorder-* | dataBlockHeaderEnabled | int | 0 | Enable (1) or disable (0) the writing to file of the internal readout header (Readout DataBlock.h) between the data pages, to easily navigate through the file without RDH decoding. If disabled, the raw data pages received from CRU are written without further formatting. |

doc/releaseNotes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,3 +484,9 @@ This file describes the main feature changes for each readout.exe released versi
484484
## v2.14.1 - 22/08/2022
485485
- Updated configuration parameters:
486486
- added consumer-FairMQChannel-*.threads. If set, a pool of threads is used for FMQ message formatting. Needed at high rates when a single CPU core is not enough to prepare data for DataDistribution (including overlapping HBF copy).
487+
488+
## v2.14.2 - 01/09/2022
489+
- Updated configuration parameters:
490+
- consumer-FairMQChannel-*.enablePackedCopy default changed to 1.
491+
- Fix for running without packed copy (was crashing).
492+
- In auto mode, get ROC numa node from /sys/bus/pci/devices because ROC library reports wrong value.

src/ConsumerDataProcessor.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
#include <thread>
1616

1717
#include "Consumer.h"
18+
#include "ReadoutUtils.h"
19+
20+
#define CONSUMER_THREAD_NAME "processor"
1821

1922
const bool debug = false;
2023

@@ -78,6 +81,7 @@ class processThread
7881
// the loop which runs in a separate thread and calls fProcess() for each block in input fifo, until stop() is called
7982
void loop()
8083
{
84+
setThreadName(CONSUMER_THREAD_NAME "-loop");
8185
// printf("starting thread %d input=%p
8286
// output=%p\n",threadId,inputFifo.get(),outputFifo.get());
8387
// printf("processing thread %d starting\n",threadId);
@@ -305,7 +309,7 @@ class ConsumerDataProcessor : public Consumer
305309
// collector thread loop: handle the output of processing threads
306310
void loopOutput(void)
307311
{
308-
312+
setThreadName(CONSUMER_THREAD_NAME "-out");
309313
bool isActive = 0;
310314

311315
// lambda function that pushes forward next available bage

src/ConsumerDataSampling.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <fairmq/FairMQParts.h>
1919
#include <fairmq/FairMQTransportFactory.h>
2020
#include <thread>
21+
#include "ReadoutUtils.h"
2122

2223
class ConsumerDataSampling : public Consumer
2324
{
@@ -143,7 +144,10 @@ class ConsumerDataSampling : public Consumer
143144
}
144145

145146
private:
146-
void runDevice() { sender.RunStateMachine(); }
147+
void runDevice() {
148+
setThreadName("fmq-run-ds");
149+
sender.RunStateMachine();
150+
}
147151
};
148152

149153
std::unique_ptr<Consumer> getUniqueConsumerDataSampling(ConfigFile& cfg, std::string cfgEntryPoint) { return std::make_unique<ConsumerDataSampling>(cfg, cfgEntryPoint); }

src/ConsumerFMQ.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <fairmq/FairMQMessage.h>
1818
#include <fairmq/FairMQTransportFactory.h>
1919
#include <thread>
20+
#include "ReadoutUtils.h"
2021

2122
class FMQSender : public FairMQDevice
2223
{
@@ -142,7 +143,10 @@ class ConsumerFMQ : public Consumer
142143
}
143144

144145
private:
145-
void runDevice() { sender.RunStateMachine(); }
146+
void runDevice() {
147+
setThreadName("fmq-run-ds");
148+
sender.RunStateMachine();
149+
}
146150
};
147151

148152
std::unique_ptr<Consumer> getUniqueConsumerFMQ(ConfigFile& cfg, std::string cfgEntryPoint) { return std::make_unique<ConsumerFMQ>(cfg, cfgEntryPoint); }

src/ConsumerFMQchannel.cxx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class ConsumerFMQchannel : public Consumer
123123
bool enableRawFormat = false;
124124
bool enableStfSuperpage = false; // optimized stf transport: minimize STF packets
125125
bool enableRawFormatDatablock = false;
126-
int enablePackedCopy = 0; // default mode for repacking of page overlapping HBF. 0 = one page per copy, 1 = change page on TF only
126+
int enablePackedCopy = 1; // default mode for repacking of page overlapping HBF. 0 = one page per copy, 1 = change page on TF only
127127

128128
std::shared_ptr<MemoryBank> memBank; // a dedicated memory bank allocated by FMQ mechanism
129129
std::shared_ptr<MemoryPagesPool> mp; // a memory pool from which to allocate data pages
@@ -364,7 +364,7 @@ class ConsumerFMQchannel : public Consumer
364364
}
365365
theLog.log(LogInfoDevel_(3008), "Using memory pool [%d]: %d pages x %d bytes", mp->getId(), memoryPoolNumberOfPages, memoryPoolPageSize);
366366

367-
// configuration parameter: | consumer-FairMQChannel-* | enablePackedCopy | int | 0 | If set, the same superpage may be reused (space allowing) for the copy of multiple HBF (instead of a separate one for each copy). This allows a reduced memoryPoolNumberOfPages. |
367+
// configuration parameter: | consumer-FairMQChannel-* | enablePackedCopy | int | 1 | If set, the same superpage may be reused (space allowing) for the copy of multiple HBF (instead of a separate one for each copy). This allows a reduced memoryPoolNumberOfPages. |
368368
cfg.getOptionalValue<int>(cfgEntryPoint + ".enablePackedCopy", enablePackedCopy);
369369
theLog.log(LogInfoDevel_(3008), "Packed copy enabled = %d", enablePackedCopy);
370370

@@ -885,13 +885,17 @@ int ConsumerFMQchannel::DDformatMessage(DataSetReference &bc, DDMessage &ddm) {
885885
}
886886
DataBlockContainerReference copyBlock = nullptr;
887887
int isNewBlock = 0;
888+
int copyBlockMemSize = 0;
888889
try {
889890
if (enablePackedCopy) {
890891
for (int i = 0; i<=2; i++) {
891892
// allocate new buffer for copies if needed
892893
if (copyBlockBuffer == nullptr) {
893894
copyBlockBuffer = mp->getNewDataBlockContainer();
894895
isNewBlock = 1;
896+
if (copyBlockBuffer != nullptr) {
897+
copyBlockMemSize = copyBlockBuffer->getDataBufferSize();
898+
}
895899
nPagesUsedForRepack++;
896900
continue;
897901
}
@@ -906,6 +910,9 @@ int ConsumerFMQchannel::DDformatMessage(DataSetReference &bc, DDMessage &ddm) {
906910
} else {
907911
copyBlock = mp->getNewDataBlockContainer();
908912
isNewBlock = 1;
913+
if (copyBlock != nullptr) {
914+
copyBlockMemSize = copyBlock->getDataBufferSize();
915+
}
909916
nPagesUsedForRepack++;
910917
}
911918
} catch (...) {
@@ -916,10 +923,8 @@ int ConsumerFMQchannel::DDformatMessage(DataSetReference &bc, DDMessage &ddm) {
916923
theLog.log(token, "no page left");
917924
throw __LINE__;
918925
}
919-
int copyBlockMemSize = 0;
920926
if (isNewBlock) {
921-
ddm.subTimeframeMemorySize += copyBlockBuffer->getDataBufferSize();
922-
copyBlockMemSize = copyBlockBuffer->getDataBufferSize();
927+
ddm.subTimeframeMemorySize += copyBlockMemSize;
923928
//printf("%d size 1 TF %d block %p mem size %d %d\n", __LINE__, (int)copyBlock->getData()->header.timeframeId, copyBlock->getData(), (int)copyBlockBuffer->getDataBufferSize(), copyBlock->getData()->header.memorySize);
924929
}
925930
auto blockRef = new DataBlockContainerReference(copyBlock);

src/ConsumerStats.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ class ConsumerStats : public Consumer
221221
bool periodicUpdateThreadShutdown; // flag to stop periodicUpdateThread
222222
void periodicUpdate()
223223
{
224+
setThreadName("consumer-stats");
224225
periodicUpdateThreadShutdown = 0;
225226

226227
// periodic update

src/DataBlockAggregator.cxx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ Thread::CallbackResult DataBlockAggregator::threadCallback(void* arg)
4141
return Thread::CallbackResult::Error;
4242
}
4343

44+
if (!dPtr->isThreadNamed) {
45+
#ifdef _GNU_SOURCE
46+
pthread_setname_np(pthread_self(), "aggregator");
47+
#endif
48+
dPtr->isThreadNamed = 1;
49+
}
50+
4451
if (dPtr->output->isFull()) {
4552
return Thread::CallbackResult::Idle;
4653
}

src/DataBlockAggregator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ class DataBlockAggregator
115115
void reset(); // reset all internal buffers, counters and states
116116

117117
private:
118+
bool isThreadNamed = 0; // flag to set once thread name
118119
std::vector<std::shared_ptr<AliceO2::Common::Fifo<DataBlockContainerReference>>> inputs;
119120
AliceO2::Common::Fifo<DataSetReference>* output; // todo: unique_ptr
120121

0 commit comments

Comments
 (0)