forked from kliu20/jRAPL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
arch_spec.h
81 lines (68 loc) · 2.07 KB
/
arch_spec.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdint.h>
#include <unistd.h>
#ifndef _ARCH_SPEC_H
#define _ARCH_SPEC_H
/**
* Reference Intel ® 64 and IA-32 Architectures Software Developer’s Manual
* for those CPUID information (December 2016)
*
* Table: CPUID Signature Values of DisplayFamily_DisplayModel
*/
#define SANDYBRIDGE 0x2AU
#define SANDYBRIDGE_EP 0x2DU
#define IVYBRIDGE 0x3AU
#define SKYLAKE1 0x4EU
#define SKYLAKE2 0x5EU
#define SKYLAKEX 0x55U
#define HASWELL1 0x3CU
#define HASWELL2 0x45U
#define HASWELL3 0x46U
#define HASWELL_EP 0x3FU
#define BROADWELL 0xD4U
#define BROADWELL2 0x4FU
#define CLOUDLAB 0x56U
#define CPUID \
__asm__ volatile ("cpuid" \
: "=a" (eax), \
"=b" (ebx), \
"=c" (ecx), \
"=d" (edx) \
: "0" (eax), "2" (ecx))
typedef struct APIC_ID_t {
uint64_t smt_id;
uint64_t core_id;
uint64_t pkg_id;
uint64_t os_id;
} APIC_ID_t;
typedef struct cpuid_info_t {
uint32_t eax;
uint32_t ebx;
uint32_t ecx;
uint32_t edx;
} cpuid_info_t;
extern uint32_t eax, ebx, ecx, edx;
extern uint32_t cpu_model;
/*
int read_time = 0;
uint64_t max_pkg = 0;
uint64_t num_core_thread = 0; //number of physical threads per core
uint64_t num_pkg_thread = 0; //number of physical threads per package
uint64_t num_pkg_core = 0; //number of cores per package
uint64_t num_pkg = 0; //number of packages for current machine
*/
extern int core;
extern int read_time;
extern uint64_t max_pkg;
extern uint64_t num_core_thread; //number of physical threads per core
extern uint64_t num_pkg_thread; //number of physical threads per package
extern uint64_t num_pkg_core; //number of cores per package
extern uint64_t num_pkg; //number of packages for current machine
extern int coreNum;
//void
//get_cpu_model(void);
void
parse_apic_id(cpuid_info_t info_l0, cpuid_info_t info_l1, APIC_ID_t *my_id);
void cpuid(uint32_t eax_in, uint32_t ecx_in, cpuid_info_t *ci);
cpuid_info_t getProcessorTopology(uint32_t level);
int getSocketNum();
#endif