Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/rm-hull/i7z into rmhull-m…
Browse files Browse the repository at this point in the history
…aster

Conflicts:
	README.txt
	i7z_Single_Socket.c
  • Loading branch information
ajaiantilal committed Oct 12, 2013
2 parents 555e1c9 + ed4f3bf commit 6a965c4
Show file tree
Hide file tree
Showing 13 changed files with 288 additions and 565 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GUI/i7z_GUI
i7z
13 changes: 5 additions & 8 deletions GUI/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#############################################################################
# Makefile for building: i7z_GUI
# Generated by qmake (2.01a) (Qt 4.8.1) on: Fri Nov 16 16:12:19 2012
# Generated by qmake (2.01a) (Qt 4.8.4) on: Fri Sep 13 10:41:57 2013
# Project: i7z_GUI.pro
# Template: app
# Command: /usr/bin/qmake -o Makefile i7z_GUI.pro
# Command: /usr/lib/x86_64-linux-gnu/qt4/bin/qmake -o Makefile i7z_GUI.pro
#############################################################################

####### Compiler, tools and options

CC = gcc
CXX = g++
DEFINES = -DQT_WEBKIT -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
DEFINES = -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
CFLAGS = -m64 -pipe -v -fno-schedule-insns2 -fno-schedule-insns -fno-inline-small-functions -fno-caller-saves -g -Wall -W -D_REENTRANT $(DEFINES)
CXXFLAGS = -m64 -pipe -v -fno-schedule-insns2 -fno-schedule-insns -fno-inline-small-functions -fno-caller-saves -g -Wall -W -D_REENTRANT $(DEFINES)
INCPATH = -I/usr/share/qt4/mkspecs/linux-g++-64 -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I.
Expand All @@ -19,7 +19,7 @@ LFLAGS = -m64
LIBS = $(SUBLIBS) -L/usr/lib/x86_64-linux-gnu -lQtGui -lQtCore -lpthread
AR = ar cqs
RANLIB =
QMAKE = /usr/bin/qmake
QMAKE = /usr/lib/x86_64-linux-gnu/qt4/bin/qmake
TAR = tar -cf
COMPRESS = gzip -9f
COPY = cp -f
Expand Down Expand Up @@ -52,7 +52,6 @@ DIST = /usr/share/qt4/mkspecs/common/unix.conf \
/usr/share/qt4/mkspecs/common/g++-base.conf \
/usr/share/qt4/mkspecs/common/g++-unix.conf \
/usr/share/qt4/mkspecs/qconfig.pri \
/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
/usr/share/qt4/mkspecs/features/qt_functions.prf \
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
Expand Down Expand Up @@ -109,7 +108,6 @@ Makefile: i7z_GUI.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share
/usr/share/qt4/mkspecs/common/g++-base.conf \
/usr/share/qt4/mkspecs/common/g++-unix.conf \
/usr/share/qt4/mkspecs/qconfig.pri \
/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
/usr/share/qt4/mkspecs/features/qt_functions.prf \
/usr/share/qt4/mkspecs/features/qt_config.prf \
/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
Expand All @@ -136,7 +134,6 @@ Makefile: i7z_GUI.pro /usr/share/qt4/mkspecs/linux-g++-64/qmake.conf /usr/share
/usr/share/qt4/mkspecs/common/g++-base.conf:
/usr/share/qt4/mkspecs/common/g++-unix.conf:
/usr/share/qt4/mkspecs/qconfig.pri:
/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri:
/usr/share/qt4/mkspecs/features/qt_functions.prf:
/usr/share/qt4/mkspecs/features/qt_config.prf:
/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
Expand Down Expand Up @@ -194,7 +191,7 @@ compiler_moc_source_clean:
i7z_GUI.moc: ../helper_functions.c \
../i7z.h \
i7z_GUI.cpp
/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) i7z_GUI.cpp -o i7z_GUI.moc
/usr/lib/x86_64-linux-gnu/qt4/bin/moc $(DEFINES) $(INCPATH) i7z_GUI.cpp -o i7z_GUI.moc

