mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2026-11-25 13:11:36 +00:00
docs: replace the Markdown docs with links to the site
- Remove docs/*.md and docs/images/ - Rewrite README.md: description, install, first steps and links to the site - Replace the READMEs of the examples, fairmq/shmem, fairmq/devices and fairmq/tools with links to the site pages Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
178
README.md
178
README.md
@@ -6,168 +6,58 @@
|
||||
[](https://github.com/FairRootGroup/FairMQ/actions/workflows/fair-software.yml)
|
||||
[](https://repology.org/project/fairmq/versions)
|
||||
|
||||
C++ Message Queuing Library and Framework
|
||||
C++ message queuing library and framework for large-scale data processing.
|
||||
|
||||
Docs: [Book](https://github.com/FairRootGroup/FairMQ/blob/dev/README.md#documentation)
|
||||
**Documentation: <https://fairrootgroup.github.io/FairMQ/>**
|
||||
|
||||
Find all FairMQ releases [here](https://github.com/FairRootGroup/FairMQ/releases).
|
||||
FairMQ helps to build data processing workflows of particle physics experiments
|
||||
from many small processes. Each process is a *device* with a state machine. Devices
|
||||
send messages to each other through *channels* with the socket patterns of ZeroMQ
|
||||
(push/pull, pub/sub, req/rep, pair). Each channel uses a *transport*:
|
||||
|
||||
## Introduction
|
||||
* `zeromq` sends the messages through ZeroMQ sockets, also to other hosts.
|
||||
* `shmem` puts the payload into shared memory and sends only a small header, so
|
||||
devices on one host exchange data without a copy.
|
||||
|
||||
FairMQ is designed to help implementing large-scale data processing workflows needed in next-generation Particle Physics experiments. FairMQ is written in C++ and aims to
|
||||
* provide **an asynchronous message passing abstraction** of different data transport technologies,
|
||||
* provide a reasonably **efficient data transport** service (zero-copy, high throughput),
|
||||
* be **data format agnostic**, and
|
||||
* provide **basic building blocks** that can be used to implement higher level data processing workflows.
|
||||
Plugins configure and control the devices. FairMQ was developed in the context of
|
||||
[FairRoot](https://github.com/FairRootGroup/FairRoot).
|
||||
|
||||
The core of FairMQ provides an abstract asynchronous message passing API with scalability protocols
|
||||
inspired by [ZeroMQ](https://github.com/zeromq/libzmq) (e.g. PUSH/PULL, PUB/SUB).
|
||||
FairMQ provides multiple implementations for its API (so-called "transports",
|
||||
e.g. `zeromq` and `shmem` (latest release of the `ofi` transport in v1.4.56, removed since v1.5+)) to cover
|
||||
a variety of use cases
|
||||
(e.g. inter-thread, inter-process, inter-node communication) and machines (e.g. Ethernet, Infiniband).
|
||||
In addition to this core functionality FairMQ provides a framework for creating "devices" - actors which
|
||||
are communicating through message passing. FairMQ does not only allow the user to use different transport
|
||||
but also to mix them; i.e: A Device can communicate using different transport on different channels at the
|
||||
same time. Device execution is modelled as a simple state machine that shapes the integration points for
|
||||
the user task. Devices also incorporate a plugin system for runtime configuration and control.
|
||||
Next to the provided [devices](https://github.com/FairRootGroup/FairMQ/tree/master/fairmq/devices) and
|
||||
[plugins](https://github.com/FairRootGroup/FairMQ/tree/master/fairmq/plugins) the user can extend FairMQ
|
||||
by developing his own plugins to integrate his devices with external configuration and control services.
|
||||
## Install
|
||||
|
||||
FairMQ has been developed in the context of its mother project [FairRoot](https://github.com/FairRootGroup/FairRoot) -
|
||||
a simulation, reconstruction and analysis framework.
|
||||
With [Spack](https://spack.readthedocs.io/en/latest/getting_started.html):
|
||||
|
||||
## Installation from Source
|
||||
```bash
|
||||
spack install fairmq
|
||||
```
|
||||
|
||||
Recommended:
|
||||
From source:
|
||||
|
||||
```bash
|
||||
git clone https://github.com/FairRootGroup/FairMQ fairmq_source
|
||||
cmake -S fairmq_source -B fairmq_build -GNinja -DCMAKE_BUILD_TYPE=Release [-DBUILD_TESTING=ON]
|
||||
cmake -S fairmq_source -B fairmq_build -GNinja -DCMAKE_BUILD_TYPE=Release
|
||||
cmake --build fairmq_build
|
||||
[ctest --test-dir fairmq_build --output-on-failure --schedule-random -j<ncpus>] # needs -DBUILD_TESTING=ON
|
||||
cmake --install fairmq_build --prefix $(pwd)/fairmq_install
|
||||
```
|
||||
|
||||
Please consult the [manpages of your CMake version](https://cmake.org/cmake/help/latest/manual/cmake.1.html) for more options.
|
||||
The [install page](https://fairrootgroup.github.io/FairMQ/start/install/) lists the
|
||||
dependencies, the build options and how to run the tests.
|
||||
|
||||
If dependencies are not installed in standard system directories, you can hint the installation location via
|
||||
`-DCMAKE_PREFIX_PATH=...` or per dependency via `-D{DEPENDENCY}_ROOT=...` (`*_ROOT` variables can also be environment variables).
|
||||
## Get started
|
||||
|
||||
## Installation via Spack
|
||||
* [Your first device](https://fairrootgroup.github.io/FairMQ/start/first-device/): write, build and run a sampler and a sink.
|
||||
* [Use FairMQ in a CMake project](https://fairrootgroup.github.io/FairMQ/start/cmake/): `find_package(FairMQ)` and the target `FairMQ::FairMQ`.
|
||||
* [Examples](https://fairrootgroup.github.io/FairMQ/examples/1-1/): the programs in [`examples/`](examples), with their topologies.
|
||||
* [API reference](https://fairrootgroup.github.io/FairMQ/api/) and [source browser](https://fairrootgroup.github.io/FairMQ/source/).
|
||||
|
||||
Prerequisite: [Spack](https://spack.readthedocs.io/en/latest/getting_started.html)
|
||||
## Releases and support
|
||||
|
||||
```bash
|
||||
spack info fairmq # inspect build options
|
||||
spack install fairmq # build latest packaged version with default options
|
||||
```
|
||||
Find all releases [on GitHub](https://github.com/FairRootGroup/FairMQ/releases) and the
|
||||
changes in the [release notes](https://fairrootgroup.github.io/FairMQ/project/release-notes/).
|
||||
Report bugs and ask questions in the [issues](https://github.com/FairRootGroup/FairMQ/issues).
|
||||
Read [Contributing](https://fairrootgroup.github.io/FairMQ/project/contributing/) before you
|
||||
open a pull request.
|
||||
|
||||
Build FairMQ's dependencies via Spack for development:
|
||||
```bash
|
||||
git clone -b dev https://github.com/FairRootGroup/FairMQ fairmq_source
|
||||
spack --env fairmq_source install # installs deps declared in fairmq_source/spack.yaml
|
||||
spack env activate fairmq_source # sets $CMAKE_PREFIX_PATH which is used by CMake to find FairMQ's deps
|
||||
cmake -S fairmq_source -B fairmq_build -GNinja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON
|
||||
# develop, compile, test
|
||||
spack env deactivate # at end of dev session, or simply close the shell
|
||||
```
|
||||
## License
|
||||
|
||||
## Usage
|
||||
|
||||
FairMQ ships as a CMake package, so in your `CMakeLists.txt` you can discover it like this:
|
||||
|
||||
```cmake
|
||||
find_package(FairCMakeModules 1.0 REQUIRED)
|
||||
include(FairFindPackage2)
|
||||
find_package2(FairMQ)
|
||||
find_package2_implicit_dependencies()
|
||||
```
|
||||
|
||||
The [`FairFindPackage2` module](https://fairrootgroup.github.io/FairCMakeModules/latest/module/FairFindPackage2.html) is part of the [`FairCMakeModules` package](https://fairrootgroup.github.io/FairCMakeModules).
|
||||
|
||||
If FairMQ is not installed in system directories, you can hint the installation:
|
||||
|
||||
```cmake
|
||||
list(PREPEND CMAKE_PREFIX_PATH /path/to/fairmq_install)
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
* [Boost](https://www.boost.org/)
|
||||
* [CMake](https://cmake.org/)
|
||||
* [FairCMakeModules](https://github.com/FairRootGroup/FairCMakeModules) (optionally bundled)
|
||||
* [FairLogger](https://github.com/FairRootGroup/FairLogger)
|
||||
* [GTest](https://github.com/google/googletest) (optionally bundled)
|
||||
* [ZeroMQ](http://zeromq.org/)
|
||||
|
||||
Which dependencies are required depends on which components are built.
|
||||
|
||||
Supported platform is Linux. macOS is supported on a best-effort basis.
|
||||
|
||||
## CMake options
|
||||
|
||||
On command line:
|
||||
|
||||
* `-DDISABLE_COLOR=ON` disables coloured console output.
|
||||
* `-DBUILD_TESTING=OFF` disables building of tests.
|
||||
* `-DBUILD_EXAMPLES=OFF` disables building of examples.
|
||||
* `-DFAIRMQ_CHANNEL_DEFAULT_AUTOBIND=OFF` disable channel `autoBind` by default
|
||||
* You can hint non-system installations for dependent packages, see the #installation-from-source section above
|
||||
|
||||
After the `find_package(FairMQ)` call the following CMake variables are defined:
|
||||
|
||||
| Variable | Info |
|
||||
| --- | --- |
|
||||
| `${FairMQ_PACKAGE_DEPENDENCIES}` | the list of public package dependencies |
|
||||
| `${FairMQ_<dep>_VERSION}` | the minimum `<dep>` version FairMQ requires |
|
||||
| `${FairMQ_<dep>_COMPONENTS}` | the list of `<dep>` components FairMQ depends on |
|
||||
| `${FairMQ_PACKAGE_COMPONENTS}` | the list of components FairMQ consists of |
|
||||
| `${FairMQ_#COMPONENT#_FOUND}` | `TRUE` if this component was built |
|
||||
| `${FairMQ_VERSION}` | the version in format `MAJOR.MINOR.PATCH` |
|
||||
| `${FairMQ_GIT_VERSION}` | the version in the format returned by `git describe --tags --dirty --match "v*"` |
|
||||
| `${FairMQ_PREFIX}` | the actual installation prefix |
|
||||
| `${FairMQ_BINDIR}` | the installation bin directory |
|
||||
| `${FairMQ_INCDIR}` | the installation include directory |
|
||||
| `${FairMQ_LIBDIR}` | the installation lib directory |
|
||||
| `${FairMQ_DATADIR}` | the installation data directory (`../share/fairmq`) |
|
||||
| `${FairMQ_CMAKEMODDIR}` | the installation directory of shipped CMake find modules |
|
||||
| `${FairMQ_BUILD_TYPE}` | the value of `CMAKE_BUILD_TYPE` at build-time |
|
||||
| `${FairMQ_CXX_FLAGS}` | the values of `CMAKE_CXX_FLAGS` and `CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}` at build-time |
|
||||
|
||||
## Documentation
|
||||
|
||||
1. [Device](docs/Device.md#1-device)
|
||||
1. [Topology](docs/Device.md#11-topology)
|
||||
2. [Communication Patterns](docs/Device.md#12-communication-patterns)
|
||||
3. [State Machine](docs/Device.md#13-state-machine)
|
||||
4. [Multiple devices in the same process](docs/Device.md#15-multiple-devices-in-the-same-process)
|
||||
2. [Transport Interface](docs/Transport.md#2-transport-interface)
|
||||
1. [Message](docs/Transport.md#21-message)
|
||||
1. [Ownership](docs/Transport.md#211-ownership)
|
||||
2. [Channel](docs/Transport.md#22-channel)
|
||||
3. [Poller](docs/Transport.md#23-poller)
|
||||
3. [Configuration](docs/Configuration.md#3-configuration)
|
||||
1. [Device Configuration](docs/Configuration.md#31-device-configuration)
|
||||
2. [Communication Channels Configuration](docs/Configuration.md#32-communication-channels-configuration)
|
||||
1. [JSON Parser](docs/Configuration.md#321-json-parser)
|
||||
2. [SuboptParser](docs/Configuration.md#322-suboptparser)
|
||||
3. [Introspection](docs/Configuration.md#33-introspection)
|
||||
4. [Development](docs/Development.md#4-development)
|
||||
1. [Testing](docs/Development.md#41-testing)
|
||||
2. [Static Analysis](docs/Development.md#42-static-analysis)
|
||||
1. [CMake Integration](docs/Development.md#421-cmake-integration)
|
||||
2. [Extra Compiler Arguments](docs/Development.md#422-extra-compiler-arguments)
|
||||
5. [Logging](docs/Logging.md#5-logging)
|
||||
1. [Log severity](docs/Logging.md#51-log-severity)
|
||||
2. [Log verbosity](docs/Logging.md#52-log-verbosity)
|
||||
3. [Color for console output](docs/Logging.md#53-color)
|
||||
4. [File output](docs/Logging.md#54-file-output)
|
||||
5. [Custom sinks](docs/Logging.md#55-custom-sinks)
|
||||
6. [Examples](docs/Examples.md#6-examples)
|
||||
7. [Plugins](docs/Plugins.md#7-plugins)
|
||||
1. [Usage](docs/Plugins.md#71-usage)
|
||||
2. [Development](docs/Plugins.md#72-development)
|
||||
3. [Provided Plugins](docs/Plugins.md#73-provided-plugins)
|
||||
1. [PMIx](docs/Plugins.md#731-pmix)
|
||||
FairMQ is free software under the [LGPL-3.0](LICENSE). See [COPYRIGHT](COPYRIGHT) and
|
||||
[how to cite FairMQ](https://fairrootgroup.github.io/FairMQ/project/license/).
|
||||
|
||||
@@ -1,147 +0,0 @@
|
||||
← [Back](../README.md)
|
||||
|
||||
# 3. Configuration
|
||||
|
||||
## 3.1 Device Configuration
|
||||
|
||||
Device Configuration is stored in configuration object - `fair::mq::ProgOptions`. It is accessible by the device, plugins or from DeviceRunner/main:
|
||||
|
||||
Plugins <---read/write---> ProgOptions <---read/write---> Device
|
||||
|
||||
Whenever a configuration property is set, it is set in ProgOptions. Device/Channels/User code read this value and apply it as necessary at different stages:
|
||||
- apply it immidiately
|
||||
- apply it in device/channels during InitializingDevice/Binding/Connecting states
|
||||
|
||||
Here is an overview of the device/channel options and when they are applied:
|
||||
|
||||
| Property | Applied in |
|
||||
| --- | --- |
|
||||
| `severity` | immidiately (if `fair::mq::DeviceRunner` is used (also the case when using `<fairmq/runDevice.h>`)) |
|
||||
| `file-severity` | immidiately (if `fair::mq::DeviceRunner` is used (also the case when using `<fairmq/runDevice.h>`)) |
|
||||
| `verbosity` | immidiately (if `fair::mq::DeviceRunner` is used (also the case when using `<fairmq/runDevice.h>`)) |
|
||||
| `color` | immidiately (if `fair::mq::DeviceRunner` is used (also the case when using `<fairmq/runDevice.h>`)) |
|
||||
| `log-to-file` | immidiately (if `fair::mq::DeviceRunner` is used (also the case when using `<fairmq/runDevice.h>`)) |
|
||||
| `id` | at the end of `fair::mq::State::InitializingDevice` |
|
||||
| `io-threads` | at the end of `fair::mq::State::InitializingDevice` |
|
||||
| `transport` | at the end of `fair::mq::State::InitializingDevice` |
|
||||
| `network-interface` | at the end of `fair::mq::State::InitializingDevice` |
|
||||
| `init-timeout` | at the end of `fair::mq::State::InitializingDevice` |
|
||||
| `shm-segment-size` | at the end of `fair::mq::State::InitializingDevice` |
|
||||
| `shm-monitor` | at the end of `fair::mq::State::InitializingDevice` |
|
||||
| `rate` | at the end of `fair::mq::State::InitializingDevice` |
|
||||
| `session` | at the end of `fair::mq::State::InitializingDevice` |
|
||||
| `chan.*` | at the end of `fair::mq::State::InitializingDevice` (channel addresses can be also applied during `fair::mq::State::Binding`/`fair::mq::State::Connecting`) |
|
||||
|
||||
## 3.2 Configuration options
|
||||
|
||||
## 3.2 Communication Channels Configuration
|
||||
|
||||
The communication channels can be configured via configuration parsers. The parser system is extendable, so if provided parsers do not suit your style, you can write your own and plug them in the configuration system.
|
||||
|
||||
The provided parsers are:
|
||||
|
||||
### 3.2.1 JSON Parser
|
||||
|
||||
This parser reads channel configuration from a JSON file. Example:
|
||||
|
||||
```JSON
|
||||
{
|
||||
"fairMQOptions": {
|
||||
"devices": [
|
||||
{
|
||||
"id": "sampler1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "push",
|
||||
"method": "bind",
|
||||
"address": "tcp://*:5555",
|
||||
"sndBufSize": 1000,
|
||||
"rcvBufSize": 1000,
|
||||
"sndKernelSize" : 0,
|
||||
"rcvKernelSize" : 0,
|
||||
"transport": "shmem",
|
||||
"linger": "500",
|
||||
"portRangeMin": "22000",
|
||||
"portRangeMax": "23000",
|
||||
"autoBind": false,
|
||||
"numSockets": 0,
|
||||
"rateLogging": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sink1",
|
||||
"channels": [
|
||||
{
|
||||
"name": "data",
|
||||
"sockets": [
|
||||
{
|
||||
"type": "pull",
|
||||
"method": "connect",
|
||||
"address": "tcp://localhost:5555",
|
||||
"transport": "shmem"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The JSON file can contain configuration for multiple devices.
|
||||
|
||||
- The mapping between device and configuration happens via the device ID (the `--id` parameter of the launched device and the `"id"` entry in the config).
|
||||
- Instead of `"id"`, JSON file may contain device configurations under `"key"`, which allows launched devices to share configuration, e.g.: `my-device-executable --id <device-id> --config-key <config-key>`.
|
||||
- Socket options must contain at least *type*, *method* and *address*, the rest of the values are optional and will get default values of the channel.
|
||||
- If a channel has multiple sub-channels, common properties can be defined under channel directly, and will be shared by all sub-channels, e.g.:
|
||||
|
||||
```JSON
|
||||
"channels": [{
|
||||
"name": "data",
|
||||
"type": "push",
|
||||
"method": "bind",
|
||||
"sockets": [{
|
||||
"address": "tcp://*:5555",
|
||||
"address": "tcp://*:5556",
|
||||
"address": "tcp://*:5557"
|
||||
}]
|
||||
}]
|
||||
```
|
||||
|
||||
### 3.2.2 SuboptParser
|
||||
|
||||
This parser configures channels directly from the command line.
|
||||
The parser handles a comma separated key=value list format by using the getsubopt function of the standard library.
|
||||
The option key `--channel-config` can be used with the list of key/value pairs, e.g.:
|
||||
|
||||
```
|
||||
--channel-config name=output,type=push,method=bind,address=tcp://127.0.0.1:5555
|
||||
```
|
||||
|
||||
## 3.3 Introspection
|
||||
|
||||
A compiled device executable repots its available configuration. Run the device with one of the following options to see the corresponding help:
|
||||
|
||||
- `-h [ --help ]`: All available command line options with their descriptions and default values.
|
||||
|
||||
- `--print-options`: All available command line options in a machine-readable format: `<option>:<computed-value>:<<type>>:<description>`.
|
||||
|
||||
- `--print-channels`: Prints registered channels in a machine-readable format: `<channel name>:<minimum sub-channels>:<maximum sub-channels>`. There are devices where channels names are not known in advance before the configuration takes place (e.g. FairMQMultiplier has configurable channel names at runtime). This options will only print channels that have been registered in the device by implementing the following method:
|
||||
|
||||
```C++
|
||||
void YourDevice::RegisterChannelEndpoints()
|
||||
{
|
||||
// provide channel name, minimum and maximum number of subchannels
|
||||
RegisterChannelEndpoint("channelA", 1, 10000);
|
||||
RegisterChannelEndpoint("channelB", 1, 1);
|
||||
}
|
||||
```
|
||||
|
||||
← [Back](../README.md)
|
||||
@@ -1,58 +0,0 @@
|
||||
← [Back](../README.md)
|
||||
|
||||
# 4. Development
|
||||
|
||||
## 4.1 Testing
|
||||
|
||||
For unit testing it is often not feasible to boot up a full-blown distributed system with dozens of processes.
|
||||
|
||||
In some scenarios it is useful to not even instantiate a `fair::mq::Device` at all. Please see [this example](../test/protocols/_push_pull_multipart.cxx) for single and multi threaded unit test without a device instance. If you store your transport factories and channels on the heap, pls make sure, you destroy the channels before you destroy the related transport factory for proper shutdown. Channels provide all the `Send/Receive` and `New*Message/New*Poller` APIs provided by the device too.
|
||||
|
||||
## 4.2 Static Analysis
|
||||
|
||||
With `-DBUILD_TIDY_TOOL=ON` you can build the `fairmq-tidy` tool that implements static checks on your source code. To use it, enable the generation of a [compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) in your project via `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` (generates a file `<builddir>/compile_commands.json`):
|
||||
|
||||
```
|
||||
fairmq-tidy -p <builddir> mysourcefile.cpp
|
||||
```
|
||||
|
||||
If you find any issue (e.g. false positives) with this tool, please tell us by opening an issue on github.
|
||||
|
||||
### 4.2.1 CMake Integration
|
||||
|
||||
When discovering a FairMQ installation in your project, explicitely state, that you want one with the `fairmq-tidy` tool included:
|
||||
|
||||
```
|
||||
find_package(FairMQ COMPONENTS tidy_tool)
|
||||
```
|
||||
|
||||
Now the CMake module [`FairMQTidy.cmake`](../cmake/FairMQTidy.cmake) is available for inclusion:
|
||||
|
||||
```
|
||||
include(FairMQTidy)
|
||||
```
|
||||
|
||||
It provides the CMake function `fairmq_target_tidy()` which attaches appropriate `fairmq-tidy` build rules to each source file contained in the passed library or executable target, e.g. if you have an executable that uses FairMQ:
|
||||
|
||||
```
|
||||
add_executable(myexe mysource1.cpp mysource2.cpp)
|
||||
target_link_libraries(myexe PRIVATE FairMQ::FairMQ)
|
||||
fairmq_target_tidy(TARGET myexe)
|
||||
```
|
||||
|
||||
### 4.2.2 Extra Compiler Arguments
|
||||
|
||||
On most Linux distros you are likely to use GCC to compile your projects, so the resulting `compile_commands.json` contains the command-line tuned for GCC which might be missing options needed to successfully invoke the Clang frontend which is used internally by `fairmq-tidy`. In general, you can pass extra `clang` options via the following options:
|
||||
|
||||
```
|
||||
--extra-arg=<string> - Additional argument to append to the compiler command line
|
||||
--extra-arg-before=<string> - Additional argument to prepend to the compiler command line
|
||||
```
|
||||
|
||||
E.g. if standard headers are not found, you can hint the location like this:
|
||||
|
||||
```
|
||||
fairmq-top -p <builddir> --extra-arg-before=-I$(clang -print-resource-dir)/include mysourcefile.cpp
|
||||
```
|
||||
|
||||
← [Back](../README.md)
|
||||
@@ -1,53 +0,0 @@
|
||||
← [Back](../README.md)
|
||||
|
||||
# 1. Device
|
||||
|
||||
The components encapsulating the tasks are called **devices** and derive from the common base class `fair::mq::Device`. FairMQ provides ready to use devices to organize the dataflow between the components (without touching the contents of a message), providing functionality like merging and splitting of the data stream (see subdirectory `devices`).
|
||||
|
||||
## 1.1 Topology
|
||||
|
||||
Devices are arranged into **topologies** where each device has a defined number of data inputs and outputs.
|
||||
|
||||
Example of a simple FairMQ topology:
|
||||
|
||||

|
||||
|
||||
Within a topology each device needs a unique id (given to it via required command line option `--id`).
|
||||
|
||||
Topology configuration is currently happening via setup scripts. This is very rudimentary and a much more flexible system is now in development. For now, example setup scripts can be found in directory `FairRoot/example/Tutorial3/` along with some additional documentation.
|
||||
|
||||
## 1.2 Communication Patterns
|
||||
|
||||
FairMQ devices communicate via the communication patterns offered by ZeroMQ: PUSH-PULL, PUB-SUB, REQ-REP, PAIR, [more info here](http://api.zeromq.org/4-0:zmq-socket). Each transport may provide further patterns.
|
||||
|
||||
## 1.3 State Machine
|
||||
|
||||
Each FairMQ device has an internal state machine:
|
||||
|
||||

|
||||
|
||||
The state machine can be querried and controlled via `GetCurrentStateName()` and `ChangeState("<state name>")` methods. Only legal state transitions are allowed (see image above). Illegal transitions will fail with an error.
|
||||
|
||||
If the device is running in interactive mode (default), states can be changed via keyboard input:
|
||||
|
||||
- `'h'` - help
|
||||
- `'r'` - run
|
||||
- `'s'` - stop
|
||||
- `'t'` - reset task
|
||||
- `'d'` - reset device
|
||||
- `'q'` - end
|
||||
- `'j'` - init task
|
||||
- `'i'` - initialize
|
||||
- `'b'` - bind
|
||||
- `'x'` - connect
|
||||
|
||||
Without the interactive mode, for example for a run in background, two other control mechanisms are available:
|
||||
|
||||
- static (`--control static`) - device goes through a simple init -> run -> reset -> exit chain.
|
||||
- dds (`--control dds`) - device is controled by external command, in this case using dds commands (fairmq-dds-command-ui).
|
||||
|
||||
## 1.4 Multiple devices in the same process
|
||||
|
||||
Technically one can create two or more devices within the same process without any conflicts. However the configuration (fair::mq::ProgOptions) currently assumes the supplied configuration values are for one device/process.
|
||||
|
||||
← [Back](../README.md)
|
||||
@@ -1,9 +0,0 @@
|
||||
← [Back](../README.md)
|
||||
|
||||
# 6. Examples
|
||||
|
||||
A collection of simple examples in `FairRoot/examples/MQ` directory demonstrates some common usage patterns of FairMQ.
|
||||
|
||||
A number of devices to handle the data from the Tutorial3 FairTestDetector of FairRoot are provided as an example and can be found in `FairRoot/base/MQ` directory. The implementation of the tasks run by these devices can be found `FairRoot/examples/advanced/Tutorial3`. The implementation includes sending raw binary data as well as serializing the data with either [Boost Serialization](http://www.boost.org/doc/libs/release/libs/serialization/), [Google Protocol Buffers](https://developers.google.com/protocol-buffers/) or [Root TMessage](http://root.cern.ch/root/html/TMessage.html). Following the examples you can implement your own devices to transport arbitrary data.
|
||||
|
||||
← [Back](../README.md)
|
||||
103
docs/Logging.md
103
docs/Logging.md
@@ -1,103 +0,0 @@
|
||||
← [Back](../README.md)
|
||||
|
||||
# 5. Logging
|
||||
|
||||
The FairMQLogger header uses fair::Logger library for logging.
|
||||
|
||||
All log calls go through the provided LOG(severity) macro. Output through this macro is thread-safe. Logging is done to cout, file output and/or custom sinks.
|
||||
|
||||
## 5.1 Log severity
|
||||
|
||||
The log severity is controlled via:
|
||||
```C++
|
||||
fair::Logger::SetConsoleSeverity("<severity level>");
|
||||
// and/or
|
||||
fair::Logger::SetFileSeverity("<severity level>");
|
||||
// and/or
|
||||
fair::Logger::SetCustomSeverity("<customSinkName>", "<severity level>");
|
||||
```
|
||||
|
||||
where severity level is one of the following:
|
||||
|
||||
```C++
|
||||
"nolog",
|
||||
"fatal",
|
||||
"error",
|
||||
"warn",
|
||||
"state",
|
||||
"info",
|
||||
"debug",
|
||||
"debug1",
|
||||
"debug2",
|
||||
"debug3",
|
||||
"debug4",
|
||||
"trace",
|
||||
```
|
||||
|
||||
Logger will log the chosen severity and all above it (except "nolog", which deactivates logging for that sink completely). Fatal severity is always logged.
|
||||
|
||||
When running a FairMQ device, the log severity can be simply provided via `--severity <level>` cmd option.
|
||||
|
||||
## 5.2 Log verbosity
|
||||
|
||||
The log verbosity is controlled via:
|
||||
```C++
|
||||
fair::Logget::SetVerbosity("<verbosity level>");
|
||||
```
|
||||
|
||||
it is same for all sinks, and is one of the following values: `low`, `medium`, `high`, `veryhigh`, which translates to following output:
|
||||
|
||||
```
|
||||
low: [severity] message
|
||||
medium: [HH:MM:SS][severity] message
|
||||
high: [process name][HH:MM:SS:µS][severity] message
|
||||
veryhigh: [process name][HH:MM:SS:µS][severity][file:line:function] message
|
||||
```
|
||||
|
||||
When running a FairMQ device, the log severity can be simply provided via `--verbosity <level>` cmd option.
|
||||
|
||||
## 5.3 Color
|
||||
|
||||
Colored output on console can be activated with:
|
||||
```C++
|
||||
Logger::SetConsoleColor(true);
|
||||
```
|
||||
|
||||
When running a FairMQ device, the log color (console) can be simply provided via `--color <true/false>` cmd option (default is true).
|
||||
|
||||
## 5.4 File output
|
||||
|
||||
Output to file can be enabled via:
|
||||
```C++
|
||||
Logger::InitFileSink("<severity level>", "test_log", true);
|
||||
```
|
||||
which will add output to "test_log" filename (if third parameter is `true` it will add timestamp to the file name) with `<severity level>` severity.
|
||||
|
||||
When running a FairMQ device, the log file can be simply provided via `--log-to-file <filename_prefix>` cmd option (this will also turn off console output).
|
||||
|
||||
## 5.5 Custom sinks
|
||||
|
||||
Custom sinks can be added via `Logger::AddCustomSink("sink name", "<severity>", callback)` method.
|
||||
|
||||
Here is an example adding a custom sink for all severities ("trace" and above). It has access to the log content and meta data. Custom log calls are also thread-safe.
|
||||
|
||||
```C++
|
||||
Logger::AddCustomSink("MyCustomSink", "trace", [](const string& content, const LogMetaData& metadata)
|
||||
{
|
||||
cout << "content: " << content << endl;
|
||||
|
||||
cout << "available metadata: " << endl;
|
||||
cout << "std::time_t timestamp: " << metadata.timestamp << endl;
|
||||
cout << "std::chrono::microseconds us: " << metadata.us.count() << endl;
|
||||
cout << "std::string process_name: " << metadata.process_name << endl;
|
||||
cout << "std::string file: " << metadata.file << endl;
|
||||
cout << "std::string line: " << metadata.line << endl;
|
||||
cout << "std::string func: " << metadata.func << endl;
|
||||
cout << "std::string severity_name: " << metadata.severity_name << endl;
|
||||
cout << "fair::Severity severity: " << static_cast<int>(metadata.severity) << endl;
|
||||
});
|
||||
```
|
||||
|
||||
If only output from custom sinks is desirable, console/file sinks must be deactivated by setting their severity to `"nolog"`.
|
||||
|
||||
← [Back](../README.md)
|
||||
@@ -1,61 +0,0 @@
|
||||
← [Back](../README.md)
|
||||
|
||||
# 7. Plugins
|
||||
|
||||
FairMQ devices can be integrated with external configuration and control systems through its plugin system. FairMQ plugins are special dynamic libraries that can be loaded at runtime. Plugins have access to the Plugin API which includes the capability to control/monitor the device [state machine](Device.md#13-state-machine) and change/monitor configuration properties.
|
||||
|
||||
A simple plugin may add the feature to read configuration from a certain desired file format once at the start of a device. A more complex plugin may create a long-running thread that integrates a network client to an external API of a central experiment control system.
|
||||
|
||||
Because plugins are loaded dynamically, they can be developed in separate repositories/projects and also have their own set of runtime dependency that are not needed to be known at compile-time of the FairMQ device.
|
||||
|
||||
## 7.1 Usage
|
||||
|
||||
To load a plugin pass the `-P <name>[,<name>]` (or long `--plugin`) command line option. Multiple plugins can be loaded at the same time. The load order is as specified at the command line. This determines the order in which the plugins are instantiated (ctor call order) and in which order they are notified, should they subscribe to any notifications.
|
||||
|
||||
When passing `-h/--help` on the command line one can find more detailed information:
|
||||
|
||||
```
|
||||
Plugin Manager:
|
||||
-S [ --plugin-search-path ] arg List of plugin search paths.
|
||||
* Override default search path, e.g.
|
||||
-S /home/user/lib /lib
|
||||
* Append(>) or prepend(<) to default
|
||||
search path, e.g.
|
||||
-S >/lib </home/user/lib
|
||||
* If you mix the overriding and
|
||||
appending/prepending syntaxes, the
|
||||
overriding paths act as default search
|
||||
path, e.g.
|
||||
-S /usr/lib >/lib </home/user/lib
|
||||
/usr/local/lib results in
|
||||
/home/user/lib,/usr/local/lib,/usr/lib/
|
||||
,/lib
|
||||
If nothing is found, the default
|
||||
dynamic library lookup is performed,
|
||||
see man ld.so(8) for details.
|
||||
-P [ --plugin ] arg List of plugin names to load in
|
||||
order,e.g. if the file is called
|
||||
'libfairmq-plugin-example.so', just list
|
||||
'example' or 'd:example' here.To load a
|
||||
prelinked plugin, list 'p:example'
|
||||
here.
|
||||
```
|
||||
|
||||
## 7.2 Development
|
||||
|
||||
To develop a custom FairMQ plugin, one simply needs to inherit from the `fair::mq::Plugin` base class (`#include <fairmq/Plugin.h>`) and call the `REGISTER_FAIRMQ_PLUGIN` macro. It is possible to introduce new command line option together with a plugin.
|
||||
|
||||
The Plugin API includes:
|
||||
* `Take/Steal/ReleaseDeviceControl()`/`GetCurrent/ChangeDeviceState()`/`SubscribeTo/UnsubscribeFromDeviceStateChange()` APIs enable controlling the device state machine. Only one plugin is authorized to control at the same time. Which one is determined by which plugin calls `TakeDeviceControl()` first.
|
||||
* `Set/GetProperty()`/`GetPropertyKeys()`/`SubscribeTo/UnsubscribeFromPropertyChange()` APIs enable configuration of device properties.
|
||||
See [`<fairmq/Plugin.h>`](/fairmq/Plugin.h) for the full API.
|
||||
|
||||
A more complete example which may serve as a start including example CMake code can be found here: [FairRootGroup/FairMQPlugin_example](https://github.com/FairRootGroup/FairMQPlugin_example).
|
||||
|
||||
## 7.3 Provided Plugins
|
||||
|
||||
### 7.3.1 PMIx
|
||||
|
||||
The [PMIx](https://pmix.org/) plugin enables launching a FairMQ topology with any PMIx capable launcher, e.g. the [Open Run-Time Environment (ORTE) of OpenMPI](https://www.open-mpi.org/doc/v4.0/man1/mpirun.1.php) or the [Slurm workload manager](https://slurm.schedmd.com/srun.html). This experimental plugin has been last released in v1.4.56 and is removed in v1.5+. For now there are no plans to pick up development of it again.
|
||||
|
||||
← [Back](../README.md)
|
||||
@@ -1,94 +0,0 @@
|
||||
← [Back](../README.md)
|
||||
|
||||
# 2. Transport Interface
|
||||
|
||||
The communication layer is available through the transport interface. Three interface implementations are currently available. Main implementation uses the [ZeroMQ](http://zeromq.org) library. Second transport implementation is using shared memory via boost::interprocess & ZeroMQ combination.
|
||||
|
||||
Here is an overview to give an idea how the interface is implemented:
|
||||
|
||||

|
||||
|
||||
Currently, the transports have been tested to work with these communication patterns:
|
||||
|
||||
| | zeromq | shmem |
|
||||
| ------------- |--------| ----- |
|
||||
| PAIR | yes | yes |
|
||||
| PUSH/PULL | yes | yes |
|
||||
| PUB/SUB | yes | no |
|
||||
| REQ/REP | yes | yes |
|
||||
|
||||
The next table shows the supported address types for each transport implementation:
|
||||
|
||||
| | zeromq | shmem | comment |
|
||||
| ----------- | ------ | ----- | --------------------------------------------- |
|
||||
| `inproc://` | yes | yes | in process: useful for unit testing |
|
||||
| `ipc://` | yes | yes | inter process comm: useful on single machine |
|
||||
| `tcp://` | yes | yes | useful for any communication, local or remote |
|
||||
|
||||
## 2.1 Message
|
||||
|
||||
Devices transport data between each other in form of `fair::mq::Message`s. These can be filled with arbitrary content. Message can be initialized in three different ways by calling `NewMessage()`:
|
||||
|
||||
```cpp
|
||||
fair::mq::MessagePtr NewMessage() const;
|
||||
```
|
||||
**with no parameters**: Initializes an empty message (typically used for receiving).
|
||||
|
||||
```cpp
|
||||
fair::mq::MessagePtr NewMessage(const size_t size) const;
|
||||
```
|
||||
**given message size**: Initializes message body with a given size. Fill the created contents via buffer pointer.
|
||||
|
||||
```cpp
|
||||
using fairmq_free_fn = void(void* data, void* hint);
|
||||
fair::mq::MessagePtr NewMessage(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) const;
|
||||
```
|
||||
**given existing buffer and a size**: Initialize the message from an existing buffer. In case of ZeroMQ this is a zero-copy operation.
|
||||
|
||||
Additionally, FairMQ provides two more message factories for convenience:
|
||||
```cpp
|
||||
template<typename T>
|
||||
fair::mq::MessagePtr NewSimpleMessage(const T& data) const
|
||||
```
|
||||
**copy and own**: Copy the `data` argument into the returned message and take ownership (free memory after message is sent). This interface is useful for small, [trivially copyable](http://en.cppreference.com/w/cpp/concept/TriviallyCopyable) data.
|
||||
|
||||
```cpp
|
||||
template<typename T>
|
||||
fair::mq::MessagePtr NewStaticMessage(const T& data) const
|
||||
```
|
||||
**point to existing memory**: The returned message will point to the `data` argument, but not take ownership (someone else must destruct this variable). Make sure that `data` lives long enough to be successfully sent. This interface is most useful for third party managed, contiguous memory (Be aware of shallow types with internal pointer references! These will not be sent.)
|
||||
|
||||
## 2.1.1 Ownership
|
||||
|
||||
The component of a program, that is reponsible for the allocation or destruction of data in memory, is taking ownership over this data. Ownership may be passed along to another component. It is also possible that multiple components share ownership of data. In this case, some strategy must be in place to determine the last user of the data and assign her the responsibility of destruction.
|
||||
|
||||
After queuing a message for sending in FairMQ, the transport takes ownership over the message body and will free it with `free()` after it is no longer used. A callback can be passed to the message object, to be called instead of the destruction with `free()` (for initialization via buffer+size).
|
||||
|
||||
```cpp
|
||||
static void fair::mq::NoCleanup(void* /*data*/, void* /*obj*/) {}
|
||||
|
||||
template<typename T>
|
||||
static void fair::mq::SimpleMsgCleanup(void* /*data*/, void* obj) { delete static_cast<T*>(obj); }
|
||||
```
|
||||
For convenience, two common deleter callbacks are already defined in the `fair::mq::TransportFactory` class to aid the user in controlling ownership of the data.
|
||||
|
||||
## 2.2 Channel
|
||||
|
||||
A channel represents a communication endpoint in FairMQ. Usage is similar to a traditional Unix network socket. A device usually contains a number of channels that can either listen for incoming connections from channels of other devices or they can connect to other listening channels. Channels are organized by a channel name and a subchannel index.
|
||||
|
||||
```cpp
|
||||
const fair::mq::Channel& GetChannel(const std::string& channelName, const int index = 0) const;
|
||||
```
|
||||
|
||||
All subchannels with a common channel name need to be of the same transport type.
|
||||
|
||||
## 2.3 Poller
|
||||
|
||||
A poller allows to wait on multiple channels either to receive or send a message.
|
||||
|
||||
```cpp
|
||||
fair::mq::PollerPtr NewPoller(const std::vector<const fair::mq::Channel*>& channels)
|
||||
```
|
||||
**list channels**: This poller waits on all supplied channels. Currently, it is limited to channels of the same transport type only.
|
||||
|
||||
← [Back](../README.md)
|
||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 170 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 11 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
@@ -1,10 +1,6 @@
|
||||
1-1: Sampler -> Sink
|
||||
====================
|
||||
# Example 1-1: sampler and sink
|
||||
|
||||
A simple topology of two devices - **Sampler** and **Sink**. **Sampler** sends data to **Sink** via the **PUSH-PULL** pattern.
|
||||
Two devices: a sampler sends a text message on a push channel, and a sink receives it on a pull channel.
|
||||
|
||||
`sampler.cxx` and `sink.cxx` configure and run the devices.
|
||||
|
||||
The executables take two command line parameters: `--id` and `--channel-config`. The value of `--id` should be a unique identifier and the value for `--channel-config` is the configuration of the communication channel. .
|
||||
|
||||
For this and the following example, all the commands needed to start the device are contained in the `fairmq-start-ex-*.sh` script (that can also be used for starting the example).
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/1-1/>
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
1-n-1: Sampler -> Processor(s) -> Sink
|
||||
======================================
|
||||
# Example 1-n-1: sampler, processors and sink
|
||||
|
||||
A simple topology of three devices - **Sampler**, **Processor** and **Sink**. **Sampler** sends data to one or more **Processor**s, who modify the data and send it to one **Sink**. Transport with the **PUSH-PULL** pattern.
|
||||
A sampler sends messages to several processors, and the processors send the results to one sink. A JSON file configures the channels.
|
||||
|
||||
The communication channels for this example are configured via a JSON file. The matching between device and config entry is done either via id, or the config key. For this example both processor devices share same configuration, and can therefore use same setting from the JSON file. But since their ID still has to be unique, additional command line argument must be used to allow them to share configuration. This parameter is `--config-key`.
|
||||
|
||||
In this example the Sampler is configured to **bind** its output and the Sink is configured to also **bind** its input. This allows us run any number of processors with the same configuration, because they all connect to same Sampler and Sink addresses. Furthermore, it allows adding of processors dynamically during run-time. The PUSH and PULL sockets will handle the data distribution to/from the new devices according to their distribution strategies ([Round-robin output for PUSH](http://api.zeromq.org/4-0:zmq-socket#toc14) and [Fair-queued input for PULL](http://api.zeromq.org/4-0:zmq-socket#toc15)).
|
||||
|
||||
The Sampler sends out a simple text string (its content configurable with `--text` command line parameter, defaul is "Hello"). Each Processor modifies the string by appending its ID to it and send it to the Sink.
|
||||
|
||||
The provided configuration file contains two Processors. To add more Processors, you can either extend the configuration file, or create a separate file only for new processors. Or combine JSON config with `--channel-config` from other examples.
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/1-n-1/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Built-in devices
|
||||
==========================
|
||||
# Example builtin-devices: a topology of built-in devices
|
||||
|
||||
This example demonstrates use of generic devices that are provided with FairMQ - BenchmarkSampler, Merger, Multiplier, Proxy, Sink, Splitter. They are all connected in one topology and transfer some dummy buffers generated by the BenchmarkSampler.
|
||||
The built-in devices fairmq-bsampler, fairmq-splitter, fairmq-proxy, fairmq-merger, fairmq-multiplier and fairmq-sink in one topology, without own code.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/builtin-devices/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Copy & Push
|
||||
===========
|
||||
# Example copypush: one message to several receivers
|
||||
|
||||
A topology consisting of one **Sampler** and two **Sink**s. The **Sampler** uses the `Copy` method to send the same data to both sinks with the **PUSH-PULL** pattern. In contrary to the **PUB-SUB** pattern, this ensures that all receivers are connected and no data is lost, but requires additional sockets.
|
||||
A sampler sends the same data to two sinks. It makes a copy of each message for each sub-channel of a push channel.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/copypush/>
|
||||
|
||||
@@ -1,122 +1,6 @@
|
||||
DDS Example
|
||||
===========
|
||||
# Example dds: run with 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 the one in Example 1-n-1, but now it can be easily distributed on different computing nodes without the need for manual addresses reconfiguration of the devices.
|
||||
A sampler, ten processors and a sink in a DDS topology without channel addresses; the start script needs DDS and a DDS plugin for FairMQ.
|
||||
|
||||
The description below outlines the minimal steps needed to run the example with DDS. For general DDS help please refer to DDS documentation on [DDS Website](http://dds.gsi.de/).
|
||||
|
||||
##### 1. The device handles the channel addresses and ports configuration via DDS Plugin.
|
||||
|
||||
It is sufficient to provide the `-S "<@FAIRMQ_INSTALL_DIR@/lib" -P dds` (`<` prepends the following path to the default plugin search paths; put in the path which points to the library dir of your FairRoot installation) command line arguments to let the devices be configured dynamically. No code changes in the device are necessary. See the XML topology file for example of using the command line arguments.
|
||||
|
||||
##### 2a. Write DDS hosts file that contains a list of worker nodes to run the topology on (When deploying using the SSH plug-in).
|
||||
|
||||
We run this example on the local machine for simplicity. The file below defines 3 workers - sampler, processor and sink - with a total of 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 (password-less SSH access to these hosts must be possible)
|
||||
- additional SSH params (can be empty)
|
||||
- a remote working directory (most exist on the worker nodes)
|
||||
- number of DDS Agents for this worker
|
||||
|
||||
```bash
|
||||
@bash_begin@
|
||||
#source setup.sh
|
||||
@bash_end@
|
||||
|
||||
sampler, username@localhost, , /path/to/dds-work-dir/, 1
|
||||
processor, username@localhost, , /path/to/dds-work-dir/, 10
|
||||
sink, username@localhost, , /path/to/dds-work-dir/, 1
|
||||
```
|
||||
|
||||
##### 2b. Skip (When deploying using the localhost plug-in).
|
||||
|
||||
If you want to deploy on a single host DDS 1.6+ provides a localhost rms plug-in. You do not need a hosts file in that case.
|
||||
|
||||
##### 3. Write DDS topology file that describes which tasks (processes) to run and their topology and configuration.
|
||||
|
||||
Take a look at `ex-dds-topology.xml`. It consists of a definition part (properties, tasks, collections and more) and execution part (main). In our example Sampler, Processor and Sink tasks are defined, containing their executables and exchanged properties. The `<main>` of the topology uses the defined tasks. Besides one Sampler and one Sink task, a group containing Processor task is defined. The group has a multiplicity of 10, meaninig 10 Processors will be executed. Each of the Processors will receive the properties with Sampler and Sink addresses.
|
||||
|
||||
The configuration of the channel connection addresses is done by the DDS plugin via the channel names. The task property names must correspond to the channel names (data1, data2), with binding channels writing the properties and connecting channel reading the properties.
|
||||
|
||||
**If you chose step 2b earlier**, then modify the provided `ex-dds-topology.xml` in the top that the following lines read as following:
|
||||
```xml
|
||||
<declrequirement name="SamplerWorker" type="wnname" value=".*"/>
|
||||
<declrequirement name="ProcessorWorker" type="wnname" value=".*"/>
|
||||
<declrequirement name="SinkWorker" type="wnname" value=".*"/>
|
||||
```
|
||||
|
||||
Note that the attributes `value` contain a different value.
|
||||
|
||||
##### 4. Start DDS session.
|
||||
|
||||
First you need to initialize DDS environment:
|
||||
|
||||
```bash
|
||||
source DDS_env.sh # this script is located in the DDS installation directory
|
||||
```
|
||||
|
||||
The DDS session is started with:
|
||||
|
||||
```bash
|
||||
dds-session start
|
||||
```
|
||||
|
||||
##### 5. Submit DDS Agents (configured in the hosts file).
|
||||
|
||||
Agents are submitted with:
|
||||
```bash
|
||||
dds-submit --rms ssh --config ex-dds-hosts.cfg
|
||||
```
|
||||
The `--rms` option defines a destination resource management system. The `--config` specifies an SSH plug-in resource definition file.
|
||||
|
||||
**If you chose step 2b earlier**, run the following command instead:
|
||||
|
||||
```bash
|
||||
dds-submit --rms localhost -n 12
|
||||
```
|
||||
|
||||
##### 6. Activate the topology.
|
||||
|
||||
```bash
|
||||
dds-topology --activate ex-dds-topology.xml
|
||||
```
|
||||
|
||||
##### 7. Run
|
||||
|
||||
After activation, agents will execute the defined tasks on the worker nodes. Output of the tasks will be stored in the directory that was specified in the hosts file (or in the system temporary directory when using the localhost plugin).
|
||||
|
||||
##### 8. (optional) Use example command UI to check state of the devices
|
||||
|
||||
A simple utility (fairmq-dds-command-ui) is included with FairMQ to send commands to devices and receive replies from them. The utility uses the DDS intercom library to query state/config of devices and allows changing their state. To let the device listen to the commands from the utility, start the device with `-S "<@FAIRMQ_INSTALL_DIR@/lib" -P dds` cmd option (see example XML topology).
|
||||
|
||||
To see it in action, start the fairmq-dds-command-ui while the topology is running. Run the utility with `-h` to see everything that it can do.
|
||||
|
||||
The utility requires a session parameter to connect to appropriate DDS session. The session value is given when starting dds-session.
|
||||
|
||||
By default the command UI sends commands to all tasks. This can be further refined by giving a specific topology path via `-p` argument.
|
||||
Given our topology file, here are some examples of valid paths:
|
||||
```bash
|
||||
# get state of all devices
|
||||
./fairmq/plugins/DDS/fairmq-dds-command-ui -s 937ffbca-b524-44d8-9898-1d69aedc3751 -c c
|
||||
# get state of sampler
|
||||
./fairmq/plugins/DDS/fairmq-dds-command-ui -s 937ffbca-b524-44d8-9898-1d69aedc3751 -c c -p main/Sampler
|
||||
# get state of sink
|
||||
./fairmq/plugins/DDS/fairmq-dds-command-ui -s 937ffbca-b524-44d8-9898-1d69aedc3751 -c c -p main/Sink
|
||||
# get state all processors
|
||||
./fairmq/plugins/DDS/fairmq-dds-command-ui -s 937ffbca-b524-44d8-9898-1d69aedc3751 -c c -p main/ProcessorGroup/Processor
|
||||
# get state of a specific processor
|
||||
./fairmq/plugins/DDS/fairmq-dds-command-ui -s 937ffbca-b524-44d8-9898-1d69aedc3751 -c c -p main/ProcessorGroup/Processor_9
|
||||
```
|
||||
|
||||
##### 9. Stop DDS session/topology.
|
||||
|
||||
The execution of tasks can be stopped with:
|
||||
```bash
|
||||
dds-topology --stop
|
||||
```
|
||||
Or by stopping the DDS session:
|
||||
```bash
|
||||
dds-session stop
|
||||
```
|
||||
|
||||
For general DDS documentation please refer to [DDS Website](http://dds.gsi.de/).
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/dds/>
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
Sending Multipart messages
|
||||
==========================
|
||||
# Example multipart: several parts in one message
|
||||
|
||||
A topology of two devices - Sampler and Sink, communicating with PUSH-PULL pattern.
|
||||
A sampler sends a header and six data parts as one multipart message, and a sink receives all parts in one handler call.
|
||||
|
||||
The Sampler sends a multipart message to the Sink, consisting of two message parts - header and body.
|
||||
|
||||
Each message part is a regular fair::mq::Message. To combine them into a multi-part message use `fair::mq::Parts`. Add messages to `fair::mq::Parts` with `AddPart` method.
|
||||
|
||||
All parts are guaranteed to be delivered together. The Receive call in the sink will recive the entire parts structure.
|
||||
|
||||
The header contains a simple data structure with one integer. The integer in this structure is used as a stop flag for the sink. As long as its value is 0, the Sink will keep processing the data. Once its value is 1, the data handler method of the Sink will return false, which will exit the RUNNING state of the device.
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/multipart/>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
Multiple Channels
|
||||
=================
|
||||
# Example multiple-channels: data and broadcast
|
||||
|
||||
This example demonstrates how to work with multiple channels and multiplex between them.
|
||||
A sampler and a sink use a data channel and a broadcast channel. The sampler polls both channels, and the sink has one handler for each.
|
||||
|
||||
A topology of three devices - **Sampler**, **Sink** and **Broadcaster**. The Sampler sends data to the Sink via the PUSH-PULL pattern. The Broadcaster device sends a message to both Sampler and Sink containing a string "OK" every second. The Broadcaster sends the message via PUB pattern. Both Sampler and Sink, besides doing their PUSH-PULL job, listen via SUB to the Broadcaster.
|
||||
|
||||
The multiplexing between their data channels and the broadcast channels happens with `fair::mq::Poller`.
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/multiple-channels/>
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
Multiple Transports example
|
||||
===========================
|
||||
# Example multiple-transports: zeromq and shmem
|
||||
|
||||
This example demonstrates use of multiple transports (zeromq/shmem) within the same topology and/or device. It is a simple topology consisting of two samplers and a sink. The devices are connected via 3 channels:
|
||||
Two samplers and a sink use the shmem and the zeromq transport at the same time, with a transport for each channel.
|
||||
|
||||

|
||||
|
||||
Each device has main transport that it uses. By default it is ZeroMQ, and can be overriden via the `--transport` cmd option. The device will initialize additional transports if any of the channels have them configured (e.g. as an option to `--channel-config`).
|
||||
|
||||
In this example sampler1 and sink are started with `--transport shmem`, making shared memory their main transport, sampler2 with `--transport zeromq`. Additionally, the ack channel is configured to use zeromq as its transport.
|
||||
|
||||
The main two things that a transport does is transfer of data and allocation of memory for the messages. By default, new messages are created via the main device transport. If a message has been created with one transport and is to be transferred with another, it has to be copied into a new message of the target transport. This happens automatically behind the scenes. To avoid this copy the device can create messages via `NewMessageFor(const string& channelName, int subChannelIndex, ...)` method, that creates the messages via the transport of the given channel (check sampler1 and sink for an example) or as the channel directly to create a message.
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/multiple-transports/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
N-M
|
||||
==========================
|
||||
# Example n-m: n senders to m receivers
|
||||
|
||||
A topology consisting of three layers of devices: synchronizer -> sender(s) -> receiver(s). Senders distribute data to receivers based on the data id contained in the message from the synchronizer (same id goes to the same receiver from every sender). The senders send the data in a non-blocking fashion - if queue is full or receiver is down, data is discarded. Two configurations are provided - one using push/pull channels between senders/receivers, another using pair channels. In push/pull case there is only one receiving channel on the receiver device. In pair case there are as many receiver (sub-)channels as there are senders.
|
||||
Three senders send each timeframe to one of four receivers, and the receiver collects the parts of all senders; with push/pull or pair channels.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/n-m/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
QC
|
||||
==
|
||||
# Example qc: quality control on demand
|
||||
|
||||
A topology consisting of 4 devices - Sampler, QCDispatcher, QCTask and Sink. The data flows from Sampler through QCDispatcher to Sink. On demand - by setting the corresponding configuration property - the QCDispatcher device will duplicate the data to the QCTask device. The property is set by the topology controller, in this example this is the `fairmq-dds-command-ui` utility.
|
||||
A dispatcher forwards data from a sampler to a sink, and also to a QC task when a controller sets the property qc to active; the start script needs DDS.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/qc/>
|
||||
|
||||
@@ -1,27 +1,6 @@
|
||||
# Readout example
|
||||
# Example readout: a readout chain
|
||||
|
||||
This examples shows two possible topologies (out of many) for a node connected to a detector readout (followed by a processing node).
|
||||
A readout node passes region messages over shmem channels and sends them to a receiver over zeromq, with or without a processor.
|
||||
|
||||
## Setup without new data generation
|
||||
|
||||
```
|
||||
|------------------------------- Readout Node ---------------------------| |- Processing Node -|
|
||||
| Readout --> Builder --> Sender | --> | Receiver |
|
||||
| [# shared memory segment (unused in this topology) ##################] | zmq | |
|
||||
| [# shmem unmanaged region (readout writes here, others read) ########] | | |
|
||||
|------------------------------------------------------------------------| |-------------------|
|
||||
```
|
||||
|
||||
The devices one the Readout Node communicate via shared memory transport. Readout device writes into shared memory unmanaged region. The data is then forwarded through Builder to Sender process, which sends it out via zeromq transport.
|
||||
|
||||
## Setup with generating new data on the Readout node
|
||||
|
||||
```
|
||||
|------------------------------- Readout Node ---------------------------| |- Processing Node -|
|
||||
| Readout --> Builder --> Processor --> Sender | --> | Receiver |
|
||||
| [# shared memory segment (used between Proccessor and Sender) #######] | zmq | |
|
||||
| [# shmem unmanaged region (readout writes here, builder & proc read) ] | | |
|
||||
|------------------------------------------------------------------------| |-------------------|
|
||||
```
|
||||
|
||||
In this topology one more device is added - Processor. It examines the arriving data and creates new data in shared memory. This data is not part of the unmanaged region, but lives in the general shared memory segment (unused in the previous setup). This new data is then forwarded to Sender and the Readout device is notified that the corresponding data piece in the unmanaged region is no longer used.
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/readout/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
Region example
|
||||
==============
|
||||
# Example region: unmanaged regions
|
||||
|
||||
This example demonstrates the use of a more advanced feature - UnmanagedRegion, that can be used to create a buffer through one of FairMQ transports. The contents of this buffer are managed by the user, who can also create messages out of sub-buffers of the created buffer. Such feature can be interesting in environments that have special requirements by the hardware that writes the data, to keep the transfer efficient (e.g. shared memory).
|
||||
A sampler sends messages from an unmanaged region and counts the acknowledgements; a larger topology shares the region data with four sinks.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/region/>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Request & Reply example
|
||||
=======================
|
||||
# Example req-rep: request and reply
|
||||
|
||||
This topology contains two devices that communicate with each other via the **REQ-REP** pettern. Bidirectional communication via a single socket.
|
||||
A client sends a request on a req socket and waits for the reply. A server answers on a rep socket of the same channel.
|
||||
|
||||
The documentation explains the code, the topology and the commands:
|
||||
<https://fairrootgroup.github.io/FairMQ/examples/req-rep/>
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
# Generic Devices
|
||||
# Built-in devices
|
||||
|
||||
With FairMQ several generic devices are provided:
|
||||
This folder holds the devices that FairMQ installs as programs: `fairmq-bsampler`, `fairmq-sink`, `fairmq-merger`, `fairmq-splitter`, `fairmq-multiplier` and `fairmq-proxy`.
|
||||
|
||||
- **BenchmarkSampler**: generates random data of configurable size and at configurable rate and sends it out on an output channel.
|
||||
- **Sink**: receives messages on the input channel and simply discards them.
|
||||
- **Merger**: receives data from multiple input channels and forwards it to a single output channel.
|
||||
- **Splitter**: receives messages on a single input channels and round-robins them among multiple output channels (which can have different socket types).
|
||||
- **Multiplier**: receives data from a single input channel and multiplies (copies) it to two or more output channels.
|
||||
- **Proxy**: connects input channel to output channel, where both can have different socket types and multiple peers.
|
||||
* [Built-in devices](https://fairrootgroup.github.io/FairMQ/tools/builtin-devices/)
|
||||
* [Run a benchmark](https://fairrootgroup.github.io/FairMQ/guides/benchmark/)
|
||||
* [builtin-devices: a topology of built-in devices](https://fairrootgroup.github.io/FairMQ/examples/builtin-devices/)
|
||||
|
||||
@@ -1,67 +1,11 @@
|
||||
## Shared Memory transport
|
||||
# Shared memory transport
|
||||
|
||||
Shared memory transport for FairMQ. To try with existing devices, run the devices with `--transport shmem` option or configure channel transport in JSON (see examples/MQ/multiple-transports).
|
||||
This folder holds the `shmem` transport. The documentation explains it:
|
||||
|
||||
The transport manages shared memory via boost::interprocess library. The transfer of the meta data, required to locate the content in the shared memory, is done via ZeroMQ. The transport supports all communication patterns where a single message is received by a single receiver. For multiple receivers for the same message, the message has to be copied.
|
||||
|
||||
Devices track and cleanup shared memory on shutdown. For more information on the current shared memory segment and additional cleanup options, see following section.
|
||||
|
||||
## Shared Memory objects / files
|
||||
|
||||
FairMQ Shared Memory currently uses the following names to register shared memory on the system:
|
||||
|
||||
| name | info | created by | used by |
|
||||
| --------------------------- | ---------------------------------------------- | ------------------ | ------------------------------ |
|
||||
| `fmq_<shmId>_m_<segmentId>` | managed segment(s) (user data) | one of the devices | devices |
|
||||
| `fmq_<shmId>_mng` | management segment (management data) | one of the devices | devices |
|
||||
| `fmq_<shmId>_rg_<index>` | unmanaged region(s) | one of the devices | devices with unmanaged regions |
|
||||
| `fmq_<shmId>_rgq_<index>` | unmanaged region queue(s) | one of the devices | devices with unmanaged regions |
|
||||
| `fmq_<shmId>_rrc_<index>` | unmanaged region reference count pool(s) | one of the devices | devices with unmanaged regions |
|
||||
| `fmq_<shmId>_ms` | shmmonitor status | shmmonitor | devices, shmmonitor |
|
||||
|
||||
The shmId is generated out of session id and user id.
|
||||
|
||||
## Shared memory monitor
|
||||
|
||||
The shared memory monitor tool (`fairmq-shmmonitor`) can be used to monitor and cleanup the created shared memory.
|
||||
|
||||
Most commands act for the specified session, identified either via session id (`--session`,`-s`) or shmid (`--shmid`).
|
||||
|
||||
The monitor runs in one of the following modes:
|
||||
|
||||
| command | action |
|
||||
| --------------------------- | ---------------------------------------------- |
|
||||
| no args | Print segment info of the specified session/shm ID and exit. |
|
||||
| `--view`,`-v` | Print segment info of the specified session/shm ID and exit. |
|
||||
| `--interactive`,`-i` | Print segment info of the specified session/shm ID at a given interval (`--interval`), with some keyboard controls. Can be combined with `--view` for read-only access (and avoid receiving heartbeats). |
|
||||
| `--monitor`,`-m` | Monitor the session shm usage by receiving heartbeats from shmem users, cleaning it up if no heartbeats arrived within configured timeout (`--timeout`/`-t`). Only one heartbeat receiver per session is currently possible. If `--self-destruct`/`-x` is added, monitor will exit either when (a) no shm has been observed for interval * 2, (b) a cleanup due to reached timeout has been performed, or (c) shm has been observed, but is now cleaned up. |
|
||||
| `--cleanup`,`-c` | Cleanup the shm for the specified session and exit. |
|
||||
| `--debug`,`-b` | Print the list of messages in the current session and exit. Only availabe when FairMQ is compiled with `FAIRMQ_DEBUG_MODE=ON` (high performance impact). |
|
||||
| `--get-shmid` | Translate given session id and user id (`--user-id`) to a shmem id (uses current user id if none provided) and exit. |
|
||||
| `--list-all` | Print segment info for all sessions present on the system and exit. |
|
||||
|
||||
Additional cmd options:
|
||||
|
||||
| command | action |
|
||||
| --------------------------- | ---------------------------------------------- |
|
||||
| `--cleanup-on-exit` | Perform a cleanup on exit, when running in monitoring or interactive mode. |
|
||||
| `--daemonize`,`-d` | Can be combined with the monitoring mode to detach the process from the parent. |
|
||||
| `--verbose`,`-d` | When running as a daemon, store monitor output in `fairmq-shmmonitor_<timestamp>.log` |
|
||||
|
||||
For full option details, run with `-h`.
|
||||
|
||||
The Monitor class can also be used independently from the supplied executable, allowing integration on any level.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Bus Error (SIGBUS) can occur if the transport tries to access shared memory that is not accessible. One reason could be because the used memory in the segment exceeds the capacity or available memory of the shmem filesystem (capacity is by default set to half of RAM on Linux).
|
||||
|
||||
## Shared Memory cleanup
|
||||
|
||||
On a graceful shutdown of all devices, shared memory transport removes all created shared memory files. In case of a crash however, the cleanup cannot be guaranteed. Following possibilites are available to perform cleanup in case of crashes:
|
||||
|
||||
- For execution with Slurm a [job_container](https://slurm.schedmd.com/job_container.conf.html) can be used, which can isolate the shm and remove them upon job finish. This is currently the recommended approach.
|
||||
- a [trap](https://www.man7.org/linux/man-pages/man1/trap.1p.html) in an executing script on ERR/EXIT with a call to `fairmq-shmmonitor -c -s <sessionid>`. This would not work if the script is killed with -SIGKILL or similar fashion where it cannot call the trap.
|
||||
- [CTest cleanup fixture](https://cmake.org/cmake/help/latest/prop_test/FIXTURES_CLEANUP.html) with a call to `fairmq-shmmonitor -c -s <sessionid>`. This would work for an ongoing ctest run, but would not be called if a test run is interrupted, e.g. by SIGINT.
|
||||
- manual cleanup of the files listed [above](#shared-memory-objects--files).
|
||||
- Launch devices with `--shm-monitor true`. This will launch a daemon. The daemon will then listen for heartbeats from devices (every 100ms) and if none are received within 2000ms, will clean the memory. This is unreliable because the daemon can also be killed by a strict enough controller. But also if for some reason there are significant delays in the heartbeats, shmem could end up being cleaned before it should be.
|
||||
* [How shared memory works](https://fairrootgroup.github.io/FairMQ/shmem/how-it-works/)
|
||||
* [Sessions and segments](https://fairrootgroup.github.io/FairMQ/shmem/sessions/)
|
||||
* [Unmanaged regions](https://fairrootgroup.github.io/FairMQ/shmem/regions/)
|
||||
* [Out-of-band buffers](https://fairrootgroup.github.io/FairMQ/shmem/side-channel/)
|
||||
* [Monitor and clean up](https://fairrootgroup.github.io/FairMQ/shmem/monitor/)
|
||||
* [Tune and debug](https://fairrootgroup.github.io/FairMQ/shmem/tuning/)
|
||||
* [fairmq-shmmonitor](https://fairrootgroup.github.io/FairMQ/tools/shmmonitor/)
|
||||
|
||||
@@ -1,35 +1,5 @@
|
||||
# FairMQ Tools
|
||||
# Tools
|
||||
|
||||
Contains common tools for use by FairMQ and/or users.
|
||||
This folder holds the helpers in `fair::mq::tools`. The documentation lists them:
|
||||
|
||||
## fair::mq::tools::getHostIPs
|
||||
|
||||
Fills a map with the network interfaces and their IP addresses available on the current host.
|
||||
|
||||
#### Example usage
|
||||
|
||||
```c++
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <fairmq/Tools.h>
|
||||
|
||||
void main()
|
||||
{
|
||||
std::map<string,string> IPs;
|
||||
|
||||
fair::mq::tools::getHostIPs(IPs);
|
||||
|
||||
for (std::map<string,string>::iterator it = IPs.begin(); it != IPs.end(); ++it)
|
||||
{
|
||||
std::cout << it->first << ": " << it->second << std::endl;
|
||||
}
|
||||
}
|
||||
```
|
||||
##### Example Output
|
||||
```
|
||||
eth0: 123.123.1.123
|
||||
ib0: 123.123.2.123
|
||||
lo: 127.0.0.1
|
||||
```
|
||||
* [Helpers in fair::mq::tools](https://fairrootgroup.github.io/FairMQ/reference/tools/)
|
||||
|
||||
Reference in New Issue
Block a user