Thursday, November 7, 2013

Intel power gadget for linux

This is a cool tool to tell you how much power your computer is using. Unfortunately I don't find it packaged anywhere and is not pre-built by intel. Then, it did not build for me as downloaded.

I downloaded it from here: http://software.intel.com/en-us/articles/intel-power-gadget-20 and the files were dated 24 Jun 2013. Unfortunately the makefile had the libm location wrong on the command line and wouldn't link. Here's my modification:

 CFLAGS=-g

all: rapl_lib_shared rapl_lib_static power_gadget_static

rapl_lib_shared:
    gcc $(CFLAGS) -fpic -c msr.c cpuid.c rapl.c -lm
    gcc $(CFLAGS) -shared -o librapl.so msr.o cpuid.o rapl.o -lm

rapl_lib_static:
    gcc -Wl, -t $(CFLAGS) -c msr.c cpuid.c rapl.c -lm
    ar rcs librapl.a msr.o cpuid.o rapl.o

power_gadget_static:
    gcc $(CFLAGS) power_gadget.c -I. -L. -o power_gadget ./librapl.a -lm

power_gadget:
    gcc $(CFLAGS) power_gadget.c -I. -L. -lrapl -o -lm power_gadget
gprof: CFLAGS = -pg
gprof: all
    ./power_gadget -e 100 -d 60 >/dev/null 2>&1
    gprof power_gadget > power_gadget.gprof
    rm -f gmon.out
    make clean

clean:
    rm -f power_gadget librapl.so librapl.a msr.o cpuid.o rapl.o

That builds it. But do bear in mind that it's a command-line tool in linux, unlike the nice GUIs for Windows/Mac.

Addendum: Apparently the files are no longer easily found on Intel's site. Here is the source code I downloaded.

No comments:

Post a Comment