diff --git a/.gitlab-ci.dhall b/.gitlab-ci.dhall index 625bb160c5de6b2f5b4700c6f4a36e8f88114aa2..218d9dad95caa0c95f26689c69dbed69defb2352 100644 --- a/.gitlab-ci.dhall +++ b/.gitlab-ci.dhall @@ -8,7 +8,7 @@ let baseJob = let mkJob = λ(stage : Text) → λ(target : Text) - → baseJob stage ("nix-shell -p gnumake --run 'make " ++ target ++"'") + → baseJob stage ("nix-shell -p gnumake --run 'make " ++ target ++ "'") let mkNix = λ(stage : Text) @@ -23,66 +23,36 @@ let mkT = mkJob "test" let mkNixB = mkNix "build" -in { stages = - [ "source", "build", "test", "deploy" ] - , nix/hsnrm-bin = - mkNixB "haskellPackages.hsnrm-bin" - , nix/hsnrm = - mkNixB "haskellPackages.hsnrm" - , nix/pynrm = - mkNixB "pythonPackages.pynrm" - , nix/libnrm = - mkNixB "libnrm" - , nix/stream = - mkNixB "stream" - , notebooks = - mkT "notebooks" - , tests/kvm = - mkT "tests-kvm" - , tests/apps = - mkT "app-tests" - , tests/rapl = - mkT "tests-rapl" // {tags = ["chimera"]} - , tests/perf = - mkT "tests-perf" // {tags = ["chimera"]} - , libnrm/autotools = - mkB "libnrm/autotools" - , hsnrm/all = - mkB "hsnrm/all" - , hsnrm/hsnrm-bin/hsnrm-bin_cabal = - mkS "hsnrm/hsnrm/hsnrm.cabal" - , hsnrm/hsnrm/hsnrm_cabal = - mkS "hsnrm/hsnrm-bin/hsnrm-bin.cabal" - , hsnrm/resources = - mkS "hsnrm/resources" - , shellcheck = - mkS "shellcheck" - , nixfmt = - mkS "nixfmt" - , dhall-format = - mkS "dhall-format" - , libnrm/clang-format = - mkS "libnrm/clang-format" - , pynrm/black = - mkS "pynrm/black" - , hsnrm/ormolu = - mkS "hsnrm/ormolu" - , hsnrm/hlint = - mkS "hsnrm/hlint" - , hsnrm/shellcheck = - mkS "hsnrm/shellcheck" - , hsnrm-/dhall-format = - mkS "hsnrm/dhall-format" +in { stages = [ "source", "build", "test", "deploy" ] + , nix/hsnrm-bin = mkNixB "haskellPackages.hsnrm-bin" + , nix/hsnrm = mkNixB "haskellPackages.hsnrm" + , nix/pynrm = mkNixB "pythonPackages.pynrm" + , nix/libnrm = mkNixB "libnrm" + , nix/stream = mkNixB "stream" + , notebooks = mkT "notebooks" + , tests/kvm = mkT "tests-kvm" + , tests/apps = mkT "app-tests" + , tests/rapl = mkT "tests-rapl" ⫽ { tags = [ "chimera" ] } + , tests/perf = mkT "tests-perf" ⫽ { tags = [ "chimera" ] } + , libnrm/autotools = mkB "libnrm/autotools" + , hsnrm/all = mkB "hsnrm/all" + , resources = mkS "resources" + , shellcheck = mkS "shellcheck" + , nixfmt = mkS "nixfmt" + , dhall-format = mkS "dhall-format" + , libnrm/clang-format = mkS "libnrm/clang-format" + , pynrm/black = mkS "pynrm/black" + , hsnrm/ormolu = mkS "hsnrm/ormolu" + , hsnrm/hlint = mkS "hsnrm/hlint" + , hsnrm/shellcheck = mkS "hsnrm/shellcheck" + , hsnrm-/dhall-format = mkS "hsnrm/dhall-format" , readthedocs = - { stage = - "deploy" - , tags = - tags - , only = - [ "master" ] + { stage = "deploy" + , tags = tags + , only = [ "master" ] , script = - [ "echo \"token=\$RTD_TOKEN\"" - , "nix run nixpkgs.curl -c curl --fail -X POST -d \"token=\$RTD_TOKEN\" readthedocs.org/api/v2/webhook/hnrm/104604/" - ] + [ "echo \"token=\$RTD_TOKEN\"" + , "nix run nixpkgs.curl -c curl --fail -X POST -d \"token=\$RTD_TOKEN\" readthedocs.org/api/v2/webhook/hnrm/104604/" + ] } } diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b701434b20ed08468312000ea763b9d753858515..7ee661f678d70af0c25be4e935594f8defb89e5d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,30 +23,12 @@ hsnrm/hlint: tags: - nix - kvm -hsnrm/hsnrm-bin/hsnrm-bin_cabal: - script: "nix-shell -p gnumake --run 'make hsnrm/hsnrm/hsnrm.cabal'" - stage: source - tags: - - nix - - kvm -hsnrm/hsnrm/hsnrm_cabal: - script: "nix-shell -p gnumake --run 'make hsnrm/hsnrm-bin/hsnrm-bin.cabal'" - stage: source - tags: - - nix - - kvm hsnrm/ormolu: script: "nix-shell -p gnumake --run 'make hsnrm/ormolu'" stage: source tags: - nix - kvm -hsnrm/resources: - script: "nix-shell -p gnumake --run 'make hsnrm/resources'" - stage: source - tags: - - nix - - kvm hsnrm/shellcheck: script: "nix-shell -p gnumake --run 'make hsnrm/shellcheck'" stage: source @@ -123,6 +105,12 @@ readthedocs: tags: - nix - kvm +resources: + script: "nix-shell -p gnumake --run 'make resources'" + stage: source + tags: + - nix + - kvm shellcheck: script: "nix-shell -p gnumake --run 'make shellcheck'" stage: source diff --git a/Makefile b/Makefile index 239f8193d128df911c7a473bb1913050096584ef..ef201169adf787d3d54c9de7be9c3b80af4e0c70 100644 --- a/Makefile +++ b/Makefile @@ -107,13 +107,24 @@ dhall-format: resource-propagation: pynrm/nrm/schemas/downstreamEvent.json\ libnrm/src/nrm_messaging.h -pynrm/nrm/schemas/downstreamEvent.json: hsnrm/resources - cp hsnrm/resources/downstreamEvent.json $@ - -libnrm/src/nrm_messaging.h: hsnrm/resources - cp hsnrm/resources/nrm_messaging.h $@ +pynrm/nrm/schemas/downstreamEvent.json: resources + cp resources/schemas/downstream.json $@ + +libnrm/src/nrm_messaging.h: resources + cp resources/nrm_messaging.h $@ + +resources: + @nix-shell --pure -E ' + let pkgs = import {}; + in with pkgs; haskellPackages.shellFor { + packages = p: [ haskellPackages.hsnrm haskellPackages.hsnrm-extra ]; + buildInputs = [ cabal-install ]; + } + ' --run bash <<< ' + cd hsnrm; cabal v2-run hsnrm-extra/Codegen.hs ../resources + ' -############################# SECTION: libnrm pseudo-recursive targets (actual directory uses autotools) +############################# SECTION: libnrm pseudo-recursive targets (directory uses autotools) libnrm/all: libnrm/autotools @@ -157,7 +168,7 @@ libnrm/clang-format: .PHONY: ci ci: - @nix-shell --pure -p yq jq --run bash <<< ' + @nix-shell -p yq jq --run bash <<< ' for jobname in $$(yq -r "keys| .[]" .gitlab-ci.yml); do if [ "$$jobname" != "stages" ]; then gitlab-runner exec shell "$$jobname" diff --git a/README.md b/README.md index b8fe11fc01d61b07cb4455560379b971977e5f27..4ac109e419e1f53737a5ae068b6cd05ed0a2804d 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,37 @@ git clone https://xgitlab.cels.anl.gov/argo/hnrm.git - local nix build: `nix-build -A nrm` - local nix profile install: `nix-env -f. -iA nrm` +## Usage + +### binaries +``` +#daemon +nrmd --help +#client +nrm --help +``` + +### `nrmd` configuration / `nrm` manifests +`nrmd` configurations and `nrm` manifests can use any of YAML, JSON or Dhall. +JSON schemas (raw) and Dhall types (documented with comments, for now) +are available. + +when using JSON/YAML, +- JSON schemas: `resources/schemas/{nrmd,manifest}.json` +- default values: `resources/defauts/{nrmd,manifest}.json` + +when using Dhall, +- types: `hsnrm/hsnrm/dhall/types/{nrmd,manifest}.dhall` +- default values: `hsnrm/hsnrm/dhall/defaults/{nrmd,manifest}.dhall` + +Example `nrmd` configurations and `nrm` manifests are available in the +`examples` folder in JSON,YAML and Dhall format. + +### APIs + +JSON schema files for upstream and downstream APIs are available. +- JSON/YAML schemas: `resources/schemas/{upstream-*,downstream}.json` + ## Development - building: `make` diff --git a/examples/manifests/libnrm.dhall b/examples/manifests/libnrm.dhall new file mode 100644 index 0000000000000000000000000000000000000000..2084a0405e916a3706a281dadda7be1ccee7b0ca --- /dev/null +++ b/examples/manifests/libnrm.dhall @@ -0,0 +1,11 @@ +let types = ../../hsnrm/hsnrm/dhall/types/manifest.dhall + +let default = ../../hsnrm/hsnrm/dhall/defaults/manifest.dhall + +in default + ⫽ { name = "libnrm-wrapped" + , app = + default.app + ⫽ { instrumentation = Some { ratelimit.hertz = 1000000.0 } } + } + : types.Manifest diff --git a/examples/manifests/libnrm.json b/examples/manifests/libnrm.json new file mode 100644 index 0000000000000000000000000000000000000000..a091bd7fe385fd6dd0f6ca229565a7a88d408a14 --- /dev/null +++ b/examples/manifests/libnrm.json @@ -0,0 +1,10 @@ +{ + "name": "libnrm-wrapped", + "app": { + "instrumentation": { + "ratelimit": { + "hertz": 1000000 + } + } + } +} diff --git a/examples/manifests/libnrm.yaml b/examples/manifests/libnrm.yaml new file mode 100644 index 0000000000000000000000000000000000000000..dfb45ad7e9ad9ade4d58c181519167ab71cb2812 --- /dev/null +++ b/examples/manifests/libnrm.yaml @@ -0,0 +1,5 @@ +name: libnrm-wrapped +app: + instrumentation: + ratelimit: + hertz: 1000000 diff --git a/examples/manifests/perfwrap.dhall b/examples/manifests/perfwrap.dhall new file mode 100644 index 0000000000000000000000000000000000000000..f451e5d76acce2f2807ec75dc827eb02f142546c --- /dev/null +++ b/examples/manifests/perfwrap.dhall @@ -0,0 +1,12 @@ +let types = ../../hsnrm/hsnrm/dhall/types/manifest.dhall + +let default = ../../hsnrm/hsnrm/dhall/defaults/manifest.dhall + +in default + ⫽ { name = "linuxperf-wrapped" + , app = + default.app + ⫽ { perfwrapper = Some { perfFreq.hertz = 1.0, perfLimit = +100000 } + } + } + : types.Manifest diff --git a/examples/manifests/perfwrap.json b/examples/manifests/perfwrap.json new file mode 100644 index 0000000000000000000000000000000000000000..1e53727a28173c9ef43ada114deaf1e34d72f1c7 --- /dev/null +++ b/examples/manifests/perfwrap.json @@ -0,0 +1,11 @@ +{ + "name": "linuxperf-wrapped", + "app": { + "perfwrapper": { + "perfFreq": { + "hertz": 1 + }, + "perfLimit": 100000 + } + } +} diff --git a/examples/manifests/perfwrap.yaml b/examples/manifests/perfwrap.yaml new file mode 100644 index 0000000000000000000000000000000000000000..0af028b9ec52a9046aa132d5460415b257796a5d --- /dev/null +++ b/examples/manifests/perfwrap.yaml @@ -0,0 +1,6 @@ +name: linuxperf-wrapped +app: + perfwrapper: + perfFreq: + hertz: 1 + perfLimit: 100000 diff --git a/examples/nrmd/control.dhall b/examples/nrmd/control.dhall new file mode 100644 index 0000000000000000000000000000000000000000..f5401256c2e82fa4cfaabc0d256a3f71296ea0b3 --- /dev/null +++ b/examples/nrmd/control.dhall @@ -0,0 +1,26 @@ +let types = ../../hsnrm/hsnrm/dhall/types/nrmd.dhall + +let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall + +let action1 = { microwatts = 1.0e8 } + +let action2 = { microwatts = 2.0e8 } + +in default + ⫽ { raplCfg = Some + { raplPath = "/sys/devices/virtual/powercap/intel-rapl" + , raplActions = [ action1, action2 ] + , referencePower.microwatts = 2.5e8 + } + , controlCfg = + types.ControlCfg.ControlCfg + { minimumControlInterval.microseconds = 100000.0 + , staticPower.microwatts = 2.0e8 + , learnCfg = types.LearnCfg.Contextual { horizon = +4000 } + , speedThreshold = 1.1 + , referenceMeasurementRoundInterval = +6 + , hint = types.Hint.Full + } + , activeSensorFrequency.hertz = 1.0 + } + : types.Cfg diff --git a/examples/nrmd/control.json b/examples/nrmd/control.json new file mode 100644 index 0000000000000000000000000000000000000000..613f43af91a040b0fa8d1cedfe8887e36410e4e6 --- /dev/null +++ b/examples/nrmd/control.json @@ -0,0 +1,33 @@ +{ + "activeSensorFrequency": { + "hertz": 1 + }, + "controlCfg": { + "hint": "Full", + "learnCfg": { + "horizon": 4000 + }, + "minimumControlInterval": { + "microseconds": 100000 + }, + "referenceMeasurementRoundInterval": 6, + "speedThreshold": 1.1, + "staticPower": { + "microwatts": 200000000 + } + }, + "raplCfg": { + "raplActions": [ + { + "microwatts": 100000000 + }, + { + "microwatts": 200000000 + } + ], + "raplPath": "/sys/devices/virtual/powercap/intel-rapl", + "referencePower": { + "microwatts": 250000000 + } + } +} diff --git a/examples/nrmd/control.yaml b/examples/nrmd/control.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4770cf23b7c277f7b187dfce8603ab2197ecbc93 --- /dev/null +++ b/examples/nrmd/control.yaml @@ -0,0 +1,19 @@ +activeSensorFrequency: + hertz: 1 +controlCfg: + hint: Full + learnCfg: + horizon: 4000 + minimumControlInterval: + microseconds: 100000 + referenceMeasurementRoundInterval: 6 + speedThreshold: 1.1 + staticPower: + microwatts: 200000000 +raplCfg: + raplActions: + - microwatts: 100000000 + - microwatts: 200000000 + raplPath: /sys/devices/virtual/powercap/intel-rapl + referencePower: + microwatts: 250000000 diff --git a/examples/nrmd/extra-static-actuator.dhall b/examples/nrmd/extra-static-actuator.dhall new file mode 100644 index 0000000000000000000000000000000000000000..5e49d37f585bc10592d170470ad7b77a5cbec072 --- /dev/null +++ b/examples/nrmd/extra-static-actuator.dhall @@ -0,0 +1,21 @@ +let types = ../../hsnrm/hsnrm/dhall/types/nrmd.dhall + +let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall + +in default + ⫽ { extraStaticActuators = + [ { staticActuatorKey = "example extra actuator ID" + , staticActuatorValue = + { actuatorBinary = "bash" + , actuatorArguments = + [ "-c" + , "echo \$@ >> /tmp/test-nrm-example-extra-actuator" + , "-o" + ] + , actions = [ 1.0, 2.0 ] + , referenceAction = 1.0 + } + } + ] + } + : types.Cfg diff --git a/examples/nrmd/extra-static-actuator.json b/examples/nrmd/extra-static-actuator.json new file mode 100644 index 0000000000000000000000000000000000000000..9ebb410a71ec71ccb9942362ca347b5b959c13e7 --- /dev/null +++ b/examples/nrmd/extra-static-actuator.json @@ -0,0 +1,20 @@ +{ + "extraStaticActuators": [ + { + "staticActuatorKey": "example extra actuator ID", + "staticActuatorValue": { + "actions": [ + 1, + 2 + ], + "actuatorArguments": [ + "-c", + "echo $@ >> /tmp/test-nrm-example-extra-actuator", + "-o" + ], + "actuatorBinary": "bash", + "referenceAction": 1 + } + } + ] +} diff --git a/examples/nrmd/extra-static-actuator.yaml b/examples/nrmd/extra-static-actuator.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7fa100a26a7ad34151b9d20a24bd8c3e66e20abe --- /dev/null +++ b/examples/nrmd/extra-static-actuator.yaml @@ -0,0 +1,12 @@ +extraStaticActuators: + - staticActuatorKey: "example extra actuator ID" + staticActuatorValue: + actions: + - 1 + - 2 + actuatorArguments: + - "-c" + - "echo $@ >> /tmp/test-nrm-example-extra-actuator" + - "-o" + actuatorBinary: bash + referenceAction: 1 diff --git a/examples/nrmd/extra-static-sensor.dhall b/examples/nrmd/extra-static-sensor.dhall new file mode 100644 index 0000000000000000000000000000000000000000..2a196751b55a12ba604dd3e44e4642f6feb577d4 --- /dev/null +++ b/examples/nrmd/extra-static-sensor.dhall @@ -0,0 +1,18 @@ +let types = ../../hsnrm/hsnrm/dhall/types/nrmd.dhall + +let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall + +in default + ⫽ { extraStaticPassiveSensors = + [ { passiveSensorKey = "example extra static passive power sensor" + , passiveSensorValue = + { sensorBinary = "echo" + , sensorArguments = [ "30" ] + , range = { lower = 1.0, upper = 40.0 } + , tags = [ types.Tag.TagPower ] + , sensorBehavior = types.SensorBehavior.IntervalBased + } + } + ] + } + : types.Cfg diff --git a/examples/nrmd/extra-static-sensor.json b/examples/nrmd/extra-static-sensor.json new file mode 100644 index 0000000000000000000000000000000000000000..4b7ea9cb3bf0b36c51299c6ae514d46976116dd3 --- /dev/null +++ b/examples/nrmd/extra-static-sensor.json @@ -0,0 +1,21 @@ +{ + "extraStaticPassiveSensors": [ + { + "passiveSensorKey": "example extra static passive power sensor", + "passiveSensorValue": { + "range": { + "lower": 1, + "upper": 40 + }, + "sensorArguments": [ + "30" + ], + "sensorBehavior": "IntervalBased", + "sensorBinary": "echo", + "tags": [ + "TagPower" + ] + } + } + ] +} diff --git a/examples/nrmd/extra-static-sensor.yaml b/examples/nrmd/extra-static-sensor.yaml new file mode 100644 index 0000000000000000000000000000000000000000..56dfdb4875167340d4087d695930aaad9db0c6fc --- /dev/null +++ b/examples/nrmd/extra-static-sensor.yaml @@ -0,0 +1,12 @@ +extraStaticPassiveSensors: + - passiveSensorKey: "example extra static passive power sensor" + passiveSensorValue: + range: + lower: 1 + upper: 40 + sensorArguments: + - "30" + sensorBehavior: IntervalBased + sensorBinary: echo + tags: + - TagPower diff --git a/examples/nrmd/variorum-two-package-power-limit-sensor.dhall b/examples/nrmd/variorum-two-package-power-limit-sensor.dhall new file mode 100644 index 0000000000000000000000000000000000000000..4de114ad9d459596501c014bf7912823201a5776 --- /dev/null +++ b/examples/nrmd/variorum-two-package-power-limit-sensor.dhall @@ -0,0 +1,35 @@ +let types = ../../hsnrm/hsnrm/dhall/types/nrmd.dhall + +let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall + +in default + ⫽ { extraStaticPassiveSensors = + [ { passiveSensorKey = + "Sensor that gets package power limits for package 0 through variorum" + , passiveSensorValue = + { sensorBinary = "bash" + , sensorArguments = + [ "-c" + , "variorum-print-power-limits-example | awk '{ if (\$1 == \"_PACKAGE_POWER_LIMITS\" && \$2 == \"0x610\" && \$4 == 0 ) { print \$6 } }'" + ] + , range = { lower = 1.0, upper = 40.0 } + , tags = [] : List types.Tag + , sensorBehavior = types.SensorBehavior.IntervalBased + } + } + , { passiveSensorKey = + "Sensor that gets package power limits for package 1 through variorum" + , passiveSensorValue = + { sensorBinary = "bash" + , sensorArguments = + [ "-c" + , "variorum-print-power-limits-example | awk '{ if (\$1 == \"_PACKAGE_POWER_LIMITS\" && \$2 == \"0x610\" && \$4 == 1 ) { print \$6 } }'" + ] + , range = { lower = 1.0, upper = 40.0 } + , tags = [] : List types.Tag + , sensorBehavior = types.SensorBehavior.IntervalBased + } + } + ] + } + : types.Cfg diff --git a/examples/nrmd/variorum-two-package-power-limit-sensor.json b/examples/nrmd/variorum-two-package-power-limit-sensor.json new file mode 100644 index 0000000000000000000000000000000000000000..728aab94e9ba9b47f73f8c0d26ffb2872c25e59e --- /dev/null +++ b/examples/nrmd/variorum-two-package-power-limit-sensor.json @@ -0,0 +1,36 @@ +{ + "extraStaticPassiveSensors": [ + { + "passiveSensorKey": "Sensor that gets package power limits for package 0 through variorum", + "passiveSensorValue": { + "range": { + "lower": 1, + "upper": 40 + }, + "sensorArguments": [ + "-c", + "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_POWER_LIMITS\" && $2 == \"0x610\" && $4 == 0 ) { print $6 } }'" + ], + "sensorBehavior": "IntervalBased", + "sensorBinary": "bash", + "tags": [] + } + }, + { + "passiveSensorKey": "Sensor that gets package power limits for package 1 through variorum", + "passiveSensorValue": { + "range": { + "lower": 1, + "upper": 40 + }, + "sensorArguments": [ + "-c", + "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_POWER_LIMITS\" && $2 == \"0x610\" && $4 == 1 ) { print $6 } }'" + ], + "sensorBehavior": "IntervalBased", + "sensorBinary": "bash", + "tags": [] + } + } + ] +} diff --git a/examples/nrmd/variorum-two-package-power-limit-sensor.yaml b/examples/nrmd/variorum-two-package-power-limit-sensor.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4bcb1df1cd13936edc557db5ec30041f2542b6f1 --- /dev/null +++ b/examples/nrmd/variorum-two-package-power-limit-sensor.yaml @@ -0,0 +1,23 @@ +extraStaticPassiveSensors: + - passiveSensorKey: "Sensor that gets package power limits for package 0 through variorum" + passiveSensorValue: + range: + lower: 1 + upper: 40 + sensorArguments: + - "-c" + - "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_POWER_LIMITS\" && $2 == \"0x610\" && $4 == 0 ) { print $6 } }'" + sensorBehavior: IntervalBased + sensorBinary: bash + tags: [] + - passiveSensorKey: "Sensor that gets package power limits for package 1 through variorum" + passiveSensorValue: + range: + lower: 1 + upper: 40 + sensorArguments: + - "-c" + - "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_POWER_LIMITS\" && $2 == \"0x610\" && $4 == 1 ) { print $6 } }'" + sensorBehavior: IntervalBased + sensorBinary: bash + tags: [] diff --git a/examples/nrmd/variorum-two-package-power-limits-actuator.dhall b/examples/nrmd/variorum-two-package-power-limits-actuator.dhall new file mode 100644 index 0000000000000000000000000000000000000000..170d03401b9fcde80b680c9a6234f4f08c1c6514 --- /dev/null +++ b/examples/nrmd/variorum-two-package-power-limits-actuator.dhall @@ -0,0 +1,17 @@ +let types = ../../hsnrm/hsnrm/dhall/types/nrmd.dhall + +let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall + +in default + ⫽ { extraStaticActuators = + [ { staticActuatorKey = "example extra actuator" + , staticActuatorValue = + { actuatorBinary = "variorum-set-socket-power-limits-example" + , actuatorArguments = [] : List Text + , actions = [ 100.0, 150.0 ] + , referenceAction = 100.0 + } + } + ] + } + : types.Cfg diff --git a/examples/nrmd/variorum-two-package-power-limits-actuator.json b/examples/nrmd/variorum-two-package-power-limits-actuator.json new file mode 100644 index 0000000000000000000000000000000000000000..aa55f91ad9bf806d7c03255b05548fcf69228a26 --- /dev/null +++ b/examples/nrmd/variorum-two-package-power-limits-actuator.json @@ -0,0 +1,16 @@ +{ + "extraStaticActuators": [ + { + "staticActuatorKey": "example extra actuator", + "staticActuatorValue": { + "actions": [ + 100, + 150 + ], + "actuatorArguments": [], + "actuatorBinary": "variorum-set-socket-power-limits-example", + "referenceAction": 100 + } + } + ] +} diff --git a/examples/nrmd/variorum-two-package-power-limits-actuator.yaml b/examples/nrmd/variorum-two-package-power-limits-actuator.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8718b1cb7dfb3688b560d1136c0fb72aa7c85eb0 --- /dev/null +++ b/examples/nrmd/variorum-two-package-power-limits-actuator.yaml @@ -0,0 +1,9 @@ +extraStaticActuators: + - staticActuatorKey: "example extra actuator" + staticActuatorValue: + actions: + - 100 + - 150 + actuatorArguments: [] + actuatorBinary: variorum-set-socket-power-limits-example + referenceAction: 100 diff --git a/examples/nrmd/variorum-two-package-power-value-sensor.dhall b/examples/nrmd/variorum-two-package-power-value-sensor.dhall new file mode 100644 index 0000000000000000000000000000000000000000..f6d5aa58cbed65fe6565451a0cb07029767c242b --- /dev/null +++ b/examples/nrmd/variorum-two-package-power-value-sensor.dhall @@ -0,0 +1,35 @@ +let types = ../../hsnrm/hsnrm/dhall/types/nrmd.dhall + +let default = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall + +in default + ⫽ { extraStaticPassiveSensors = + [ { passiveSensorKey = + "Sensor that gets package power limits for package 0 through variorum" + , passiveSensorValue = + { sensorBinary = "bash" + , sensorArguments = + [ "-c" + , "variorum-print-power-limits-example | awk '{ if (\$1 == \"_PACKAGE_ENERGY_STATUS\" && \$2 == \"0x610\" && \$4 == 0 ) { print \$6 } }'" + ] + , range = { lower = 1.0, upper = 40.0 } + , tags = [ types.Tag.TagPower ] + , sensorBehavior = types.SensorBehavior.Cumulative + } + } + , { passiveSensorKey = + "Sensor that gets package power limits for package 1 through variorum" + , passiveSensorValue = + { sensorBinary = "bash" + , sensorArguments = + [ "-c" + , "variorum-print-power-limits-example | awk '{ if (\$1 == \"_PACKAGE_ENERGY_STATUS\" && \$2 == \"0x610\" && \$4 == 1 ) { print \$6 } }'" + ] + , range = { lower = 1.0, upper = 40.0 } + , tags = [ types.Tag.TagPower ] + , sensorBehavior = types.SensorBehavior.Cumulative + } + } + ] + } + : types.Cfg diff --git a/examples/nrmd/variorum-two-package-power-value-sensor.json b/examples/nrmd/variorum-two-package-power-value-sensor.json new file mode 100644 index 0000000000000000000000000000000000000000..82f452c515b13974d02011cba8968e597fe7ba99 --- /dev/null +++ b/examples/nrmd/variorum-two-package-power-value-sensor.json @@ -0,0 +1,40 @@ +{ + "extraStaticPassiveSensors": [ + { + "passiveSensorKey": "Sensor that gets package power limits for package 0 through variorum", + "passiveSensorValue": { + "range": { + "lower": 1, + "upper": 40 + }, + "sensorArguments": [ + "-c", + "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_ENERGY_STATUS\" && $2 == \"0x610\" && $4 == 0 ) { print $6 } }'" + ], + "sensorBehavior": "Cumulative", + "sensorBinary": "bash", + "tags": [ + "TagPower" + ] + } + }, + { + "passiveSensorKey": "Sensor that gets package power limits for package 1 through variorum", + "passiveSensorValue": { + "range": { + "lower": 1, + "upper": 40 + }, + "sensorArguments": [ + "-c", + "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_ENERGY_STATUS\" && $2 == \"0x610\" && $4 == 1 ) { print $6 } }'" + ], + "sensorBehavior": "Cumulative", + "sensorBinary": "bash", + "tags": [ + "TagPower" + ] + } + } + ] +} diff --git a/examples/nrmd/variorum-two-package-power-value-sensor.yaml b/examples/nrmd/variorum-two-package-power-value-sensor.yaml new file mode 100644 index 0000000000000000000000000000000000000000..098972f27c47eca895f46c344c828a4adb3b1ae6 --- /dev/null +++ b/examples/nrmd/variorum-two-package-power-value-sensor.yaml @@ -0,0 +1,25 @@ +extraStaticPassiveSensors: + - passiveSensorKey: "Sensor that gets package power limits for package 0 through variorum" + passiveSensorValue: + range: + lower: 1 + upper: 40 + sensorArguments: + - "-c" + - "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_ENERGY_STATUS\" && $2 == \"0x610\" && $4 == 0 ) { print $6 } }'" + sensorBehavior: Cumulative + sensorBinary: bash + tags: + - TagPower + - passiveSensorKey: "Sensor that gets package power limits for package 1 through variorum" + passiveSensorValue: + range: + lower: 1 + upper: 40 + sensorArguments: + - "-c" + - "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_ENERGY_STATUS\" && $2 == \"0x610\" && $4 == 1 ) { print $6 } }'" + sensorBehavior: Cumulative + sensorBinary: bash + tags: + - TagPower diff --git a/hsnrm/.hlint.yaml b/hsnrm/.hlint.yaml index b33c80695aab891a80774a90dd2c766aa3d8b595..9309133b6feee3078f4649a1520abaebc86f57b1 100644 --- a/hsnrm/.hlint.yaml +++ b/hsnrm/.hlint.yaml @@ -11,6 +11,7 @@ - name: [ScopedTypeVariables] - name: [NoRecordWildCards] - name: [TypeApplications] + - name: [TemplateHaskell] - flags: - default: false diff --git a/hsnrm/Makefile b/hsnrm/Makefile index 2aa0699d07683628d4be55bf49464ccde30321ac..bdea688f6b7a1a5d8ca8ceb409a21dc88d44ff67 100644 --- a/hsnrm/Makefile +++ b/hsnrm/Makefile @@ -11,28 +11,7 @@ SHELL := $(shell which bash) # https://github.com/NixOS/nix/issues/726#issuecomment-161215255 NIX_PATH := nixpkgs=./. -all: bin/nrm bin/nrm.so bin/pynrm.so resources - -dhall-to-cabal: ../default.nix - rm -rf ./dhall-to-cabal - echo $$(nix-build -A dhall-to-cabal-resources --no-out-link) - cp -r $$(nix-build -A dhall-to-cabal-resources --no-out-link) ./dhall-to-cabal - chmod -R +rw ./dhall-to-cabal - -%.cabal: %.dhall common.dhall dhall-to-cabal - @nix-shell --pure -E ' - with import {}; - mkShell { - buildInputs = [ dhall-to-cabal haskellPackages.ghc ]; - LOCALE_ARCHIVE="$${pkgs.glibcLocales}/lib/locale/locale-archive"; - LANG="en_US.UTF-8"; - GHCDIR="$${haskellPackages.ghc}"; - } - ' --run bash <<< ' - GHCVERSION=$$(ghc --numeric-version) - echo injecting ghc version $$GHCVERSION and ghc directory $$GHCDIR in cabal file. - dhall-to-cabal --output-stdout <<< "./$*.dhall \"$$GHCDIR\" \"$$GHCVERSION\"" > $@ - ' +all: bin/nrm bin/nrm.so bin/pynrm.so .PHONY: bin/nrm bin/nrm.so bin/nrm: hsnrm-extra/hsnrm-extra.cabal hsnrm-static/hsnrm-static.cabal hsnrm-bin/hsnrm-bin.cabal hsnrm/hsnrm.cabal @@ -46,20 +25,6 @@ bin/pynrm.so: hsnrm-extra/hsnrm-extra.cabal hsnrm-static/hsnrm-static.cabal hsnr cabal v2-install hsnrm-extra --installdir=./bin --overwrite-policy=always ' -resources: hsnrm/* hsnrm-bin/* - @nix-shell --pure -E ' - let pkgs = import {}; - in with pkgs; haskellPackages.shellFor { - packages = p: [ haskellPackages.hsnrm haskellPackages.hsnrm-extra ]; - buildInputs = [ cabal-install ]; - } - ' --run bash <<< ' - rm -rf resources - mkdir resources - cabal v2-run hsnrm-extra/Codegen.hs resources/ - cp resources/downstreamEvent.json ../pynrm/nrm/schemas/ - ' - .PHONY: ghcid ghcid: ghcid-hsnrm @@ -69,7 +34,7 @@ ghcid-%: .hlint.yaml %/*.cabal -l .PHONY: pre-commit -pre-commit: hsnrm/hsnrm.cabal hsnrm-static/hsnrm-static.cabal hsnrm-bin/hsnrm-bin.cabal resources dhall-format ormolu shellcheck hlint +pre-commit: hsnrm/hsnrm.cabal hsnrm-static/hsnrm-static.cabal hsnrm-bin/hsnrm-bin.cabal dhall-format ormolu shellcheck hlint .PHONY: dhall-format dhall-format: @@ -127,7 +92,6 @@ hlint: .PHONY:clean clean: rm -rf dist-newstyle - rm -rf resources rm -f hsnrm.cabal rm -f hsnrm.nix rm -f a.out diff --git a/hsnrm/common.dhall b/hsnrm/common.dhall deleted file mode 100644 index 6b97f5cbf6290832c39b3a9869c757bb1c83846d..0000000000000000000000000000000000000000 --- a/hsnrm/common.dhall +++ /dev/null @@ -1,332 +0,0 @@ -let prelude = ./dhall-to-cabal/prelude.dhall - -let types = ./dhall-to-cabal/types.dhall - -let defexts = - [ types.Extension.LambdaCase True - , types.Extension.QuasiQuotes True - , types.Extension.DefaultSignatures True - , types.Extension.OverloadedLists True - , types.Extension.ExistentialQuantification True - , types.Extension.RecordWildCards True - , types.Extension.RankNTypes True - , types.Extension.TypeSynonymInstances True - , types.Extension.StandaloneDeriving True - , types.Extension.NamedFieldPuns True - , types.Extension.FlexibleInstances True - , types.Extension.TupleSections True - , types.Extension.ScopedTypeVariables True - , types.Extension.MultiParamTypeClasses True - , types.Extension.ImplicitPrelude False - , types.Extension.OverloadedStrings True - , types.Extension.ViewPatterns True - , types.Extension.PatternSynonyms True - , types.Extension.DeriveFunctor True - , types.Extension.DeriveTraversable True - , types.Extension.TypeFamilies True - , types.Extension.DeriveAnyClass True - , types.Extension.DeriveGeneric True - , types.Extension.DeriveDataTypeable True - , types.Extension.OverloadedLabels True - , types.Extension.DeriveFoldable True - , types.Extension.DerivingStrategies True - , types.Extension.TypeApplications True - , types.Extension.MultiWayIf True - , types.Extension.TemplateHaskell False - , types.Extension.BlockArguments True - , types.Extension.GADTs True - , types.Extension.FlexibleContexts True - , types.Extension.TypeOperators True - , types.Extension.DataKinds True - , types.Extension.PolyKinds True - , types.Extension.AllowAmbiguousTypes True - , types.Extension.FunctionalDependencies True - , types.Extension.UndecidableInstances True - ] - -let deflang = Some types.Language.Haskell2010 - -let defcopts = - λ(addcopts : List Text) - → prelude.defaults.CompilerOptions - ⫽ { GHC = - [ "-Wall" - , "-O0" - , "-Wcompat" - , "-Wincomplete-uni-patterns" - , "-Wmissing-home-modules" - , "-Widentities" - , "-Wredundant-constraints" - , "-Wcpp-undef" - , "-fwarn-tabs" - , "-fwarn-unused-imports" - , "-fwarn-missing-signatures" - , "-fwarn-name-shadowing" - , "-fprint-potential-instances" - , "-Wmissing-export-lists" - , "-fwarn-unused-do-bind" - , "-fwarn-wrong-do-bind" - , "-fwarn-incomplete-patterns" - , "-Wincomplete-record-updates" - , "-Wmonomorphism-restriction" - , "-Wimplicit-prelude" - , "-Wmissing-local-signatures" - , "-Wmissing-exported-signatures" - , "-Wmissing-export-lists" - , "-Wmissing-home-modules" - , "-Widentities" - , "-Wredundant-constraints" - , "-Wpartial-fields" - ] - # addcopts - : List Text - } - -let copts = - λ(addcopts : List Text) - → { compiler-options = defcopts addcopts - , default-extensions = defexts - , default-language = deflang - } - -let nobound = λ(p : Text) → { bounds = prelude.anyVersion, package = p } - -let deps = - { base = nobound "base" - , hbandit = nobound "hbandit" - , iso-deriving = nobound "iso-deriving" - , pretty-simple = nobound "pretty-simple" - , protolude = nobound "protolude" - , tasty = nobound "tasty" - , tasty-hunit = nobound "tasty-hunit" - , tasty-discover = nobound "tasty-discover" - , Chart = nobound "Chart" - , Chart-cairo = nobound "Chart-cairo" - , gtk3 = nobound "gtk3" - , cereal = nobound "cereal" - , tree-view = nobound "tree-view" - , dynamic-graph = nobound "dynamic-graph" - , colour = nobound "colour" - , transformers = nobound "transformers" - , glib = nobound "glib" - , opengl = nobound "OpenGL" - , scientific = nobound "scientific" - , generic-deriving = nobound "generic-deriving" - , typed-process = nobound "typed-process" - , optparse-applicative = nobound "optparse-applicative" - , aeson-pretty = nobound "aeson-pretty" - , random = nobound "random" - , pipes = nobound "pipes" - , either = nobound "either" - , transformers-either = nobound "transformers-either" - , intervals = nobound "intervals" - , hxt = nobound "hxt" - , hxt-xpath = nobound "hxt-xpath" - , recursion-schemes = nobound "recursion-schemes" - , binary = nobound "binary" - , refined = nobound "refined" - , generic-data = nobound "generic-data" - , filepath = nobound "filepath" - , neat-interpolation = nobound "neat-interpolation" - , generic-lens = nobound "generic-lens" - , yaml = nobound "yaml" - , plot-ho-matic = nobound "Plot-ho-matic" - , aeson = nobound "aeson" - , hsnrm-lib = nobound "hsnrm-lib" - , monadRandom = nobound "MonadRandom" - , directory = nobound "directory" - , regex = nobound "regex" - , units-defs = nobound "units-defs" - , mtl-compat = nobound "mtl-compat" - , units = nobound "units" - , data-default = nobound "data-default" - , flat = nobound "flat" - , unix = nobound "unix" - , prettyprinter = nobound "prettyprinter" - , containers = nobound "containers" - , unordered-containers = nobound "unordered-containers" - , zeromq4-conduit = nobound "zeromq4-conduit" - , zeromq4-haskell = nobound "zeromq4-haskell" - , uuid = nobound "uuid" - , text = nobound "text" - , dhall = nobound "dhall" - , bytestring = nobound "bytestring" - , data-msgpack = nobound "data-msgpack" - , enclosed-exceptions = nobound "enclosed-exceptions" - , storable-endian = nobound "storable-endian" - , template-haskell = nobound "template-haskell" - , vcs-revision = nobound "vcs-revision" - , resourcet = nobound "resourcet" - , async = nobound "async" - , dhall-json = nobound "dhall-json" - , lens = nobound "lens" - , mtl = nobound "mtl" - , conduit = nobound "conduit" - , brick = nobound "brick" - , aeson-extra = nobound "aeson-extra" - , conduit-extra = nobound "conduit-extra" - , generic-aeson = nobound "generic-aeson" - , vector = nobound "vector" - , json-schema = nobound "json-schema" - , megaparsec = nobound "megaparsec" - } - -let modules = - [ "NRM.Slices" - , "NRM.Slices.Class" - , "NRM.Slices.Nodeos" - , "NRM.Slices.Singularity" - , "NRM.Slices.Dummy" - , "NRM.Node.Hwloc" - , "NRM.Node.Sysfs" - , "NRM.Control" - , "NRM.Codegen" - , "NRM.Export" - , "NRM.ExportIO" - , "NRM.Client" - , "NRM.Daemon" - , "NRM.CPD" - , "NRM.Optparse" - , "NRM.Behavior" - , "NRM.Version" - , "NRM.Sensors" - , "NRM.Actuators" - , "NRM.Messaging" - , "NRM.Processes" - , "NRM.State" - , "NRM.Node.Sysfs.Internal" - , "NRM.Optparse.Client" - , "NRM.Optparse.Daemon" - , "NRM.Types.Topology" - , "NRM.Types.Topology.Package" - , "NRM.Types.Topology.Core" - , "NRM.Types.Topology.PU" - , "NRM.Types.Topology.PackageID" - , "NRM.Types.Topology.CoreID" - , "NRM.Types.Topology.PUID" - , "NRM.Types.Units" - , "NRM.Types.Controller" - , "NRM.Types.Actuator" - , "NRM.Types.Sensor" - , "NRM.Types.Behavior" - , "NRM.Types.Slice" - , "NRM.Types.Cmd" - , "NRM.Types.CmdID" - , "NRM.Types.NRM" - , "NRM.Types.Process" - , "NRM.Types.DownstreamThread" - , "NRM.Types.DownstreamThreadID" - , "NRM.Types.DownstreamCmd" - , "NRM.Types.DownstreamCmdID" - , "NRM.Types.State" - , "NRM.Types.MemBuffer" - , "NRM.Types.UpstreamClient" - , "NRM.Types.DownstreamClient" - , "NRM.Classes.Messaging" - , "NRM.Classes.Sensors" - , "NRM.Classes.Actuators" - , "NRM.Classes.Topology" - , "NRM.Orphans.ExitCode" - , "NRM.Orphans.UUID" - , "NRM.Orphans.Dhall" - , "NRM.Orphans.NonEmpty" - , "NRM.Orphans.ZeroOne" - , "NRM.Orphans.Refined" - , "NRM.Types.Messaging.DownstreamEvent" - , "NRM.Types.Messaging.UpstreamPub" - , "NRM.Types.Messaging.UpstreamReq" - , "NRM.Types.Messaging.UpstreamRep" - , "NRM.Types.Messaging.Protocols" - , "NRM.Types.Configuration" - , "NRM.Types.Manifest" - ] - -let extramodules = - [ "FFI.TypeUncurry" - , "FFI.TypeUncurry.Msgpack" - , "FFI.TypeUncurry.DataKinds" - , "Codegen.Schema" - , "Codegen.Dhall" - , "Codegen.CHeader" - , "LensMap.Core" - , "CPD.Core" - , "CPD.Integrated" - , "CPD.Values" - , "CPD.Utils" - , "CPD.Text" - ] - -let allmodules = modules # extramodules - -let libdep = - [ deps.base - , deps.hbandit - , deps.either - , deps.protolude - , deps.scientific - , deps.megaparsec - , deps.enclosed-exceptions - , deps.monadRandom - , deps.mtl-compat - , deps.vcs-revision - , deps.transformers - , deps.generic-data - , deps.bytestring - , deps.iso-deriving - , deps.random - , deps.prettyprinter - , deps.zeromq4-haskell - , deps.zeromq4-conduit - , deps.generic-lens - , deps.data-msgpack - , deps.containers - , deps.binary - , deps.unordered-containers - , deps.mtl - , deps.aeson - , deps.dhall - , deps.dhall-json - , deps.conduit - , deps.conduit-extra - , deps.aeson-extra - , deps.resourcet - , deps.intervals - , deps.neat-interpolation - , deps.generic-aeson - , deps.aeson-pretty - , deps.pretty-simple - , deps.typed-process - , deps.hxt - , deps.recursion-schemes - , deps.hxt-xpath - , deps.json-schema - , deps.yaml - , deps.data-default - , deps.flat - , deps.refined - , deps.vector - , deps.optparse-applicative - , deps.directory - , deps.regex - , deps.units - , deps.unix - , deps.generic-deriving - , deps.uuid - , deps.async - , deps.text - , deps.units-defs - , deps.storable-endian - , deps.template-haskell - , deps.mtl - , deps.brick - , deps.filepath - , deps.lens - ] - -in { defexts = defexts - , deps = deps - , libdep = libdep - , allmodules = allmodules - , copts = copts - , nobound = nobound - } diff --git a/hsnrm/hsnrm-bin/hsnrm-bin.cabal b/hsnrm/hsnrm-bin/hsnrm-bin.cabal index c5f6b7080d9625b32d69c8839b8b2816e7e28e60..cf1d255b5e328bfe3437a57bb82bdc2aa9a2c863 100644 --- a/hsnrm/hsnrm-bin/hsnrm-bin.cabal +++ b/hsnrm/hsnrm-bin/hsnrm-bin.cabal @@ -1,13 +1,4 @@ cabal-version: 2.0 --- * * * * * * * * * * * * WARNING * * * * * * * * * * * * --- This file has been AUTO-GENERATED by dhall-to-cabal. --- --- Do not edit it by hand, because your changes will be over-written! --- --- Instead, edit the source Dhall file (which may have the --- '.dhall' extension) and re-run dhall-to-cabal, passing --- the source file's name as its argument. --- * * * * * * * * * * * * WARNING * * * * * * * * * * * * name: hsnrm-bin version: 1.0.0 license: BSD3 diff --git a/hsnrm/hsnrm-bin/hsnrm-bin.dhall b/hsnrm/hsnrm-bin/hsnrm-bin.dhall deleted file mode 100644 index f61a9328e322d39c7303f21061fb841e62022ddf..0000000000000000000000000000000000000000 --- a/hsnrm/hsnrm-bin/hsnrm-bin.dhall +++ /dev/null @@ -1,64 +0,0 @@ -let prelude = ../dhall-to-cabal/prelude.dhall - -let types = ../dhall-to-cabal/types.dhall - -let common = ../common.dhall - -in λ(ghcPath : Text) - → λ(ghcNumericVersion : Text) - → prelude.defaults.Package - ⫽ { name = "hsnrm-bin" - , version = prelude.v "1.0.0" - , author = "Valentin Reis" - , build-type = Some types.BuildType.Simple - , cabal-version = prelude.v "2.0" - , category = "tools" - , description = - "The Node Resource Manager(NRM) is a linux daemon that enables dynamic resource optimization for improving the power/performance tradeoff of HPC applications." - , executables = - [ { executable = - λ(config : types.Config) - → prelude.defaults.Executable - ⫽ { main-is = "Export.hs" - , build-depends = - [ common.nobound "hsnrm" - , common.deps.base - , common.deps.protolude - , common.deps.enclosed-exceptions - ] - , extra-lib-dirs = - [ ghcPath ++ "/lib/ghc-" ++ ghcNumericVersion ++ "/rts/" ] - } - ⫽ common.copts - [ "-Wmissed-specialisations" - , "-Wall-missed-specialisations" - , "-fPIC" - , "-shared" - , "-no-hs-main" - , "-dynamic" - , "-lHSrts-ghc" ++ ghcNumericVersion - ] - , name = "nrm.so" - } - , { executable = - λ(config : types.Config) - → prelude.defaults.Executable - ⫽ { main-is = "Hnrm.hs" - , build-depends = [ common.nobound "hsnrm" ] - } - ⫽ common.copts [ "-main-is", "Hnrm" ] - , name = "nrm" - } - ] - , extra-source-files = [] : List Text - , license = types.License.BSD3 - , license-files = [] : List Text - , maintainer = "fre@freux.fr" - , source-repos = - [ prelude.defaults.SourceRepo - ⫽ { type = Some types.RepoType.Git - , location = Some "https://xgitlab.cels.anl.gov/vreis/hsnrm.git" - } - ] - , synopsis = "hsnrm" - } diff --git a/hsnrm/hsnrm-extra/hsnrm-extra.cabal b/hsnrm/hsnrm-extra/hsnrm-extra.cabal index 1ccbd2505108887a7dfc4c89d1e095b45c18a6b5..b7abf3a3effa39e575052c76ec70e4353337fd56 100644 --- a/hsnrm/hsnrm-extra/hsnrm-extra.cabal +++ b/hsnrm/hsnrm-extra/hsnrm-extra.cabal @@ -1,13 +1,4 @@ cabal-version: 2.0 --- * * * * * * * * * * * * WARNING * * * * * * * * * * * * --- This file has been AUTO-GENERATED by dhall-to-cabal. --- --- Do not edit it by hand, because your changes will be over-written! --- --- Instead, edit the source Dhall file (which may have the --- '.dhall' extension) and re-run dhall-to-cabal, passing --- the source file's name as its argument. --- * * * * * * * * * * * * WARNING * * * * * * * * * * * * name: hsnrm-extra version: 1.0.0 license: BSD3 diff --git a/hsnrm/hsnrm-extra/hsnrm-extra.dhall b/hsnrm/hsnrm-extra/hsnrm-extra.dhall deleted file mode 100644 index deec74f5b445111dc7ac92efc5eb3a06eb53baad..0000000000000000000000000000000000000000 --- a/hsnrm/hsnrm-extra/hsnrm-extra.dhall +++ /dev/null @@ -1,60 +0,0 @@ -let prelude = ../dhall-to-cabal/prelude.dhall - -let types = ../dhall-to-cabal/types.dhall - -let common = ../common.dhall - -in λ(ghcPath : Text) - → λ(ghcNumericVersion : Text) - → prelude.defaults.Package - ⫽ { name = "hsnrm-extra" - , version = prelude.v "1.0.0" - , author = "Valentin Reis" - , build-type = Some types.BuildType.Simple - , cabal-version = prelude.v "2.0" - , category = "tools" - , description = "hsnrm utilities" - , executables = - [ { executable = - λ(config : types.Config) - → prelude.defaults.Executable - ⫽ { main-is = "PyExport.hs" - , build-depends = - [ common.nobound "hsnrm" - , common.deps.base - , common.deps.protolude - , common.deps.containers - , common.deps.aeson - , common.deps.zeromq4-haskell - , common.deps.pretty-simple - , common.deps.data-default - , common.deps.bytestring - , common.deps.enclosed-exceptions - ] - , extra-lib-dirs = - [ ghcPath ++ "/lib/ghc-" ++ ghcNumericVersion ++ "/rts/" ] - } - ⫽ common.copts - [ "-Wmissed-specialisations" - , "-Wall-missed-specialisations" - , "-fPIC" - , "-shared" - , "-no-hs-main" - , "-dynamic" - , "-lHSrts-ghc" ++ ghcNumericVersion - ] - , name = "pynrm.so" - } - ] - , extra-source-files = [] : List Text - , license = types.License.BSD3 - , license-files = [] : List Text - , maintainer = "fre@freux.fr" - , source-repos = - [ prelude.defaults.SourceRepo - ⫽ { type = Some types.RepoType.Git - , location = Some "https://xgitlab.cels.anl.gov/vreis/hsnrm.git" - } - ] - , synopsis = "hsnrm-extra" - } diff --git a/hsnrm/hsnrm-static/hsnrm-static.cabal b/hsnrm/hsnrm-static/hsnrm-static.cabal index abeb6e7f48a8f52eda0f8f20bd4811f9d49ee04f..500ca7a4e91a0d4cded0b3d85402beb5959d9b06 100644 --- a/hsnrm/hsnrm-static/hsnrm-static.cabal +++ b/hsnrm/hsnrm-static/hsnrm-static.cabal @@ -1,13 +1,4 @@ cabal-version: 2.0 --- * * * * * * * * * * * * WARNING * * * * * * * * * * * * --- This file has been AUTO-GENERATED by dhall-to-cabal. --- --- Do not edit it by hand, because your changes will be over-written! --- --- Instead, edit the source Dhall file (which may have the --- '.dhall' extension) and re-run dhall-to-cabal, passing --- the source file's name as its argument. --- * * * * * * * * * * * * WARNING * * * * * * * * * * * * name: hsnrm version: 1.0.0 license: BSD3 diff --git a/hsnrm/hsnrm-static/hsnrm-static.dhall b/hsnrm/hsnrm-static/hsnrm-static.dhall deleted file mode 100644 index f60ea742c5d9a160d7eba24cba85e6e98c122e70..0000000000000000000000000000000000000000 --- a/hsnrm/hsnrm-static/hsnrm-static.dhall +++ /dev/null @@ -1,29 +0,0 @@ -let prelude = ../dhall-to-cabal/prelude.dhall - -let types = ../dhall-to-cabal/types.dhall - -let common = ../common.dhall - -in λ(ghcPath : Text) - → λ(ghcNumericVersion : Text) - → prelude.defaults.Package - ⫽ { name = "hsnrm" - , version = prelude.v "1.0.0" - , author = "Valentin Reis" - , build-type = Some types.BuildType.Simple - , cabal-version = prelude.v "2.0" - , category = "tools" - , description = - "The Node Resource Manager(NRM) is a linux daemon that enables dynamic resource optimization for improving the power/performance tradeoff of HPC applications." - , extra-source-files = [] : List Text - , license = types.License.BSD3 - , license-files = [] : List Text - , maintainer = "fre@freux.fr" - , source-repos = - [ prelude.defaults.SourceRepo - ⫽ { type = Some types.RepoType.Git - , location = Some "https://xgitlab.cels.anl.gov/vreis/hsnrm.git" - } - ] - , synopsis = "hsnrm" - } diff --git a/hsnrm/hsnrm/dhall/defaults/manifest.dhall b/hsnrm/hsnrm/dhall/defaults/manifest.dhall new file mode 100644 index 0000000000000000000000000000000000000000..49b18ba978a832dcacf8bfe2934248ad4dc71dbe --- /dev/null +++ b/hsnrm/hsnrm/dhall/defaults/manifest.dhall @@ -0,0 +1,29 @@ +-- ****************************************************************************** +-- Copyright 2019 UChicago Argonne, LLC. +-- (c.f. AUTHORS, LICENSE) +-- +-- SPDX-License-Identifier: BSD-3-Clause +-- ****************************************************************************** + +let t = ../types/manifest.dhall + +in { name = "default" + , app = + { slice = { cpus = +1, mems = +1 } + , scheduler = t.Scheduler.FIFO + , perfwrapper = None t.Perfwrapper + , powerCfg = + { policy = < NoPowerPolicy | DDCM | DVFS | Combined >.NoPowerPolicy + , profile = False + , slowdown = +1 + } + , instrumentation = None t.Instrumentation + } + , hwbind = False + , image = + None + { path : Text + , imagetype : < Sif | Docker > + , binds : Optional (List Text) + } + } diff --git a/hsnrm/hsnrm/dhall/defaults/nrmd.dhall b/hsnrm/hsnrm/dhall/defaults/nrmd.dhall new file mode 100644 index 0000000000000000000000000000000000000000..115395fcc45d192432903266354d2d3b375b83ec --- /dev/null +++ b/hsnrm/hsnrm/dhall/defaults/nrmd.dhall @@ -0,0 +1,28 @@ +let t = ../types/nrmd.dhall + +in { verbose = t.Verbosity.Error + , logfile = "/tmp/nrm.log" + , hwloc = "hwloc" + , perf = "perf" + , argo_perf_wrapper = "nrm-perfwrapper" + , argo_nodeos_config = "argo_nodeos_config" + , libnrmPath = None Text + , pmpi_lib = "pmpi_lib" + , singularity = False + , dummy = True + , nodeos = False + , downstreamCfg.downstreamBindAddress = "ipc:///tmp/nrm-downstream-event" + , upstreamCfg = + { upstreamBindAddress = "*", pubPort = +2345, rpcPort = +3456 } + , raplCfg = Some + { raplPath = "/sys/devices/virtual/powercap/intel-rapl" + , raplActions = [ { microwatts = 1.0e8 }, { microwatts = 2.0e8 } ] + , referencePower.microwatts = 2.5e8 + } + , hwmonCfg = { hwmonEnabled = True, hwmonPath = "/sys/class/hwmon" } + , controlCfg = t.ControlCfg.ControlOff + , activeSensorFrequency.hertz = 1.0 + , extraStaticPassiveSensors = [] : List t.PassiveSensorKV + , extraStaticActuators = [] : List t.StaticActuatorKV + } + : t.Cfg diff --git a/hsnrm/hsnrm/dhall/types/manifest.dhall b/hsnrm/hsnrm/dhall/types/manifest.dhall new file mode 100644 index 0000000000000000000000000000000000000000..eac3d56b0e585e0ad3ec64027dea8feed43456a2 --- /dev/null +++ b/hsnrm/hsnrm/dhall/types/manifest.dhall @@ -0,0 +1,66 @@ +-- ****************************************************************************** +-- Copyright 2019 UChicago Argonne, LLC. +-- (c.f. AUTHORS, LICENSE) +-- +-- SPDX-License-Identifier: BSD-3-Clause +-- ****************************************************************************** +let types = ./types.dhall + +let Scheduler = + -- This type was imported from NRM1: feature not present (yet) + < FIFO | HPC | Other : Integer > + +let Perfwrapper = + -- Configuration for linux perf performance measurements. + { perfFreq : types.Frequency, perfLimit : Integer } + +let ImageType = + -- This type was imported from NRM1: feature not present (yet) + < Sif | Docker > + +let Image = + -- This type was imported from NRM1: feature not present (yet) + { path : Text, imagetype : ImageType, binds : Optional (List Text) } + +let PowerPolicy = + -- This type was imported from NRM1: feature not present (yet) + < NoPowerPolicy | DDCM | DVFS | Combined > + +let Slice = + -- This type was imported from NRM1: feature not present (yet) + { cpus : Integer, mems : Integer } + +let PowerCfg = + -- This type was imported from NRM1: feature not present (yet) + { policy : PowerPolicy, profile : Bool, slowdown : Integer } + +let Instrumentation = + -- Message rate limitation for libnrm instrumentation. + { ratelimit : types.Frequency } + +let App -- Application configuration + = + { slice : Slice + , scheduler : Scheduler + , perfwrapper : Optional Perfwrapper + , powerCfg : PowerCfg + , instrumentation : Optional Instrumentation + } + +let Manifest = + -- A manifest has a name, an application configuration. + -- placeholders field from NRM1: hwbind, image + { name : Text, app : App, hwbind : Bool, image : Optional Image } + +in types + ⫽ { Scheduler = Scheduler + , Perfwrapper = Perfwrapper + , Image = Image + , ImageType = ImageType + , PowerPolicy = PowerPolicy + , Slice = Slice + , PowerCfg = PowerCfg + , Instrumentation = Instrumentation + , App = App + , Manifest = Manifest + } diff --git a/hsnrm/hsnrm/dhall/types/nrmd.dhall b/hsnrm/hsnrm/dhall/types/nrmd.dhall new file mode 100644 index 0000000000000000000000000000000000000000..31f7252b916000f0926f98611bd8b64a97d6b2ae --- /dev/null +++ b/hsnrm/hsnrm/dhall/types/nrmd.dhall @@ -0,0 +1,159 @@ +-- ****************************************************************************** +-- Copyright 2019 UChicago Argonne, LLC. +-- (c.f. AUTHORS, LICENSE) +-- +-- SPDX-License-Identifier: BSD-3-Clause +-- ****************************************************************************** +-- +-- types used by nrmd's configuration. +-- +-- +let types = ./types.dhall + +let Verbosity = + -- Daemon verbosity: + -- Error: Only report errors + -- Info: Be verbose + -- Debug: Report all that can possibly be reported + < Error | Info | Debug > + +let SensorBehavior = + -- Sensor Behavior. + < Cumulative | IntervalBased | CumulativeWithCapacity : Double > + +let Range = + -- An inclusive range of values + { lower : Double, upper : Double } + +let DownstreamCfg = + -- Configuration for the dowstream API + { downstreamBindAddress : Text } + +let UpstreamCfg = + -- Configuration for the upstream API + { upstreamBindAddress : Text, pubPort : Integer, rpcPort : Integer } + +let Tag = + -- Available tags for describing sensors. Tags are used for setting + -- objective functions up. + < TagPower + | Rapl + | DownstreamThreadSignal + | DownstreamCmdSignal + | Minimize + | Maximize + > + +let Sensor = + -- Configuration for an arbitrary sensor. + { sensorBinary : Text + , sensorArguments : List Text + , range : Range + , tags : List Tag + , sensorBehavior : SensorBehavior + } + +let Actuator = + -- Configuration for an arbitrary actuator. + { actuatorBinary : Text + , actuatorArguments : List Text + , actions : List Double + , referenceAction : Double + } + +let StaticActuatorKV = + -- Key-value representation for an actuator. + { staticActuatorKey : Text, staticActuatorValue : Actuator } + +let PassiveSensorKV = + -- Key-value representation for a passive sensor. + { passiveSensorKey : Text, passiveSensorValue : Sensor } + +let Hwmon = { hwmonEnabled : Bool, hwmonPath : Text } + +let RaplCfg = + -- Configuration for auto-discovered RAPL power sensors/actuators + { raplPath : Text + , raplActions : List types.Power + , referencePower : types.Power + } + +let ActuatorValue = + -- Actuator value configuration for the internal control loop configuration. + { actuatorID : Text, actuatorValue : Double } + +let Hint = + -- Action space configuration for internal control loop. + < Full + | Only : + { neHead : List ActuatorValue, neTail : List (List ActuatorValue) } + > + +let LearnCfg = + -- Internal control loop algorithm type and hyperparameters. + < Lagrange : { lagrange : Double } + | Random : { seed : Integer } + | Contextual : { horizon : Integer } + > + +let ControlCfg = + -- Root control configuration. + -- ControlCfg: configures an internal control loop + -- ControlOff: bypass mode + < ControlCfg : + { minimumControlInterval : types.Time + , staticPower : types.Power + , learnCfg : LearnCfg + , speedThreshold : Double + , referenceMeasurementRoundInterval : Integer + , hint : Hint + } + | ControlOff + > + +let Cfg = + -- The configuration type for nrmd. + { verbose : Verbosity + , logfile : Text + , hwloc : Text + , perf : Text + , argo_perf_wrapper : Text + , argo_nodeos_config : Text + , libnrmPath : Optional Text + , pmpi_lib : Text + , singularity : Bool + , dummy : Bool + , nodeos : Bool + , downstreamCfg : DownstreamCfg + , upstreamCfg : UpstreamCfg + , raplCfg : Optional RaplCfg + , hwmonCfg : Hwmon + , controlCfg : ControlCfg + , activeSensorFrequency : types.Frequency + , extraStaticPassiveSensors : List PassiveSensorKV + , extraStaticActuators : List StaticActuatorKV + } + +let output = + { Verbosity = Verbosity + , UpstreamCfg = UpstreamCfg + , DownstreamCfg = DownstreamCfg + , Tag = Tag + , SensorBehavior = SensorBehavior + , Actuator = Actuator + , PassiveSensorKV = PassiveSensorKV + , PassiveSensor = Sensor + , StaticActuatorKV = StaticActuatorKV + , Range = Range + , PassiveSensorCfg = Sensor + , ActuatorValue = ActuatorValue + , ActuatorCfg = Actuator + , HwmonCfg = Hwmon + , LearnCfg = LearnCfg + , RaplCfg = RaplCfg + , ControlCfg = ControlCfg + , Hint = Hint + , Cfg = Cfg + } + +in types ⫽ output diff --git a/hsnrm/hsnrm/dhall/types/types.dhall b/hsnrm/hsnrm/dhall/types/types.dhall new file mode 100644 index 0000000000000000000000000000000000000000..cf3a029547b6dcbf3780b881a0397216276c24ae --- /dev/null +++ b/hsnrm/hsnrm/dhall/types/types.dhall @@ -0,0 +1,13 @@ +let Power = + -- Base unit: power. + { microwatts : Double } + +let Time = + -- Base unit: time. + { microseconds : Double } + +let Frequency = + --Base unit: frequency. + { hertz : Double } + +in { Frequency = Frequency, Time = Time, Power = Power } diff --git a/hsnrm/hsnrm/hsnrm.cabal b/hsnrm/hsnrm/hsnrm.cabal index 4fdb97fbbddabc5e10744b365130861a213abd8d..c65af01862fe74febdace6b2e9db17bdb7e2eb50 100644 --- a/hsnrm/hsnrm/hsnrm.cabal +++ b/hsnrm/hsnrm/hsnrm.cabal @@ -1,13 +1,4 @@ cabal-version: 2.0 --- * * * * * * * * * * * * WARNING * * * * * * * * * * * * --- This file has been AUTO-GENERATED by dhall-to-cabal. --- --- Do not edit it by hand, because your changes will be over-written! --- --- Instead, edit the source Dhall file (which may have the --- '.dhall' extension) and re-run dhall-to-cabal, passing --- the source file's name as its argument. --- * * * * * * * * * * * * WARNING * * * * * * * * * * * * name: hsnrm version: 1.0.0 license: BSD3 @@ -19,6 +10,10 @@ description: category: tools build-type: Simple +extra-source-files: + dhall/defaults/*.dhall + dhall/types/*.dhall + source-repository head type: git location: https://xgitlab.cels.anl.gov/vreis/hsnrm.git @@ -96,7 +91,6 @@ library FFI.TypeUncurry.Msgpack FFI.TypeUncurry.DataKinds Codegen.Schema - Codegen.Dhall Codegen.CHeader LensMap.Core CPD.Core @@ -116,7 +110,7 @@ library OverloadedLabels DeriveFoldable DerivingStrategies TypeApplications MultiWayIf NoTemplateHaskell BlockArguments GADTs FlexibleContexts TypeOperators DataKinds PolyKinds AllowAmbiguousTypes - FunctionalDependencies UndecidableInstances + FunctionalDependencies UndecidableInstances CPP ghc-options: -Wall -O0 -Wcompat -Wincomplete-uni-patterns -Wmissing-home-modules -Widentities -Wredundant-constraints -Wcpp-undef -fwarn-tabs -fwarn-unused-imports @@ -129,6 +123,7 @@ library -Wmissing-export-lists -Wmissing-home-modules -Widentities -Wredundant-constraints -Wpartial-fields build-depends: + process -any, base -any, hbandit -any, either -any, @@ -154,7 +149,7 @@ library unordered-containers -any, mtl -any, aeson -any, - dhall -any, + dhall >= 1.30.0, dhall-json -any, conduit -any, conduit-extra -any, diff --git a/hsnrm/hsnrm/hsnrm.dhall b/hsnrm/hsnrm/hsnrm.dhall deleted file mode 100644 index 70ef41b67a4b3131e73a763a34dfcad6f175f268..0000000000000000000000000000000000000000 --- a/hsnrm/hsnrm/hsnrm.dhall +++ /dev/null @@ -1,59 +0,0 @@ -let prelude = ../dhall-to-cabal/prelude.dhall - -let types = ../dhall-to-cabal/types.dhall - -let common = ../common.dhall - -in λ(ghcPath : Text) - → λ(ghcNumericVersion : Text) - → prelude.defaults.Package - ⫽ { name = "hsnrm" - , version = prelude.v "1.0.0" - , author = "Valentin Reis" - , build-type = Some types.BuildType.Simple - , cabal-version = prelude.v "2.0" - , category = "tools" - , description = - "The Node Resource Manager(NRM) is a linux daemon that enables dynamic resource optimization for improving the power/performance tradeoff of HPC applications." - , library = - prelude.unconditional.library - ( prelude.defaults.Library - ⫽ { build-depends = common.libdep - , hs-source-dirs = [ "src" ] - , exposed-modules = common.allmodules - } - ⫽ common.copts ([] : List Text) - ) - , test-suites = - [ { name = "discover" - , test-suite = - λ(config : types.Config) - → prelude.defaults.TestSuite - ⫽ { type = - types.TestType.exitcode-stdio { main-is = "Driver.hs" } - , other-modules = [ "Test.CPD.Integrated" ] - , build-depends = - [ common.deps.base - , common.deps.protolude - , common.nobound "hsnrm" - , common.deps.tasty-hunit - , common.deps.tasty - , common.deps.tasty-discover - ] - , hs-source-dirs = [ "tests" ] - } - ⫽ common.copts [ "-threaded" ] - } - ] - , extra-source-files = [] : List Text - , license = types.License.BSD3 - , license-files = [] : List Text - , maintainer = "fre@freux.fr" - , source-repos = - [ prelude.defaults.SourceRepo - ⫽ { type = Some types.RepoType.Git - , location = Some "https://xgitlab.cels.anl.gov/vreis/hsnrm.git" - } - ] - , synopsis = "hsnrm" - } diff --git a/hsnrm/hsnrm/src/CPD/Integrated.hs b/hsnrm/hsnrm/src/CPD/Integrated.hs index 6183ffc8a6e8bc582e8b1646a71e48603480da1f..3345a0adcdaebcdc01b4df7a23b8514e092b0a21 100644 --- a/hsnrm/hsnrm/src/CPD/Integrated.hs +++ b/hsnrm/hsnrm/src/CPD/Integrated.hs @@ -120,7 +120,7 @@ squeeze :: Maybe (Map SensorID Double, Map SensorID (MeasurementState M)) squeeze _t mstM = case traverse throughTuple (M.toList mstM) of - Done (M.fromList -> m) -> Just (m <&> averageArea, m <&> const Never) + Done (M.fromList -> m) -> Just (m <&> averageArea, m $> Never) _ -> Nothing throughTuple :: Functor f => (a, f b) -> f (a, b) diff --git a/hsnrm/hsnrm/src/Codegen/Dhall.hs b/hsnrm/hsnrm/src/Codegen/Dhall.hs deleted file mode 100644 index e6b57fef7de99e1727cf4b6dc2a9981517177f4c..0000000000000000000000000000000000000000 --- a/hsnrm/hsnrm/src/Codegen/Dhall.hs +++ /dev/null @@ -1,97 +0,0 @@ -{-# LANGUAGE ScopedTypeVariables #-} - --- | --- Module : Codegen.Dhall --- Copyright : Copyright (c) 2018 Oliver Charles. --- License : MIT License. --- --- Dhall code generation utilities adapted from dhall-to-cabal-meta. -module Codegen.Dhall - ( writeOutput, - relativeTo, - takeDirectory, - typeToExpr, - defaultToExpr, - valueToExpr, - exprToText, - ) -where - -import Data.Default -import qualified Data.Text.Prettyprint.Doc as Pretty -import qualified Data.Text.Prettyprint.Doc.Render.Text as Pretty -import Dhall -import Dhall.Core as Dhall -import Dhall.Parser as Dhall -import Dhall.Pretty as Dhall -import Dhall.TypeCheck as Dhall -import Protolude -import System.FilePath - ( dropTrailingPathSeparator, - joinPath, - normalise, - splitDirectories, - takeDirectory, - ) -import qualified System.IO - -writeOutput :: (Pretty.Pretty a) => Text -> FilePath -> Expr s a -> IO () -writeOutput header dest e = - withFile dest WriteMode $ \hnd -> do - System.IO.hPutStrLn hnd (toS header) - Pretty.renderIO - hnd - $ Pretty.layoutSmart - prettyOpts - (Pretty.pretty e) - System.IO.hPutStr hnd "\n" - -prettyOpts :: Pretty.LayoutOptions -prettyOpts = - Pretty.defaultLayoutOptions - { Pretty.layoutPageWidth = Pretty.AvailablePerLine 80 1.0 - } - -relativeTo :: - -- | The path to be relative to. Note that the final file-name is - -- ignored: @foo/bar@ is relative to @foo/@, even if @foo/bar@ is - -- a directory. - FilePath -> - -- | The path to relativise. - FilePath -> - FilePath -relativeTo = - \(splitDirectories . dropTrailingPathSeparator . takeDirectory . normalise -> base) -> - \(splitDirectories . normalise -> path) -> - joinPath (go base path) - where - -- @normalise "."@ is @"."@, so we have to take care here with dots. - go :: [FilePath] -> [FilePath] -> [FilePath] - go (a : as) (b : bs) - | a == b = go as bs - | a == "." = go as (b : bs) - | b == "." = go (a : as) bs - | otherwise = (".." <$ (a : as)) <> (b : bs) - go [] bs = bs - go as [] = ".." <$ as - -typeToExpr :: FromDhall x => Proxy x -> Expr Src b -typeToExpr (Proxy :: Proxy x) = - Dhall.absurd <$> Dhall.expected (Dhall.auto :: Dhall.Decoder x) - -defaultToExpr :: (Inject x, Default x) => Proxy x -> Expr Src b -defaultToExpr (Proxy :: Proxy x) = - Dhall.absurd - <$> embed - (injectWith defaultInterpretOptions) - (def :: x) - -valueToExpr :: (Inject x) => x -> Expr Src Void -valueToExpr x = - Dhall.absurd - <$> embed - (injectWith defaultInterpretOptions) - x - -exprToText :: (Pretty.Pretty a) => Expr Src a -> Text -exprToText = show . Dhall.prettyExpr diff --git a/hsnrm/hsnrm/src/NRM/Behavior.hs b/hsnrm/hsnrm/src/NRM/Behavior.hs index c2b0395f4023788db2421280f11a6806376c5812..1a4eb38b6cf2ff95f3c526be6bc294da44fe81b8 100644 --- a/hsnrm/hsnrm/src/NRM/Behavior.hs +++ b/hsnrm/hsnrm/src/NRM/Behavior.hs @@ -128,11 +128,15 @@ nrm _callTime (Req clientid msg) = <&> fromMaybe (panic "couldn't generate next cmd id") let (runCmd, runArgs) = (spec ^. #cmd, spec ^. #args) & case Manifest.perfwrapper (Manifest.app manifest) of - Manifest.PerfwrapperDisabled -> identity - p@Manifest.Perfwrapper {} -> + Nothing -> identity + (Just p@Manifest.Perfwrapper {}) -> wrapCmd - (Cfg.argo_perf_wrapper c) - ["-f", Arg . show . U.fromHz $ Manifest.perfFreq p] + (Command $ Cfg.argo_perf_wrapper c) + [ "-f", + Arg . show . U.fromHz + . Manifest.toFrequency + $ Manifest.perfFreq p + ] modify $ registerAwaiting cmdID @@ -253,7 +257,7 @@ doControl input = do zoom (#controller . _Just) $ do logInfo ("Control input:" <> show input) mccfg & \case - FixedCommand _ -> pass + ControlOff -> pass ccfg@ControlCfg {} -> let cpd = NRMCPD.toCPD ccfg st mRefActions = @@ -490,7 +494,9 @@ injectDownstreamVars c manifest cmdID = execState $ do _Unwrapped . at cmdIDEnvVar ?= CmdID.toText cmdID for_ - (manifest ^.. #app . #instrumentation . _Just . #ratelimit) + ( Manifest.toFrequency + <$> (manifest ^.. #app . #instrumentation . _Just . #ratelimit) + ) modifyRatelimitLens for_ (c ^. #libnrmPath) modifyLDPreloadLens where diff --git a/hsnrm/hsnrm/src/NRM/CPD.hs b/hsnrm/hsnrm/src/NRM/CPD.hs index 920b201cf07abcca764b6e57d9bd78fff5e557d4..6f74d66c0538245d39758fe9ae350d8d220cb40d 100644 --- a/hsnrm/hsnrm/src/NRM/CPD.hs +++ b/hsnrm/hsnrm/src/NRM/CPD.hs @@ -53,7 +53,7 @@ throughputConstrained cfg st = Just ids -> let powerTerm = coerce (foldMap (OExprSum . sID) ids) - \+ scalar (fromWatts $ staticPower cfg) + \+ scalar (fromWatts . toPower $ staticPower cfg) in [(Bandit.Types.one, maybe powerTerm (powerTerm \/) normalizedSumSlowdown)], normalizedSumSlowdown & \case Nothing -> [] @@ -67,7 +67,7 @@ throughputConstrained cfg st = idsToMinimize :: Maybe (NonEmpty SensorID) idsToMinimize = nonEmpty (fst <$> M.toList toMinimize) toMinimize :: Map SensorID SensorMeta - toMinimize = M.filterWithKey (\_ m -> Power `elem` S.tags m) allSensorMeta + toMinimize = M.filterWithKey (\_ m -> TagPower `elem` S.tags m) allSensorMeta constrained :: Map SensorID SensorMeta constrained = M.filterWithKey (\_ m -> DownstreamCmdSignal `elem` S.tags m) allSensorMeta allSensorMeta :: Map SensorID S.SensorMeta diff --git a/hsnrm/hsnrm/src/NRM/Codegen.hs b/hsnrm/hsnrm/src/NRM/Codegen.hs index 108ab49945fc7a1718153c0f3d4b3734115d679c..db2e70c013293846f7b8bf592a4851cd2d1ce8d1 100644 --- a/hsnrm/hsnrm/src/NRM/Codegen.hs +++ b/hsnrm/hsnrm/src/NRM/Codegen.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE QuasiQuotes #-} {-# LANGUAGE ScopedTypeVariables #-} -- | @@ -8,7 +7,6 @@ -- Maintainer : fre@freux.fr module NRM.Codegen ( main, - typeToFile, upstreamPubSchema, upstreamReqSchema, upstreamRepSchema, @@ -17,27 +15,16 @@ module NRM.Codegen configurationSchema, libnrmHeader, licenseC, - licenseDhall, - licenseYaml, ) where import Codegen.CHeader -import Codegen.Dhall import Codegen.Schema (generatePretty) import Codegen.Schema as CS import Data.Aeson.Encode.Pretty as AP (encodePretty) import Data.Default import Data.JSON.Schema as S -import qualified Data.Map as M -import Data.Yaml as Y import Dhall -import qualified Dhall.Core as Dhall -import Dhall.Import as Dhall -import Dhall.JSON as DJ -import qualified Dhall.Lint as Lint -import qualified Dhall.Parser -import qualified Dhall.TypeCheck as Dhall import NRM.Messaging import qualified NRM.Types.Configuration as C import qualified NRM.Types.Manifest as MI @@ -46,9 +33,7 @@ import qualified NRM.Types.Messaging.DownstreamEvent as Down (Event (..)) import NRM.Types.Messaging.UpstreamPub import NRM.Types.Messaging.UpstreamRep import NRM.Types.Messaging.UpstreamReq -import NeatInterpolation import Protolude hiding (Rep) -import System.Directory -- | The main code generation binary. main :: IO () @@ -58,16 +43,18 @@ main = do putText $ " Writing libnrm header to " <> prefix <> "/nrm_messaging.h" writeFile (toS $ prefix <> "/nrm_messaging.h") $ toS (licenseC <> "\n\n" <> libnrmVars <> "\n\n" <> libnrmHeader) putText "Codegen: JSON schemas" - verboseWriteSchema prefix "upstreamPub" upstreamPubSchema - verboseWriteSchema prefix "upstreamRep" upstreamRepSchema - verboseWriteSchema prefix "upstreamReq" upstreamReqSchema - verboseWriteSchema prefix "downstreamEvent" downstreamEventSchema - verboseWriteSchema prefix "manifestSchema" manifestSchema - generateResources prefix + verboseWrite (prefix <> "/schemas") "upstream-pub" upstreamPubSchema + verboseWrite (prefix <> "/schemas") "upstream-rep" upstreamRepSchema + verboseWrite (prefix <> "/schemas") "upstream-req" upstreamReqSchema + verboseWrite (prefix <> "/schemas") "downstream" downstreamEventSchema + verboseWrite (prefix <> "/schemas") "manifest" manifestSchema + verboseWrite (prefix <> "/schemas") "nrmd" configurationSchema + verboseWrite (prefix <> "/defaults") "nrmd" (toS $ AP.encodePretty (def :: C.Cfg)) + verboseWrite (prefix <> "/defaults") "manifest" (toS $ AP.encodePretty (def :: MI.Manifest)) where - verboseWriteSchema :: Text -> Text -> Text -> IO () - verboseWriteSchema prefix desc sch = do - putText $ toS (" Writing schema for " <> toS desc <> " to " <> fp) + verboseWrite :: Text -> Text -> Text -> IO () + verboseWrite prefix desc sch = do + putText $ toS (" Writing file " <> fp) writeFile (toS fp) sch where fp = prefix <> "/" <> desc <> ".json" @@ -103,124 +90,20 @@ libnrmHeader = toS $ toCHeader (Proxy :: Proxy Down.Event) -- | A license for C headers. licenseC :: Text licenseC = - [text| - /******************************************************************************* - * Copyright 2019 UChicago Argonne, LLC. - * (c.f. AUTHORS, LICENSE) - * - * SPDX-License-Identifier: BSD-3-Clause - ******************************************************************************* - * - * this file is generated, modifications will be erased. - */ - - |] - --- | A license for Yaml files -licenseYaml :: Text -licenseYaml = - [text| - # ****************************************************************************** - # Copyright 2019 UChicago Argonne, LLC. - # (c.f. AUTHORS, LICENSE) - # - # SPDX-License-Identifier: BSD-3-Clause - # ****************************************************************************** - # - # this file is generated, modifications will be erased. - # - - |] - --- | A license for Dhall files -licenseDhall :: Text -licenseDhall = - [text| - -- ****************************************************************************** - -- Copyright 2019 UChicago Argonne, LLC. - -- (c.f. AUTHORS, LICENSE) - -- - -- SPDX-License-Identifier: BSD-3-Clause - -- ****************************************************************************** - -- - -- this file is generated, modifications will be erased. - -- - - |] - -data KnownType - = Cfg - | Manifest - deriving (Bounded, Enum, Eq, Ord, Read, Show) - -dhallType :: KnownType -> Dhall.Expr Dhall.Parser.Src Dhall.Import -dhallType = - fmap Dhall.absurd <$> \case - Cfg -> Dhall.expected (Dhall.auto :: Dhall.Decoder C.Cfg) - Manifest -> Dhall.expected (Dhall.auto :: Dhall.Decoder MI.Manifest) - -sandwich :: Semigroup a => a -> a -> a -> a -sandwich a b x = a <> x <> b - -typeFile :: KnownType -> FilePath -typeFile = sandwich "types/" ".dhall" . show - -getDefault :: KnownType -> Dhall.Expr Dhall.Parser.Src b -getDefault x = - Dhall.absurd <$> case x of - Cfg -> embed (injectWith defaultInterpretOptions) (def :: C.Cfg) - Manifest -> embed (injectWith defaultInterpretOptions) (def :: MI.Manifest) - -generateResources :: Text -> IO () -generateResources prefix = do - putText "Codegen: Dhall types." - --typeToFile (Proxy :: Proxy [CPD.Values.Measurement]) $ prefix <> "/types/CPDMeasurements.dhall" - --typeToFile (Proxy :: Proxy [CPD.Values.Action]) $ prefix <> "/types/CPDActions.dhall" - --typeToFile (Proxy :: Proxy CPD.Core.Problem) $ toS prefix <> "/types/CPDProblem.dhall" - for_ ([minBound .. maxBound] :: [KnownType]) $ \t -> do - let dest = toS prefix <> typeFile t - putText $ " Writing type for " <> show t <> " to " <> toS dest - createDirectoryIfMissing True (takeDirectory dest) - writeOutput licenseDhall dest (dhallType t) - putText "Codegen: defaults." - for_ ([minBound .. maxBound] :: [KnownType]) $ \defaultType -> - Dhall.load (Lint.lint (getDefault defaultType)) - >>= exprToDir "defaults/" (show defaultType) - putText "Codegen: example manifests." - for_ (M.toList MI.examples) $ \(defName, defValue) -> - Dhall.load (Lint.lint $ Dhall.absurd <$> embed (injectWith defaultInterpretOptions) defValue) - >>= exprToDir "example-manifests/" defName - putText "Codegen: example configurations." - for_ (M.toList C.examples) $ \(defName, defValue) -> - Dhall.load (Lint.lint $ Dhall.absurd <$> embed (injectWith defaultInterpretOptions) defValue) - >>= exprToDir "example-configurations/" defName - where - exprToDir dir defName expr = do - let (dest, destJ, destY) = mkPaths dir defName - DJ.dhallToJSON expr & \case - Left e -> die $ "horrible internal dhall error: " <> show e - Right jsonValue -> do - putText $ " Writing default for " <> defName <> " to " <> dest <> "." - createDirectoryIfMissing True (takeDirectory $ toS dest) - writeOutput - licenseDhall - (toS dest) - expr - writeFile (toS destJ) $ toS (AP.encodePretty jsonValue) - writeFile (toS destY) $ licenseYaml <> toS (Y.encode jsonValue) - resourcePath dir defName x = toS prefix <> dir <> defName <> x - mkPaths dir defName = - ( resourcePath dir defName ".dhall", - resourcePath dir defName ".json", - resourcePath dir defName ".yaml" - ) - -typeToFile :: (Interpret x) => Proxy x -> Text -> IO () -typeToFile (Proxy :: Proxy x) fp = do - let destCPD = fp - putText $ " Writing types for CPD format. " <> " to " <> toS destCPD - createDirectoryIfMissing True (takeDirectory $ toS destCPD) - writeOutput - licenseDhall - (toS destCPD) - (Dhall.expected (Dhall.auto :: Dhall.Decoder x)) + "/*******************************************************************************" <> "\n" + <> " * Copyright 2019 UChicago Argonne, LLC." + <> "\n" + <> " * (c.f. AUTHORS, LICENSE)" + <> "\n" + <> " *" + <> "\n" + <> " * SPDX-License-Identifier: BSD-3-Clause" + <> "\n" + <> "*******************************************************************************" + <> "\n" + <> " *" + <> "\n" + <> " * this file is generated, modifications will be erased." + <> "\n" + <> "*/" + <> "\n" diff --git a/hsnrm/hsnrm/src/NRM/Control.hs b/hsnrm/hsnrm/src/NRM/Control.hs index 7de0b8612e4ed89a0fcd9be4bb8e62fc13516552..eac683edc9f158d26dcce20d62c535f80269a7b9 100644 --- a/hsnrm/hsnrm/src/NRM/Control.hs +++ b/hsnrm/hsnrm/src/NRM/Control.hs @@ -82,7 +82,7 @@ banditCartesianProductControl ccfg cpd (Reconfigure t) _ = do g <- liftIO getStdGen (b, aInitial) <- Cfg.learnCfg ccfg & \case - Contextual (CtxCfg hrizon) -> do + Cfg.Contextual hrizon -> do -- per terminology of sun wen let riskThreshold :: ZeroOne Double riskThreshold = @@ -95,19 +95,28 @@ banditCartesianProductControl ccfg cpd (Reconfigure t) _ = do ( Exp4RCfg { expertsCfg = mkExperts availableActions, constraintCfg = riskThreshold, - horizonCfg = unsafeRefine hrizon, + horizonCfg = unsafeRefine (fromInteger hrizon), as = availableActions } ) let ((a, g'), s') = runState (stepCtx g Nothing ()) b liftIO $ setStdGen g' return (Contextual s', a) - Lagrange _ -> do + Cfg.Lagrange _ -> do let (b, a, g') = Bandit.Class.init g (Arms availableActions) & _1 %~ Lagrange liftIO $ setStdGen g' return (b, a) - Random (UniformCfg seed) -> do - let (b, a, g') = initUniform (maybe g (\(Seed s) -> mkStdGen s) seed) availableActions & _1 %~ Random + Cfg.Random seed -> do + let (b, a, g') = + initUniform + ( maybe + g + (\(Seed s) -> mkStdGen s) + (Just . Seed . fromInteger $ seed) + ) + availableActions + & _1 + %~ Random liftIO $ setStdGen g' return (b, a) #bandit .= Just b @@ -148,10 +157,11 @@ intersect (x : xs) l intersectNE :: Eq a => NonEmpty a -> NonEmpty a -> Maybe (NonEmpty a) intersectNE (NE.toList -> x) (NE.toList -> y) = nonEmpty (x `intersect` y) -mkActions :: NonEmpty (ActuatorID, Actuator) -> Hint -> Maybe (NonEmpty [Action]) +mkActions :: NonEmpty (ActuatorID, Actuator) -> Cfg.Hint -> Maybe (NonEmpty [Action]) mkActions actuators = \case - Full -> Just allA - (Only as) -> intersectNE allA as + Cfg.Full -> Just allA + (Cfg.Only (fmap Cfg.toAction -> neh) ((fmap . fmap) Cfg.toAction -> net)) -> + intersectNE allA (neh :| net) where allA = allActions actuators @@ -198,7 +208,8 @@ wrappedCStep cc stepObjectives stepConstraints sensorRanges t mRefActions = do logInfo "control: integrator squeeze success" #integrator . #measured .= newMeasured -- acquiring fields - counter <- use #referenceMeasurementCounter + (counter :: Refined NonNegative Int) <- + use #referenceMeasurementCounter bufM <- use #bufferedMeasurements refM <- use #referenceMeasurements let maxCounter = Cfg.referenceMeasurementRoundInterval cc @@ -219,7 +230,7 @@ wrappedCStep cc stepObjectives stepConstraints sensorRanges t mRefActions = do #bufferedMeasurements ?= measurements -- take the reference actions return $ Decision refActions ReferenceMeasurementDecision - if unrefine counterValue <= unrefine maxCounter + if unrefine counterValue <= (fromIntegral maxCounter :: Int) then case bufM of Nothing -> do logInfo "control: inner control" diff --git a/hsnrm/hsnrm/src/NRM/Export.hs b/hsnrm/hsnrm/src/NRM/Export.hs index 59daddaa8edba81fba888182882edc34c36ba7bb..2fccd0281f27741d14b5770db6be5aa44804c441 100644 --- a/hsnrm/hsnrm/src/NRM/Export.hs +++ b/hsnrm/hsnrm/src/NRM/Export.hs @@ -48,6 +48,7 @@ import qualified NRM.Types.Configuration as C UpstreamCfg (..), activeSensorFrequency, logfile, + toFrequency, verbose, ) import qualified NRM.Types.Messaging.UpstreamRep as URep @@ -65,7 +66,7 @@ parseDaemon = O.parseArgDaemonCli -- | Parses Daemon CLI arguments activeSensorFrequency :: C.Cfg -> Double -activeSensorFrequency = fromHz . C.activeSensorFrequency +activeSensorFrequency = fromHz . C.toFrequency . C.activeSensorFrequency -- | Queries configuration for 'verbose' verbosity verbosity :: C.Cfg -> Int diff --git a/hsnrm/hsnrm/src/NRM/Messaging.hs b/hsnrm/hsnrm/src/NRM/Messaging.hs index d59a355dc03a37e16ccf3d8b93e079f8604fbed3..35b4babd383092e715ca6a46d1e5f8210f301c5d 100644 --- a/hsnrm/hsnrm/src/NRM/Messaging.hs +++ b/hsnrm/hsnrm/src/NRM/Messaging.hs @@ -12,13 +12,7 @@ where import Data.Default import NRM.Types.Configuration -import NRM.Types.Manifest -import NRM.Types.Units import Protolude -import Refined -import Refined.Unsafe - -data V = Str Text | LLPos (Refined Positive Int) ratelimitEnvVar :: Text ratelimitEnvVar = "NRM_RATELIMIT" @@ -30,16 +24,13 @@ libnrmVars :: Text libnrmVars = mconcat . intersperse "\n" $ toHeader - <$> [ ("NRM_DEFAULT_URI", Str (downstreamBindAddress (def :: DownstreamCfg))), - ("NRM_ENV_URI", Str "NRM_DOWNSTREAM_EVENT_URI"), - ("NRM_ENV_CMDID", Str cmdIDEnvVar), - ("NRM_ENV_RATELIMIT", Str ratelimitEnvVar), - ("NRM_ENV_TRANSMIT", Str "NRM_TRANSMIT"), - ( "NRM_DEFAULT_RATELIMIT_THRESHOLD", - LLPos (unsafeRefine . floor . fromHz $ ratelimit (def :: Instrumentation)) - ) + <$> [ ("NRM_DEFAULT_URI", show (downstreamBindAddress $ downstreamCfg (def :: Cfg))), + ("NRM_ENV_URI", show ("NRM_DOWNSTREAM_EVENT_URI" :: Text)), + ("NRM_ENV_CMDID", show cmdIDEnvVar), + ("NRM_ENV_RATELIMIT", show ratelimitEnvVar), + ("NRM_ENV_TRANSMIT", show ("NRM_TRANSMIT" :: Text)), + ("NRM_DEFAULT_RATELIMIT_THRESHOLD", "(10000000LL)") ] -toHeader :: (Text, V) -> Text -toHeader (t, Str x) = "#define " <> t <> " " <> show x -toHeader (t, LLPos x) = "#define " <> t <> " (" <> show (unrefine x) <> "LL)" +toHeader :: (Text, Text) -> Text +toHeader (t, x) = "#define " <> t <> " " <> x diff --git a/hsnrm/hsnrm/src/NRM/Optparse/Client.hs b/hsnrm/hsnrm/src/NRM/Optparse/Client.hs index 4145223130748514d75d02c858e4ff1c0cf13911..2887e07a8d2c3549805e8395694f4505fc5b4620 100644 --- a/hsnrm/hsnrm/src/NRM/Optparse/Client.hs +++ b/hsnrm/hsnrm/src/NRM/Optparse/Client.hs @@ -46,7 +46,7 @@ data CommonOpts deriving (Generic, MessagePack) instance Default CommonOpts where - def = CommonOpts Normal False False pub rpc addr + def = CommonOpts Normal False False (fromInteger pub) (fromInteger rpc) addr where rpc = Cfg.rpcPort . Cfg.upstreamCfg $ def pub = Cfg.pubPort . Cfg.upstreamCfg $ def diff --git a/hsnrm/hsnrm/src/NRM/Optparse/Daemon.hs b/hsnrm/hsnrm/src/NRM/Optparse/Daemon.hs index bd14ca60314aae313a9cd6923590b60b91ec4e94..ca61e25f5027b83994805c24f8e7ea9194538d44 100644 --- a/hsnrm/hsnrm/src/NRM/Optparse/Daemon.hs +++ b/hsnrm/hsnrm/src/NRM/Optparse/Daemon.hs @@ -15,18 +15,18 @@ module NRM.Optparse.Daemon ) where -import Codegen.Dhall import qualified Data.Aeson as J import Data.Aeson.Extra.Merge import qualified Data.ByteString as B (getContents) import Data.Default import Data.Either.Validation as V import qualified Data.Yaml as Y -import qualified Dhall +import Dhall import qualified Dhall.Core as Dhall import Dhall.JSON as DJ import Dhall.JSONToDhall as JSONToDhall import qualified Dhall.Src as Dhall +import qualified Dhall.TypeCheck as Dhall import NRM.Types.Configuration import Options.Applicative import Protolude @@ -156,3 +156,10 @@ mergeAndExtract x expr = & \case V.Failure _ -> die "dhall extraction error" V.Success a -> return a + +typeToExpr :: FromDhall x => Proxy x -> Dhall.Expr Dhall.Src b +typeToExpr (Proxy :: Proxy x) = + Dhall.absurd <$> Dhall.expected (Dhall.auto :: Dhall.Decoder x) + +valueToExpr :: (Inject x) => x -> Dhall.Expr Dhall.Src Void +valueToExpr x = Dhall.absurd <$> embed (injectWith defaultInterpretOptions) x diff --git a/hsnrm/hsnrm/src/NRM/Sensors.hs b/hsnrm/hsnrm/src/NRM/Sensors.hs index 481416950220950eca66f7db9ace1731e68519c8..1fea1ccc3de2fd14be06a5b9801d8565c835ced5 100644 --- a/hsnrm/hsnrm/src/NRM/Sensors.hs +++ b/hsnrm/hsnrm/src/NRM/Sensors.hs @@ -24,6 +24,7 @@ import Data.Generics.Labels () import Data.Map as M import LensMap.Core import NRM.Classes.Sensors +import NRM.Types.Configuration import NRM.Types.Sensor as S import NRM.Types.State import NRM.Types.Units diff --git a/hsnrm/hsnrm/src/NRM/State.hs b/hsnrm/hsnrm/src/NRM/State.hs index ac8ed2cce549002d98d7c73fa111ba9e04e3baf8..12ac66b05813942f037605f9065aad1cac6b8f56 100644 --- a/hsnrm/hsnrm/src/NRM/State.hs +++ b/hsnrm/hsnrm/src/NRM/State.hs @@ -30,7 +30,7 @@ import NRM.Slices.Nodeos as CN import NRM.Slices.Singularity as CS import NRM.Types.Cmd import NRM.Types.CmdID -import NRM.Types.Configuration as Cfg +import qualified NRM.Types.Configuration as Cfg import NRM.Types.Controller import NRM.Types.MemBuffer as MemBuffer import NRM.Types.Process @@ -43,7 +43,7 @@ import NRM.Types.UpstreamClient import Protolude -- | Populate the initial NRMState. -initialState :: Cfg -> Time -> IO NRMState +initialState :: Cfg.Cfg -> Time -> IO NRMState initialState c time = do hwl <- getHwlocData let packages' = M.fromList $ selectPackageIDs hwl <&> (,Package {rapl = Nothing}) @@ -70,8 +70,11 @@ initialState c time = do raplCfg = packageRaplConfig, maxEnergyCounterValue = packageRaplDir ^. #maxEnergy, max = watts 150, - defaultPower = referencePower raplc, - discreteChoices = raplActions raplc, + defaultPower = + uW $ + Cfg.microwatts (Cfg.referencePower raplc), + discreteChoices = + uW . Cfg.microwatts <$> Cfg.raplActions raplc, lastRead = Nothing, history = MemBuffer.empty } @@ -85,30 +88,40 @@ initialState c time = do fullMap return newPkgs return NRMState - { controller = controlCfg c & \case - FixedCommand _ -> Nothing - ccfg -> Just $ initialController time (minimumControlInterval ccfg) [], + { controller = Cfg.controlCfg c & \case + Cfg.ControlOff -> Nothing + ccfg -> + Just $ + initialController + time + (Cfg.toTime $ Cfg.minimumControlInterval ccfg) + [], slices = M.fromList [], pus = M.fromList $ (,PU) <$> selectPUIDs hwl, cores = M.fromList $ (,Core) <$> selectCoreIDs hwl, dummyRuntime = - if dummy c + if Cfg.dummy c then Just CD.emptyRuntime else Nothing, singularityRuntime = - if singularity c + if Cfg.singularity c then Just SingularityRuntime else Nothing, nodeosRuntime = - if nodeos c + if Cfg.nodeos c then Just NodeosRuntime else Nothing, extraStaticActuators = Cfg.extraStaticActuators c - <&> NRMState.ExtraActuator, + & fmap (\(Cfg.StaticActuatorKV k v) -> (k, v)) + & M.fromList, extraStaticPassiveSensors = - Cfg.extraStaticPassiveSensors c - <&> concretizeExtraPassiveSensor (activeSensorFrequency c), + ( Cfg.extraStaticPassiveSensors c + & fmap (\(Cfg.PassiveSensorKV k v) -> (k, v)) + & M.fromList + ) + <&> concretizeExtraPassiveSensor + (Cfg.toFrequency $ Cfg.activeSensorFrequency c), .. } diff --git a/hsnrm/hsnrm/src/NRM/Types/Cmd.hs b/hsnrm/hsnrm/src/NRM/Types/Cmd.hs index 982c0d00f0900aed3cc9410e594669463ef8303f..ad27a5cb672b843602104d9935a8b469a75a4aa4 100644 --- a/hsnrm/hsnrm/src/NRM/Types/Cmd.hs +++ b/hsnrm/hsnrm/src/NRM/Types/Cmd.hs @@ -107,14 +107,14 @@ addDownstreamCmdClient :: Maybe Cmd addDownstreamCmdClient c downstreamCmdClientID = c ^. #cmdCore . #manifest . #app . #perfwrapper & \case - PerfwrapperDisabled -> Nothing - Perfwrapper perfFreq perfLimit -> + Nothing -> Nothing + (Just (Perfwrapper perfFreq perfLimit)) -> Just $ c & #downstreamCmds . at downstreamCmdClientID ?~ DownstreamCmd - { maxValue = perfLimit, - ratelimit = perfFreq, + { maxValue = Operations (fromInteger perfLimit), + ratelimit = toFrequency perfFreq, dtLastReferenceMeasurements = MemBuffer.empty, lastRead = Nothing } @@ -127,7 +127,7 @@ addDownstreamThreadClient c downstreamThreadClientID = c ^. #cmdCore . #manifest . #app . #instrumentation <&> \(Manifest.Instrumentation ratelimit) -> c & #downstreamThreads . at downstreamThreadClientID ?~ DownstreamThread { maxValue = 1 & progress, - ratelimit = ratelimit, + ratelimit = toFrequency ratelimit, dtLastReferenceMeasurements = MemBuffer.empty, lastRead = Nothing } diff --git a/hsnrm/hsnrm/src/NRM/Types/Configuration.hs b/hsnrm/hsnrm/src/NRM/Types/Configuration.hs index b76e1eddf6de87fcd2e7e3de842feeff3b138aa3..3185c885f150c6cc43e9fd7e9b82502473987163 100644 --- a/hsnrm/hsnrm/src/NRM/Types/Configuration.hs +++ b/hsnrm/hsnrm/src/NRM/Types/Configuration.hs @@ -1,4 +1,6 @@ {-# LANGUAGE DerivingVia #-} +{-# LANGUAGE TemplateHaskell #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-partial-fields #-} -- | @@ -8,7 +10,6 @@ -- Maintainer : fre@freux.fr module NRM.Types.Configuration ( Cfg (..), - SliceRuntime (..), UpstreamCfg (..), DownstreamCfg (..), DaemonVerbosity (..), @@ -16,270 +17,508 @@ module NRM.Types.Configuration RaplCfg (..), HwmonCfg (..), ExtraPassiveSensor (..), + StaticActuatorKV (..), + PassiveSensorKV (..), + Power (..), + Tag (..), + Hint (..), + SensorBehavior (..), ExtraActuator (..), + LearnCfg (..), + toInterval, + toRange, + toAction, + toTime, + toFrequency, + toPower, jsonOptions, - examples, ) where +-- examples, + import CPD.Core +import CPD.Values import Data.Aeson import Data.Default -import Data.JSON.Schema +import Data.Either.Validation as V +import Data.JSON.Schema () import Data.MessagePack import Data.Yaml.Internal () import Dhall +import qualified Dhall.Core as Dhall +import Dhall.TH (HaskellType (..), makeHaskellTypes, staticDhallExpression) import NRM.Classes.Messaging import NRM.Orphans.Dhall () -import qualified NRM.Types.Cmd as Cmd -import NRM.Types.Controller -import NRM.Types.Sensor -import NRM.Types.Units +import qualified NRM.Types.Units as U import Numeric.Interval import Protolude -import Refined -import Refined.Unsafe - -data SliceRuntime = Singularity | Nodeos | Dummy - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON SliceRuntime - -data DaemonVerbosity = Error | Info | Debug - deriving (Eq, Ord, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON DaemonVerbosity - -data Cfg - = Cfg - { verbose :: DaemonVerbosity, - logfile :: Text, - hwloc :: Text, - perf :: Text, - argo_perf_wrapper :: Cmd.Command, - argo_nodeos_config :: Cmd.Command, - libnrmPath :: Maybe Text, - pmpi_lib :: Text, - singularity :: Bool, - dummy :: Bool, - nodeos :: Bool, - slice_runtime :: SliceRuntime, - downstreamCfg :: DownstreamCfg, - upstreamCfg :: UpstreamCfg, - raplCfg :: Maybe RaplCfg, - hwmonCfg :: HwmonCfg, - controlCfg :: ControlCfg, - activeSensorFrequency :: Frequency, - extraStaticPassiveSensors :: Map Text ExtraPassiveSensor, - extraStaticActuators :: Map Text ExtraActuator - } - deriving (Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Cfg - -data ExtraActuator - = ExtraActuator - { actuatorBinary :: Text, - actuatorArguments :: [Text], - actions :: [Discrete], - referenceAction :: Discrete - } - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON ExtraActuator - -data ExtraPassiveSensor - = ExtraPassiveSensor - { sensorBinary :: Text, - sensorArguments :: [Text], - range :: Interval Double, - tags :: [Tag], - sensorBehavior :: Cumulative - } - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON ExtraPassiveSensor - -data ControlCfg - = ControlCfg - { minimumControlInterval :: Time, - staticPower :: Power, - learnCfg :: LearnConfig, - speedThreshold :: Double, - referenceMeasurementRoundInterval :: Refined (GreaterThan 5) Int, - hint :: Hint - } - | FixedCommand - { fixedPower :: Power - } - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON ControlCfg - -data HwmonCfg - = HwmonCfg - { hwmonEnabled :: Bool, - hwmonPath :: Text - } - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON HwmonCfg - -data RaplCfg - = RaplCfg - { raplPath :: Text, - raplActions :: [Power], - referencePower :: Power - } - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON RaplCfg - -newtype DownstreamCfg - = DownstreamCfg - { downstreamBindAddress :: Text - } - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON DownstreamCfg - -data UpstreamCfg - = UpstreamCfg - { upstreamBindAddress :: Text, - pubPort :: Int, - rpcPort :: Int - } - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON UpstreamCfg - -instance Default ControlCfg where - def = ControlCfg - { minimumControlInterval = 0.1 & seconds, - staticPower = watts 200, - speedThreshold = 1.1, - learnCfg = Contextual (CtxCfg 4000), - referenceMeasurementRoundInterval = unsafeRefine 6, - hint = Full - } - -instance Default HwmonCfg where - def = HwmonCfg - { hwmonEnabled = True, - hwmonPath = "/sys/class/hwmon" - } - -instance Default RaplCfg where - def = RaplCfg - { raplPath = "/sys/devices/virtual/powercap/intel-rapl", - raplActions = watts <$> [100, 200], - referencePower = watts 250 - } - -instance Default DownstreamCfg where - def = DownstreamCfg {downstreamBindAddress = "ipc:///tmp/nrm-downstream-event"} + +instance MessagePack Integer where + + toObject = toObject . (fromInteger :: Integer -> Int) + + fromObject x = (toInteger :: Int -> Integer) <$> fromObject x + +makeHaskellTypes $ + let rPath :: Text + rPath = "(./dhall/types/nrmd.dhall)." + dRec :: Text -> Text -> HaskellType Text + dRec s path = SingleConstructor s s (rPath <> path) + dSum :: Text -> Text -> HaskellType Text + dSum s path = MultipleConstructors s (rPath <> path) + in [ dRec "Time" "Time", + dRec "Power" "Power", + dSum "DaemonVerbosity" "Verbosity", + dSum "Tag" "Tag", + dRec "Range" "Range", + dRec "Frequency" "Frequency", + dRec "HwmonCfg" "HwmonCfg", + dRec "ExtraActuator" "Actuator", + dRec "ActuatorValue" "ActuatorValue", + dSum "Hint" "Hint", + dRec "Cfg" "Cfg", + dSum "ControlCfg" "ControlCfg", + dSum "LearnCfg" "LearnCfg", + dRec "StaticActuatorKV" "StaticActuatorKV", + dRec "PassiveSensorKV" "PassiveSensorKV", + dRec "ExtraPassiveSensor" "PassiveSensor", + dRec "DownstreamCfg" "DownstreamCfg", + dSum "SensorBehavior" "SensorBehavior", + dRec "UpstreamCfg" "UpstreamCfg", + dRec "RaplCfg" "RaplCfg" + ] instance Default Cfg where - def = Cfg - { logfile = "/tmp/nrm.log", - hwloc = "hwloc", - perf = "perf", - argo_perf_wrapper = "nrm-perfwrapper", - argo_nodeos_config = "argo_nodeos_config", - libnrmPath = Nothing, - pmpi_lib = "pmpi_lib", - singularity = False, - dummy = True, - nodeos = False, - slice_runtime = Dummy, - downstreamCfg = def, - upstreamCfg = def, - raplCfg = Just def, - hwmonCfg = def, - verbose = NRM.Types.Configuration.Error, - controlCfg = FixedCommand (watts 250), - activeSensorFrequency = 1 & hz, - extraStaticPassiveSensors = [], - extraStaticActuators = [] - } - -instance Default UpstreamCfg where - def = UpstreamCfg - { upstreamBindAddress = "*", - pubPort = 2345, - rpcPort = 3456 - } + def = + let expr :: Dhall.Expr s a + expr = + $( staticDhallExpression $ + "let t = ./dhall/types/nrmd.dhall" + <> " in ./dhall/defaults/nrmd.dhall : t.Cfg" + ) + in (Dhall.extract (Dhall.auto :: Decoder Cfg) $! expr) + & \case + V.Failure _ -> panic "Error in default cfg" + V.Success a -> a + +toInterval :: Range -> Interval Double +toInterval r = upper r ... lower r + +toRange :: Interval Double -> Range +toRange i = Range (inf i) (sup i) + +toAction :: ActuatorValue -> Action +toAction (ActuatorValue i v) = Action (ActuatorID i) (DiscreteDouble v) + +toTime :: Time -> U.Time +toTime t@Time {} = U.uS $ microseconds t + +toFrequency :: Frequency -> U.Frequency +toFrequency t@Frequency {} = U.hz $ hertz t + +toPower :: Power -> U.Power +toPower t@Power {} = U.uW $ microwatts t + +deriving instance Generic UpstreamCfg + +deriving instance Eq UpstreamCfg + +deriving instance Ord UpstreamCfg + +deriving instance Show UpstreamCfg + +deriving instance MessagePack UpstreamCfg + +deriving instance FromDhall UpstreamCfg + +deriving instance ToDhall UpstreamCfg + +deriving via (GenericJSON UpstreamCfg) instance FromJSON UpstreamCfg + +deriving via (GenericJSON UpstreamCfg) instance ToJSON UpstreamCfg + +deriving via (GenericJSON UpstreamCfg) instance JSONSchema UpstreamCfg + +deriving instance Generic RaplCfg + +deriving instance Eq RaplCfg + +deriving instance Ord RaplCfg + +deriving instance Show RaplCfg + +deriving instance MessagePack RaplCfg + +deriving instance FromDhall RaplCfg + +deriving instance ToDhall RaplCfg + +deriving via (GenericJSON RaplCfg) instance FromJSON RaplCfg + +deriving via (GenericJSON RaplCfg) instance ToJSON RaplCfg + +deriving via (GenericJSON RaplCfg) instance JSONSchema RaplCfg + +deriving instance Generic HwmonCfg + +deriving instance Eq HwmonCfg + +deriving instance Ord HwmonCfg + +deriving instance Show HwmonCfg + +deriving instance MessagePack HwmonCfg + +deriving instance FromDhall HwmonCfg + +deriving instance ToDhall HwmonCfg + +deriving via (GenericJSON HwmonCfg) instance FromJSON HwmonCfg + +deriving via (GenericJSON HwmonCfg) instance ToJSON HwmonCfg + +deriving via (GenericJSON HwmonCfg) instance JSONSchema HwmonCfg + +deriving instance Generic Tag + +deriving instance Eq Tag + +deriving instance Ord Tag + +deriving instance Show Tag + +deriving instance MessagePack Tag + +deriving instance FromDhall Tag + +deriving instance ToDhall Tag + +deriving via (GenericJSON Tag) instance FromJSON Tag + +deriving via (GenericJSON Tag) instance ToJSON Tag + +deriving via (GenericJSON Tag) instance JSONSchema Tag + +deriving instance Generic SensorBehavior + +deriving instance Eq SensorBehavior + +deriving instance Ord SensorBehavior + +deriving instance Show SensorBehavior + +deriving instance MessagePack SensorBehavior + +deriving instance FromDhall SensorBehavior + +deriving instance ToDhall SensorBehavior + +deriving via (GenericJSON SensorBehavior) instance FromJSON SensorBehavior + +deriving via (GenericJSON SensorBehavior) instance ToJSON SensorBehavior + +deriving via (GenericJSON SensorBehavior) instance JSONSchema SensorBehavior + +deriving instance Generic Range + +deriving instance Eq Range + +deriving instance Ord Range + +deriving instance Show Range + +deriving instance MessagePack Range + +deriving instance FromDhall Range + +deriving instance ToDhall Range + +deriving via (GenericJSON Range) instance FromJSON Range + +deriving via (GenericJSON Range) instance ToJSON Range + +deriving via (GenericJSON Range) instance JSONSchema Range + +deriving instance Generic ExtraPassiveSensor + +deriving instance Eq ExtraPassiveSensor + +deriving instance Ord ExtraPassiveSensor + +deriving instance Show ExtraPassiveSensor + +deriving instance MessagePack ExtraPassiveSensor + +deriving instance FromDhall ExtraPassiveSensor + +deriving instance ToDhall ExtraPassiveSensor + +deriving via (GenericJSON ExtraPassiveSensor) instance FromJSON ExtraPassiveSensor + +deriving via (GenericJSON ExtraPassiveSensor) instance ToJSON ExtraPassiveSensor + +deriving via (GenericJSON ExtraPassiveSensor) instance JSONSchema ExtraPassiveSensor + +deriving instance Generic PassiveSensorKV + +deriving instance Eq PassiveSensorKV + +deriving instance Ord PassiveSensorKV + +deriving instance Show PassiveSensorKV + +deriving instance MessagePack PassiveSensorKV + +deriving instance FromDhall PassiveSensorKV + +deriving instance ToDhall PassiveSensorKV + +deriving via (GenericJSON PassiveSensorKV) instance FromJSON PassiveSensorKV + +deriving via (GenericJSON PassiveSensorKV) instance ToJSON PassiveSensorKV + +deriving via (GenericJSON PassiveSensorKV) instance JSONSchema PassiveSensorKV + +deriving instance Generic ExtraActuator + +deriving instance Eq ExtraActuator + +deriving instance Ord ExtraActuator + +deriving instance Show ExtraActuator + +deriving instance MessagePack ExtraActuator + +deriving instance FromDhall ExtraActuator + +deriving instance ToDhall ExtraActuator + +deriving via (GenericJSON ExtraActuator) instance FromJSON ExtraActuator + +deriving via (GenericJSON ExtraActuator) instance ToJSON ExtraActuator + +deriving via (GenericJSON ExtraActuator) instance JSONSchema ExtraActuator + +deriving instance Generic DownstreamCfg + +deriving instance Eq DownstreamCfg + +deriving instance Ord DownstreamCfg + +deriving instance Show DownstreamCfg + +deriving instance MessagePack DownstreamCfg + +deriving instance FromDhall DownstreamCfg + +deriving instance ToDhall DownstreamCfg + +deriving via (GenericJSON DownstreamCfg) instance FromJSON DownstreamCfg + +deriving via (GenericJSON DownstreamCfg) instance ToJSON DownstreamCfg + +deriving via (GenericJSON DownstreamCfg) instance JSONSchema DownstreamCfg + +deriving instance Generic StaticActuatorKV + +deriving instance Eq StaticActuatorKV + +deriving instance Ord StaticActuatorKV + +deriving instance Show StaticActuatorKV + +deriving instance MessagePack StaticActuatorKV + +deriving instance FromDhall StaticActuatorKV + +deriving instance ToDhall StaticActuatorKV + +deriving via (GenericJSON StaticActuatorKV) instance FromJSON StaticActuatorKV + +deriving via (GenericJSON StaticActuatorKV) instance ToJSON StaticActuatorKV + +deriving via (GenericJSON StaticActuatorKV) instance JSONSchema StaticActuatorKV + +deriving instance Generic Power + +deriving instance Eq Power + +deriving instance Ord Power + +deriving instance Show Power + +deriving instance MessagePack Power + +deriving instance FromDhall Power + +deriving instance ToDhall Power + +deriving via (GenericJSON Power) instance FromJSON Power + +deriving via (GenericJSON Power) instance ToJSON Power + +deriving via (GenericJSON Power) instance JSONSchema Power + +deriving instance Generic Time + +deriving instance Eq Time + +deriving instance Ord Time + +deriving instance Show Time + +deriving instance MessagePack Time + +deriving instance FromDhall Time + +deriving instance ToDhall Time + +deriving via (GenericJSON Time) instance FromJSON Time + +deriving via (GenericJSON Time) instance ToJSON Time + +deriving via (GenericJSON Time) instance JSONSchema Time + +deriving instance Generic Frequency + +deriving instance Eq Frequency + +deriving instance Ord Frequency + +deriving instance Show Frequency + +deriving instance MessagePack Frequency + +deriving instance FromDhall Frequency + +deriving instance ToDhall Frequency + +deriving via (GenericJSON Frequency) instance FromJSON Frequency + +deriving via (GenericJSON Frequency) instance ToJSON Frequency + +deriving via (GenericJSON Frequency) instance JSONSchema Frequency + +deriving instance Generic Hint + +deriving instance Eq Hint + +deriving instance Ord Hint + +deriving instance Show Hint + +deriving instance MessagePack Hint + +deriving instance FromDhall Hint + +deriving instance ToDhall Hint + +deriving via (GenericJSON Hint) instance FromJSON Hint + +deriving via (GenericJSON Hint) instance ToJSON Hint + +deriving via (GenericJSON Hint) instance JSONSchema Hint + +deriving instance Generic LearnCfg + +deriving instance Eq LearnCfg + +deriving instance Ord LearnCfg + +deriving instance Show LearnCfg + +deriving instance MessagePack LearnCfg + +deriving instance FromDhall LearnCfg + +deriving instance ToDhall LearnCfg + +deriving via (GenericJSON LearnCfg) instance FromJSON LearnCfg + +deriving via (GenericJSON LearnCfg) instance ToJSON LearnCfg + +deriving via (GenericJSON LearnCfg) instance JSONSchema LearnCfg + +deriving instance Generic ActuatorValue + +deriving instance Eq ActuatorValue + +deriving instance Ord ActuatorValue + +deriving instance Show ActuatorValue + +deriving instance MessagePack ActuatorValue + +deriving instance FromDhall ActuatorValue + +deriving instance ToDhall ActuatorValue + +deriving via (GenericJSON ActuatorValue) instance FromJSON ActuatorValue + +deriving via (GenericJSON ActuatorValue) instance ToJSON ActuatorValue + +deriving via (GenericJSON ActuatorValue) instance JSONSchema ActuatorValue + +deriving instance Generic ControlCfg + +deriving instance Eq ControlCfg + +deriving instance Ord ControlCfg + +deriving instance Show ControlCfg + +deriving instance MessagePack ControlCfg + +deriving instance FromDhall ControlCfg + +deriving instance ToDhall ControlCfg + +deriving via (GenericJSON ControlCfg) instance FromJSON ControlCfg + +deriving via (GenericJSON ControlCfg) instance ToJSON ControlCfg + +deriving via (GenericJSON ControlCfg) instance JSONSchema ControlCfg + +deriving instance Generic DaemonVerbosity + +deriving instance Eq DaemonVerbosity + +deriving instance Ord DaemonVerbosity + +deriving instance Show DaemonVerbosity + +deriving instance MessagePack DaemonVerbosity + +deriving instance FromDhall DaemonVerbosity + +deriving instance ToDhall DaemonVerbosity + +deriving via (GenericJSON DaemonVerbosity) instance FromJSON DaemonVerbosity + +deriving via (GenericJSON DaemonVerbosity) instance ToJSON DaemonVerbosity + +deriving via (GenericJSON DaemonVerbosity) instance JSONSchema DaemonVerbosity + +deriving instance Generic Cfg + +deriving instance Eq Cfg + +deriving instance Ord Cfg + +deriving instance Show Cfg + +deriving instance MessagePack Cfg + +deriving instance FromDhall Cfg + +deriving instance ToDhall Cfg + +deriving via (GenericJSON Cfg) instance FromJSON Cfg + +deriving via (GenericJSON Cfg) instance ToJSON Cfg + +deriving via (GenericJSON Cfg) instance JSONSchema Cfg jsonOptions :: Options jsonOptions = defaultOptions {omitNothingFields = True} - -examples :: Map Text Cfg -examples = - [ ( "control", - def - { controlCfg = def - } - ), - ( "extra-static-sensor", - def - { extraStaticPassiveSensors = - [ ( "example extra static passive power sensor", - ExtraPassiveSensor - { sensorBinary = "echo", - sensorArguments = ["30"], - sensorBehavior = IntervalBased, - range = 1 ... 40, - tags = [Power] - } - ) - ] - } - ), - ( "extra-static-actuator", - def - { extraStaticActuators = - [ ( "example extra actuator", - ExtraActuator - { actuatorBinary = "bash", - actuatorArguments = ["-c", "echo $@ >> /tmp/test-nrm-example-extra-actuator", "-o"], - actions = [DiscreteDouble 1, DiscreteDouble 2], - referenceAction = DiscreteDouble 1 - } - ) - ] - } - ), - ( "variorum-two-package-power-limit-sensor", - def {extraStaticPassiveSensors = [mkVariorumPowerLimitSensor 0, mkVariorumPowerLimitSensor 1]} - ), - ( "variorum-two-package-power-value-sensor", - def {extraStaticPassiveSensors = [mkVariorumPowerSensor 0, mkVariorumPowerSensor 1]} - ), - ( "variorum-two-package-power-limits-actuator", - def - { extraStaticActuators = - [ ( "example extra actuator", - ExtraActuator - { actuatorBinary = "variorum-set-socket-power-limits-example", - actuatorArguments = [], - actions = [DiscreteDouble 100, DiscreteDouble 150], - referenceAction = DiscreteDouble 100 - } - ) - ] - } - ) - ] - where - mkVariorumPowerLimitSensor :: Int -> (Text, ExtraPassiveSensor) - mkVariorumPowerLimitSensor x = - ( "Sensor that gets package power limits for package " <> show x <> " through variorum", - ExtraPassiveSensor - { sensorBinary = "bash", - sensorArguments = ["-c", "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_POWER_LIMITS\" && $2 == \"0x610\" && $4 == " <> show x <> " ) { print $6 } }'"], - sensorBehavior = IntervalBased, - range = 1 ... 40, - tags = [] - } - ) - mkVariorumPowerSensor :: Int -> (Text, ExtraPassiveSensor) - mkVariorumPowerSensor x = - ( "Sensor that gets package power limits for package " <> show x <> " through variorum", - ExtraPassiveSensor - { sensorBinary = "bash", - sensorArguments = ["-c", "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_ENERGY_STATUS\" && $2 == \"0x610\" && $4 == " <> show x <> " ) { print $6 } }'"], - sensorBehavior = Cumulative, - range = 1 ... 40, - tags = [Power] - } - ) diff --git a/hsnrm/hsnrm/src/NRM/Types/Controller.hs b/hsnrm/hsnrm/src/NRM/Types/Controller.hs index 520cffbaedeb0e0034a8450dc7d85bd033526d06..aa75bb1ba031920007755609ca7343e9cd6cd9df 100644 --- a/hsnrm/hsnrm/src/NRM/Types/Controller.hs +++ b/hsnrm/hsnrm/src/NRM/Types/Controller.hs @@ -20,7 +20,6 @@ module NRM.Types.Controller LearnConfig, LagrangeMultiplier (..), CtxCfg (..), - Hint (..), Seed (..), Uniform (..), UniformCfg (..), @@ -111,10 +110,6 @@ newtype CtxCfg = CtxCfg {horizon :: Int} deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON CtxCfg -data Hint = Full | Only {only :: NonEmpty [Action]} - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Hint - newtype Actions = Actions [V.Action] deriving ( MessagePack, diff --git a/hsnrm/hsnrm/src/NRM/Types/DownstreamCmd.hs b/hsnrm/hsnrm/src/NRM/Types/DownstreamCmd.hs index 4dacc47dd3fb7cdcf9ccb1e1aa3c533c4c6d0114..fe93b8257b790fb061aaef734cc14230a03de1d9 100644 --- a/hsnrm/hsnrm/src/NRM/Types/DownstreamCmd.hs +++ b/hsnrm/hsnrm/src/NRM/Types/DownstreamCmd.hs @@ -18,6 +18,7 @@ import Data.Map as M import Data.MessagePack import LensMap.Core import NRM.Classes.Messaging +import qualified NRM.Types.Configuration as Cfg import NRM.Types.DownstreamCmdID import NRM.Types.MemBuffer import NRM.Types.Sensor @@ -54,7 +55,7 @@ instance range = 0 ... (maxValue downstreamCmd & fromOps & fromIntegral), lastReferenceMeasurements = dtLastRef, last = lastRead <&> fmap (fromIntegral . fromProgress), - cumulative = IntervalBased + cumulative = Cfg.IntervalBased }, maxFrequency = ratelimit, process = identity diff --git a/hsnrm/hsnrm/src/NRM/Types/DownstreamThread.hs b/hsnrm/hsnrm/src/NRM/Types/DownstreamThread.hs index eaa5ebd05939efaf54e76e356b462cfde7aebc3d..d6b760224ecad0231dd4105d9714c052ebeed744 100644 --- a/hsnrm/hsnrm/src/NRM/Types/DownstreamThread.hs +++ b/hsnrm/hsnrm/src/NRM/Types/DownstreamThread.hs @@ -18,6 +18,7 @@ import Data.Map as M import Data.MessagePack import LensMap.Core import NRM.Classes.Messaging +import qualified NRM.Types.Configuration as Cfg import NRM.Types.DownstreamThreadID import NRM.Types.MemBuffer import NRM.Types.Sensor @@ -52,7 +53,7 @@ instance range = 0 ... (maxValue downstreamThread & fromProgress & fromIntegral), lastReferenceMeasurements = dtLastRef, last = lastRead <&> fmap (fromIntegral . fromProgress), - cumulative = IntervalBased + cumulative = Cfg.IntervalBased }, maxFrequency = ratelimit, process = identity diff --git a/hsnrm/hsnrm/src/NRM/Types/Manifest.hs b/hsnrm/hsnrm/src/NRM/Types/Manifest.hs index 4a7861dedf16915d7fbfcd8685bf302abac26cfc..4f4bb3a6aca53180cc1e7777ed57f6adc755e629 100644 --- a/hsnrm/hsnrm/src/NRM/Types/Manifest.hs +++ b/hsnrm/hsnrm/src/NRM/Types/Manifest.hs @@ -1,4 +1,5 @@ {-# LANGUAGE DerivingVia #-} +{-# LANGUAGE TemplateHaskell #-} {-# OPTIONS_GHC -fno-warn-orphans #-} {-# OPTIONS_GHC -fno-warn-partial-fields #-} @@ -13,141 +14,65 @@ module NRM.Types.Manifest Slice (..), Scheduler (..), PowerPolicy (..), - Power (..), + PowerCfg (..), Instrumentation (..), ImageType (..), Perfwrapper (..), Image (..), + toFrequency, jsonOptions, - examples, ) where import Data.Aeson -import Data.Data import Data.Default +import Data.Either.Validation as V import Data.JSON.Schema import Data.MessagePack import Data.Yaml.Internal () import Dhall +import qualified Dhall.Core as Dhall +import Dhall.TH (HaskellType (..), makeHaskellTypes, staticDhallExpression) import Generics.Generic.Aeson () import NRM.Classes.Messaging import qualified NRM.Types.Units as U import Protolude -data Manifest - = Manifest - { name :: Text, - app :: App, - hwbind :: Bool, - image :: Maybe Image - } - deriving (Eq, Show, Generic, Data, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Manifest - -data SliceRuntime = Singularity | Nodeos | Dummy - deriving (Eq, Show, Generic, Data, MessagePack, Interpret) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON SliceRuntime - -data App - = App - { slice :: Slice, - scheduler :: Scheduler, - perfwrapper :: Perfwrapper, - power :: Power, - instrumentation :: Maybe Instrumentation - } - deriving (Eq, Show, Generic, Data, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON App - -data Slice - = Slice - { cpus :: Integer, - mems :: Integer - } - deriving (Eq, Show, Generic, Data, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Slice - -data Scheduler = FIFO | HPC | Other Integer - deriving (Eq, Show, Generic, Data, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Scheduler - -data PowerPolicy = NoPowerPolicy | DDCM | DVFS | Combined - deriving (Eq, Show, Generic, Data, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON PowerPolicy - -data Power - = Power - { policy :: PowerPolicy, - profile :: Bool, - slowdown :: Integer - } - deriving (Eq, Show, Generic, Data, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Power - -data Perfwrapper - = PerfwrapperDisabled - | Perfwrapper - { perfFreq :: U.Frequency, - perfLimit :: U.Operations - } - deriving (Eq, Show, Generic, Data, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Perfwrapper - -newtype Instrumentation - = Instrumentation - { ratelimit :: U.Frequency - } - deriving (Eq, Show, Generic, Data, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Instrumentation - -data ImageType = Sif | Docker - deriving (Eq, Show, Generic, Data, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON ImageType - -data Image - = Image - { path :: Text, - imagetype :: ImageType, - binds :: Maybe [Text] - } - deriving (Eq, Show, Generic, Data, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Image +makeHaskellTypes $ + let rPath :: Text + rPath = "(./dhall/types/manifest.dhall)." + dRec :: Text -> Text -> HaskellType Text + dRec s path = SingleConstructor s s (rPath <> path) + dSum :: Text -> Text -> HaskellType Text + dSum s path = MultipleConstructors s (rPath <> path) + in [ dSum "Scheduler" "Scheduler", + dRec "Frequency" "Frequency", + dRec "Perfwrapper" "Perfwrapper", + dSum "ImageType" "ImageType", + dRec "Image" "Image", + dSum "PowerPolicy" "PowerPolicy", + dRec "Slice" "Slice", + dRec "PowerCfg" "PowerCfg", + dRec "Instrumentation" "Instrumentation", + dRec "App" "App", + dRec "Manifest" "Manifest" + ] + +toFrequency :: Frequency -> U.Frequency +toFrequency t@Frequency {} = U.hz $ hertz t instance Default Manifest where - def = Manifest - { name = "default", - app = def, - hwbind = False, - image = def - } - -instance Default Power where - def = Power - { policy = NoPowerPolicy, - profile = False, - slowdown = 1 - } - -instance Default App where - def = App - { slice = def, - scheduler = FIFO, - perfwrapper = def, - power = def, - instrumentation = Nothing - } - -instance Default Perfwrapper where - def = PerfwrapperDisabled - -instance Default Instrumentation where - def = Instrumentation - { ratelimit = U.hz 10000000 - } - -instance Default Slice where - def = Slice {cpus = 1, mems = 1} + def = + let expr :: Dhall.Expr s a + expr = + $( staticDhallExpression $ + "let t = ./dhall/types/manifest.dhall" + <> " in ./dhall/defaults/manifest.dhall : t.Manifest" + ) + in (Dhall.extract (Dhall.auto :: Decoder Manifest) $! expr) + & \case + V.Failure _ -> panic "Error in default cfg" + V.Success a -> a jsonOptions :: Options jsonOptions = defaultOptions {omitNothingFields = True} @@ -158,27 +83,222 @@ instance MessagePack Integer where fromObject x = (toInteger :: Int -> Integer) <$> fromObject x -examples :: Map Text Manifest -examples = - [ ( "perfwrap", - def - { app = - def - { perfwrapper = Perfwrapper - { perfFreq = U.hz 1, - perfLimit = U.Operations 100000 - } - } - } - ), - ( "libnrm", - def - { app = - def - { instrumentation = Just $ Instrumentation - { ratelimit = U.hz 1000000 - } - } - } - ) - ] +deriving instance Generic Scheduler + +deriving instance Eq Scheduler + +deriving instance Ord Scheduler + +deriving instance Show Scheduler + +deriving instance MessagePack Scheduler + +deriving instance FromDhall Scheduler + +deriving instance ToDhall Scheduler + +deriving via (GenericJSON Scheduler) instance FromJSON Scheduler + +deriving via (GenericJSON Scheduler) instance ToJSON Scheduler + +deriving via (GenericJSON Scheduler) instance JSONSchema Scheduler + +deriving instance Generic Frequency + +deriving instance Eq Frequency + +deriving instance Ord Frequency + +deriving instance Show Frequency + +deriving instance MessagePack Frequency + +deriving instance FromDhall Frequency + +deriving instance ToDhall Frequency + +deriving via (GenericJSON Frequency) instance FromJSON Frequency + +deriving via (GenericJSON Frequency) instance ToJSON Frequency + +deriving via (GenericJSON Frequency) instance JSONSchema Frequency + +deriving instance Generic Perfwrapper + +deriving instance Eq Perfwrapper + +deriving instance Ord Perfwrapper + +deriving instance Show Perfwrapper + +deriving instance MessagePack Perfwrapper + +deriving instance FromDhall Perfwrapper + +deriving instance ToDhall Perfwrapper + +deriving via (GenericJSON Perfwrapper) instance FromJSON Perfwrapper + +deriving via (GenericJSON Perfwrapper) instance ToJSON Perfwrapper + +deriving via (GenericJSON Perfwrapper) instance JSONSchema Perfwrapper + +deriving instance Generic ImageType + +deriving instance Eq ImageType + +deriving instance Ord ImageType + +deriving instance Show ImageType + +deriving instance MessagePack ImageType + +deriving instance FromDhall ImageType + +deriving instance ToDhall ImageType + +deriving via (GenericJSON ImageType) instance FromJSON ImageType + +deriving via (GenericJSON ImageType) instance ToJSON ImageType + +deriving via (GenericJSON ImageType) instance JSONSchema ImageType + +deriving instance Generic Image + +deriving instance Eq Image + +deriving instance Ord Image + +deriving instance Show Image + +deriving instance MessagePack Image + +deriving instance FromDhall Image + +deriving instance ToDhall Image + +deriving via (GenericJSON Image) instance FromJSON Image + +deriving via (GenericJSON Image) instance ToJSON Image + +deriving via (GenericJSON Image) instance JSONSchema Image + +deriving instance Generic PowerPolicy + +deriving instance Eq PowerPolicy + +deriving instance Ord PowerPolicy + +deriving instance Show PowerPolicy + +deriving instance MessagePack PowerPolicy + +deriving instance FromDhall PowerPolicy + +deriving instance ToDhall PowerPolicy + +deriving via (GenericJSON PowerPolicy) instance FromJSON PowerPolicy + +deriving via (GenericJSON PowerPolicy) instance ToJSON PowerPolicy + +deriving via (GenericJSON PowerPolicy) instance JSONSchema PowerPolicy + +deriving instance Generic Slice + +deriving instance Eq Slice + +deriving instance Ord Slice + +deriving instance Show Slice + +deriving instance MessagePack Slice + +deriving instance FromDhall Slice + +deriving instance ToDhall Slice + +deriving via (GenericJSON Slice) instance FromJSON Slice + +deriving via (GenericJSON Slice) instance ToJSON Slice + +deriving via (GenericJSON Slice) instance JSONSchema Slice + +deriving instance Generic PowerCfg + +deriving instance Eq PowerCfg + +deriving instance Ord PowerCfg + +deriving instance Show PowerCfg + +deriving instance MessagePack PowerCfg + +deriving instance FromDhall PowerCfg + +deriving instance ToDhall PowerCfg + +deriving via (GenericJSON PowerCfg) instance FromJSON PowerCfg + +deriving via (GenericJSON PowerCfg) instance ToJSON PowerCfg + +deriving via (GenericJSON PowerCfg) instance JSONSchema PowerCfg + +deriving instance Generic Instrumentation + +deriving instance Eq Instrumentation + +deriving instance Ord Instrumentation + +deriving instance Show Instrumentation + +deriving instance MessagePack Instrumentation + +deriving instance FromDhall Instrumentation + +deriving instance ToDhall Instrumentation + +deriving via (GenericJSON Instrumentation) instance FromJSON Instrumentation + +deriving via (GenericJSON Instrumentation) instance ToJSON Instrumentation + +deriving via (GenericJSON Instrumentation) instance JSONSchema Instrumentation + +deriving instance Generic App + +deriving instance Eq App + +deriving instance Ord App + +deriving instance Show App + +deriving instance MessagePack App + +deriving instance FromDhall App + +deriving instance ToDhall App + +deriving via (GenericJSON App) instance FromJSON App + +deriving via (GenericJSON App) instance ToJSON App + +deriving via (GenericJSON App) instance JSONSchema App + +deriving instance Generic Manifest + +deriving instance Eq Manifest + +deriving instance Ord Manifest + +deriving instance Show Manifest + +deriving instance MessagePack Manifest + +deriving instance FromDhall Manifest + +deriving instance ToDhall Manifest + +deriving via (GenericJSON Manifest) instance FromJSON Manifest + +deriving via (GenericJSON Manifest) instance ToJSON Manifest + +deriving via (GenericJSON Manifest) instance JSONSchema Manifest diff --git a/hsnrm/hsnrm/src/NRM/Types/Sensor.hs b/hsnrm/hsnrm/src/NRM/Types/Sensor.hs index dee8840c81c36ba3ba0b7be00544f4a7d6ff4041..7959b3eb5b8e666c3ed927ad8c5de396c5295ba5 100644 --- a/hsnrm/hsnrm/src/NRM/Types/Sensor.hs +++ b/hsnrm/hsnrm/src/NRM/Types/Sensor.hs @@ -13,7 +13,6 @@ module NRM.Types.Sensor PassiveSensor (..), SensorMeta (..), HasMeta (..), - Cumulative (..), -- * Keys for LensMap ActiveSensorKey (..), @@ -27,13 +26,10 @@ where import qualified CPD.Core as CPD import Control.Lens -import Data.Aeson import Data.Generics.Labels () -import Data.JSON.Schema -import Data.MessagePack import Dhall -import NRM.Classes.Messaging import NRM.Classes.Sensors +import NRM.Types.Configuration (SensorBehavior (..), Tag (..)) import NRM.Types.DownstreamCmdID import NRM.Types.DownstreamThreadID import NRM.Types.MemBuffer @@ -42,24 +38,13 @@ import qualified NRM.Types.Units as U import Numeric.Interval import Protolude --- | Sensor tags - used to build objectives and constraints. -data Tag - = Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Tag - data SensorMeta = SensorMeta { tags :: [Tag], range :: Interval Double, last :: Maybe (U.Time, Double), lastReferenceMeasurements :: MemBuffer, - cumulative :: Cumulative + cumulative :: SensorBehavior } deriving (Generic) @@ -88,10 +73,6 @@ data ActiveSensor instance HasMeta ActiveSensor where _meta = #activeMeta -data Cumulative = Cumulative | IntervalBased | CumulativeWithCapacity Double - deriving (Eq, Show, Generic, MessagePack, Interpret, Inject) - deriving (JSONSchema, ToJSON, FromJSON) via GenericJSON Cumulative - data ActiveSensorKey = DownstreamCmdKey DownstreamCmdID | DownstreamThreadKey DownstreamThreadID deriving (Ord, Eq, Show) diff --git a/hsnrm/hsnrm/src/NRM/Types/State.hs b/hsnrm/hsnrm/src/NRM/Types/State.hs index d54d0604c65a31b9f818dd833d774e0e71dfe41c..09a9aafbbe4aac09389dc7577d5855a8eef36fb6 100644 --- a/hsnrm/hsnrm/src/NRM/Types/State.hs +++ b/hsnrm/hsnrm/src/NRM/Types/State.hs @@ -1,3 +1,5 @@ +{-# OPTIONS_GHC -fno-warn-orphans #-} + -- | -- Module : NRM.Types.State -- Copyright : (c) UChicago Argonne, 2019 @@ -5,7 +7,6 @@ -- Maintainer : fre@freux.fr module NRM.Types.State ( NRMState (..), - ExtraActuator (..), ExtraPassiveSensor (..), -- * Useful maps @@ -26,7 +27,6 @@ module NRM.Types.State ) where -import qualified CPD.Core as CPD import Control.Lens import Data.Aeson hiding ((.=)) import Data.Coerce @@ -67,14 +67,11 @@ data NRMState singularityRuntime :: Maybe SingularityRuntime, nodeosRuntime :: Maybe NodeosRuntime, controller :: Maybe Controller, - extraStaticActuators :: Map Text ExtraActuator, + extraStaticActuators :: Map Text Cfg.ExtraActuator, extraStaticPassiveSensors :: Map Text ExtraPassiveSensor } deriving (Show, Generic, MessagePack, ToJSON, FromJSON) -newtype ExtraActuator = ExtraActuator {getExtraActuator :: Cfg.ExtraActuator} - deriving (Show, Generic, MessagePack, ToJSON, FromJSON) - type Parser = Parsec Void Text sc :: Parser () @@ -87,7 +84,7 @@ sc = lexeme :: Parser a -> Parser a lexeme = L.lexeme sc -instance HasLensMap (Text, ExtraActuator) A.ActuatorKey A.Actuator where +instance HasLensMap (Text, Cfg.ExtraActuator) A.ActuatorKey A.Actuator where lenses (actuatorID, _) = M.singleton (A.ExtraActuatorKey actuatorID) @@ -95,17 +92,21 @@ instance HasLensMap (Text, ExtraActuator) A.ActuatorKey A.Actuator where (_2 . lens getter setter) ) where - getter :: ExtraActuator -> A.Actuator + getter :: Cfg.ExtraActuator -> A.Actuator getter (coerce -> extraActuator) = A.Actuator - { actions = Cfg.actions extraActuator <&> CPD.getDiscrete, - referenceAction = CPD.getDiscrete $ Cfg.referenceAction extraActuator, - go = \value -> runProcess_ $ System.Process.Typed.proc (toS $ Cfg.actuatorBinary extraActuator) ((toS <$> Cfg.actuatorArguments extraActuator) <> [show value]) + { actions = Cfg.actions extraActuator, + referenceAction = Cfg.referenceAction extraActuator, + go = \value -> + runProcess_ $ + System.Process.Typed.proc + (toS $ Cfg.actuatorBinary extraActuator) + ((toS <$> Cfg.actuatorArguments extraActuator) <> [show value]) } - setter :: ExtraActuator -> A.Actuator -> ExtraActuator - setter (getExtraActuator -> oldExtraActuator) actuator = coerce $ + setter :: Cfg.ExtraActuator -> A.Actuator -> Cfg.ExtraActuator + setter oldExtraActuator actuator = coerce $ oldExtraActuator &~ do - #referenceAction . #_DiscreteDouble .= A.referenceAction actuator - #actions .= (A.actions actuator <&> CPD.DiscreteDouble) + #referenceAction .= A.referenceAction actuator + #actions .= A.actions actuator data ExtraPassiveSensor = ExtraPassiveSensor @@ -116,7 +117,12 @@ data ExtraPassiveSensor } deriving (Eq, Show, Generic, MessagePack, ToJSON, FromJSON) -instance HasLensMap (Text, ExtraPassiveSensor) PassiveSensorKey PassiveSensor where +instance + HasLensMap + (Text, ExtraPassiveSensor) + PassiveSensorKey + PassiveSensor + where lenses (sensorID, _) = M.singleton (S.ExtraPassiveSensorKey sensorID) @@ -129,15 +135,15 @@ instance HasLensMap (Text, ExtraPassiveSensor) PassiveSensorKey PassiveSensor wh S.PassiveSensor { passiveMeta = S.SensorMeta { tags = Cfg.tags extraPassiveSensor, - range = Cfg.range extraPassiveSensor, + range = Cfg.toInterval $ Cfg.range extraPassiveSensor, lastReferenceMeasurements = history, last = lastRead, cumulative = Cfg.sensorBehavior extraPassiveSensor }, frequency = frequency, perform = - -- this megaparsec-based code might be given a module and improved if/when the - -- need arises + -- this megaparsec-based code might be given a module and improved + -- if/when the need arises fmap toRealFloat . parseMaybe (lexeme L.scientific) . toS @@ -150,7 +156,8 @@ instance HasLensMap (Text, ExtraPassiveSensor) PassiveSensorKey PassiveSensor wh setter :: ExtraPassiveSensor -> S.PassiveSensor -> ExtraPassiveSensor setter p passiveSensor = p &~ do - #extraPassiveSensor . #range .= passiveSensor ^. S._meta . #range + #extraPassiveSensor . #range + .= Cfg.toRange (passiveSensor ^. S._meta . #range) #history .= passiveSensor ^. S._meta . #lastReferenceMeasurements #lastRead .= passiveSensor ^. S._meta . #last diff --git a/hsnrm/hsnrm/src/NRM/Types/Topology/Package.hs b/hsnrm/hsnrm/src/NRM/Types/Topology/Package.hs index 7581d4a9d8116ed099082bb1019925ca05ec5483..72001a564d58b53ff782a1ec12cc203f18f1da44 100644 --- a/hsnrm/hsnrm/src/NRM/Types/Topology/Package.hs +++ b/hsnrm/hsnrm/src/NRM/Types/Topology/Package.hs @@ -21,6 +21,7 @@ import LensMap.Core import NRM.Node.Sysfs import NRM.Node.Sysfs.Internal import NRM.Types.Actuator as A +import qualified NRM.Types.Configuration as Cfg import NRM.Types.MemBuffer import NRM.Types.Sensor as S import NRM.Types.Topology.PackageID @@ -91,11 +92,11 @@ instance HasLensMap (PackageID, Package) S.PassiveSensorKey S.PassiveSensor wher getter (NRM.Types.Topology.Package.Rapl cfg maxPower maxCounter freq _discreteChoices _defaultPower lastRead history) = S.PassiveSensor { passiveMeta = S.SensorMeta - { tags = [S.Minimize, S.Power, S.Rapl], + { tags = [Cfg.Minimize, Cfg.TagPower, Cfg.Rapl], range = 0 ... fromWatts maxPower, S.lastReferenceMeasurements = history, last = lastRead <&> fmap fromJoules, - cumulative = S.CumulativeWithCapacity (fromJoules maxCounter) + cumulative = Cfg.CumulativeWithCapacity (fromJoules maxCounter) }, frequency = freq, perform = measureRAPLDir (configPath cfg) <&> fmap (fromJoules . energy) diff --git a/hsnrm/resources/defaults/Cfg.dhall b/hsnrm/resources/defaults/Cfg.dhall deleted file mode 100644 index dcf1afc2e61bd89e5839875b1f01dcca164dbb7d..0000000000000000000000000000000000000000 --- a/hsnrm/resources/defaults/Cfg.dhall +++ /dev/null @@ -1,92 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ verbose = < Error | Info | Debug >.Error -, logfile = "/tmp/nrm.log" -, hwloc = "hwloc" -, perf = "perf" -, argo_perf_wrapper = "nrm-perfwrapper" -, argo_nodeos_config = "argo_nodeos_config" -, libnrmPath = None Text -, pmpi_lib = "pmpi_lib" -, singularity = False -, dummy = True -, nodeos = False -, slice_runtime = < Singularity | Nodeos | Dummy >.Dummy -, downstreamCfg = { downstreamBindAddress = "ipc:///tmp/nrm-downstream-event" } -, upstreamCfg = { upstreamBindAddress = "*", pubPort = +2345, rpcPort = +3456 } -, raplCfg = Some - { raplPath = "/sys/devices/virtual/powercap/intel-rapl" - , raplActions = [ { fromuW = 1.0e8 }, { fromuW = 2.0e8 } ] - , referencePower = { fromuW = 2.5e8 } - } -, hwmonCfg = { hwmonEnabled = True, hwmonPath = "/sys/class/hwmon" } -, controlCfg = - < ControlCfg : - { minimumControlInterval : { fromuS : Double } - , staticPower : { fromuW : Double } - , learnCfg : - < Lagrange : { lagrange : Double } - | Random : { random : Optional Integer } - | Contextual : { contextual : { horizon : Integer } } - > - , speedThreshold : Double - , referenceMeasurementRoundInterval : Integer - , hint : - < Full - | Only : - { only : - { neHead : - List { actuatorID : Text, actuatorValue : Double } - , neTail : - List - (List { actuatorID : Text, actuatorValue : Double }) - } - } - > - } - | FixedCommand : { fixedPower : { fromuW : Double } } - >.FixedCommand - { fixedPower = { fromuW = 2.5e8 } } -, activeSensorFrequency = { fromHz = 1.0 } -, extraStaticPassiveSensors = - [] : List - { mapKey : Text - , mapValue : - { sensorBinary : Text - , sensorArguments : List Text - , range : < I : { _1 : Double, _2 : Double } | Empty > - , tags : - List - < Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - > - , sensorBehavior : - < Cumulative - | IntervalBased - | CumulativeWithCapacity : Double - > - } - } -, extraStaticActuators = - [] : List - { mapKey : Text - , mapValue : - { actuatorBinary : Text - , actuatorArguments : List Text - , actions : List Double - , referenceAction : Double - } - } -} diff --git a/hsnrm/resources/defaults/Cfg.yaml b/hsnrm/resources/defaults/Cfg.yaml deleted file mode 100644 index 1880b5ff95883a089d9504432549b48578092ed5..0000000000000000000000000000000000000000 --- a/hsnrm/resources/defaults/Cfg.yaml +++ /dev/null @@ -1,44 +0,0 @@ -# ****************************************************************************** -# Copyright 2019 UChicago Argonne, LLC. -# (c.f. AUTHORS, LICENSE) -# -# SPDX-License-Identifier: BSD-3-Clause -# ****************************************************************************** -# -# this file is generated, modifications will be erased. -# -extraStaticPassiveSensors: [] -pmpi_lib: pmpi_lib -verbose: Error -logfile: /tmp/nrm.log -singularity: false -argo_nodeos_config: argo_nodeos_config -controlCfg: - fixedPower: - fromuW: 2.5e8 -upstreamCfg: - upstreamBindAddress: '*' - rpcPort: 3456 - pubPort: 2345 -libnrmPath: null -activeSensorFrequency: - fromHz: 1 -perf: perf -argo_perf_wrapper: nrm-perfwrapper -downstreamCfg: - downstreamBindAddress: ipc:///tmp/nrm-downstream-event -nodeos: false -hwloc: hwloc -extraStaticActuators: [] -raplCfg: - referencePower: - fromuW: 2.5e8 - raplActions: - - fromuW: 1.0e8 - - fromuW: 2.0e8 - raplPath: /sys/devices/virtual/powercap/intel-rapl -dummy: true -slice_runtime: Dummy -hwmonCfg: - hwmonPath: /sys/class/hwmon - hwmonEnabled: true diff --git a/hsnrm/resources/defaults/Manifest.dhall b/hsnrm/resources/defaults/Manifest.dhall deleted file mode 100644 index f9c9069f233ae1c6b1448438e1b87b2329f0457d..0000000000000000000000000000000000000000 --- a/hsnrm/resources/defaults/Manifest.dhall +++ /dev/null @@ -1,36 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ name = "default" -, app = - { slice = { cpus = +1, mems = +1 } - , scheduler = < FIFO | HPC | Other : Integer >.FIFO - , perfwrapper = - < PerfwrapperDisabled - | Perfwrapper : - { perfFreq : { fromHz : Double } - , perfLimit : { fromOps : Integer } - } - >.PerfwrapperDisabled - , power = - { policy = < NoPowerPolicy | DDCM | DVFS | Combined >.NoPowerPolicy - , profile = False - , slowdown = +1 - } - , instrumentation = None { ratelimit : { fromHz : Double } } - } -, hwbind = False -, image = - None - { path : Text - , imagetype : < Sif | Docker > - , binds : Optional (List Text) - } -} diff --git a/hsnrm/resources/defaults/Manifest.yaml b/hsnrm/resources/defaults/Manifest.yaml deleted file mode 100644 index 6419062c49e431288893d6ad98765d4e9cd7de2b..0000000000000000000000000000000000000000 --- a/hsnrm/resources/defaults/Manifest.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# ****************************************************************************** -# Copyright 2019 UChicago Argonne, LLC. -# (c.f. AUTHORS, LICENSE) -# -# SPDX-License-Identifier: BSD-3-Clause -# ****************************************************************************** -# -# this file is generated, modifications will be erased. -# -image: null -hwbind: false -app: - scheduler: FIFO - instrumentation: null - power: - slowdown: 1 - profile: false - policy: NoPowerPolicy - perfwrapper: PerfwrapperDisabled - slice: - cpus: 1 - mems: 1 -name: default diff --git a/hsnrm/resources/example-configurations/control.dhall b/hsnrm/resources/example-configurations/control.dhall deleted file mode 100644 index a685309546732feeb36a73f89452502cbbd34418..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/control.dhall +++ /dev/null @@ -1,112 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ verbose = < Error | Info | Debug >.Error -, logfile = "/tmp/nrm.log" -, hwloc = "hwloc" -, perf = "perf" -, argo_perf_wrapper = "nrm-perfwrapper" -, argo_nodeos_config = "argo_nodeos_config" -, libnrmPath = None Text -, pmpi_lib = "pmpi_lib" -, singularity = False -, dummy = True -, nodeos = False -, slice_runtime = < Singularity | Nodeos | Dummy >.Dummy -, downstreamCfg = { downstreamBindAddress = "ipc:///tmp/nrm-downstream-event" } -, upstreamCfg = { upstreamBindAddress = "*", pubPort = +2345, rpcPort = +3456 } -, raplCfg = Some - { raplPath = "/sys/devices/virtual/powercap/intel-rapl" - , raplActions = [ { fromuW = 1.0e8 }, { fromuW = 2.0e8 } ] - , referencePower = { fromuW = 2.5e8 } - } -, hwmonCfg = { hwmonEnabled = True, hwmonPath = "/sys/class/hwmon" } -, controlCfg = - < ControlCfg : - { minimumControlInterval : { fromuS : Double } - , staticPower : { fromuW : Double } - , learnCfg : - < Lagrange : { lagrange : Double } - | Random : { random : Optional Integer } - | Contextual : { contextual : { horizon : Integer } } - > - , speedThreshold : Double - , referenceMeasurementRoundInterval : Integer - , hint : - < Full - | Only : - { only : - { neHead : - List { actuatorID : Text, actuatorValue : Double } - , neTail : - List - (List { actuatorID : Text, actuatorValue : Double }) - } - } - > - } - | FixedCommand : { fixedPower : { fromuW : Double } } - >.ControlCfg - { minimumControlInterval = { fromuS = 100000.0 } - , staticPower = { fromuW = 2.0e8 } - , learnCfg = - < Lagrange : { lagrange : Double } - | Random : { random : Optional Integer } - | Contextual : { contextual : { horizon : Integer } } - >.Contextual - { contextual = { horizon = +4000 } } - , speedThreshold = 1.1 - , referenceMeasurementRoundInterval = +6 - , hint = - < Full - | Only : - { only : - { neHead : List { actuatorID : Text, actuatorValue : Double } - , neTail : - List (List { actuatorID : Text, actuatorValue : Double }) - } - } - >.Full - } -, activeSensorFrequency = { fromHz = 1.0 } -, extraStaticPassiveSensors = - [] : List - { mapKey : Text - , mapValue : - { sensorBinary : Text - , sensorArguments : List Text - , range : < I : { _1 : Double, _2 : Double } | Empty > - , tags : - List - < Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - > - , sensorBehavior : - < Cumulative - | IntervalBased - | CumulativeWithCapacity : Double - > - } - } -, extraStaticActuators = - [] : List - { mapKey : Text - , mapValue : - { actuatorBinary : Text - , actuatorArguments : List Text - , actions : List Double - , referenceAction : Double - } - } -} diff --git a/hsnrm/resources/example-configurations/control.json b/hsnrm/resources/example-configurations/control.json deleted file mode 100644 index 9f46ade11601c1b22bc3227dd4c8ecae38be933f..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/control.json +++ /dev/null @@ -1,61 +0,0 @@ -{ - "extraStaticPassiveSensors": [], - "pmpi_lib": "pmpi_lib", - "verbose": "Error", - "logfile": "/tmp/nrm.log", - "singularity": false, - "argo_nodeos_config": "argo_nodeos_config", - "controlCfg": { - "referenceMeasurementRoundInterval": 6, - "hint": "Full", - "learnCfg": { - "contextual": { - "horizon": 4000 - } - }, - "staticPower": { - "fromuW": 200000000 - }, - "speedThreshold": 1.1, - "minimumControlInterval": { - "fromuS": 100000 - } - }, - "upstreamCfg": { - "upstreamBindAddress": "*", - "rpcPort": 3456, - "pubPort": 2345 - }, - "libnrmPath": null, - "activeSensorFrequency": { - "fromHz": 1 - }, - "perf": "perf", - "argo_perf_wrapper": "nrm-perfwrapper", - "downstreamCfg": { - "downstreamBindAddress": "ipc:///tmp/nrm-downstream-event" - }, - "nodeos": false, - "hwloc": "hwloc", - "extraStaticActuators": [], - "raplCfg": { - "referencePower": { - "fromuW": 250000000 - }, - "raplActions": [ - { - "fromuW": 100000000 - }, - { - "fromuW": 200000000 - } - ], - "raplPath": "/sys/devices/virtual/powercap/intel-rapl" - }, - "dummy": true, - "slice_runtime": "Dummy", - "hwmonCfg": { - "hwmonPath": "/sys/class/hwmon", - "hwmonEnabled": true - } -} \ No newline at end of file diff --git a/hsnrm/resources/example-configurations/control.yaml b/hsnrm/resources/example-configurations/control.yaml deleted file mode 100644 index 5a736628f4e862bfa3db118f509ea71a51fdcbdb..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/control.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# ****************************************************************************** -# Copyright 2019 UChicago Argonne, LLC. -# (c.f. AUTHORS, LICENSE) -# -# SPDX-License-Identifier: BSD-3-Clause -# ****************************************************************************** -# -# this file is generated, modifications will be erased. -# -extraStaticPassiveSensors: [] -pmpi_lib: pmpi_lib -verbose: Error -logfile: /tmp/nrm.log -singularity: false -argo_nodeos_config: argo_nodeos_config -controlCfg: - referenceMeasurementRoundInterval: 6 - hint: Full - learnCfg: - contextual: - horizon: 4000 - staticPower: - fromuW: 2.0e8 - speedThreshold: 1.1 - minimumControlInterval: - fromuS: 100000.0 -upstreamCfg: - upstreamBindAddress: '*' - rpcPort: 3456 - pubPort: 2345 -libnrmPath: null -activeSensorFrequency: - fromHz: 1 -perf: perf -argo_perf_wrapper: nrm-perfwrapper -downstreamCfg: - downstreamBindAddress: ipc:///tmp/nrm-downstream-event -nodeos: false -hwloc: hwloc -extraStaticActuators: [] -raplCfg: - referencePower: - fromuW: 2.5e8 - raplActions: - - fromuW: 1.0e8 - - fromuW: 2.0e8 - raplPath: /sys/devices/virtual/powercap/intel-rapl -dummy: true -slice_runtime: Dummy -hwmonCfg: - hwmonPath: /sys/class/hwmon - hwmonEnabled: true diff --git a/hsnrm/resources/example-configurations/extra-static-actuator.dhall b/hsnrm/resources/example-configurations/extra-static-actuator.dhall deleted file mode 100644 index 988af5e1c4372ea1d37734de9d6f48dbbd779702..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/extra-static-actuator.dhall +++ /dev/null @@ -1,93 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ verbose = < Error | Info | Debug >.Error -, logfile = "/tmp/nrm.log" -, hwloc = "hwloc" -, perf = "perf" -, argo_perf_wrapper = "nrm-perfwrapper" -, argo_nodeos_config = "argo_nodeos_config" -, libnrmPath = None Text -, pmpi_lib = "pmpi_lib" -, singularity = False -, dummy = True -, nodeos = False -, slice_runtime = < Singularity | Nodeos | Dummy >.Dummy -, downstreamCfg = { downstreamBindAddress = "ipc:///tmp/nrm-downstream-event" } -, upstreamCfg = { upstreamBindAddress = "*", pubPort = +2345, rpcPort = +3456 } -, raplCfg = Some - { raplPath = "/sys/devices/virtual/powercap/intel-rapl" - , raplActions = [ { fromuW = 1.0e8 }, { fromuW = 2.0e8 } ] - , referencePower = { fromuW = 2.5e8 } - } -, hwmonCfg = { hwmonEnabled = True, hwmonPath = "/sys/class/hwmon" } -, controlCfg = - < ControlCfg : - { minimumControlInterval : { fromuS : Double } - , staticPower : { fromuW : Double } - , learnCfg : - < Lagrange : { lagrange : Double } - | Random : { random : Optional Integer } - | Contextual : { contextual : { horizon : Integer } } - > - , speedThreshold : Double - , referenceMeasurementRoundInterval : Integer - , hint : - < Full - | Only : - { only : - { neHead : - List { actuatorID : Text, actuatorValue : Double } - , neTail : - List - (List { actuatorID : Text, actuatorValue : Double }) - } - } - > - } - | FixedCommand : { fixedPower : { fromuW : Double } } - >.FixedCommand - { fixedPower = { fromuW = 2.5e8 } } -, activeSensorFrequency = { fromHz = 1.0 } -, extraStaticPassiveSensors = - [] : List - { mapKey : Text - , mapValue : - { sensorBinary : Text - , sensorArguments : List Text - , range : < I : { _1 : Double, _2 : Double } | Empty > - , tags : - List - < Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - > - , sensorBehavior : - < Cumulative - | IntervalBased - | CumulativeWithCapacity : Double - > - } - } -, extraStaticActuators = - [ { mapKey = "example extra actuator" - , mapValue = - { actuatorBinary = "bash" - , actuatorArguments = - [ "-c", "echo \$@ >> /tmp/test-nrm-example-extra-actuator", "-o" ] - , actions = [ 1.0, 2.0 ] - , referenceAction = 1.0 - } - } - ] -} diff --git a/hsnrm/resources/example-configurations/extra-static-actuator.json b/hsnrm/resources/example-configurations/extra-static-actuator.json deleted file mode 100644 index a6bda06c10d0039e8967a46dbe551f6c2bf1649b..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/extra-static-actuator.json +++ /dev/null @@ -1,67 +0,0 @@ -{ - "extraStaticPassiveSensors": [], - "pmpi_lib": "pmpi_lib", - "verbose": "Error", - "logfile": "/tmp/nrm.log", - "singularity": false, - "argo_nodeos_config": "argo_nodeos_config", - "controlCfg": { - "fixedPower": { - "fromuW": 250000000 - } - }, - "upstreamCfg": { - "upstreamBindAddress": "*", - "rpcPort": 3456, - "pubPort": 2345 - }, - "libnrmPath": null, - "activeSensorFrequency": { - "fromHz": 1 - }, - "perf": "perf", - "argo_perf_wrapper": "nrm-perfwrapper", - "downstreamCfg": { - "downstreamBindAddress": "ipc:///tmp/nrm-downstream-event" - }, - "nodeos": false, - "hwloc": "hwloc", - "extraStaticActuators": [ - { - "mapKey": "example extra actuator", - "mapValue": { - "actuatorBinary": "bash", - "actions": [ - 1, - 2 - ], - "actuatorArguments": [ - "-c", - "echo $@ >> /tmp/test-nrm-example-extra-actuator", - "-o" - ], - "referenceAction": 1 - } - } - ], - "raplCfg": { - "referencePower": { - "fromuW": 250000000 - }, - "raplActions": [ - { - "fromuW": 100000000 - }, - { - "fromuW": 200000000 - } - ], - "raplPath": "/sys/devices/virtual/powercap/intel-rapl" - }, - "dummy": true, - "slice_runtime": "Dummy", - "hwmonCfg": { - "hwmonPath": "/sys/class/hwmon", - "hwmonEnabled": true - } -} \ No newline at end of file diff --git a/hsnrm/resources/example-configurations/extra-static-actuator.yaml b/hsnrm/resources/example-configurations/extra-static-actuator.yaml deleted file mode 100644 index 4eaf450c859af9a218abf8d0b33526fa73af9fbd..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/extra-static-actuator.yaml +++ /dev/null @@ -1,55 +0,0 @@ -# ****************************************************************************** -# Copyright 2019 UChicago Argonne, LLC. -# (c.f. AUTHORS, LICENSE) -# -# SPDX-License-Identifier: BSD-3-Clause -# ****************************************************************************** -# -# this file is generated, modifications will be erased. -# -extraStaticPassiveSensors: [] -pmpi_lib: pmpi_lib -verbose: Error -logfile: /tmp/nrm.log -singularity: false -argo_nodeos_config: argo_nodeos_config -controlCfg: - fixedPower: - fromuW: 2.5e8 -upstreamCfg: - upstreamBindAddress: '*' - rpcPort: 3456 - pubPort: 2345 -libnrmPath: null -activeSensorFrequency: - fromHz: 1 -perf: perf -argo_perf_wrapper: nrm-perfwrapper -downstreamCfg: - downstreamBindAddress: ipc:///tmp/nrm-downstream-event -nodeos: false -hwloc: hwloc -extraStaticActuators: -- mapKey: example extra actuator - mapValue: - actuatorBinary: bash - actions: - - 1 - - 2 - actuatorArguments: - - -c - - echo $@ >> /tmp/test-nrm-example-extra-actuator - - -o - referenceAction: 1 -raplCfg: - referencePower: - fromuW: 2.5e8 - raplActions: - - fromuW: 1.0e8 - - fromuW: 2.0e8 - raplPath: /sys/devices/virtual/powercap/intel-rapl -dummy: true -slice_runtime: Dummy -hwmonCfg: - hwmonPath: /sys/class/hwmon - hwmonEnabled: true diff --git a/hsnrm/resources/example-configurations/extra-static-sensor.dhall b/hsnrm/resources/example-configurations/extra-static-sensor.dhall deleted file mode 100644 index f1cb0e89c4bb17fd0252d61c721803633f59f1be..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/extra-static-sensor.dhall +++ /dev/null @@ -1,94 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ verbose = < Error | Info | Debug >.Error -, logfile = "/tmp/nrm.log" -, hwloc = "hwloc" -, perf = "perf" -, argo_perf_wrapper = "nrm-perfwrapper" -, argo_nodeos_config = "argo_nodeos_config" -, libnrmPath = None Text -, pmpi_lib = "pmpi_lib" -, singularity = False -, dummy = True -, nodeos = False -, slice_runtime = < Singularity | Nodeos | Dummy >.Dummy -, downstreamCfg = { downstreamBindAddress = "ipc:///tmp/nrm-downstream-event" } -, upstreamCfg = { upstreamBindAddress = "*", pubPort = +2345, rpcPort = +3456 } -, raplCfg = Some - { raplPath = "/sys/devices/virtual/powercap/intel-rapl" - , raplActions = [ { fromuW = 1.0e8 }, { fromuW = 2.0e8 } ] - , referencePower = { fromuW = 2.5e8 } - } -, hwmonCfg = { hwmonEnabled = True, hwmonPath = "/sys/class/hwmon" } -, controlCfg = - < ControlCfg : - { minimumControlInterval : { fromuS : Double } - , staticPower : { fromuW : Double } - , learnCfg : - < Lagrange : { lagrange : Double } - | Random : { random : Optional Integer } - | Contextual : { contextual : { horizon : Integer } } - > - , speedThreshold : Double - , referenceMeasurementRoundInterval : Integer - , hint : - < Full - | Only : - { only : - { neHead : - List { actuatorID : Text, actuatorValue : Double } - , neTail : - List - (List { actuatorID : Text, actuatorValue : Double }) - } - } - > - } - | FixedCommand : { fixedPower : { fromuW : Double } } - >.FixedCommand - { fixedPower = { fromuW = 2.5e8 } } -, activeSensorFrequency = { fromHz = 1.0 } -, extraStaticPassiveSensors = - [ { mapKey = "example extra static passive power sensor" - , mapValue = - { sensorBinary = "echo" - , sensorArguments = [ "30" ] - , range = - < I : { _1 : Double, _2 : Double } | Empty >.I - { _1 = 1.0, _2 = 40.0 } - , tags = - [ < Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - >.Power - ] - , sensorBehavior = - < Cumulative - | IntervalBased - | CumulativeWithCapacity : Double - >.IntervalBased - } - } - ] -, extraStaticActuators = - [] : List - { mapKey : Text - , mapValue : - { actuatorBinary : Text - , actuatorArguments : List Text - , actions : List Double - , referenceAction : Double - } - } -} diff --git a/hsnrm/resources/example-configurations/extra-static-sensor.json b/hsnrm/resources/example-configurations/extra-static-sensor.json deleted file mode 100644 index 78321e5578a9af4e582cfaa0535808bf9ea7df1d..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/extra-static-sensor.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "extraStaticPassiveSensors": [ - { - "mapKey": "example extra static passive power sensor", - "mapValue": { - "range": { - "_2": 40, - "_1": 1 - }, - "sensorBehavior": "IntervalBased", - "sensorArguments": [ - "30" - ], - "tags": [ - "Power" - ], - "sensorBinary": "echo" - } - } - ], - "pmpi_lib": "pmpi_lib", - "verbose": "Error", - "logfile": "/tmp/nrm.log", - "singularity": false, - "argo_nodeos_config": "argo_nodeos_config", - "controlCfg": { - "fixedPower": { - "fromuW": 250000000 - } - }, - "upstreamCfg": { - "upstreamBindAddress": "*", - "rpcPort": 3456, - "pubPort": 2345 - }, - "libnrmPath": null, - "activeSensorFrequency": { - "fromHz": 1 - }, - "perf": "perf", - "argo_perf_wrapper": "nrm-perfwrapper", - "downstreamCfg": { - "downstreamBindAddress": "ipc:///tmp/nrm-downstream-event" - }, - "nodeos": false, - "hwloc": "hwloc", - "extraStaticActuators": [], - "raplCfg": { - "referencePower": { - "fromuW": 250000000 - }, - "raplActions": [ - { - "fromuW": 100000000 - }, - { - "fromuW": 200000000 - } - ], - "raplPath": "/sys/devices/virtual/powercap/intel-rapl" - }, - "dummy": true, - "slice_runtime": "Dummy", - "hwmonCfg": { - "hwmonPath": "/sys/class/hwmon", - "hwmonEnabled": true - } -} \ No newline at end of file diff --git a/hsnrm/resources/example-configurations/extra-static-sensor.yaml b/hsnrm/resources/example-configurations/extra-static-sensor.yaml deleted file mode 100644 index 603a78034554d6cecacca672561c7cd1c2d8e402..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/extra-static-sensor.yaml +++ /dev/null @@ -1,55 +0,0 @@ -# ****************************************************************************** -# Copyright 2019 UChicago Argonne, LLC. -# (c.f. AUTHORS, LICENSE) -# -# SPDX-License-Identifier: BSD-3-Clause -# ****************************************************************************** -# -# this file is generated, modifications will be erased. -# -extraStaticPassiveSensors: -- mapKey: example extra static passive power sensor - mapValue: - range: - _2: 40.0 - _1: 1 - sensorBehavior: IntervalBased - sensorArguments: - - '30' - tags: - - Power - sensorBinary: echo -pmpi_lib: pmpi_lib -verbose: Error -logfile: /tmp/nrm.log -singularity: false -argo_nodeos_config: argo_nodeos_config -controlCfg: - fixedPower: - fromuW: 2.5e8 -upstreamCfg: - upstreamBindAddress: '*' - rpcPort: 3456 - pubPort: 2345 -libnrmPath: null -activeSensorFrequency: - fromHz: 1 -perf: perf -argo_perf_wrapper: nrm-perfwrapper -downstreamCfg: - downstreamBindAddress: ipc:///tmp/nrm-downstream-event -nodeos: false -hwloc: hwloc -extraStaticActuators: [] -raplCfg: - referencePower: - fromuW: 2.5e8 - raplActions: - - fromuW: 1.0e8 - - fromuW: 2.0e8 - raplPath: /sys/devices/virtual/powercap/intel-rapl -dummy: true -slice_runtime: Dummy -hwmonCfg: - hwmonPath: /sys/class/hwmon - hwmonEnabled: true diff --git a/hsnrm/resources/example-configurations/variorum-two-package-power-limit-sensor.dhall b/hsnrm/resources/example-configurations/variorum-two-package-power-limit-sensor.dhall deleted file mode 100644 index a4bf54fb6196dec42d8724cdbc7e7b30ccfef8ce..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/variorum-two-package-power-limit-sensor.dhall +++ /dev/null @@ -1,125 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ verbose = < Error | Info | Debug >.Error -, logfile = "/tmp/nrm.log" -, hwloc = "hwloc" -, perf = "perf" -, argo_perf_wrapper = "nrm-perfwrapper" -, argo_nodeos_config = "argo_nodeos_config" -, libnrmPath = None Text -, pmpi_lib = "pmpi_lib" -, singularity = False -, dummy = True -, nodeos = False -, slice_runtime = < Singularity | Nodeos | Dummy >.Dummy -, downstreamCfg = { downstreamBindAddress = "ipc:///tmp/nrm-downstream-event" } -, upstreamCfg = { upstreamBindAddress = "*", pubPort = +2345, rpcPort = +3456 } -, raplCfg = Some - { raplPath = "/sys/devices/virtual/powercap/intel-rapl" - , raplActions = [ { fromuW = 1.0e8 }, { fromuW = 2.0e8 } ] - , referencePower = { fromuW = 2.5e8 } - } -, hwmonCfg = { hwmonEnabled = True, hwmonPath = "/sys/class/hwmon" } -, controlCfg = - < ControlCfg : - { minimumControlInterval : { fromuS : Double } - , staticPower : { fromuW : Double } - , learnCfg : - < Lagrange : { lagrange : Double } - | Random : { random : Optional Integer } - | Contextual : { contextual : { horizon : Integer } } - > - , speedThreshold : Double - , referenceMeasurementRoundInterval : Integer - , hint : - < Full - | Only : - { only : - { neHead : - List { actuatorID : Text, actuatorValue : Double } - , neTail : - List - (List { actuatorID : Text, actuatorValue : Double }) - } - } - > - } - | FixedCommand : { fixedPower : { fromuW : Double } } - >.FixedCommand - { fixedPower = { fromuW = 2.5e8 } } -, activeSensorFrequency = { fromHz = 1.0 } -, extraStaticPassiveSensors = - [ { mapKey = - "Sensor that gets package power limits for package 0 through variorum" - , mapValue = - { sensorBinary = "bash" - , sensorArguments = - [ "-c" - , "variorum-print-power-limits-example | awk '{ if (\$1 == \"_PACKAGE_POWER_LIMITS\" && \$2 == \"0x610\" && \$4 == 0 ) { print \$6 } }'" - ] - , range = - < I : { _1 : Double, _2 : Double } | Empty >.I - { _1 = 1.0, _2 = 40.0 } - , tags = - [] : List - < Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - > - , sensorBehavior = - < Cumulative - | IntervalBased - | CumulativeWithCapacity : Double - >.IntervalBased - } - } - , { mapKey = - "Sensor that gets package power limits for package 1 through variorum" - , mapValue = - { sensorBinary = "bash" - , sensorArguments = - [ "-c" - , "variorum-print-power-limits-example | awk '{ if (\$1 == \"_PACKAGE_POWER_LIMITS\" && \$2 == \"0x610\" && \$4 == 1 ) { print \$6 } }'" - ] - , range = - < I : { _1 : Double, _2 : Double } | Empty >.I - { _1 = 1.0, _2 = 40.0 } - , tags = - [] : List - < Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - > - , sensorBehavior = - < Cumulative - | IntervalBased - | CumulativeWithCapacity : Double - >.IntervalBased - } - } - ] -, extraStaticActuators = - [] : List - { mapKey : Text - , mapValue : - { actuatorBinary : Text - , actuatorArguments : List Text - , actions : List Double - , referenceAction : Double - } - } -} diff --git a/hsnrm/resources/example-configurations/variorum-two-package-power-limit-sensor.json b/hsnrm/resources/example-configurations/variorum-two-package-power-limit-sensor.json deleted file mode 100644 index b6eb577c8b12bfb681b34c0d490dab9d6b4467bb..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/variorum-two-package-power-limit-sensor.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "extraStaticPassiveSensors": [ - { - "mapKey": "Sensor that gets package power limits for package 0 through variorum", - "mapValue": { - "range": { - "_2": 40, - "_1": 1 - }, - "sensorBehavior": "IntervalBased", - "sensorArguments": [ - "-c", - "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_POWER_LIMITS\" && $2 == \"0x610\" && $4 == 0 ) { print $6 } }'" - ], - "tags": [], - "sensorBinary": "bash" - } - }, - { - "mapKey": "Sensor that gets package power limits for package 1 through variorum", - "mapValue": { - "range": { - "_2": 40, - "_1": 1 - }, - "sensorBehavior": "IntervalBased", - "sensorArguments": [ - "-c", - "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_POWER_LIMITS\" && $2 == \"0x610\" && $4 == 1 ) { print $6 } }'" - ], - "tags": [], - "sensorBinary": "bash" - } - } - ], - "pmpi_lib": "pmpi_lib", - "verbose": "Error", - "logfile": "/tmp/nrm.log", - "singularity": false, - "argo_nodeos_config": "argo_nodeos_config", - "controlCfg": { - "fixedPower": { - "fromuW": 250000000 - } - }, - "upstreamCfg": { - "upstreamBindAddress": "*", - "rpcPort": 3456, - "pubPort": 2345 - }, - "libnrmPath": null, - "activeSensorFrequency": { - "fromHz": 1 - }, - "perf": "perf", - "argo_perf_wrapper": "nrm-perfwrapper", - "downstreamCfg": { - "downstreamBindAddress": "ipc:///tmp/nrm-downstream-event" - }, - "nodeos": false, - "hwloc": "hwloc", - "extraStaticActuators": [], - "raplCfg": { - "referencePower": { - "fromuW": 250000000 - }, - "raplActions": [ - { - "fromuW": 100000000 - }, - { - "fromuW": 200000000 - } - ], - "raplPath": "/sys/devices/virtual/powercap/intel-rapl" - }, - "dummy": true, - "slice_runtime": "Dummy", - "hwmonCfg": { - "hwmonPath": "/sys/class/hwmon", - "hwmonEnabled": true - } -} \ No newline at end of file diff --git a/hsnrm/resources/example-configurations/variorum-two-package-power-limit-sensor.yaml b/hsnrm/resources/example-configurations/variorum-two-package-power-limit-sensor.yaml deleted file mode 100644 index 8137f41321cd37cfea26c7cfa9b2c911bbafe004..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/variorum-two-package-power-limit-sensor.yaml +++ /dev/null @@ -1,68 +0,0 @@ -# ****************************************************************************** -# Copyright 2019 UChicago Argonne, LLC. -# (c.f. AUTHORS, LICENSE) -# -# SPDX-License-Identifier: BSD-3-Clause -# ****************************************************************************** -# -# this file is generated, modifications will be erased. -# -extraStaticPassiveSensors: -- mapKey: Sensor that gets package power limits for package 0 through variorum - mapValue: - range: - _2: 40.0 - _1: 1 - sensorBehavior: IntervalBased - sensorArguments: - - -c - - variorum-print-power-limits-example | awk '{ if ($1 == "_PACKAGE_POWER_LIMITS" - && $2 == "0x610" && $4 == 0 ) { print $6 } }' - tags: [] - sensorBinary: bash -- mapKey: Sensor that gets package power limits for package 1 through variorum - mapValue: - range: - _2: 40.0 - _1: 1 - sensorBehavior: IntervalBased - sensorArguments: - - -c - - variorum-print-power-limits-example | awk '{ if ($1 == "_PACKAGE_POWER_LIMITS" - && $2 == "0x610" && $4 == 1 ) { print $6 } }' - tags: [] - sensorBinary: bash -pmpi_lib: pmpi_lib -verbose: Error -logfile: /tmp/nrm.log -singularity: false -argo_nodeos_config: argo_nodeos_config -controlCfg: - fixedPower: - fromuW: 2.5e8 -upstreamCfg: - upstreamBindAddress: '*' - rpcPort: 3456 - pubPort: 2345 -libnrmPath: null -activeSensorFrequency: - fromHz: 1 -perf: perf -argo_perf_wrapper: nrm-perfwrapper -downstreamCfg: - downstreamBindAddress: ipc:///tmp/nrm-downstream-event -nodeos: false -hwloc: hwloc -extraStaticActuators: [] -raplCfg: - referencePower: - fromuW: 2.5e8 - raplActions: - - fromuW: 1.0e8 - - fromuW: 2.0e8 - raplPath: /sys/devices/virtual/powercap/intel-rapl -dummy: true -slice_runtime: Dummy -hwmonCfg: - hwmonPath: /sys/class/hwmon - hwmonEnabled: true diff --git a/hsnrm/resources/example-configurations/variorum-two-package-power-limits-actuator.dhall b/hsnrm/resources/example-configurations/variorum-two-package-power-limits-actuator.dhall deleted file mode 100644 index 37ad73634d49c551cd37bca72ddf38cf8e405f6b..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/variorum-two-package-power-limits-actuator.dhall +++ /dev/null @@ -1,92 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ verbose = < Error | Info | Debug >.Error -, logfile = "/tmp/nrm.log" -, hwloc = "hwloc" -, perf = "perf" -, argo_perf_wrapper = "nrm-perfwrapper" -, argo_nodeos_config = "argo_nodeos_config" -, libnrmPath = None Text -, pmpi_lib = "pmpi_lib" -, singularity = False -, dummy = True -, nodeos = False -, slice_runtime = < Singularity | Nodeos | Dummy >.Dummy -, downstreamCfg = { downstreamBindAddress = "ipc:///tmp/nrm-downstream-event" } -, upstreamCfg = { upstreamBindAddress = "*", pubPort = +2345, rpcPort = +3456 } -, raplCfg = Some - { raplPath = "/sys/devices/virtual/powercap/intel-rapl" - , raplActions = [ { fromuW = 1.0e8 }, { fromuW = 2.0e8 } ] - , referencePower = { fromuW = 2.5e8 } - } -, hwmonCfg = { hwmonEnabled = True, hwmonPath = "/sys/class/hwmon" } -, controlCfg = - < ControlCfg : - { minimumControlInterval : { fromuS : Double } - , staticPower : { fromuW : Double } - , learnCfg : - < Lagrange : { lagrange : Double } - | Random : { random : Optional Integer } - | Contextual : { contextual : { horizon : Integer } } - > - , speedThreshold : Double - , referenceMeasurementRoundInterval : Integer - , hint : - < Full - | Only : - { only : - { neHead : - List { actuatorID : Text, actuatorValue : Double } - , neTail : - List - (List { actuatorID : Text, actuatorValue : Double }) - } - } - > - } - | FixedCommand : { fixedPower : { fromuW : Double } } - >.FixedCommand - { fixedPower = { fromuW = 2.5e8 } } -, activeSensorFrequency = { fromHz = 1.0 } -, extraStaticPassiveSensors = - [] : List - { mapKey : Text - , mapValue : - { sensorBinary : Text - , sensorArguments : List Text - , range : < I : { _1 : Double, _2 : Double } | Empty > - , tags : - List - < Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - > - , sensorBehavior : - < Cumulative - | IntervalBased - | CumulativeWithCapacity : Double - > - } - } -, extraStaticActuators = - [ { mapKey = "example extra actuator" - , mapValue = - { actuatorBinary = "variorum-set-socket-power-limits-example" - , actuatorArguments = [] : List Text - , actions = [ 100.0, 150.0 ] - , referenceAction = 100.0 - } - } - ] -} diff --git a/hsnrm/resources/example-configurations/variorum-two-package-power-limits-actuator.json b/hsnrm/resources/example-configurations/variorum-two-package-power-limits-actuator.json deleted file mode 100644 index ee6fdd863287dac8239084b2d14995dd23fad03e..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/variorum-two-package-power-limits-actuator.json +++ /dev/null @@ -1,63 +0,0 @@ -{ - "extraStaticPassiveSensors": [], - "pmpi_lib": "pmpi_lib", - "verbose": "Error", - "logfile": "/tmp/nrm.log", - "singularity": false, - "argo_nodeos_config": "argo_nodeos_config", - "controlCfg": { - "fixedPower": { - "fromuW": 250000000 - } - }, - "upstreamCfg": { - "upstreamBindAddress": "*", - "rpcPort": 3456, - "pubPort": 2345 - }, - "libnrmPath": null, - "activeSensorFrequency": { - "fromHz": 1 - }, - "perf": "perf", - "argo_perf_wrapper": "nrm-perfwrapper", - "downstreamCfg": { - "downstreamBindAddress": "ipc:///tmp/nrm-downstream-event" - }, - "nodeos": false, - "hwloc": "hwloc", - "extraStaticActuators": [ - { - "mapKey": "example extra actuator", - "mapValue": { - "actuatorBinary": "variorum-set-socket-power-limits-example", - "actions": [ - 100, - 150 - ], - "actuatorArguments": [], - "referenceAction": 100 - } - } - ], - "raplCfg": { - "referencePower": { - "fromuW": 250000000 - }, - "raplActions": [ - { - "fromuW": 100000000 - }, - { - "fromuW": 200000000 - } - ], - "raplPath": "/sys/devices/virtual/powercap/intel-rapl" - }, - "dummy": true, - "slice_runtime": "Dummy", - "hwmonCfg": { - "hwmonPath": "/sys/class/hwmon", - "hwmonEnabled": true - } -} \ No newline at end of file diff --git a/hsnrm/resources/example-configurations/variorum-two-package-power-limits-actuator.yaml b/hsnrm/resources/example-configurations/variorum-two-package-power-limits-actuator.yaml deleted file mode 100644 index 0018f732283f8a72a0623052f4e561a8f239d3d4..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/variorum-two-package-power-limits-actuator.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# ****************************************************************************** -# Copyright 2019 UChicago Argonne, LLC. -# (c.f. AUTHORS, LICENSE) -# -# SPDX-License-Identifier: BSD-3-Clause -# ****************************************************************************** -# -# this file is generated, modifications will be erased. -# -extraStaticPassiveSensors: [] -pmpi_lib: pmpi_lib -verbose: Error -logfile: /tmp/nrm.log -singularity: false -argo_nodeos_config: argo_nodeos_config -controlCfg: - fixedPower: - fromuW: 2.5e8 -upstreamCfg: - upstreamBindAddress: '*' - rpcPort: 3456 - pubPort: 2345 -libnrmPath: null -activeSensorFrequency: - fromHz: 1 -perf: perf -argo_perf_wrapper: nrm-perfwrapper -downstreamCfg: - downstreamBindAddress: ipc:///tmp/nrm-downstream-event -nodeos: false -hwloc: hwloc -extraStaticActuators: -- mapKey: example extra actuator - mapValue: - actuatorBinary: variorum-set-socket-power-limits-example - actions: - - 100.0 - - 150.0 - actuatorArguments: [] - referenceAction: 100.0 -raplCfg: - referencePower: - fromuW: 2.5e8 - raplActions: - - fromuW: 1.0e8 - - fromuW: 2.0e8 - raplPath: /sys/devices/virtual/powercap/intel-rapl -dummy: true -slice_runtime: Dummy -hwmonCfg: - hwmonPath: /sys/class/hwmon - hwmonEnabled: true diff --git a/hsnrm/resources/example-configurations/variorum-two-package-power-value-sensor.dhall b/hsnrm/resources/example-configurations/variorum-two-package-power-value-sensor.dhall deleted file mode 100644 index c0d936eeab718fae2d1ba20bd1990714aaa158b2..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/variorum-two-package-power-value-sensor.dhall +++ /dev/null @@ -1,125 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ verbose = < Error | Info | Debug >.Error -, logfile = "/tmp/nrm.log" -, hwloc = "hwloc" -, perf = "perf" -, argo_perf_wrapper = "nrm-perfwrapper" -, argo_nodeos_config = "argo_nodeos_config" -, libnrmPath = None Text -, pmpi_lib = "pmpi_lib" -, singularity = False -, dummy = True -, nodeos = False -, slice_runtime = < Singularity | Nodeos | Dummy >.Dummy -, downstreamCfg = { downstreamBindAddress = "ipc:///tmp/nrm-downstream-event" } -, upstreamCfg = { upstreamBindAddress = "*", pubPort = +2345, rpcPort = +3456 } -, raplCfg = Some - { raplPath = "/sys/devices/virtual/powercap/intel-rapl" - , raplActions = [ { fromuW = 1.0e8 }, { fromuW = 2.0e8 } ] - , referencePower = { fromuW = 2.5e8 } - } -, hwmonCfg = { hwmonEnabled = True, hwmonPath = "/sys/class/hwmon" } -, controlCfg = - < ControlCfg : - { minimumControlInterval : { fromuS : Double } - , staticPower : { fromuW : Double } - , learnCfg : - < Lagrange : { lagrange : Double } - | Random : { random : Optional Integer } - | Contextual : { contextual : { horizon : Integer } } - > - , speedThreshold : Double - , referenceMeasurementRoundInterval : Integer - , hint : - < Full - | Only : - { only : - { neHead : - List { actuatorID : Text, actuatorValue : Double } - , neTail : - List - (List { actuatorID : Text, actuatorValue : Double }) - } - } - > - } - | FixedCommand : { fixedPower : { fromuW : Double } } - >.FixedCommand - { fixedPower = { fromuW = 2.5e8 } } -, activeSensorFrequency = { fromHz = 1.0 } -, extraStaticPassiveSensors = - [ { mapKey = - "Sensor that gets package power limits for package 0 through variorum" - , mapValue = - { sensorBinary = "bash" - , sensorArguments = - [ "-c" - , "variorum-print-power-limits-example | awk '{ if (\$1 == \"_PACKAGE_ENERGY_STATUS\" && \$2 == \"0x610\" && \$4 == 0 ) { print \$6 } }'" - ] - , range = - < I : { _1 : Double, _2 : Double } | Empty >.I - { _1 = 1.0, _2 = 40.0 } - , tags = - [ < Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - >.Power - ] - , sensorBehavior = - < Cumulative - | IntervalBased - | CumulativeWithCapacity : Double - >.Cumulative - } - } - , { mapKey = - "Sensor that gets package power limits for package 1 through variorum" - , mapValue = - { sensorBinary = "bash" - , sensorArguments = - [ "-c" - , "variorum-print-power-limits-example | awk '{ if (\$1 == \"_PACKAGE_ENERGY_STATUS\" && \$2 == \"0x610\" && \$4 == 1 ) { print \$6 } }'" - ] - , range = - < I : { _1 : Double, _2 : Double } | Empty >.I - { _1 = 1.0, _2 = 40.0 } - , tags = - [ < Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - >.Power - ] - , sensorBehavior = - < Cumulative - | IntervalBased - | CumulativeWithCapacity : Double - >.Cumulative - } - } - ] -, extraStaticActuators = - [] : List - { mapKey : Text - , mapValue : - { actuatorBinary : Text - , actuatorArguments : List Text - , actions : List Double - , referenceAction : Double - } - } -} diff --git a/hsnrm/resources/example-configurations/variorum-two-package-power-value-sensor.json b/hsnrm/resources/example-configurations/variorum-two-package-power-value-sensor.json deleted file mode 100644 index 10289e46db1ae159b5f6ed9c618f1cfa78bced82..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/variorum-two-package-power-value-sensor.json +++ /dev/null @@ -1,87 +0,0 @@ -{ - "extraStaticPassiveSensors": [ - { - "mapKey": "Sensor that gets package power limits for package 0 through variorum", - "mapValue": { - "range": { - "_2": 40, - "_1": 1 - }, - "sensorBehavior": "Cumulative", - "sensorArguments": [ - "-c", - "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_ENERGY_STATUS\" && $2 == \"0x610\" && $4 == 0 ) { print $6 } }'" - ], - "tags": [ - "Power" - ], - "sensorBinary": "bash" - } - }, - { - "mapKey": "Sensor that gets package power limits for package 1 through variorum", - "mapValue": { - "range": { - "_2": 40, - "_1": 1 - }, - "sensorBehavior": "Cumulative", - "sensorArguments": [ - "-c", - "variorum-print-power-limits-example | awk '{ if ($1 == \"_PACKAGE_ENERGY_STATUS\" && $2 == \"0x610\" && $4 == 1 ) { print $6 } }'" - ], - "tags": [ - "Power" - ], - "sensorBinary": "bash" - } - } - ], - "pmpi_lib": "pmpi_lib", - "verbose": "Error", - "logfile": "/tmp/nrm.log", - "singularity": false, - "argo_nodeos_config": "argo_nodeos_config", - "controlCfg": { - "fixedPower": { - "fromuW": 250000000 - } - }, - "upstreamCfg": { - "upstreamBindAddress": "*", - "rpcPort": 3456, - "pubPort": 2345 - }, - "libnrmPath": null, - "activeSensorFrequency": { - "fromHz": 1 - }, - "perf": "perf", - "argo_perf_wrapper": "nrm-perfwrapper", - "downstreamCfg": { - "downstreamBindAddress": "ipc:///tmp/nrm-downstream-event" - }, - "nodeos": false, - "hwloc": "hwloc", - "extraStaticActuators": [], - "raplCfg": { - "referencePower": { - "fromuW": 250000000 - }, - "raplActions": [ - { - "fromuW": 100000000 - }, - { - "fromuW": 200000000 - } - ], - "raplPath": "/sys/devices/virtual/powercap/intel-rapl" - }, - "dummy": true, - "slice_runtime": "Dummy", - "hwmonCfg": { - "hwmonPath": "/sys/class/hwmon", - "hwmonEnabled": true - } -} \ No newline at end of file diff --git a/hsnrm/resources/example-configurations/variorum-two-package-power-value-sensor.yaml b/hsnrm/resources/example-configurations/variorum-two-package-power-value-sensor.yaml deleted file mode 100644 index 2e814dce4430ec1f3fb15903b94d330aa699c63a..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-configurations/variorum-two-package-power-value-sensor.yaml +++ /dev/null @@ -1,70 +0,0 @@ -# ****************************************************************************** -# Copyright 2019 UChicago Argonne, LLC. -# (c.f. AUTHORS, LICENSE) -# -# SPDX-License-Identifier: BSD-3-Clause -# ****************************************************************************** -# -# this file is generated, modifications will be erased. -# -extraStaticPassiveSensors: -- mapKey: Sensor that gets package power limits for package 0 through variorum - mapValue: - range: - _2: 40.0 - _1: 1 - sensorBehavior: Cumulative - sensorArguments: - - -c - - variorum-print-power-limits-example | awk '{ if ($1 == "_PACKAGE_ENERGY_STATUS" - && $2 == "0x610" && $4 == 0 ) { print $6 } }' - tags: - - Power - sensorBinary: bash -- mapKey: Sensor that gets package power limits for package 1 through variorum - mapValue: - range: - _2: 40.0 - _1: 1 - sensorBehavior: Cumulative - sensorArguments: - - -c - - variorum-print-power-limits-example | awk '{ if ($1 == "_PACKAGE_ENERGY_STATUS" - && $2 == "0x610" && $4 == 1 ) { print $6 } }' - tags: - - Power - sensorBinary: bash -pmpi_lib: pmpi_lib -verbose: Error -logfile: /tmp/nrm.log -singularity: false -argo_nodeos_config: argo_nodeos_config -controlCfg: - fixedPower: - fromuW: 2.5e8 -upstreamCfg: - upstreamBindAddress: '*' - rpcPort: 3456 - pubPort: 2345 -libnrmPath: null -activeSensorFrequency: - fromHz: 1 -perf: perf -argo_perf_wrapper: nrm-perfwrapper -downstreamCfg: - downstreamBindAddress: ipc:///tmp/nrm-downstream-event -nodeos: false -hwloc: hwloc -extraStaticActuators: [] -raplCfg: - referencePower: - fromuW: 2.5e8 - raplActions: - - fromuW: 1.0e8 - - fromuW: 2.0e8 - raplPath: /sys/devices/virtual/powercap/intel-rapl -dummy: true -slice_runtime: Dummy -hwmonCfg: - hwmonPath: /sys/class/hwmon - hwmonEnabled: true diff --git a/hsnrm/resources/example-manifests/libnrm.dhall b/hsnrm/resources/example-manifests/libnrm.dhall deleted file mode 100644 index f9e4c445143be2fade13cc4e89fd3cd5d2d4175d..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-manifests/libnrm.dhall +++ /dev/null @@ -1,36 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ name = "default" -, app = - { slice = { cpus = +1, mems = +1 } - , scheduler = < FIFO | HPC | Other : Integer >.FIFO - , perfwrapper = - < PerfwrapperDisabled - | Perfwrapper : - { perfFreq : { fromHz : Double } - , perfLimit : { fromOps : Integer } - } - >.PerfwrapperDisabled - , power = - { policy = < NoPowerPolicy | DDCM | DVFS | Combined >.NoPowerPolicy - , profile = False - , slowdown = +1 - } - , instrumentation = Some { ratelimit = { fromHz = 1000000.0 } } - } -, hwbind = False -, image = - None - { path : Text - , imagetype : < Sif | Docker > - , binds : Optional (List Text) - } -} diff --git a/hsnrm/resources/example-manifests/libnrm.json b/hsnrm/resources/example-manifests/libnrm.json deleted file mode 100644 index e5aab84bc90b6ab971ca16707c914a1789526b40..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-manifests/libnrm.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "image": null, - "hwbind": false, - "app": { - "scheduler": "FIFO", - "instrumentation": { - "ratelimit": { - "fromHz": 1000000 - } - }, - "power": { - "slowdown": 1, - "profile": false, - "policy": "NoPowerPolicy" - }, - "perfwrapper": "PerfwrapperDisabled", - "slice": { - "cpus": 1, - "mems": 1 - } - }, - "name": "default" -} \ No newline at end of file diff --git a/hsnrm/resources/example-manifests/libnrm.yaml b/hsnrm/resources/example-manifests/libnrm.yaml deleted file mode 100644 index a4b4cebc095599752dbea8e5bdbf50b6fba773d7..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-manifests/libnrm.yaml +++ /dev/null @@ -1,25 +0,0 @@ -# ****************************************************************************** -# Copyright 2019 UChicago Argonne, LLC. -# (c.f. AUTHORS, LICENSE) -# -# SPDX-License-Identifier: BSD-3-Clause -# ****************************************************************************** -# -# this file is generated, modifications will be erased. -# -image: null -hwbind: false -app: - scheduler: FIFO - instrumentation: - ratelimit: - fromHz: 1000000.0 - power: - slowdown: 1 - profile: false - policy: NoPowerPolicy - perfwrapper: PerfwrapperDisabled - slice: - cpus: 1 - mems: 1 -name: default diff --git a/hsnrm/resources/example-manifests/perfwrap.dhall b/hsnrm/resources/example-manifests/perfwrap.dhall deleted file mode 100644 index 6b6442e1a16e11abeb5bd41c8fdad8c95ccb92fb..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-manifests/perfwrap.dhall +++ /dev/null @@ -1,37 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ name = "default" -, app = - { slice = { cpus = +1, mems = +1 } - , scheduler = < FIFO | HPC | Other : Integer >.FIFO - , perfwrapper = - < PerfwrapperDisabled - | Perfwrapper : - { perfFreq : { fromHz : Double } - , perfLimit : { fromOps : Integer } - } - >.Perfwrapper - { perfFreq = { fromHz = 1.0 }, perfLimit = { fromOps = +100000 } } - , power = - { policy = < NoPowerPolicy | DDCM | DVFS | Combined >.NoPowerPolicy - , profile = False - , slowdown = +1 - } - , instrumentation = None { ratelimit : { fromHz : Double } } - } -, hwbind = False -, image = - None - { path : Text - , imagetype : < Sif | Docker > - , binds : Optional (List Text) - } -} diff --git a/hsnrm/resources/example-manifests/perfwrap.json b/hsnrm/resources/example-manifests/perfwrap.json deleted file mode 100644 index 26eee2be66b8b91ee7553c5fb3dd7fbf71a2c883..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-manifests/perfwrap.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "image": null, - "hwbind": false, - "app": { - "scheduler": "FIFO", - "instrumentation": null, - "power": { - "slowdown": 1, - "profile": false, - "policy": "NoPowerPolicy" - }, - "perfwrapper": { - "perfLimit": { - "fromOps": 100000 - }, - "perfFreq": { - "fromHz": 1 - } - }, - "slice": { - "cpus": 1, - "mems": 1 - } - }, - "name": "default" -} \ No newline at end of file diff --git a/hsnrm/resources/example-manifests/perfwrap.yaml b/hsnrm/resources/example-manifests/perfwrap.yaml deleted file mode 100644 index 426585fb80ac96a0641721e2443f39d58536d105..0000000000000000000000000000000000000000 --- a/hsnrm/resources/example-manifests/perfwrap.yaml +++ /dev/null @@ -1,27 +0,0 @@ -# ****************************************************************************** -# Copyright 2019 UChicago Argonne, LLC. -# (c.f. AUTHORS, LICENSE) -# -# SPDX-License-Identifier: BSD-3-Clause -# ****************************************************************************** -# -# this file is generated, modifications will be erased. -# -image: null -hwbind: false -app: - scheduler: FIFO - instrumentation: null - power: - slowdown: 1 - profile: false - policy: NoPowerPolicy - perfwrapper: - perfLimit: - fromOps: 100000 - perfFreq: - fromHz: 1 - slice: - cpus: 1 - mems: 1 -name: default diff --git a/hsnrm/resources/types/Cfg.dhall b/hsnrm/resources/types/Cfg.dhall deleted file mode 100644 index 4fd078e82aaf47d0ccfc5b1a3c91e1c81ad812b7..0000000000000000000000000000000000000000 --- a/hsnrm/resources/types/Cfg.dhall +++ /dev/null @@ -1,90 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ verbose : < Error | Info | Debug > -, logfile : Text -, hwloc : Text -, perf : Text -, argo_perf_wrapper : Text -, argo_nodeos_config : Text -, libnrmPath : Optional Text -, pmpi_lib : Text -, singularity : Bool -, dummy : Bool -, nodeos : Bool -, slice_runtime : < Singularity | Nodeos | Dummy > -, downstreamCfg : { downstreamBindAddress : Text } -, upstreamCfg : - { upstreamBindAddress : Text, pubPort : Integer, rpcPort : Integer } -, raplCfg : - Optional - { raplPath : Text - , raplActions : List { fromuW : Double } - , referencePower : { fromuW : Double } - } -, hwmonCfg : { hwmonEnabled : Bool, hwmonPath : Text } -, controlCfg : - < ControlCfg : - { minimumControlInterval : { fromuS : Double } - , staticPower : { fromuW : Double } - , learnCfg : - < Lagrange : { lagrange : Double } - | Random : { random : Optional Integer } - | Contextual : { contextual : { horizon : Integer } } - > - , speedThreshold : Double - , referenceMeasurementRoundInterval : Integer - , hint : - < Full - | Only : - { only : - { neHead : - List { actuatorID : Text, actuatorValue : Double } - , neTail : - List - (List { actuatorID : Text, actuatorValue : Double }) - } - } - > - } - | FixedCommand : { fixedPower : { fromuW : Double } } - > -, activeSensorFrequency : { fromHz : Double } -, extraStaticPassiveSensors : - List - { mapKey : Text - , mapValue : - { sensorBinary : Text - , sensorArguments : List Text - , range : < I : { _1 : Double, _2 : Double } | Empty > - , tags : - List - < Power - | Rapl - | DownstreamThreadSignal - | DownstreamCmdSignal - | Minimize - | Maximize - > - , sensorBehavior : - < Cumulative | IntervalBased | CumulativeWithCapacity : Double > - } - } -, extraStaticActuators : - List - { mapKey : Text - , mapValue : - { actuatorBinary : Text - , actuatorArguments : List Text - , actions : List Double - , referenceAction : Double - } - } -} diff --git a/hsnrm/resources/types/Manifest.dhall b/hsnrm/resources/types/Manifest.dhall deleted file mode 100644 index aa29a92ff8770d42c92c7f11ffeba2aae4d38ba1..0000000000000000000000000000000000000000 --- a/hsnrm/resources/types/Manifest.dhall +++ /dev/null @@ -1,36 +0,0 @@ --- ****************************************************************************** --- Copyright 2019 UChicago Argonne, LLC. --- (c.f. AUTHORS, LICENSE) --- --- SPDX-License-Identifier: BSD-3-Clause --- ****************************************************************************** --- --- this file is generated, modifications will be erased. --- - -{ name : Text -, app : - { slice : { cpus : Integer, mems : Integer } - , scheduler : < FIFO | HPC | Other : Integer > - , perfwrapper : - < PerfwrapperDisabled - | Perfwrapper : - { perfFreq : { fromHz : Double } - , perfLimit : { fromOps : Integer } - } - > - , power : - { policy : < NoPowerPolicy | DDCM | DVFS | Combined > - , profile : Bool - , slowdown : Integer - } - , instrumentation : Optional { ratelimit : { fromHz : Double } } - } -, hwbind : Bool -, image : - Optional - { path : Text - , imagetype : < Sif | Docker > - , binds : Optional (List Text) - } -} diff --git a/hsnrm/shell.nix b/hsnrm/shell.nix index e299a27a18b425341e9a874ec316e72f3c2c668a..5c2e15f530795f29f85ef98a768999e8e9f6f8b0 100644 --- a/hsnrm/shell.nix +++ b/hsnrm/shell.nix @@ -4,9 +4,10 @@ haskellPackages.shellFor { packages = p: [ haskellPackages.hsnrm haskellPackages.hsnrm-extra ]; withHoogle = true; buildInputs = [ + jq + yq haskellPackages.ghcid dhall - dhall-to-cabal cabal2nix ormolu hlint diff --git a/nix/default.nix b/nix/default.nix index 3110457b8a0cc32d68582dd0dffb382bd509cc1e..5f31d4661e2c01fbb9e1054f011c34e9ef0116b8 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -37,8 +37,6 @@ let }) (_: pkgs: { - dhall-to-cabal = - pkgs.haskell.lib.unmarkBroken pkgs.haskellPackages.dhall-to-cabal; haskellPackages = pkgs.haskell.packages.ghc865.override { overrides = self: super: with pkgs.haskell.lib; rec { @@ -63,8 +61,16 @@ let Plot-ho-matic = unmarkBroken super.Plot-ho-matic; zeromq4-haskell = unmarkBroken super.zeromq4-haskell; time-parsers = unmarkBroken super.time-parsers; - dhall = super.dhall_1_29_0; - dhall-json = doJailbreak super.dhall-json_1_6_1; + dhall = overrideSrc super.dhall_1_29_0 { + version = "1.30.0"; + src = builtins.fetchTarball + "https://hackage.haskell.org/package/dhall-1.30.0/dhall-1.30.0.tar.gz"; + }; + dhall-json = (overrideSrc (super.dhall-json_1_6_1) { + version = "1.6.2"; + src = builtins.fetchTarball + "https://hackage.haskell.org/package/dhall-json-1.6.2/dhall-json-1.6.2.tar.gz"; + }).override { inherit dhall; }; ihaskell = unmarkBroken super.ihaskell; vinyl = doJailbreak (unmarkBroken super.vinyl); ihaskell-blaze = unmarkBroken super.ihaskell-blaze; @@ -101,13 +107,6 @@ let in with pkgs; pkgs // rec { - - dhall-to-cabal-resources = pkgs.stdenv.mkDerivation { - name = "dhall-to-cabal-resources"; - src = pkgs.haskellPackages.dhall-to-cabal.src; - installPhase = "cp -r dhall $out"; - }; - ormolu = let source = pkgs.fetchFromGitHub { owner = "tweag"; diff --git a/hsnrm/resources/defaults/Manifest.json b/resources/defaults/manifest.json similarity index 52% rename from hsnrm/resources/defaults/Manifest.json rename to resources/defaults/manifest.json index c303c9b3c70e5ae09c3fc79c1843b40779be491b..04590adac1b0133792980dc3493b22c940b97372 100644 --- a/hsnrm/resources/defaults/Manifest.json +++ b/resources/defaults/manifest.json @@ -1,15 +1,14 @@ { - "image": null, "hwbind": false, "app": { - "scheduler": "FIFO", - "instrumentation": null, - "power": { + "scheduler": { + "fIFO": {} + }, + "powerCfg": { "slowdown": 1, "profile": false, - "policy": "NoPowerPolicy" + "policy": "noPowerPolicy" }, - "perfwrapper": "PerfwrapperDisabled", "slice": { "cpus": 1, "mems": 1 diff --git a/hsnrm/resources/defaults/Cfg.json b/resources/defaults/nrmd.json similarity index 77% rename from hsnrm/resources/defaults/Cfg.json rename to resources/defaults/nrmd.json index 0998cfd72b8f466542734ab29466e483ecf8a9d4..5ca0a79d4067997b052d31025353f3b65e95123e 100644 --- a/hsnrm/resources/defaults/Cfg.json +++ b/resources/defaults/nrmd.json @@ -1,23 +1,20 @@ { "extraStaticPassiveSensors": [], "pmpi_lib": "pmpi_lib", - "verbose": "Error", + "verbose": "error", "logfile": "/tmp/nrm.log", "singularity": false, "argo_nodeos_config": "argo_nodeos_config", "controlCfg": { - "fixedPower": { - "fromuW": 250000000 - } + "controlOff": {} }, "upstreamCfg": { "upstreamBindAddress": "*", "rpcPort": 3456, "pubPort": 2345 }, - "libnrmPath": null, "activeSensorFrequency": { - "fromHz": 1 + "hertz": 1 }, "perf": "perf", "argo_perf_wrapper": "nrm-perfwrapper", @@ -29,20 +26,19 @@ "extraStaticActuators": [], "raplCfg": { "referencePower": { - "fromuW": 250000000 + "microwatts": 250000000 }, "raplActions": [ { - "fromuW": 100000000 + "microwatts": 100000000 }, { - "fromuW": 200000000 + "microwatts": 200000000 } ], "raplPath": "/sys/devices/virtual/powercap/intel-rapl" }, "dummy": true, - "slice_runtime": "Dummy", "hwmonCfg": { "hwmonPath": "/sys/class/hwmon", "hwmonEnabled": true diff --git a/hsnrm/resources/nrm_messaging.h b/resources/nrm_messaging.h similarity index 100% rename from hsnrm/resources/nrm_messaging.h rename to resources/nrm_messaging.h diff --git a/hsnrm/resources/downstreamEvent.json b/resources/schemas/downstream.json similarity index 100% rename from hsnrm/resources/downstreamEvent.json rename to resources/schemas/downstream.json diff --git a/hsnrm/resources/manifestSchema.json b/resources/schemas/manifest.json similarity index 80% rename from hsnrm/resources/manifestSchema.json rename to resources/schemas/manifest.json index 401a0a6a329abb3e8b7122a40d88d093aa99e908..4f701a9b6fc859a4c3ee393d5a2eb87a46827030 100644 --- a/hsnrm/resources/manifestSchema.json +++ b/resources/schemas/manifest.json @@ -1,15 +1,15 @@ { "required": [ - "name", "app", - "hwbind" + "hwbind", + "name" ], "type": "object", "properties": { "image": { "required": [ - "path", - "imagetype" + "imagetype", + "path" ], "type": "object", "properties": { @@ -26,10 +26,10 @@ "imagetype": { "oneOf": [ { - "const": "\"sif\"" + "const": "\"docker\"" }, { - "const": "\"docker\"" + "const": "\"sif\"" } ] } @@ -40,10 +40,9 @@ }, "app": { "required": [ - "slice", + "powerCfg", "scheduler", - "perfwrapper", - "power" + "slice" ], "type": "object", "properties": { @@ -93,11 +92,42 @@ "type": "object", "properties": { "ratelimit": { + "required": [ + "hertz" + ], + "type": "object", + "properties": { + "hertz": { + "type": "number" + } + } + } + } + }, + "perfwrapper": { + "required": [ + "perfFreq", + "perfLimit" + ], + "type": "object", + "properties": { + "perfLimit": { "type": "number" + }, + "perfFreq": { + "required": [ + "hertz" + ], + "type": "object", + "properties": { + "hertz": { + "type": "number" + } + } } } }, - "power": { + "powerCfg": { "required": [ "policy", "profile", @@ -114,7 +144,7 @@ "policy": { "oneOf": [ { - "const": "\"noPowerPolicy\"" + "const": "\"combined\"" }, { "const": "\"dDCM\"" @@ -123,51 +153,12 @@ "const": "\"dVFS\"" }, { - "const": "\"combined\"" + "const": "\"noPowerPolicy\"" } ] } } }, - "perfwrapper": { - "oneOf": [ - { - "required": [ - "perfwrapperDisabled" - ], - "type": "object", - "properties": { - "perfwrapperDisabled": { - "type": "object", - "properties": {} - } - } - }, - { - "required": [ - "perfwrapper" - ], - "type": "object", - "properties": { - "perfwrapper": { - "required": [ - "perfFreq", - "perfLimit" - ], - "type": "object", - "properties": { - "perfLimit": { - "type": "number" - }, - "perfFreq": { - "type": "number" - } - } - } - } - } - ] - }, "slice": { "required": [ "cpus", diff --git a/resources/schemas/nrmd.json b/resources/schemas/nrmd.json new file mode 100644 index 0000000000000000000000000000000000000000..d9ea4affe7ae61157b0e0d4e085501bcc2c771f9 --- /dev/null +++ b/resources/schemas/nrmd.json @@ -0,0 +1,528 @@ +{ + "required": [ + "activeSensorFrequency", + "argo_nodeos_config", + "argo_perf_wrapper", + "controlCfg", + "downstreamCfg", + "dummy", + "extraStaticActuators", + "extraStaticPassiveSensors", + "hwloc", + "hwmonCfg", + "logfile", + "nodeos", + "perf", + "pmpi_lib", + "singularity", + "upstreamCfg", + "verbose" + ], + "type": "object", + "properties": { + "extraStaticPassiveSensors": { + "uniqueItems": false, + "items": { + "required": [ + "passiveSensorKey", + "passiveSensorValue" + ], + "type": "object", + "properties": { + "passiveSensorKey": { + "type": "string" + }, + "passiveSensorValue": { + "required": [ + "range", + "sensorArguments", + "sensorBehavior", + "sensorBinary", + "tags" + ], + "type": "object", + "properties": { + "range": { + "required": [ + "lower", + "upper" + ], + "type": "object", + "properties": { + "upper": { + "type": "number" + }, + "lower": { + "type": "number" + } + } + }, + "sensorBehavior": { + "oneOf": [ + { + "required": [ + "cumulative" + ], + "type": "object", + "properties": { + "cumulative": { + "type": "object", + "properties": {} + } + } + }, + { + "required": [ + "cumulativeWithCapacity" + ], + "type": "object", + "properties": { + "cumulativeWithCapacity": { + "type": "number" + } + } + }, + { + "required": [ + "intervalBased" + ], + "type": "object", + "properties": { + "intervalBased": { + "type": "object", + "properties": {} + } + } + } + ] + }, + "sensorArguments": { + "uniqueItems": false, + "items": { + "type": "string" + }, + "type": "array" + }, + "tags": { + "uniqueItems": false, + "items": { + "oneOf": [ + { + "const": "\"downstreamCmdSignal\"" + }, + { + "const": "\"downstreamThreadSignal\"" + }, + { + "const": "\"maximize\"" + }, + { + "const": "\"minimize\"" + }, + { + "const": "\"rapl\"" + }, + { + "const": "\"tagPower\"" + } + ] + }, + "type": "array" + }, + "sensorBinary": { + "type": "string" + } + } + } + } + }, + "type": "array" + }, + "pmpi_lib": { + "type": "string" + }, + "verbose": { + "oneOf": [ + { + "const": "\"debug\"" + }, + { + "const": "\"error\"" + }, + { + "const": "\"info\"" + } + ] + }, + "logfile": { + "type": "string" + }, + "singularity": { + "type": "boolean" + }, + "argo_nodeos_config": { + "type": "string" + }, + "controlCfg": { + "oneOf": [ + { + "required": [ + "controlCfg" + ], + "type": "object", + "properties": { + "controlCfg": { + "required": [ + "hint", + "learnCfg", + "minimumControlInterval", + "referenceMeasurementRoundInterval", + "speedThreshold", + "staticPower" + ], + "type": "object", + "properties": { + "referenceMeasurementRoundInterval": { + "type": "number" + }, + "hint": { + "oneOf": [ + { + "required": [ + "full" + ], + "type": "object", + "properties": { + "full": { + "type": "object", + "properties": {} + } + } + }, + { + "required": [ + "only" + ], + "type": "object", + "properties": { + "only": { + "required": [ + "neHead", + "neTail" + ], + "type": "object", + "properties": { + "neHead": { + "uniqueItems": false, + "items": { + "required": [ + "actuatorID", + "actuatorValue" + ], + "type": "object", + "properties": { + "actuatorValue": { + "type": "number" + }, + "actuatorID": { + "type": "string" + } + } + }, + "type": "array" + }, + "neTail": { + "uniqueItems": false, + "items": { + "uniqueItems": false, + "items": { + "required": [ + "actuatorID", + "actuatorValue" + ], + "type": "object", + "properties": { + "actuatorValue": { + "type": "number" + }, + "actuatorID": { + "type": "string" + } + } + }, + "type": "array" + }, + "type": "array" + } + } + } + } + } + ] + }, + "learnCfg": { + "oneOf": [ + { + "required": [ + "contextual" + ], + "type": "object", + "properties": { + "contextual": { + "required": [ + "horizon" + ], + "type": "object", + "properties": { + "horizon": { + "type": "number" + } + } + } + } + }, + { + "required": [ + "lagrange" + ], + "type": "object", + "properties": { + "lagrange": { + "required": [ + "lagrange" + ], + "type": "object", + "properties": { + "lagrange": { + "type": "number" + } + } + } + } + }, + { + "required": [ + "random" + ], + "type": "object", + "properties": { + "random": { + "required": [ + "seed" + ], + "type": "object", + "properties": { + "seed": { + "type": "number" + } + } + } + } + } + ] + }, + "staticPower": { + "required": [ + "microwatts" + ], + "type": "object", + "properties": { + "microwatts": { + "type": "number" + } + } + }, + "speedThreshold": { + "type": "number" + }, + "minimumControlInterval": { + "required": [ + "microseconds" + ], + "type": "object", + "properties": { + "microseconds": { + "type": "number" + } + } + } + } + } + } + }, + { + "required": [ + "controlOff" + ], + "type": "object", + "properties": { + "controlOff": { + "type": "object", + "properties": {} + } + } + } + ] + }, + "upstreamCfg": { + "required": [ + "pubPort", + "rpcPort", + "upstreamBindAddress" + ], + "type": "object", + "properties": { + "upstreamBindAddress": { + "type": "string" + }, + "rpcPort": { + "type": "number" + }, + "pubPort": { + "type": "number" + } + } + }, + "libnrmPath": { + "type": "string" + }, + "activeSensorFrequency": { + "required": [ + "hertz" + ], + "type": "object", + "properties": { + "hertz": { + "type": "number" + } + } + }, + "perf": { + "type": "string" + }, + "argo_perf_wrapper": { + "type": "string" + }, + "downstreamCfg": { + "required": [ + "downstreamBindAddress" + ], + "type": "object", + "properties": { + "downstreamBindAddress": { + "type": "string" + } + } + }, + "nodeos": { + "type": "boolean" + }, + "hwloc": { + "type": "string" + }, + "extraStaticActuators": { + "uniqueItems": false, + "items": { + "required": [ + "staticActuatorKey", + "staticActuatorValue" + ], + "type": "object", + "properties": { + "staticActuatorValue": { + "required": [ + "actions", + "actuatorArguments", + "actuatorBinary", + "referenceAction" + ], + "type": "object", + "properties": { + "actuatorBinary": { + "type": "string" + }, + "actions": { + "uniqueItems": false, + "items": { + "type": "number" + }, + "type": "array" + }, + "actuatorArguments": { + "uniqueItems": false, + "items": { + "type": "string" + }, + "type": "array" + }, + "referenceAction": { + "type": "number" + } + } + }, + "staticActuatorKey": { + "type": "string" + } + } + }, + "type": "array" + }, + "raplCfg": { + "required": [ + "raplActions", + "raplPath", + "referencePower" + ], + "type": "object", + "properties": { + "referencePower": { + "required": [ + "microwatts" + ], + "type": "object", + "properties": { + "microwatts": { + "type": "number" + } + } + }, + "raplActions": { + "uniqueItems": false, + "items": { + "required": [ + "microwatts" + ], + "type": "object", + "properties": { + "microwatts": { + "type": "number" + } + } + }, + "type": "array" + }, + "raplPath": { + "type": "string" + } + } + }, + "dummy": { + "type": "boolean" + }, + "hwmonCfg": { + "required": [ + "hwmonEnabled", + "hwmonPath" + ], + "type": "object", + "properties": { + "hwmonPath": { + "type": "string" + }, + "hwmonEnabled": { + "type": "boolean" + } + } + } + } +} \ No newline at end of file diff --git a/hsnrm/resources/upstreamPub.json b/resources/schemas/upstream-pub.json similarity index 100% rename from hsnrm/resources/upstreamPub.json rename to resources/schemas/upstream-pub.json diff --git a/hsnrm/resources/upstreamRep.json b/resources/schemas/upstream-rep.json similarity index 89% rename from hsnrm/resources/upstreamRep.json rename to resources/schemas/upstream-rep.json index 94fa913b664bb0f5ade2dcf06a38a52e0be50842..bd8de1c2b225275aee2540648cfeeeaf50d3f756 100644 --- a/hsnrm/resources/upstreamRep.json +++ b/resources/schemas/upstream-rep.json @@ -73,16 +73,16 @@ }, "manifest": { "required": [ - "name", "app", - "hwbind" + "hwbind", + "name" ], "type": "object", "properties": { "image": { "required": [ - "path", - "imagetype" + "imagetype", + "path" ], "type": "object", "properties": { @@ -99,10 +99,10 @@ "imagetype": { "oneOf": [ { - "const": "\"sif\"" + "const": "\"docker\"" }, { - "const": "\"docker\"" + "const": "\"sif\"" } ] } @@ -113,10 +113,9 @@ }, "app": { "required": [ - "slice", + "powerCfg", "scheduler", - "perfwrapper", - "power" + "slice" ], "type": "object", "properties": { @@ -166,11 +165,42 @@ "type": "object", "properties": { "ratelimit": { + "required": [ + "hertz" + ], + "type": "object", + "properties": { + "hertz": { + "type": "number" + } + } + } + } + }, + "perfwrapper": { + "required": [ + "perfFreq", + "perfLimit" + ], + "type": "object", + "properties": { + "perfLimit": { "type": "number" + }, + "perfFreq": { + "required": [ + "hertz" + ], + "type": "object", + "properties": { + "hertz": { + "type": "number" + } + } } } }, - "power": { + "powerCfg": { "required": [ "policy", "profile", @@ -187,7 +217,7 @@ "policy": { "oneOf": [ { - "const": "\"noPowerPolicy\"" + "const": "\"combined\"" }, { "const": "\"dDCM\"" @@ -196,51 +226,12 @@ "const": "\"dVFS\"" }, { - "const": "\"combined\"" + "const": "\"noPowerPolicy\"" } ] } } }, - "perfwrapper": { - "oneOf": [ - { - "required": [ - "perfwrapperDisabled" - ], - "type": "object", - "properties": { - "perfwrapperDisabled": { - "type": "object", - "properties": {} - } - } - }, - { - "required": [ - "perfwrapper" - ], - "type": "object", - "properties": { - "perfwrapper": { - "required": [ - "perfFreq", - "perfLimit" - ], - "type": "object", - "properties": { - "perfLimit": { - "type": "number" - }, - "perfFreq": { - "type": "number" - } - } - } - } - } - ] - }, "slice": { "required": [ "cpus", @@ -346,16 +337,16 @@ }, "manifest": { "required": [ - "name", "app", - "hwbind" + "hwbind", + "name" ], "type": "object", "properties": { "image": { "required": [ - "path", - "imagetype" + "imagetype", + "path" ], "type": "object", "properties": { @@ -372,10 +363,10 @@ "imagetype": { "oneOf": [ { - "const": "\"sif\"" + "const": "\"docker\"" }, { - "const": "\"docker\"" + "const": "\"sif\"" } ] } @@ -386,10 +377,9 @@ }, "app": { "required": [ - "slice", + "powerCfg", "scheduler", - "perfwrapper", - "power" + "slice" ], "type": "object", "properties": { @@ -439,11 +429,42 @@ "type": "object", "properties": { "ratelimit": { + "required": [ + "hertz" + ], + "type": "object", + "properties": { + "hertz": { + "type": "number" + } + } + } + } + }, + "perfwrapper": { + "required": [ + "perfFreq", + "perfLimit" + ], + "type": "object", + "properties": { + "perfLimit": { "type": "number" + }, + "perfFreq": { + "required": [ + "hertz" + ], + "type": "object", + "properties": { + "hertz": { + "type": "number" + } + } } } }, - "power": { + "powerCfg": { "required": [ "policy", "profile", @@ -460,7 +481,7 @@ "policy": { "oneOf": [ { - "const": "\"noPowerPolicy\"" + "const": "\"combined\"" }, { "const": "\"dDCM\"" @@ -469,51 +490,12 @@ "const": "\"dVFS\"" }, { - "const": "\"combined\"" + "const": "\"noPowerPolicy\"" } ] } } }, - "perfwrapper": { - "oneOf": [ - { - "required": [ - "perfwrapperDisabled" - ], - "type": "object", - "properties": { - "perfwrapperDisabled": { - "type": "object", - "properties": {} - } - } - }, - { - "required": [ - "perfwrapper" - ], - "type": "object", - "properties": { - "perfwrapper": { - "required": [ - "perfFreq", - "perfLimit" - ], - "type": "object", - "properties": { - "perfLimit": { - "type": "number" - }, - "perfFreq": { - "type": "number" - } - } - } - } - } - ] - }, "slice": { "required": [ "cpus", @@ -1065,151 +1047,143 @@ "properties": { "config": { "required": [ - "verbose", - "logfile", + "activeSensorFrequency", + "argo_nodeos_config", + "argo_perf_wrapper", + "controlCfg", + "downstreamCfg", + "dummy", + "extraStaticActuators", + "extraStaticPassiveSensors", "hwloc", + "hwmonCfg", + "logfile", + "nodeos", "perf", - "argo_perf_wrapper", - "argo_nodeos_config", "pmpi_lib", "singularity", - "dummy", - "nodeos", - "slice_runtime", - "downstreamCfg", "upstreamCfg", - "hwmonCfg", - "controlCfg", - "activeSensorFrequency", - "extraStaticPassiveSensors", - "extraStaticActuators" + "verbose" ], "type": "object", "properties": { "extraStaticPassiveSensors": { - "additionalProperties": { + "uniqueItems": false, + "items": { "required": [ - "sensorBinary", - "sensorArguments", - "range", - "tags", - "sensorBehavior" + "passiveSensorKey", + "passiveSensorValue" ], "type": "object", "properties": { - "range": { - "oneOf": [ - { + "passiveSensorKey": { + "type": "string" + }, + "passiveSensorValue": { + "required": [ + "range", + "sensorArguments", + "sensorBehavior", + "sensorBinary", + "tags" + ], + "type": "object", + "properties": { + "range": { "required": [ - "i" + "lower", + "upper" ], "type": "object", "properties": { - "i": { - "items": [ - { - "type": "number" - }, - { - "type": "number" - } - ], - "type": "array" + "upper": { + "type": "number" + }, + "lower": { + "type": "number" } } }, - { - "required": [ - "empty" - ], - "type": "object", - "properties": { - "empty": { + "sensorBehavior": { + "oneOf": [ + { + "required": [ + "cumulative" + ], "type": "object", - "properties": {} - } - } - } - ] - }, - "sensorBehavior": { - "oneOf": [ - { - "required": [ - "cumulative" - ], - "type": "object", - "properties": { - "cumulative": { + "properties": { + "cumulative": { + "type": "object", + "properties": {} + } + } + }, + { + "required": [ + "cumulativeWithCapacity" + ], "type": "object", - "properties": {} - } - } - }, - { - "required": [ - "intervalBased" - ], - "type": "object", - "properties": { - "intervalBased": { + "properties": { + "cumulativeWithCapacity": { + "type": "number" + } + } + }, + { + "required": [ + "intervalBased" + ], "type": "object", - "properties": {} + "properties": { + "intervalBased": { + "type": "object", + "properties": {} + } + } } - } + ] }, - { - "required": [ - "cumulativeWithCapacity" - ], - "type": "object", - "properties": { - "cumulativeWithCapacity": { - "type": "number" - } - } - } - ] - }, - "sensorArguments": { - "uniqueItems": false, - "items": { - "type": "string" - }, - "type": "array" - }, - "tags": { - "uniqueItems": false, - "items": { - "oneOf": [ - { - "const": "\"power\"" - }, - { - "const": "\"rapl\"" - }, - { - "const": "\"downstreamThreadSignal\"" - }, - { - "const": "\"downstreamCmdSignal\"" + "sensorArguments": { + "uniqueItems": false, + "items": { + "type": "string" }, - { - "const": "\"minimize\"" + "type": "array" + }, + "tags": { + "uniqueItems": false, + "items": { + "oneOf": [ + { + "const": "\"downstreamCmdSignal\"" + }, + { + "const": "\"downstreamThreadSignal\"" + }, + { + "const": "\"maximize\"" + }, + { + "const": "\"minimize\"" + }, + { + "const": "\"rapl\"" + }, + { + "const": "\"tagPower\"" + } + ] }, - { - "const": "\"maximize\"" - } - ] - }, - "type": "array" - }, - "sensorBinary": { - "type": "string" + "type": "array" + }, + "sensorBinary": { + "type": "string" + } + } } } }, - "type": "object" + "type": "array" }, "pmpi_lib": { "type": "string" @@ -1217,13 +1191,13 @@ "verbose": { "oneOf": [ { - "const": "\"error\"" + "const": "\"debug\"" }, { - "const": "\"info\"" + "const": "\"error\"" }, { - "const": "\"debug\"" + "const": "\"info\"" } ] }, @@ -1246,12 +1220,12 @@ "properties": { "controlCfg": { "required": [ - "minimumControlInterval", - "staticPower", + "hint", "learnCfg", - "speedThreshold", + "minimumControlInterval", "referenceMeasurementRoundInterval", - "hint" + "speedThreshold", + "staticPower" ], "type": "object", "properties": { @@ -1280,11 +1254,31 @@ "properties": { "only": { "required": [ - "only" + "neHead", + "neTail" ], "type": "object", "properties": { - "only": { + "neHead": { + "uniqueItems": false, + "items": { + "required": [ + "actuatorID", + "actuatorValue" + ], + "type": "object", + "properties": { + "actuatorValue": { + "type": "number" + }, + "actuatorID": { + "type": "string" + } + } + }, + "type": "array" + }, + "neTail": { "uniqueItems": false, "items": { "uniqueItems": false, @@ -1317,17 +1311,17 @@ "oneOf": [ { "required": [ - "lagrange" + "contextual" ], "type": "object", "properties": { - "lagrange": { + "contextual": { "required": [ - "lagrange" + "horizon" ], "type": "object", "properties": { - "lagrange": { + "horizon": { "type": "number" } } @@ -1336,42 +1330,18 @@ }, { "required": [ - "random" + "lagrange" ], "type": "object", "properties": { - "random": { + "lagrange": { "required": [ - "random" + "lagrange" ], "type": "object", "properties": { - "random": { - "oneOf": [ - { - "required": [ - "nothing" - ], - "type": "object", - "properties": { - "nothing": { - "type": "object", - "properties": {} - } - } - }, - { - "required": [ - "just" - ], - "type": "object", - "properties": { - "just": { - "type": "number" - } - } - } - ] + "lagrange": { + "type": "number" } } } @@ -1379,26 +1349,18 @@ }, { "required": [ - "contextual" + "random" ], "type": "object", "properties": { - "contextual": { + "random": { "required": [ - "contextual" + "seed" ], "type": "object", "properties": { - "contextual": { - "required": [ - "horizon" - ], - "type": "object", - "properties": { - "horizon": { - "type": "number" - } - } + "seed": { + "type": "number" } } } @@ -1407,13 +1369,29 @@ ] }, "staticPower": { - "type": "number" + "required": [ + "microwatts" + ], + "type": "object", + "properties": { + "microwatts": { + "type": "number" + } + } }, "speedThreshold": { "type": "number" }, "minimumControlInterval": { - "type": "number" + "required": [ + "microseconds" + ], + "type": "object", + "properties": { + "microseconds": { + "type": "number" + } + } } } } @@ -1421,20 +1399,13 @@ }, { "required": [ - "fixedCommand" + "controlOff" ], "type": "object", "properties": { - "fixedCommand": { - "required": [ - "fixedPower" - ], + "controlOff": { "type": "object", - "properties": { - "fixedPower": { - "type": "number" - } - } + "properties": {} } } } @@ -1442,9 +1413,9 @@ }, "upstreamCfg": { "required": [ - "upstreamBindAddress", "pubPort", - "rpcPort" + "rpcPort", + "upstreamBindAddress" ], "type": "object", "properties": { @@ -1463,7 +1434,15 @@ "type": "string" }, "activeSensorFrequency": { - "type": "number" + "required": [ + "hertz" + ], + "type": "object", + "properties": { + "hertz": { + "type": "number" + } + } }, "perf": { "type": "string" @@ -1489,54 +1468,83 @@ "type": "string" }, "extraStaticActuators": { - "additionalProperties": { + "uniqueItems": false, + "items": { "required": [ - "actuatorBinary", - "actuatorArguments", - "actions", - "referenceAction" + "staticActuatorKey", + "staticActuatorValue" ], "type": "object", "properties": { - "actuatorBinary": { - "type": "string" - }, - "actions": { - "uniqueItems": false, - "items": { - "type": "number" - }, - "type": "array" - }, - "actuatorArguments": { - "uniqueItems": false, - "items": { - "type": "string" - }, - "type": "array" + "staticActuatorValue": { + "required": [ + "actions", + "actuatorArguments", + "actuatorBinary", + "referenceAction" + ], + "type": "object", + "properties": { + "actuatorBinary": { + "type": "string" + }, + "actions": { + "uniqueItems": false, + "items": { + "type": "number" + }, + "type": "array" + }, + "actuatorArguments": { + "uniqueItems": false, + "items": { + "type": "string" + }, + "type": "array" + }, + "referenceAction": { + "type": "number" + } + } }, - "referenceAction": { - "type": "number" + "staticActuatorKey": { + "type": "string" } } }, - "type": "object" + "type": "array" }, "raplCfg": { "required": [ - "raplPath", "raplActions", + "raplPath", "referencePower" ], "type": "object", "properties": { "referencePower": { - "type": "number" + "required": [ + "microwatts" + ], + "type": "object", + "properties": { + "microwatts": { + "type": "number" + } + } }, "raplActions": { "uniqueItems": false, "items": { - "type": "number" + "required": [ + "microwatts" + ], + "type": "object", + "properties": { + "microwatts": { + "type": "number" + } + } }, "type": "array" }, @@ -1548,19 +1556,6 @@ "dummy": { "type": "boolean" }, - "slice_runtime": { - "oneOf": [ - { - "const": "\"singularity\"" - }, - { - "const": "\"nodeos\"" - }, - { - "const": "\"dummy\"" - } - ] - }, "hwmonCfg": { "required": [ "hwmonEnabled", diff --git a/hsnrm/resources/upstreamReq.json b/resources/schemas/upstream-req.json similarity index 89% rename from hsnrm/resources/upstreamReq.json rename to resources/schemas/upstream-req.json index d3dbddd47d67390771c183dba1b135811552bca0..9e63c216cad7a4ec21e29c437a374633732c7527 100644 --- a/hsnrm/resources/upstreamReq.json +++ b/resources/schemas/upstream-req.json @@ -57,16 +57,16 @@ }, "manifest": { "required": [ - "name", "app", - "hwbind" + "hwbind", + "name" ], "type": "object", "properties": { "image": { "required": [ - "path", - "imagetype" + "imagetype", + "path" ], "type": "object", "properties": { @@ -83,10 +83,10 @@ "imagetype": { "oneOf": [ { - "const": "\"sif\"" + "const": "\"docker\"" }, { - "const": "\"docker\"" + "const": "\"sif\"" } ] } @@ -97,10 +97,9 @@ }, "app": { "required": [ - "slice", + "powerCfg", "scheduler", - "perfwrapper", - "power" + "slice" ], "type": "object", "properties": { @@ -150,11 +149,42 @@ "type": "object", "properties": { "ratelimit": { + "required": [ + "hertz" + ], + "type": "object", + "properties": { + "hertz": { + "type": "number" + } + } + } + } + }, + "perfwrapper": { + "required": [ + "perfFreq", + "perfLimit" + ], + "type": "object", + "properties": { + "perfLimit": { "type": "number" + }, + "perfFreq": { + "required": [ + "hertz" + ], + "type": "object", + "properties": { + "hertz": { + "type": "number" + } + } } } }, - "power": { + "powerCfg": { "required": [ "policy", "profile", @@ -171,7 +201,7 @@ "policy": { "oneOf": [ { - "const": "\"noPowerPolicy\"" + "const": "\"combined\"" }, { "const": "\"dDCM\"" @@ -180,51 +210,12 @@ "const": "\"dVFS\"" }, { - "const": "\"combined\"" + "const": "\"noPowerPolicy\"" } ] } } }, - "perfwrapper": { - "oneOf": [ - { - "required": [ - "perfwrapperDisabled" - ], - "type": "object", - "properties": { - "perfwrapperDisabled": { - "type": "object", - "properties": {} - } - } - }, - { - "required": [ - "perfwrapper" - ], - "type": "object", - "properties": { - "perfwrapper": { - "required": [ - "perfFreq", - "perfLimit" - ], - "type": "object", - "properties": { - "perfLimit": { - "type": "number" - }, - "perfFreq": { - "type": "number" - } - } - } - } - } - ] - }, "slice": { "required": [ "cpus", diff --git a/shell.nix b/shell.nix index 98ac2063e050b1098590786afb9aec8e08aff6ba..1e3c901bf5a67da3ff8a1497df85710268dd360e 100644 --- a/shell.nix +++ b/shell.nix @@ -56,7 +56,6 @@ in mkShell { haskellPackages.cabal-install haskellPackages.graphmod haskellPackages.hdevtools - pkgs.dhall-to-cabal haskellPackages.wreq haskellPackages.hlint haskellPackages.fix-imports diff --git a/tests/apps/amg_progress.sh b/tests/apps/amg_progress.sh index 5c5f3012a0d9f36e280365d2593653ba673aa7fc..0c7c654d32bf7bde9c5c392d640e33e015c9a1ae 100755 --- a/tests/apps/amg_progress.sh +++ b/tests/apps/amg_progress.sh @@ -1,12 +1,13 @@ #!/usr/bin/env bash -nrmd '{ verbose = < Error | Info | Debug >.Debug, - raplCfg = None { raplPath : Text, - raplActions : List { fromuW : Double }, - referencePower : { fromuW : Double } } - }' & +nrmd ' let t = ../../hsnrm/hsnrm/dhall/types/nrmd.dhall + let d = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall + in d // { verbose = t.Verbosity.Debug, + raplCfg = None t.RaplCfg + } + ' & -OMP_NUM_THREADS=1 nrm run --manifest=../../hsnrm/resources/example-manifests/libnrm.dhall -d \ +OMP_NUM_THREADS=1 nrm run --manifest=../../examples/manifests/libnrm.dhall -d \ -- mpiexec -n 2 amg -problem 2 -n 90 90 90 -P 2 1 1 timeout 10 nrm listen-cpd diff --git a/tests/apps/python_progress.sh b/tests/apps/python_progress.sh index 87f660a88ef104e6feadd18131141917a04689b1..139648c2235dba0ce80ca15fb7fdfbc03c675b69 100755 --- a/tests/apps/python_progress.sh +++ b/tests/apps/python_progress.sh @@ -3,15 +3,16 @@ # in case there is a daemon hanging somewhere. pkill -f nrmd -nrmd '{ verbose = < Error | Info | Debug >.Debug, - raplCfg = None { raplPath : Text , - raplActions : List { fromuW : Double } , - referencePower : { fromuW : Double } }} +nrmd ' let t = ../../hsnrm/hsnrm/dhall/types/nrmd.dhall + let d = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall + in d // { verbose = t.Verbosity.Debug, + raplCfg = None t.RaplCfg + } ' >/dev/null 2>/dev/null & # using python nrm library to report progress. PYTHONPATH=$PYTHONPATH:../../pynrm/ nrm run \ ---manifest=../../hsnrm/resources/example-manifests/libnrm.dhall -d \ +--manifest=../../examples/manifests/libnrm.dhall -d \ ../../pynrm/extra/test-progress.py >/dev/null 2>/dev/null # listening to the message on the upstream API diff --git a/tests/apps/stream_progress.sh b/tests/apps/stream_progress.sh index efe3fa3b51d0cb6db8d39466ee8d741f415a3bf3..c79504b01ad124103c3e971ed38b317f9b041ecb 100755 --- a/tests/apps/stream_progress.sh +++ b/tests/apps/stream_progress.sh @@ -1,12 +1,13 @@ #!/usr/bin/env bash -nrmd '{ verbose = < Error | Info | Debug >.Debug, - raplCfg = None { raplPath : Text, - raplActions : List { fromuW : Double }, - referencePower : { fromuW : Double } } - }' >/dev/null 2>/dev/null & +nrmd ' let t = ../../hsnrm/hsnrm/dhall/types/nrmd.dhall + let d = ../../hsnrm/hsnrm/dhall/defaults/nrmd.dhall + in d // { verbose = t.Verbosity.Debug, + raplCfg = None t.RaplCfg + } + ' >/dev/null 2>/dev/null & -nrm run --manifest=../../hsnrm/resources/example-manifests/libnrm.dhall -d \ +nrm run --manifest=../../examples/manifests/libnrm.dhall -d \ stream_c >/dev/null 2>/dev/null timeout 10 nrm listen-cpd diff --git a/tests/perf/perfwrap.sh b/tests/perf/perfwrap.sh index d5f47db5a9188f96198961df7b5d7a93c28b930f..f58d6835b6712d4a81517d15d7984b7c40733cc7 100755 --- a/tests/perf/perfwrap.sh +++ b/tests/perf/perfwrap.sh @@ -2,9 +2,9 @@ nrmd ' {verbose =< Error | Info | Debug >.Debug } ' >/dev/null 2>/dev/null & -nrm run --manifest=../../hsnrm/resources/example-manifests/perfwrap.dhall -d \ +nrm run --manifest=../../examples/manifests/perfwrap.dhall -d \ sleep 10 >/dev/null 2>/dev/null -timeout 5 nrm listen-cpd +timeout 15 nrm listen-cpd pkill -f nrmd