Project
Loading...
Searching...
No Matches
ResourcePolicyHelpers.cxx
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
15
16#include <string>
17#include <regex>
18
19namespace o2::framework
20{
21
25{
26 return ResourcePolicy{
27 "trivial",
28 [matcher = std::regex(s)](DeviceSpec const& spec) -> bool {
29 return std::regex_match(spec.name, matcher);
30 },
32}
33
34ResourcePolicy ResourcePolicyHelpers::cpuBoundTask(char const* s, int requestedCPUs)
35{
36 return ResourcePolicy{
37 "cpu-bound",
38 [matcher = std::regex(s)](DeviceSpec const& spec) -> bool {
39 return std::regex_match(spec.name, matcher);
40 },
41 [requestedCPUs](ComputingQuotaOffer const& offer, ComputingQuotaOffer const& accumulated) -> OfferScore { return accumulated.cpu >= requestedCPUs ? OfferScore::Enough : OfferScore::More; }};
42}
43
44ResourcePolicy ResourcePolicyHelpers::sharedMemoryBoundTask(char const* s, int requestedSharedMemory)
45{
46 return ResourcePolicy{
47 "shm-bound",
48 [matcher = std::regex(s)](DeviceSpec const& spec) -> bool {
49 return std::regex_match(spec.name, matcher);
50 },
51 [requestedSharedMemory](ComputingQuotaOffer const& offer, ComputingQuotaOffer const& accumulated) -> OfferScore {
52 if (offer.sharedMemory == 0) {
54 }
55 return accumulated.sharedMemory >= requestedSharedMemory ? OfferScore::Enough : OfferScore::More; }};
56}
57
58} // namespace o2::framework
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
int64_t sharedMemory
How much shared memory it can allocate.
static ResourcePolicy trivialTask(char const *taskMatcher)
static ResourcePolicy sharedMemoryBoundTask(char const *taskMatcher, int maxMemory)
static ResourcePolicy cpuBoundTask(char const *taskMatcher, int maxCPUs=1)