compiler_uic_make_all:
compiler_uic_clean:
Expand Down
2 changes: 1 addition & 1 deletion GUI/compile_me.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
#qmake-qt4 -project
#qmake-qt4
qmake
make
make clean
make
35 changes: 25 additions & 10 deletions GUI/i7z_GUI.moc
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/****************************************************************************
** Meta object code from reading C++ file 'i7z_GUI.cpp'
**
** Created: Mon Mar 12 16:54:28 2012
** by: The Qt Meta Object Compiler version 62 (Qt 4.7.4)
** Created: Fri Sep 13 10:43:03 2013
** by: The Qt Meta Object Compiler version 63 (Qt 4.8.4)
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/

#if !defined(Q_MOC_OUTPUT_REVISION)
#error "The header file 'i7z_GUI.cpp' doesn't include <QObject>."
#elif Q_MOC_OUTPUT_REVISION != 62
#error "This file was generated using the moc from 4.7.4. It"
#elif Q_MOC_OUTPUT_REVISION != 63
#error "This file was generated using the moc from 4.8.4. It"
#error "cannot be used with the include files from this version of Qt."
#error "(The moc has changed too much.)"
#endif
Expand All @@ -19,7 +19,7 @@ QT_BEGIN_MOC_NAMESPACE
static const uint qt_meta_data_MyWidget[] = {

// content:
5, // revision
6, // revision
0, // classname
0, 0, // classinfo
1, 14, // methods
Expand All @@ -39,9 +39,26 @@ static const char qt_meta_stringdata_MyWidget[] = {
"MyWidget\0\0UpdateWidget()\0"
};

void MyWidget::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
MyWidget *_t = static_cast<MyWidget *>(_o);
switch (_id) {
case 0: _t->UpdateWidget(); break;
default: ;
}
}
Q_UNUSED(_a);
}

const QMetaObjectExtraData MyWidget::staticMetaObjectExtraData = {
0, qt_static_metacall
};

const QMetaObject MyWidget::staticMetaObject = {
{ &QWidget::staticMetaObject, qt_meta_stringdata_MyWidget,
qt_meta_data_MyWidget, 0 }
qt_meta_data_MyWidget, &staticMetaObjectExtraData }
};

#ifdef Q_NO_DATA_RELOCATION
Expand All @@ -67,10 +84,8 @@ int MyWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: UpdateWidget(); break;
default: ;
}
if (_id < 1)
qt_static_metacall(this, _c, _id, _a);
_id -= 1;
}
return _id;
Expand Down
Empty file modified MAKEDEV-cpuid-msr
100755 → 100644
Empty file.
20 changes: 18 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
license: My code is GPLv2, Details in COPYING
Current Version: svn-92 (July/2012)
Current Version: git-93 (May/2013)

Prerequisites:
Ivy Bridge processors seem to need phc_intel to function correctly.

Compiling:
32/64-bit linux:
Expand All @@ -15,6 +18,7 @@ Running:
also needs support of MSR (model specific register) in kernel. Usually most kernels
have it. Else run the MAKEDEV file. I do modprobing of msr within the C-program.


I added in new code that shows a nice GUI.
The Makefile for that is in GUI/ subdirectory. Just install a couple of qt packages
and you should be all set to run it. There is a README file that lists those packages.
Expand All @@ -29,9 +33,15 @@ Installation


Version and Bug History:
v git-93 (27/May/2013)
added full (lol) support for Ivy Bridge

v svn 103 (Sep/2012)
some fixes for segv fault when cpuid code is not inline

v svn-43 (27/May/2010)
moved some global variables into individual functions.
removed a redundant line that was bieng printed
removed a redundant line that was bieng printed
GUI version should support upto 12 physical cores. can be easily edited for more cores.

v svn-40 (27/May/2010)
Expand Down Expand Up @@ -88,4 +98,10 @@ v0.01- very simple program to examine i7 feature clocking and running with speed



<<<<<<< HEAD
coder: Abhishek Jaiantilal ([email protected]). And suggestions/help from multiple people.
=======
coder: Abhishek Jaiantilal ([email protected])
contributor: raininja <[email protected]>
contributor: Richard Hull <[email protected]>
>>>>>>> ed4f3bf81bdbf160b0b052571e3799db45de7779
21 changes: 4 additions & 17 deletions doc/i7z.man
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,17 @@ i7z runs the i7z, ncurses based, program without any options. i7z will print out
.TP
\fB-h, --help \fPshow the list of options available with the i7z tool.
.TP
\fB-w [a|l], --write [a,l] \fPLogging enabled via this option. Frequencies will always be logged (no way yet to disable them yet), temperature and cstate logging are disabled by default. Option "-w a" or "--write a" will append to the log file. Option "-w l" or "--write l" will replace the log file.
\fB-w [a|l], --write [a,l] \fPLogging of the frequencies can be turned on with this options. Option "-w a" or "--write a" will append to the log file. Option "-w l" or "--write l" will replace the log file.
.TP
\fB-c, --logcstate \fPLogging of the cstates can be turned on with this options. cstate logging is disabled by default, this option will enable it. Note that \fB-w [a|l]\fP has to be set, else this option remains disabled.
.TP
\fB-t, --logtemp \fPLogging of the temperature can be turned on with this options. temperature logging is disabled by default, this option will enable it. Note that \fB-w [a|l]\fP has to be set, else this option remains disabled.
.TP
\fB-l, --logfile [FILENAME] \fPChange the (frequency) log file name to the specified FILENAME. Default logging file is cpu_freq_log.txt (single socket) or cpu_freq_log_dual%d.txt (dual socket, %d is either 0, 1).
.TP
\fB-x, --templogfile [FILENAME] \fPChange the temperature log file name to the specified FILENAME. Default logging file is cpu_temp_log.txt (single socket) or cpu_temp_log_dual%d.txt (dual socket, %d is either 0, 1).
.TP
\fB-p, --cstatelogfile [FILENAME] \fPChange the cstate log file name to the specified FILENAME. Default logging file is cpu_cstate_log.txt (single socket) or cpu_cstate_log_dual%d.txt (dual socket, %d is either 0, 1).
\fB-l, --logfile [FILENAME] \fPChange the log file name to the specified FILENAME. Default logging file is cpu_freq_log.txt (single socket) or cpu_freq_log_dual%d.txt (dual socket, %d is either 0, 1).
.TP
\fB--socket0 [SOCKETNUM], --socket1 [SOCKETNUM] \fPThe tool can print information for about 2 sockets at once at the most. The top view will be, by default, of the first socket (controlled by --socket0) and the bottom view will be of the second socket (controlled by --socket1). Supply the appropriate value of 0 or 1 or more for SOCKETNUM (if there are more sockets on the machine) to show in the top and bottom view.
.TP
\fB--nogui \fPDisable the GUI. Useful when the only need is logging.
.SH Example
To print for two sockets and also change the frequency log file (log to /tmp/logfilei7z). Note that \fB-w [a|l]\fP has to be supplied for enabling logging.

i7z \-\-socket0 0 \-\-socket1 1 \-\-logfile /tmp/logfilei7z \-w l

.SH Example
To print for two sockets and also change the log files (freq logged to /tmp/freq.txt, temperature logged to /tmp/temp.txt, cstates to /tmp/cstates.txt). Note that \fB-w [a|l]\fP has to be supplied for enabling logging.
To print for two sockets and also change the log file (log to /tmp/logfilei7z)

i7z \-\-socket0 0 \-\-socket1 1 \-\-logfile /tmp/freq.txt \-w l \-\-cstatelogfile /tmp/cstates.txt \-\-templogfile /tmp/temp.txt
i7z \-\-socket0 0 \-\-socket1 1 \-logfile /tmp/logfilei7z \-w l

.SH BUGS
Do report bugs or feature enhancement as an issue at http://code.google.com/p/i7z.
Expand Down
63 changes: 33 additions & 30 deletions helper_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA;
* Boston, MA 02110-1301, USA;
* either version 2 of the License, or (at your option) any later
* version; incorporated herein by reference.
*
Expand Down Expand Up @@ -45,7 +45,7 @@ bool E7_mp_present=false;
#define IA32_TEMPERATURE_TARGET 0x1a2
#define IA32_PACKAGE_THERM_STATUS 0x1b1

int Get_Bits_Value(unsigned long val,int highbit, int lowbit){
int Get_Bits_Value(unsigned long val,int highbit, int lowbit){
unsigned long data = val;
int bits = highbit - lowbit + 1;
if(bits<64){
Expand Down Expand Up @@ -167,7 +167,7 @@ double estimate_MHz ()
*/
struct timezone tz;
struct timeval tvstart, tvstop;
unsigned long long int cycles[2]; /* gotta be 64 bit */
unsigned long long int cycles[2]; /* must be 64 bit */
unsigned long long int microseconds; /* total time taken */

