mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
Compare commits
279 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
dcea48fcee | ||
|
67dcf77a7f | ||
|
24e7a5b8d0 | ||
|
c11506e958 | ||
|
e4f258c9ea | ||
|
324a27a2e1 | ||
|
c80f97b338 | ||
|
76824fee36 | ||
|
d2e4679dc8 | ||
|
6bb70bd519 | ||
|
fe2127e12f | ||
|
41165cf16b | ||
|
8fe95e644e | ||
|
6628a231e2 | ||
|
91b31f0799 | ||
|
39cb021827 | ||
|
36b48f5594 | ||
|
0e221b28b8 | ||
|
1ee0977df4 | ||
|
24d578a4ba | ||
|
ce1a4499cc | ||
|
7d009f0915 | ||
|
b70b181c38 | ||
|
94602d23b3 | ||
|
41ac755c57 | ||
|
6d4a82427b | ||
|
0966dee55d | ||
|
b649356c5a | ||
|
2df3d909fa | ||
|
05a2ae6a31 | ||
|
58ffdfd1f4 | ||
|
addfd071bb | ||
|
2d27abc533 | ||
|
faf577086a | ||
|
ff1f9b94ef | ||
|
34e8a24c86 | ||
|
7567a10513 | ||
|
424e22b41a | ||
|
961eca5276 | ||
|
fbb6577625 | ||
|
6122010694 | ||
|
b40db42196 | ||
|
f732b87def | ||
|
f05a09da5a | ||
|
5aa6c99442 | ||
|
3c714fd9e0 | ||
|
1b7532a520 | ||
|
f092b94c96 | ||
|
8d28824489 | ||
|
4310d07ed1 | ||
|
7bd31f8ff0 | ||
|
1a0ab3a4e2 | ||
|
cacf69d5f6 | ||
|
46f50a10ea | ||
|
68038c4693 | ||
|
1036e204d0 | ||
|
fddbbc1732 | ||
|
3c1723fc54 | ||
|
c3418cc7b8 | ||
|
cc00c5a6f1 | ||
|
e6bb14f535 | ||
|
b18d60372c | ||
|
7ceccdeaa6 | ||
|
d1c99f7e15 | ||
|
bfc665d76e | ||
|
42d27af20f | ||
|
25614e3e06 | ||
|
3decac58fc | ||
|
f278e7e312 | ||
|
491a943c63 | ||
|
c47fc6f9fe | ||
|
7b259afdb5 | ||
|
33ddcaad5e | ||
|
4d5dbedeab | ||
|
c8fde17b6a | ||
|
3781495d29 | ||
|
8960ce9416 | ||
|
05b734ee0d | ||
|
f2dce91098 | ||
|
4af0954ae9 | ||
|
8f60929f85 | ||
|
7d401115a0 | ||
|
0aecfff133 | ||
|
2e98a4e2cb | ||
|
21735544f5 | ||
|
651d779226 | ||
|
5108f699b7 | ||
|
c35d35a3c3 | ||
|
c2fa2e8848 | ||
|
b25c0787c0 | ||
|
84de22f80b | ||
|
435d07eaf9 | ||
|
5ef17fddbb | ||
|
f699208e30 | ||
|
8f5efdf74c | ||
|
45663189a9 | ||
|
61d2797971 | ||
|
afd5700cca | ||
|
569f2ccebf | ||
|
a83e401100 | ||
|
0a63c74849 | ||
|
a58b4870d7 | ||
|
7bf1d368a8 | ||
|
ae7bc6fc6c | ||
|
9093ed82dc | ||
|
efb659f0ac | ||
|
ae51ecc659 | ||
|
da1c9e4400 | ||
|
16275db125 | ||
|
42ce691f57 | ||
|
58aa2b4f88 | ||
|
c3b273cec0 | ||
|
a982d60ed7 | ||
|
1076fbf824 | ||
|
d16e473b91 | ||
|
ae6b60cc60 | ||
|
1881986cca | ||
|
adf91d053d | ||
|
d3be9af9b6 | ||
|
4104636456 | ||
|
c6dc360dc1 | ||
|
f04266f738 | ||
|
7e0faa297b | ||
|
9389030835 | ||
|
7697f2f4b1 | ||
|
87baf9749d | ||
|
a8b7ebef09 | ||
|
ac661dfd63 | ||
|
ed364a4857 | ||
|
9a25c4d28a | ||
|
19e40bd32e | ||
|
b7a4f22a13 | ||
|
77e04d56de | ||
|
64a09dd991 | ||
|
126475e7d2 | ||
|
0e12c57ff0 | ||
|
6eb973235a | ||
|
904037d9be | ||
|
de8236491f | ||
|
af0d668951 | ||
|
072d7cb744 | ||
|
f5c46ce018 | ||
|
de09018198 | ||
|
46e568c55e | ||
|
1870c1c060 | ||
|
c5cbc3d33b | ||
|
fdfde95dec | ||
|
d105960444 | ||
|
3aae5bae58 | ||
|
9031029d2c | ||
|
d478e050ba | ||
|
06b2b9b01f | ||
|
b3fa4f6e7e | ||
|
75e68e3e4d | ||
|
83ddbcef4c | ||
|
1b796b80dd | ||
|
9f06cfe66b | ||
|
a37781475b | ||
|
832c83247a | ||
|
69e82ca60c | ||
|
8086a04fb3 | ||
|
3367abdce3 | ||
|
f462e595ed | ||
|
40fcc466a9 | ||
|
69220a2e49 | ||
|
b707a8b45e | ||
|
c9fb8ac936 | ||
|
3925feb2b6 | ||
|
41b4a5f027 | ||
|
faa309556f | ||
|
da5cb34416 | ||
|
4587af2eb4 | ||
|
73fd1b2c2a | ||
|
a1e5962262 | ||
|
e57f746dc9 | ||
|
9a51c7b5fb | ||
|
b3395ef26e | ||
|
a48344bb03 | ||
|
9297308f8a | ||
|
c3fdc8c08c | ||
|
4ae68b63e9 | ||
|
2db9bd4b82 | ||
|
e202512621 | ||
|
2513da2136 | ||
|
640becc436 | ||
|
ca420a0e0d | ||
|
b798b1e098 | ||
|
ac1904661a | ||
|
cfc6090405 | ||
|
12a85c6fb1 | ||
|
0959095a39 | ||
|
9ad9393d44 | ||
|
cda7282422 | ||
|
226733c653 | ||
|
b06efc401e | ||
|
2500771689 | ||
|
d2aa3b6bb0 | ||
|
00df117c7c | ||
|
69faa63c5b | ||
|
b7474ae138 | ||
|
b426bf39d7 | ||
|
6780b7452c | ||
|
27277b11b4 | ||
|
cb5029f826 | ||
|
5d45d89269 | ||
|
eb9ddc81cf | ||
|
f5891d5ae3 | ||
|
3b2ad1f6f4 | ||
|
fa0bf96eb2 | ||
|
29827f0426 | ||
|
8efe7adf0e | ||
|
b747a8787c | ||
|
1a75141fc4 | ||
|
2f82eb4f09 | ||
|
92a56c26bc | ||
|
4f9aeda8ec | ||
|
ad894c79cf | ||
|
5f33401d41 | ||
|
f4d39d224b | ||
|
bfd08bb33f | ||
|
f15f669853 | ||
|
f6bade32bb | ||
|
ddf9bc7272 | ||
|
f79a0714b4 | ||
|
c04958e2a4 | ||
|
692576a5b1 | ||
|
eb4620b1ec | ||
|
9f9583eb55 | ||
|
08ba068791 | ||
|
1839f7e8c0 | ||
|
80ed45df63 | ||
|
eef42d2dea | ||
|
d630fbb1e4 | ||
|
acfb495411 | ||
|
953c4a75c8 | ||
|
f24dee33c2 | ||
|
856780f88a | ||
|
dbdf17c661 | ||
|
a3bb5fb4b0 | ||
|
0eaea3c66f | ||
|
ebcbe2dde6 | ||
|
fda8126a43 | ||
|
8796ce5b20 | ||
|
b8503bfbd5 | ||
|
7329cb4428 | ||
|
e84a16da88 | ||
|
1a5d0eddbe | ||
|
5fe2f53c7b | ||
|
d7fb01908c | ||
|
1449166d44 | ||
|
55a2cfcc37 | ||
|
36600dce2c | ||
|
153dcfab94 | ||
|
ad824b4de1 | ||
|
597d88277b | ||
|
9590b5be40 | ||
|
cf9b45cd75 | ||
|
1ee9d2d222 | ||
|
310204a89d | ||
|
f33c597f34 | ||
|
42a7e298c0 | ||
|
efca8e0ad4 | ||
|
1ac30b51b1 | ||
|
2934016586 | ||
|
e484bf4578 | ||
|
b442483dc3 | ||
|
727a709aff | ||
|
bce380d871 | ||
|
c57410b820 | ||
|
815b2f1d76 | ||
|
4e8f247a0d | ||
|
0bf765e6ba | ||
|
24fbf94946 | ||
|
d392f60c09 | ||
|
dff2b4b7d1 | ||
|
9cbaf7e0fd | ||
|
db727092c5 | ||
|
8e6c50e7cc | ||
|
db0500fb2d |
5
.devcontainer/devcontainer.json
Normal file
5
.devcontainer/devcontainer.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"image": "ghcr.io/fairrootgroup/fairmq-dev/fedora-38:latest",
|
||||||
|
"features": {
|
||||||
|
}
|
||||||
|
}
|
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "github-actions"
|
||||||
|
directory: "/"
|
||||||
|
target-branch: "dev"
|
||||||
|
schedule:
|
||||||
|
interval: "monthly"
|
||||||
|
- package-ecosystem: "gitsubmodule"
|
||||||
|
directory: "/"
|
||||||
|
target-branch: "dev"
|
||||||
|
schedule:
|
||||||
|
interval: "monthly"
|
29
.github/workflows/check_metadata.yaml
vendored
Normal file
29
.github/workflows/check_metadata.yaml
vendored
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
# SPDX-FileCopyrightText: 2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH, Darmstadt, Germany
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
name: Check AUTHORS and CONTRIBUTORS in metadata
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- AUTHORS
|
||||||
|
- CONTRIBUTORS
|
||||||
|
- codemeta.json
|
||||||
|
- .zenodo.json
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- AUTHORS
|
||||||
|
- CONTRIBUTORS
|
||||||
|
- codemeta.json
|
||||||
|
- .zenodo.json
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: Try updating metadata
|
||||||
|
run: python meta_update.py
|
||||||
|
- name: Check for Updates
|
||||||
|
run: git diff --exit-code
|
21
.github/workflows/codemeta_validate.yaml
vendored
Normal file
21
.github/workflows/codemeta_validate.yaml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
name: validate codemeta
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- codemeta.json
|
||||||
|
- .github/workflows/codemeta_validate.yaml
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- codemeta.json
|
||||||
|
- .github/workflows/codemeta_validate.yaml
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: gitlab-registry.in2p3.fr/escape2020/wp3/eossr:v1.0
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- name: validate codemeta
|
||||||
|
run: eossr-metadata-validator codemeta.json
|
16
.github/workflows/fair-software.yml
vendored
Normal file
16
.github/workflows/fair-software.yml
vendored
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
name: fair-software
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
verify:
|
||||||
|
name: "fair-software"
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.repository == 'FairRootGroup/FairMQ'
|
||||||
|
steps:
|
||||||
|
- uses: fair-software/howfairis-github-action@0.2.1
|
||||||
|
name: Measure compliance with fair-software.eu recommendations
|
||||||
|
env:
|
||||||
|
PYCHARM_HOSTED: "Trick colorama into displaying colored output"
|
||||||
|
with:
|
||||||
|
MY_REPO_URL: "https://github.com/${{ github.repository }}"
|
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,5 +1,8 @@
|
||||||
build
|
build
|
||||||
|
install
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
.vscode
|
.vscode
|
||||||
|
/compile_commands.json
|
||||||
|
.cache
|
||||||
|
.spack-env
|
||||||
|
spack.lock
|
||||||
|
|
88
.zenodo.json
Normal file
88
.zenodo.json
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
{
|
||||||
|
"creators": [
|
||||||
|
{
|
||||||
|
"orcid": "0000-0002-8071-4497",
|
||||||
|
"name": "Al-Turany, Mohammad"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"orcid": "0000-0003-3787-1910",
|
||||||
|
"name": "Klein, Dennis"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Kollegger, Thorsten"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"orcid": "0000-0002-6249-155X",
|
||||||
|
"name": "Rybalchenko, Alexey"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Winckler, Nicolas"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"contributors": [
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Aphecetche, Laurent"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Binet, Sebastien"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Eulisse, Giulio"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Karabowicz, Radoslaw"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Kretz, Matthias"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Krzewicki, Mikolaj"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Lebedev, Andrey"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Mrnjavac, Teo"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Neskovic, Gvozden"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Richter, Matthias"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"orcid": "0000-0002-5321-8404",
|
||||||
|
"name": "Tacke, Christian"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Uhlig, Florian"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Other",
|
||||||
|
"name": "Wenzel, Sandro"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "<p>C++ Message Queuing Library and Framework</p>",
|
||||||
|
"related_identifiers": [
|
||||||
|
{
|
||||||
|
"identifier": "https://github.com/FairRootGroup/FairMQ/",
|
||||||
|
"relation": "isSupplementTo",
|
||||||
|
"resource_type": "software",
|
||||||
|
"scheme": "url"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"title": "FairMQ",
|
||||||
|
"license": "LGPL-3.0-only"
|
||||||
|
}
|
6
AUTHORS
6
AUTHORS
|
@ -1,5 +1,5 @@
|
||||||
Al-Turany, Mohammad
|
Al-Turany, Mohammad [https://orcid.org/0000-0002-8071-4497]
|
||||||
Klein, Dennis
|
Klein, Dennis [https://orcid.org/0000-0003-3787-1910]
|
||||||
Kollegger, Thorsten
|
Kollegger, Thorsten
|
||||||
Rybalchenko, Alexey
|
Rybalchenko, Alexey [https://orcid.org/0000-0002-6249-155X]
|
||||||
Winckler, Nicolas
|
Winckler, Nicolas
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2018-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2018-2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
|
@ -8,8 +8,7 @@
|
||||||
|
|
||||||
|
|
||||||
# Project ######################################################################
|
# Project ######################################################################
|
||||||
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.15...3.30 FATAL_ERROR)
|
||||||
cmake_policy(VERSION 3.15...3.20)
|
|
||||||
|
|
||||||
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
||||||
include(GitHelper)
|
include(GitHelper)
|
||||||
|
@ -27,18 +26,10 @@ fairmq_build_option(BUILD_FAIRMQ "Build FairMQ library and devices."
|
||||||
DEFAULT ON)
|
DEFAULT ON)
|
||||||
fairmq_build_option(BUILD_TESTING "Build tests."
|
fairmq_build_option(BUILD_TESTING "Build tests."
|
||||||
DEFAULT OFF REQUIRES "BUILD_FAIRMQ")
|
DEFAULT OFF REQUIRES "BUILD_FAIRMQ")
|
||||||
fairmq_build_option(BUILD_OFI_TRANSPORT "Build experimental OFI transport."
|
|
||||||
DEFAULT OFF REQUIRES "BUILD_FAIRMQ")
|
|
||||||
fairmq_build_option(BUILD_SDK_COMMANDS "Build the FairMQ SDK commands."
|
|
||||||
DEFAULT OFF)
|
|
||||||
fairmq_build_option(BUILD_DDS_PLUGIN "Build DDS plugin."
|
|
||||||
DEFAULT OFF REQUIRES "BUILD_FAIRMQ;BUILD_SDK_COMMANDS")
|
|
||||||
fairmq_build_option(BUILD_PMIX_PLUGIN "Build PMIx plugin."
|
|
||||||
DEFAULT OFF REQUIRES "BUILD_FAIRMQ;BUILD_SDK_COMMANDS")
|
|
||||||
fairmq_build_option(BUILD_EXAMPLES "Build FairMQ examples."
|
fairmq_build_option(BUILD_EXAMPLES "Build FairMQ examples."
|
||||||
DEFAULT ON REQUIRES "BUILD_FAIRMQ")
|
DEFAULT ON REQUIRES "BUILD_FAIRMQ")
|
||||||
fairmq_build_option(BUILD_SDK "Build the FairMQ controller SDK."
|
fairmq_build_option(BUILD_TIDY_TOOL "Build the fairmq-tidy tool."
|
||||||
DEFAULT OFF REQUIRES "BUILD_DDS_PLUGIN;BUILD_SDK_COMMANDS")
|
DEFAULT OFF)
|
||||||
fairmq_build_option(BUILD_DOCS "Build FairMQ documentation."
|
fairmq_build_option(BUILD_DOCS "Build FairMQ documentation."
|
||||||
DEFAULT OFF)
|
DEFAULT OFF)
|
||||||
fairmq_build_option(USE_EXTERNAL_GTEST "Do not use bundled GTest. Not recommended."
|
fairmq_build_option(USE_EXTERNAL_GTEST "Do not use bundled GTest. Not recommended."
|
||||||
|
@ -55,7 +46,7 @@ include(FairMQDependencies)
|
||||||
|
|
||||||
|
|
||||||
# Targets ######################################################################
|
# Targets ######################################################################
|
||||||
if(BUILD_FAIRMQ OR BUILD_SDK)
|
if(BUILD_FAIRMQ)
|
||||||
add_subdirectory(fairmq)
|
add_subdirectory(fairmq)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -76,6 +67,10 @@ if(BUILD_DOCS)
|
||||||
doxygen_add_docs(doxygen README.md fairmq)
|
doxygen_add_docs(doxygen README.md fairmq)
|
||||||
add_custom_target(docs ALL DEPENDS doxygen)
|
add_custom_target(docs ALL DEPENDS doxygen)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_TIDY_TOOL)
|
||||||
|
add_subdirectory(fairmq/tidy)
|
||||||
|
endif()
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,26 +81,14 @@ endif()
|
||||||
if(BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS tests)
|
list(APPEND PROJECT_PACKAGE_COMPONENTS tests)
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_DDS_PLUGIN)
|
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS dds_plugin)
|
|
||||||
endif()
|
|
||||||
if(BUILD_PMIX_PLUGIN)
|
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS pmix_plugin)
|
|
||||||
endif()
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS ofi_transport)
|
|
||||||
endif()
|
|
||||||
if(BUILD_EXAMPLES)
|
if(BUILD_EXAMPLES)
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS examples)
|
list(APPEND PROJECT_PACKAGE_COMPONENTS examples)
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_DOCS)
|
if(BUILD_DOCS)
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS docs)
|
list(APPEND PROJECT_PACKAGE_COMPONENTS docs)
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_SDK)
|
if(BUILD_TIDY_TOOL)
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS sdk)
|
list(APPEND PROJECT_PACKAGE_COMPONENTS tidy_tool)
|
||||||
endif()
|
|
||||||
if(BUILD_SDK_COMMANDS)
|
|
||||||
list(APPEND PROJECT_PACKAGE_COMPONENTS sdk_commands)
|
|
||||||
endif()
|
endif()
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
@ -116,16 +99,16 @@ if(BUILD_FAIRMQ)
|
||||||
DESTINATION ${PROJECT_INSTALL_CMAKEMODDIR}
|
DESTINATION ${PROJECT_INSTALL_CMAKEMODDIR}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_SDK OR BUILD_DDS_PLUGIN)
|
|
||||||
install(FILES cmake/Findasio.cmake
|
|
||||||
DESTINATION ${PROJECT_INSTALL_CMAKEMODDIR}
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
if(BUILD_DOCS)
|
if(BUILD_DOCS)
|
||||||
install(DIRECTORY ${CMAKE_BINARY_DIR}/doxygen/html
|
install(DIRECTORY ${CMAKE_BINARY_DIR}/doxygen/html
|
||||||
DESTINATION ${PROJECT_INSTALL_DATADIR}/docs
|
DESTINATION ${PROJECT_INSTALL_DATADIR}/docs
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
if(BUILD_TIDY_TOOL)
|
||||||
|
install(FILES cmake/FairMQTidy.cmake
|
||||||
|
DESTINATION ${PROJECT_INSTALL_CMAKEMODDIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(FairMQPackage)
|
include(FairMQPackage)
|
||||||
install_cmake_package()
|
install_cmake_package()
|
||||||
|
@ -143,5 +126,6 @@ fairmq_summary_components()
|
||||||
fairmq_summary_static_analysis()
|
fairmq_summary_static_analysis()
|
||||||
fairmq_summary_install_prefix()
|
fairmq_summary_install_prefix()
|
||||||
fairmq_summary_debug_mode()
|
fairmq_summary_debug_mode()
|
||||||
|
fairmq_summary_compile_definitions()
|
||||||
message(STATUS " ")
|
message(STATUS " ")
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
|
@ -3,11 +3,11 @@ Binet, Sebastien
|
||||||
Eulisse, Giulio
|
Eulisse, Giulio
|
||||||
Karabowicz, Radoslaw
|
Karabowicz, Radoslaw
|
||||||
Kretz, Matthias <kretz@kde.org>
|
Kretz, Matthias <kretz@kde.org>
|
||||||
Krzewicki, Mikolaj
|
Krzewicki, Mikolaj
|
||||||
Lebedev, Andrey
|
Lebedev, Andrey
|
||||||
Mrnjavac, Teo <teo.m@cern.ch>
|
Mrnjavac, Teo <teo.m@cern.ch>
|
||||||
Neskovic, Gvozden
|
Neskovic, Gvozden
|
||||||
Richter, Matthias
|
Richter, Matthias
|
||||||
Tacke, Christian
|
Tacke, Christian [https://orcid.org/0000-0002-5321-8404]
|
||||||
Uhlig, Florian
|
Uhlig, Florian
|
||||||
Wenzel, Sandro
|
Wenzel, Sandro
|
||||||
|
|
10
COPYRIGHT
10
COPYRIGHT
|
@ -4,19 +4,19 @@ Upstream-Contact: Mohammad Al-Turany <m.al-turany@gsi.de>
|
||||||
Source: https://github.com/FairRootGroup/FairMQ
|
Source: https://github.com/FairRootGroup/FairMQ
|
||||||
|
|
||||||
Files: *
|
Files: *
|
||||||
Copyright: 2012-2021, GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
|
Copyright: 2012-2022, GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
|
||||||
Copyright: 2012-2021, [see AUTHORS file]
|
Copyright: 2012-2022, [see AUTHORS file]
|
||||||
Copyright: 2012-2021, [see CONTRIBUTORS file]
|
Copyright: 2012-2022, [see CONTRIBUTORS file]
|
||||||
Comment: The copyright of individual contributors is documented in the
|
Comment: The copyright of individual contributors is documented in the
|
||||||
Git history.
|
Git history.
|
||||||
License: LGPL-3.0-only
|
License: LGPL-3.0-only
|
||||||
|
|
||||||
Files: extern/googletest
|
Files: extern/googletest
|
||||||
Copyright: 2008-2021, Google Inc.
|
Copyright: 2008-2022, Google Inc.
|
||||||
License: GOOGLE
|
License: GOOGLE
|
||||||
|
|
||||||
Files: extern/asio
|
Files: extern/asio
|
||||||
Copyright: 2003-2021, Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
Copyright: 2003-2022, Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||||
License: BSL-1.0
|
License: BSL-1.0
|
||||||
|
|
||||||
Files: extern/PicoSHA2
|
Files: extern/PicoSHA2
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2021-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
|
@ -42,15 +42,6 @@ endif()
|
||||||
ctest_start(Continuous)
|
ctest_start(Continuous)
|
||||||
|
|
||||||
list(APPEND options "-DDISABLE_COLOR=ON" "-DBUILD_EXAMPLES=ON" "-DBUILD_TESTING=ON")
|
list(APPEND options "-DDISABLE_COLOR=ON" "-DBUILD_EXAMPLES=ON" "-DBUILD_TESTING=ON")
|
||||||
if(HAS_ASIO AND HAS_DDS)
|
|
||||||
list(APPEND options "-DBUILD_SDK_COMMANDS=ON" "-DBUILD_SDK=ON" "-DBUILD_DDS_PLUGIN=ON")
|
|
||||||
endif()
|
|
||||||
if(HAS_PMIX)
|
|
||||||
list(APPEND options "-DBUILD_SDK_COMMANDS=ON" "-DBUILD_PMIX_PLUGIN=ON")
|
|
||||||
endif()
|
|
||||||
if(HAS_ASIO AND HAS_ASIOFI)
|
|
||||||
list(APPEND options "-DBUILD_OFI_TRANSPORT=ON")
|
|
||||||
endif()
|
|
||||||
if(RUN_STATIC_ANALYSIS)
|
if(RUN_STATIC_ANALYSIS)
|
||||||
list(APPEND options "-DRUN_STATIC_ANALYSIS=ON")
|
list(APPEND options "-DRUN_STATIC_ANALYSIS=ON")
|
||||||
endif()
|
endif()
|
||||||
|
@ -72,6 +63,9 @@ endif()
|
||||||
if(ENABLE_SANITIZER_THREAD)
|
if(ENABLE_SANITIZER_THREAD)
|
||||||
list(APPEND options "-DENABLE_SANITIZER_THREAD=ON")
|
list(APPEND options "-DENABLE_SANITIZER_THREAD=ON")
|
||||||
endif()
|
endif()
|
||||||
|
if(CMAKE_CXX_COMPILER)
|
||||||
|
list(APPEND options "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
||||||
|
endif()
|
||||||
if(CMAKE_CXX_FLAGS)
|
if(CMAKE_CXX_FLAGS)
|
||||||
list(APPEND options "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
|
list(APPEND options "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -87,7 +81,7 @@ ctest_submit()
|
||||||
|
|
||||||
if(NOT RUN_STATIC_ANALYSIS)
|
if(NOT RUN_STATIC_ANALYSIS)
|
||||||
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}"
|
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}"
|
||||||
PARALLEL_LEVEL 1
|
PARALLEL_LEVEL ${NCPUS}
|
||||||
SCHEDULE_RANDOM ON
|
SCHEDULE_RANDOM ON
|
||||||
RETURN_VALUE _ctest_test_ret_val)
|
RETURN_VALUE _ctest_test_ret_val)
|
||||||
|
|
||||||
|
|
48
Jenkinsfile
vendored
48
Jenkinsfile
vendored
|
@ -4,20 +4,21 @@ def jobMatrix(String type, List specs) {
|
||||||
def nodes = [:]
|
def nodes = [:]
|
||||||
for (spec in specs) {
|
for (spec in specs) {
|
||||||
def job = ""
|
def job = ""
|
||||||
def selector = ""
|
def selector = "slurm"
|
||||||
def os = ""
|
def os = ""
|
||||||
def ver = ""
|
def ver = ""
|
||||||
|
|
||||||
if (type == 'build') {
|
if (type == 'build') {
|
||||||
job = "${spec.os}-${spec.ver}-${spec.arch}-${spec.compiler}"
|
job = "${spec.os}-${spec.ver}-${spec.arch}-${spec.compiler}"
|
||||||
selector = "${spec.os}-${spec.ver}-${spec.arch}"
|
if (spec.os =~ /^macos/) {
|
||||||
|
selector = "${spec.os}-${spec.ver}-${spec.arch}"
|
||||||
|
}
|
||||||
os = spec.os
|
os = spec.os
|
||||||
ver = spec.ver
|
ver = spec.ver
|
||||||
} else { // == 'check'
|
} else { // == 'check'
|
||||||
job = "${spec.name}"
|
job = "${spec.name}"
|
||||||
selector = 'fedora-34-x86_64'
|
|
||||||
os = 'fedora'
|
os = 'fedora'
|
||||||
ver = '34'
|
ver = '36'
|
||||||
}
|
}
|
||||||
|
|
||||||
def label = "${job}"
|
def label = "${job}"
|
||||||
|
@ -36,14 +37,14 @@ def jobMatrix(String type, List specs) {
|
||||||
sh "echo \"export LABEL=\\\"\${JOB_BASE_NAME} ${label}\\\"\" >> ${jobscript}"
|
sh "echo \"export LABEL=\\\"\${JOB_BASE_NAME} ${label}\\\"\" >> ${jobscript}"
|
||||||
if (selector =~ /^macos/) {
|
if (selector =~ /^macos/) {
|
||||||
sh """\
|
sh """\
|
||||||
echo \"export DDS_ROOT=\\\"\\\$(brew --prefix dds)\\\"\" >> ${jobscript}
|
|
||||||
echo \"export PATH=\\\"\\\$(brew --prefix dds)/bin:\\\$PATH\\\"\" >> ${jobscript}
|
|
||||||
echo \"${ctestcmd}\" >> ${jobscript}
|
echo \"${ctestcmd}\" >> ${jobscript}
|
||||||
"""
|
"""
|
||||||
sh "cat ${jobscript}"
|
sh "cat ${jobscript}"
|
||||||
sh "bash ${jobscript}"
|
sh "bash ${jobscript}"
|
||||||
} else {
|
} else { // selector == "slurm"
|
||||||
def containercmd = "singularity exec --net --ipc --uts --pid -B/shared ${env.SINGULARITY_CONTAINER_ROOT}/fairmq/${os}.${ver}.sif bash -l -c \\\"${ctestcmd} ${extra}\\\""
|
def imageurl = "oras://ghcr.io/fairrootgroup/fairmq-dev/${os}-${ver}-sif:latest"
|
||||||
|
def execopts = "--ipc --uts --pid -B/shared"
|
||||||
|
def containercmd = "singularity exec ${execopts} ${imageurl} bash -l -c \\\"${ctestcmd} ${extra}\\\""
|
||||||
sh """\
|
sh """\
|
||||||
echo \"echo \\\"*** Job started at .......: \\\$(date -R)\\\"\" >> ${jobscript}
|
echo \"echo \\\"*** Job started at .......: \\\$(date -R)\\\"\" >> ${jobscript}
|
||||||
echo \"echo \\\"*** Job ID ...............: \\\${SLURM_JOB_ID}\\\"\" >> ${jobscript}
|
echo \"echo \\\"*** Job ID ...............: \\\${SLURM_JOB_ID}\\\"\" >> ${jobscript}
|
||||||
|
@ -67,12 +68,6 @@ def jobMatrix(String type, List specs) {
|
||||||
deleteDir()
|
deleteDir()
|
||||||
githubNotify(context: "${label}", description: 'Success', status: 'SUCCESS')
|
githubNotify(context: "${label}", description: 'Success', status: 'SUCCESS')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
def tarball = "${type}_${job}_dds_logs.tar.gz"
|
|
||||||
if (fileExists("build/test/.DDS")) {
|
|
||||||
sh "tar czvf ${tarball} -C \${WORKSPACE}/build/test .DDS/"
|
|
||||||
archiveArtifacts tarball
|
|
||||||
}
|
|
||||||
|
|
||||||
deleteDir()
|
deleteDir()
|
||||||
githubNotify(context: "${label}", description: 'Error', status: 'ERROR')
|
githubNotify(context: "${label}", description: 'Error', status: 'ERROR')
|
||||||
throw e
|
throw e
|
||||||
|
@ -89,23 +84,30 @@ pipeline{
|
||||||
stage("CI") {
|
stage("CI") {
|
||||||
steps{
|
steps{
|
||||||
script {
|
script {
|
||||||
def all = '-DHAS_ASIO=ON -DHAS_DDS=ON -DHAS_PMIX=ON'
|
|
||||||
|
|
||||||
def builds = jobMatrix('build', [
|
def builds = jobMatrix('build', [
|
||||||
[os: 'ubuntu', ver: '20.04', arch: 'x86_64', compiler: 'gcc-9', extra: all],
|
[os: 'ubuntu', ver: '20.04', arch: 'x86_64', compiler: 'gcc-9'],
|
||||||
[os: 'fedora', ver: '32', arch: 'x86_64', compiler: 'gcc-10', extra: all],
|
[os: 'ubuntu', ver: '22.04', arch: 'x86_64', compiler: 'gcc-11'],
|
||||||
[os: 'fedora', ver: '33', arch: 'x86_64', compiler: 'gcc-10', extra: all],
|
[os: 'ubuntu', ver: '24.04', arch: 'x86_64', compiler: 'gcc-13'],
|
||||||
[os: 'fedora', ver: '34', arch: 'x86_64', compiler: 'gcc-11', extra: all],
|
[os: 'fedora', ver: '33', arch: 'x86_64', compiler: 'gcc-10'],
|
||||||
[os: 'macos', ver: '11', arch: 'x86_64', compiler: 'apple-clang-12',
|
[os: 'fedora', ver: '34', arch: 'x86_64', compiler: 'gcc-11'],
|
||||||
extra: '-DHAS_ASIO=ON -DHAS_DDS=ON'],
|
[os: 'fedora', ver: '35', arch: 'x86_64', compiler: 'gcc-11'],
|
||||||
|
[os: 'fedora', ver: '36', arch: 'x86_64', compiler: 'gcc-12'],
|
||||||
|
[os: 'fedora', ver: '37', arch: 'x86_64', compiler: 'gcc-12'],
|
||||||
|
[os: 'fedora', ver: '38', arch: 'x86_64', compiler: 'gcc-13'],
|
||||||
|
[os: 'fedora', ver: '39', arch: 'x86_64', compiler: 'gcc-13'],
|
||||||
|
[os: 'fedora', ver: '40', arch: 'x86_64', compiler: 'gcc-14'],
|
||||||
|
[os: 'macos', ver: '14', arch: 'x86_64', compiler: 'apple-clang-16'],
|
||||||
|
[os: 'macos', ver: '15', arch: 'x86_64', compiler: 'apple-clang-16'],
|
||||||
|
[os: 'macos', ver: '15', arch: 'arm64', compiler: 'apple-clang-16'],
|
||||||
])
|
])
|
||||||
|
|
||||||
def all_debug = "${all} -DCMAKE_BUILD_TYPE=Debug"
|
def all_debug = "-DCMAKE_BUILD_TYPE=Debug"
|
||||||
|
|
||||||
def checks = jobMatrix('check', [
|
def checks = jobMatrix('check', [
|
||||||
[name: 'static-analyzers', extra: "${all_debug} -DRUN_STATIC_ANALYSIS=ON"],
|
[name: 'static-analyzers', extra: "${all_debug} -DRUN_STATIC_ANALYSIS=ON"],
|
||||||
[name: '{address,leak,ub}-sanitizers',
|
[name: '{address,leak,ub}-sanitizers',
|
||||||
extra: "${all_debug} -DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_LEAK=ON -DENABLE_SANITIZER_UNDEFINED_BEHAVIOUR=ON -DCMAKE_CXX_FLAGS='-O1 -fno-omit-frame-pointer'"],
|
extra: "${all_debug} -DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_LEAK=ON -DENABLE_SANITIZER_UNDEFINED_BEHAVIOUR=ON -DCMAKE_CXX_FLAGS='-O1 -fno-omit-frame-pointer'"],
|
||||||
|
[name: 'thread-sanitizer', extra: "${all_debug} -DENABLE_SANITIZER_THREAD=ON -DCMAKE_CXX_COMPILER=clang++"],
|
||||||
])
|
])
|
||||||
|
|
||||||
parallel(builds + checks)
|
parallel(builds + checks)
|
||||||
|
|
83
README.md
83
README.md
|
@ -1,12 +1,15 @@
|
||||||
<!-- {#mainpage} -->
|
<!-- {#mainpage} -->
|
||||||
# FairMQ [](COPYRIGHT) [](https://alfa-ci.gsi.de/blue/organizations/jenkins/FairRootGroup%2FFairMQ/branches) [](https://scan.coverity.com/projects/fairrootgroup-fairmq)
|
# FairMQ
|
||||||
|
|
||||||
|
[](COPYRIGHT)
|
||||||
|
[](https://doi.org/10.5281/zenodo.1689985)
|
||||||
|
[](https://bestpractices.coreinfrastructure.org/projects/6915)
|
||||||
|
[](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
|
||||||
|
|
||||||
| Release | Version | Docs |
|
Docs: [Book](https://github.com/FairRootGroup/FairMQ/blob/dev/README.md#documentation)
|
||||||
| :---: | :--- | :--- |
|
|
||||||
| `stable` | [](https://github.com/FairRootGroup/FairMQ/releases/latest) | [API](https://fairrootgroup.github.io/FairMQ/latest), [Book](https://github.com/FairRootGroup/FairMQ/blob/master/README.md#documentation) |
|
|
||||||
| `testing` | [](https://github.com/FairRootGroup/FairMQ/tags) | [Book](https://github.com/FairRootGroup/FairMQ/blob/dev/README.md#documentation) |
|
|
||||||
|
|
||||||
Find all FairMQ releases [here](https://github.com/FairRootGroup/FairMQ/releases).
|
Find all FairMQ releases [here](https://github.com/FairRootGroup/FairMQ/releases).
|
||||||
|
|
||||||
|
@ -21,14 +24,17 @@ FairMQ is designed to help implementing large-scale data processing workflows ne
|
||||||
The core of FairMQ provides an abstract asynchronous message passing API with scalability protocols
|
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).
|
inspired by [ZeroMQ](https://github.com/zeromq/libzmq) (e.g. PUSH/PULL, PUB/SUB).
|
||||||
FairMQ provides multiple implementations for its API (so-called "transports",
|
FairMQ provides multiple implementations for its API (so-called "transports",
|
||||||
e.g. `zeromq`, `shmem` and `ofi` (in development)) to cover a variety of use cases
|
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).
|
(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
|
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
|
are communicating through message passing. FairMQ does not only allow the user to use different transport
|
||||||
shapes the integration points for the user task. Devices also incorporate a plugin system for runtime configuration and control.
|
but also to mix them; i.e: A Device can communicate using different transport on different channels at the
|
||||||
Next to the provided devices and plugins (e.g. [DDS](https://github.com/FairRootGroup/DDS))
|
same time. Device execution is modelled as a simple state machine that shapes the integration points for
|
||||||
the user can extend FairMQ by developing his own plugins to integrate his devices with external
|
the user task. Devices also incorporate a plugin system for runtime configuration and control.
|
||||||
configuration and control services.
|
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.
|
||||||
|
|
||||||
FairMQ has been developed in the context of its mother project [FairRoot](https://github.com/FairRootGroup/FairRoot) -
|
FairMQ has been developed in the context of its mother project [FairRoot](https://github.com/FairRootGroup/FairRoot) -
|
||||||
a simulation, reconstruction and analysis framework.
|
a simulation, reconstruction and analysis framework.
|
||||||
|
@ -39,22 +45,42 @@ Recommended:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
git clone https://github.com/FairRootGroup/FairMQ fairmq_source
|
git clone https://github.com/FairRootGroup/FairMQ fairmq_source
|
||||||
cmake -S fairmq_source -B fairmq_build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=fairmq_install
|
cmake -S fairmq_source -B fairmq_build -GNinja -DCMAKE_BUILD_TYPE=Release [-DBUILD_TESTING=ON]
|
||||||
cmake --build fairmq_build
|
cmake --build fairmq_build
|
||||||
cmake --build fairmq_build --target test
|
[ctest --test-dir fairmq_build --output-on-failure --schedule-random -j<ncpus>] # needs -DBUILD_TESTING=ON
|
||||||
cmake --build fairmq_build --target install
|
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.
|
Please consult the [manpages of your CMake version](https://cmake.org/cmake/help/latest/manual/cmake.1.html) for more options.
|
||||||
|
|
||||||
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=...`. `{DEPENDENCY}` can be `GTEST`, `BOOST`, `FAIRLOGGER`, `ZEROMQ`, `OFI`, `PMIX`, `ASIO`, `ASIOFI` or `DDS` (`*_ROOT` variables can also be environment variables).
|
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).
|
||||||
|
|
||||||
|
## Installation via Spack
|
||||||
|
|
||||||
|
Prerequisite: [Spack](https://spack.readthedocs.io/en/latest/getting_started.html)
|
||||||
|
|
||||||
|
```bash
|
||||||
|
spack info fairmq # inspect build options
|
||||||
|
spack install fairmq # build latest packaged version with default options
|
||||||
|
```
|
||||||
|
|
||||||
|
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
|
||||||
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
FairMQ ships as a CMake package, so in your `CMakeLists.txt` you can discover it like this:
|
FairMQ ships as a CMake package, so in your `CMakeLists.txt` you can discover it like this:
|
||||||
|
|
||||||
```cmake
|
```cmake
|
||||||
find_package(FairCMakeModules 0.2 REQUIRED)
|
find_package(FairCMakeModules 1.0 REQUIRED)
|
||||||
include(FairFindPackage2)
|
include(FairFindPackage2)
|
||||||
find_package2(FairMQ)
|
find_package2(FairMQ)
|
||||||
find_package2_implicit_dependencies()
|
find_package2_implicit_dependencies()
|
||||||
|
@ -68,31 +94,19 @@ If FairMQ is not installed in system directories, you can hint the installation:
|
||||||
list(PREPEND CMAKE_PREFIX_PATH /path/to/fairmq_install)
|
list(PREPEND CMAKE_PREFIX_PATH /path/to/fairmq_install)
|
||||||
```
|
```
|
||||||
|
|
||||||
Optionally, you can require certain FairMQ package components and a minimum version:
|
|
||||||
|
|
||||||
```cmake
|
|
||||||
find_package(FairMQ 1.4.0 COMPONENTS dds_plugin)
|
|
||||||
```
|
|
||||||
|
|
||||||
When building FairMQ, CMake will print a summary table of all available package components.
|
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
* [asio](https://github.com/chriskohlhoff/asio) (optionally bundled)
|
|
||||||
* [asiofi](https://github.com/FairRootGroup/asiofi)
|
|
||||||
* [Boost](https://www.boost.org/)
|
* [Boost](https://www.boost.org/)
|
||||||
* [CMake](https://cmake.org/)
|
* [CMake](https://cmake.org/)
|
||||||
* [DDS](http://dds.gsi.de)
|
|
||||||
* [Doxygen](http://www.doxygen.org/)
|
* [Doxygen](http://www.doxygen.org/)
|
||||||
* [FairCMakeModules](https://github.com/FairRootGroup/FairCMakeModules) (optionally bundled)
|
* [FairCMakeModules](https://github.com/FairRootGroup/FairCMakeModules) (optionally bundled)
|
||||||
* [FairLogger](https://github.com/FairRootGroup/FairLogger)
|
* [FairLogger](https://github.com/FairRootGroup/FairLogger)
|
||||||
* [GTest](https://github.com/google/googletest) (optionally bundled)
|
* [GTest](https://github.com/google/googletest) (optionally bundled)
|
||||||
* [PMIx](https://pmix.org/)
|
|
||||||
* [ZeroMQ](http://zeromq.org/)
|
* [ZeroMQ](http://zeromq.org/)
|
||||||
|
|
||||||
Which dependencies are required depends on which components are built.
|
Which dependencies are required depends on which components are built.
|
||||||
|
|
||||||
Supported platforms: Linux and MacOS.
|
Supported platform is Linux. macOS is supported on a best-effort basis.
|
||||||
|
|
||||||
## CMake options
|
## CMake options
|
||||||
|
|
||||||
|
@ -101,10 +115,8 @@ On command line:
|
||||||
* `-DDISABLE_COLOR=ON` disables coloured console output.
|
* `-DDISABLE_COLOR=ON` disables coloured console output.
|
||||||
* `-DBUILD_TESTING=OFF` disables building of tests.
|
* `-DBUILD_TESTING=OFF` disables building of tests.
|
||||||
* `-DBUILD_EXAMPLES=OFF` disables building of examples.
|
* `-DBUILD_EXAMPLES=OFF` disables building of examples.
|
||||||
* `-DBUILD_OFI_TRANSPORT=ON` enables building of the experimental OFI transport.
|
|
||||||
* `-DBUILD_DDS_PLUGIN=ON` enables building of the DDS plugin.
|
|
||||||
* `-DBUILD_PMIX_PLUGIN=ON` enables building of the PMIx plugin.
|
|
||||||
* `-DBUILD_DOCS=ON` enables building of API docs.
|
* `-DBUILD_DOCS=ON` enables building of API docs.
|
||||||
|
* `-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
|
* 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:
|
After the `find_package(FairMQ)` call the following CMake variables are defined:
|
||||||
|
@ -147,6 +159,9 @@ After the `find_package(FairMQ)` call the following CMake variables are defined:
|
||||||
3. [Introspection](docs/Configuration.md#33-introspection)
|
3. [Introspection](docs/Configuration.md#33-introspection)
|
||||||
4. [Development](docs/Development.md#4-development)
|
4. [Development](docs/Development.md#4-development)
|
||||||
1. [Testing](docs/Development.md#41-testing)
|
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)
|
5. [Logging](docs/Logging.md#5-logging)
|
||||||
1. [Log severity](docs/Logging.md#51-log-severity)
|
1. [Log severity](docs/Logging.md#51-log-severity)
|
||||||
2. [Log verbosity](docs/Logging.md#52-log-verbosity)
|
2. [Log verbosity](docs/Logging.md#52-log-verbosity)
|
||||||
|
@ -158,6 +173,4 @@ After the `find_package(FairMQ)` call the following CMake variables are defined:
|
||||||
1. [Usage](docs/Plugins.md#71-usage)
|
1. [Usage](docs/Plugins.md#71-usage)
|
||||||
2. [Development](docs/Plugins.md#72-development)
|
2. [Development](docs/Plugins.md#72-development)
|
||||||
3. [Provided Plugins](docs/Plugins.md#73-provided-plugins)
|
3. [Provided Plugins](docs/Plugins.md#73-provided-plugins)
|
||||||
1. [DDS](docs/Plugins.md#731-dds)
|
1. [PMIx](docs/Plugins.md#731-pmix)
|
||||||
2. [PMIx](docs/Plugins.md#732-pmix)
|
|
||||||
8. [Controller SDK](docs/SDK.md)
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2018-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2018-2025 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
|
@ -12,46 +12,19 @@ include(FairCMakeModules)
|
||||||
include(FairFindPackage2)
|
include(FairFindPackage2)
|
||||||
include(FairMQBundlePackageHelper)
|
include(FairMQBundlePackageHelper)
|
||||||
|
|
||||||
if(BUILD_FAIRMQ OR BUILD_SDK)
|
if(BUILD_FAIRMQ)
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||||
find_package2(PUBLIC Threads REQUIRED)
|
find_package2(PUBLIC Threads REQUIRED)
|
||||||
set(Threads_PREFIX "<unknown system prefix>")
|
set(Threads_PREFIX "<system>")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
if(BUILD_FAIRMQ OR BUILD_TIDY_TOOL)
|
||||||
find_package2(PRIVATE asiofi REQUIRED VERSION 0.5)
|
|
||||||
find_package2(PRIVATE OFI REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_SDK_COMMANDS)
|
|
||||||
find_package2(PRIVATE Flatbuffers REQUIRED)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_DDS_PLUGIN OR BUILD_SDK)
|
|
||||||
find_package2(PRIVATE DDS REQUIRED VERSION 3.5.13.7)
|
|
||||||
set(DDS_Boost_COMPONENTS system log log_setup regex filesystem thread)
|
|
||||||
set(DDS_Boost_VERSION 1.67)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_PMIX_PLUGIN)
|
|
||||||
find_package2(PRIVATE PMIx REQUIRED VERSION 2.1.4)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_FAIRMQ OR BUILD_SDK)
|
|
||||||
find_package2(PUBLIC FairLogger REQUIRED VERSION 1.6.0)
|
find_package2(PUBLIC FairLogger REQUIRED VERSION 1.6.0)
|
||||||
find_package2(PUBLIC Boost REQUIRED VERSION 1.66
|
find_package2(PUBLIC Boost REQUIRED VERSION 1.66
|
||||||
COMPONENTS container program_options filesystem date_time regex
|
COMPONENTS container program_options filesystem date_time regex
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_OFI_TRANSPORT OR BUILD_SDK OR BUILD_DDS_PLUGIN)
|
|
||||||
set(__old ${CMAKE_FIND_PACKAGE_PREFER_CONFIG})
|
|
||||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
|
|
||||||
find_package2(PUBLIC asio REQUIRED VERSION 1.18)
|
|
||||||
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ${__old})
|
|
||||||
unset(__old)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_FAIRMQ)
|
if(BUILD_FAIRMQ)
|
||||||
find_package2(PRIVATE ZeroMQ REQUIRED VERSION 4.1.4)
|
find_package2(PRIVATE ZeroMQ REQUIRED VERSION 4.1.4)
|
||||||
if(NOT PicoSHA2_BUNDLED)
|
if(NOT PicoSHA2_BUNDLED)
|
||||||
|
@ -59,6 +32,7 @@ if(BUILD_FAIRMQ)
|
||||||
endif()
|
endif()
|
||||||
find_package2(BUNDLED PicoSHA2 REQUIRED)
|
find_package2(BUNDLED PicoSHA2 REQUIRED)
|
||||||
set(PicoSHA2_VERSION "1.0.0")
|
set(PicoSHA2_VERSION "1.0.0")
|
||||||
|
set(PicoSHA2_PREFIX "<bundled>")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
|
@ -67,7 +41,8 @@ if(BUILD_TESTING)
|
||||||
endif()
|
endif()
|
||||||
find_package2(BUNDLED GTest REQUIRED)
|
find_package2(BUNDLED GTest REQUIRED)
|
||||||
if(GTest_BUNDLED)
|
if(GTest_BUNDLED)
|
||||||
set(GTest_VERSION "Apr 28 2021 @f5e592d8")
|
set(GTest_VERSION "Dec 26 2024 @7d76a23")
|
||||||
|
set(GTest_PREFIX "<bundled>")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -77,6 +52,13 @@ if(BUILD_DOCS)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(BUILD_TIDY_TOOL)
|
||||||
|
find_package2(PRIVATE LLVM REQUIRED)
|
||||||
|
find_package2(PRIVATE Clang REQUIRED)
|
||||||
|
set(Clang_VERSION ${LLVM_VERSION})
|
||||||
|
find_package2(PRIVATE CLI11 REQUIRED)
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package2_implicit_dependencies() # Always call last after latest find_package2
|
find_package2_implicit_dependencies() # Always call last after latest find_package2
|
||||||
|
|
||||||
if(PROJECT_PACKAGE_DEPENDENCIES)
|
if(PROJECT_PACKAGE_DEPENDENCIES)
|
||||||
|
@ -88,12 +70,6 @@ if(PROJECT_PACKAGE_DEPENDENCIES)
|
||||||
if(NOT FairLogger_PREFIX AND FairLogger_ROOT)
|
if(NOT FairLogger_PREFIX AND FairLogger_ROOT)
|
||||||
set(FairLogger_PREFIX ${FairLogger_ROOT})
|
set(FairLogger_PREFIX ${FairLogger_ROOT})
|
||||||
endif()
|
endif()
|
||||||
elseif(${dep} STREQUAL asiofi)
|
|
||||||
if(NOT asiofi_PREFIX AND asiofi_ROOT)
|
|
||||||
set(asiofi_PREFIX ${asiofi_ROOT})
|
|
||||||
endif()
|
|
||||||
elseif(${dep} STREQUAL DDS)
|
|
||||||
set(DDS_PREFIX "${DDS_INSTALL_PREFIX}")
|
|
||||||
elseif(${dep} STREQUAL Boost)
|
elseif(${dep} STREQUAL Boost)
|
||||||
if(TARGET Boost::headers)
|
if(TARGET Boost::headers)
|
||||||
get_target_property(boost_include Boost::headers INTERFACE_INCLUDE_DIRECTORIES)
|
get_target_property(boost_include Boost::headers INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
@ -107,14 +83,6 @@ if(PROJECT_PACKAGE_DEPENDENCIES)
|
||||||
get_filename_component(Doxygen_PREFIX ${doxygen_bin} DIRECTORY)
|
get_filename_component(Doxygen_PREFIX ${doxygen_bin} DIRECTORY)
|
||||||
get_filename_component(Doxygen_PREFIX ${Doxygen_PREFIX}/.. ABSOLUTE)
|
get_filename_component(Doxygen_PREFIX ${Doxygen_PREFIX}/.. ABSOLUTE)
|
||||||
unset(doxygen_bin)
|
unset(doxygen_bin)
|
||||||
elseif(${dep} STREQUAL Flatbuffers)
|
|
||||||
if(TARGET flatbuffers::flatbuffers)
|
|
||||||
get_target_property(flatbuffers_include flatbuffers::flatbuffers INTERFACE_INCLUDE_DIRECTORIES)
|
|
||||||
else()
|
|
||||||
get_target_property(flatbuffers_include flatbuffers::flatbuffers_shared INTERFACE_INCLUDE_DIRECTORIES)
|
|
||||||
endif()
|
|
||||||
get_filename_component(Flatbuffers_PREFIX ${flatbuffers_include}/.. ABSOLUTE)
|
|
||||||
unset(flatbuffers_include)
|
|
||||||
elseif(NOT ${dep}_PREFIX)
|
elseif(NOT ${dep}_PREFIX)
|
||||||
# try to guess
|
# try to guess
|
||||||
if(TARGET ${dep}::${dep})
|
if(TARGET ${dep}::${dep})
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2018-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2018-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
|
@ -34,8 +34,6 @@ endfunction()
|
||||||
|
|
||||||
# Configure/Install CMake package
|
# Configure/Install CMake package
|
||||||
macro(install_cmake_package)
|
macro(install_cmake_package)
|
||||||
list(SORT PROJECT_PACKAGE_DEPENDENCIES)
|
|
||||||
list(SORT PROJECT_INTERFACE_PACKAGE_DEPENDENCIES)
|
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
set(PACKAGE_INSTALL_DESTINATION
|
set(PACKAGE_INSTALL_DESTINATION
|
||||||
${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2018-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2018-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
|
@ -114,16 +114,16 @@ endif()
|
||||||
set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" "RelWithDebInfo")
|
set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" "RelWithDebInfo")
|
||||||
set(_warnings "-Wshadow -Wall -Wextra -Wpedantic")
|
set(_warnings "-Wshadow -Wall -Wextra -Wpedantic")
|
||||||
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g ${_warnings} ${_sanitizers}")
|
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g ${_warnings} ${_sanitizers}")
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g ${_warnings} -DNDEBUG ${_sanitizers}")
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g ${_warnings} -DNDEBUG ${_sanitizers}")
|
||||||
unset(_warnings)
|
unset(_warnings)
|
||||||
unset(_sanitizers)
|
unset(_sanitizers)
|
||||||
|
|
||||||
if(CMAKE_GENERATOR STREQUAL "Ninja" AND
|
if(DISABLE_COLOR)
|
||||||
((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9) OR
|
set(CMAKE_COLOR_MAKEFILE OFF)
|
||||||
(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)))
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=never")
|
||||||
# Force colored warnings in Ninja's output, if the compiler has -fdiagnostics-color support.
|
else()
|
||||||
# Rationale in https://github.com/ninja-build/ninja/issues/814
|
set(CMAKE_COLOR_MAKEFILE ON)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -168,9 +168,22 @@ if(CMAKE_GENERATOR STREQUAL Ninja AND ENABLE_CCACHE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
|
if(NOT DEFINED FAIRMQ_HAS_STD_FILESYSTEM)
|
||||||
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
|
if( ( CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
|
||||||
set(FAIRMQ_HAS_STD_FILESYSTEM 0)
|
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
|
||||||
else()
|
OR ( CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
|
||||||
set(FAIRMQ_HAS_STD_FILESYSTEM 1)
|
AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9))
|
||||||
|
set(FAIRMQ_HAS_STD_FILESYSTEM 0)
|
||||||
|
else()
|
||||||
|
set(FAIRMQ_HAS_STD_FILESYSTEM 1)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT DEFINED FAIRMQ_HAS_STD_PMR)
|
||||||
|
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||||
|
# Clang (to be more precise: libc++) currently does not implement <memory_resource>
|
||||||
|
set(FAIRMQ_HAS_STD_PMR 0)
|
||||||
|
else()
|
||||||
|
set(FAIRMQ_HAS_STD_PMR 1)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2018-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2018-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
|
@ -27,24 +27,6 @@ macro(fairmq_summary_components)
|
||||||
set(tests_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_TESTING=ON${CR})")
|
set(tests_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_TESTING=ON${CR})")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS " ${BWhite}tests${CR} ${tests_summary}")
|
message(STATUS " ${BWhite}tests${CR} ${tests_summary}")
|
||||||
if(BUILD_OFI_TRANSPORT)
|
|
||||||
set(ofi_summary "${BGreen}YES${CR} EXPERIMENTAL (disable with ${BMagenta}-DBUILD_OFI_TRANSPORT=OFF${CR})")
|
|
||||||
else()
|
|
||||||
set(ofi_summary "${BRed} NO${CR} EXPERIMENTAL (default, enable with ${BMagenta}-DBUILD_OFI_TRANSPORT=ON${CR})")
|
|
||||||
endif()
|
|
||||||
message(STATUS " ${BWhite}ofi_transport${CR} ${ofi_summary}")
|
|
||||||
if(BUILD_DDS_PLUGIN)
|
|
||||||
set(dds_summary "${BGreen}YES${CR} (disable with ${BMagenta}-DBUILD_DDS_PLUGIN=OFF${CR})")
|
|
||||||
else()
|
|
||||||
set(dds_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_DDS_PLUGIN=ON${CR})")
|
|
||||||
endif()
|
|
||||||
message(STATUS " ${BWhite}dds_plugin${CR} ${dds_summary}")
|
|
||||||
if(BUILD_PMIX_PLUGIN)
|
|
||||||
set(pmix_summary "${BGreen}YES${CR} EXPERIMENTAL (disable with ${BMagenta}-DBUILD_PMIX_PLUGIN=OFF${CR})")
|
|
||||||
else()
|
|
||||||
set(pmix_summary "${BRed} NO${CR} EXPERIMENTAL (default, enable with ${BMagenta}-DBUILD_PMIX_PLUGIN=ON${CR})")
|
|
||||||
endif()
|
|
||||||
message(STATUS " ${BWhite}pmix_plugin${CR} ${pmix_summary}")
|
|
||||||
if(BUILD_EXAMPLES)
|
if(BUILD_EXAMPLES)
|
||||||
set(examples_summary "${BGreen}YES${CR} (default, disable with ${BMagenta}-DBUILD_EXAMPLES=OFF${CR})")
|
set(examples_summary "${BGreen}YES${CR} (default, disable with ${BMagenta}-DBUILD_EXAMPLES=OFF${CR})")
|
||||||
else()
|
else()
|
||||||
|
@ -57,18 +39,12 @@ macro(fairmq_summary_components)
|
||||||
set(docs_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_DOCS=ON${CR})")
|
set(docs_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_DOCS=ON${CR})")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS " ${BWhite}docs${CR} ${docs_summary}")
|
message(STATUS " ${BWhite}docs${CR} ${docs_summary}")
|
||||||
if(BUILD_SDK)
|
if(BUILD_TIDY_TOOL)
|
||||||
set(sdk_summary "${BGreen}YES${CR} EXPERIMENTAL (disable with ${BMagenta}-DBUILD_SDK=OFF${CR})")
|
set(sdk_tidy_summary "${BGreen}YES${CR} EXPERIMENTAL (disable with ${BMagenta}-DBUILD_TIDY_TOOL=OFF${CR})")
|
||||||
else()
|
else()
|
||||||
set(sdk_summary "${BRed} NO${CR} EXPERIMENTAL (default, enable with ${BMagenta}-DBUILD_SDK=ON${CR})")
|
set(sdk_tidy_summary "${BRed} NO${CR} EXPERIMENTAL (default, enable with ${BMagenta}-DBUILD_TIDY_TOOL=ON${CR})")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS " ${BWhite}sdk${CR} ${sdk_summary}")
|
message(STATUS " ${BWhite}tidy_tool${CR} ${sdk_tidy_summary}")
|
||||||
if(BUILD_SDK_COMMANDS)
|
|
||||||
set(sdk_commands_summary "${BGreen}YES${CR} (disable with ${BMagenta}-DBUILD_SDK_COMMANDS=OFF${CR})")
|
|
||||||
else()
|
|
||||||
set(sdk_commands_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DBUILD_SDK_COMMANDS=ON${CR})")
|
|
||||||
endif()
|
|
||||||
message(STATUS " ${BWhite}sdk_commands${CR} ${sdk_commands_summary}")
|
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(fairmq_summary_static_analysis)
|
macro(fairmq_summary_static_analysis)
|
||||||
|
@ -91,9 +67,17 @@ macro(fairmq_summary_static_analysis)
|
||||||
endforeach()
|
endforeach()
|
||||||
set(static_ana_summary "${BWhite}(${CR}${analyser_list}${BWhite})${CR} (disable with ${BMagenta}-DRUN_STATIC_ANALYSIS=OFF${CR})")
|
set(static_ana_summary "${BWhite}(${CR}${analyser_list}${BWhite})${CR} (disable with ${BMagenta}-DRUN_STATIC_ANALYSIS=OFF${CR})")
|
||||||
else()
|
else()
|
||||||
set(static_ana_summary "${BRed}OFF${CR} (default, enable with ${BMagenta}-DRUN_STATIC_ANALYSIS=ON${CR})")
|
set(static_ana_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DRUN_STATIC_ANALYSIS=ON${CR})")
|
||||||
endif()
|
endif()
|
||||||
message(STATUS " ${Cyan}RUN STATIC ANALYSIS ${static_ana_summary}")
|
message(STATUS " ${Cyan}RUN STATIC ANALYSIS ${static_ana_summary}")
|
||||||
|
if(BUILD_TIDY_TOOL)
|
||||||
|
if(RUN_FAIRMQ_TIDY)
|
||||||
|
set(tidy_summary "${BGreen}YES${CR} (disable with ${BMagenta}-DRUN_FAIRMQ_TIDY=OFF${CR})")
|
||||||
|
else()
|
||||||
|
set(tidy_summary "${BRed} NO${CR} (default, enable with ${BMagenta}-DRUN_FAIRMQ_TIDY=ON${CR})")
|
||||||
|
endif()
|
||||||
|
message(STATUS " ${Cyan}RUN fairmq-tidy ${tidy_summary}")
|
||||||
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(fairmq_summary_install_prefix)
|
macro(fairmq_summary_install_prefix)
|
||||||
|
@ -109,3 +93,13 @@ macro(fairmq_summary_debug_mode)
|
||||||
message(STATUS " ${Cyan}DEBUG MODE${CR} ${BRed}${FAIRMQ_DEBUG_MODE}${CR} (enable with ${BMagenta}-DFAIRMQ_DEBUG_MODE=ON${CR})")
|
message(STATUS " ${Cyan}DEBUG MODE${CR} ${BRed}${FAIRMQ_DEBUG_MODE}${CR} (enable with ${BMagenta}-DFAIRMQ_DEBUG_MODE=ON${CR})")
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
macro(fairmq_summary_compile_definitions)
|
||||||
|
message(STATUS " ")
|
||||||
|
message(STATUS " ${Cyan}COMPILE DEFINITION VALUE${CR}")
|
||||||
|
message(STATUS " ${BWhite}FAIRMQ_HAS_STD_FILESYSTEM${CR} ${FAIRMQ_HAS_STD_FILESYSTEM} (overridable with ${BMagenta}-DFAIRMQ_HAS_STD_FILESYSTEM=0|1${CR})")
|
||||||
|
message(STATUS " ${BWhite}FAIRMQ_HAS_STD_PMR${CR} ${FAIRMQ_HAS_STD_PMR} (overridable with ${BMagenta}-DFAIRMQ_HAS_STD_PMR=0|1${CR})")
|
||||||
|
if(DEFINED FAIRMQ_CHANNEL_DEFAULT_AUTOBIND)
|
||||||
|
message(STATUS " ${BWhite}FAIRMQ_CHANNEL_DEFAULT_AUTOBIND${CR} ${FAIRMQ_CHANNEL_DEFAULT_AUTOBIND}")
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
103
cmake/FairMQTidy.cmake
Normal file
103
cmake/FairMQTidy.cmake
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
################################################################################
|
||||||
|
# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
|
# #
|
||||||
|
# This software is distributed under the terms of the #
|
||||||
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
|
# copied verbatim in the file "LICENSE" #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
include_guard(GLOBAL)
|
||||||
|
|
||||||
|
#[=======================================================================[.rst:
|
||||||
|
|
||||||
|
``fairmq_target_tidy()``
|
||||||
|
========================
|
||||||
|
|
||||||
|
Runs the FairMQ static analyzer ``fairmq-tidy`` on source files in given
|
||||||
|
target.
|
||||||
|
|
||||||
|
.. code-block:: cmake
|
||||||
|
|
||||||
|
fairmq_target_tidy(TARGET <target> [EXTRA_ARGS <args>]
|
||||||
|
[CLANG_EXECUTABLE <clang>])
|
||||||
|
|
||||||
|
Registers a custom command that depends on ``<target>`` which runs ``fairmq-tidy``
|
||||||
|
on the source files that belong to ``<target>``. Optional extra arguments
|
||||||
|
``<args>`` are passed to the ``fairmq-tidy`` command-line.
|
||||||
|
|
||||||
|
Requires ``CMAKE_EXPORT_COMPILE_COMMANDS`` to be enabled.
|
||||||
|
|
||||||
|
#]=======================================================================]
|
||||||
|
|
||||||
|
function(fairmq_target_tidy)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 ARG "" "TARGET;EXTRA_ARGS;CLANG_EXECUTABLE" "")
|
||||||
|
|
||||||
|
if(NOT CMAKE_EXPORT_COMPILE_COMMANDS)
|
||||||
|
message(AUTHOR_WARNING "CMAKE_EXPORT_COMPILE_COMMANDS is not enabled. Skipping.")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT ARG_TARGET)
|
||||||
|
message(AUTHOR_WARNING "TARGET argument is required. Skipping.")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT TARGET ${ARG_TARGET})
|
||||||
|
message(AUTHOR_WARNING "Given TARGET argument `${ARG_TARGET}` is not a target. Skipping.")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
|
if(NOT fairmq_tidy_clang_resource_dir)
|
||||||
|
if(ARG_CLANG_EXECUTABLE)
|
||||||
|
set(clang_exe ${ARG_CLANG_EXECUTABLE})
|
||||||
|
else()
|
||||||
|
if(TARGET clang)
|
||||||
|
get_property(clang_exe TARGET clang PROPERTY LOCATION)
|
||||||
|
else()
|
||||||
|
set(clang_exe "clang")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
execute_process(
|
||||||
|
COMMAND ${clang_exe} -print-resource-dir
|
||||||
|
OUTPUT_VARIABLE clang_resource_dir
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
set(fairmq_tidy_clang_resource_dir ${clang_resource_dir}
|
||||||
|
CACHE PATH "fairmq_target_tidy() internal state" FORCE)
|
||||||
|
endif()
|
||||||
|
list(APPEND ARG_EXTRA_ARGS
|
||||||
|
"--extra-arg-before=-I${fairmq_tidy_clang_resource_dir}/include")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ARG_EXTRA_ARGS)
|
||||||
|
set(extra 1)
|
||||||
|
else()
|
||||||
|
set(extra 0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_target_property(sources ${ARG_TARGET} SOURCES)
|
||||||
|
list(FILTER sources INCLUDE REGEX "\.(cpp|cxx)$")
|
||||||
|
string(REPLACE ":" "-" target_nocolon "${ARG_TARGET}")
|
||||||
|
|
||||||
|
set(src_deps)
|
||||||
|
foreach(source IN LISTS sources)
|
||||||
|
string(REPLACE "\/" "-" source_noslash "${source}")
|
||||||
|
set(src_stamp "${CMAKE_CURRENT_BINARY_DIR}/${target_nocolon}-${source_noslash}.fairmq-tidy")
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${src_stamp}
|
||||||
|
COMMAND $<TARGET_FILE:FairMQ::fairmq-tidy> -p=${CMAKE_BINARY_DIR}
|
||||||
|
$<${extra}:${ARG_EXTRA_ARGS}> ${source}
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E touch ${src_stamp}
|
||||||
|
COMMENT "fairmq-tidy: Analyzing source file '${source}' of target '${ARG_TARGET}'"
|
||||||
|
DEPENDS ${ARG_TARGET}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
COMMAND_EXPAND_LISTS VERBATIM
|
||||||
|
)
|
||||||
|
list(APPEND src_deps ${src_stamp})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(src_deps)
|
||||||
|
add_custom_target("fairmq-tidy-${target_nocolon}" ALL DEPENDS ${src_deps})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
|
@ -1,74 +0,0 @@
|
||||||
################################################################################
|
|
||||||
# Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
|
||||||
# #
|
|
||||||
# This software is distributed under the terms of the #
|
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
|
||||||
# copied verbatim in the file "LICENSE" #
|
|
||||||
################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
# The "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix" part in all
|
|
||||||
# the PATH_SUFFIXES is here to be able to find Debian's
|
|
||||||
# libpmix-dev package. It installs everything below
|
|
||||||
# /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix
|
|
||||||
|
|
||||||
|
|
||||||
find_path(PMIx_INCLUDE_DIR
|
|
||||||
NAMES pmix.h
|
|
||||||
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
|
||||||
PATH_SUFFIXES include lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix/include
|
|
||||||
)
|
|
||||||
|
|
||||||
find_path(PMIx_LIBRARY_DIR
|
|
||||||
NAMES libpmix.dylib libpmix.so
|
|
||||||
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
|
||||||
PATH_SUFFIXES lib lib64 lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix/lib
|
|
||||||
)
|
|
||||||
|
|
||||||
find_library(PMIx_LIBRARY_SHARED
|
|
||||||
NAMES libpmix.dylib libpmix.so
|
|
||||||
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
|
||||||
PATH_SUFFIXES lib lib64 lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix/lib
|
|
||||||
)
|
|
||||||
|
|
||||||
find_file(PMIx_VERSION_FILE
|
|
||||||
NAMES pmix_version.h
|
|
||||||
HINTS ${PMIX_ROOT} $ENV{PMIX_ROOT}
|
|
||||||
PATH_SUFFIXES include lib/${CMAKE_LIBRARY_ARCHITECTURE}/pmix/include
|
|
||||||
)
|
|
||||||
|
|
||||||
file(READ "${PMIx_VERSION_FILE}" __version_raw)
|
|
||||||
string(REGEX MATCH "#define PMIX_VERSION_MAJOR ([0-9]?)L?"
|
|
||||||
__version_major_raw "${__version_raw}"
|
|
||||||
)
|
|
||||||
set(PMIx_VERSION_MAJOR "${CMAKE_MATCH_1}")
|
|
||||||
|
|
||||||
string(REGEX MATCH "#define PMIX_VERSION_MINOR ([0-9]?)L?"
|
|
||||||
__version_minor_raw "${__version_raw}"
|
|
||||||
)
|
|
||||||
set(PMIx_VERSION_MINOR "${CMAKE_MATCH_1}")
|
|
||||||
|
|
||||||
string(REGEX MATCH "#define PMIX_VERSION_RELEASE ([0-9]?)L?"
|
|
||||||
__version_patch_raw "${__version_raw}"
|
|
||||||
)
|
|
||||||
set(PMIx_VERSION_PATCH "${CMAKE_MATCH_1}")
|
|
||||||
|
|
||||||
set(PMIx_VERSION "${PMIx_VERSION_MAJOR}.${PMIx_VERSION_MINOR}.${PMIx_VERSION_PATCH}")
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
find_package_handle_standard_args(PMIx
|
|
||||||
REQUIRED_VARS
|
|
||||||
PMIx_INCLUDE_DIR
|
|
||||||
PMIx_LIBRARY_DIR
|
|
||||||
PMIx_LIBRARY_SHARED
|
|
||||||
|
|
||||||
VERSION_VAR PMIx_VERSION
|
|
||||||
)
|
|
||||||
|
|
||||||
if(NOT TARGET PMIx::libpmix AND PMIx_FOUND)
|
|
||||||
add_library(PMIx::libpmix SHARED IMPORTED)
|
|
||||||
set_target_properties(PMIx::libpmix PROPERTIES
|
|
||||||
IMPORTED_LOCATION ${PMIx_LIBRARY_SHARED}
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES ${PMIx_INCLUDE_DIR}
|
|
||||||
)
|
|
||||||
endif()
|
|
|
@ -1,5 +1,5 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2017-2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2017-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
# [DEPENDS dep1 [dep2 ...]]
|
# [DEPENDS dep1 [dep2 ...]]
|
||||||
# [LINKS linklib1 [linklib2 ...]
|
# [LINKS linklib1 [linklib2 ...]
|
||||||
# [INCLUDES dir1 [dir2 ...]
|
# [INCLUDES dir1 [dir2 ...]
|
||||||
|
# [ENVIRONMENT var1=op:val1[;var2=op:val2 ...]]
|
||||||
# [TIMEOUT seconds]
|
# [TIMEOUT seconds]
|
||||||
# [RUN_SERIAL ON/OFF])
|
# [RUN_SERIAL ON/OFF])
|
||||||
#
|
#
|
||||||
|
@ -48,12 +49,15 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
include(GoogleTest)
|
include(GoogleTest)
|
||||||
|
if(BUILD_TIDY_TOOL)
|
||||||
|
include(FairMQTidy)
|
||||||
|
endif()
|
||||||
|
|
||||||
function(add_testsuite suitename)
|
function(add_testsuite suitename)
|
||||||
cmake_parse_arguments(testsuite
|
cmake_parse_arguments(testsuite
|
||||||
""
|
""
|
||||||
"TIMEOUT;RUN_SERIAL"
|
"TIMEOUT;RUN_SERIAL"
|
||||||
"SOURCES;LINKS;DEPENDS;INCLUDES;DEFINITIONS"
|
"SOURCES;LINKS;DEPENDS;INCLUDES;DEFINITIONS;ENVIRONMENT"
|
||||||
${ARGN}
|
${ARGN}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -74,6 +78,12 @@ function(add_testsuite suitename)
|
||||||
if(testsuite_DEFINITIONS)
|
if(testsuite_DEFINITIONS)
|
||||||
target_compile_definitions("${target}" PUBLIC ${testsuite_DEFINITIONS})
|
target_compile_definitions("${target}" PUBLIC ${testsuite_DEFINITIONS})
|
||||||
endif()
|
endif()
|
||||||
|
if(testsuite_ENVIRONMENT AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
|
||||||
|
set(env "ENVIRONMENT_MODIFICATION" ${testsuite_ENVIRONMENT})
|
||||||
|
endif()
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET ${target})
|
||||||
|
endif()
|
||||||
|
|
||||||
# add_test(NAME "${suitename}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${target})
|
# add_test(NAME "${suitename}" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} COMMAND ${target})
|
||||||
if(testsuite_TIMEOUT)
|
if(testsuite_TIMEOUT)
|
||||||
|
@ -91,6 +101,7 @@ function(add_testsuite suitename)
|
||||||
TEST_PREFIX ${suitename}.
|
TEST_PREFIX ${suitename}.
|
||||||
PROPERTIES RUN_SERIAL ${testsuite_RUN_SERIAL}
|
PROPERTIES RUN_SERIAL ${testsuite_RUN_SERIAL}
|
||||||
TIMEOUT ${testsuite_TIMEOUT}
|
TIMEOUT ${testsuite_TIMEOUT}
|
||||||
|
${env}
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND ALL_TEST_TARGETS ${target})
|
list(APPEND ALL_TEST_TARGETS ${target})
|
||||||
|
@ -120,6 +131,9 @@ function(add_testhelper helpername)
|
||||||
if(testhelper_DEFINITIONS)
|
if(testhelper_DEFINITIONS)
|
||||||
target_compile_definitions(${target} PUBLIC ${testhelper_DEFINITIONS})
|
target_compile_definitions(${target} PUBLIC ${testhelper_DEFINITIONS})
|
||||||
endif()
|
endif()
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET ${target})
|
||||||
|
endif()
|
||||||
|
|
||||||
list(APPEND ALL_TEST_TARGETS ${target})
|
list(APPEND ALL_TEST_TARGETS ${target})
|
||||||
set(ALL_TEST_TARGETS ${ALL_TEST_TARGETS} PARENT_SCOPE)
|
set(ALL_TEST_TARGETS ${ALL_TEST_TARGETS} PARENT_SCOPE)
|
||||||
|
@ -154,6 +168,9 @@ function(add_testlib libname)
|
||||||
if(testlib_DEFINITIONS)
|
if(testlib_DEFINITIONS)
|
||||||
target_compile_definitions(${target} PUBLIC ${testlib_DEFINITIONS})
|
target_compile_definitions(${target} PUBLIC ${testlib_DEFINITIONS})
|
||||||
endif()
|
endif()
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET ${target})
|
||||||
|
endif()
|
||||||
|
|
||||||
list(APPEND ALL_TEST_TARGETS ${target})
|
list(APPEND ALL_TEST_TARGETS ${target})
|
||||||
set(ALL_TEST_TARGETS ${ALL_TEST_TARGETS} PARENT_SCOPE)
|
set(ALL_TEST_TARGETS ${ALL_TEST_TARGETS} PARENT_SCOPE)
|
||||||
|
|
|
@ -6,17 +6,29 @@
|
||||||
"license": "./COPYRIGHT",
|
"license": "./COPYRIGHT",
|
||||||
"datePublished": "2018-04-15",
|
"datePublished": "2018-04-15",
|
||||||
"developmentStatus": "active",
|
"developmentStatus": "active",
|
||||||
|
"softwareVersion": "master",
|
||||||
|
"releaseNotes": "https://github.com/FairRootGroup/FairMQ/releases",
|
||||||
"codeRepository": "https://github.com/FairRootGroup/FairMQ/",
|
"codeRepository": "https://github.com/FairRootGroup/FairMQ/",
|
||||||
|
"readme": "https://github.com/FairRootGroup/FairMQ/#readme",
|
||||||
"issueTracker": "https://github.com/FairRootGroup/FairMQ/issues",
|
"issueTracker": "https://github.com/FairRootGroup/FairMQ/issues",
|
||||||
"identifier": "https://doi.org/10.5281/zenodo.1689985",
|
"identifier": "https://doi.org/10.5281/zenodo.1689985",
|
||||||
|
"maintainer": [
|
||||||
|
{
|
||||||
|
"@type": "ResearchOrganisation",
|
||||||
|
"@id": "https://ror.org/02k8cbn47",
|
||||||
|
"name": "GSI Helmholtz Centre for Heavy Ion Research"
|
||||||
|
}
|
||||||
|
],
|
||||||
"author": [
|
"author": [
|
||||||
{
|
{
|
||||||
"@type": "Person",
|
"@type": "Person",
|
||||||
|
"@id": "https://orcid.org/0000-0002-8071-4497",
|
||||||
"givenName": "Mohammad",
|
"givenName": "Mohammad",
|
||||||
"familyName": "Al-Turany"
|
"familyName": "Al-Turany"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@type": "Person",
|
"@type": "Person",
|
||||||
|
"@id": "https://orcid.org/0000-0003-3787-1910",
|
||||||
"givenName": "Dennis",
|
"givenName": "Dennis",
|
||||||
"familyName": "Klein"
|
"familyName": "Klein"
|
||||||
},
|
},
|
||||||
|
@ -27,6 +39,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@type": "Person",
|
"@type": "Person",
|
||||||
|
"@id": "https://orcid.org/0000-0002-6249-155X",
|
||||||
"givenName": "Alexey",
|
"givenName": "Alexey",
|
||||||
"familyName": "Rybalchenko"
|
"familyName": "Rybalchenko"
|
||||||
},
|
},
|
||||||
|
@ -91,6 +104,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"@type": "Person",
|
"@type": "Person",
|
||||||
|
"@id": "https://orcid.org/0000-0002-5321-8404",
|
||||||
"givenName": "Christian",
|
"givenName": "Christian",
|
||||||
"familyName": "Tacke"
|
"familyName": "Tacke"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,83 +0,0 @@
|
||||||
#! /usr/bin/env python3
|
|
||||||
# Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
||||||
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import json
|
|
||||||
import re
|
|
||||||
from collections import OrderedDict
|
|
||||||
|
|
||||||
|
|
||||||
class CodeMetaManipulator(object):
|
|
||||||
def load(self, filename='codemeta.json'):
|
|
||||||
with open(filename, 'rb') as fp:
|
|
||||||
self.data = json.load(fp, object_pairs_hook=OrderedDict)
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def _dict_entry_cmp(dict1, dict2, field):
|
|
||||||
if (field in dict1) and (field in dict2):
|
|
||||||
return dict1[field] == dict2[field]
|
|
||||||
else:
|
|
||||||
return False
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def find_person_entry(cls, person_list, matchdict):
|
|
||||||
for entry in person_list:
|
|
||||||
if cls._dict_entry_cmp(entry, matchdict, 'email'):
|
|
||||||
return entry
|
|
||||||
if cls._dict_entry_cmp(entry, matchdict, 'familyName') \
|
|
||||||
and cls._dict_entry_cmp(entry, matchdict, 'givenName'):
|
|
||||||
return entry
|
|
||||||
return None
|
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def update_person_entry(entry, matchdict):
|
|
||||||
if entry is None:
|
|
||||||
entry = OrderedDict()
|
|
||||||
entry['@type'] = 'Person'
|
|
||||||
for field in ('givenName', 'familyName', 'email'):
|
|
||||||
val = matchdict.get(field, None)
|
|
||||||
if val is not None:
|
|
||||||
entry[field] = val
|
|
||||||
return entry
|
|
||||||
|
|
||||||
def handle_person_list_file(self, filename, cm_field_name):
|
|
||||||
fp = open(filename, 'r', encoding='utf8')
|
|
||||||
findregex = re.compile(r'^(?P<familyName>[-\w\s]*[-\w]),\s*'
|
|
||||||
r'(?P<givenName>[-\w\s]*[-\w])\s*'
|
|
||||||
r'(?:<(?P<email>\S+@\S+)>)?$')
|
|
||||||
person_list = self.data.setdefault(cm_field_name, [])
|
|
||||||
for line in fp:
|
|
||||||
line = line.strip()
|
|
||||||
m = findregex.match(line)
|
|
||||||
if m is None:
|
|
||||||
raise RuntimeError("Could not analyze line %r" % line)
|
|
||||||
found_entry = self.find_person_entry(person_list, m.groupdict())
|
|
||||||
entry = self.update_person_entry(found_entry, m.groupdict())
|
|
||||||
if found_entry is None:
|
|
||||||
person_list.append(entry)
|
|
||||||
|
|
||||||
def save(self, filename='codemeta.json'):
|
|
||||||
with open('codemeta.json', 'w', encoding='utf8') as fp:
|
|
||||||
json.dump(self.data, fp, indent=2)
|
|
||||||
fp.write('\n')
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(description='Update codemeta.json')
|
|
||||||
parser.add_argument('--set-version', dest='newversion')
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
cm = CodeMetaManipulator()
|
|
||||||
cm.load()
|
|
||||||
if args.newversion is not None:
|
|
||||||
cm.data['softwareVersion'] = args.newversion
|
|
||||||
cm.handle_person_list_file('AUTHORS', 'author')
|
|
||||||
cm.handle_person_list_file('CONTRIBUTORS', 'contributor')
|
|
||||||
cm.save()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
main()
|
|
|
@ -16,20 +16,18 @@ Here is an overview of the device/channel options and when they are applied:
|
||||||
|
|
||||||
| Property | Applied in |
|
| Property | Applied in |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| `severity` | immidiately (if `fair::mq::DeviceRunner` is used (also the case when using `<runFairMQDevice.h>`)) |
|
| `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 `<runFairMQDevice.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 `<runFairMQDevice.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 `<runFairMQDevice.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 `<runFairMQDevice.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` |
|
| `id` | at the end of `fair::mq::State::InitializingDevice` |
|
||||||
| `io-threads` | 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` |
|
| `transport` | at the end of `fair::mq::State::InitializingDevice` |
|
||||||
| `network-interface` | 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` |
|
| `init-timeout` | at the end of `fair::mq::State::InitializingDevice` |
|
||||||
| `max-run-time` | at the end of `fair::mq::State::InitializingDevice` |
|
|
||||||
| `shm-segment-size` | 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` |
|
| `shm-monitor` | at the end of `fair::mq::State::InitializingDevice` |
|
||||||
| `ofi-size-hint` | at the end of `fair::mq::State::InitializingDevice` |
|
|
||||||
| `rate` | 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` |
|
| `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`) |
|
| `chan.*` | at the end of `fair::mq::State::InitializingDevice` (channel addresses can be also applied during `fair::mq::State::Binding`/`fair::mq::State::Connecting`) |
|
||||||
|
|
|
@ -6,8 +6,53 @@
|
||||||
|
|
||||||
For unit testing it is often not feasible to boot up a full-blown distributed system with dozens of processes.
|
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 `FairMQDevice` 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.
|
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.
|
||||||
|
|
||||||
TODO Multiple devices in one process.
|
## 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)
|
← [Back](../README.md)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
# 1. Device
|
# 1. Device
|
||||||
|
|
||||||
The components encapsulating the tasks are called **devices** and derive from the common base class `FairMQDevice`. 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`).
|
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
|
## 1.1 Topology
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ Plugin Manager:
|
||||||
see man ld.so(8) for details.
|
see man ld.so(8) for details.
|
||||||
-P [ --plugin ] arg List of plugin names to load in
|
-P [ --plugin ] arg List of plugin names to load in
|
||||||
order,e.g. if the file is called
|
order,e.g. if the file is called
|
||||||
'libFairMQPlugin_example.so', just list
|
'libfairmq-plugin-example.so', just list
|
||||||
'example' or 'd:example' here.To load a
|
'example' or 'd:example' here.To load a
|
||||||
prelinked plugin, list 'p:example'
|
prelinked plugin, list 'p:example'
|
||||||
here.
|
here.
|
||||||
|
@ -54,40 +54,8 @@ A more complete example which may serve as a start including example CMake code
|
||||||
|
|
||||||
## 7.3 Provided Plugins
|
## 7.3 Provided Plugins
|
||||||
|
|
||||||
### 7.3.1 DDS
|
### 7.3.1 PMIx
|
||||||
|
|
||||||
When launching a FairMQ topology via [DDS](http://dds.gsi.de/) the DDS plugin enables FairMQ devices to interact with DDS' custom command and property subsystems - enable the plugin by passing `-P dds` on the command line.
|
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.
|
||||||
|
|
||||||
Via the property subsystem a FairMQ topology may exchange channel connection data (essentially to do service discovery) needed to connect/bind all FairMQ channels appropriately. DDS is highly optimized for this use case. See [examples/dds](examples/dds/README.md) for more details.
|
|
||||||
|
|
||||||
Via the custom command subsystem a FairMQ device can receive a number of commands. FairMQ provides a convenient command line tool `fairmq-dds-command-ui` that allows interactive or scripted control of a running FairMQ topology managed via DDS. If one develops directly against the custom command DDS API, the following table lists all the commands the DDS plugin currently understands:
|
|
||||||
|
|
||||||
| Custom Command | Response | Error | Description |
|
|
||||||
| --- | --- | --- | --- |
|
|
||||||
| `check-state` | `<ID>: <STATE> (pid: <PID>)` | n/a | Query current device state, see state machine for possible states |
|
|
||||||
| `dump-config` | `(<ID>: <PKEY> -> <PVALUE>\n)+` | n/a | Query current device config (list property key/value pairs) |
|
|
||||||
| `INIT DEVICE` | `<ID>: queued <CMD> transition` | `<ID>: could not queue <CMD> transition` | Initiate state transition |
|
|
||||||
| `BIND` | `<ID>: queued <CMD> transition` | `<ID>: could not queue <CMD> transition` | Initiate state transition |
|
|
||||||
| `CONNECT` | `<ID>: queued <CMD> transition` | `<ID>: could not queue <CMD> transition` | Initiate state transition |
|
|
||||||
| `INIT TASK` | `<ID>: queued <CMD> transition` | `<ID>: could not queue <CMD> transition` | Initiate state transition |
|
|
||||||
| `RUN` | `<ID>: queued <CMD> transition` | `<ID>: could not queue <CMD> transition` | Initiate state transition |
|
|
||||||
| `STOP` | `<ID>: queued <CMD> transition` | `<ID>: could not queue <CMD> transition` | Initiate state transition |
|
|
||||||
| `RESET TASK` | `<ID>: queued <CMD> transition` | `<ID>: could not queue <CMD> transition` | Initiate state transition |
|
|
||||||
| `RESET DEVICE` | `<ID>: queued <CMD> transition` | `<ID>: could not queue <CMD> transition` | Initiate state transition |
|
|
||||||
| `END` | `<ID>: queued <CMD> transition` | `<ID>: could not queue <CMD> transition` | Initiate state transition |
|
|
||||||
| `subscribe-to-heartbeats` | `heartbeat-subscription: <ID>,OK` | n/a | Subscribe to heartbeats |
|
|
||||||
| on heartbeat subscription | `heartbeat: <ID>,<PID>` | n/a | Heartbeat every 100ms |
|
|
||||||
| `unsubscribe-from-heartbeats` | `heartbeat-unsubscription: <ID>,OK` | n/a | Unsubscribe from heartbeats |
|
|
||||||
| `subscribe-to-state-changes` | `state-changes-subscription: <ID>,OK` | n/a | Subscribe to state changes |
|
|
||||||
| on state changes subscription | `state-change: <ID>,<STATE>` | n/a | State change notification |
|
|
||||||
| `unsubscribe-from-state-changes` | `state-changes-unsubscription: <ID>,OK` | n/a | Unsubscribe from state changes |
|
|
||||||
|
|
||||||
If unknown commands are received the plugin will print a warning.
|
|
||||||
|
|
||||||
### 7.3.2 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 plugin is not (yet) very mature and serves as a proof of concept at the moment.
|
|
||||||
|
|
||||||
TODO example usage
|
|
||||||
|
|
||||||
← [Back](../README.md)
|
← [Back](../README.md)
|
||||||
|
|
34
docs/SDK.md
34
docs/SDK.md
|
@ -1,34 +0,0 @@
|
||||||
← [Back](../README.md)
|
|
||||||
|
|
||||||
# 8. Controller SDK
|
|
||||||
|
|
||||||
The FairMQ Controller Software Development Kit (`-DBUILD_SDK=ON`) contains a (as of today still experimental) set of C++ APIs that provide essential functionality to the implementer of a global controller.
|
|
||||||
|
|
||||||
The FairMQ core library only provides two local controllers - `static` (a fixed sequence of state transitions) and `interactive` (a read-eval-print-loop which reads keyboard commands from standard input). A local controller only knows how steer a single [FairMQ device](Device.md) - in fact, it runs in a thread within the device process.
|
|
||||||
|
|
||||||
A global controller has knowledge about the full topology of connected FairMQ devices. Its responsibility is to facilitate the lifecycle of a distributed FairMQ-based application (*executing a topology*), such as
|
|
||||||
|
|
||||||
* allocating/releasing compute resources from a resource management system,
|
|
||||||
* launching/setting up the run-time environment and the FairMQ devices,
|
|
||||||
* driving the device state machines in lock-step across the full topology,
|
|
||||||
* pushing the device configuration,
|
|
||||||
* monitoring (some aspects of the application's) operation,
|
|
||||||
* and handling/reporting (some) error cases.
|
|
||||||
|
|
||||||
The low-level hook to integrate FairMQ devices with such a global contoller is the [plugin mechanism](Plugins.md) in the FairMQ core library. The FairMQ Controller SDK provides C++ APIs that communicate to the endpoints exposed by such a FairMQ plugin.
|
|
||||||
|
|
||||||
At the moment, the Controller SDK only supports [DDS](https://dds.gsi.de) as resource manager and run-time environment. A second implementation based on [PMIx](https://pmix.org/) (targeting its implementation in [Slurm](https://slurm.schedmd.com/documentation.html) and [OpenRTE](https://www-lb.open-mpi.org/papers/euro-pvmmpi-2005-orte/)) is in development.
|
|
||||||
|
|
||||||
The following section give a short overview on the APIs provided.
|
|
||||||
|
|
||||||
## RMS and run-time environment
|
|
||||||
|
|
||||||
The classes [`fair::mq::sdk::DDSEnvironment`](../fairmq/sdk/DDSEnvironment.h), [`fair::mq::sdk::DDSSession`](../fairmq/sdk/DDSSession.h), and [`fair::mq::sdk::DDSTopology`](../fairmq/sdk/DDSTopology.h) are thin wrappers of most of the synchronous APIs exposed by DDS ([`dds::tools_api`](http://dds.gsi.de/doc/api-docs/DDS/html/namespacedds_1_1tools__api.html) and [`dds::topology_api`](http://dds.gsi.de/doc/api-docs/DDS/html/namespacedds_1_1topology__api.html)). E.g. they allow to [start a DDS session](https://github.com/FairRootGroup/FairMQ/blob/077eb0ef691940d764cfd1852bf3981dc812ddbd/main.cpp#L26-L28), [allocate resources](https://github.com/FairRootGroup/FairMQ/blob/077eb0ef691940d764cfd1852bf3981dc812ddbd/main.cpp#L34) and [launch a topology](https://github.com/FairRootGroup/FairMQ/blob/077eb0ef691940d764cfd1852bf3981dc812ddbd/main.cpp#L39) from a C++ program.
|
|
||||||
|
|
||||||
## Driving the global state machine
|
|
||||||
|
|
||||||
The class [`fair::mq::sdk::Topology`](../fairmq/sdk/Topology.h) adds a FairMQ-specific view on an existing DDS session that is executing a topology of FairMQ devices. One can e.g. [initiate a state transition on all devices in the topology simultaneously](https://github.com/FairRootGroup/FairMQ/blob/077eb0ef691940d764cfd1852bf3981dc812ddbd/main.cpp#L48-L49). This topology transition completes once a topology-wide barrier is passed (all devices completed the transition). This effectively exposes the device state machine as a topology state machine. The implementation is based on remote procedure calls over the [DDS intercom service](http://dds.gsi.de/doc/api-docs/DDS/html/namespacedds_1_1intercom__api.html) between the controller and the DDS plugin shipped with FairMQ (`-DBUILD_DDS_PLUGIN=ON`).
|
|
||||||
|
|
||||||
For future versions of the SDK new APIs are planned to inspect and modify the device configurations and also operate only on subsets of a given topology.
|
|
||||||
|
|
||||||
← [Back](../README.md)
|
|
|
@ -27,34 +27,34 @@ The next table shows the supported address types for each transport implementati
|
||||||
|
|
||||||
## 2.1 Message
|
## 2.1 Message
|
||||||
|
|
||||||
Devices transport data between each other in form of `FairMQMessage`s. These can be filled with arbitrary content. Message can be initialized in three different ways by calling `NewMessage()`:
|
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
|
```cpp
|
||||||
FairMQMessagePtr NewMessage() const;
|
fair::mq::MessagePtr NewMessage() const;
|
||||||
```
|
```
|
||||||
**with no parameters**: Initializes an empty message (typically used for receiving).
|
**with no parameters**: Initializes an empty message (typically used for receiving).
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
FairMQMessagePtr NewMessage(const size_t size) const;
|
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.
|
**given message size**: Initializes message body with a given size. Fill the created contents via buffer pointer.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
using fairmq_free_fn = void(void* data, void* hint);
|
using fairmq_free_fn = void(void* data, void* hint);
|
||||||
FairMQMessagePtr NewMessage(void* data, const size_t size, fairmq_free_fn* ffn, void* hint = nullptr) const;
|
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.
|
**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:
|
Additionally, FairMQ provides two more message factories for convenience:
|
||||||
```cpp
|
```cpp
|
||||||
template<typename T>
|
template<typename T>
|
||||||
FairMQMessagePtr NewSimpleMessage(const T& data) const
|
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.
|
**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
|
```cpp
|
||||||
template<typename T>
|
template<typename T>
|
||||||
FairMQMessagePtr NewStaticMessage(const T& data) const
|
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.)
|
**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.)
|
||||||
|
|
||||||
|
@ -65,19 +65,19 @@ The component of a program, that is reponsible for the allocation or 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).
|
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
|
```cpp
|
||||||
static void FairMQNoCleanup(void* /*data*/, void* /*obj*/) {}
|
static void fair::mq::NoCleanup(void* /*data*/, void* /*obj*/) {}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void FairMQSimpleMsgCleanup(void* /*data*/, void* obj) { delete static_cast<T*>(obj); }
|
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 `FairMQTransportFactory` class to aid the user in controlling ownership of the data.
|
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
|
## 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.
|
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
|
```cpp
|
||||||
const FairMQChannel& GetChannel(const std::string& channelName, const int index = 0) const;
|
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.
|
All subchannels with a common channel name need to be of the same transport type.
|
||||||
|
@ -87,7 +87,7 @@ All subchannels with a common channel name need to be of the same transport type
|
||||||
A poller allows to wait on multiple channels either to receive or send a message.
|
A poller allows to wait on multiple channels either to receive or send a message.
|
||||||
|
|
||||||
```cpp
|
```cpp
|
||||||
FairMQPollerPtr NewPoller(const std::vector<const FairMQChannel*>& channels)
|
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.
|
**list channels**: This poller waits on all supplied channels. Currently, it is limited to channels of the same transport type only.
|
||||||
|
|
||||||
|
|
|
@ -1,51 +1,9 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
add_executable(fairmq-ex-1-1-sampler sampler.cxx)
|
add_example(NAME 1-1 DEVICE sampler sink)
|
||||||
target_link_libraries(fairmq-ex-1-1-sampler PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_executable(fairmq-ex-1-1-sink sink.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-1-1-sink PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_custom_target(Example11 DEPENDS fairmq-ex-1-1-sampler fairmq-ex-1-1-sink)
|
|
||||||
|
|
||||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-1.sh)
|
|
||||||
|
|
||||||
# test
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-1-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh)
|
|
||||||
|
|
||||||
add_test(NAME Example.1-1.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh zeromq)
|
|
||||||
set_tests_properties(Example.1-1.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
|
||||||
|
|
||||||
add_test(NAME Example.1-1.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-1.sh shmem)
|
|
||||||
set_tests_properties(Example.1-1.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
|
||||||
|
|
||||||
# install
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
fairmq-ex-1-1-sampler
|
|
||||||
fairmq-ex-1-1-sink
|
|
||||||
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# configure run script with different executable paths for build and for install directories
|
|
||||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-1.sh_install)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-1.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-1-1.sh
|
|
||||||
)
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ struct Sampler : fair::mq::Device
|
||||||
// create message object with a pointer to the data buffer, its size,
|
// create message object with a pointer to the data buffer, its size,
|
||||||
// custom deletion function (called when transfer is done),
|
// custom deletion function (called when transfer is done),
|
||||||
// and pointer to the object managing the data buffer
|
// and pointer to the object managing the data buffer
|
||||||
FairMQMessagePtr msg(NewMessage(
|
fair::mq::MessagePtr msg(NewMessage(
|
||||||
const_cast<char*>(text->c_str()),
|
const_cast<char*>(text->c_str()),
|
||||||
text->length(),
|
text->length(),
|
||||||
[](void* /*data*/, void* object) { delete static_cast<std::string*>(object); },
|
[](void* /*data*/, void* object) { delete static_cast<std::string*>(object); },
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct Sink : fair::mq::Device
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int)
|
bool HandleData(fair::mq::MessagePtr& msg, int)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
LOG(info) << "Received: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
transport="zeromq"
|
transport="zeromq"
|
||||||
|
@ -8,20 +10,24 @@ if [[ $1 =~ ^[a-z]+$ ]]; then
|
||||||
transport=$1
|
transport=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SESSION="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
session="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
||||||
|
chan="data"
|
||||||
|
chanAddr="/tmp/fmq_$session""_""$chan""_""$transport"
|
||||||
|
|
||||||
# setup a trap to kill everything if the test fails/timeouts
|
# setup a trap to kill everything if the test fails/timeouts
|
||||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID;' TERM
|
trap 'set +e; kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID; rm $chanAddr; exit 0' TERM
|
||||||
|
|
||||||
SAMPLER="fairmq-ex-1-1-sampler"
|
SAMPLER="fairmq-ex-1-1-sampler"
|
||||||
SAMPLER+=" --id sampler1"
|
SAMPLER+=" --id sampler1"
|
||||||
SAMPLER+=" --rate 1"
|
SAMPLER+=" --rate 1"
|
||||||
SAMPLER+=" --transport $transport"
|
SAMPLER+=" --transport $transport"
|
||||||
SAMPLER+=" --verbosity veryhigh"
|
SAMPLER+=" --verbosity veryhigh"
|
||||||
SAMPLER+=" --session $SESSION"
|
SAMPLER+=" --session $session"
|
||||||
|
SAMPLER+=" --shm-segment-size 100000000"
|
||||||
|
SAMPLER+=" --shm-monitor true"
|
||||||
SAMPLER+=" --control static --color false"
|
SAMPLER+=" --control static --color false"
|
||||||
SAMPLER+=" --max-iterations 1"
|
SAMPLER+=" --max-iterations 1"
|
||||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://*:5555,rateLogging=0"
|
SAMPLER+=" --channel-config name=$chan,type=push,method=bind,address=ipc://$chanAddr,rateLogging=0"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||||
SAMPLER_PID=$!
|
SAMPLER_PID=$!
|
||||||
|
|
||||||
|
@ -29,13 +35,19 @@ SINK="fairmq-ex-1-1-sink"
|
||||||
SINK+=" --id sink1"
|
SINK+=" --id sink1"
|
||||||
SINK+=" --transport $transport"
|
SINK+=" --transport $transport"
|
||||||
SINK+=" --verbosity veryhigh"
|
SINK+=" --verbosity veryhigh"
|
||||||
SINK+=" --session $SESSION"
|
SINK+=" --session $session"
|
||||||
|
SINK+=" --shm-segment-size 100000000"
|
||||||
|
SINK+=" --shm-monitor true"
|
||||||
SINK+=" --control static --color false"
|
SINK+=" --control static --color false"
|
||||||
SINK+=" --max-iterations 1"
|
SINK+=" --max-iterations 1"
|
||||||
SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://localhost:5555,rateLogging=0"
|
SINK+=" --channel-config name=$chan,type=pull,method=connect,address=ipc://$chanAddr,rateLogging=0"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
||||||
SINK_PID=$!
|
SINK_PID=$!
|
||||||
|
|
||||||
# wait for sampler and sink to finish
|
# wait for sampler and sink to finish
|
||||||
wait $SAMPLER_PID
|
wait $SAMPLER_PID
|
||||||
wait $SINK_PID
|
wait $SINK_PID
|
||||||
|
|
||||||
|
set +e
|
||||||
|
rm $chanAddr
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,64 +1,9 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
add_executable(fairmq-ex-1-n-1-sampler sampler.cxx)
|
add_example(NAME 1-n-1 DEVICE sampler processor sink CONFIG)
|
||||||
target_link_libraries(fairmq-ex-1-n-1-sampler PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_executable(fairmq-ex-1-n-1-processor processor.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-1-n-1-processor PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_executable(fairmq-ex-1-n-1-sink sink.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-1-n-1-sink PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_custom_target(Example1N1 DEPENDS fairmq-ex-1-n-1-sampler fairmq-ex-1-n-1-processor fairmq-ex-1-n-1-sink)
|
|
||||||
|
|
||||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(EX_CONF_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-n-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-n-1.sh)
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/ex-1-n-1.json ${CMAKE_CURRENT_BINARY_DIR}/ex-1-n-1.json)
|
|
||||||
|
|
||||||
# test
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-1-n-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh)
|
|
||||||
|
|
||||||
add_test(NAME Example.1-n-1.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh zeromq)
|
|
||||||
set_tests_properties(Example.1-n-1.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
|
||||||
|
|
||||||
add_test(NAME Example.1-n-1.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-1-n-1.sh shmem)
|
|
||||||
set_tests_properties(Example.1-n-1.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received: ")
|
|
||||||
|
|
||||||
# install
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
fairmq-ex-1-n-1-sampler
|
|
||||||
fairmq-ex-1-n-1-processor
|
|
||||||
fairmq-ex-1-n-1-sink
|
|
||||||
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# configure run script with different executable paths for build and for install directories
|
|
||||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
|
||||||
set(EX_CONF_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_DATADIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-1-n-1.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-n-1.sh_install)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-1-n-1.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-1-n-1.sh
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
FILES ${CMAKE_CURRENT_BINARY_DIR}/ex-1-n-1.json
|
|
||||||
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
|
||||||
)
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ struct Processor : fair::mq::Device
|
||||||
OnData("data1", &Processor::HandleData);
|
OnData("data1", &Processor::HandleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int)
|
bool HandleData(fair::mq::MessagePtr& msg, int)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received data, processing...";
|
LOG(info) << "Received data, processing...";
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ struct Processor : fair::mq::Device
|
||||||
// its size,
|
// its size,
|
||||||
// custom deletion function (called when transfer is done),
|
// custom deletion function (called when transfer is done),
|
||||||
// and pointer to the object managing the data buffer
|
// and pointer to the object managing the data buffer
|
||||||
FairMQMessagePtr msg2(NewMessage(const_cast<char*>(text->c_str()),
|
fair::mq::MessagePtr msg2(NewMessage(const_cast<char*>(text->c_str()),
|
||||||
text->length(),
|
text->length(),
|
||||||
[](void* /*data*/, void* object) { delete static_cast<std::string*>(object); },
|
[](void* /*data*/, void* object) { delete static_cast<std::string*>(object); },
|
||||||
text));
|
text));
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct Sampler : fair::mq::Device
|
||||||
{
|
{
|
||||||
// Initializing message with NewStaticMessage will avoid copy
|
// Initializing message with NewStaticMessage will avoid copy
|
||||||
// but won't delete the data after the sending is completed.
|
// but won't delete the data after the sending is completed.
|
||||||
FairMQMessagePtr msg(NewStaticMessage(fText));
|
fair::mq::MessagePtr msg(NewStaticMessage(fText));
|
||||||
|
|
||||||
LOG(info) << "Sending \"" << fText << "\"";
|
LOG(info) << "Sending \"" << fText << "\"";
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct Sink : fair::mq::Device
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int)
|
bool HandleData(fair::mq::MessagePtr& msg, int)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
LOG(info) << "Received: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
transport="zeromq"
|
transport="zeromq"
|
||||||
|
@ -8,20 +10,26 @@ if [[ $1 =~ ^[a-z]+$ ]]; then
|
||||||
transport=$1
|
transport=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ex2config="@CMAKE_CURRENT_BINARY_DIR@/ex-1-n-1.json"
|
session="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
||||||
SESSION="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
chan1="data1"
|
||||||
|
chan2="data2"
|
||||||
|
chan1Addr="/tmp/fmq_$session""_""$chan1""_""$transport"
|
||||||
|
chan2Addr="/tmp/fmq_$session""_""$chan2""_""$transport"
|
||||||
|
|
||||||
# setup a trap to kill everything if the test fails/timeouts
|
# setup a trap to kill everything if the test fails/timeouts
|
||||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; kill -TERM $PROCESSOR1_PID; kill -TERM $PROCESSOR2_PID; wait $SAMPLER_PID; wait $SINK_PID; wait $PROCESSOR1_PID; wait $PROCESSOR2_PID;' TERM
|
trap 'set +e; kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; kill -TERM $PROCESSOR1_PID; kill -TERM $PROCESSOR2_PID; wait $SAMPLER_PID; wait $SINK_PID; wait $PROCESSOR1_PID; wait $PROCESSOR2_PID; rm $chan1Addr; rm $chan2Addr; exit 0' TERM
|
||||||
|
|
||||||
SAMPLER="fairmq-ex-1-n-1-sampler"
|
SAMPLER="fairmq-ex-1-n-1-sampler"
|
||||||
SAMPLER+=" --id sampler1"
|
SAMPLER+=" --id sampler1"
|
||||||
SAMPLER+=" --transport $transport"
|
SAMPLER+=" --transport $transport"
|
||||||
SAMPLER+=" --verbosity veryhigh"
|
SAMPLER+=" --verbosity veryhigh"
|
||||||
SAMPLER+=" --session $SESSION"
|
SAMPLER+=" --session $session"
|
||||||
|
SAMPLER+=" --severity debug"
|
||||||
|
SAMPLER+=" --shm-segment-size 100000000"
|
||||||
|
SAMPLER+=" --shm-monitor true"
|
||||||
SAMPLER+=" --control static --color false"
|
SAMPLER+=" --control static --color false"
|
||||||
SAMPLER+=" --max-iterations 2"
|
SAMPLER+=" --max-iterations 2"
|
||||||
SAMPLER+=" --mq-config $ex2config"
|
SAMPLER+=" --channel-config name=$chan1,type=push,method=bind,address=ipc://$chan1Addr,rateLogging=0"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||||
SAMPLER_PID=$!
|
SAMPLER_PID=$!
|
||||||
|
|
||||||
|
@ -29,10 +37,13 @@ PROCESSOR1="fairmq-ex-1-n-1-processor"
|
||||||
PROCESSOR1+=" --id processor1"
|
PROCESSOR1+=" --id processor1"
|
||||||
PROCESSOR1+=" --transport $transport"
|
PROCESSOR1+=" --transport $transport"
|
||||||
PROCESSOR1+=" --verbosity veryhigh"
|
PROCESSOR1+=" --verbosity veryhigh"
|
||||||
PROCESSOR1+=" --session $SESSION"
|
PROCESSOR1+=" --session $session"
|
||||||
|
PROCESSOR1+=" --severity debug"
|
||||||
|
PROCESSOR1+=" --shm-segment-size 100000000"
|
||||||
|
PROCESSOR1+=" --shm-monitor true"
|
||||||
PROCESSOR1+=" --control static --color false"
|
PROCESSOR1+=" --control static --color false"
|
||||||
PROCESSOR1+=" --mq-config $ex2config"
|
PROCESSOR1+=" --channel-config name=$chan1,type=pull,method=connect,address=ipc://$chan1Addr,rateLogging=0"
|
||||||
PROCESSOR1+=" --config-key processor"
|
PROCESSOR1+=" name=$chan2,type=push,method=connect,address=ipc://$chan2Addr,rateLogging=0"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR1 &
|
@CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR1 &
|
||||||
PROCESSOR1_PID=$!
|
PROCESSOR1_PID=$!
|
||||||
|
|
||||||
|
@ -40,10 +51,13 @@ PROCESSOR2="fairmq-ex-1-n-1-processor"
|
||||||
PROCESSOR2+=" --id processor2"
|
PROCESSOR2+=" --id processor2"
|
||||||
PROCESSOR2+=" --transport $transport"
|
PROCESSOR2+=" --transport $transport"
|
||||||
PROCESSOR2+=" --verbosity veryhigh"
|
PROCESSOR2+=" --verbosity veryhigh"
|
||||||
PROCESSOR2+=" --session $SESSION"
|
PROCESSOR2+=" --session $session"
|
||||||
|
PROCESSOR2+=" --severity debug"
|
||||||
|
PROCESSOR2+=" --shm-segment-size 100000000"
|
||||||
|
PROCESSOR2+=" --shm-monitor true"
|
||||||
PROCESSOR2+=" --control static --color false"
|
PROCESSOR2+=" --control static --color false"
|
||||||
PROCESSOR2+=" --mq-config $ex2config"
|
PROCESSOR2+=" --channel-config name=$chan1,type=pull,method=connect,address=ipc://$chan1Addr,rateLogging=0"
|
||||||
PROCESSOR2+=" --config-key processor"
|
PROCESSOR2+=" name=$chan2,type=push,method=connect,address=ipc://$chan2Addr,rateLogging=0"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR2 &
|
@CMAKE_CURRENT_BINARY_DIR@/$PROCESSOR2 &
|
||||||
PROCESSOR2_PID=$!
|
PROCESSOR2_PID=$!
|
||||||
|
|
||||||
|
@ -51,10 +65,13 @@ SINK="fairmq-ex-1-n-1-sink"
|
||||||
SINK+=" --id sink1"
|
SINK+=" --id sink1"
|
||||||
SINK+=" --transport $transport"
|
SINK+=" --transport $transport"
|
||||||
SINK+=" --verbosity veryhigh"
|
SINK+=" --verbosity veryhigh"
|
||||||
SINK+=" --session $SESSION"
|
SINK+=" --session $session"
|
||||||
|
SINK+=" --severity debug"
|
||||||
|
SINK+=" --shm-segment-size 100000000"
|
||||||
|
SINK+=" --shm-monitor true"
|
||||||
SINK+=" --control static --color false"
|
SINK+=" --control static --color false"
|
||||||
SINK+=" --max-iterations 2"
|
SINK+=" --max-iterations 2"
|
||||||
SINK+=" --mq-config $ex2config"
|
SINK+=" --channel-config name=$chan2,type=pull,method=bind,address=ipc://$chan2Addr,rateLogging=0"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
||||||
SINK_PID=$!
|
SINK_PID=$!
|
||||||
|
|
||||||
|
@ -69,3 +86,7 @@ kill -SIGINT $PROCESSOR2_PID
|
||||||
# wait for everything to finish
|
# wait for everything to finish
|
||||||
wait $PROCESSOR1_PID
|
wait $PROCESSOR1_PID
|
||||||
wait $PROCESSOR2_PID
|
wait $PROCESSOR2_PID
|
||||||
|
|
||||||
|
set +e
|
||||||
|
rm $chan1Addr; rm $chan2Addr
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,15 +1,145 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2018-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
set(exe_prefix "fairmq-ex")
|
||||||
|
set(script_prefix "fairmq-start-ex")
|
||||||
|
set(test_script_prefix "test-ex")
|
||||||
|
set(testsuite "Example")
|
||||||
|
set(transports "zeromq" "shmem")
|
||||||
|
|
||||||
|
function(add_example)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 0 ARG
|
||||||
|
"CONFIG;NO_TRANSPORT;NO_TEST"
|
||||||
|
"NAME"
|
||||||
|
"DEVICE;VARIANT;TRANSPORT;SCRIPT"
|
||||||
|
)
|
||||||
|
|
||||||
|
if(ARG_UNPARSED_ARGUMENTS)
|
||||||
|
message(FATAL_ERROR "Unexpected unparsed arguments: ${ARG_UNPARSED_ARGUMENTS}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ARG_NAME)
|
||||||
|
set(name ${ARG_NAME})
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "NAME arg is required")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ENABLE_SANITIZER_LEAK AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.22)
|
||||||
|
get_filename_component(lsan_supps "${CMAKE_SOURCE_DIR}/test/leak_sanitizer_suppressions.txt" ABSOLUTE)
|
||||||
|
set(lsan_options "LSAN_OPTIONS=set:suppressions=${lsan_supps}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ARG_DEVICE)
|
||||||
|
set(exe_targets)
|
||||||
|
foreach(device IN LISTS ARG_DEVICE)
|
||||||
|
set(exe "${exe_prefix}-${name}-${device}")
|
||||||
|
list(APPEND exe_targets ${exe})
|
||||||
|
add_executable(${exe} "${device}.cxx")
|
||||||
|
target_link_libraries(${exe} PRIVATE FairMQ)
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ARG_TRANSPORT)
|
||||||
|
set(transports ${ARG_TRANSPORT})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(ARG_SCRIPT)
|
||||||
|
set(scripts ${ARG_SCRIPT})
|
||||||
|
else()
|
||||||
|
set(scripts ${ARG_NAME})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
if(ARG_CONFIG)
|
||||||
|
set(EX_CONF_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
endif()
|
||||||
|
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
||||||
|
foreach(script IN LISTS scripts)
|
||||||
|
set(script_file "${script_prefix}-${script}.sh")
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${script_file}.in" "${CMAKE_CURRENT_BINARY_DIR}/${script_file}" @ONLY)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(ARG_CONFIG)
|
||||||
|
set(config "ex-${name}.json")
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${config}" "${CMAKE_CURRENT_BINARY_DIR}/${config}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# test
|
||||||
|
if(NOT ARG_NO_TEST)
|
||||||
|
set(test_script "${test_script_prefix}-${name}.sh")
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${test_script}.in" "${CMAKE_CURRENT_BINARY_DIR}/${test_script}")
|
||||||
|
|
||||||
|
if(ARG_NO_TRANSPORT)
|
||||||
|
set(test "${testsuite}.${name}.${transport}")
|
||||||
|
add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${test_script} ${transport})
|
||||||
|
set_tests_properties(${test} PROPERTIES TIMEOUT "30")
|
||||||
|
if(lsan_options)
|
||||||
|
set_tests_properties(${test} PROPERTIES ENVIRONMENT_MODIFICATION ${lsan_options})
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
foreach(transport IN LISTS transports)
|
||||||
|
if(ARG_VARIANT)
|
||||||
|
foreach(variant IN LISTS ARG_VARIANT)
|
||||||
|
set(test "${testsuite}.${name}.${variant}.${transport}")
|
||||||
|
add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${test_script} ${transport} ${variant})
|
||||||
|
set_tests_properties(${test} PROPERTIES TIMEOUT "30")
|
||||||
|
if(lsan_options)
|
||||||
|
set_tests_properties(${test} PROPERTIES ENVIRONMENT_MODIFICATION ${lsan_options})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
set(test "${testsuite}.${name}.${transport}")
|
||||||
|
add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${test_script} ${transport})
|
||||||
|
set_tests_properties(${test} PROPERTIES TIMEOUT "30")
|
||||||
|
if(lsan_options)
|
||||||
|
set_tests_properties(${test} PROPERTIES ENVIRONMENT_MODIFICATION ${lsan_options})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# install
|
||||||
|
install(
|
||||||
|
TARGETS ${exe_targets}
|
||||||
|
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
||||||
|
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# configure run script with different executable paths for build and for install directories
|
||||||
|
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
||||||
|
if(ARG_CONFIG)
|
||||||
|
set(EX_CONF_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_DATADIR})
|
||||||
|
endif()
|
||||||
|
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
||||||
|
foreach(script IN LISTS scripts)
|
||||||
|
set(script_file "${script_prefix}-${script}.sh")
|
||||||
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${script_file}.in" "${CMAKE_CURRENT_BINARY_DIR}/${script_file}_install" @ONLY)
|
||||||
|
install(
|
||||||
|
PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/${script_file}_install"
|
||||||
|
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
||||||
|
RENAME ${script_file}
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(ARG_CONFIG)
|
||||||
|
install(
|
||||||
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/${config}
|
||||||
|
DESTINATION ${PROJECT_INSTALL_DATADIR}
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
add_subdirectory(1-1)
|
add_subdirectory(1-1)
|
||||||
add_subdirectory(1-n-1)
|
add_subdirectory(1-n-1)
|
||||||
add_subdirectory(builtin-devices)
|
add_subdirectory(builtin-devices)
|
||||||
add_subdirectory(copypush)
|
add_subdirectory(copypush)
|
||||||
|
add_subdirectory(custom-controller)
|
||||||
add_subdirectory(dds)
|
add_subdirectory(dds)
|
||||||
add_subdirectory(multipart)
|
add_subdirectory(multipart)
|
||||||
add_subdirectory(multiple-channels)
|
add_subdirectory(multiple-channels)
|
||||||
|
|
|
@ -1,40 +1,11 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
add_example(NAME builtin-devices
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
VARIANT single_msg multipart
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-builtin-devices.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-builtin-devices.sh)
|
|
||||||
|
|
||||||
# test
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-builtin-devices.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh)
|
|
||||||
|
|
||||||
add_test(NAME Example.BuiltinDevices.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh zeromq)
|
|
||||||
set_tests_properties(Example.BuiltinDevices.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
|
||||||
|
|
||||||
add_test(NAME Example.BuiltinDevices.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh shmem)
|
|
||||||
set_tests_properties(Example.BuiltinDevices.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
|
||||||
|
|
||||||
add_test(NAME Example.BuiltinDevices.multipart.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh zeromq true 2)
|
|
||||||
set_tests_properties(Example.BuiltinDevices.multipart.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
|
||||||
|
|
||||||
add_test(NAME Example.BuiltinDevices.multipart.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-builtin-devices.sh shmem true 2)
|
|
||||||
set_tests_properties(Example.BuiltinDevices.multipart.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Configured maximum number of iterations reached")
|
|
||||||
|
|
||||||
# install
|
|
||||||
|
|
||||||
# configure run script with different executable paths for build and for install directories
|
|
||||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-builtin-devices.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-builtin-devices.sh_install)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-builtin-devices.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-builtin-devices.sh
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
set -e
|
||||||
|
|
||||||
SESSION="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
transport="zeromq"
|
transport="zeromq"
|
||||||
multipart="false"
|
multipart="false"
|
||||||
|
@ -12,16 +12,27 @@ if [[ $1 =~ ^[a-z]+$ ]]; then
|
||||||
transport=$1
|
transport=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $2 =~ ^[a-z]+$ ]]; then
|
if [[ $2 =~ ^multipart$ ]]; then
|
||||||
multipart=$2
|
multipart="true"
|
||||||
|
numParts=2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $3 =~ ^[0-9]+$ ]]; then
|
session="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
||||||
numParts=$3
|
chan1="data1"
|
||||||
fi
|
chan2="data2"
|
||||||
|
chan3="data3"
|
||||||
|
chan4="data4"
|
||||||
|
chan5="data5"
|
||||||
|
chan1Addr="/tmp/fmq_$session""_""$chan1""_""$transport"
|
||||||
|
chan2Addr1="/tmp/fmq_$session""_""$chan2""_1""_""$transport"
|
||||||
|
chan2Addr2="/tmp/fmq_$session""_""$chan2""_2""_""$transport"
|
||||||
|
chan3Addr1="/tmp/fmq_$session""_""$chan3""_1""_""$transport"
|
||||||
|
chan3Addr2="/tmp/fmq_$session""_""$chan3""_2""_""$transport"
|
||||||
|
chan4Addr="/tmp/fmq_$session""_""$chan4""_""$transport"
|
||||||
|
chan5Addr="/tmp/fmq_$session""_""$chan5""_""$transport"
|
||||||
|
|
||||||
# setup a trap to kill everything if the test fails/timeouts
|
# setup a trap to kill everything if the test fails/timeouts
|
||||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SPLITTER_PID; kill -TERM $PROXY1_PID; kill -TERM $PROXY2_PID; kill -TERM $MERGER_PID; kill -TERM $MULTIPLIER_PID; kill -TERM $SINK_PID;' TERM
|
trap 'set +e; kill -TERM $SAMPLER_PID; kill -TERM $SPLITTER_PID; kill -TERM $PROXY1_PID; kill -TERM $PROXY2_PID; kill -TERM $MERGER_PID; kill -TERM $MULTIPLIER_PID; kill -TERM $SINK_PID; rm $chan1Addr; rm $chan2Addr1; rm $chan2Addr2; rm $chan3Addr1; rm $chan3Addr2; rm $chan4Addr; rm $chan5Addr; exit 0' TERM
|
||||||
|
|
||||||
SAMPLER="fairmq-bsampler"
|
SAMPLER="fairmq-bsampler"
|
||||||
SAMPLER+=" --id bsampler1"
|
SAMPLER+=" --id bsampler1"
|
||||||
|
@ -30,14 +41,16 @@ SAMPLER+=" --transport $transport"
|
||||||
SAMPLER+=" --color false"
|
SAMPLER+=" --color false"
|
||||||
SAMPLER+=" --control static"
|
SAMPLER+=" --control static"
|
||||||
SAMPLER+=" --verbosity veryhigh"
|
SAMPLER+=" --verbosity veryhigh"
|
||||||
|
SAMPLER+=" --shm-segment-size 100000000"
|
||||||
|
SAMPLER+=" --shm-monitor true"
|
||||||
SAMPLER+=" --severity debug"
|
SAMPLER+=" --severity debug"
|
||||||
SAMPLER+=" --msg-size 100000"
|
SAMPLER+=" --msg-size 100000"
|
||||||
SAMPLER+=" --multipart $multipart"
|
SAMPLER+=" --multipart $multipart"
|
||||||
SAMPLER+=" --num-parts $numParts"
|
SAMPLER+=" --num-parts $numParts"
|
||||||
SAMPLER+=" --msg-rate 1"
|
SAMPLER+=" --msg-rate 1"
|
||||||
SAMPLER+=" --max-iterations 0"
|
SAMPLER+=" --max-iterations 0"
|
||||||
SAMPLER+=" --out-channel data1"
|
SAMPLER+=" --out-channel $chan1"
|
||||||
SAMPLER+=" --channel-config name=data1,type=push,method=bind,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5555"
|
SAMPLER+=" --channel-config name=$chan1,type=push,method=bind,sndBufSize=50,rcvBufSize=50,address=ipc://$chan1Addr"
|
||||||
@FAIRMQ_BIN_DIR@/$SAMPLER &
|
@FAIRMQ_BIN_DIR@/$SAMPLER &
|
||||||
SAMPLER_PID=$!
|
SAMPLER_PID=$!
|
||||||
|
|
||||||
|
@ -48,11 +61,13 @@ SPLITTER+=" --transport $transport"
|
||||||
SPLITTER+=" --color false"
|
SPLITTER+=" --color false"
|
||||||
SPLITTER+=" --control static"
|
SPLITTER+=" --control static"
|
||||||
SPLITTER+=" --verbosity veryhigh"
|
SPLITTER+=" --verbosity veryhigh"
|
||||||
|
SPLITTER+=" --shm-segment-size 100000000"
|
||||||
|
SPLITTER+=" --shm-monitor true"
|
||||||
SPLITTER+=" --multipart $multipart"
|
SPLITTER+=" --multipart $multipart"
|
||||||
SPLITTER+=" --in-channel data1"
|
SPLITTER+=" --in-channel $chan1"
|
||||||
SPLITTER+=" --out-channel data2"
|
SPLITTER+=" --out-channel $chan2"
|
||||||
SPLITTER+=" --channel-config name=data1,type=pull,method=connect,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5555"
|
SPLITTER+=" --channel-config name=$chan1,type=pull,method=connect,sndBufSize=50,rcvBufSize=50,address=ipc://$chan1Addr"
|
||||||
SPLITTER+=" name=data2,type=push,method=bind,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5556,address=tcp://localhost:5557"
|
SPLITTER+=" name=$chan2,type=push,method=bind,sndBufSize=50,rcvBufSize=50,address=ipc://$chan2Addr1,address=ipc://$chan2Addr2"
|
||||||
@FAIRMQ_BIN_DIR@/$SPLITTER &
|
@FAIRMQ_BIN_DIR@/$SPLITTER &
|
||||||
SPLITTER_PID=$!
|
SPLITTER_PID=$!
|
||||||
|
|
||||||
|
@ -63,11 +78,13 @@ PROXY1+=" --transport $transport"
|
||||||
PROXY1+=" --color false"
|
PROXY1+=" --color false"
|
||||||
PROXY1+=" --control static"
|
PROXY1+=" --control static"
|
||||||
PROXY1+=" --verbosity veryhigh"
|
PROXY1+=" --verbosity veryhigh"
|
||||||
|
PROXY1+=" --shm-segment-size 100000000"
|
||||||
|
PROXY1+=" --shm-monitor true"
|
||||||
PROXY1+=" --multipart $multipart"
|
PROXY1+=" --multipart $multipart"
|
||||||
PROXY1+=" --in-channel data2"
|
PROXY1+=" --in-channel $chan2"
|
||||||
PROXY1+=" --out-channel data3"
|
PROXY1+=" --out-channel $chan3"
|
||||||
PROXY1+=" --channel-config name=data2,type=pull,method=connect,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5556"
|
PROXY1+=" --channel-config name=$chan2,type=pull,method=connect,sndBufSize=50,rcvBufSize=50,address=ipc://$chan2Addr1"
|
||||||
PROXY1+=" name=data3,type=push,method=connect,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5558"
|
PROXY1+=" name=$chan3,type=push,method=connect,sndBufSize=50,rcvBufSize=50,address=ipc://$chan3Addr1"
|
||||||
@FAIRMQ_BIN_DIR@/$PROXY1 &
|
@FAIRMQ_BIN_DIR@/$PROXY1 &
|
||||||
PROXY1_PID=$!
|
PROXY1_PID=$!
|
||||||
|
|
||||||
|
@ -78,11 +95,13 @@ PROXY2+=" --transport $transport"
|
||||||
PROXY2+=" --color false"
|
PROXY2+=" --color false"
|
||||||
PROXY2+=" --control static"
|
PROXY2+=" --control static"
|
||||||
PROXY2+=" --verbosity veryhigh"
|
PROXY2+=" --verbosity veryhigh"
|
||||||
|
PROXY2+=" --shm-segment-size 100000000"
|
||||||
|
PROXY2+=" --shm-monitor true"
|
||||||
PROXY2+=" --multipart $multipart"
|
PROXY2+=" --multipart $multipart"
|
||||||
PROXY2+=" --in-channel data2"
|
PROXY2+=" --in-channel $chan2"
|
||||||
PROXY2+=" --out-channel data3"
|
PROXY2+=" --out-channel $chan3"
|
||||||
PROXY2+=" --channel-config name=data2,type=pull,method=connect,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5557"
|
PROXY2+=" --channel-config name=$chan2,type=pull,method=connect,sndBufSize=50,rcvBufSize=50,address=ipc://$chan2Addr2"
|
||||||
PROXY2+=" name=data3,type=push,method=connect,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5559"
|
PROXY2+=" name=$chan3,type=push,method=connect,sndBufSize=50,rcvBufSize=50,address=ipc://$chan3Addr2"
|
||||||
@FAIRMQ_BIN_DIR@/$PROXY2 &
|
@FAIRMQ_BIN_DIR@/$PROXY2 &
|
||||||
PROXY2_PID=$!
|
PROXY2_PID=$!
|
||||||
|
|
||||||
|
@ -93,11 +112,13 @@ MERGER+=" --transport $transport"
|
||||||
MERGER+=" --color false"
|
MERGER+=" --color false"
|
||||||
MERGER+=" --control static"
|
MERGER+=" --control static"
|
||||||
MERGER+=" --verbosity veryhigh"
|
MERGER+=" --verbosity veryhigh"
|
||||||
|
MERGER+=" --shm-segment-size 100000000"
|
||||||
|
MERGER+=" --shm-monitor true"
|
||||||
MERGER+=" --multipart $multipart"
|
MERGER+=" --multipart $multipart"
|
||||||
MERGER+=" --in-channel data3"
|
MERGER+=" --in-channel $chan3"
|
||||||
MERGER+=" --out-channel data4"
|
MERGER+=" --out-channel $chan4"
|
||||||
MERGER+=" --channel-config name=data3,type=pull,method=bind,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5558,address=tcp://localhost:5559"
|
MERGER+=" --channel-config name=$chan3,type=pull,method=bind,sndBufSize=50,rcvBufSize=50,address=ipc://$chan3Addr1,address=ipc://$chan3Addr2"
|
||||||
MERGER+=" name=data4,type=push,method=connect,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5560"
|
MERGER+=" name=$chan4,type=push,method=connect,sndBufSize=50,rcvBufSize=50,address=ipc://$chan4Addr"
|
||||||
@FAIRMQ_BIN_DIR@/$MERGER &
|
@FAIRMQ_BIN_DIR@/$MERGER &
|
||||||
MERGER_PID=$!
|
MERGER_PID=$!
|
||||||
|
|
||||||
|
@ -108,11 +129,13 @@ MULTIPLIER+=" --transport $transport"
|
||||||
MULTIPLIER+=" --color false"
|
MULTIPLIER+=" --color false"
|
||||||
MULTIPLIER+=" --control static"
|
MULTIPLIER+=" --control static"
|
||||||
MULTIPLIER+=" --verbosity veryhigh"
|
MULTIPLIER+=" --verbosity veryhigh"
|
||||||
|
MULTIPLIER+=" --shm-segment-size 100000000"
|
||||||
|
MULTIPLIER+=" --shm-monitor true"
|
||||||
MULTIPLIER+=" --multipart $multipart"
|
MULTIPLIER+=" --multipart $multipart"
|
||||||
MULTIPLIER+=" --in-channel data4"
|
MULTIPLIER+=" --in-channel $chan4"
|
||||||
MULTIPLIER+=" --out-channel data5"
|
MULTIPLIER+=" --out-channel $chan5"
|
||||||
MULTIPLIER+=" --channel-config name=data4,type=pull,method=bind,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5560"
|
MULTIPLIER+=" --channel-config name=$chan4,type=pull,method=bind,sndBufSize=50,rcvBufSize=50,address=ipc://$chan4Addr"
|
||||||
MULTIPLIER+=" name=data5,type=push,method=connect,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5561,address=tcp://localhost:5561"
|
MULTIPLIER+=" name=$chan5,type=push,method=connect,sndBufSize=50,rcvBufSize=50,address=ipc://$chan5Addr,address=ipc://$chan5Addr"
|
||||||
@FAIRMQ_BIN_DIR@/$MULTIPLIER &
|
@FAIRMQ_BIN_DIR@/$MULTIPLIER &
|
||||||
MULTIPLIER_PID=$!
|
MULTIPLIER_PID=$!
|
||||||
|
|
||||||
|
@ -125,9 +148,10 @@ SINK+=" --control static"
|
||||||
SINK+=" --verbosity veryhigh"
|
SINK+=" --verbosity veryhigh"
|
||||||
SINK+=" --severity debug"
|
SINK+=" --severity debug"
|
||||||
SINK+=" --multipart $multipart"
|
SINK+=" --multipart $multipart"
|
||||||
|
SINK+=" --shm-monitor true"
|
||||||
SINK+=" --max-iterations 2"
|
SINK+=" --max-iterations 2"
|
||||||
SINK+=" --in-channel data5"
|
SINK+=" --in-channel $chan5"
|
||||||
SINK+=" --channel-config name=data5,type=pull,method=bind,sndBufSize=50,rcvBufSize=50,address=tcp://localhost:5561"
|
SINK+=" --channel-config name=$chan5,type=pull,method=bind,sndBufSize=50,rcvBufSize=50,address=ipc://$chan5Addr"
|
||||||
@FAIRMQ_BIN_DIR@/$SINK &
|
@FAIRMQ_BIN_DIR@/$SINK &
|
||||||
SINK_PID=$!
|
SINK_PID=$!
|
||||||
|
|
||||||
|
@ -146,3 +170,7 @@ wait $PROXY1_PID
|
||||||
wait $PROXY2_PID
|
wait $PROXY2_PID
|
||||||
wait $MERGER_PID
|
wait $MERGER_PID
|
||||||
wait $MULTIPLIER_PID
|
wait $MULTIPLIER_PID
|
||||||
|
|
||||||
|
set +e
|
||||||
|
rm $chan1Addr; rm $chan2Addr1; rm $chan2Addr2; rm $chan3Addr1; rm $chan3Addr2; rm $chan4Addr; rm $chan5Addr
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,52 +1,11 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
add_example(NAME copypush
|
||||||
add_executable(fairmq-ex-copypush-sampler sampler.cxx)
|
DEVICE sampler sink
|
||||||
target_link_libraries(fairmq-ex-copypush-sampler PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_executable(fairmq-ex-copypush-sink sink.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-copypush-sink PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_custom_target(ExampleCopyPush DEPENDS fairmq-ex-copypush-sampler fairmq-ex-copypush-sink)
|
|
||||||
|
|
||||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-copypush.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-copypush.sh)
|
|
||||||
|
|
||||||
# test
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-copypush.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh)
|
|
||||||
|
|
||||||
add_test(NAME Example.CopyPush.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh zeromq)
|
|
||||||
set_tests_properties(Example.CopyPush.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message: ")
|
|
||||||
|
|
||||||
add_test(NAME Example.CopyPush.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-copypush.sh shmem)
|
|
||||||
set_tests_properties(Example.CopyPush.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message: ")
|
|
||||||
|
|
||||||
# install
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
fairmq-ex-copypush-sampler
|
|
||||||
fairmq-ex-copypush-sink
|
|
||||||
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# configure run script with different executable paths for build and for install directories
|
|
||||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-copypush.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-copypush.sh_install)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-copypush.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-copypush.sh
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -19,7 +19,7 @@ struct Sampler : fair::mq::Device
|
||||||
{
|
{
|
||||||
void InitTask() override
|
void InitTask() override
|
||||||
{
|
{
|
||||||
fNumDataChannels = fChannels.at("data").size();
|
fNumDataChannels = GetNumSubChannels("data");
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ struct Sampler : fair::mq::Device
|
||||||
{
|
{
|
||||||
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
|
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
|
||||||
// Should only be used for small data because of the cost of an additional copy
|
// Should only be used for small data because of the cost of an additional copy
|
||||||
FairMQMessagePtr msg(NewSimpleMessage(fCounter++));
|
fair::mq::MessagePtr msg(NewSimpleMessage(fCounter++));
|
||||||
|
|
||||||
for (int i = 0; i < fNumDataChannels - 1; ++i) {
|
for (int i = 0; i < fNumDataChannels - 1; ++i) {
|
||||||
FairMQMessagePtr msgCopy(NewMessage());
|
fair::mq::MessagePtr msgCopy(NewMessage());
|
||||||
msgCopy->Copy(*msg);
|
msgCopy->Copy(*msg);
|
||||||
Send(msgCopy, "data", i);
|
Send(msgCopy, "data", i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct Sink : fair::mq::Device
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int)
|
bool HandleData(fair::mq::MessagePtr& msg, int)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received message: \"" << *(static_cast<uint64_t*>(msg->GetData())) << "\"";
|
LOG(info) << "Received message: \"" << *(static_cast<uint64_t*>(msg->GetData())) << "\"";
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
transport="zeromq"
|
transport="zeromq"
|
||||||
|
@ -8,19 +10,25 @@ if [[ $1 =~ ^[a-z]+$ ]]; then
|
||||||
transport=$1
|
transport=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SESSION="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
session="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
||||||
|
chan="data"
|
||||||
|
chanAddr1="/tmp/fmq_$session""_""$chan""_1""_""$transport"
|
||||||
|
chanAddr2="/tmp/fmq_$session""_""$chan""_2""_""$transport"
|
||||||
|
|
||||||
# setup a trap to kill everything if the test fails/timeouts
|
# setup a trap to kill everything if the test fails/timeouts
|
||||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK1_PID; kill -TERM $SINK2_PID; wait $SAMPLER_PID; wait $SINK1_PID; wait $SINK2_PID;' TERM
|
trap 'set +e; kill -TERM $SAMPLER_PID; kill -TERM $SINK1_PID; kill -TERM $SINK2_PID; wait $SAMPLER_PID; wait $SINK1_PID; wait $SINK2_PID; rm $chanAddr1; rm $chanAddr2; exit 0' TERM
|
||||||
|
|
||||||
SAMPLER="fairmq-ex-copypush-sampler"
|
SAMPLER="fairmq-ex-copypush-sampler"
|
||||||
SAMPLER+=" --id sampler1"
|
SAMPLER+=" --id sampler1"
|
||||||
SAMPLER+=" --transport $transport"
|
SAMPLER+=" --transport $transport"
|
||||||
SAMPLER+=" --verbosity veryhigh"
|
SAMPLER+=" --verbosity veryhigh"
|
||||||
SAMPLER+=" --session $SESSION"
|
SAMPLER+=" --severity debug"
|
||||||
|
SAMPLER+=" --shm-segment-size 100000000"
|
||||||
|
SAMPLER+=" --shm-monitor true"
|
||||||
|
SAMPLER+=" --session $session"
|
||||||
SAMPLER+=" --control static --color false"
|
SAMPLER+=" --control static --color false"
|
||||||
SAMPLER+=" --max-iterations 1"
|
SAMPLER+=" --max-iterations 1"
|
||||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,rateLogging=0,address=tcp://*:5555,address=tcp://*:5556"
|
SAMPLER+=" --channel-config name=$chan,type=push,method=bind,rateLogging=0,address=ipc://$chanAddr1,address=ipc://$chanAddr2"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||||
SAMPLER_PID=$!
|
SAMPLER_PID=$!
|
||||||
|
|
||||||
|
@ -28,10 +36,13 @@ SINK1="fairmq-ex-copypush-sink"
|
||||||
SINK1+=" --id sink1"
|
SINK1+=" --id sink1"
|
||||||
SINK1+=" --transport $transport"
|
SINK1+=" --transport $transport"
|
||||||
SINK1+=" --verbosity veryhigh"
|
SINK1+=" --verbosity veryhigh"
|
||||||
SINK1+=" --session $SESSION"
|
SINK1+=" --severity debug"
|
||||||
|
SINK1+=" --shm-segment-size 100000000"
|
||||||
|
SINK1+=" --shm-monitor true"
|
||||||
|
SINK1+=" --session $session"
|
||||||
SINK1+=" --control static --color false"
|
SINK1+=" --control static --color false"
|
||||||
SINK1+=" --max-iterations 1"
|
SINK1+=" --max-iterations 1"
|
||||||
SINK1+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5555"
|
SINK1+=" --channel-config name=$chan,type=pull,method=connect,rateLogging=0,address=ipc://$chanAddr1"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK1 &
|
@CMAKE_CURRENT_BINARY_DIR@/$SINK1 &
|
||||||
SINK1_PID=$!
|
SINK1_PID=$!
|
||||||
|
|
||||||
|
@ -39,10 +50,13 @@ SINK2="fairmq-ex-copypush-sink"
|
||||||
SINK2+=" --id sink2"
|
SINK2+=" --id sink2"
|
||||||
SINK2+=" --transport $transport"
|
SINK2+=" --transport $transport"
|
||||||
SINK2+=" --verbosity veryhigh"
|
SINK2+=" --verbosity veryhigh"
|
||||||
SINK2+=" --session $SESSION"
|
SINK2+=" --severity debug"
|
||||||
|
SINK2+=" --shm-segment-size 100000000"
|
||||||
|
SINK2+=" --shm-monitor true"
|
||||||
|
SINK2+=" --session $session"
|
||||||
SINK2+=" --control static --color false"
|
SINK2+=" --control static --color false"
|
||||||
SINK2+=" --max-iterations 1"
|
SINK2+=" --max-iterations 1"
|
||||||
SINK2+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5556"
|
SINK2+=" --channel-config name=$chan,type=pull,method=connect,rateLogging=0,address=ipc://$chanAddr2"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK2 &
|
@CMAKE_CURRENT_BINARY_DIR@/$SINK2 &
|
||||||
SINK2_PID=$!
|
SINK2_PID=$!
|
||||||
|
|
||||||
|
@ -50,3 +64,7 @@ SINK2_PID=$!
|
||||||
wait $SAMPLER_PID
|
wait $SAMPLER_PID
|
||||||
wait $SINK1_PID
|
wait $SINK1_PID
|
||||||
wait $SINK2_PID
|
wait $SINK2_PID
|
||||||
|
|
||||||
|
set +e
|
||||||
|
rm $chanAddr1; rm $chanAddr2
|
||||||
|
exit 0
|
||||||
|
|
20
examples/custom-controller/CMakeLists.txt
Normal file
20
examples/custom-controller/CMakeLists.txt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
################################################################################
|
||||||
|
# Copyright (C) 2022-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
|
# #
|
||||||
|
# This software is distributed under the terms of the #
|
||||||
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
|
# copied verbatim in the file "LICENSE" #
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
set(name "custom-controller")
|
||||||
|
set(exe "${exe_prefix}-${name}")
|
||||||
|
add_executable(${exe} main.cxx)
|
||||||
|
target_link_libraries(${exe} PRIVATE FairMQ)
|
||||||
|
set_target_properties(${exe} PROPERTIES ENABLE_EXPORTS ON)
|
||||||
|
|
||||||
|
set(test "${testsuite}.${name}")
|
||||||
|
add_test(NAME ${test} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${exe})
|
||||||
|
set_tests_properties(${test} PROPERTIES TIMEOUT 30)
|
||||||
|
if(lsan_options)
|
||||||
|
set_tests_properties(${test} PROPERTIES ENVIRONMENT_MODIFICATION ${lsan_options})
|
||||||
|
endif()
|
97
examples/custom-controller/MyController.h
Normal file
97
examples/custom-controller/MyController.h
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
|
* *
|
||||||
|
* This software is distributed under the terms of the *
|
||||||
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
|
* copied verbatim in the file "LICENSE" *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#ifndef FAIR_MQ_EXAMPLE_CUSTOM_CONTROLLER_PLUGIN
|
||||||
|
#define FAIR_MQ_EXAMPLE_CUSTOM_CONTROLLER_PLUGIN
|
||||||
|
|
||||||
|
#include <fairmq/Plugin.h>
|
||||||
|
#include <utility> // for std::forward
|
||||||
|
|
||||||
|
namespace example {
|
||||||
|
|
||||||
|
struct MyController : fair::mq::Plugin // NOLINT
|
||||||
|
{
|
||||||
|
template<typename... Args>
|
||||||
|
MyController(Args&&... args)
|
||||||
|
: Plugin(std::forward<Args>(args)...)
|
||||||
|
{
|
||||||
|
TakeDeviceControl();
|
||||||
|
|
||||||
|
SubscribeToDeviceStateChange([this](auto state) {
|
||||||
|
auto shutdown = GetProperty<bool>("please-shut-me-down", false);
|
||||||
|
try {
|
||||||
|
switch (state) {
|
||||||
|
case DeviceState::Idle: {
|
||||||
|
ChangeDeviceState(shutdown ? DeviceStateTransition::End
|
||||||
|
: DeviceStateTransition::InitDevice);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DeviceState::InitializingDevice: {
|
||||||
|
ChangeDeviceState(DeviceStateTransition::CompleteInit);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DeviceState::Initialized: {
|
||||||
|
ChangeDeviceState(DeviceStateTransition::Bind);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DeviceState::Bound: {
|
||||||
|
ChangeDeviceState(DeviceStateTransition::Connect);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DeviceState::DeviceReady: {
|
||||||
|
ChangeDeviceState(shutdown ? DeviceStateTransition::ResetDevice
|
||||||
|
: DeviceStateTransition::InitTask);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DeviceState::Ready: {
|
||||||
|
ChangeDeviceState(shutdown ? DeviceStateTransition::ResetTask
|
||||||
|
: DeviceStateTransition::Run);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DeviceState::Running: {
|
||||||
|
ChangeDeviceState(DeviceStateTransition::Stop);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DeviceState::Exiting: {
|
||||||
|
ReleaseDeviceControl();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (fair::mq::PluginServices::DeviceControlError const&) {
|
||||||
|
// this means we do not have device control
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
~MyController() override { ReleaseDeviceControl(); }
|
||||||
|
};
|
||||||
|
|
||||||
|
// auto MyControllerProgramOptions() -> fair::mq::Plugin::ProgOptions
|
||||||
|
// {
|
||||||
|
// auto plugin_options = boost::program_options::options_description{"MyController Plugin"};
|
||||||
|
// plugin_options.add_options()
|
||||||
|
// ("custom-dummy-option", boost::program_options::value<std::string>(), "Cool custom option.")
|
||||||
|
// ("custom-dummy-option2", boost::program_options::value<std::string>(), "Another one.");
|
||||||
|
// return plugin_options;
|
||||||
|
// }
|
||||||
|
|
||||||
|
} // namespace example
|
||||||
|
|
||||||
|
REGISTER_FAIRMQ_PLUGIN(example::MyController, // Class name
|
||||||
|
mycontroller, // Plugin name (string, lower case chars only)
|
||||||
|
(fair::mq::Plugin::Version{0, 42, 0}), // Version
|
||||||
|
"Mr. Dummy <dummy@test.net>", // Maintainer
|
||||||
|
"https://git.test.net/mycontroller.git", // Homepage
|
||||||
|
// example::MyControllerProgramOptions // Free
|
||||||
|
// function which declares custom
|
||||||
|
// program options for the plugin
|
||||||
|
fair::mq::Plugin::NoProgramOptions)
|
||||||
|
|
||||||
|
#endif /* FAIR_MQ_EXAMPLE_CUSTOM_CONTROLLER_PLUGIN */
|
|
@ -1,9 +1,21 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2018 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
* copied verbatim in the file "LICENSE" *
|
* copied verbatim in the file "LICENSE" *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include <FairMQSocket.h>
|
#ifndef FAIR_MQ_EXAMPLE_CUSTOM_CONTROLLER_DEVICE
|
||||||
|
#define FAIR_MQ_EXAMPLE_CUSTOM_CONTROLLER_DEVICE
|
||||||
|
|
||||||
|
#include <fairmq/Device.h>
|
||||||
|
|
||||||
|
namespace example {
|
||||||
|
|
||||||
|
using MyDevice = fair::mq::Device;
|
||||||
|
|
||||||
|
} // namespace example
|
||||||
|
|
||||||
|
#endif /* FAIR_MQ_EXAMPLE_CUSTOM_CONTROLLER_DEVICE */
|
||||||
|
|
46
examples/custom-controller/main.cxx
Normal file
46
examples/custom-controller/main.cxx
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (C) 2022 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
|
* *
|
||||||
|
* This software is distributed under the terms of the *
|
||||||
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
|
* copied verbatim in the file "LICENSE" *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include "MyController.h"
|
||||||
|
#include "MyDevice.h"
|
||||||
|
|
||||||
|
#include <chrono> // for std::chrono_literals
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
#include <fairmq/DeviceRunner.h>
|
||||||
|
#include <memory> // for std::make_unique
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
using namespace fair::mq;
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
|
DeviceRunner runner(argc, argv);
|
||||||
|
|
||||||
|
runner.AddHook<hooks::LoadPlugins>([](DeviceRunner& r) {
|
||||||
|
r.fPluginManager.LoadPlugin("s:mycontroller");
|
||||||
|
// 's:' stands for static because the plugin is compiled into the executable
|
||||||
|
// 'mycontroller' is the plugin name passed as second arg to REGISTER_FAIRMQ_PLUGIN
|
||||||
|
});
|
||||||
|
|
||||||
|
fair::Logger::SetConsoleSeverity(fair::Severity::debug);
|
||||||
|
|
||||||
|
runner.AddHook<hooks::InstantiateDevice>([](DeviceRunner& r) {
|
||||||
|
r.fConfig.SetProperty<int>("catch-signals", 0);
|
||||||
|
r.fConfig.SetProperty<bool>("please-shut-me-down", false);
|
||||||
|
r.fDevice = std::make_unique<example::MyDevice>(r.fConfig);
|
||||||
|
|
||||||
|
r.fDevice->SubscribeToStateChange("example", [&r](auto state) {
|
||||||
|
if (state == State::Running) {
|
||||||
|
r.fDevice->WaitFor(3s);
|
||||||
|
r.fConfig.SetProperty<bool>("please-shut-me-down", true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return runner.RunWithExceptionHandlers();
|
||||||
|
}
|
|
@ -20,7 +20,7 @@ struct Processor : fair::mq::Device
|
||||||
OnData("data1", &Processor::HandleData);
|
OnData("data1", &Processor::HandleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int)
|
bool HandleData(fair::mq::MessagePtr& msg, int)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received data, processing...";
|
LOG(info) << "Received data, processing...";
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ struct Processor : fair::mq::Device
|
||||||
// its size,
|
// its size,
|
||||||
// custom deletion function (called when transfer is done),
|
// custom deletion function (called when transfer is done),
|
||||||
// and pointer to the object managing the data buffer
|
// and pointer to the object managing the data buffer
|
||||||
FairMQMessagePtr msg2(NewMessage(const_cast<char*>(text->c_str()),
|
fair::mq::MessagePtr msg2(NewMessage(const_cast<char*>(text->c_str()),
|
||||||
text->length(),
|
text->length(),
|
||||||
[](void* /*data*/, void* object) { delete static_cast<std::string*>(object); },
|
[](void* /*data*/, void* object) { delete static_cast<std::string*>(object); },
|
||||||
text));
|
text));
|
||||||
|
|
|
@ -24,7 +24,7 @@ struct Sampler : fair::mq::Device
|
||||||
{
|
{
|
||||||
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
|
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
|
||||||
// Should only be used for small data because of the cost of an additional copy
|
// Should only be used for small data because of the cost of an additional copy
|
||||||
FairMQMessagePtr msg(NewSimpleMessage("Data"));
|
fair::mq::MessagePtr msg(NewSimpleMessage("Data"));
|
||||||
|
|
||||||
LOG(info) << "Sending \"Data\"";
|
LOG(info) << "Sending \"Data\"";
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ struct Sink : fair::mq::Device
|
||||||
fIterations = fConfig->GetValue<uint64_t>("iterations");
|
fIterations = fConfig->GetValue<uint64_t>("iterations");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int)
|
bool HandleData(fair::mq::MessagePtr& msg, int)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
LOG(info) << "Received: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||||
|
|
||||||
|
|
|
@ -1,56 +1,11 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
add_executable(fairmq-ex-multipart-sampler sampler.cxx)
|
add_example(NAME multipart
|
||||||
target_link_libraries(fairmq-ex-multipart-sampler PRIVATE FairMQ)
|
DEVICE sampler sink
|
||||||
|
|
||||||
add_executable(fairmq-ex-multipart-sink sink.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-multipart-sink PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_custom_target(ExampleMultipart DEPENDS fairmq-ex-multipart-sampler fairmq-ex-multipart-sink)
|
|
||||||
|
|
||||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multipart.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multipart.sh)
|
|
||||||
|
|
||||||
# test
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-multipart.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh)
|
|
||||||
|
|
||||||
add_test(NAME Example.Multipart.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh zeromq)
|
|
||||||
set_tests_properties(Example.Multipart.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message with 7 parts")
|
|
||||||
|
|
||||||
add_test(NAME Example.Multipart.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh shmem)
|
|
||||||
set_tests_properties(Example.Multipart.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message with 7 parts")
|
|
||||||
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
|
||||||
add_test(NAME Example.Multipart.ofi COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multipart.sh ofi)
|
|
||||||
set_tests_properties(Example.Multipart.ofi PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received message with 7 parts")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# install
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
fairmq-ex-multipart-sampler
|
|
||||||
fairmq-ex-multipart-sink
|
|
||||||
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# configure run script with different executable paths for build and for install directories
|
|
||||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multipart.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multipart.sh_install)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multipart.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-multipart.sh
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@ A topology of two devices - Sampler and Sink, communicating with PUSH-PULL patte
|
||||||
|
|
||||||
The Sampler sends a multipart message to the Sink, consisting of two message parts - header and body.
|
The Sampler sends a multipart message to the Sink, consisting of two message parts - header and body.
|
||||||
|
|
||||||
Each message part is a regular FairMQMessage. To combine them into a multi-part message use `FairMQParts`. Add messages to `FairMQParts` with `AddPart` method.
|
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.
|
All parts are guaranteed to be delivered together. The Receive call in the sink will recive the entire parts structure.
|
||||||
|
|
||||||
|
|
|
@ -35,15 +35,15 @@ struct Sampler : fair::mq::Device
|
||||||
}
|
}
|
||||||
LOG(info) << "Sending header with stopFlag: " << header.stopFlag;
|
LOG(info) << "Sending header with stopFlag: " << header.stopFlag;
|
||||||
|
|
||||||
FairMQParts parts;
|
fair::mq::Parts parts;
|
||||||
|
|
||||||
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
|
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
|
||||||
// Should only be used for small data because of the cost of an additional copy
|
// Should only be used for small data because of the cost of an additional copy
|
||||||
parts.AddPart(NewSimpleMessage(header));
|
parts.AddPart(NewSimpleMessage(header));
|
||||||
parts.AddPart(NewMessage(1000));
|
parts.AddPart(NewMessage(1000));
|
||||||
|
|
||||||
// create more data parts, testing the FairMQParts in-place constructor
|
// create more data parts, testing the fair::mq::Parts in-place constructor
|
||||||
FairMQParts auxData{ NewMessage(500), NewMessage(600), NewMessage(700) };
|
fair::mq::Parts auxData{ NewMessage(500), NewMessage(600), NewMessage(700) };
|
||||||
assert(auxData.Size() == 3);
|
assert(auxData.Size() == 3);
|
||||||
parts.AddPart(std::move(auxData));
|
parts.AddPart(std::move(auxData));
|
||||||
assert(auxData.Size() == 0);
|
assert(auxData.Size() == 0);
|
||||||
|
|
|
@ -20,10 +20,14 @@ struct Sink : fair::mq::Device
|
||||||
OnData("data", &Sink::HandleData);
|
OnData("data", &Sink::HandleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQParts& parts, int)
|
bool HandleData(fair::mq::Parts& parts, int)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received message with " << parts.Size() << " parts";
|
LOG(info) << "Received message with " << parts.Size() << " parts";
|
||||||
|
|
||||||
|
if (parts.Size() != 7) {
|
||||||
|
throw std::runtime_error("Number of received parts != 7");
|
||||||
|
}
|
||||||
|
|
||||||
example_multipart::Header header;
|
example_multipart::Header header;
|
||||||
header.stopFlag = (static_cast<example_multipart::Header*>(parts.At(0)->GetData()))->stopFlag;
|
header.stopFlag = (static_cast<example_multipart::Header*>(parts.At(0)->GetData()))->stopFlag;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
transport="zeromq"
|
transport="zeromq"
|
||||||
|
@ -8,19 +10,25 @@ if [[ $1 =~ ^[a-z]+$ ]]; then
|
||||||
transport=$1
|
transport=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SESSION="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
session="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
||||||
|
chan="data"
|
||||||
|
chanAddr=""
|
||||||
|
chanIpcFile="/tmp/fmq_$session""_""$chan""_""$transport"
|
||||||
|
chanAddr="ipc://""$chanIpcFile"
|
||||||
|
|
||||||
# setup a trap to kill everything if the test fails/timeouts
|
# setup a trap to kill everything if the test fails/timeouts
|
||||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID;' TERM
|
trap 'set +e; kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID; rm $chanIpcFile; exit 0' TERM
|
||||||
|
|
||||||
SAMPLER="fairmq-ex-multipart-sampler"
|
SAMPLER="fairmq-ex-multipart-sampler"
|
||||||
SAMPLER+=" --id sampler1"
|
SAMPLER+=" --id sampler1"
|
||||||
SAMPLER+=" --transport $transport"
|
SAMPLER+=" --transport $transport"
|
||||||
SAMPLER+=" --verbosity veryhigh"
|
SAMPLER+=" --verbosity veryhigh"
|
||||||
SAMPLER+=" --session $SESSION"
|
SAMPLER+=" --session $session"
|
||||||
|
SAMPLER+=" --shm-segment-size 100000000"
|
||||||
|
SAMPLER+=" --shm-monitor true"
|
||||||
SAMPLER+=" --max-iterations 1"
|
SAMPLER+=" --max-iterations 1"
|
||||||
SAMPLER+=" --control static --color false"
|
SAMPLER+=" --control static --color false"
|
||||||
SAMPLER+=" --channel-config name=data,type=pair,method=connect,rateLogging=0,address=tcp://127.0.0.1:5555,linger=1000"
|
SAMPLER+=" --channel-config name=$chan,type=pair,method=connect,rateLogging=0,address=$chanAddr,linger=1000"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||||
SAMPLER_PID=$!
|
SAMPLER_PID=$!
|
||||||
|
|
||||||
|
@ -28,11 +36,17 @@ SINK="fairmq-ex-multipart-sink"
|
||||||
SINK+=" --id sink1"
|
SINK+=" --id sink1"
|
||||||
SINK+=" --transport $transport"
|
SINK+=" --transport $transport"
|
||||||
SINK+=" --verbosity veryhigh"
|
SINK+=" --verbosity veryhigh"
|
||||||
SINK+=" --session $SESSION"
|
SINK+=" --session $session"
|
||||||
|
SINK+=" --shm-segment-size 100000000"
|
||||||
|
SINK+=" --shm-monitor true"
|
||||||
SINK+=" --control static --color false"
|
SINK+=" --control static --color false"
|
||||||
SINK+=" --channel-config name=data,type=pair,method=bind,rateLogging=0,address=tcp://127.0.0.1:5555"
|
SINK+=" --channel-config name=$chan,type=pair,method=bind,rateLogging=0,address=$chanAddr"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
||||||
SINK_PID=$!
|
SINK_PID=$!
|
||||||
|
|
||||||
wait $SAMPLER_PID
|
wait $SAMPLER_PID
|
||||||
wait $SINK_PID
|
wait $SINK_PID
|
||||||
|
|
||||||
|
set +e
|
||||||
|
rm $chanIpcFile
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,52 +1,12 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
add_executable(fairmq-ex-multiple-channels-sampler sampler.cxx)
|
add_example(NAME multiple-channels
|
||||||
target_link_libraries(fairmq-ex-multiple-channels-sampler PRIVATE FairMQ)
|
DEVICE sampler broadcaster sink
|
||||||
|
TRANSPORT zeromq
|
||||||
add_executable(fairmq-ex-multiple-channels-broadcaster broadcaster.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-multiple-channels-broadcaster PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_executable(fairmq-ex-multiple-channels-sink sink.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-multiple-channels-sink PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_custom_target(ExampleMultipleChannels DEPENDS fairmq-ex-multiple-channels-sampler fairmq-ex-multiple-channels-broadcaster fairmq-ex-multiple-channels-sink)
|
|
||||||
|
|
||||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multiple-channels.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-channels.sh)
|
|
||||||
|
|
||||||
# test
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-multiple-channels.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-channels.sh)
|
|
||||||
|
|
||||||
add_test(NAME Example.MultipleChannels.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-channels.sh zeromq)
|
|
||||||
set_tests_properties(Example.MultipleChannels.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received messages from both sources.")
|
|
||||||
|
|
||||||
# install
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
fairmq-ex-multiple-channels-sampler
|
|
||||||
fairmq-ex-multiple-channels-broadcaster
|
|
||||||
fairmq-ex-multiple-channels-sink
|
|
||||||
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# configure run script with different executable paths for build and for install directories
|
|
||||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multiple-channels.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-channels.sh_install)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-channels.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-multiple-channels.sh
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,4 +5,4 @@ This example demonstrates how to work with multiple channels and multiplex betwe
|
||||||
|
|
||||||
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.
|
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 `FairMQPoller`.
|
The multiplexing between their data channels and the broadcast channels happens with `fair::mq::Poller`.
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct Broadcaster : fair::mq::Device
|
||||||
|
|
||||||
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
|
// NewSimpleMessage creates a copy of the data and takes care of its destruction (after the transfer takes place).
|
||||||
// Should only be used for small data because of the cost of an additional copy
|
// Should only be used for small data because of the cost of an additional copy
|
||||||
FairMQMessagePtr msg(NewSimpleMessage("OK"));
|
fair::mq::MessagePtr msg(NewSimpleMessage("OK"));
|
||||||
|
|
||||||
LOG(info) << "Sending OK";
|
LOG(info) << "Sending OK";
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include <fairmq/Device.h>
|
#include <fairmq/Device.h>
|
||||||
#include <FairMQPoller.h>
|
#include <fairmq/Poller.h>
|
||||||
#include <fairmq/runDevice.h>
|
#include <fairmq/runDevice.h>
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
@ -26,13 +26,13 @@ struct Sampler : fair::mq::Device
|
||||||
|
|
||||||
void Run() override
|
void Run() override
|
||||||
{
|
{
|
||||||
FairMQPollerPtr poller(NewPoller("data", "broadcast"));
|
fair::mq::PollerPtr poller(NewPoller("data", "broadcast"));
|
||||||
|
|
||||||
while (!NewStatePending()) {
|
while (!NewStatePending()) {
|
||||||
poller->Poll(100);
|
poller->Poll(100);
|
||||||
|
|
||||||
if (poller->CheckInput("broadcast", 0)) {
|
if (poller->CheckInput("broadcast", 0)) {
|
||||||
FairMQMessagePtr msg(NewMessage());
|
fair::mq::MessagePtr msg(NewMessage());
|
||||||
|
|
||||||
if (Receive(msg, "broadcast") > 0) {
|
if (Receive(msg, "broadcast") > 0) {
|
||||||
LOG(info) << "Received broadcast: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
LOG(info) << "Received broadcast: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||||
|
@ -42,7 +42,7 @@ struct Sampler : fair::mq::Device
|
||||||
if (poller->CheckOutput("data", 0)) {
|
if (poller->CheckOutput("data", 0)) {
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
|
||||||
FairMQMessagePtr msg(NewSimpleMessage(fText));
|
fair::mq::MessagePtr msg(NewSimpleMessage(fText));
|
||||||
|
|
||||||
if (Send(msg, "data") > 0) {
|
if (Send(msg, "data") > 0) {
|
||||||
LOG(info) << "Sent \"" << fText << "\"";
|
LOG(info) << "Sent \"" << fText << "\"";
|
||||||
|
|
|
@ -27,7 +27,7 @@ struct Sink : fair::mq::Device
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleBroadcast(FairMQMessagePtr& msg, int /*index*/)
|
bool HandleBroadcast(fair::mq::MessagePtr& msg, int /*index*/)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received broadcast: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
LOG(info) << "Received broadcast: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||||
fReceivedBroadcast = true;
|
fReceivedBroadcast = true;
|
||||||
|
@ -35,7 +35,7 @@ struct Sink : fair::mq::Device
|
||||||
return CheckIterations();
|
return CheckIterations();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int /*index*/)
|
bool HandleData(fair::mq::MessagePtr& msg, int /*index*/)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received message: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
LOG(info) << "Received message: \"" << std::string(static_cast<char*>(msg->GetData()), msg->GetSize()) << "\"";
|
||||||
fReceivedData = true;
|
fReceivedData = true;
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
transport="zeromq"
|
transport="zeromq"
|
||||||
|
@ -8,18 +10,26 @@ if [[ $1 =~ ^[a-z]+$ ]]; then
|
||||||
transport=$1
|
transport=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# setup a trap to kill everything if the test fails/timeouts
|
session="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
||||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; kill -TERM $BROADCASTER_PID; wait $SAMPLER_PID; wait $SINK_PID; wait $BROADCASTER_PID;' TERM
|
dataChan="data"
|
||||||
|
broadcastChan="broadcast"
|
||||||
|
dataChanAddr="/tmp/fmq_$session""_""$dataChan""_""$transport"
|
||||||
|
broadcastChanAddr="/tmp/fmq_$session""_""$broadcastChan""_""$transport"
|
||||||
|
|
||||||
|
# setup a trap to kill everything if the test fails/timeouts
|
||||||
|
trap 'set +e; kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; kill -TERM $BROADCASTER_PID; wait $SAMPLER_PID; wait $SINK_PID; wait $BROADCASTER_PID; rm $dataChanAddr; rm $broadcastChanAddr; exit 0' TERM
|
||||||
|
|
||||||
SINK="fairmq-ex-multiple-channels-sink"
|
SINK="fairmq-ex-multiple-channels-sink"
|
||||||
SINK+=" --id sink1"
|
SINK+=" --id sink1"
|
||||||
|
SINK+=" --session $session"
|
||||||
SINK+=" --transport $transport"
|
SINK+=" --transport $transport"
|
||||||
SINK+=" --verbosity veryhigh"
|
SINK+=" --verbosity veryhigh --severity debug"
|
||||||
|
SINK+=" --shm-segment-size 100000000"
|
||||||
|
SINK+=" --shm-monitor true"
|
||||||
SINK+=" --max-iterations 1"
|
SINK+=" --max-iterations 1"
|
||||||
SINK+=" --control static --color false"
|
SINK+=" --control static --color false"
|
||||||
SINK+=" --channel-config name=data,type=pull,method=connect,rateLogging=0,address=tcp://localhost:5555"
|
SINK+=" --channel-config name=$dataChan,type=pull,method=connect,rateLogging=0,address=ipc://$dataChanAddr"
|
||||||
SINK+=" name=broadcast,type=sub,method=connect,rateLogging=0,address=tcp://localhost:5005"
|
SINK+=" name=$broadcastChan,type=sub,method=connect,rateLogging=0,address=ipc://$broadcastChanAddr"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
||||||
SINK_PID=$!
|
SINK_PID=$!
|
||||||
|
|
||||||
|
@ -27,21 +37,27 @@ sleep 1
|
||||||
|
|
||||||
SAMPLER="fairmq-ex-multiple-channels-sampler"
|
SAMPLER="fairmq-ex-multiple-channels-sampler"
|
||||||
SAMPLER+=" --id sampler1"
|
SAMPLER+=" --id sampler1"
|
||||||
|
SAMPLER+=" --session $session"
|
||||||
SAMPLER+=" --transport $transport"
|
SAMPLER+=" --transport $transport"
|
||||||
SAMPLER+=" --verbosity veryhigh"
|
SAMPLER+=" --verbosity veryhigh --severity debug"
|
||||||
|
SAMPLER+=" --shm-segment-size 100000000"
|
||||||
|
SAMPLER+=" --shm-monitor true"
|
||||||
SAMPLER+=" --max-iterations 1"
|
SAMPLER+=" --max-iterations 1"
|
||||||
SAMPLER+=" --control static --color false"
|
SAMPLER+=" --control static --color false"
|
||||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,rateLogging=0,address=tcp://*:5555"
|
SAMPLER+=" --channel-config name=$dataChan,type=push,method=bind,rateLogging=0,address=ipc://$dataChanAddr"
|
||||||
SAMPLER+=" name=broadcast,type=sub,method=connect,rateLogging=0,address=tcp://localhost:5005"
|
SAMPLER+=" name=$broadcastChan,type=sub,method=connect,rateLogging=0,address=ipc://$broadcastChanAddr"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||||
SAMPLER_PID=$!
|
SAMPLER_PID=$!
|
||||||
|
|
||||||
BROADCASTER="fairmq-ex-multiple-channels-broadcaster"
|
BROADCASTER="fairmq-ex-multiple-channels-broadcaster"
|
||||||
BROADCASTER+=" --id broadcaster1"
|
BROADCASTER+=" --id broadcaster1"
|
||||||
|
BROADCASTER+=" --session $session"
|
||||||
BROADCASTER+=" --transport $transport"
|
BROADCASTER+=" --transport $transport"
|
||||||
BROADCASTER+=" --verbosity veryhigh"
|
BROADCASTER+=" --verbosity veryhigh --severity debug"
|
||||||
|
BROADCASTER+=" --shm-segment-size 100000000"
|
||||||
|
BROADCASTER+=" --shm-monitor true"
|
||||||
BROADCASTER+=" --control static --color false"
|
BROADCASTER+=" --control static --color false"
|
||||||
BROADCASTER+=" --channel-config name=broadcast,type=pub,method=bind,rateLogging=0,address=tcp://*:5005"
|
BROADCASTER+=" --channel-config name=$broadcastChan,type=pub,method=bind,rateLogging=0,address=ipc://$broadcastChanAddr"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$BROADCASTER &
|
@CMAKE_CURRENT_BINARY_DIR@/$BROADCASTER &
|
||||||
BROADCASTER_PID=$!
|
BROADCASTER_PID=$!
|
||||||
|
|
||||||
|
@ -53,3 +69,7 @@ kill -SIGINT $BROADCASTER_PID
|
||||||
|
|
||||||
# wait for broadcaster to finish
|
# wait for broadcaster to finish
|
||||||
wait $BROADCASTER_PID
|
wait $BROADCASTER_PID
|
||||||
|
|
||||||
|
set +e
|
||||||
|
rm $dataChanAddr; rm $broadcastChanAddr
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,51 +1,12 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
add_executable(fairmq-ex-multiple-transports-sampler1 sampler1.cxx)
|
add_example(NAME multiple-transports
|
||||||
target_link_libraries(fairmq-ex-multiple-transports-sampler1 PRIVATE FairMQ)
|
DEVICE sampler1 sampler2 sink
|
||||||
|
NO_TRANSPORT
|
||||||
add_executable(fairmq-ex-multiple-transports-sampler2 sampler2.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-multiple-transports-sampler2 PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_executable(fairmq-ex-multiple-transports-sink sink.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-multiple-transports-sink PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_custom_target(ExampleMultipleTransports DEPENDS fairmq-ex-multiple-transports-sampler1 fairmq-ex-multiple-transports-sampler2 fairmq-ex-multiple-transports-sink)
|
|
||||||
|
|
||||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multiple-transports.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-transports.sh)
|
|
||||||
|
|
||||||
# test
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-multiple-transports.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-transports.sh)
|
|
||||||
add_test(NAME Example.MultipleTransports COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-multiple-transports.sh)
|
|
||||||
set_tests_properties(Example.MultipleTransports PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received messages from both sources.")
|
|
||||||
|
|
||||||
# install
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
fairmq-ex-multiple-transports-sampler1
|
|
||||||
fairmq-ex-multiple-transports-sampler2
|
|
||||||
fairmq-ex-multiple-transports-sink
|
|
||||||
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# configure run script with different executable paths for install directories
|
|
||||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-multiple-transports.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-transports.sh_install)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-multiple-transports.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-multiple-transports.sh
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct Sampler1 : fair::mq::Device
|
||||||
bool ConditionalRun() override
|
bool ConditionalRun() override
|
||||||
{
|
{
|
||||||
// Creates a message using the transport of channel data1
|
// Creates a message using the transport of channel data1
|
||||||
FairMQMessagePtr msg(NewMessageFor("data1", 0, 1000000));
|
fair::mq::MessagePtr msg(NewMessageFor("data1", 0, 1000000));
|
||||||
|
|
||||||
// in case of error or transfer interruption, return false to go to IDLE state
|
// in case of error or transfer interruption, return false to go to IDLE state
|
||||||
// successfull transfer will return number of bytes transfered (can be 0 if sending an empty message).
|
// successfull transfer will return number of bytes transfered (can be 0 if sending an empty message).
|
||||||
|
@ -54,7 +54,7 @@ struct Sampler1 : fair::mq::Device
|
||||||
uint64_t numAcks = 0;
|
uint64_t numAcks = 0;
|
||||||
|
|
||||||
while (!NewStatePending()) {
|
while (!NewStatePending()) {
|
||||||
FairMQMessagePtr ack(NewMessageFor("ack", 0));
|
fair::mq::MessagePtr ack(NewMessageFor("ack", 0));
|
||||||
if (Receive(ack, "ack") < 0) {
|
if (Receive(ack, "ack") < 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct Sampler2 : fair::mq::Device
|
||||||
|
|
||||||
bool ConditionalRun() override
|
bool ConditionalRun() override
|
||||||
{
|
{
|
||||||
FairMQMessagePtr msg(NewMessage(1000));
|
fair::mq::MessagePtr msg(NewMessage(1000));
|
||||||
|
|
||||||
// in case of error or transfer interruption, return false to go to IDLE state
|
// in case of error or transfer interruption, return false to go to IDLE state
|
||||||
// successfull transfer will return number of bytes transfered (can be 0 if sending an empty message).
|
// successfull transfer will return number of bytes transfered (can be 0 if sending an empty message).
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include <fairmq/Device.h>
|
#include <fairmq/Device.h>
|
||||||
#include <fairmq/runDevice.h>
|
#include <fairmq/runDevice.h>
|
||||||
|
|
||||||
|
#include <stdexcept>
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
|
|
||||||
struct Sink : fair::mq::Device
|
struct Sink : fair::mq::Device
|
||||||
|
@ -26,13 +28,13 @@ struct Sink : fair::mq::Device
|
||||||
}
|
}
|
||||||
|
|
||||||
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
|
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
|
||||||
bool HandleData1(FairMQMessagePtr& /*msg*/, int /*index*/)
|
bool HandleData1(fair::mq::MessagePtr& /*msg*/, int /*index*/)
|
||||||
{
|
{
|
||||||
fNumIterations1++;
|
fNumIterations1++;
|
||||||
// Creates a message using the transport of channel ack
|
// Creates a message using the transport of channel ack
|
||||||
FairMQMessagePtr ack(NewMessageFor("ack", 0));
|
fair::mq::MessagePtr ack(NewMessageFor("ack", 0));
|
||||||
if (Send(ack, "ack") < 0) {
|
if (Send(ack, "ack") < 0) {
|
||||||
return false;
|
throw std::runtime_error("could not send an ack");
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if want to be called again (otherwise go to IDLE state)
|
// return true if want to be called again (otherwise go to IDLE state)
|
||||||
|
@ -40,7 +42,7 @@ struct Sink : fair::mq::Device
|
||||||
}
|
}
|
||||||
|
|
||||||
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
|
// handler is called whenever a message arrives on "data", with a reference to the message and a sub-channel index (here 0)
|
||||||
bool HandleData2(FairMQMessagePtr& /*msg*/, int /*index*/)
|
bool HandleData2(fair::mq::MessagePtr& /*msg*/, int /*index*/)
|
||||||
{
|
{
|
||||||
fNumIterations2++;
|
fNumIterations2++;
|
||||||
// return true if want to be called again (otherwise go to IDLE state)
|
// return true if want to be called again (otherwise go to IDLE state)
|
||||||
|
|
|
@ -1,47 +1,65 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
SESSION="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
session="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
||||||
|
chan1="data1"
|
||||||
|
chan2="data2"
|
||||||
|
ackChan="ack"
|
||||||
|
chan1Addr="/tmp/fmq_$session""_""$chan1"
|
||||||
|
chan2Addr="/tmp/fmq_$session""_""$chan2"
|
||||||
|
ackChanAddr="/tmp/fmq_$session""_""$ackChan"
|
||||||
|
|
||||||
trap 'kill -TERM $SAMPLER1_PID; kill -TERM $SAMPLER2_PID; kill -TERM $SINK_PID; wait $SAMPLER1_PID; wait $SAMPLER2_PID; wait $SINK_PID; @CMAKE_BINARY_DIR@/fairmq/fairmq-shmmonitor --cleanup --session $SESSION;' TERM
|
trap 'set +e; kill -TERM $SAMPLER1_PID; kill -TERM $SAMPLER2_PID; kill -TERM $SINK_PID; wait $SAMPLER1_PID; wait $SAMPLER2_PID; wait $SINK_PID; @CMAKE_BINARY_DIR@/fairmq/fairmq-shmmonitor --cleanup --session $SESSION; rm $chan1Addr; rm $chan2Addr; rm $ackChanAddr; exit 0' TERM
|
||||||
|
|
||||||
SINK="fairmq-ex-multiple-transports-sink"
|
SINK="fairmq-ex-multiple-transports-sink"
|
||||||
SINK+=" --id sink1"
|
SINK+=" --id sink1"
|
||||||
SINK+=" --verbosity veryhigh"
|
SINK+=" --verbosity veryhigh --severity debug"
|
||||||
SINK+=" --session $SESSION"
|
SINK+=" --shm-segment-size 100000000"
|
||||||
|
SINK+=" --shm-monitor true"
|
||||||
|
SINK+=" --session $session"
|
||||||
SINK+=" --max-iterations 1"
|
SINK+=" --max-iterations 1"
|
||||||
SINK+=" --control static --color false"
|
SINK+=" --control static --color false"
|
||||||
SINK+=" --transport shmem"
|
SINK+=" --transport shmem"
|
||||||
SINK+=" --channel-config name=data1,type=pull,method=connect,address=tcp://127.0.0.1:5555"
|
SINK+=" --channel-config name=$chan1,type=pull,method=connect,address=ipc://$chan1Addr"
|
||||||
SINK+=" name=data2,type=pull,method=connect,address=tcp://127.0.0.1:5556,transport=zeromq"
|
SINK+=" name=$chan2,type=pull,method=connect,address=ipc://$chan2Addr,transport=zeromq"
|
||||||
SINK+=" name=ack,type=pub,method=connect,address=tcp://127.0.0.1:5557,transport=zeromq"
|
SINK+=" name=$ackChan,type=pub,method=connect,address=ipc://$ackChanAddr,transport=zeromq"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
||||||
SINK_PID=$!
|
SINK_PID=$!
|
||||||
|
|
||||||
SAMPLER1="fairmq-ex-multiple-transports-sampler1"
|
SAMPLER1="fairmq-ex-multiple-transports-sampler1"
|
||||||
SAMPLER1+=" --id sampler1"
|
SAMPLER1+=" --id sampler1"
|
||||||
SAMPLER1+=" --session $SESSION"
|
SAMPLER1+=" --session $session"
|
||||||
SAMPLER1+=" --verbosity veryhigh"
|
SAMPLER1+=" --verbosity veryhigh --severity debug"
|
||||||
|
SAMPLER1+=" --shm-segment-size 100000000"
|
||||||
|
SAMPLER1+=" --shm-monitor true"
|
||||||
SAMPLER1+=" --max-iterations 1"
|
SAMPLER1+=" --max-iterations 1"
|
||||||
SAMPLER1+=" --control static --color false"
|
SAMPLER1+=" --control static --color false"
|
||||||
SAMPLER1+=" --transport shmem"
|
SAMPLER1+=" --transport shmem"
|
||||||
SAMPLER1+=" --channel-config name=data1,type=push,method=bind,address=tcp://127.0.0.1:5555"
|
SAMPLER1+=" --channel-config name=$chan1,type=push,method=bind,address=ipc://$chan1Addr"
|
||||||
SAMPLER1+=" name=ack,type=sub,method=bind,address=tcp://127.0.0.1:5557,transport=zeromq"
|
SAMPLER1+=" name=$ackChan,type=sub,method=bind,address=ipc://$ackChanAddr,transport=zeromq"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER1 &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER1 &
|
||||||
SAMPLER1_PID=$!
|
SAMPLER1_PID=$!
|
||||||
|
|
||||||
SAMPLER2="fairmq-ex-multiple-transports-sampler2"
|
SAMPLER2="fairmq-ex-multiple-transports-sampler2"
|
||||||
SAMPLER2+=" --id sampler2"
|
SAMPLER2+=" --id sampler2"
|
||||||
SAMPLER2+=" --session $SESSION"
|
SAMPLER2+=" --session $session"
|
||||||
SAMPLER2+=" --verbosity veryhigh"
|
SAMPLER2+=" --verbosity veryhigh --severity debug"
|
||||||
|
SAMPLER2+=" --shm-segment-size 100000000"
|
||||||
|
SAMPLER2+=" --shm-monitor true"
|
||||||
SAMPLER2+=" --max-iterations 1"
|
SAMPLER2+=" --max-iterations 1"
|
||||||
SAMPLER2+=" --control static --color false"
|
SAMPLER2+=" --control static --color false"
|
||||||
SAMPLER2+=" --transport zeromq"
|
SAMPLER2+=" --transport zeromq"
|
||||||
SAMPLER2+=" --channel-config name=data2,type=push,method=bind,address=tcp://127.0.0.1:5556"
|
SAMPLER2+=" --channel-config name=$chan2,type=push,method=bind,address=ipc://$chan2Addr"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER2 &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER2 &
|
||||||
SAMPLER2_PID=$!
|
SAMPLER2_PID=$!
|
||||||
|
|
||||||
wait $SAMPLER1_PID
|
wait $SAMPLER1_PID
|
||||||
wait $SAMPLER2_PID
|
wait $SAMPLER2_PID
|
||||||
wait $SINK_PID
|
wait $SINK_PID
|
||||||
|
|
||||||
|
set +e
|
||||||
|
rm $chan1Addr; rm $chan2Addr; rm $ackChanAddr
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2020 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2020-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
|
@ -24,7 +24,7 @@ namespace bpo = boost::program_options;
|
||||||
|
|
||||||
struct TFBuffer
|
struct TFBuffer
|
||||||
{
|
{
|
||||||
FairMQParts parts;
|
fair::mq::Parts parts;
|
||||||
chrono::steady_clock::time_point start;
|
chrono::steady_clock::time_point start;
|
||||||
chrono::steady_clock::time_point end;
|
chrono::steady_clock::time_point end;
|
||||||
};
|
};
|
||||||
|
@ -43,7 +43,7 @@ struct Receiver : fair::mq::Device
|
||||||
fMaxTimeframes = GetConfig()->GetValue<int>("max-timeframes");
|
fMaxTimeframes = GetConfig()->GetValue<int>("max-timeframes");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQParts& parts, int /* index */)
|
bool HandleData(fair::mq::Parts& parts, int /* index */)
|
||||||
{
|
{
|
||||||
Header& h = *(static_cast<Header*>(parts.At(0)->GetData()));
|
Header& h = *(static_cast<Header*>(parts.At(0)->GetData()));
|
||||||
// LOG(info) << "Received sub-time frame #" << h.id << " from Sender" << h.senderIndex;
|
// LOG(info) << "Received sub-time frame #" << h.id << " from Sender" << h.senderIndex;
|
||||||
|
@ -54,7 +54,7 @@ struct Receiver : fair::mq::Device
|
||||||
fBuffer[h.id].start = chrono::steady_clock::now();
|
fBuffer[h.id].start = chrono::steady_clock::now();
|
||||||
}
|
}
|
||||||
// if the received ID has not previously been discarded, store the data part in the buffer
|
// if the received ID has not previously been discarded, store the data part in the buffer
|
||||||
fBuffer[h.id].parts.AddPart(move(parts.At(1)));
|
fBuffer[h.id].parts.AddPart(std::move(parts.At(1)));
|
||||||
} else {
|
} else {
|
||||||
// if received ID has been previously discarded.
|
// if received ID has been previously discarded.
|
||||||
LOG(debug) << "Received part from an already discarded timeframe with id " << h.id;
|
LOG(debug) << "Received part from an already discarded timeframe with id " << h.id;
|
||||||
|
@ -93,7 +93,7 @@ struct Receiver : fair::mq::Device
|
||||||
unordered_map<uint16_t, TFBuffer> fBuffer;
|
unordered_map<uint16_t, TFBuffer> fBuffer;
|
||||||
unordered_set<uint16_t> fDiscardedSet;
|
unordered_set<uint16_t> fDiscardedSet;
|
||||||
|
|
||||||
int fNumSenders = 0;
|
unsigned int fNumSenders = 0;
|
||||||
int fBufferTimeoutInMs = 5000;
|
int fBufferTimeoutInMs = 5000;
|
||||||
int fMaxTimeframes = 0;
|
int fMaxTimeframes = 0;
|
||||||
int fTimeframeCounter = 0;
|
int fTimeframeCounter = 0;
|
||||||
|
@ -107,7 +107,7 @@ void addCustomOptions(bpo::options_description& options)
|
||||||
("max-timeframes", bpo::value<int>()->default_value(0), "Maximum number of timeframes to receive (0 - unlimited)");
|
("max-timeframes", bpo::value<int>()->default_value(0), "Maximum number of timeframes to receive (0 - unlimited)");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<fair::mq::Device> getDevice(FairMQProgOptions& /* config */)
|
std::unique_ptr<fair::mq::Device> getDevice(fair::mq::ProgOptions& /* config */)
|
||||||
{
|
{
|
||||||
return std::make_unique<Receiver>();
|
return std::make_unique<Receiver>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,11 +28,11 @@ struct Sender : fair::mq::Device
|
||||||
|
|
||||||
void Run() override
|
void Run() override
|
||||||
{
|
{
|
||||||
FairMQChannel& dataInChannel = fChannels.at("sync").at(0);
|
fair::mq::Channel& dataInChannel = GetChannel("sync", 0);
|
||||||
|
|
||||||
while (!NewStatePending()) {
|
while (!NewStatePending()) {
|
||||||
Header h;
|
Header h;
|
||||||
FairMQMessagePtr id(NewMessage());
|
fair::mq::MessagePtr id(NewMessage());
|
||||||
if (dataInChannel.Receive(id) > 0) {
|
if (dataInChannel.Receive(id) > 0) {
|
||||||
h.id = *(static_cast<uint16_t*>(id->GetData()));
|
h.id = *(static_cast<uint16_t*>(id->GetData()));
|
||||||
h.senderIndex = fIndex;
|
h.senderIndex = fIndex;
|
||||||
|
@ -40,7 +40,7 @@ struct Sender : fair::mq::Device
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQParts parts;
|
fair::mq::Parts parts;
|
||||||
parts.AddPart(NewSimpleMessage(h));
|
parts.AddPart(NewSimpleMessage(h));
|
||||||
parts.AddPart(NewMessage(fSubtimeframeSize));
|
parts.AddPart(NewMessage(fSubtimeframeSize));
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ void addCustomOptions(bpo::options_description& options)
|
||||||
("subtimeframe-size", bpo::value<int>()->default_value(1000), "Subtimeframe size in bytes")
|
("subtimeframe-size", bpo::value<int>()->default_value(1000), "Subtimeframe size in bytes")
|
||||||
("num-receivers", bpo::value<int>()->required(), "Number of EPNs");
|
("num-receivers", bpo::value<int>()->required(), "Number of EPNs");
|
||||||
}
|
}
|
||||||
std::unique_ptr<fair::mq::Device> getDevice(FairMQProgOptions& /* config */)
|
std::unique_ptr<fair::mq::Device> getDevice(fair::mq::ProgOptions& /* config */)
|
||||||
{
|
{
|
||||||
return std::make_unique<Sender>();
|
return std::make_unique<Sender>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ struct Synchronizer : fair::mq::Device
|
||||||
{
|
{
|
||||||
bool ConditionalRun() override
|
bool ConditionalRun() override
|
||||||
{
|
{
|
||||||
FairMQMessagePtr msg(NewSimpleMessage(fTimeframeId));
|
fair::mq::MessagePtr msg(NewSimpleMessage(fTimeframeId));
|
||||||
|
|
||||||
if (Send(msg, "sync") > 0) {
|
if (Send(msg, "sync") > 0) {
|
||||||
if (++fTimeframeId == UINT16_MAX - 1) {
|
if (++fTimeframeId == UINT16_MAX - 1) {
|
||||||
|
@ -37,7 +37,7 @@ struct Synchronizer : fair::mq::Device
|
||||||
};
|
};
|
||||||
|
|
||||||
void addCustomOptions(bpo::options_description& /* options */) {}
|
void addCustomOptions(bpo::options_description& /* options */) {}
|
||||||
std::unique_ptr<fair::mq::Device> getDevice(FairMQProgOptions& /* config */)
|
std::unique_ptr<fair::mq::Device> getDevice(fair::mq::ProgOptions& /* config */)
|
||||||
{
|
{
|
||||||
return std::make_unique<Synchronizer>();
|
return std::make_unique<Synchronizer>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@ struct QCDispatcher : fair::mq::Device
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int)
|
bool HandleData(fair::mq::MessagePtr& msg, int)
|
||||||
{
|
{
|
||||||
if (fDoQC.load() == true) {
|
if (fDoQC.load() == true) {
|
||||||
FairMQMessagePtr msgCopy(NewMessage());
|
fair::mq::MessagePtr msgCopy(NewMessage());
|
||||||
msgCopy->Copy(*msg);
|
msgCopy->Copy(*msg);
|
||||||
if (Send(msg, "qc") < 0) {
|
if (Send(msg, "qc") < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -9,12 +9,12 @@
|
||||||
#include <fairmq/Device.h>
|
#include <fairmq/Device.h>
|
||||||
#include <fairmq/runDevice.h>
|
#include <fairmq/runDevice.h>
|
||||||
|
|
||||||
class QCTask : public FairMQDevice
|
class QCTask : public fair::mq::Device
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QCTask()
|
QCTask()
|
||||||
{
|
{
|
||||||
OnData("qc", [](FairMQMessagePtr& /*msg*/, int) {
|
OnData("qc", [](fair::mq::MessagePtr& /*msg*/, int) {
|
||||||
LOG(info) << "received data";
|
LOG(info) << "received data";
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,7 @@ struct Sampler : fair::mq::Device
|
||||||
{
|
{
|
||||||
bool ConditionalRun() override
|
bool ConditionalRun() override
|
||||||
{
|
{
|
||||||
FairMQMessagePtr msg(NewMessage(1000));
|
fair::mq::MessagePtr msg(NewMessage(1000));
|
||||||
|
|
||||||
if (Send(msg, "data1") < 0) {
|
if (Send(msg, "data1") < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
struct Sink : fair::mq::Device
|
struct Sink : fair::mq::Device
|
||||||
{
|
{
|
||||||
Sink() { OnData("data2", &Sink::HandleData); }
|
Sink() { OnData("data2", &Sink::HandleData); }
|
||||||
bool HandleData(FairMQMessagePtr& /*msg*/, int /*index*/) { return true; }
|
bool HandleData(fair::mq::MessagePtr& /*msg*/, int /*index*/) { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
|
|
|
@ -1,59 +1,13 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
add_executable(fairmq-ex-readout-readout readout.cxx)
|
add_example(NAME readout
|
||||||
target_link_libraries(fairmq-ex-readout-readout PRIVATE FairMQ)
|
DEVICE readout builder processor sender receiver
|
||||||
|
SCRIPT readout readout-processing
|
||||||
add_executable(fairmq-ex-readout-builder builder.cxx)
|
NO_TEST
|
||||||
target_link_libraries(fairmq-ex-readout-builder PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_executable(fairmq-ex-readout-processor processor.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-readout-processor PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_executable(fairmq-ex-readout-sender sender.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-readout-sender PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_executable(fairmq-ex-readout-receiver receiver.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-readout-receiver PRIVATE FairMQ)
|
|
||||||
|
|
||||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-readout.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-readout.sh)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-readout-processing.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-readout-processing.sh)
|
|
||||||
|
|
||||||
# install
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
fairmq-ex-readout-readout
|
|
||||||
fairmq-ex-readout-builder
|
|
||||||
fairmq-ex-readout-processor
|
|
||||||
fairmq-ex-readout-sender
|
|
||||||
fairmq-ex-readout-receiver
|
|
||||||
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# configure run script with different executable paths for build and for install directories
|
|
||||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-readout.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-readout.sh_install)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-readout-processing.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-readout-processing.sh_install)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-readout.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-readout.sh
|
|
||||||
)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-readout-processing.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-readout-processing.sh
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,19 +7,19 @@ This examples shows two possible topologies (out of many) for a node connected t
|
||||||
```
|
```
|
||||||
|------------------------------- Readout Node ---------------------------| |- Processing Node -|
|
|------------------------------- Readout Node ---------------------------| |- Processing Node -|
|
||||||
| Readout --> Builder --> Sender | --> | Receiver |
|
| Readout --> Builder --> Sender | --> | Receiver |
|
||||||
| [# shared memory segment (unused in this topology) ##################] | ofi | |
|
| [# shared memory segment (unused in this topology) ##################] | zmq | |
|
||||||
| [# shmem unmanaged region (readout writes here, others read) ########] | | |
|
| [# 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 OFI transport.
|
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
|
## Setup with generating new data on the Readout node
|
||||||
|
|
||||||
```
|
```
|
||||||
|------------------------------- Readout Node ---------------------------| |- Processing Node -|
|
|------------------------------- Readout Node ---------------------------| |- Processing Node -|
|
||||||
| Readout --> Builder --> Processor --> Sender | --> | Receiver |
|
| Readout --> Builder --> Processor --> Sender | --> | Receiver |
|
||||||
| [# shared memory segment (used between Proccessor and Sender) #######] | ofi | |
|
| [# shared memory segment (used between Proccessor and Sender) #######] | zmq | |
|
||||||
| [# shmem unmanaged region (readout writes here, builder & proc read) ] | | |
|
| [# shmem unmanaged region (readout writes here, builder & proc read) ] | | |
|
||||||
|------------------------------------------------------------------------| |-------------------|
|
|------------------------------------------------------------------------| |-------------------|
|
||||||
```
|
```
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
|
|
||||||
class Builder : public FairMQDevice
|
class Builder : public fair::mq::Device
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Builder() = default;
|
Builder() = default;
|
||||||
|
@ -24,7 +24,7 @@ class Builder : public FairMQDevice
|
||||||
OnData("rb", &Builder::HandleData);
|
OnData("rb", &Builder::HandleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int /*index*/)
|
bool HandleData(fair::mq::MessagePtr& msg, int /*index*/)
|
||||||
{
|
{
|
||||||
if (Send(msg, fOutputChannelName) < 0) {
|
if (Send(msg, fOutputChannelName) < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -31,12 +31,10 @@ SENDER="fairmq-ex-readout-sender"
|
||||||
SENDER+=" --id sender1"
|
SENDER+=" --id sender1"
|
||||||
SENDER+=" --input-name ps"
|
SENDER+=" --input-name ps"
|
||||||
SENDER+=" --channel-config name=ps,type=pair,method=bind,address=tcp://localhost:7779,transport=shmem"
|
SENDER+=" --channel-config name=ps,type=pair,method=bind,address=tcp://localhost:7779,transport=shmem"
|
||||||
#SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7780,transport=ofi"
|
|
||||||
SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7780,transport=zeromq"
|
SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7780,transport=zeromq"
|
||||||
xterm -geometry 80x23+1000+0 -hold -e @EX_BIN_DIR@/$SENDER &
|
xterm -geometry 80x23+1000+0 -hold -e @EX_BIN_DIR@/$SENDER &
|
||||||
|
|
||||||
RECEIVER="fairmq-ex-readout-receiver"
|
RECEIVER="fairmq-ex-readout-receiver"
|
||||||
RECEIVER+=" --id receiver1"
|
RECEIVER+=" --id receiver1"
|
||||||
#RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7780,transport=ofi"
|
|
||||||
RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7780,transport=zeromq"
|
RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7780,transport=zeromq"
|
||||||
xterm -geometry 80x23+1500+0 -hold -e @EX_BIN_DIR@/$RECEIVER &
|
xterm -geometry 80x23+1500+0 -hold -e @EX_BIN_DIR@/$RECEIVER &
|
||||||
|
|
|
@ -25,12 +25,10 @@ SENDER="fairmq-ex-readout-sender"
|
||||||
SENDER+=" --id sender1"
|
SENDER+=" --id sender1"
|
||||||
SENDER+=" --input-name bs"
|
SENDER+=" --input-name bs"
|
||||||
SENDER+=" --channel-config name=bs,type=pair,method=bind,address=tcp://localhost:7778,transport=shmem"
|
SENDER+=" --channel-config name=bs,type=pair,method=bind,address=tcp://localhost:7778,transport=shmem"
|
||||||
# SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7779,transport=ofi"
|
|
||||||
SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7779,transport=zeromq"
|
SENDER+=" name=sr,type=pair,method=connect,address=tcp://localhost:7779,transport=zeromq"
|
||||||
xterm -geometry 80x23+1000+0 -hold -e @EX_BIN_DIR@/$SENDER &
|
xterm -geometry 80x23+1000+0 -hold -e @EX_BIN_DIR@/$SENDER &
|
||||||
|
|
||||||
RECEIVER="fairmq-ex-readout-receiver"
|
RECEIVER="fairmq-ex-readout-receiver"
|
||||||
RECEIVER+=" --id receiver1"
|
RECEIVER+=" --id receiver1"
|
||||||
# RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7779,transport=ofi"
|
|
||||||
RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7779,transport=zeromq"
|
RECEIVER+=" --channel-config name=sr,type=pair,method=bind,address=tcp://localhost:7779,transport=zeromq"
|
||||||
xterm -geometry 80x23+1500+0 -hold -e @EX_BIN_DIR@/$RECEIVER &
|
xterm -geometry 80x23+1500+0 -hold -e @EX_BIN_DIR@/$RECEIVER &
|
||||||
|
|
|
@ -18,9 +18,9 @@ struct Processor : fair::mq::Device
|
||||||
OnData("bp", &Processor::HandleData);
|
OnData("bp", &Processor::HandleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int /*index*/)
|
bool HandleData(fair::mq::MessagePtr& msg, int /*index*/)
|
||||||
{
|
{
|
||||||
FairMQMessagePtr msg2(NewMessageFor("ps", 0, msg->GetSize()));
|
fair::mq::MessagePtr msg2(NewMessageFor("ps", 0, msg->GetSize()));
|
||||||
if (Send(msg2, "ps") < 0) {
|
if (Send(msg2, "ps") < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ struct Readout : fair::mq::Device
|
||||||
fMsgSize = fConfig->GetProperty<int>("msg-size");
|
fMsgSize = fConfig->GetProperty<int>("msg-size");
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
|
|
||||||
fRegion = FairMQUnmanagedRegionPtr(NewUnmanagedRegionFor("rb",
|
fRegion = fair::mq::UnmanagedRegionPtr(NewUnmanagedRegionFor("rb",
|
||||||
0,
|
0,
|
||||||
10000000,
|
10000000,
|
||||||
[this](const std::vector<fair::mq::RegionBlock>& blocks) { // callback to be called when message buffers no longer needed by transport
|
[this](const std::vector<fair::mq::RegionBlock>& blocks) { // callback to be called when message buffers no longer needed by transport
|
||||||
|
@ -36,7 +36,7 @@ struct Readout : fair::mq::Device
|
||||||
|
|
||||||
bool ConditionalRun() override
|
bool ConditionalRun() override
|
||||||
{
|
{
|
||||||
FairMQMessagePtr msg(NewMessageFor("rb", // channel
|
fair::mq::MessagePtr msg(NewMessageFor("rb", // channel
|
||||||
0, // sub-channel
|
0, // sub-channel
|
||||||
fRegion, // region
|
fRegion, // region
|
||||||
fRegion->GetData(), // ptr within region
|
fRegion->GetData(), // ptr within region
|
||||||
|
@ -71,7 +71,7 @@ struct Readout : fair::mq::Device
|
||||||
int fMsgSize = 10000;
|
int fMsgSize = 10000;
|
||||||
uint64_t fMaxIterations = 0;
|
uint64_t fMaxIterations = 0;
|
||||||
uint64_t fNumIterations = 0;
|
uint64_t fNumIterations = 0;
|
||||||
FairMQUnmanagedRegionPtr fRegion = nullptr;
|
fair::mq::UnmanagedRegionPtr fRegion = nullptr;
|
||||||
std::atomic<uint64_t> fNumUnackedMsgs = 0;
|
std::atomic<uint64_t> fNumUnackedMsgs = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2014-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
|
@ -8,10 +8,15 @@
|
||||||
|
|
||||||
#include <fairmq/Device.h>
|
#include <fairmq/Device.h>
|
||||||
#include <fairmq/runDevice.h>
|
#include <fairmq/runDevice.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace fair::mq;
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
|
|
||||||
struct Receiver : fair::mq::Device
|
namespace {
|
||||||
|
|
||||||
|
struct Receiver : Device
|
||||||
{
|
{
|
||||||
void InitTask() override
|
void InitTask() override
|
||||||
{
|
{
|
||||||
|
@ -21,15 +26,14 @@ struct Receiver : fair::mq::Device
|
||||||
|
|
||||||
void Run() override
|
void Run() override
|
||||||
{
|
{
|
||||||
FairMQChannel& dataInChannel = fChannels.at("sr").at(0);
|
Channel& dataInChannel = GetChannel("sr", 0);
|
||||||
|
|
||||||
while (!NewStatePending()) {
|
while (!NewStatePending()) {
|
||||||
FairMQMessagePtr msg(dataInChannel.Transport()->CreateMessage());
|
auto msg(dataInChannel.NewMessage());
|
||||||
dataInChannel.Receive(msg);
|
dataInChannel.Receive(msg);
|
||||||
// void* ptr = msg->GetData();
|
|
||||||
|
|
||||||
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
||||||
LOG(info) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
|
LOG(info) << "Configured max number of iterations reached. Leaving RUNNING state.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,13 +44,14 @@ struct Receiver : fair::mq::Device
|
||||||
uint64_t fNumIterations = 0;
|
uint64_t fNumIterations = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void addCustomOptions(bpo::options_description& options)
|
void addCustomOptions(bpo::options_description& options)
|
||||||
{
|
{
|
||||||
options.add_options()
|
options.add_options()(
|
||||||
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
"max-iterations",
|
||||||
|
bpo::value<uint64_t>()->default_value(0),
|
||||||
|
"Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<fair::mq::Device> getDevice(fair::mq::ProgOptions& /*config*/)
|
unique_ptr<Device> getDevice(ProgOptions& /*config*/) { return make_unique<Receiver>(); }
|
||||||
{
|
|
||||||
return std::make_unique<Receiver>();
|
|
||||||
}
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ struct Sender : fair::mq::Device
|
||||||
OnData(fInputChannelName, &Sender::HandleData);
|
OnData(fInputChannelName, &Sender::HandleData);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& msg, int /*index*/)
|
bool HandleData(fair::mq::MessagePtr& msg, int /*index*/)
|
||||||
{
|
{
|
||||||
if (Send(msg, "sr") < 0) {
|
if (Send(msg, "sr") < 0) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1,51 +1,12 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
add_executable(fairmq-ex-region-sampler sampler.cxx)
|
add_example(NAME region
|
||||||
target_link_libraries(fairmq-ex-region-sampler PRIVATE FairMQ)
|
DEVICE sampler processor sink keep-alive
|
||||||
|
SCRIPT region region-advanced region-advanced-external
|
||||||
add_executable(fairmq-ex-region-sink sink.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-region-sink PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_custom_target(ExampleRegion DEPENDS fairmq-ex-region-sampler fairmq-ex-region-sink)
|
|
||||||
|
|
||||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-region.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-region.sh)
|
|
||||||
|
|
||||||
# test
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-region.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-region.sh)
|
|
||||||
|
|
||||||
add_test(NAME Example.Region.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-region.sh zeromq)
|
|
||||||
set_tests_properties(Example.Region.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received [0-9*] acks")
|
|
||||||
|
|
||||||
add_test(NAME Example.Region.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-region.sh shmem)
|
|
||||||
set_tests_properties(Example.Region.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received [0-9*] acks")
|
|
||||||
|
|
||||||
# install
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
fairmq-ex-region-sampler
|
|
||||||
fairmq-ex-region-sink
|
|
||||||
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# configure run script with different executable paths for build and for install directories
|
|
||||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-region.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-region.sh_install)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-region.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-region.sh
|
|
||||||
)
|
)
|
||||||
|
|
95
examples/region/fairmq-start-ex-region-advanced-external.sh.in
Executable file
95
examples/region/fairmq-start-ex-region-advanced-external.sh.in
Executable file
|
@ -0,0 +1,95 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
|
transport=${1:-shmem}
|
||||||
|
msgSize=${2:-1000000}
|
||||||
|
|
||||||
|
SAMPLER="fairmq-ex-region-sampler"
|
||||||
|
SAMPLER+=" --id sampler1"
|
||||||
|
# SAMPLER+=" --sampling-rate 10"
|
||||||
|
SAMPLER+=" --severity debug"
|
||||||
|
SAMPLER+=" --msg-size $msgSize"
|
||||||
|
SAMPLER+=" --transport $transport"
|
||||||
|
SAMPLER+=" --shmid 1"
|
||||||
|
SAMPLER+=" --shm-monitor false"
|
||||||
|
SAMPLER+=" --rc-segment-size 200000000"
|
||||||
|
SAMPLER+=" --external-region true"
|
||||||
|
SAMPLER+=" --shm-no-cleanup true"
|
||||||
|
SAMPLER+=" --chan-name data1"
|
||||||
|
SAMPLER+=" --channel-config name=data1,type=push,method=bind,address=tcp://127.0.0.1:7777"
|
||||||
|
xterm -geometry 90x60+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER &
|
||||||
|
|
||||||
|
PROCESSOR1="fairmq-ex-region-processor"
|
||||||
|
PROCESSOR1+=" --id processor1"
|
||||||
|
PROCESSOR1+=" --severity debug"
|
||||||
|
PROCESSOR1+=" --transport $transport"
|
||||||
|
PROCESSOR1+=" --shmid 1"
|
||||||
|
PROCESSOR1+=" --shm-segment-id 1"
|
||||||
|
PROCESSOR1+=" --shm-monitor false"
|
||||||
|
PROCESSOR1+=" --shm-no-cleanup true"
|
||||||
|
PROCESSOR1+=" --channel-config name=data1,type=pull,method=connect,address=tcp://127.0.0.1:7777"
|
||||||
|
PROCESSOR1+=" name=data2,type=push,method=bind,address=tcp://127.0.0.1:7778"
|
||||||
|
PROCESSOR1+=" name=data3,type=push,method=bind,address=tcp://127.0.0.1:7779"
|
||||||
|
xterm -geometry 90x40+550+40 -hold -e @EX_BIN_DIR@/$PROCESSOR1 &
|
||||||
|
|
||||||
|
PROCESSOR2="fairmq-ex-region-processor"
|
||||||
|
PROCESSOR2+=" --id processor2"
|
||||||
|
PROCESSOR2+=" --severity debug"
|
||||||
|
PROCESSOR2+=" --transport $transport"
|
||||||
|
PROCESSOR2+=" --shmid 1"
|
||||||
|
PROCESSOR2+=" --shm-segment-id 2"
|
||||||
|
PROCESSOR2+=" --shm-monitor false"
|
||||||
|
PROCESSOR2+=" --shm-no-cleanup true"
|
||||||
|
PROCESSOR2+=" --channel-config name=data1,type=pull,method=connect,address=tcp://127.0.0.1:7777"
|
||||||
|
PROCESSOR2+=" name=data2,type=push,method=bind,address=tcp://127.0.0.1:7788"
|
||||||
|
PROCESSOR2+=" name=data3,type=push,method=bind,address=tcp://127.0.0.1:7789"
|
||||||
|
xterm -geometry 90x40+550+600 -hold -e @EX_BIN_DIR@/$PROCESSOR2 &
|
||||||
|
|
||||||
|
SINK1_1="fairmq-ex-region-sink"
|
||||||
|
SINK1_1+=" --id sink1_1"
|
||||||
|
SINK1_1+=" --severity debug"
|
||||||
|
SINK1_1+=" --chan-name data2"
|
||||||
|
SINK1_1+=" --transport $transport"
|
||||||
|
SINK1_1+=" --shmid 1"
|
||||||
|
SINK1_1+=" --shm-segment-id 1"
|
||||||
|
SINK1_1+=" --shm-monitor false"
|
||||||
|
SINK1_1+=" --shm-no-cleanup true"
|
||||||
|
SINK1_1+=" --channel-config name=data2,type=pull,method=connect,address=tcp://127.0.0.1:7778"
|
||||||
|
xterm -geometry 90x20+1100+0 -hold -e @EX_BIN_DIR@/$SINK1_1 &
|
||||||
|
|
||||||
|
SINK1_2="fairmq-ex-region-sink"
|
||||||
|
SINK1_2+=" --id sink1_2"
|
||||||
|
SINK1_2+=" --severity debug"
|
||||||
|
SINK1_2+=" --chan-name data3"
|
||||||
|
SINK1_2+=" --transport $transport"
|
||||||
|
SINK1_2+=" --shmid 1"
|
||||||
|
SINK1_2+=" --shm-segment-id 1"
|
||||||
|
SINK1_2+=" --shm-monitor false"
|
||||||
|
SINK1_2+=" --shm-no-cleanup true"
|
||||||
|
SINK1_2+=" --channel-config name=data3,type=pull,method=connect,address=tcp://127.0.0.1:7779"
|
||||||
|
xterm -geometry 90x20+1100+300 -hold -e @EX_BIN_DIR@/$SINK1_2 &
|
||||||
|
|
||||||
|
SINK2_1="fairmq-ex-region-sink"
|
||||||
|
SINK2_1+=" --id sink2_1"
|
||||||
|
SINK2_1+=" --severity debug"
|
||||||
|
SINK2_1+=" --chan-name data2"
|
||||||
|
SINK2_1+=" --transport $transport"
|
||||||
|
SINK2_1+=" --shmid 1"
|
||||||
|
SINK2_1+=" --shm-segment-id 2"
|
||||||
|
SINK2_1+=" --shm-monitor false"
|
||||||
|
SINK2_1+=" --shm-no-cleanup true"
|
||||||
|
SINK2_1+=" --channel-config name=data2,type=pull,method=connect,address=tcp://127.0.0.1:7788"
|
||||||
|
xterm -geometry 90x20+1100+600 -hold -e @EX_BIN_DIR@/$SINK2_1 &
|
||||||
|
|
||||||
|
SINK2_2="fairmq-ex-region-sink"
|
||||||
|
SINK2_2+=" --id sink2_2"
|
||||||
|
SINK2_2+=" --severity debug"
|
||||||
|
SINK2_2+=" --chan-name data3"
|
||||||
|
SINK2_2+=" --transport $transport"
|
||||||
|
SINK2_2+=" --shmid 1"
|
||||||
|
SINK2_2+=" --shm-segment-id 2"
|
||||||
|
SINK2_2+=" --shm-monitor false"
|
||||||
|
SINK2_2+=" --shm-no-cleanup true"
|
||||||
|
SINK2_2+=" --channel-config name=data3,type=pull,method=connect,address=tcp://127.0.0.1:7789"
|
||||||
|
xterm -geometry 90x20+1100+900 -hold -e @EX_BIN_DIR@/$SINK2_2 &
|
80
examples/region/fairmq-start-ex-region-advanced.sh.in
Executable file
80
examples/region/fairmq-start-ex-region-advanced.sh.in
Executable file
|
@ -0,0 +1,80 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
|
transport=${1:-shmem}
|
||||||
|
msgSize=${2:-1000000}
|
||||||
|
|
||||||
|
SAMPLER="fairmq-ex-region-sampler"
|
||||||
|
SAMPLER+=" --id sampler1"
|
||||||
|
# SAMPLER+=" --sampling-rate 10"
|
||||||
|
SAMPLER+=" --severity debug"
|
||||||
|
SAMPLER+=" --msg-size $msgSize"
|
||||||
|
SAMPLER+=" --transport $transport"
|
||||||
|
#SAMPLER+=" --rc-segment-size 0"
|
||||||
|
SAMPLER+=" --shm-monitor true"
|
||||||
|
SAMPLER+=" --chan-name data1"
|
||||||
|
SAMPLER+=" --channel-config name=data1,type=push,method=bind,address=tcp://127.0.0.1:7777"
|
||||||
|
xterm -geometry 90x60+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER &
|
||||||
|
|
||||||
|
PROCESSOR1="fairmq-ex-region-processor"
|
||||||
|
PROCESSOR1+=" --id processor1"
|
||||||
|
PROCESSOR1+=" --severity debug"
|
||||||
|
PROCESSOR1+=" --transport $transport"
|
||||||
|
PROCESSOR1+=" --shm-segment-id 1"
|
||||||
|
PROCESSOR1+=" --shm-monitor true"
|
||||||
|
PROCESSOR1+=" --channel-config name=data1,type=pull,method=connect,address=tcp://127.0.0.1:7777"
|
||||||
|
PROCESSOR1+=" name=data2,type=push,method=bind,address=tcp://127.0.0.1:7778"
|
||||||
|
PROCESSOR1+=" name=data3,type=push,method=bind,address=tcp://127.0.0.1:7779"
|
||||||
|
xterm -geometry 90x40+550+40 -hold -e @EX_BIN_DIR@/$PROCESSOR1 &
|
||||||
|
|
||||||
|
PROCESSOR2="fairmq-ex-region-processor"
|
||||||
|
PROCESSOR2+=" --id processor2"
|
||||||
|
PROCESSOR2+=" --severity debug"
|
||||||
|
PROCESSOR2+=" --transport $transport"
|
||||||
|
PROCESSOR2+=" --shm-segment-id 2"
|
||||||
|
PROCESSOR2+=" --shm-monitor true"
|
||||||
|
PROCESSOR2+=" --channel-config name=data1,type=pull,method=connect,address=tcp://127.0.0.1:7777"
|
||||||
|
PROCESSOR2+=" name=data2,type=push,method=bind,address=tcp://127.0.0.1:7788"
|
||||||
|
PROCESSOR2+=" name=data3,type=push,method=bind,address=tcp://127.0.0.1:7789"
|
||||||
|
xterm -geometry 90x40+550+600 -hold -e @EX_BIN_DIR@/$PROCESSOR2 &
|
||||||
|
|
||||||
|
SINK1_1="fairmq-ex-region-sink"
|
||||||
|
SINK1_1+=" --id sink1_1"
|
||||||
|
SINK1_1+=" --severity debug"
|
||||||
|
SINK1_1+=" --chan-name data2"
|
||||||
|
SINK1_1+=" --transport $transport"
|
||||||
|
SINK1_1+=" --shm-segment-id 1"
|
||||||
|
SINK1_1+=" --shm-monitor true"
|
||||||
|
SINK1_1+=" --channel-config name=data2,type=pull,method=connect,address=tcp://127.0.0.1:7778"
|
||||||
|
xterm -geometry 90x20+1100+0 -hold -e @EX_BIN_DIR@/$SINK1_1 &
|
||||||
|
|
||||||
|
SINK1_2="fairmq-ex-region-sink"
|
||||||
|
SINK1_2+=" --id sink1_2"
|
||||||
|
SINK1_2+=" --severity debug"
|
||||||
|
SINK1_2+=" --chan-name data3"
|
||||||
|
SINK1_2+=" --transport $transport"
|
||||||
|
SINK1_2+=" --shm-segment-id 1"
|
||||||
|
SINK1_2+=" --shm-monitor true"
|
||||||
|
SINK1_2+=" --channel-config name=data3,type=pull,method=connect,address=tcp://127.0.0.1:7779"
|
||||||
|
xterm -geometry 90x20+1100+300 -hold -e @EX_BIN_DIR@/$SINK1_2 &
|
||||||
|
|
||||||
|
SINK2_1="fairmq-ex-region-sink"
|
||||||
|
SINK2_1+=" --id sink2_1"
|
||||||
|
SINK2_1+=" --severity debug"
|
||||||
|
SINK2_1+=" --chan-name data2"
|
||||||
|
SINK2_1+=" --transport $transport"
|
||||||
|
SINK2_1+=" --shm-segment-id 2"
|
||||||
|
SINK2_1+=" --shm-monitor true"
|
||||||
|
SINK2_1+=" --channel-config name=data2,type=pull,method=connect,address=tcp://127.0.0.1:7788"
|
||||||
|
xterm -geometry 90x20+1100+600 -hold -e @EX_BIN_DIR@/$SINK2_1 &
|
||||||
|
|
||||||
|
SINK2_2="fairmq-ex-region-sink"
|
||||||
|
SINK2_2+=" --id sink2_2"
|
||||||
|
SINK2_2+=" --severity debug"
|
||||||
|
SINK2_2+=" --chan-name data3"
|
||||||
|
SINK2_2+=" --transport $transport"
|
||||||
|
SINK2_2+=" --shm-segment-id 2"
|
||||||
|
SINK2_2+=" --shm-monitor true"
|
||||||
|
SINK2_2+=" --channel-config name=data3,type=pull,method=connect,address=tcp://127.0.0.1:7789"
|
||||||
|
xterm -geometry 90x20+1100+900 -hold -e @EX_BIN_DIR@/$SINK2_2 &
|
|
@ -2,16 +2,8 @@
|
||||||
|
|
||||||
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
transport="shmem"
|
transport=${1:-shmem}
|
||||||
msgSize="1000000"
|
msgSize=${2:-1000000}
|
||||||
|
|
||||||
if [[ $1 =~ ^[a-z]+$ ]]; then
|
|
||||||
transport=$1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $2 =~ ^[0-9]+$ ]]; then
|
|
||||||
msgSize=$1
|
|
||||||
fi
|
|
||||||
|
|
||||||
SAMPLER="fairmq-ex-region-sampler"
|
SAMPLER="fairmq-ex-region-sampler"
|
||||||
SAMPLER+=" --id sampler1"
|
SAMPLER+=" --id sampler1"
|
||||||
|
@ -19,6 +11,10 @@ SAMPLER+=" --severity debug"
|
||||||
SAMPLER+=" --msg-size $msgSize"
|
SAMPLER+=" --msg-size $msgSize"
|
||||||
# SAMPLER+=" --rate 10"
|
# SAMPLER+=" --rate 10"
|
||||||
SAMPLER+=" --transport $transport"
|
SAMPLER+=" --transport $transport"
|
||||||
|
# SAMPLER+=" --external-region true"
|
||||||
|
# SAMPLER+=" --shm-no-cleaup true"
|
||||||
|
SAMPLER+=" --shm-monitor true"
|
||||||
|
# SAMPLER+=" --shmid 1"
|
||||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://127.0.0.1:7777,sndKernelSize=212992"
|
SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://127.0.0.1:7777,sndKernelSize=212992"
|
||||||
xterm -geometry 120x60+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER &
|
xterm -geometry 120x60+0+0 -hold -e @EX_BIN_DIR@/$SAMPLER &
|
||||||
|
|
||||||
|
@ -26,5 +22,8 @@ SINK="fairmq-ex-region-sink"
|
||||||
SINK+=" --id sink1"
|
SINK+=" --id sink1"
|
||||||
SINK+=" --severity debug"
|
SINK+=" --severity debug"
|
||||||
SINK+=" --transport $transport"
|
SINK+=" --transport $transport"
|
||||||
|
# SINK+=" --shm-no-cleaup true"
|
||||||
|
SINK+=" --shm-monitor true"
|
||||||
|
# SINK+=" --shmid 1"
|
||||||
SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://127.0.0.1:7777,rcvKernelSize=212992"
|
SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://127.0.0.1:7777,rcvKernelSize=212992"
|
||||||
xterm -geometry 120x60+750+0 -hold -e @EX_BIN_DIR@/$SINK &
|
xterm -geometry 120x60+750+0 -hold -e @EX_BIN_DIR@/$SINK &
|
||||||
|
|
226
examples/region/keep-alive.cxx
Normal file
226
examples/region/keep-alive.cxx
Normal file
|
@ -0,0 +1,226 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (C) 2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
|
* *
|
||||||
|
* This software is distributed under the terms of the *
|
||||||
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
|
* copied verbatim in the file "LICENSE" *
|
||||||
|
********************************************************************************/
|
||||||
|
#include <fairmq/shmem/Common.h>
|
||||||
|
#include <fairmq/shmem/Monitor.h>
|
||||||
|
#include <fairmq/shmem/Segment.h>
|
||||||
|
#include <fairmq/shmem/UnmanagedRegion.h>
|
||||||
|
#include <fairmq/tools/Unique.h>
|
||||||
|
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
|
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
#include <csignal>
|
||||||
|
#include <map>
|
||||||
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
using namespace boost::program_options;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
volatile sig_atomic_t gStopping = 0;
|
||||||
|
volatile sig_atomic_t gResetContent = 0;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void signalHandler(int /* signal */) { gStopping = 1; }
|
||||||
|
|
||||||
|
void resetContentHandler(int /* signal */) { gResetContent = 1; }
|
||||||
|
|
||||||
|
struct ShmManager
|
||||||
|
{
|
||||||
|
ShmManager(uint64_t _shmId, const vector<string>& _segments, const vector<string>& _regions, bool zero = true)
|
||||||
|
: shmId(fair::mq::shmem::makeShmIdStr(_shmId))
|
||||||
|
{
|
||||||
|
LOG(info) << "Starting ShmManager for shmId: " << shmId;
|
||||||
|
LOG(info) << "Performing full reset...";
|
||||||
|
FullReset();
|
||||||
|
LOG(info) << "Done.";
|
||||||
|
LOG(info) << "Adding managed segments...";
|
||||||
|
AddSegments(_segments, zero);
|
||||||
|
LOG(info) << "Done.";
|
||||||
|
LOG(info) << "Adding unmanaged regions...";
|
||||||
|
AddRegions(_regions, zero);
|
||||||
|
LOG(info) << "Done.";
|
||||||
|
LOG(info) << "Shared memory is ready for use.";
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddSegments(const vector<string>& _segments, bool zero)
|
||||||
|
{
|
||||||
|
for (const auto& s : _segments) {
|
||||||
|
vector<string> conf;
|
||||||
|
boost::algorithm::split(conf, s, boost::algorithm::is_any_of(","));
|
||||||
|
if (conf.size() != 3) {
|
||||||
|
LOG(error) << "incorrect format for --segments. Expecting pairs of <id>,<size><numaid>.";
|
||||||
|
fair::mq::shmem::Monitor::Cleanup(fair::mq::shmem::ShmId{shmId});
|
||||||
|
throw runtime_error("incorrect format for --segments. Expecting pairs of <id>,<size>,<numaid>.");
|
||||||
|
}
|
||||||
|
uint16_t id = stoi(conf.at(0));
|
||||||
|
uint64_t size = stoull(conf.at(1));
|
||||||
|
segmentCfgs.emplace_back(fair::mq::shmem::SegmentConfig{id, size, "rbtree_best_fit"});
|
||||||
|
|
||||||
|
auto ret = segments.emplace(id, fair::mq::shmem::Segment(shmId, id, size, fair::mq::shmem::rbTreeBestFit));
|
||||||
|
fair::mq::shmem::Segment& segment = ret.first->second;
|
||||||
|
LOG(info) << "Created segment " << id << " of size " << segment.GetSize()
|
||||||
|
<< ", starting at " << segment.GetData() << ". Locking...";
|
||||||
|
segment.Lock();
|
||||||
|
LOG(info) << "Done.";
|
||||||
|
if (zero) {
|
||||||
|
LOG(info) << "Zeroing...";
|
||||||
|
segment.Zero();
|
||||||
|
LOG(info) << "Done.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddRegions(const vector<string>& _regions, bool zero)
|
||||||
|
{
|
||||||
|
for (const auto& r : _regions) {
|
||||||
|
vector<string> conf;
|
||||||
|
boost::algorithm::split(conf, r, boost::algorithm::is_any_of(","));
|
||||||
|
if (conf.size() != 3) {
|
||||||
|
LOG(error) << "incorrect format for --regions. Expecting pairs of <id>,<size>,<numaid>.";
|
||||||
|
fair::mq::shmem::Monitor::Cleanup(fair::mq::shmem::ShmId{shmId});
|
||||||
|
throw runtime_error("incorrect format for --regions. Expecting pairs of <id>,<size>,<numaid>.");
|
||||||
|
}
|
||||||
|
uint16_t id = stoi(conf.at(0));
|
||||||
|
uint64_t size = stoull(conf.at(1));
|
||||||
|
fair::mq::RegionConfig cfg;
|
||||||
|
cfg.id = id;
|
||||||
|
cfg.rcSegmentSize = 0;
|
||||||
|
cfg.size = size;
|
||||||
|
regionCfgs.push_back(cfg);
|
||||||
|
|
||||||
|
auto ret = regions.emplace(id, make_unique<fair::mq::shmem::UnmanagedRegion>(shmId, cfg));
|
||||||
|
fair::mq::shmem::UnmanagedRegion& region = *(ret.first->second);
|
||||||
|
LOG(info) << "Created unamanged region " << id << " of size " << region.GetSize()
|
||||||
|
<< ", starting at " << region.GetData() << ". Locking...";
|
||||||
|
region.Lock();
|
||||||
|
LOG(info) << "Done.";
|
||||||
|
if (zero) {
|
||||||
|
LOG(info) << "Zeroing...";
|
||||||
|
region.Zero();
|
||||||
|
LOG(info) << "Done.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CheckPresence()
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(localMtx);
|
||||||
|
for (const auto& sc : segmentCfgs) {
|
||||||
|
if (!(fair::mq::shmem::Monitor::SegmentIsPresent(fair::mq::shmem::ShmId{shmId}, sc.id))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (const auto& rc : regionCfgs) {
|
||||||
|
if (!(fair::mq::shmem::Monitor::RegionIsPresent(fair::mq::shmem::ShmId{shmId}, rc.id.value()))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetContent()
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(localMtx);
|
||||||
|
fair::mq::shmem::Monitor::ResetContent(fair::mq::shmem::ShmId{shmId}, segmentCfgs, regionCfgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FullReset()
|
||||||
|
{
|
||||||
|
segments.clear();
|
||||||
|
regions.clear();
|
||||||
|
fair::mq::shmem::Monitor::Cleanup(fair::mq::shmem::ShmId{shmId});
|
||||||
|
}
|
||||||
|
|
||||||
|
~ShmManager()
|
||||||
|
{
|
||||||
|
// clean all segments, regions and any other shmem objects belonging to this shmId
|
||||||
|
fair::mq::shmem::Monitor::Cleanup(fair::mq::shmem::ShmId{shmId});
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string shmId;
|
||||||
|
std::mutex localMtx;
|
||||||
|
map<uint16_t, fair::mq::shmem::Segment> segments;
|
||||||
|
map<uint16_t, unique_ptr<fair::mq::shmem::UnmanagedRegion>> regions;
|
||||||
|
std::vector<fair::mq::shmem::SegmentConfig> segmentCfgs;
|
||||||
|
std::vector<fair::mq::RegionConfig> regionCfgs;
|
||||||
|
};
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
fair::Logger::SetConsoleColor(true);
|
||||||
|
|
||||||
|
signal(SIGINT, signalHandler);
|
||||||
|
signal(SIGTERM, signalHandler);
|
||||||
|
signal(SIGUSR1, resetContentHandler);
|
||||||
|
|
||||||
|
try {
|
||||||
|
bool nozero = false;
|
||||||
|
bool checkPresence = true;
|
||||||
|
uint64_t shmId = 0;
|
||||||
|
vector<string> segments;
|
||||||
|
vector<string> regions;
|
||||||
|
|
||||||
|
options_description desc("Options");
|
||||||
|
desc.add_options()
|
||||||
|
("shmid", value<uint64_t>(&shmId)->required(), "Shm id")
|
||||||
|
("segments", value<vector<string>>(&segments)->multitoken()->composing(), "Segments, as <id>,<size>,<numaid> <id>,<size>,<numaid> <id>,<size>,<numaid> ... (numaid: -2 disabled, -1 interleave, >=0 node)")
|
||||||
|
("regions", value<vector<string>>(®ions)->multitoken()->composing(), "Regions, as <id>,<size> <id>,<size>,<numaid> <id>,<size>,<numaid> ...")
|
||||||
|
("nozero", value<bool>(&nozero)->default_value(false)->implicit_value(true), "Do not zero segments after initialization")
|
||||||
|
("check-presence", value<bool>(&checkPresence)->default_value(true)->implicit_value(true), "Check periodically if configured segments/regions are still present, and cleanup and leave if they are not")
|
||||||
|
("help,h", "Print help");
|
||||||
|
|
||||||
|
variables_map vm;
|
||||||
|
store(parse_command_line(argc, argv, desc), vm);
|
||||||
|
|
||||||
|
if (vm.count("help")) {
|
||||||
|
LOG(info) << "ShmManager" << "\n" << desc;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
notify(vm);
|
||||||
|
|
||||||
|
ShmManager shmManager(shmId, segments, regions, !nozero);
|
||||||
|
|
||||||
|
std::thread resetContentThread([&shmManager]() {
|
||||||
|
while (!gStopping) {
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
|
if (gResetContent == 1) {
|
||||||
|
LOG(info) << "Resetting content for shmId " << shmManager.shmId;
|
||||||
|
shmManager.ResetContent();
|
||||||
|
gResetContent = 0;
|
||||||
|
LOG(info) << "Done resetting content for shmId " << shmManager.shmId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (checkPresence) {
|
||||||
|
while (!gStopping) {
|
||||||
|
if (shmManager.CheckPresence() == false) {
|
||||||
|
LOG(error) << "Failed to find segments, exiting.";
|
||||||
|
gStopping = true;
|
||||||
|
}
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resetContentThread.join();
|
||||||
|
|
||||||
|
LOG(info) << "stopping.";
|
||||||
|
} catch (exception& e) {
|
||||||
|
LOG(error) << "Exception reached the top of main: " << e.what() << ", exiting";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
80
examples/region/processor.cxx
Normal file
80
examples/region/processor.cxx
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
/********************************************************************************
|
||||||
|
* Copyright (C) 2014-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
|
* *
|
||||||
|
* This software is distributed under the terms of the *
|
||||||
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
|
* copied verbatim in the file "LICENSE" *
|
||||||
|
********************************************************************************/
|
||||||
|
|
||||||
|
#include <fairmq/Device.h>
|
||||||
|
#include <fairmq/runDevice.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace bpo = boost::program_options;
|
||||||
|
using namespace std;
|
||||||
|
using namespace fair::mq;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
struct Processor : Device
|
||||||
|
{
|
||||||
|
void InitTask() override
|
||||||
|
{
|
||||||
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
|
GetChannel("data1", 0).Transport()->SubscribeToRegionEvents([](RegionInfo info) {
|
||||||
|
LOG(info) << "Region event: " << info.event << ": "
|
||||||
|
<< (info.managed ? "managed" : "unmanaged") << ", id: " << info.id
|
||||||
|
<< ", ptr: " << info.ptr << ", size: " << info.size
|
||||||
|
<< ", flags: " << info.flags;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Run() override
|
||||||
|
{
|
||||||
|
Channel& dataIn = GetChannel("data1", 0);
|
||||||
|
Channel& dataOut1 = GetChannel("data2", 0);
|
||||||
|
Channel& dataOut2 = GetChannel("data3", 0);
|
||||||
|
|
||||||
|
while (!NewStatePending()) {
|
||||||
|
fair::mq::Parts inParts;
|
||||||
|
dataIn.Receive(inParts);
|
||||||
|
|
||||||
|
fair::mq::Parts outParts1;
|
||||||
|
fair::mq::Parts outParts2;
|
||||||
|
|
||||||
|
for (const auto& inPart : inParts) {
|
||||||
|
outParts1.AddPart(NewMessage());
|
||||||
|
outParts1.fParts.back()->Copy(*inPart);
|
||||||
|
|
||||||
|
outParts2.AddPart(NewMessage());
|
||||||
|
outParts2.fParts.back()->Copy(*inPart);
|
||||||
|
}
|
||||||
|
|
||||||
|
dataOut1.Send(outParts1);
|
||||||
|
dataOut2.Send(outParts2);
|
||||||
|
|
||||||
|
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
||||||
|
LOG(info) << "Configured max number of iterations reached. Leaving RUNNING state.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResetTask() override
|
||||||
|
{
|
||||||
|
GetChannel("data1", 0).Transport()->UnsubscribeFromRegionEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
uint64_t fMaxIterations = 0;
|
||||||
|
uint64_t fNumIterations = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
void addCustomOptions(bpo::options_description& options)
|
||||||
|
{
|
||||||
|
options.add_options()("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||||
|
}
|
||||||
|
|
||||||
|
unique_ptr<Device> getDevice(ProgOptions& /*config*/) { return make_unique<Processor>(); }
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <fairmq/Device.h>
|
#include <fairmq/Device.h>
|
||||||
#include <fairmq/runDevice.h>
|
#include <fairmq/runDevice.h>
|
||||||
|
#include <fairmq/tools/RateLimit.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
@ -19,11 +20,15 @@ struct Sampler : fair::mq::Device
|
||||||
{
|
{
|
||||||
void InitTask() override
|
void InitTask() override
|
||||||
{
|
{
|
||||||
|
fExternalRegion = fConfig->GetProperty<bool>("external-region");
|
||||||
fMsgSize = fConfig->GetProperty<int>("msg-size");
|
fMsgSize = fConfig->GetProperty<int>("msg-size");
|
||||||
fLinger = fConfig->GetProperty<uint32_t>("region-linger");
|
fLinger = fConfig->GetProperty<uint32_t>("region-linger");
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
|
fChanName = fConfig->GetProperty<std::string>("chan-name");
|
||||||
|
fSamplingRate = fConfig->GetProperty<float>("sampling-rate");
|
||||||
|
fRCSegmentSize = fConfig->GetProperty<uint64_t>("rc-segment-size");
|
||||||
|
|
||||||
fChannels.at("data").at(0).Transport()->SubscribeToRegionEvents([](FairMQRegionInfo info) {
|
GetChannel(fChanName, 0).Transport()->SubscribeToRegionEvents([](fair::mq::RegionInfo info) {
|
||||||
LOG(info) << "Region event: " << info.event << ": "
|
LOG(info) << "Region event: " << info.event << ": "
|
||||||
<< (info.managed ? "managed" : "unmanaged")
|
<< (info.managed ? "managed" : "unmanaged")
|
||||||
<< ", id: " << info.id
|
<< ", id: " << info.id
|
||||||
|
@ -32,80 +37,111 @@ struct Sampler : fair::mq::Device
|
||||||
<< ", flags: " << info.flags;
|
<< ", flags: " << info.flags;
|
||||||
});
|
});
|
||||||
|
|
||||||
fRegion = FairMQUnmanagedRegionPtr(NewUnmanagedRegionFor("data", // region is created using the transport of this channel...
|
fair::mq::RegionConfig regionCfg;
|
||||||
0, // ... and this sub-channel
|
regionCfg.linger = fLinger; // delay in ms before region destruction to collect outstanding events
|
||||||
10000000, // region size
|
// options for testing with an externally-created -region
|
||||||
[this](const std::vector<fair::mq::RegionBlock>& blocks) { // callback to be called when message buffers no longer needed by transport
|
if (fExternalRegion) {
|
||||||
std::lock_guard<std::mutex> lock(fMtx);
|
regionCfg.id = 1;
|
||||||
fNumUnackedMsgs -= blocks.size();
|
regionCfg.removeOnDestruction = false;
|
||||||
|
}
|
||||||
if (fMaxIterations > 0) {
|
regionCfg.lock = !fExternalRegion; // mlock region after creation
|
||||||
LOG(info) << "Received " << blocks.size() << " acks";
|
regionCfg.zero = !fExternalRegion; // zero region content after creation
|
||||||
}
|
regionCfg.rcSegmentSize = fRCSegmentSize; // size of the corresponding reference count segment
|
||||||
},
|
fRegion = fair::mq::UnmanagedRegionPtr(NewUnmanagedRegionFor(
|
||||||
"", // path, if a region is backed by a file
|
fChanName, // region is created using the transport of this channel...
|
||||||
0, // flags that are passed for region creation
|
0, // ... and this sub-channel
|
||||||
fair::mq::RegionConfig{true, true} // additional config: { call mlock on the region, zero the region memory }
|
10000000, // region size
|
||||||
));
|
[this](const std::vector<fair::mq::RegionBlock>& blocks) { // callback to be called when message buffers no longer needed by transport
|
||||||
fRegion->SetLinger(fLinger);
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
|
fNumUnackedMsgs -= blocks.size();
|
||||||
|
if (fMaxIterations > 0) {
|
||||||
|
LOG(info) << "Received " << blocks.size() << " acks";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
regionCfg
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConditionalRun() override
|
void Run() override
|
||||||
{
|
{
|
||||||
FairMQMessagePtr msg(NewMessageFor("data", // channel
|
|
||||||
0, // sub-channel
|
|
||||||
fRegion, // region
|
|
||||||
fRegion->GetData(), // ptr within region
|
|
||||||
fMsgSize, // offset from ptr
|
|
||||||
nullptr // hint
|
|
||||||
));
|
|
||||||
|
|
||||||
// static_cast<char*>(fRegion->GetData())[3] = 97;
|
fair::mq::tools::RateLimiter rateLimiter(fSamplingRate);
|
||||||
// LOG(info) << "check: " << static_cast<char*>(fRegion->GetData())[3];
|
|
||||||
// std::this_thread::sleep_for(std::chrono::seconds(1));
|
|
||||||
|
|
||||||
std::lock_guard<std::mutex> lock(fMtx);
|
while (!NewStatePending()) {
|
||||||
++fNumUnackedMsgs;
|
fair::mq::Parts parts;
|
||||||
if (Send(msg, "data", 0) > 0) {
|
// make 64 parts
|
||||||
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
for (int i = 0; i < 64; ++i) {
|
||||||
LOG(info) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
|
parts.AddPart(NewMessageFor(
|
||||||
return false;
|
fChanName, // channel
|
||||||
|
0, // sub-channel
|
||||||
|
fRegion, // region
|
||||||
|
fRegion->GetData(), // ptr within region
|
||||||
|
fMsgSize, // offset from ptr
|
||||||
|
nullptr // hint
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
|
fNumUnackedMsgs += parts.Size();
|
||||||
|
if (Send(parts, fChanName, 0) > 0) {
|
||||||
|
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
||||||
|
LOG(info) << "Configured maximum number of iterations reached. Stopping sending.";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (fSamplingRate > 0.001) {
|
||||||
|
rateLimiter.maybe_sleep();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
// wait for all acks to arrive
|
||||||
|
while (!NewStatePending()) {
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(fMtx);
|
||||||
|
if (fNumUnackedMsgs == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(25));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fNumUnackedMsgs != 0) {
|
||||||
|
LOG(info) << "Done, still not acknowledged: " << fNumUnackedMsgs;
|
||||||
|
} else {
|
||||||
|
LOG(info) << "All acknowledgements received.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetTask() override
|
void ResetTask() override
|
||||||
{
|
{
|
||||||
fRegion.reset();
|
fRegion.reset();
|
||||||
{
|
GetChannel(fChanName, 0).Transport()->UnsubscribeFromRegionEvents();
|
||||||
std::lock_guard<std::mutex> lock(fMtx);
|
|
||||||
if (fNumUnackedMsgs != 0) {
|
|
||||||
LOG(info) << "Done, still not acknowledged: " << fNumUnackedMsgs;
|
|
||||||
} else {
|
|
||||||
LOG(info) << "All acknowledgements received.";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fChannels.at("data").at(0).Transport()->UnsubscribeFromRegionEvents();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int fExternalRegion = false;
|
||||||
int fMsgSize = 10000;
|
int fMsgSize = 10000;
|
||||||
uint32_t fLinger = 100;
|
uint32_t fLinger = 100;
|
||||||
uint64_t fMaxIterations = 0;
|
uint64_t fMaxIterations = 0;
|
||||||
uint64_t fNumIterations = 0;
|
uint64_t fNumIterations = 0;
|
||||||
FairMQUnmanagedRegionPtr fRegion = nullptr;
|
uint64_t fRCSegmentSize = 10000000;
|
||||||
|
fair::mq::UnmanagedRegionPtr fRegion = nullptr;
|
||||||
std::mutex fMtx;
|
std::mutex fMtx;
|
||||||
uint64_t fNumUnackedMsgs = 0;
|
uint64_t fNumUnackedMsgs = 0;
|
||||||
|
std::string fChanName;
|
||||||
|
float fSamplingRate = 0.;
|
||||||
};
|
};
|
||||||
|
|
||||||
void addCustomOptions(bpo::options_description& options)
|
void addCustomOptions(bpo::options_description& options)
|
||||||
{
|
{
|
||||||
options.add_options()
|
options.add_options()
|
||||||
|
("chan-name", bpo::value<std::string>()->default_value("data"), "name of the output channel")
|
||||||
("msg-size", bpo::value<int>()->default_value(1000), "Message size in bytes")
|
("msg-size", bpo::value<int>()->default_value(1000), "Message size in bytes")
|
||||||
|
("sampling-rate", bpo::value<float>()->default_value(0.), "Sampling rate (Hz).")
|
||||||
("region-linger", bpo::value<uint32_t>()->default_value(100), "Linger period for regions")
|
("region-linger", bpo::value<uint32_t>()->default_value(100), "Linger period for regions")
|
||||||
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)")
|
||||||
|
("external-region", bpo::value<bool>()->default_value(false), "Use region created by another process")
|
||||||
|
("rc-segment-size", bpo::value<uint64_t>()->default_value(10000000), "Size of the reference count segment for Unamanged Region");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<fair::mq::Device> getDevice(fair::mq::ProgOptions& /*config*/)
|
std::unique_ptr<fair::mq::Device> getDevice(fair::mq::ProgOptions& /*config*/)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2014-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
|
@ -8,60 +8,62 @@
|
||||||
|
|
||||||
#include <fairmq/Device.h>
|
#include <fairmq/Device.h>
|
||||||
#include <fairmq/runDevice.h>
|
#include <fairmq/runDevice.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
|
using namespace std;
|
||||||
|
using namespace fair::mq;
|
||||||
|
|
||||||
struct Sink : fair::mq::Device
|
namespace {
|
||||||
|
|
||||||
|
struct Sink : Device
|
||||||
{
|
{
|
||||||
void InitTask() override
|
void InitTask() override
|
||||||
{
|
{
|
||||||
// Get the fMaxIterations value from the command line options (via fConfig)
|
// Get the fMaxIterations value from the command line options (via fConfig)
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
fChannels.at("data").at(0).Transport()->SubscribeToRegionEvents([](FairMQRegionInfo info) {
|
fChanName = fConfig->GetProperty<std::string>("chan-name");
|
||||||
|
GetChannel(fChanName, 0).Transport()->SubscribeToRegionEvents([](RegionInfo info) {
|
||||||
LOG(info) << "Region event: " << info.event << ": "
|
LOG(info) << "Region event: " << info.event << ": "
|
||||||
<< (info.managed ? "managed" : "unmanaged")
|
<< (info.managed ? "managed" : "unmanaged") << ", id: " << info.id
|
||||||
<< ", id: " << info.id
|
<< ", ptr: " << info.ptr << ", size: " << info.size
|
||||||
<< ", ptr: " << info.ptr
|
<< ", flags: " << info.flags;
|
||||||
<< ", size: " << info.size
|
|
||||||
<< ", flags: " << info.flags;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Run() override
|
void Run() override
|
||||||
{
|
{
|
||||||
FairMQChannel& dataInChannel = fChannels.at("data").at(0);
|
Channel& dataIn = GetChannel(fChanName, 0);
|
||||||
|
|
||||||
while (!NewStatePending()) {
|
while (!NewStatePending()) {
|
||||||
FairMQMessagePtr msg(dataInChannel.Transport()->CreateMessage());
|
fair::mq::Parts parts;
|
||||||
dataInChannel.Receive(msg);
|
dataIn.Receive(parts);
|
||||||
|
|
||||||
// void* ptr = msg->GetData();
|
|
||||||
// char* cptr = static_cast<char*>(ptr);
|
|
||||||
// LOG(info) << "check: " << cptr[3];
|
|
||||||
|
|
||||||
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
if (fMaxIterations > 0 && ++fNumIterations >= fMaxIterations) {
|
||||||
LOG(info) << "Configured maximum number of iterations reached. Leaving RUNNING state.";
|
LOG(info) << "Configured max number of iterations reached. Leaving RUNNING state.";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResetTask() override
|
void ResetTask() override
|
||||||
{
|
{
|
||||||
fChannels.at("data").at(0).Transport()->UnsubscribeFromRegionEvents();
|
GetChannel(fChanName, 0).Transport()->UnsubscribeFromRegionEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint64_t fMaxIterations = 0;
|
uint64_t fMaxIterations = 0;
|
||||||
uint64_t fNumIterations = 0;
|
uint64_t fNumIterations = 0;
|
||||||
|
std::string fChanName;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void addCustomOptions(bpo::options_description& options)
|
void addCustomOptions(bpo::options_description& options)
|
||||||
{
|
{
|
||||||
options.add_options()
|
options.add_options()
|
||||||
|
("chan-name", bpo::value<std::string>()->default_value("data"), "name of the input channel")
|
||||||
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
("max-iterations", bpo::value<uint64_t>()->default_value(0), "Maximum number of iterations of Run/ConditionalRun/OnData (0 - infinite)");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<fair::mq::Device> getDevice(fair::mq::ProgOptions& /*config*/)
|
unique_ptr<Device> getDevice(ProgOptions& /*config*/) { return make_unique<Sink>(); }
|
||||||
{
|
|
||||||
return std::make_unique<Sink>();
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
transport="zeromq"
|
transport="zeromq"
|
||||||
|
@ -9,22 +11,26 @@ if [[ $1 =~ ^[a-z]+$ ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msgSize="1000000"
|
msgSize="1000000"
|
||||||
SESSION="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
session="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
||||||
|
chan="data"
|
||||||
|
chanAddr="/tmp/fmq_$session""_""$chan""_""$transport"
|
||||||
|
|
||||||
# setup a trap to kill everything if the test fails/timeouts
|
# setup a trap to kill everything if the test fails/timeouts
|
||||||
trap 'kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID; @CMAKE_BINARY_DIR@/fairmq/fairmq-shmmonitor --cleanup --session $SESSION' TERM
|
trap 'set +e; kill -TERM $SAMPLER_PID; kill -TERM $SINK_PID; wait $SAMPLER_PID; wait $SINK_PID; @CMAKE_BINARY_DIR@/fairmq/fairmq-shmmonitor --cleanup --session $SESSION; rm $chanAddr; exit 0' TERM
|
||||||
|
|
||||||
SAMPLER="fairmq-ex-region-sampler"
|
SAMPLER="fairmq-ex-region-sampler"
|
||||||
SAMPLER+=" --id sampler1"
|
SAMPLER+=" --id sampler1"
|
||||||
SAMPLER+=" --transport $transport"
|
SAMPLER+=" --transport $transport"
|
||||||
SAMPLER+=" --severity debug"
|
SAMPLER+=" --severity debug"
|
||||||
SAMPLER+=" --session $SESSION"
|
SAMPLER+=" --session $session"
|
||||||
|
SAMPLER+=" --shm-segment-size 100000000"
|
||||||
|
SAMPLER+=" --shm-monitor true"
|
||||||
SAMPLER+=" --verbosity veryhigh"
|
SAMPLER+=" --verbosity veryhigh"
|
||||||
SAMPLER+=" --control static --color false"
|
SAMPLER+=" --control static --color false"
|
||||||
SAMPLER+=" --max-iterations 1"
|
SAMPLER+=" --max-iterations 1"
|
||||||
SAMPLER+=" --msg-size $msgSize"
|
SAMPLER+=" --msg-size $msgSize"
|
||||||
SAMPLER+=" --region-linger 500"
|
SAMPLER+=" --region-linger 500"
|
||||||
SAMPLER+=" --channel-config name=data,type=push,method=bind,address=tcp://127.0.0.1:7777"
|
SAMPLER+=" --channel-config name=$chan,type=push,method=bind,address=ipc://$chanAddr"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
@CMAKE_CURRENT_BINARY_DIR@/$SAMPLER &
|
||||||
SAMPLER_PID=$!
|
SAMPLER_PID=$!
|
||||||
|
|
||||||
|
@ -32,14 +38,20 @@ SINK="fairmq-ex-region-sink"
|
||||||
SINK+=" --id sink1"
|
SINK+=" --id sink1"
|
||||||
SINK+=" --transport $transport"
|
SINK+=" --transport $transport"
|
||||||
SINK+=" --severity debug"
|
SINK+=" --severity debug"
|
||||||
SINK+=" --session $SESSION"
|
SINK+=" --session $session"
|
||||||
|
SINK+=" --shm-segment-size 100000000"
|
||||||
|
SINK+=" --shm-monitor true"
|
||||||
SINK+=" --verbosity veryhigh"
|
SINK+=" --verbosity veryhigh"
|
||||||
SINK+=" --control static --color false"
|
SINK+=" --control static --color false"
|
||||||
SINK+=" --max-iterations 1"
|
SINK+=" --max-iterations 1"
|
||||||
SINK+=" --channel-config name=data,type=pull,method=connect,address=tcp://127.0.0.1:7777"
|
SINK+=" --channel-config name=$chan,type=pull,method=connect,address=ipc://$chanAddr"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
@CMAKE_CURRENT_BINARY_DIR@/$SINK &
|
||||||
SINK_PID=$!
|
SINK_PID=$!
|
||||||
|
|
||||||
# wait for sampler and sink to finish
|
# wait for sampler and sink to finish
|
||||||
wait $SAMPLER_PID
|
wait $SAMPLER_PID
|
||||||
wait $SINK_PID
|
wait $SINK_PID
|
||||||
|
|
||||||
|
set +e
|
||||||
|
rm $chanAddr
|
||||||
|
exit 0
|
||||||
|
|
|
@ -1,52 +1,11 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2014-2023 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
add_executable(fairmq-ex-req-rep-client client.cxx)
|
add_example(NAME req-rep
|
||||||
target_link_libraries(fairmq-ex-req-rep-client PRIVATE FairMQ)
|
DEVICE client server
|
||||||
|
|
||||||
|
|
||||||
add_executable(fairmq-ex-req-rep-server server.cxx)
|
|
||||||
target_link_libraries(fairmq-ex-req-rep-server PRIVATE FairMQ)
|
|
||||||
|
|
||||||
add_custom_target(ExampleReqRep DEPENDS fairmq-ex-req-rep-client fairmq-ex-req-rep-server)
|
|
||||||
|
|
||||||
set(EX_BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-req-rep.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-req-rep.sh)
|
|
||||||
|
|
||||||
# test
|
|
||||||
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test-ex-req-rep.sh.in ${CMAKE_CURRENT_BINARY_DIR}/test-ex-req-rep.sh)
|
|
||||||
|
|
||||||
add_test(NAME Example.ReqRep.zeromq COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-req-rep.sh zeromq)
|
|
||||||
set_tests_properties(Example.ReqRep.zeromq PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received reply from server: ")
|
|
||||||
|
|
||||||
add_test(NAME Example.ReqRep.shmem COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test-ex-req-rep.sh shmem)
|
|
||||||
set_tests_properties(Example.ReqRep.shmem PROPERTIES TIMEOUT "30" RUN_SERIAL true PASS_REGULAR_EXPRESSION "Received reply from server: ")
|
|
||||||
|
|
||||||
# install
|
|
||||||
|
|
||||||
install(
|
|
||||||
TARGETS
|
|
||||||
fairmq-ex-req-rep-client
|
|
||||||
fairmq-ex-req-rep-server
|
|
||||||
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# configure run script with different executable paths for build and for install directories
|
|
||||||
set(EX_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR})
|
|
||||||
set(FAIRMQ_BIN_DIR ${CMAKE_INSTALL_PREFIX}/${PROJECT_INSTALL_BINDIR}/fairmq)
|
|
||||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/fairmq-start-ex-req-rep.sh.in ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-req-rep.sh_install)
|
|
||||||
|
|
||||||
install(
|
|
||||||
PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/fairmq-start-ex-req-rep.sh_install
|
|
||||||
DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
RENAME fairmq-start-ex-req-rep.sh
|
|
||||||
)
|
)
|
||||||
|
|
|
@ -32,11 +32,11 @@ struct Client : fair::mq::Device
|
||||||
// its size,
|
// its size,
|
||||||
// custom deletion function (called when transfer is done),
|
// custom deletion function (called when transfer is done),
|
||||||
// and pointer to the object managing the data buffer
|
// and pointer to the object managing the data buffer
|
||||||
FairMQMessagePtr req(NewMessage(const_cast<char*>(text->c_str()), // data
|
fair::mq::MessagePtr req(NewMessage(const_cast<char*>(text->c_str()), // data
|
||||||
text->length(), // size
|
text->length(), // size
|
||||||
[](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, // deletion callback
|
[](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, // deletion callback
|
||||||
text)); // object that manages the data
|
text)); // object that manages the data
|
||||||
FairMQMessagePtr rep(NewMessage());
|
fair::mq::MessagePtr rep(NewMessage());
|
||||||
|
|
||||||
LOG(info) << "Sending \"" << fText << "\" to server.";
|
LOG(info) << "Sending \"" << fText << "\" to server.";
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ struct Server : fair::mq::Device
|
||||||
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
fMaxIterations = fConfig->GetProperty<uint64_t>("max-iterations");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HandleData(FairMQMessagePtr& req, int)
|
bool HandleData(fair::mq::MessagePtr& req, int)
|
||||||
{
|
{
|
||||||
LOG(info) << "Received request from client: \"" << std::string(static_cast<char*>(req->GetData()), req->GetSize()) << "\"";
|
LOG(info) << "Received request from client: \"" << std::string(static_cast<char*>(req->GetData()), req->GetSize()) << "\"";
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ struct Server : fair::mq::Device
|
||||||
|
|
||||||
LOG(info) << "Sending reply to client.";
|
LOG(info) << "Sending reply to client.";
|
||||||
|
|
||||||
FairMQMessagePtr rep(NewMessage(const_cast<char*>(text->c_str()), // data
|
fair::mq::MessagePtr rep(NewMessage(const_cast<char*>(text->c_str()), // data
|
||||||
text->length(), // size
|
text->length(), // size
|
||||||
[](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, // deletion callback
|
[](void* /*data*/, void* object) { delete static_cast<std::string*>(object); }, // deletion callback
|
||||||
text)); // object that manages the data
|
text)); // object that manages the data
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
export FAIRMQ_PATH=@FAIRMQ_BIN_DIR@
|
||||||
|
|
||||||
transport="zeromq"
|
transport="zeromq"
|
||||||
|
@ -8,19 +10,23 @@ if [[ $1 =~ ^[a-z]+$ ]]; then
|
||||||
transport=$1
|
transport=$1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SESSION="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
session="$(@CMAKE_BINARY_DIR@/fairmq/fairmq-uuid-gen -h)"
|
||||||
|
chan="data"
|
||||||
|
chanAddr="/tmp/fmq_$session""_""$chan""_""$transport"
|
||||||
|
|
||||||
# setup a trap to kill everything if the test fails/timeouts
|
# setup a trap to kill everything if the test fails/timeouts
|
||||||
trap 'kill -TERM $CLIENT_PID; kill -TERM $SERVER_PID; wait $CLIENT_PID; wait $SERVER_PID;' TERM
|
trap 'set +e; kill -TERM $CLIENT_PID; kill -TERM $SERVER_PID; wait $CLIENT_PID; wait $SERVER_PID; rm $chanAddr; exit 0' TERM
|
||||||
|
|
||||||
CLIENT="fairmq-ex-req-rep-client"
|
CLIENT="fairmq-ex-req-rep-client"
|
||||||
CLIENT+=" --id client"
|
CLIENT+=" --id client"
|
||||||
CLIENT+=" --transport $transport"
|
CLIENT+=" --transport $transport"
|
||||||
CLIENT+=" --verbosity veryhigh"
|
CLIENT+=" --verbosity veryhigh"
|
||||||
CLIENT+=" --session $SESSION"
|
CLIENT+=" --session $session"
|
||||||
|
CLIENT+=" --shm-segment-size 100000000"
|
||||||
|
CLIENT+=" --shm-monitor true"
|
||||||
CLIENT+=" --control static --color false"
|
CLIENT+=" --control static --color false"
|
||||||
CLIENT+=" --max-iterations 1"
|
CLIENT+=" --max-iterations 1"
|
||||||
CLIENT+=" --channel-config name=data,type=req,method=connect,rateLogging=0,address=tcp://127.0.0.1:5005"
|
CLIENT+=" --channel-config name=$chan,type=req,method=connect,rateLogging=0,address=ipc://$chanAddr"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$CLIENT &
|
@CMAKE_CURRENT_BINARY_DIR@/$CLIENT &
|
||||||
CLIENT_PID=$!
|
CLIENT_PID=$!
|
||||||
|
|
||||||
|
@ -28,13 +34,19 @@ SERVER="fairmq-ex-req-rep-server"
|
||||||
SERVER+=" --id server"
|
SERVER+=" --id server"
|
||||||
SERVER+=" --transport $transport"
|
SERVER+=" --transport $transport"
|
||||||
SERVER+=" --verbosity veryhigh"
|
SERVER+=" --verbosity veryhigh"
|
||||||
SERVER+=" --session $SESSION"
|
SERVER+=" --session $session"
|
||||||
|
SERVER+=" --shm-segment-size 100000000"
|
||||||
|
SERVER+=" --shm-monitor true"
|
||||||
SERVER+=" --control static --color false"
|
SERVER+=" --control static --color false"
|
||||||
SERVER+=" --max-iterations 1"
|
SERVER+=" --max-iterations 1"
|
||||||
SERVER+=" --channel-config name=data,type=rep,method=bind,rateLogging=0,address=tcp://127.0.0.1:5005"
|
SERVER+=" --channel-config name=$chan,type=rep,method=bind,rateLogging=0,address=ipc://$chanAddr"
|
||||||
@CMAKE_CURRENT_BINARY_DIR@/$SERVER &
|
@CMAKE_CURRENT_BINARY_DIR@/$SERVER &
|
||||||
SERVER_PID=$!
|
SERVER_PID=$!
|
||||||
|
|
||||||
# wait for everything to finish
|
# wait for everything to finish
|
||||||
wait $CLIENT_PID
|
wait $CLIENT_PID
|
||||||
wait $SERVER_PID
|
wait $SERVER_PID
|
||||||
|
|
||||||
|
set +e
|
||||||
|
rm $chanAddr
|
||||||
|
exit 0
|
||||||
|
|
2
extern/googletest
vendored
2
extern/googletest
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit f5e592d8ee5ffb1d9af5be7f715ce3576b8bf9c4
|
Subproject commit 7d76a231b0e29caf86e68d1df858308cd53b2a66
|
|
@ -1,12 +1,17 @@
|
||||||
################################################################################
|
################################################################################
|
||||||
# Copyright (C) 2012-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
# Copyright (C) 2012-2025 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH #
|
||||||
# #
|
# #
|
||||||
# This software is distributed under the terms of the #
|
# This software is distributed under the terms of the #
|
||||||
# GNU Lesser General Public Licence (LGPL) version 3, #
|
# GNU Lesser General Public Licence (LGPL) version 3, #
|
||||||
# copied verbatim in the file "LICENSE" #
|
# copied verbatim in the file "LICENSE" #
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
if(BUILD_FAIRMQ OR BUILD_SDK)
|
if(BUILD_FAIRMQ)
|
||||||
|
|
||||||
|
if(BUILD_TIDY_TOOL)
|
||||||
|
include(FairMQTidy)
|
||||||
|
endif()
|
||||||
|
|
||||||
###########
|
###########
|
||||||
# Version #
|
# Version #
|
||||||
###########
|
###########
|
||||||
|
@ -18,125 +23,6 @@ if(BUILD_FAIRMQ OR BUILD_SDK)
|
||||||
DESTINATION ${PROJECT_INSTALL_INCDIR}
|
DESTINATION ${PROJECT_INSTALL_INCDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
#########
|
|
||||||
# Tools #
|
|
||||||
#########
|
|
||||||
set(target Tools)
|
|
||||||
|
|
||||||
set(TOOLS_PUBLIC_HEADER_FILES
|
|
||||||
tools/CppSTL.h
|
|
||||||
tools/InstanceLimit.h
|
|
||||||
tools/Network.h
|
|
||||||
tools/Process.h
|
|
||||||
tools/RateLimit.h
|
|
||||||
tools/Semaphore.h
|
|
||||||
tools/Strings.h
|
|
||||||
tools/Unique.h
|
|
||||||
tools/Version.h
|
|
||||||
Tools.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(TOOLS_SOURCE_FILES
|
|
||||||
tools/Network.cxx
|
|
||||||
tools/Process.cxx
|
|
||||||
tools/Semaphore.cxx
|
|
||||||
tools/Unique.cxx
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(${target}
|
|
||||||
${TOOLS_SOURCE_FILES}
|
|
||||||
${TOOLS_PUBLIC_HEADER_FILES}
|
|
||||||
)
|
|
||||||
target_compile_features(${target} PUBLIC cxx_std_17)
|
|
||||||
target_compile_definitions(${target} PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
|
|
||||||
target_include_directories(${target}
|
|
||||||
PUBLIC
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
|
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
||||||
)
|
|
||||||
target_link_libraries(${target}
|
|
||||||
PRIVATE
|
|
||||||
FairLogger::FairLogger
|
|
||||||
Threads::Threads
|
|
||||||
Boost::boost
|
|
||||||
)
|
|
||||||
set_target_properties(${target} PROPERTIES
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
|
|
||||||
OUTPUT_NAME FairMQ${target}
|
|
||||||
)
|
|
||||||
install(
|
|
||||||
TARGETS ${target}
|
|
||||||
EXPORT ${PROJECT_EXPORT_SET}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
ARCHIVE DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
)
|
|
||||||
foreach(HEADER ${TOOLS_PUBLIC_HEADER_FILES})
|
|
||||||
get_filename_component(_path ${HEADER} DIRECTORY)
|
|
||||||
file(TO_CMAKE_PATH ${PROJECT_INSTALL_INCDIR}/${_path} _destination)
|
|
||||||
install(FILES ${HEADER}
|
|
||||||
DESTINATION ${_destination}
|
|
||||||
)
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
#################
|
|
||||||
# State Machine #
|
|
||||||
#################
|
|
||||||
set(target StateMachine)
|
|
||||||
|
|
||||||
set(FSM_PUBLIC_HEADER_FILES
|
|
||||||
StateMachine.h
|
|
||||||
States.h
|
|
||||||
StateQueue.h
|
|
||||||
)
|
|
||||||
|
|
||||||
set(FSM_SOURCE_FILES
|
|
||||||
StateMachine.cxx
|
|
||||||
States.cxx
|
|
||||||
)
|
|
||||||
|
|
||||||
add_library(${target}
|
|
||||||
${FSM_SOURCE_FILES}
|
|
||||||
${FSM_PUBLIC_HEADER_FILES}
|
|
||||||
)
|
|
||||||
target_compile_features(${target} PUBLIC cxx_std_17)
|
|
||||||
target_compile_definitions(${target} PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
|
|
||||||
target_include_directories(${target}
|
|
||||||
PUBLIC
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
|
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
||||||
)
|
|
||||||
target_link_libraries(${target}
|
|
||||||
PUBLIC
|
|
||||||
FairLogger::FairLogger
|
|
||||||
|
|
||||||
PRIVATE
|
|
||||||
Boost::boost
|
|
||||||
Tools
|
|
||||||
)
|
|
||||||
set_target_properties(${target} PROPERTIES
|
|
||||||
VERSION ${PROJECT_VERSION}
|
|
||||||
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
|
|
||||||
OUTPUT_NAME FairMQ${target}
|
|
||||||
)
|
|
||||||
install(
|
|
||||||
TARGETS ${target}
|
|
||||||
EXPORT ${PROJECT_EXPORT_SET}
|
|
||||||
RUNTIME DESTINATION ${PROJECT_INSTALL_BINDIR}
|
|
||||||
LIBRARY DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
ARCHIVE DESTINATION ${PROJECT_INSTALL_LIBDIR}
|
|
||||||
)
|
|
||||||
foreach(HEADER ${FSM_PUBLIC_HEADER_FILES})
|
|
||||||
get_filename_component(_path ${HEADER} DIRECTORY)
|
|
||||||
file(TO_CMAKE_PATH ${PROJECT_INSTALL_INCDIR}/${_path} _destination)
|
|
||||||
install(FILES ${HEADER}
|
|
||||||
DESTINATION ${_destination}
|
|
||||||
)
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_FAIRMQ)
|
|
||||||
##########################
|
##########################
|
||||||
# libFairMQ header files #
|
# libFairMQ header files #
|
||||||
##########################
|
##########################
|
||||||
|
@ -144,6 +30,7 @@ if(BUILD_FAIRMQ)
|
||||||
Channel.h
|
Channel.h
|
||||||
Device.h
|
Device.h
|
||||||
DeviceRunner.h
|
DeviceRunner.h
|
||||||
|
Error.h
|
||||||
EventManager.h
|
EventManager.h
|
||||||
FairMQChannel.h
|
FairMQChannel.h
|
||||||
FairMQDevice.h
|
FairMQDevice.h
|
||||||
|
@ -159,6 +46,7 @@ if(BUILD_FAIRMQ)
|
||||||
MemoryResourceTools.h
|
MemoryResourceTools.h
|
||||||
MemoryResources.h
|
MemoryResources.h
|
||||||
Message.h
|
Message.h
|
||||||
|
Parts.h
|
||||||
Plugin.h
|
Plugin.h
|
||||||
PluginManager.h
|
PluginManager.h
|
||||||
PluginServices.h
|
PluginServices.h
|
||||||
|
@ -167,14 +55,41 @@ if(BUILD_FAIRMQ)
|
||||||
ProgOptionsFwd.h
|
ProgOptionsFwd.h
|
||||||
Properties.h
|
Properties.h
|
||||||
PropertyOutput.h
|
PropertyOutput.h
|
||||||
|
Socket.h
|
||||||
|
StateMachine.h
|
||||||
|
States.h
|
||||||
|
StateQueue.h
|
||||||
SuboptParser.h
|
SuboptParser.h
|
||||||
|
Tools.h
|
||||||
TransportFactory.h
|
TransportFactory.h
|
||||||
Transports.h
|
Transports.h
|
||||||
|
TransportEnum.h
|
||||||
UnmanagedRegion.h
|
UnmanagedRegion.h
|
||||||
options/FairMQProgOptions.h
|
options/FairMQProgOptions.h
|
||||||
runDevice.h
|
runDevice.h
|
||||||
runFairMQDevice.h
|
runFairMQDevice.h
|
||||||
|
shmem/Common.h
|
||||||
|
shmem/Manager.h
|
||||||
|
shmem/Message.h
|
||||||
shmem/Monitor.h
|
shmem/Monitor.h
|
||||||
|
shmem/Poller.h
|
||||||
|
shmem/Segment.h
|
||||||
|
shmem/Socket.h
|
||||||
|
shmem/TransportFactory.h
|
||||||
|
shmem/UnmanagedRegion.h
|
||||||
|
shmem/UnmanagedRegionImpl.h
|
||||||
|
tools/Compiler.h
|
||||||
|
tools/CppSTL.h
|
||||||
|
tools/Exceptions.h
|
||||||
|
tools/IO.h
|
||||||
|
tools/InstanceLimit.h
|
||||||
|
tools/Network.h
|
||||||
|
tools/Process.h
|
||||||
|
tools/RateLimit.h
|
||||||
|
tools/Semaphore.h
|
||||||
|
tools/Strings.h
|
||||||
|
tools/Unique.h
|
||||||
|
tools/Version.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(FAIRMQ_PRIVATE_HEADER_FILES
|
set(FAIRMQ_PRIVATE_HEADER_FILES
|
||||||
|
@ -187,66 +102,46 @@ if(BUILD_FAIRMQ)
|
||||||
plugins/Builtin.h
|
plugins/Builtin.h
|
||||||
plugins/config/Config.h
|
plugins/config/Config.h
|
||||||
plugins/control/Control.h
|
plugins/control/Control.h
|
||||||
shmem/Message.h
|
zeromq/Common.h
|
||||||
shmem/Poller.h
|
|
||||||
shmem/UnmanagedRegion.h
|
|
||||||
shmem/Socket.h
|
|
||||||
shmem/TransportFactory.h
|
|
||||||
shmem/Common.h
|
|
||||||
shmem/Manager.h
|
|
||||||
shmem/Region.h
|
|
||||||
zeromq/Context.h
|
zeromq/Context.h
|
||||||
zeromq/Message.h
|
zeromq/Message.h
|
||||||
zeromq/Poller.h
|
zeromq/Poller.h
|
||||||
zeromq/UnmanagedRegion.h
|
zeromq/UnmanagedRegion.h
|
||||||
zeromq/Socket.h
|
zeromq/Socket.h
|
||||||
zeromq/TransportFactory.h
|
zeromq/TransportFactory.h
|
||||||
|
zeromq/ZMsg.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
|
||||||
set(FAIRMQ_PRIVATE_HEADER_FILES ${FAIRMQ_PRIVATE_HEADER_FILES}
|
|
||||||
ofi/Context.h
|
|
||||||
ofi/ControlMessages.h
|
|
||||||
ofi/Message.h
|
|
||||||
ofi/Socket.h
|
|
||||||
ofi/TransportFactory.h
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
##########################
|
##########################
|
||||||
# libFairMQ source files #
|
# libFairMQ source files #
|
||||||
##########################
|
##########################
|
||||||
set(FAIRMQ_SOURCE_FILES
|
set(FAIRMQ_SOURCE_FILES
|
||||||
|
Channel.cxx
|
||||||
|
Device.cxx
|
||||||
DeviceRunner.cxx
|
DeviceRunner.cxx
|
||||||
FairMQChannel.cxx
|
EventManager.cxx
|
||||||
FairMQDevice.cxx
|
JSONParser.cxx
|
||||||
FairMQLogger.cxx
|
MemoryResources.cxx
|
||||||
FairMQMessage.cxx
|
|
||||||
FairMQPoller.cxx
|
|
||||||
FairMQSocket.cxx
|
|
||||||
FairMQTransportFactory.cxx
|
|
||||||
Plugin.cxx
|
Plugin.cxx
|
||||||
PluginManager.cxx
|
PluginManager.cxx
|
||||||
PluginServices.cxx
|
PluginServices.cxx
|
||||||
ProgOptions.cxx
|
ProgOptions.cxx
|
||||||
JSONParser.cxx
|
|
||||||
Properties.cxx
|
Properties.cxx
|
||||||
|
StateMachine.cxx
|
||||||
|
States.cxx
|
||||||
SuboptParser.cxx
|
SuboptParser.cxx
|
||||||
|
TransportFactory.cxx
|
||||||
plugins/config/Config.cxx
|
plugins/config/Config.cxx
|
||||||
plugins/control/Control.cxx
|
plugins/control/Control.cxx
|
||||||
MemoryResources.cxx
|
shmem/Common.cxx
|
||||||
shmem/Manager.cxx
|
shmem/Manager.cxx
|
||||||
shmem/Monitor.cxx
|
shmem/Monitor.cxx
|
||||||
|
tools/Network.cxx
|
||||||
|
tools/Process.cxx
|
||||||
|
tools/Semaphore.cxx
|
||||||
|
tools/Unique.cxx
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILD_OFI_TRANSPORT)
|
|
||||||
set(FAIRMQ_SOURCE_FILES ${FAIRMQ_SOURCE_FILES}
|
|
||||||
ofi/Context.cxx
|
|
||||||
ofi/Message.cxx
|
|
||||||
ofi/Socket.cxx
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
###################
|
###################
|
||||||
# configure files #
|
# configure files #
|
||||||
|
@ -270,14 +165,26 @@ if(BUILD_FAIRMQ)
|
||||||
############################
|
############################
|
||||||
# preprocessor definitions #
|
# preprocessor definitions #
|
||||||
############################
|
############################
|
||||||
target_compile_definitions(${target} PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
|
target_compile_definitions(${target} PUBLIC
|
||||||
|
BOOST_ERROR_CODE_HEADER_ONLY
|
||||||
|
BOOST_ASIO_HAS_HAS_STD_CHRONO
|
||||||
|
)
|
||||||
if(FAIRMQ_DEBUG_MODE)
|
if(FAIRMQ_DEBUG_MODE)
|
||||||
target_compile_definitions(${target} PUBLIC FAIRMQ_DEBUG_MODE)
|
target_compile_definitions(${target} PUBLIC FAIRMQ_DEBUG_MODE)
|
||||||
endif()
|
endif()
|
||||||
if(BUILD_OFI_TRANSPORT)
|
target_compile_definitions(${target} PUBLIC
|
||||||
target_compile_definitions(${target} PRIVATE BUILD_OFI_TRANSPORT)
|
FAIRMQ_HAS_STD_FILESYSTEM=${FAIRMQ_HAS_STD_FILESYSTEM}
|
||||||
|
FAIRMQ_HAS_STD_PMR=${FAIRMQ_HAS_STD_PMR}
|
||||||
|
)
|
||||||
|
if(DEFINED FAIRMQ_CHANNEL_DEFAULT_AUTOBIND)
|
||||||
|
# translate CMake boolean (TRUE, FALSE, 0, 1, OFF, ON) into C++ boolean literal (true, false)
|
||||||
|
if(FAIRMQ_CHANNEL_DEFAULT_AUTOBIND)
|
||||||
|
set(value "true")
|
||||||
|
else()
|
||||||
|
set(value "false")
|
||||||
|
endif()
|
||||||
|
target_compile_definitions(${target} PUBLIC FAIRMQ_CHANNEL_DEFAULT_AUTOBIND=${value})
|
||||||
endif()
|
endif()
|
||||||
target_compile_definitions(${target} PUBLIC FAIRMQ_HAS_STD_FILESYSTEM=${FAIRMQ_HAS_STD_FILESYSTEM})
|
|
||||||
|
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
|
@ -295,13 +202,6 @@ if(BUILD_FAIRMQ)
|
||||||
##################
|
##################
|
||||||
# link libraries #
|
# link libraries #
|
||||||
##################
|
##################
|
||||||
if(BUILD_OFI_TRANSPORT)
|
|
||||||
set(OFI_DEPS
|
|
||||||
asio::asio
|
|
||||||
asiofi::asiofi
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${target}
|
target_link_libraries(${target}
|
||||||
INTERFACE # only consumers link against interface dependencies
|
INTERFACE # only consumers link against interface dependencies
|
||||||
Boost::container
|
Boost::container
|
||||||
|
@ -312,21 +212,21 @@ if(BUILD_FAIRMQ)
|
||||||
$<$<PLATFORM_ID:Linux>:rt>
|
$<$<PLATFORM_ID:Linux>:rt>
|
||||||
Boost::boost
|
Boost::boost
|
||||||
Boost::program_options
|
Boost::program_options
|
||||||
Boost::filesystem
|
Boost::filesystem # still needed for Boost.DLL
|
||||||
Boost::regex
|
Boost::regex
|
||||||
FairLogger::FairLogger
|
FairLogger::FairLogger
|
||||||
Tools
|
|
||||||
StateMachine
|
|
||||||
|
|
||||||
PRIVATE # only libFairMQ links against private dependencies
|
PRIVATE # only libFairMQ links against private dependencies
|
||||||
libzmq
|
libzmq
|
||||||
PicoSHA2
|
PicoSHA2
|
||||||
${OFI_DEPS}
|
|
||||||
)
|
)
|
||||||
set_target_properties(${target} PROPERTIES
|
set_target_properties(${target} PROPERTIES
|
||||||
VERSION ${PROJECT_VERSION}
|
VERSION ${PROJECT_VERSION}
|
||||||
SOVERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}"
|
OUTPUT_NAME ${PROJECT_NAME_LOWER}
|
||||||
)
|
)
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET ${target})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
###############
|
###############
|
||||||
|
@ -334,23 +234,41 @@ if(BUILD_FAIRMQ)
|
||||||
###############
|
###############
|
||||||
add_executable(fairmq-bsampler devices/runBenchmarkSampler.cxx)
|
add_executable(fairmq-bsampler devices/runBenchmarkSampler.cxx)
|
||||||
target_link_libraries(fairmq-bsampler FairMQ)
|
target_link_libraries(fairmq-bsampler FairMQ)
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET fairmq-bsampler)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(fairmq-merger devices/runMerger.cxx)
|
add_executable(fairmq-merger devices/runMerger.cxx)
|
||||||
target_link_libraries(fairmq-merger FairMQ)
|
target_link_libraries(fairmq-merger FairMQ)
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET fairmq-merger)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(fairmq-multiplier devices/runMultiplier.cxx)
|
add_executable(fairmq-multiplier devices/runMultiplier.cxx)
|
||||||
target_link_libraries(fairmq-multiplier FairMQ)
|
target_link_libraries(fairmq-multiplier FairMQ)
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET fairmq-multiplier)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(fairmq-proxy devices/runProxy.cxx)
|
add_executable(fairmq-proxy devices/runProxy.cxx)
|
||||||
target_link_libraries(fairmq-proxy FairMQ)
|
target_link_libraries(fairmq-proxy FairMQ)
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET fairmq-proxy)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(fairmq-sink devices/runSink.cxx)
|
add_executable(fairmq-sink devices/runSink.cxx)
|
||||||
target_link_libraries(fairmq-sink FairMQ)
|
target_link_libraries(fairmq-sink FairMQ)
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET fairmq-sink)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(fairmq-splitter devices/runSplitter.cxx)
|
add_executable(fairmq-splitter devices/runSplitter.cxx)
|
||||||
target_link_libraries(fairmq-splitter FairMQ)
|
target_link_libraries(fairmq-splitter FairMQ)
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET fairmq-splitter)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(fairmq-shmmonitor shmem/Monitor.cxx shmem/Monitor.h shmem/runMonitor.cxx)
|
add_executable(fairmq-shmmonitor shmem/Common.cxx shmem/Monitor.cxx shmem/Monitor.h shmem/runMonitor.cxx)
|
||||||
target_compile_features(fairmq-shmmonitor PUBLIC cxx_std_17)
|
target_compile_features(fairmq-shmmonitor PUBLIC cxx_std_17)
|
||||||
target_compile_definitions(fairmq-shmmonitor PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
|
target_compile_definitions(fairmq-shmmonitor PUBLIC BOOST_ERROR_CODE_HEADER_ONLY)
|
||||||
if(FAIRMQ_DEBUG_MODE)
|
if(FAIRMQ_DEBUG_MODE)
|
||||||
|
@ -370,12 +288,18 @@ if(BUILD_FAIRMQ)
|
||||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
|
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
|
||||||
)
|
)
|
||||||
target_compile_definitions(fairmq-shmmonitor PUBLIC FAIRMQ_HAS_STD_FILESYSTEM=${FAIRMQ_HAS_STD_FILESYSTEM})
|
target_compile_definitions(fairmq-shmmonitor PUBLIC FAIRMQ_HAS_STD_FILESYSTEM=${FAIRMQ_HAS_STD_FILESYSTEM})
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET fairmq-shmmonitor)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(fairmq-uuid-gen tools/runUuidGenerator.cxx)
|
add_executable(fairmq-uuid-gen tools/runUuidGenerator.cxx)
|
||||||
target_link_libraries(fairmq-uuid-gen PUBLIC
|
target_link_libraries(fairmq-uuid-gen PUBLIC
|
||||||
Boost::program_options
|
Boost::program_options
|
||||||
Tools
|
FairMQ
|
||||||
)
|
)
|
||||||
|
if(BUILD_TIDY_TOOL AND RUN_FAIRMQ_TIDY)
|
||||||
|
fairmq_target_tidy(TARGET fairmq-uuid-gen)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
###########
|
###########
|
||||||
|
@ -408,21 +332,3 @@ if(BUILD_FAIRMQ)
|
||||||
)
|
)
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BUILD_SDK_COMMANDS)
|
|
||||||
add_subdirectory(sdk/commands)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BUILD_SDK)
|
|
||||||
add_subdirectory(sdk)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
####################
|
|
||||||
# external plugins #
|
|
||||||
####################
|
|
||||||
if(BUILD_DDS_PLUGIN)
|
|
||||||
add_subdirectory(plugins/DDS)
|
|
||||||
endif()
|
|
||||||
if(BUILD_PMIX_PLUGIN)
|
|
||||||
add_subdirectory(plugins/PMIx)
|
|
||||||
endif()
|
|
||||||
|
|
|
@ -1,30 +1,28 @@
|
||||||
/********************************************************************************
|
/********************************************************************************
|
||||||
* Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
* Copyright (C) 2014-2021 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
|
||||||
* *
|
* *
|
||||||
* This software is distributed under the terms of the *
|
* This software is distributed under the terms of the *
|
||||||
* GNU Lesser General Public Licence (LGPL) version 3, *
|
* GNU Lesser General Public Licence (LGPL) version 3, *
|
||||||
* copied verbatim in the file "LICENSE" *
|
* copied verbatim in the file "LICENSE" *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include "FairMQChannel.h"
|
#include <boost/algorithm/string.hpp> // join/split
|
||||||
|
#include <cstddef> // size_t
|
||||||
#include <fairmq/tools/Strings.h>
|
|
||||||
#include <fairmq/Properties.h>
|
|
||||||
|
|
||||||
#include <fairlogger/Logger.h>
|
#include <fairlogger/Logger.h>
|
||||||
|
#include <fairmq/Channel.h>
|
||||||
#include <boost/algorithm/string.hpp> // join/split
|
#include <fairmq/Properties.h>
|
||||||
|
#include <fairmq/Tools.h>
|
||||||
#include <cstddef> // size_t
|
#include <fairmq/Transports.h>
|
||||||
|
#include <random>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <random>
|
|
||||||
|
namespace fair::mq {
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace fair::mq;
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
T GetPropertyOrDefault(const fair::mq::Properties& m, const string& k, const T& ifNotFound)
|
T GetPropertyOrDefault(const Properties& m, const string& k, const T& ifNotFound)
|
||||||
{
|
{
|
||||||
if (m.count(k)) {
|
if (m.count(k)) {
|
||||||
return boost::any_cast<T>(m.at(k));
|
return boost::any_cast<T>(m.at(k));
|
||||||
|
@ -32,39 +30,41 @@ T GetPropertyOrDefault(const fair::mq::Properties& m, const string& k, const T&
|
||||||
return ifNotFound;
|
return ifNotFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr fair::mq::Transport FairMQChannel::DefaultTransportType;
|
constexpr Transport Channel::DefaultTransportType;
|
||||||
constexpr const char* FairMQChannel::DefaultTransportName;
|
constexpr const char* Channel::DefaultTransportName;
|
||||||
constexpr const char* FairMQChannel::DefaultName;
|
constexpr const char* Channel::DefaultName;
|
||||||
constexpr const char* FairMQChannel::DefaultType;
|
constexpr const char* Channel::DefaultType;
|
||||||
constexpr const char* FairMQChannel::DefaultMethod;
|
constexpr const char* Channel::DefaultMethod;
|
||||||
constexpr const char* FairMQChannel::DefaultAddress;
|
constexpr const char* Channel::DefaultAddress;
|
||||||
constexpr int FairMQChannel::DefaultSndBufSize;
|
constexpr int Channel::DefaultSndBufSize;
|
||||||
constexpr int FairMQChannel::DefaultRcvBufSize;
|
constexpr int Channel::DefaultRcvBufSize;
|
||||||
constexpr int FairMQChannel::DefaultSndKernelSize;
|
constexpr int Channel::DefaultSndKernelSize;
|
||||||
constexpr int FairMQChannel::DefaultRcvKernelSize;
|
constexpr int Channel::DefaultRcvKernelSize;
|
||||||
constexpr int FairMQChannel::DefaultLinger;
|
constexpr int Channel::DefaultSndTimeoutMs;
|
||||||
constexpr int FairMQChannel::DefaultRateLogging;
|
constexpr int Channel::DefaultRcvTimeoutMs;
|
||||||
constexpr int FairMQChannel::DefaultPortRangeMin;
|
constexpr int Channel::DefaultLinger;
|
||||||
constexpr int FairMQChannel::DefaultPortRangeMax;
|
constexpr int Channel::DefaultRateLogging;
|
||||||
constexpr bool FairMQChannel::DefaultAutoBind;
|
constexpr int Channel::DefaultPortRangeMin;
|
||||||
|
constexpr int Channel::DefaultPortRangeMax;
|
||||||
|
constexpr bool Channel::DefaultAutoBind;
|
||||||
|
|
||||||
FairMQChannel::FairMQChannel()
|
Channel::Channel()
|
||||||
: FairMQChannel(DefaultName, DefaultType, DefaultMethod, DefaultAddress, nullptr)
|
: Channel(DefaultName, DefaultType, DefaultMethod, DefaultAddress, nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FairMQChannel::FairMQChannel(const string& name)
|
Channel::Channel(const string& name)
|
||||||
: FairMQChannel(name, DefaultType, DefaultMethod, DefaultAddress, nullptr)
|
: Channel(name, DefaultType, DefaultMethod, DefaultAddress, nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FairMQChannel::FairMQChannel(const string& type, const string& method, const string& address)
|
Channel::Channel(const string& type, const string& method, const string& address)
|
||||||
: FairMQChannel(DefaultName, type, method, address, nullptr)
|
: Channel(DefaultName, type, method, address, nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FairMQChannel::FairMQChannel(const string& name, const string& type, shared_ptr<FairMQTransportFactory> factory)
|
Channel::Channel(const string& name, const string& type, shared_ptr<TransportFactory> factory)
|
||||||
: FairMQChannel(name, type, DefaultMethod, DefaultAddress, factory)
|
: Channel(name, type, DefaultMethod, DefaultAddress, factory)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FairMQChannel::FairMQChannel(string name, string type, string method, string address, shared_ptr<FairMQTransportFactory> factory)
|
Channel::Channel(string name, string type, string method, string address, shared_ptr<TransportFactory> factory)
|
||||||
: fTransportFactory(factory)
|
: fTransportFactory(factory)
|
||||||
, fTransportType(factory ? factory->GetType() : DefaultTransportType)
|
, fTransportType(factory ? factory->GetType() : DefaultTransportType)
|
||||||
, fSocket(factory ? factory->CreateSocket(type, name) : nullptr)
|
, fSocket(factory ? factory->CreateSocket(type, name) : nullptr)
|
||||||
|
@ -76,6 +76,8 @@ FairMQChannel::FairMQChannel(string name, string type, string method, string add
|
||||||
, fRcvBufSize(DefaultRcvBufSize)
|
, fRcvBufSize(DefaultRcvBufSize)
|
||||||
, fSndKernelSize(DefaultSndKernelSize)
|
, fSndKernelSize(DefaultSndKernelSize)
|
||||||
, fRcvKernelSize(DefaultRcvKernelSize)
|
, fRcvKernelSize(DefaultRcvKernelSize)
|
||||||
|
, fSndTimeoutMs(DefaultSndTimeoutMs)
|
||||||
|
, fRcvTimeoutMs(DefaultRcvTimeoutMs)
|
||||||
, fLinger(DefaultLinger)
|
, fLinger(DefaultLinger)
|
||||||
, fRateLogging(DefaultRateLogging)
|
, fRateLogging(DefaultRateLogging)
|
||||||
, fPortRangeMin(DefaultPortRangeMin)
|
, fPortRangeMin(DefaultPortRangeMin)
|
||||||
|
@ -87,8 +89,8 @@ FairMQChannel::FairMQChannel(string name, string type, string method, string add
|
||||||
// LOG(warn) << "Constructing channel '" << fName << "'";
|
// LOG(warn) << "Constructing channel '" << fName << "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQChannel::FairMQChannel(const string& name, int index, const fair::mq::Properties& properties)
|
Channel::Channel(const string& name, int index, const Properties& properties)
|
||||||
: FairMQChannel(tools::ToString(name, "[", index, "]"), "unspecified", "unspecified", "unspecified", nullptr)
|
: Channel(tools::ToString(name, "[", index, "]"), "unspecified", "unspecified", "unspecified", nullptr)
|
||||||
{
|
{
|
||||||
string prefix(tools::ToString("chans.", name, ".", index, "."));
|
string prefix(tools::ToString("chans.", name, ".", index, "."));
|
||||||
|
|
||||||
|
@ -100,6 +102,8 @@ FairMQChannel::FairMQChannel(const string& name, int index, const fair::mq::Prop
|
||||||
fRcvBufSize = GetPropertyOrDefault(properties, string(prefix + "rcvBufSize"), DefaultRcvBufSize);
|
fRcvBufSize = GetPropertyOrDefault(properties, string(prefix + "rcvBufSize"), DefaultRcvBufSize);
|
||||||
fSndKernelSize = GetPropertyOrDefault(properties, string(prefix + "sndKernelSize"), DefaultSndKernelSize);
|
fSndKernelSize = GetPropertyOrDefault(properties, string(prefix + "sndKernelSize"), DefaultSndKernelSize);
|
||||||
fRcvKernelSize = GetPropertyOrDefault(properties, string(prefix + "rcvKernelSize"), DefaultRcvKernelSize);
|
fRcvKernelSize = GetPropertyOrDefault(properties, string(prefix + "rcvKernelSize"), DefaultRcvKernelSize);
|
||||||
|
fSndTimeoutMs = GetPropertyOrDefault(properties, string(prefix + "sndTimeoutMs"), DefaultSndTimeoutMs);
|
||||||
|
fRcvTimeoutMs = GetPropertyOrDefault(properties, string(prefix + "rcvTimeoutMs"), DefaultRcvTimeoutMs);
|
||||||
fLinger = GetPropertyOrDefault(properties, string(prefix + "linger"), DefaultLinger);
|
fLinger = GetPropertyOrDefault(properties, string(prefix + "linger"), DefaultLinger);
|
||||||
fRateLogging = GetPropertyOrDefault(properties, string(prefix + "rateLogging"), DefaultRateLogging);
|
fRateLogging = GetPropertyOrDefault(properties, string(prefix + "rateLogging"), DefaultRateLogging);
|
||||||
fPortRangeMin = GetPropertyOrDefault(properties, string(prefix + "portRangeMin"), DefaultPortRangeMin);
|
fPortRangeMin = GetPropertyOrDefault(properties, string(prefix + "portRangeMin"), DefaultPortRangeMin);
|
||||||
|
@ -107,11 +111,11 @@ FairMQChannel::FairMQChannel(const string& name, int index, const fair::mq::Prop
|
||||||
fAutoBind = GetPropertyOrDefault(properties, string(prefix + "autoBind"), DefaultAutoBind);
|
fAutoBind = GetPropertyOrDefault(properties, string(prefix + "autoBind"), DefaultAutoBind);
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQChannel::FairMQChannel(const FairMQChannel& chan)
|
Channel::Channel(const Channel& chan)
|
||||||
: FairMQChannel(chan, chan.fName)
|
: Channel(chan, chan.fName)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FairMQChannel::FairMQChannel(const FairMQChannel& chan, string newName)
|
Channel::Channel(const Channel& chan, string newName)
|
||||||
: fTransportFactory(nullptr)
|
: fTransportFactory(nullptr)
|
||||||
, fTransportType(chan.fTransportType)
|
, fTransportType(chan.fTransportType)
|
||||||
, fSocket(nullptr)
|
, fSocket(nullptr)
|
||||||
|
@ -123,6 +127,8 @@ FairMQChannel::FairMQChannel(const FairMQChannel& chan, string newName)
|
||||||
, fRcvBufSize(chan.fRcvBufSize)
|
, fRcvBufSize(chan.fRcvBufSize)
|
||||||
, fSndKernelSize(chan.fSndKernelSize)
|
, fSndKernelSize(chan.fSndKernelSize)
|
||||||
, fRcvKernelSize(chan.fRcvKernelSize)
|
, fRcvKernelSize(chan.fRcvKernelSize)
|
||||||
|
, fSndTimeoutMs(chan.fSndTimeoutMs)
|
||||||
|
, fRcvTimeoutMs(chan.fRcvTimeoutMs)
|
||||||
, fLinger(chan.fLinger)
|
, fLinger(chan.fLinger)
|
||||||
, fRateLogging(chan.fRateLogging)
|
, fRateLogging(chan.fRateLogging)
|
||||||
, fPortRangeMin(chan.fPortRangeMin)
|
, fPortRangeMin(chan.fPortRangeMin)
|
||||||
|
@ -132,7 +138,7 @@ FairMQChannel::FairMQChannel(const FairMQChannel& chan, string newName)
|
||||||
, fMultipart(chan.fMultipart)
|
, fMultipart(chan.fMultipart)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
FairMQChannel& FairMQChannel::operator=(const FairMQChannel& chan)
|
Channel& Channel::operator=(const Channel& chan)
|
||||||
{
|
{
|
||||||
if (this == &chan) {
|
if (this == &chan) {
|
||||||
return *this;
|
return *this;
|
||||||
|
@ -149,6 +155,8 @@ FairMQChannel& FairMQChannel::operator=(const FairMQChannel& chan)
|
||||||
fRcvBufSize = chan.fRcvBufSize;
|
fRcvBufSize = chan.fRcvBufSize;
|
||||||
fSndKernelSize = chan.fSndKernelSize;
|
fSndKernelSize = chan.fSndKernelSize;
|
||||||
fRcvKernelSize = chan.fRcvKernelSize;
|
fRcvKernelSize = chan.fRcvKernelSize;
|
||||||
|
fSndTimeoutMs = chan.fSndTimeoutMs;
|
||||||
|
fRcvTimeoutMs = chan.fRcvTimeoutMs;
|
||||||
fLinger = chan.fLinger;
|
fLinger = chan.fLinger;
|
||||||
fRateLogging = chan.fRateLogging;
|
fRateLogging = chan.fRateLogging;
|
||||||
fPortRangeMin = chan.fPortRangeMin;
|
fPortRangeMin = chan.fPortRangeMin;
|
||||||
|
@ -160,7 +168,7 @@ FairMQChannel& FairMQChannel::operator=(const FairMQChannel& chan)
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQChannel::Validate()
|
bool Channel::Validate()
|
||||||
try {
|
try {
|
||||||
stringstream ss;
|
stringstream ss;
|
||||||
ss << "Validating channel '" << fName << "'... ";
|
ss << "Validating channel '" << fName << "'... ";
|
||||||
|
@ -305,11 +313,11 @@ try {
|
||||||
LOG(debug) << ss.str();
|
LOG(debug) << ss.str();
|
||||||
return true;
|
return true;
|
||||||
} catch (exception& e) {
|
} catch (exception& e) {
|
||||||
LOG(error) << "Exception caught in FairMQChannel::ValidateChannel: " << e.what();
|
LOG(error) << "Exception caught in Channel::ValidateChannel: " << e.what();
|
||||||
throw ChannelConfigurationError(tools::ToString(e.what()));
|
throw ChannelConfigurationError(tools::ToString(e.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FairMQChannel::Init()
|
void Channel::Init()
|
||||||
{
|
{
|
||||||
fSocket = fTransportFactory->CreateSocket(fType, fName);
|
fSocket = fTransportFactory->CreateSocket(fType, fName);
|
||||||
|
|
||||||
|
@ -329,12 +337,12 @@ void FairMQChannel::Init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQChannel::ConnectEndpoint(const string& endpoint)
|
bool Channel::ConnectEndpoint(const string& endpoint)
|
||||||
{
|
{
|
||||||
return fSocket->Connect(endpoint);
|
return fSocket->Connect(endpoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FairMQChannel::BindEndpoint(string& endpoint)
|
bool Channel::BindEndpoint(string& endpoint)
|
||||||
{
|
{
|
||||||
// try to bind to the configured port. If it fails, try random one (if AutoBind is on).
|
// try to bind to the configured port. If it fails, try random one (if AutoBind is on).
|
||||||
if (fSocket->Bind(endpoint)) {
|
if (fSocket->Bind(endpoint)) {
|
||||||
|
@ -374,5 +382,12 @@ bool FairMQChannel::BindEndpoint(string& endpoint)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Channel::GetTransportName() const { return TransportName(fTransportType); }
|
||||||
|
|
||||||
|
Transport Channel::GetTransportType() const { return fTransportType; }
|
||||||
|
|
||||||
|
void Channel::UpdateTransport(const std::string& transport) { fTransportType = TransportType(transport); Invalidate(); }
|
||||||
|
|
||||||
|
} // namespace fair::mq
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user