Debian Codegraph @

perfmon-i7z/perfmon-i7z.h

raw symbols SCIP
1 //i7z.h
2 /* ----------------------------------------------------------------------- *
3 *
4 * Copyright 2009 Abhishek Jaiantilal
5 *
6 * Under GPL v2
7 *
8 * ----------------------------------------------------------------------- */
9
10 #define i7z_VERSION_INFO "svn-r43-(31-may-2010)"
11
12 #define CPU_FREQUENCY_LOGGING_FILE "cpu_freq_log.txt"
13
14 //structure to store the information about the processor
15 #define proccpuinfo "/proc/cpuinfo"
16
17 #ifndef bool
18 #define bool int
19 #endif
20 #define false 0
21 #define true 1
22
23 #define MAX_PROCESSORS 32
24 #define MAX_HI_PROCESSORS MAX_PROCESSORS
25 #define MAX_SK_PROCESSORS (MAX_PROCESSORS/4)
26
27 struct program_options{
28 int logging; //0=no logging, 1=logging, 2=appending
29 };
30
31 struct cpu_heirarchy_info {
32 int max_online_cpu;
33 int num_sockets;
34 int sibling_num[MAX_HI_PROCESSORS];
35 int processor_num[MAX_HI_PROCESSORS];
36 int package_num[MAX_HI_PROCESSORS];
37 int coreid_num[MAX_HI_PROCESSORS];
38 int display_cores[MAX_HI_PROCESSORS];
39 bool HT;
40 };
41
42 struct cpu_socket_info {
43 int max_cpu;
44 int socket_num;
45 int processor_num[MAX_SK_PROCESSORS];
46 int num_physical_cores;
47 int num_logical_cores;
48 };
49
50 struct family_info
51 {
52 char stepping;
53 char model;
54 char family;
55 char processor_type;
56 char extended_model;
57 int extended_family;
58 };
59
60 //read TSC() code for 32 and 64-bit
61 //http://www.mcs.anl.gov/~kazutomo/rdtsc.html
62
63 #ifndef x64_BIT
64 //code for 32 bit
65 static __inline__ unsigned long long int
66 rdtsc ()
67 {
68 unsigned long long int x;
69 __asm__ volatile (".byte 0x0f, 0x31":"=A" (x));
70 return x;
71 }
72 #endif
73
74 #ifdef x64_BIT
75 //code for 32 bit
76 static __inline__ unsigned long long
77 rdtsc (void)
78 {
79 unsigned hi, lo;
80 __asm__ __volatile__ ("rdtsc":"=a" (lo), "=d" (hi));
81 return ((unsigned long long) lo) | (((unsigned long long) hi) << 32);
82 }
83 #endif
84
85
86 void print_family_info (struct family_info *proc_info);
87
88 #ifdef x64_BIT
89 void get_vendor (char *vendor_string);
90 #endif
91
92 int turbo_status ();
93 double cpufreq_info();
94 void get_familyinformation (struct family_info *proc_info);
95
96 double estimate_MHz ();
97
98 uint64_t get_msr_value (int cpu, uint32_t reg, unsigned int highbit,
99 unsigned int lowbit, int* error_indx);
100
101 uint64_t set_msr_value (int cpu, uint32_t reg, uint64_t data, int* error_indx);
102
103
104 #ifdef USE_INTEL_CPUID
105 void get_CPUs_info (unsigned int *num_Logical_OS,
106 unsigned int *num_Logical_process,
107 unsigned int *num_Processor_Core,
108 unsigned int *num_Physical_Socket);
109
110 #endif
111
112 int get_number_of_present_cpu();
113 void get_candidate_cores(struct cpu_heirarchy_info* chi);
114 void get_online_cpus(struct cpu_heirarchy_info* chi);
115 void get_siblings_list(struct cpu_heirarchy_info* chi);
116 void get_package_ids(struct cpu_heirarchy_info* chi);
117 void print_cpu_list(struct cpu_heirarchy_info chi);
118 void construct_cpu_hierarchy(struct cpu_heirarchy_info *chi);
119 void Print_Information_Processor();
120 void Test_Or_Make_MSR_DEVICE_FILES();
121
122
123 int check_and_return_processor(char*strinfo);
124 int check_and_return_physical_id(char*strinfo);
125 void construct_sibling_list(struct cpu_heirarchy_info* chi);
126 void construct_socket_information(struct cpu_heirarchy_info* chi,struct cpu_socket_info* socket_0,struct cpu_socket_info* socket_1);
127 void print_socket_information(struct cpu_socket_info* socket);
128 void construct_CPU_Heirarchy_info(struct cpu_heirarchy_info* chi);
129 void print_CPU_Heirarchy(struct cpu_heirarchy_info chi);
130 int in_core_list(int ii,int* core_list);
131 void Print_Version_Information();
132
133 int num_msr();
134 int bit_width_PMCx();
135 #define SET_ONLINE_ARRAY_MINUS1(online_cpus) {for(i=0;i<32;i++) online_cpus[i]=-1;}
136 #define SET_ONLINE_ARRAY_PLUS1(online_cpus) {for(i=0;i<32;i++) online_cpus[i]=1;}
137
138 #define SET_IF_TRUE(error_indx,a,b) if(error_indx) a=b;
139 #define CONTINUE_IF_TRUE(cond) if(cond) continue;
140 #define RETURN_IF_TRUE(cond) if(cond) return;
141
142 //due to the fact that sometimes 100.0>100, the below macro checks till 101
143 #define THRESHOLD_BETWEEN_0_100(cond) (cond>=-1 && cond <=101 && !isinf(cond) && !isnan(cond))? cond: __builtin_inf()
144
145 //due to the fact that sometimes 100.0>100, the below macro checks till 101
146 #define IS_THIS_BETWEEN_0_100(cond) (cond>=-1 && cond <=101 && !isinf(cond) && !isnan(cond))? 1: 0
147
148 #define THRESHOLD_BETWEEN_0_6000(cond) (cond>=0 && cond <=10000)? cond: __builtin_inf()