This repository was archived by the owner on Mar 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathInputParserUtil.cpp
More file actions
90 lines (76 loc) · 2.77 KB
/
Copy pathInputParserUtil.cpp
File metadata and controls
90 lines (76 loc) · 2.77 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
/**
* Copyright 2015 Pivotal Software, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/
#include "cli/InputParserUtil.hpp"
#include <cstddef>
#include <iostream>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
#include "catalog/CatalogConfig.h"
#include "storage/StorageConfig.h"
#include "utility/StringUtil.hpp"
#include "glog/logging.h"
#ifdef QUICKSTEP_HAVE_LIBNUMA
#include <numa.h>
#endif
using std::string;
namespace quickstep {
std::vector<int> InputParserUtil::ParseWorkerAffinities(
const int num_workers,
const string &affinity_string) {
std::vector<int> affinities;
if (affinity_string.empty()) {
affinities.resize(num_workers, -1);
return affinities;
}
if (!ParseIntString(affinity_string, ',', &affinities)) {
LOG(FATAL) << "--worker_affinities must be a comma-separated list of "
<< "integer CPU ids.\n";
}
for (const int affinity : affinities) {
if (affinity < -1) {
LOG(FATAL) << "CPU affinities specified by --worker_affinities must be "
<< "non-negative, or -1 to specify no affinity.\n";
}
}
if (affinities.size() < static_cast<std::size_t>(num_workers)) {
std::cout << "--num_workers is " << num_workers << ", but only "
<< "specified " << affinities.size() << " CPU affinities "
<< "with --worker_affinities. "
<< (num_workers - affinities.size()) << " workers will be "
<< "unaffinitized.\n";
affinities.resize(num_workers, -1);
} else if (affinities.size() > static_cast<std::size_t>(num_workers)) {
std::cout << "--num_workers is " << num_workers << ", but specified "
<< affinities.size() << " CPU affinities with "
<< "--worker_affinities. Extra affinities will be ignored.\n";
affinities.resize(num_workers);
}
return affinities;
}
std::vector<int> InputParserUtil::GetNUMANodesForCPUs() {
std::vector<int> numa_nodes_of_cpus;
#ifdef QUICKSTEP_HAVE_LIBNUMA
const int num_cpus = numa_num_configured_cpus();
numa_nodes_of_cpus.reserve(num_cpus);
for (int curr_cpu = 0; curr_cpu < num_cpus; ++curr_cpu) {
numa_nodes_of_cpus.push_back(numa_node_of_cpu(curr_cpu));
}
#endif
return numa_nodes_of_cpus;
}
} // namespace quickstep