FairMQ Examples cleanup

- Rename Tutorial3 MQ files for uniform naming.
  - Add search for dylib in FindDDS.cmake (OSX).
  - Add more detail to the DDS example readme.
  - MQ Example 3 (DDS): choose network interface via command line option.
  - Give FairMQ examples their own CMakeLists.txt for clarity.
  - Remove C++11 checks in Tutorial3 from the code (they are now in CMake).
  - Add Serializer for device properties (FairMQDevice::ListProperties()).
This commit is contained in:
Alexey Rybalchenko
2015-09-29 11:07:27 +02:00
committed by Mohammad Al-Turany
parent a75486f3ec
commit 19afacb504
26 changed files with 746 additions and 220 deletions

View File

@@ -0,0 +1,93 @@
################################################################################
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
# #
# This software is distributed under the terms of the #
# GNU Lesser General Public Licence version 3 (LGPL) version 3, #
# copied verbatim in the file "LICENSE" #
################################################################################
configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/3-dds/ex3-devices.json ${CMAKE_BINARY_DIR}/bin/config/ex3-devices.json)
configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/3-dds/ex3-dds-topology.xml ${CMAKE_BINARY_DIR}/bin/config/ex3-dds-topology.xml)
configure_file(${CMAKE_SOURCE_DIR}/fairmq/examples/3-dds/ex3-dds-hosts.cfg ${CMAKE_BINARY_DIR}/bin/config/ex3-dds-hosts.cfg COPYONLY)
add_definitions(-DENABLE_DDS)
Set(INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/fairmq
${CMAKE_SOURCE_DIR}/fairmq/devices
${CMAKE_SOURCE_DIR}/fairmq/tools
${CMAKE_SOURCE_DIR}/fairmq/options
${CMAKE_SOURCE_DIR}/fairmq/examples/3-dds
${CMAKE_CURRENT_BINARY_DIR}
)
Set(SYSTEM_INCLUDE_DIRECTORIES
${SYSTEM_INCLUDE_DIRECTORIES}
${DDS_INCLUDE_DIR}
)
If(NANOMSG_FOUND)
Set(INCLUDE_DIRECTORIES
${INCLUDE_DIRECTORIES}
${CMAKE_SOURCE_DIR}/fairmq/nanomsg
)
Else(NANOMSG_FOUND)
Set(INCLUDE_DIRECTORIES
${INCLUDE_DIRECTORIES}
${CMAKE_SOURCE_DIR}/fairmq/zeromq
)
EndIf(NANOMSG_FOUND)
Include_Directories(${INCLUDE_DIRECTORIES})
Include_Directories(SYSTEM ${SYSTEM_INCLUDE_DIRECTORIES})
Set(LINK_DIRECTORIES
${LINK_DIRECTORIES}
${Boost_LIBRARY_DIRS}
${DDS_LIBRARY_DIR}
)
Link_Directories(${LINK_DIRECTORIES})
Set(SRCS
${SRCS}
"FairMQExample3Sampler.cxx"
"FairMQExample3Processor.cxx"
"FairMQExample3Sink.cxx"
)
Set(DEPENDENCIES
${DEPENDENCIES}
FairMQ
dds-key-value-lib
)
set(LIBRARY_NAME FairMQExample3)
GENERATE_LIBRARY()
Set(Exe_Names
${Exe_Names}
ex3-sampler-dds
ex3-processor-dds
ex3-sink-dds
)
Set(Exe_Source
${Exe_Source}
runExample3Sampler.cxx
runExample3Processor.cxx
runExample3Sink.cxx
)
list(LENGTH Exe_Names _length)
math(EXPR _length ${_length}-1)
ForEach(_file RANGE 0 ${_length})
list(GET Exe_Names ${_file} _name)
list(GET Exe_Source ${_file} _src)
set(EXE_NAME ${_name})
set(SRCS ${_src})
set(DEPENDENCIES FairMQExample3)
GENERATE_EXECUTABLE()
EndForEach(_file RANGE 0 ${_length})

View File

