Project
Loading...
Searching...
No Matches
DeviceSpecHelpers.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11#ifndef O2_FRAMEWORK_DEVICESPECHELPERS_H_
12#define O2_FRAMEWORK_DEVICESPECHELPERS_H_
13
28#include "ResourceManager.h"
29#include "WorkflowHelpers.h"
30
31#include <boost/program_options.hpp>
32
33#include <vector>
34#include <string>
35#include <map>
36#include <functional>
37
38namespace o2::framework
39{
40struct InputChannelSpec;
41struct OutputChannelSpec;
42struct ConfigContext;
43struct DriverConfig;
44
49 const WorkflowSpec& workflow,
50 std::vector<ChannelConfigurationPolicy> const& channelPolicies,
51 std::vector<CompletionPolicy> const& completionPolicies,
52 std::vector<DispatchPolicy> const& dispatchPolicies,
53 std::vector<ResourcePolicy> const& resourcePolicies,
54 std::vector<CallbacksPolicy> const& callbacksPolicies,
55 std::vector<SendingPolicy> const& sendingPolicy,
56 std::vector<ForwardingPolicy> const& forwardingPolicies,
57 std::vector<DeviceSpec>& devices,
58 ResourceManager& resourceManager,
59 std::string const& uniqueWorkflowId,
60 ConfigContext const& configContext,
61 bool optimizeTopology = false,
62 unsigned short resourcesMonitoringInterval = 0,
63 std::string const& channelPrefix = "",
64 OverrideServiceSpecs const& overrideServices = {});
65
66 static void validate(WorkflowSpec const& workflow);
68 const WorkflowSpec& workflow,
69 std::vector<ChannelConfigurationPolicy> const& channelPolicies,
70 std::vector<CompletionPolicy> const& completionPolicies,
71 std::vector<CallbacksPolicy> const& callbacksPolicies,
72 std::vector<DeviceSpec>& devices,
73 ResourceManager& resourceManager,
74 std::string const& uniqueWorkflowId,
75 ConfigContext const& configContext,
76 bool optimizeTopology = false,
77 unsigned short resourcesMonitoringInterval = 0,
78 std::string const& channelPrefix = "",
79 OverrideServiceSpecs const& overrideServices = {})
80 {
81 std::vector<DispatchPolicy> dispatchPolicies = DispatchPolicy::createDefaultPolicies();
82 std::vector<ResourcePolicy> resourcePolicies = ResourcePolicy::createDefaultPolicies();
83 std::vector<SendingPolicy> sendingPolicies = SendingPolicy::createDefaultPolicies();
84 std::vector<ForwardingPolicy> forwardingPolicies = ForwardingPolicy::createDefaultPolicies();
85 dataProcessorSpecs2DeviceSpecs(workflow, channelPolicies, completionPolicies,
86 dispatchPolicies, resourcePolicies, callbacksPolicies,
87 sendingPolicies, forwardingPolicies, devices,
88 resourceManager, uniqueWorkflowId, configContext, optimizeTopology,
89 resourcesMonitoringInterval, channelPrefix, overrideServices);
90 }
91
93 static std::string inputChannel2String(const InputChannelSpec& channel);
94
96 static std::string outputChannel2String(const OutputChannelSpec& channel);
97
104 static void reworkHomogeneousOption(std::vector<DataProcessorInfo>& infos,
105 char const* name, char const* defaultValue);
106
112 static void reworkIntegerOption(std::vector<DataProcessorInfo>& infos,
113 char const* name,
114 std::function<long long()> defaultValueCallback,
115 long long startValue,
116 std::function<long long(long long, long long)> bestValue);
119 static void reworkShmSegmentSize(std::vector<DataProcessorInfo>& infos);
122 static void prepareArguments(
123 bool defaultQuiet,
124 bool defaultStopped,
125 bool intereactive,
126 unsigned short driverPort,
127 DriverConfig const& driverConfig,
128 std::vector<DataProcessorInfo> const& processorInfos,
129 std::vector<DeviceSpec> const& deviceSpecs,
130 std::vector<DeviceExecution>& deviceExecutions,
131 std::vector<DeviceControl>& deviceControls,
132 std::vector<ConfigParamSpec> const& detectedOptions,
133 std::string const& uniqueWorkflowId);
134
137 static std::string reworkTimeslicePlaceholder(std::string const& str, DeviceSpec const& spec);
138
143 static void processOutEdgeActions(
144 ConfigContext const& configContext,
145 std::vector<DeviceSpec>& devices,
146 std::vector<DeviceId>& deviceIndex,
147 std::vector<DeviceConnectionId>& connections,
148 ResourceManager& resourceManager,
149 const std::vector<size_t>& outEdgeIndex,
150 const std::vector<DeviceConnectionEdge>& logicalEdges,
151 const std::vector<EdgeAction>& actions,
152 const WorkflowSpec& workflow,
153 const std::vector<OutputSpec>& outputs,
154 std::vector<ChannelConfigurationPolicy> const& channelPolicies,
155 std::vector<SendingPolicy> const& sendingPolicies,
156 std::vector<ForwardingPolicy> const& forwardingPolicies,
157 std::string const& channelPrefix,
158 ComputingOffer const& defaultOffer,
159 OverrideServiceSpecs const& overrideServices = {});
160
165 static void processInEdgeActions(
166 std::vector<DeviceSpec>& devices,
167 std::vector<DeviceId>& deviceIndex,
168 const std::vector<DeviceConnectionId>& connections,
169 ResourceManager& resourceManager,
170 const std::vector<size_t>& inEdgeIndex,
171 const std::vector<DeviceConnectionEdge>& logicalEdges,
172 const std::vector<EdgeAction>& actions,
173 const WorkflowSpec& workflow,
174 const std::vector<LogicalForwardInfo>& availableForwardsInfo,
175 std::vector<ChannelConfigurationPolicy> const& channelPolicies,
176 std::string const& channelPrefix,
177 ComputingOffer const& defaultOffer,
178 OverrideServiceSpecs const& overrideServices = {});
179
182 static boost::program_options::options_description getForwardedDeviceOptions();
184 static bool hasLabel(DeviceSpec const& spec, char const* label);
185};
186
187} // namespace o2::framework
188#endif // O2_FRAMEWORK_DEVICESPECHELPERS_H_
GLuint const GLchar * name
Definition glcorearb.h:781
GLuint GLsizei const GLchar * label
Definition glcorearb.h:2519
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< OverrideServiceSpec > OverrideServiceSpecs
std::vector< DataProcessorSpec > WorkflowSpec
o2::framework::WorkflowSpec WorkflowSpec
static void processOutEdgeActions(ConfigContext const &configContext, std::vector< DeviceSpec > &devices, std::vector< DeviceId > &deviceIndex, std::vector< DeviceConnectionId > &connections, ResourceManager &resourceManager, const std::vector< size_t > &outEdgeIndex, const std::vector< DeviceConnectionEdge > &logicalEdges, const std::vector< EdgeAction > &actions, const WorkflowSpec &workflow, const std::vector< OutputSpec > &outputs, std::vector< ChannelConfigurationPolicy > const &channelPolicies, std::vector< SendingPolicy > const &sendingPolicies, std::vector< ForwardingPolicy > const &forwardingPolicies, std::string const &channelPrefix, ComputingOffer const &defaultOffer, OverrideServiceSpecs const &overrideServices={})
static void processInEdgeActions(std::vector< DeviceSpec > &devices, std::vector< DeviceId > &deviceIndex, const std::vector< DeviceConnectionId > &connections, ResourceManager &resourceManager, const std::vector< size_t > &inEdgeIndex, const std::vector< DeviceConnectionEdge > &logicalEdges, const std::vector< EdgeAction > &actions, const WorkflowSpec &workflow, const std::vector< LogicalForwardInfo > &availableForwardsInfo, std::vector< ChannelConfigurationPolicy > const &channelPolicies, std::string const &channelPrefix, ComputingOffer const &defaultOffer, OverrideServiceSpecs const &overrideServices={})
static void dataProcessorSpecs2DeviceSpecs(const WorkflowSpec &workflow, std::vector< ChannelConfigurationPolicy > const &channelPolicies, std::vector< CompletionPolicy > const &completionPolicies, std::vector< CallbacksPolicy > const &callbacksPolicies, std::vector< DeviceSpec > &devices, ResourceManager &resourceManager, std::string const &uniqueWorkflowId, ConfigContext const &configContext, bool optimizeTopology=false, unsigned short resourcesMonitoringInterval=0, std::string const &channelPrefix="", OverrideServiceSpecs const &overrideServices={})
static void validate(WorkflowSpec const &workflow)
static boost::program_options::options_description getForwardedDeviceOptions()
define the options which are forwarded to every child
static std::string inputChannel2String(const InputChannelSpec &channel)
Helper to provide the channel configuration string for an input channel.
static std::string reworkTimeslicePlaceholder(std::string const &str, DeviceSpec const &spec)
static void prepareArguments(bool defaultQuiet, bool defaultStopped, bool intereactive, unsigned short driverPort, DriverConfig const &driverConfig, std::vector< DataProcessorInfo > const &processorInfos, std::vector< DeviceSpec > const &deviceSpecs, std::vector< DeviceExecution > &deviceExecutions, std::vector< DeviceControl > &deviceControls, std::vector< ConfigParamSpec > const &detectedOptions, std::string const &uniqueWorkflowId)
static void reworkShmSegmentSize(std::vector< DataProcessorInfo > &infos)
static void reworkHomogeneousOption(std::vector< DataProcessorInfo > &infos, char const *name, char const *defaultValue)
static void reworkIntegerOption(std::vector< DataProcessorInfo > &infos, char const *name, std::function< long long()> defaultValueCallback, long long startValue, std::function< long long(long long, long long)> bestValue)
static bool hasLabel(DeviceSpec const &spec, char const *label)
static std::string outputChannel2String(const OutputChannelSpec &channel)
Helper to provide the channel configuration string for an output channel.
static void dataProcessorSpecs2DeviceSpecs(const WorkflowSpec &workflow, std::vector< ChannelConfigurationPolicy > const &channelPolicies, std::vector< CompletionPolicy > const &completionPolicies, std::vector< DispatchPolicy > const &dispatchPolicies, std::vector< ResourcePolicy > const &resourcePolicies, std::vector< CallbacksPolicy > const &callbacksPolicies, std::vector< SendingPolicy > const &sendingPolicy, std::vector< ForwardingPolicy > const &forwardingPolicies, std::vector< DeviceSpec > &devices, ResourceManager &resourceManager, std::string const &uniqueWorkflowId, ConfigContext const &configContext, bool optimizeTopology=false, unsigned short resourcesMonitoringInterval=0, std::string const &channelPrefix="", OverrideServiceSpecs const &overrideServices={})
static std::vector< DispatchPolicy > createDefaultPolicies()
Helper to create the default configuration.
static std::vector< ForwardingPolicy > createDefaultPolicies()
static std::vector< ResourcePolicy > createDefaultPolicies()
static std::vector< SendingPolicy > createDefaultPolicies()
const std::string str