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
12
#include "
Framework/ResourcePolicyHelpers.h
"
13
#include "
Framework/DeviceSpec.h
"
14
#include "
ResourcesMonitoringHelper.h
"
15
16
#include <string>
17
#include <regex>
18
19
namespace
o2::framework
20
{
21
24
ResourcePolicy
ResourcePolicyHelpers::trivialTask
(
char
const
* s)
25
{
26
return
ResourcePolicy
{
27
"trivial"
,
28
[matcher = std::regex(s)](
DeviceSpec
const
& spec) ->
bool
{
29
return
std::regex_match(spec.name, matcher);
30
},
31
[](
ComputingQuotaOffer
const
&,
ComputingQuotaOffer
const
&) ->
OfferScore
{
return
OfferScore::Enough
; }};
32
}
33
34
ResourcePolicy
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
44
ResourcePolicy
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) {
53
return
OfferScore::Unneeded
;
54
}
55
return
accumulated.sharedMemory >= requestedSharedMemory ?
OfferScore::Enough
:
OfferScore::More
; }};
56
}
57
58
}
// namespace o2::framework
DeviceSpec.h
ResourcePolicyHelpers.h
ResourcesMonitoringHelper.h
o2::framework
Defining PrimaryVertex explicitly as messageable.
Definition
TFIDInfo.h:20
o2::framework::OfferScore
OfferScore
Definition
ComputingQuotaOffer.h:26
o2::framework::OfferScore::Enough
@ Enough
o2::framework::OfferScore::Unneeded
@ Unneeded
o2::framework::OfferScore::More
@ More
o2::framework::ComputingQuotaOffer
Definition
ComputingQuotaOffer.h:40
o2::framework::ComputingQuotaOffer::sharedMemory
int64_t sharedMemory
How much shared memory it can allocate.
Definition
ComputingQuotaOffer.h:46
o2::framework::DeviceSpec
Definition
DeviceSpec.h:48
o2::framework::ResourcePolicyHelpers::trivialTask
static ResourcePolicy trivialTask(char const *taskMatcher)
Definition
ResourcePolicyHelpers.cxx:24
o2::framework::ResourcePolicyHelpers::sharedMemoryBoundTask
static ResourcePolicy sharedMemoryBoundTask(char const *taskMatcher, int maxMemory)
Definition
ResourcePolicyHelpers.cxx:44
o2::framework::ResourcePolicyHelpers::cpuBoundTask
static ResourcePolicy cpuBoundTask(char const *taskMatcher, int maxCPUs=1)
Definition
ResourcePolicyHelpers.cxx:34
o2::framework::ResourcePolicy
Definition
ResourcePolicy.h:26
Framework
Core
src
ResourcePolicyHelpers.cxx
Generated on Tue Feb 25 2025 23:16:40 for Project by
1.9.8