mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
Add FlatBuffers & MessagePack examples
- Add FlatBuffers serialization example to Tutorial 3 - Add MessagePack serialization example to Tutorial 3 - Performance improvements in Boost serialization example - Use `GetEntriesFast()` for FairTestDetectorRecoTask - Use `Clear()` instead of `Delete()` in MQ parts of Tutorial 3 - Fix CMake variables from preventing compilation without nanomsg. - create macro/data directories in install directory - Get rid of data duplication in fill_parameters.C - Various cleanups and fixes
This commit is contained in:
parent
f1abb9ecdd
commit
82ab7670a9
|
@ -479,9 +479,9 @@ void FairMQDevice::SetTransport(const string& transport)
|
|||
#endif
|
||||
else
|
||||
{
|
||||
LOG(ERROR) << "Unknown transport implementation requested: "
|
||||
<< transport
|
||||
<< ". Supported are "
|
||||
LOG(ERROR) << "Unavailable transport implementation requested: "
|
||||
<< "\"" << transport << "\""
|
||||
<< ". Available are: "
|
||||
<< "\"zeromq\""
|
||||
#ifdef NANOMSG_FOUND
|
||||
<< ", \"nanomsg\""
|
||||
|
|
|
@ -29,17 +29,17 @@ FairMQMerger::~FairMQMerger()
|
|||
|
||||
void FairMQMerger::Run()
|
||||
{
|
||||
std::unique_ptr<FairMQPoller> poller(fTransportFactory->CreatePoller(fChannels.at("data-in")));
|
||||
|
||||
// store the channel references to avoid traversing the map on every loop iteration
|
||||
auto& dataInChannelRef = fChannels.at("data-in");
|
||||
const FairMQChannel& dataOutChannel = fChannels.at("data-out").at(0);
|
||||
std::vector<FairMQChannel*> dataInChannels(fChannels.at("data-in").size());
|
||||
for (unsigned int i = 0; i < fChannels.at("data-in").size(); ++i)
|
||||
int numInputs = dataInChannelRef.size();
|
||||
std::vector<FairMQChannel*> dataInChannels(numInputs);
|
||||
for (int i = 0; i < numInputs; ++i)
|
||||
{
|
||||
dataInChannels.at(i) = &(fChannels.at("data-in").at(i));
|
||||
dataInChannels.at(i) = &(dataInChannelRef.at(i));
|
||||
}
|
||||
|
||||
int numInputs = fChannels.at("data-in").size();
|
||||
std::unique_ptr<FairMQPoller> poller(fTransportFactory->CreatePoller(dataInChannelRef));
|
||||
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
|
|
|
@ -28,17 +28,18 @@ FairMQSplitter::~FairMQSplitter()
|
|||
|
||||
void FairMQSplitter::Run()
|
||||
{
|
||||
int direction = 0;
|
||||
int numOutputs = fChannels.at("data-out").size();
|
||||
|
||||
// store the channel references to avoid traversing the map on every loop iteration
|
||||
auto& dataOutChannelRef = fChannels.at("data-out");
|
||||
const FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
|
||||
FairMQChannel* dataOutChannels[fChannels.at("data-out").size()];
|
||||
int numOutputs = dataOutChannelRef.size();
|
||||
std::vector<FairMQChannel*> dataOutChannels(numOutputs);
|
||||
for (int i = 0; i < numOutputs; ++i)
|
||||
{
|
||||
dataOutChannels[i] = &(fChannels.at("data-out").at(i));
|
||||
dataOutChannels[i] = &(dataOutChannelRef.at(i));
|
||||
}
|
||||
|
||||
int direction = 0;
|
||||
|
||||
while (CheckCurrentState(RUNNING))
|
||||
{
|
||||
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
||||
|
|
|
@ -36,7 +36,6 @@ namespace fairmq
|
|||
NOLOG
|
||||
};
|
||||
|
||||
|
||||
static const std::array<std::string, 8> g_LogSeverityLevelString
|
||||
{
|
||||
{
|
||||
|
@ -51,8 +50,6 @@ namespace fairmq
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
namespace color
|
||||
{
|
||||
enum code
|
||||
|
@ -94,19 +91,18 @@ typedef fairmq::severity_level custom_severity_level;
|
|||
struct tag_console;
|
||||
struct tag_file;
|
||||
|
||||
|
||||
// overload operator for console output
|
||||
inline boost::log::formatting_ostream& operator<<
|
||||
(
|
||||
boost::log::formatting_ostream& strm,
|
||||
boost::log::to_log_manip< custom_severity_level, tag_console > const& manip
|
||||
boost::log::to_log_manip<custom_severity_level, tag_console> const& manip
|
||||
)
|
||||
{
|
||||
custom_severity_level level = manip.get();
|
||||
std::size_t idx=static_cast< std::size_t >(level);
|
||||
if ( idx < fairmq::g_LogSeverityLevelString.size() )
|
||||
std::size_t idx = static_cast<std::size_t>(level);
|
||||
if (idx < fairmq::g_LogSeverityLevelString.size())
|
||||
{
|
||||
//strm <<" idx = "<<idx <<" ";
|
||||
// strm << " idx = " << idx << " ";
|
||||
switch (level)
|
||||
{
|
||||
case custom_severity_level::TRACE :
|
||||
|
@ -144,13 +140,11 @@ inline boost::log::formatting_ostream& operator<<
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
strm << write_in<fairmq::color::FG_RED>("Unknown log level ")
|
||||
<< "(int level = "<<static_cast< int >(level)
|
||||
<<")";
|
||||
<< "(int level = " << static_cast<int>(level) << ")";
|
||||
}
|
||||
return strm;
|
||||
}
|
||||
|
@ -159,27 +153,21 @@ inline boost::log::formatting_ostream& operator<<
|
|||
inline boost::log::formatting_ostream& operator<<
|
||||
(
|
||||
boost::log::formatting_ostream& strm,
|
||||
boost::log::to_log_manip< custom_severity_level, tag_file > const& manip
|
||||
boost::log::to_log_manip<custom_severity_level, tag_file> const& manip
|
||||
)
|
||||
{
|
||||
custom_severity_level level = manip.get();
|
||||
std::size_t idx=static_cast< std::size_t >(level);
|
||||
if ( idx < fairmq::g_LogSeverityLevelString.size() )
|
||||
std::size_t idx = static_cast<std::size_t>(level);
|
||||
if (idx < fairmq::g_LogSeverityLevelString.size())
|
||||
{
|
||||
strm << fairmq::g_LogSeverityLevelString.at(idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
strm << write_in<fairmq::color::FG_RED>("Unknown log level ")
|
||||
<< "(int level = "<<static_cast< int >(level)
|
||||
<<")";
|
||||
<< "(int level = " << static_cast<int>(level) << ")";
|
||||
}
|
||||
return strm;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif /* LOGGER_DEF_H */
|
||||
|
||||
|
|
|
@ -32,7 +32,6 @@ FairProgOptions::FairProgOptions() :
|
|||
fVarMap(),
|
||||
fSeverityMap()
|
||||
{
|
||||
// define generic options
|
||||
fGenericDesc.add_options()
|
||||
("help,h", "produce help")
|
||||
("version,v", "print version")
|
||||
|
|
|
@ -1,14 +1,36 @@
|
|||
#!/bin/bash
|
||||
|
||||
numMsgs="0"
|
||||
msgSize="1000000"
|
||||
|
||||
if [[ $1 =~ ^[0-9]+$ ]]; then
|
||||
msgSize=$1
|
||||
fi
|
||||
|
||||
echo "Starting benchmark with message size of $msgSize bytes."
|
||||
|
||||
if [[ $2 =~ ^[0-9]+$ ]]; then
|
||||
numMsgs=$2
|
||||
fi
|
||||
|
||||
if [ $numMsgs = 0 ]; then
|
||||
echo "Unlimited number of messages."
|
||||
else
|
||||
echo "Number of messages: $numMsgs."
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Usage: startBenchmark [message size=1000000] [number of messages=0]"
|
||||
|
||||
SAMPLER="bsampler"
|
||||
SAMPLER+=" --id bsampler1"
|
||||
SAMPLER+=" --msg-size 1000000"
|
||||
#SAMPLER+=" --num-msgs 1000"
|
||||
SAMPLER+=" --msg-size $msgSize"
|
||||
SAMPLER+=" --num-msgs $numMsgs"
|
||||
SAMPLER+=" --config-json-file @CMAKE_BINARY_DIR@/bin/config/benchmark.json"
|
||||
xterm -geometry 80x23+0+0 -hold -e @CMAKE_BINARY_DIR@/bin/$SAMPLER &
|
||||
xterm -geometry 80x23+0+0 -hold -e taskset 0x1 @CMAKE_BINARY_DIR@/bin/$SAMPLER &
|
||||
|
||||
SINK="sink"
|
||||
SINK+=" --id sink1"
|
||||
#SINK+=" --num-msgs 1000"
|
||||
SINK+=" --num-msgs $numMsgs"
|
||||
SINK+=" --config-json-file @CMAKE_BINARY_DIR@/bin/config/benchmark.json"
|
||||
xterm -geometry 80x23+500+0 -hold -e @CMAKE_BINARY_DIR@/bin/$SINK &
|
||||
xterm -geometry 80x23+500+0 -hold -e taskset 0x2 @CMAKE_BINARY_DIR@/bin/$SINK &
|
||||
|
|
|
@ -27,9 +27,15 @@ Set(INCLUDE_DIRECTORIES
|
|||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${Boost_INCLUDE_DIR}
|
||||
${ZMQ_INCLUDE_DIR}
|
||||
${NANOMSG_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
If(NANOMSG_FOUND)
|
||||
Set(SYSTEM_INCLUDE_DIRECTORIES
|
||||
${SYSTEM_INCLUDE_DIRECTORIES}
|
||||
${NANOMSG_INCLUDE_DIR}
|
||||
)
|
||||
EndIf(NANOMSG_FOUND)
|
||||
|
||||
Include_Directories(${INCLUDE_DIRECTORIES})
|
||||
Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user