forked from powerapi-ng/powerapi-scala
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improves a comment inside the build.sbt file chore(README): update README Adds the missing acknowledgements inside the README
- Loading branch information
Showing
7 changed files
with
57 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/main/scala/org/powerapi/configuration/SamplingConfiguration.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* This software is licensed under the GNU Affero General Public License, quoted below. | ||
* | ||
* This file is a part of PowerAPI. | ||
* | ||
* Copyright (C) 2011-2014 Inria, University of Lille 1. | ||
* | ||
* PowerAPI is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as | ||
* published by the Free Software Foundation, either version 3 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* PowerAPI is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with PowerAPI. | ||
* | ||
* If not, please consult http://www.gnu.org/licenses/agpl-3.0.html. | ||
*/ | ||
package org.powerapi.configuration | ||
|
||
import org.powerapi.core.Configuration | ||
|
||
/** | ||
* Sampling configuration. | ||
* | ||
* @author Maxime Colmant <[email protected]> | ||
*/ | ||
trait SamplingConfiguration { | ||
self: Configuration => | ||
|
||
import java.util.concurrent.TimeUnit | ||
import org.powerapi.core.ConfigValue | ||
import scala.concurrent.duration.{DurationDouble, FiniteDuration} | ||
|
||
lazy val samplingInterval: FiniteDuration = load { _.getDuration("powerapi.sampling.interval", TimeUnit.MILLISECONDS) } match { | ||
case ConfigValue(value) => value.milliseconds | ||
case _ => 1.seconds | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
*/ | ||
package org.powerapi.module.libpfm.cycles | ||
|
||
import org.powerapi.configuration.SamplingConfiguration | ||
import org.powerapi.core.{Configuration, MessageBus} | ||
import org.powerapi.module.FormulaComponent | ||
import org.powerapi.module.libpfm.PerformanceCounterChannel.PCReport | ||
|
@@ -35,41 +36,34 @@ import org.powerapi.module.libpfm.PerformanceCounterChannel.PCReport | |
* | ||
* @author Maxime Colmant <[email protected]> | ||
*/ | ||
class LibpfmCoreCyclesFormula(eventBus: MessageBus) extends FormulaComponent[PCReport](eventBus) with Configuration { | ||
class LibpfmCoreCyclesFormula(eventBus: MessageBus) extends FormulaComponent[PCReport](eventBus) with SamplingConfiguration with Configuration { | ||
import breeze.numerics.polyval | ||
import com.typesafe.config.Config | ||
import java.util.concurrent.TimeUnit | ||
import org.powerapi.core.ConfigValue | ||
import org.powerapi.module.libpfm.PerformanceCounterChannel.subscribePCReport | ||
import org.powerapi.module.PowerChannel.publishPowerReport | ||
import org.powerapi.module.PowerUnit | ||
import scala.collection.JavaConversions._ | ||
import scala.concurrent.duration.{DurationDouble, FiniteDuration} | ||
import scala.concurrent.Future | ||
|
||
lazy val cyclesThreadName: String = load { _.getString("powerapi.libpfm.cycles-thread") } match { | ||
lazy val cyclesThreadName: String = load { _.getString("powerapi.libpfm.formulae.cycles-thread") } match { | ||
case ConfigValue(value) => value | ||
case _ => "CPU_CLK_UNHALTED:THREAD_P" | ||
} | ||
|
||
lazy val cyclesRefName: String = load { _.getString("powerapi.libpfm.cycles-ref") } match { | ||
lazy val cyclesRefName: String = load { _.getString("powerapi.libpfm.formulae.cycles-ref") } match { | ||
case ConfigValue(value) => value | ||
case _ => "CPU_CLK_UNHALTED:REF_P" | ||
} | ||
|
||
lazy val formulae: Map[Double, Array[Double]] = load { conf => | ||
(for (item: Config <- conf.getConfigList("powerapi.libpfm-cycles-formulae")) | ||
(for (item: Config <- conf.getConfigList("powerapi.libpfm.formulae.cycles")) | ||
yield (item.getDouble("coefficient"), item.getDoubleList("formula").map(_.toDouble).toArray)).toMap | ||
} match { | ||
case ConfigValue(values) => values | ||
case _ => Map() | ||
} | ||
|
||
lazy val samplingInterval: FiniteDuration = load { _.getDuration("powerapi.sampling.interval", TimeUnit.MILLISECONDS) } match { | ||
case ConfigValue(value) => value.milliseconds | ||
case _ => 1.seconds | ||
} | ||
|
||
def subscribeSensorReport(): Unit = { | ||
subscribePCReport(eventBus)(self) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
powerapi.sampling.interval = 1second |