forked from max0x7ba/atomic_queue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpu_base_frequency.h
44 lines (27 loc) · 1.68 KB
/
cpu_base_frequency.h
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
/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
#ifndef CPU_BASE_FREQUENCY_H_INCLUDED
#define CPU_BASE_FREQUENCY_H_INCLUDED
// Copyright (c) 2019 Maxim Egorushkin. MIT License. See the full licence in file LICENSE.
#include <vector>
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
namespace atomic_queue {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
double cpu_base_frequency();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
struct CpuTopologyInfo {
unsigned socket_id;
unsigned core_id;
unsigned hw_thread_id;
};
std::vector<CpuTopologyInfo> get_cpu_topology_info();
std::vector<CpuTopologyInfo> sort_by_core_id(std::vector<CpuTopologyInfo> const&);
std::vector<CpuTopologyInfo> sort_by_hw_thread_id(std::vector<CpuTopologyInfo> const&);
std::vector<unsigned> hw_thread_id(std::vector<CpuTopologyInfo> const&);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void set_thread_affinity(unsigned hw_thread_id);
void reset_thread_affinity();
void set_default_thread_affinity(unsigned hw_thread_id);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
} // namespace atomic_queue
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#endif // QUORUM_CPU_BASE_FREQUENCY_H_INCLUDED