@@ -3,6 +3,12 @@ Example 3: DDS
This example demonstrates usage of the Dynamic Deployment System ([DDS](http://dds.gsi.de/)) to dynamically deploy and configure a topology of devices. The topology is similar to those of Example 2, but now it can be easily distributed on different computing nodes without the need for manual reconfiguration of the devices.
This example is compiled only if the DDS is found by CMake. Custom DDS installation location can be given to CMake like this:
```bash
cmake -DDDS_PATH="/path/to/dds/install/dir/" ..
```
The description below outlines the minimal steps needed to run the example with DDS. For more details please refer to DDS documentation on [DDS Website](http://dds.gsi.de/).
##### 1. The devices that bind their sockets need to advertise their bound addresses to DDS by writing a property.
@@ -56,9 +62,9 @@ After this step each device will have the necessary connection information.
We run this example on the local machine for simplicity. The file below defines one worker `wn0` with 12 DDS Agents (thus able to accept 12 tasks). The parameters for each worker node are:
- user-chosen worker ID (must be unique)
- a host name with or without a login, in a form: login@host.fqdn
- a host name with or without a login, in a form: login@host.fqdn (password-less SSH access to these hosts must be possible)
- additional SSH params (can be empty)
- a remote working directory
- a remote working directory (most exist on the worker nodes)
- number of DDS Agents for this worker
```bash

View File

@@ -46,11 +46,11 @@ int main(int argc, char** argv)
{
int ddsTaskIndex = 0;
options_description samplerOptions("Processor options");
samplerOptions.add_options()
("index", value<int>(&ddsTaskIndex)->default_value(0), "Store DDS task index");
options_description processorOptions("Processor options");
processorOptions.add_options()
("index", value<int>(&ddsTaskIndex)->default_value(0), "DDS task index");
config.AddToCmdLineOptions(samplerOptions);
config.AddToCmdLineOptions(processorOptions);
if (config.ParseAll(argc, argv))
{

View File

@@ -45,11 +45,13 @@ int main(int argc, char** argv)
try
{
std::string text;
std::string text; // text to be sent for processing.
std::string interfaceName; // name of the network interface to use for communication.
options_description samplerOptions("Sampler options");
samplerOptions.add_options()
("text", value<std::string>(&text)->default_value("Hello"), "Text to send out");
("text", value<std::string>(&text)->default_value("Hello"), "Text to send out")
("network-interface", value<std::string>(&interfaceName)->default_value("eth0"), "Name of the network interface to use (e.g. eth0, ib0, wlan0, en0...)");
config.AddToCmdLineOptions(samplerOptions);
@@ -83,22 +85,14 @@ int main(int argc, char** argv)
FairMQ::tools::getHostIPs(IPs);
stringstream ss;
// Check if ib0 (infiniband) interface is available, otherwise try eth0 or wlan0.
if (IPs.count("ib0"))
if (IPs.count(interfaceName))
{
ss << "tcp://" << IPs["ib0"] << ":1";
}
else if (IPs.count("eth0"))
{
ss << "tcp://" << IPs["eth0"] << ":1";
}
else if (IPs.count("wlan0"))
{
ss << "tcp://" << IPs["wlan0"] << ":1";
ss << "tcp://" << IPs[interfaceName] << ":1";
}
else
{
LOG(INFO) << ss.str();
LOG(ERROR) << "Could not find ib0, eth0 or wlan0";
LOG(ERROR) << "Could not find provided network interface: \"" << interfaceName << "\"!, exiting.";
exit(EXIT_FAILURE);
}
string initialOutputAddress = ss.str();

View File

@@ -45,6 +45,14 @@ int main(int argc, char** argv)
try
{
std::string interfaceName; // name of the network interface to use for communication.
options_description sinkOptions("Sink options");
sinkOptions.add_options()
("network-interface", value<std::string>(&interfaceName)->default_value("eth0"), "Name of the network interface to use (e.g. eth0, ib0, wlan0, en0...)");
config.AddToCmdLineOptions(sinkOptions);
if (config.ParseAll(argc, argv))
{
return 0;
@@ -74,22 +82,14 @@ int main(int argc, char** argv)
FairMQ::tools::getHostIPs(IPs);
stringstream ss;
// Check if ib0 (infiniband) interface is available, otherwise try eth0 or wlan0.
if (IPs.count("ib0"))
if (IPs.count(interfaceName))
{
ss << "tcp://" << IPs["ib0"] << ":1";
}
else if (IPs.count("eth0"))
{
ss << "tcp://" << IPs["eth0"] << ":1";
}
else if (IPs.count("wlan0"))
{
ss << "tcp://" << IPs["wlan0"] << ":1";
ss << "tcp://" << IPs[interfaceName] << ":1";
}
else
{
LOG(INFO) << ss.str();
LOG(ERROR) << "Could not find ib0, eth0 or wlan0";
LOG(ERROR) << "Could not find provided network interface: \"" << interfaceName << "\"!, exiting.";
exit(EXIT_FAILURE);
}
string initialInputAddress = ss.str();