-
Notifications
You must be signed in to change notification settings - Fork 496
Expand file tree
/
Copy pathDefaultsHelpers.cxx
More file actions
94 lines (84 loc) · 3.42 KB
/
DefaultsHelpers.cxx
File metadata and controls
94 lines (84 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/DefaultsHelpers.h"
#include "Framework/DataTakingContext.h"
#include "Framework/DeviceConfig.h"
#include <fairmq/ProgOptions.h>
#include <cstdlib>
#include <cstring>
#include <stdexcept>
namespace o2::framework
{
unsigned int DefaultsHelpers::pipelineLength(unsigned int minLength)
{
static bool override = getenv("DPL_DEFAULT_PIPELINE_LENGTH");
if (override) {
static unsigned int retval = atoi(getenv("DPL_DEFAULT_PIPELINE_LENGTH"));
return std::max(minLength, retval);
}
DeploymentMode deploymentMode = DefaultsHelpers::deploymentMode();
// just some reasonable numers
// The number should really be tuned at runtime for each processor.
if (deploymentMode == DeploymentMode::OnlineDDS || deploymentMode == DeploymentMode::OnlineECS || deploymentMode == DeploymentMode::FST) {
return std::max(minLength, 512u);
} else {
return std::max(minLength, 64u);
}
}
unsigned int DefaultsHelpers::pipelineLength(const DeviceConfig& dc)
{
static unsigned int minLength = dc.options.count("timeframes-rate-limit") ? std::max(0, atoi(dc.options["timeframes-rate-limit"].as<std::string>().c_str())) : 0;
return pipelineLength(minLength);
}
unsigned int DefaultsHelpers::pipelineLength(const fair::mq::ProgOptions& options)
{
static unsigned int minLength = options.Count("timeframes-rate-limit") ? std::max(0, atoi(options.GetValue<std::string>("timeframes-rate-limit").c_str())) : 0;
return pipelineLength(minLength);
}
static DeploymentMode getDeploymentMode_internal()
{
char* explicitMode = getenv("O2_DPL_DEPLOYMENT_MODE");
if (explicitMode != nullptr) {
if (strcmp(explicitMode, "OnlineDDS") == 0) {
return DeploymentMode::OnlineDDS;
} else if (strcmp(explicitMode, "OnlineECS") == 0) {
return DeploymentMode::OnlineECS;
} else if (strcmp(explicitMode, "OnlineAUX") == 0) {
return DeploymentMode::OnlineAUX;
} else if (strcmp(explicitMode, "Local") == 0) {
return DeploymentMode::Local;
} else if (strcmp(explicitMode, "Grid") == 0) {
return DeploymentMode::Grid;
} else if (strcmp(explicitMode, "FST") == 0) {
return DeploymentMode::FST;
} else {
throw std::runtime_error("Invalid deployment mode");
}
}
return getenv("DDS_SESSION_ID") != nullptr ? DeploymentMode::OnlineDDS : (getenv("OCC_CONTROL_PORT") != nullptr ? DeploymentMode::OnlineECS : (getenv("ALIEN_PROC_ID") != nullptr ? DeploymentMode::Grid : (getenv("ALICE_O2_FST") ? DeploymentMode::FST : (DeploymentMode::Local))));
}
DeploymentMode DefaultsHelpers::deploymentMode()
{
static DeploymentMode retVal = getDeploymentMode_internal();
return retVal;
}
bool DefaultsHelpers::onlineDeploymentMode()
{
switch (DefaultsHelpers::deploymentMode()) {
case DeploymentMode::OnlineAUX:
case DeploymentMode::OnlineECS:
case DeploymentMode::OnlineDDS:
return true;
default:
return false;
}
}
} // namespace o2::framework