Skip to content
This repository was archived by the owner on Mar 11, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
69 changes: 67 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,74 @@
sudo: required

services:
- docker

env:
global:
- secure: "BfP5e/OPM62e3ktm4RD2nuBJls2u8zdXg/YjNyght5dpD2vCjL6ZHWhgDM2mNFpzgYPiE3DPsSE7g2ZlsBUJCuK8a7lB5r+OiWFcWkilC1E9QX6OMcDTpEKb5A9InFGcpt0xbjY5+8qaIbaN8TJcdxaxeit0TZEvxeirQa5OOEY=" # COVERALLS_REPO_TOKEN
- secure: "ldIw526YR2Fe6FlfIPlbbOojEeg7etbO4dqiL4TLm00SBhVkKG+DuckhFixVAvAJx1Q1LuVyUPsXaR77OjqiTxSkaH+GbsmR5VIM4qA/kBheD4IiV4wTamg679d+AldRNWcGtLpefgwqlCJ53FcMzUT9TH/MJcbEaOJ5GKW9v+s=" # CODACY_PROJECT_TOKEN
- secure: "MLFJWju96LymkPNIsUeJelNN5J3BK55OV/RXVMONC5kDr4N7T4JyhT6KUa4k+FSJ0S1GTPQMWQQEkWDF1MlZXv5yGwW4h5rN3tt//vqyHk968SyqlhTdygqzx6tO6t3OsfQ2F1AqVWAWsHQckL+VmhEo53VqVXpsqLy9DyLYGjs=" # DOCKER_EMAIL
- secure: "FbLHLKNAtpj7ZVgSobOPgAgdLK3/P4sR6RcaOmpVRsgaqodTPx7VkzGpkf4rOqPwxKU3+96vr0TlIdPRYWAE39Y3gMb1dyZ34+CxsrJ3avJYc2+9NT3kmAuU33Iy1DCo3IEnR7pWVVEyR80ob0c1ASfPAW1JN8DhBRRERpkMyn4=" # DOCKER_USER
- secure: "VLK9NI4yE+hLV8rgjiB0hOfQn1uFO7cEHHL4sEDZKNu1TgvwfTrEWEzMMLvG8pwK/7eG78xfNB489m/Imj7Y52xK6sZuY7Y78Y06mkepZS8PisAJiW59kHWH1Ci84DYHZ0y07NAgvCOSLS9l0ncgLdlGvRboR9KBYDMEWycwEn8=" # DOCKER_PWD

cache:
directories:
- "$HOME/.m2/repository"
- "$HOME/.sbt"
- "$HOME/.ivy2"

language: scala

scala:
- 2.11.6
- 2.11.7

jdk:
- openjdk7

# workaround for openjdk buffer overflow
addons:
hostname: localhost

script:
- sbt clean "project powerapi-core" coverage test
- sbt compile test:compile
- sbt 'set concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)' "project powerapi-core" coverage test
- find $HOME/.sbt -name "*.lock" | xargs rm

before_install:
- wget -O influxdb.deb https://s3.amazonaws.com/influxdb/influxdb_0.10.2-1_amd64.deb
- sudo dpkg -i influxdb.deb
- sudo service influxdb start
- sleep 5; /usr/bin/influx --execute "CREATE USER powerapi WITH PASSWORD 'powerapi'
WITH ALL PRIVILEGES"

after_success:
- sbt "project powerapi-core" coverageReport
- sbt "project powerapi-core" codacyCoverage
- sbt "project powerapi-core" coveralls

before_deploy:
- sbt "project powerapi-sampling" universal:packageZipTarball
- sbt "project powerapi-cli" universal:packageZipTarball
- tar -C powerapi-sampling/target/universal -xvf powerapi-sampling/target/universal/powerapi-sampling.tgz
- tar -C powerapi-cli/target/universal -xvf powerapi-cli/target/universal/powerapi-cli.tgz

deploy:
provider: releases
api_key:
secure: IEU1nWNWXW394yjC8/2Ch3naFM18mUmns9q11U0sCWMm9nz7ej4D5crKxCPtIHyHtFlONY1s0udBk6rv3aCVq0UikOysHFiVdPPeJTRCtGptxOb04/pZtq3vITcMzS9+CQc+yV8Y3A2vv15L/30ERMk1fgur+Nb+8vTFfXfzEik=
file:
- "powerapi-sampling/target/universal/powerapi-sampling.tgz"
- "powerapi-cli/target/universal/powerapi-cli.tgz"
skip_cleanup: true
on:
tags: true
repo: Spirals-Team/powerapi