memset (&tz, 0, sizeof (tz));
Expand All @@ -178,7 +178,7 @@ double estimate_MHz ()
gettimeofday (&tvstart, &tz);

/* we don't trust that this is any specific length of time */
//1 sec will cause rdtsc to overlap multiple times perhaps. 100msecs is a good spot
/*1 sec will cause rdtsc to overlap multiple times perhaps. 100msecs is a good spot */
usleep (10000);

cycles[1] = rdtsc ();
Expand Down Expand Up @@ -326,7 +326,6 @@ uint64_t set_msr_value (int cpu, uint32_t reg, uint64_t data)
void get_CPUs_info (unsigned int *num_Logical_OS,
unsigned int *num_Logical_process,
unsigned int *num_Processor_Core,

unsigned int *num_Physical_Socket);

#endif
Expand All @@ -348,7 +347,7 @@ void Print_Version_Information()


//sets whether its nehalem or sandy bridge
void Print_Information_Processor(bool* nehalem, bool* sandy_bridge)
void Print_Information_Processor(bool* nehalem, bool* sandy_bridge, bool* ivy_bridge, bool* haswell)
{
struct family_info proc_info;

Expand Down Expand Up @@ -399,11 +398,11 @@ void Print_Information_Processor(bool* nehalem, bool* sandy_bridge)
//0x1, 0xA - i7, 45nm
//0x1, 0xE - i7, i5, Xeon, 45nm
//0x2, 0xE - Xeon MP, 45nm //e.g. x75xx processors
//0x2, 0xF - Xeon MP, 32nm //e.g. e7-48xx processors
//0x2, 0xF - Xeon MP, 32nm //e.g. e7-48xx processors
//0x2, 0xC - i7, Xeon, 32nm
//0x2, 0x5 - i3, i5, i7 mobile processors, 32nm
//0x2, 0xA - i7, 32nm

//0x3, 0xA - i7, 22nm
//http://ark.intel.com/SSPECQDF.aspx
//http://software.intel.com/en-us/articles/intel-processor-identification-with-cpuid-model-and-family-numbers/
printf("i7z DEBUG: msr = Model Specific Register\n");
Expand All @@ -426,64 +425,68 @@ void Print_Information_Processor(bool* nehalem, bool* sandy_bridge)
}
*nehalem = true;
*sandy_bridge = false;
*ivy_bridge = false;
*haswell = true;

} else if (proc_info.extended_model == 0x2) {
switch (proc_info.model)
{
case 0xE:
printf ("i7z DEBUG: Detected a Xeon MP - 45nm (7500, 6500 series)\n");
*nehalem = true;
*sandy_bridge = false;
break;
*ivy_bridge = false;
*haswell = false;
break;
case 0xF:
printf ("i7z DEBUG: Detected a Xeon MP - 32nm (E7 series)\n");
*nehalem = true;
*sandy_bridge = false;
*ivy_bridge = false;
*haswell = false;
E7_mp_present = true;
break;
case 0xC:
*nehalem = true;
*sandy_bridge = false;
*ivy_bridge = false;
*haswell = false;
printf ("i7z DEBUG: Detected an i7/Xeon - 32 nm (westmere)\n");
break;
case 0x5:
*nehalem = true;
*sandy_bridge = false;
*ivy_bridge = false;
*haswell = false;
printf ("i7z DEBUG: Detected an i3/i5/i7 - 32nm (westmere - 1st generation core)\n");
break;
case 0xD:
*nehalem = false;
*sandy_bridge = true;
printf ("i7z DEBUG: Detected an i7 - 32nm (haven't seen this version around, do write to me with the model number)\n");
*ivy_bridge = false;
*haswell = false;
printf ("i7z DEBUG: Detected an i7 - 32nm (haven't seen this version around, do write to me with the model number)\n");
break;
case 0xA:
*nehalem = false;
*sandy_bridge = true;
printf ("i7z DEBUG: Detected an i3/i5/i7 - 32nm (sandy bridge - 2nd generation core)\n");
break;
default:
printf ("i7z DEBUG: Unknown processor, not exactly based on Nehalem\n");
printf("i7z DEBUG: detected a newer model of ivy bridge processor\n");
printf("i7z DEBUG: my coder doesn't know about it, can you send the following info to him?\n");
printf("i7z DEBUG: model %x, extended model %x, proc_family %x\n", proc_info.model, proc_info.extended_model, proc_info.family);
//exit (1);
}
} else if (proc_info.extended_model == 0x3) {
switch (proc_info.model)
{
case 0xA:
printf ("i7z DEBUG: Detected an ivy bridege processor\n");
printf ("i7z DEBUG: Detected an i7 - 22nm (ivy bridge) \n");
*nehalem = false;
*sandy_bridge = true;
*sandy_bridge = false;
*ivy_bridge = true;
*haswell = false;
break;
case 0xC:
*nehalem = false;
*sandy_bridge = true;
printf ("i7z DEBUG: Detected an i3/i5/i7 - 22nm (haswell - 4th generation core)\n");
break;
printf ("i7z DEBUG: Detected an i7 - 22nm (haswell)\n");
*nehalem = false;
*sandy_bridge = false;
*ivy_bridge = false;
*haswell = true;
break;
default:
printf("i7z DEBUG: detected a newer model of ivy bridge processor\n");
printf("i7z DEBUG: my coder doesn't know about it, can you send the following info to him?\n");
printf("i7z DEBUG: model %x, extended model %x, proc_family %x\n", proc_info.model, proc_info.extended_model, proc_info.family);
sleep(5);
}
} else {
Expand All @@ -498,7 +501,7 @@ void Print_Information_Processor(bool* nehalem, bool* sandy_bridge)

}

void Test_Or_Make_MSR_DEVICE_FILES()
void Test_Or_Make_MSR_DEVICE_FILES()
{
//test if the msr file exists
if (access ("/dev/cpu/0/msr", F_OK) == 0)
Expand Down
Loading

0 comments on commit 6a965c4

Please sign in to comment.