Project
Loading...
Searching...
No Matches
ComputingResourceHelpers.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
#include "
ComputingResourceHelpers.h
"
12
#include <thread>
13
#include <unistd.h>
14
#include <sstream>
15
16
namespace
o2::framework
17
{
18
long
getTotalNumberOfBytes
()
19
{
20
long
pages = sysconf(_SC_PHYS_PAGES);
21
long
page_size = sysconf(_SC_PAGE_SIZE);
22
return
pages * page_size;
23
};
24
25
ComputingResource
ComputingResourceHelpers::getLocalhostResource
()
26
{
27
ComputingResource
result
;
28
result
.
cpu
= std::thread::hardware_concurrency(),
29
result
.memory =
getTotalNumberOfBytes
();
30
result
.hostname =
"localhost"
;
31
result
.startPort = 22000;
32
result
.lastPort = 27000;
33
result
.usedPorts = 0;
34
return
result
;
35
}
36
37
std::vector<ComputingResource>
ComputingResourceHelpers::parseResources
(std::string
const
& resourceString)
38
{
39
std::vector<ComputingResource> resources;
40
std::istringstream
str
{resourceString};
41
std::string
result
;
42
while
(std::getline(
str
,
result
,
','
)) {
43
std::istringstream in{
result
};
44
char
colon;
45
ComputingResource
resource;
46
std::getline(in, resource.
hostname
,
':'
);
47
in >> resource.
cpu
>> colon >> resource.
memory
>> colon >> resource.
startPort
>> colon >> resource.
lastPort
;
48
resource.
memory
= resource.
memory
* 1000000;
49
resource.
usedPorts
= 0;
50
resources.emplace_back(resource);
51
}
52
return
resources;
53
}
54
55
}
// namespace o2::framework
ComputingResourceHelpers.h
result
GLuint64EXT * result
Definition
glcorearb.h:5662
o2::framework
Defining PrimaryVertex explicitly as messageable.
Definition
TFIDInfo.h:20
o2::framework::getTotalNumberOfBytes
long getTotalNumberOfBytes()
Definition
ComputingResourceHelpers.cxx:18
o2::framework::ComputingResourceHelpers::parseResources
static std::vector< ComputingResource > parseResources(std::string const &resourceString)
Definition
ComputingResourceHelpers.cxx:37
o2::framework::ComputingResourceHelpers::getLocalhostResource
static ComputingResource getLocalhostResource()
Definition
ComputingResourceHelpers.cxx:25
o2::framework::ComputingResource
A computing resource which can be offered to run a device.
Definition
ComputingResource.h:28
o2::framework::ComputingResource::lastPort
unsigned short lastPort
Definition
ComputingResource.h:43
o2::framework::ComputingResource::hostname
std::string hostname
Definition
ComputingResource.h:41
o2::framework::ComputingResource::startPort
unsigned short startPort
Definition
ComputingResource.h:42
o2::framework::ComputingResource::usedPorts
unsigned short usedPorts
Definition
ComputingResource.h:44
o2::framework::ComputingResource::cpu
float cpu
Definition
ComputingResource.h:39
o2::framework::ComputingResource::memory
float memory
Definition
ComputingResource.h:40
str
const std::string str
Definition
test_ransEncodeDecode.cxx:37
Framework
Core
src
ComputingResourceHelpers.cxx
Generated on Tue Feb 25 2025 17:03:20 for Project by
1.9.8