after_deploy:
- docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PWD
- docker build -f docker/sampling/Dockerfile-sampling -t spirals/powerapi-sampling:$TRAVIS_TAG .
- docker build -f docker/Dockerfile-cli -t spirals/powerapi-cli:$TRAVIS_TAG .
- docker tag spirals/powerapi-sampling:$TRAVIS_TAG spirals/powerapi-sampling:latest
- docker tag spirals/powerapi-cli:$TRAVIS_TAG spirals/powerapi-cli:latest
- docker push spirals/powerapi-sampling
- docker push spirals/powerapi-cli
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,9 @@ We all stand on the shoulders of giants and get by with a little help from our f
* [Scala IO](http://jesseeichar.github.io/scala-io-doc/0.4.3/index.html#!/overview) (version 0.4.3 under [3-clause BSD license](http://www.scala-lang.org/license.html)), for an extensions of IO.
* [Saddle](http://saddle.github.io/) (version 1.3.4 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for data manipulation.
* [Sigar](https://support.hyperic.com/display/SIGAR/Home) (version 1.6.5 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for providing a portable interface for gathering system information.
* [spray-can](http://spray.io/) (version 1.3.3 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for providing a low-level, low-overhead, high-performance HTTP server and client.
* [spray-client](http://spray.io/) (version 1.3.3 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for providing high-level HTTP client.
* [spray-routing](http://spray.io/) (version 1.3.3 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for providing a high-level, very flexible routing DSL for elegantly defining RESTful web services.
* [spray-json](http://spray.io/) (version 1.2.2 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for (de)serializing JSON.
* [nscala-time](https://github.com/nscala-time/nscala-time) (version 2.8.0 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for using a scala wrapper for Joda Time (quality replacement for the Java date and time classes).
* [spray-json](http://spray.io/) (version 1.3.2 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for (de)serializing JSON.
* [docker-java](https://github.com/docker-java/docker-java) (version 2.1.4 under [Apache 2 license](http://www.apache.org/licenses/LICENSE-2.0)), for using the JAVA Docker API.
* [influxdb-java](https://github.com/influxdata/influxdb-java) (version 2.1 under [MIT license](https://github.com/influxdata/influxdb-java/blob/master/LICENSE)), for using the JAVA InfluxDB API.

# License
This software is licensed under the *GNU Affero General Public License*, quoted below.
Expand Down
23 changes: 23 additions & 0 deletions docker/Dockerfile-cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM alpine:latest

ENV POWERAPI_PACKAGE powerapi-cli
ENV LIBPFM_PACKAGE libpfm-4.6.0

ENV INSTALL_PACKAGES ca-certificates linux-headers libc-dev make gcc patch
ENV RUNTIME_PACKAGES bluez bluez-dev openjdk7-jre bash procps

COPY docker/libpfm/config.mk.patch /root/
COPY ${POWERAPI_PACKAGE}/target/universal/${POWERAPI_PACKAGE}/ /root/${POWERAPI_PACKAGE}/

VOLUME /conf

RUN apk update && apk upgrade && apk add $INSTALL_PACKAGES $RUNTIME_PACKAGES && \
wget https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk && apk --allow-untrusted add glibc-2.21-r2.apk && rm -f glibc-2.21-r2.apk && \
wget http://downloads.sourceforge.net/project/perfmon2/libpfm4/${LIBPFM_PACKAGE}.tar.gz && tar -C /root -xzvf ${LIBPFM_PACKAGE}.tar.gz && patch -d /root/$LIBPFM_PACKAGE -p1 < /root/config.mk.patch && (cd /root/$LIBPFM_PACKAGE; make lib; make install) && rm -rf /root/config.mk.patch /root/$LIBPFM_PACKAGE ${LIBPFM_PACKAGE}.tar.gz && \
rm -rf /root/${POWERAPI_PACKAGE}/conf && ln -s /conf/ /root/${POWERAPI_PACKAGE}/conf && \
apk del glibc $INSTALL_PACKAGES && \
rm -rf /var/cache/apk/*

WORKDIR /root/$POWERAPI_PACKAGE

ENTRYPOINT ["./bin/powerapi"]
88 changes: 88 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
## Docker version of PowerAPI

Lightweight docker images of PowerAPI packaged as docker images.

You have first to create a [data volume](https://docs.docker.com/engine/userguide/containers/dockervolumes/#creating-and-mounting-a-data-volume-container) to store the configuration files (`conf` directory) for PowerAPI.
It will include all parameters needed to PowerAPI for configuring its internal components.
The different parameters to set up are described inside the [Wiki](https://github.com/Spirals-Team/powerapi/wiki).

We assume that two data volumes `powerapi-cli-conf` and `powerapi-sampling-conf` are created on the host system.

### PowerAPI: CLI

This image is used to run automatically a various choices of software-defined power meters.

#### Usage

Show the help text:

```
docker run --rm --privileged --net=host --pid=host \
--volumes-from powerapi-cli-conf \
spirals/powerapi-cli
```

The `--privileged` option is used to get the root access to the host machine,
the `--net=host` option is mandatory to be able to use the PowerSPY bluetooth power meter inside a container,
and the `--pid=host` is required to be able to get an access to the running apps of the host machine.

A classic example with the `ProcFS` module can be:

powerapi.conf:

```
powerapi.cpu.tdp = 35
```

Associated docker command:

```
docker run --rm --privileged --net=host --pid=host \
--volumes-from powerapi-cli-conf \
spirals/powerapi-cli \
modules procfs-cpu-simple monitor --frequency 1000 --all --console
```

### PowerAPI: Sampling

This image is used to build a CPU power model.

#### Usage

Launch the sampling:

```
docker run --rm --privileged --net=host --pid=host \
--volumes-from powerapi-sampling-conf \
spirals/powerapi-sampling
```

Example of a sampling configuration file:

sampling.conf:

```
powerspy.mac = "00:0B:CE:07:1E:9B"
powerapi.cpu.topology = [
{ core = 0, indexes = [0, 4] }
{ core = 1, indexes = [1, 5] }
{ core = 2, indexes = [2, 6] }
{ core = 3, indexes = [3, 7] }
]
powerapi.sampling.dvfs = true
powerapi.sampling.turbo = true
powerapi.cycles-polynom-regression.cpu-base-frequency = 0.133
powerapi.cycles-polynom-regression.cpu-max-frequency = 2.66
powerapi.cycles-polynom-regression.unhalted-cycles-event = "CPU_CLK_UNHALTED:THREAD_P"
powerapi.cycles-polynom-regression.ref-cycles-event = "CPU_CLK_UNHALTED:REF_P"
interval = 1s
powerapi.actors.timeout = 15s
powerapi.sampling.interval = ${interval}
powerspy.interval = ${interval}
powerapi.sampling.steps = [100, 25]
powerapi.sampling.step-duration = 10
```
11 changes: 11 additions & 0 deletions docker/libpfm/config.mk.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--- a/config.mk
+++ b/config.mk
@@ -194,7 +194,7 @@ endif
CC?=gcc
LIBS=
INSTALL=install
-LDCONFIG=ldconfig
+LDCONFIG=/usr/glibc/usr/bin/ldconfig
LN?=ln -sf
PFMINCDIR=$(TOPDIR)/include
PFMLIBDIR=$(TOPDIR)/lib
25 changes: 25 additions & 0 deletions docker/sampling/Dockerfile-sampling
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM alpine:latest

ENV POWERAPI_PACKAGE powerapi-sampling
ENV LIBPFM_PACKAGE libpfm-4.6.0

ENV INSTALL_PACKAGES ca-certificates linux-headers libc-dev make gcc patch
ENV RUNTIME_PACKAGES bluez bluez-dev openjdk7-jre bash util-linux cpulimit procps

COPY docker/libpfm/config.mk.patch /root/
COPY docker/sampling/run.sh /root/
COPY ${POWERAPI_PACKAGE}/target/universal/${POWERAPI_PACKAGE}/ /root/${POWERAPI_PACKAGE}/

VOLUME /conf

RUN apk update && apk upgrade && apk add $INSTALL_PACKAGES $RUNTIME_PACKAGES && \
wget https://circle-artifacts.com/gh/andyshinn/alpine-pkg-glibc/6/artifacts/0/home/ubuntu/alpine-pkg-glibc/packages/x86_64/glibc-2.21-r2.apk && apk --allow-untrusted add glibc-2.21-r2.apk && rm -f glibc-2.21-r2.apk && \
wget http://downloads.sourceforge.net/project/perfmon2/libpfm4/${LIBPFM_PACKAGE}.tar.gz && tar -C /root -xzvf ${LIBPFM_PACKAGE}.tar.gz && patch -d /root/$LIBPFM_PACKAGE -p1 < /root/config.mk.patch && (cd /root/$LIBPFM_PACKAGE; make lib; make install) && rm -rf /root/config.mk.patch /root/$LIBPFM_PACKAGE ${LIBPFM_PACKAGE}.tar.gz && \
wget http://people.seas.harvard.edu/~apw/stress/stress-1.0.4.tar.gz && tar -C /root -xzvf stress-1.0.4.tar.gz && (cd /root/stress-1.0.4; ./configure; make; make install) && rm -rf /root/stress-1.0.4 && \
rm -rf /${POWERAPI_PACKAGE}/conf && ln -s /conf/ /root/${POWERAPI_PACKAGE}/conf && \
apk del glibc $INSTALL_PACKAGES && \
rm -rf /var/cache/apk/*

WORKDIR /root

ENTRYPOINT ["./run.sh"]
9 changes: 9 additions & 0 deletions docker/sampling/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

cd powerapi-sampling && ./bin/sampling --all results/sampling results/processing results/computing

echo ""
echo "Here is your CPU power model to use with PowerAPI"
echo ""
cat results/computing/libpfm-formula.conf
echo ""
10 changes: 5 additions & 5 deletions powerapi-cli/build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
name := "powerapi-cli"

mappings in Universal += downloadBluecove.value -> s"lib/${downloadBluecove.value.name}"

mappings in Universal += downloadBluecoveGpl.value -> s"lib/${downloadBluecoveGpl.value.name}"

mappings in Universal ++= {
val dir = baseDirectory.value.getParentFile

Expand All @@ -25,4 +21,8 @@ mappings in Universal ++= {

scriptClasspath ++= Seq("../conf", "../scripts")

NativePackagerKeys.executableScriptName := "powerapi"
packageName in Universal := name.value

topLevelDirectory := Some(name.value)

executableScriptName := "powerapi"
Loading