-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.hpp
58 lines (49 loc) · 2.39 KB
/
utils.hpp
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
/*
* utils.hpp
*
* \date 5/7/2011
* \author Daniele De Sensi (d.desensi.software@gmail.com)
* =========================================================================
* Copyright (C) 2010-2014, Daniele De Sensi (d.desensi.software@gmail.com)
*
* This file is part of ffProbe.
*
* ffProbe is free software: you can redistribute it and/or
* modify it under the terms of the Lesser GNU General Public
* License as published by the Free Software Foundation, either
* version 3 of the License, or (at your option) any later version.
* ffProbe is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Lesser GNU General Public License for more details.
*
* You should have received a copy of the Lesser GNU General Public
* License along with ffProbe.
* If not, see <http://www.gnu.org/licenses/>.
*
* =========================================================================
*
* Implementation of utility functions.
*/
#ifndef UTILS_HPP_
#define UTILS_HPP_
typedef unsigned int uint;
#include <math.h>
/**
* Create the array with the identifiers of the cores on which the threads must be mapped.
* The elements from 0 to readers-1 will be the identifiers of the cores on which the readers must be mapped.
* The elements from readers to readers+workers-1 will be the identifiers of the cores on which the workers must be mapped.
* The last element of the array will be the identifier of the core on which the exporter must be mapped.
*/
bool contains(std::vector<std::pair<uint,uint> > &v, std::pair<uint,uint> &element);
/**
* Extract infos about the displacement of the cores on the chips of the machine.
* \param v This vector will be filled with the identifiers of the cores. If we have n cores per chip the vector
* will be divided in blocks of n elements. Each block will represents the identifiers of the core on a chip.
* Returns the number chips on the machine or 0 on error.
*/
uint captureCpuInfos(std::vector<uint> &processors_to_use);
void generateMapping(uint* cores, uint numThreads, uint chip);
/**Generate suggestions about a possible reduction/increase of the parallelism degree.**/
void generateSuggestions(float *workers_latencies, uint workers, float reader_latency, float exporter_latency, uint indipendent_exporter, uint readers=1);
#endif