13#include <fmt/format.h>
19#if __has_include(<filesystem>)
21namespace fs = std::filesystem;
26std::string getTmpFolder()
28 std::string tmppath = fs::temp_directory_path().native();
29 while (tmppath.back() ==
'/') {
50 std::regex ipv4_regex(
"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$");
51 if (std::regex_match(
address, ipv4_regex)) {
59 std::string valueStr =
value.data();
60 if (
key ==
"address") {
61 auto parseAddress = [
v = std::string(
value), &outputChannelSpec =
specs.back()]() {
63 std::string protocol =
"tcp";
64 std::string hostname =
"127.0.0.1";
65 std::string port =
"9090";
67 if (
pos != std::string::npos) {
71 if (protocol ==
"tcp") {
73 if (
pos != std::string::npos) {
83 outputChannelSpec.hostname = hostname;
84 outputChannelSpec.port = std::stoi(port);
86 }
else if (protocol ==
"ipc") {
87 outputChannelSpec.hostname =
value;
88 outputChannelSpec.port = 0;
96 auto& outputChannelSpec =
specs.back();
98 outputChannelSpec.name =
value;
99 }
else if (
key ==
"type" &&
value ==
"pub") {
101 }
else if (
key ==
"type" &&
value ==
"sub") {
103 }
else if (
key ==
"type" &&
value ==
"push") {
105 }
else if (
key ==
"type" &&
value ==
"pull") {
107 }
else if (
key ==
"type" &&
value ==
"pair") {
109 }
else if (
key ==
"method" &&
value ==
"bind") {
111 }
else if (
key ==
"method" &&
value ==
"connect") {
113 }
else if (
key ==
"rateLogging") {
114 outputChannelSpec.rateLogging = std::stoi(valueStr);
115 }
else if (
key ==
"recvBufSize") {
116 outputChannelSpec.recvBufferSize = std::stoi(valueStr);
117 }
else if (
key ==
"sendBufSize") {
118 outputChannelSpec.recvBufferSize = std::stoi(valueStr);
157std::string composeIPCName(std::string
const& prefix, std::string
const& hostname,
short port)
159 if (prefix.empty() ==
false && prefix[0] ==
'@') {
160 return fmt::format(
"ipc://{}{}_{},transport=shmem", prefix, hostname, port);
162 if (prefix.empty() ==
false && prefix.back() ==
'/') {
163 return fmt::format(
"ipc://{}{}_{},transport=shmem", prefix, hostname, port);
165 return fmt::format(
"ipc://{}/{}_{},transport=shmem", prefix, hostname, port);
176 : fmt::format(
"tcp://{}:{}", channel.
hostname, channel.
port);
187 : fmt::format(
"tcp://{}:{}", channel.
hostname, channel.
port);
219 char const* cur = config;
220 char const* next = config;
221 std::string_view
key;
222 std::string_view
value;
223 char const* nameKey =
"name";
224 char const* lastError =
"bad configuation string";
230 lastError =
"empty config string";
232 }
else if (!isalpha(*cur)) {
233 lastError =
"first character is not alphabetic";
241 next = strpbrk(cur,
":=;,");
242 if (*next ==
';' || *next ==
',') {
243 lastError =
"expected channel name";
246 }
else if (*next ==
':') {
248 key = std::string_view(nameKey, 4);
249 value = std::string_view(cur, next - cur);
265 next = strchr(cur,
'=');
266 if (next ==
nullptr) {
267 lastError =
"expected '='";
270 key = std::string_view(cur, next - cur);
277 next = strpbrk(cur,
";,");
278 if (next ==
nullptr) {
279 size_t l = strlen(cur);
280 value = std::string_view(cur, l);
283 }
else if (*next ==
';') {
284 value = std::string_view(cur, next - cur);
287 }
else if (*next ==
',') {
288 value = std::string_view(cur, next - cur);
298 }
else if (*cur ==
',') {
301 }
else if (*cur ==
';') {
311 }
else if (*cur ==
';') {
315 lastError =
"expected ';'";
324 throw runtime_error_f(
"Unable to parse channel config: %s", lastError);
338 char const* channelPrefix = getenv(
"ALIEN_PROC_ID");
340 return fmt::format(
"@dpl_{}_", channelPrefix);
342 channelPrefix = getenv(
"SLURM_JOB_ID");
344 return fmt::format(
"@dpl_{}_", channelPrefix);
349 char const* channelPrefix = getenv(
"TMPDIR");
351 return {channelPrefix};
353 return access(
"/tmp", W_OK) == 0 ?
"/tmp/" :
"./";
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
GLuint GLuint64EXT address
GLsizei const GLfloat * value
GLint GLint GLsizei GLint GLenum GLenum type
GLuint GLint GLboolean GLint GLenum access
Defining ITS Vertex explicitly as messageable.
RuntimeErrorRef runtime_error(const char *)
std::ostream & operator<<(std::ostream &s, ChannelType const &type)
Stream operators so that we can use ChannelType with Boost.Test.
bool isIPAddress(const std::string &address)
ChannelType
These map to zeromq types for the channels.
RuntimeErrorRef runtime_error_f(const char *,...)
static std::string defaultIPCFolder()
static void parseChannelConfig(char const *channelConfig, FairMQChannelConfigParser &parser)
static char const * typeAsString(enum ChannelType type)
return a ChannelType as a lowercase string
static std::string channelUrl(InputChannelSpec const &)
static char const * methodAsString(enum ChannelMethod method)
return a ChannelMethod as a lowercase string
Handler to parse the description of the –channel-config.
virtual void property(std::string_view, std::string_view)
virtual void endChannel()
virtual void beginChannel()
void endChannel() override
std::vector< OutputChannelSpec > specs
void beginChannel() override
void property(std::string_view, std::string_view) override
enum ChannelMethod method