From d01658209fde7ee34d60f252d490c5b19802e95f Mon Sep 17 00:00:00 2001
From: Sebastian Eibl <sebastian.eibl@fau.de>
Date: Fri, 20 Sep 2019 11:17:54 +0200
Subject: [PATCH] [ADD] mesa_pd grafana benchmark

---
 .gitlab-ci.yml                                |  6 ++-
 .../GranularGas/MESA_PD_Benchmark.cfg         | 29 +++++++++++
 apps/benchmarks/GranularGas/PE_Benchmark.cfg  |  4 +-
 apps/benchmarks/GranularGas/mesa_pd_upload.py | 52 +++++++++++++++++++
 .../GranularGas/{upload.py => pe_upload.py}   |  0
 5 files changed, 87 insertions(+), 4 deletions(-)
 create mode 100644 apps/benchmarks/GranularGas/MESA_PD_Benchmark.cfg
 create mode 100755 apps/benchmarks/GranularGas/mesa_pd_upload.py
 rename apps/benchmarks/GranularGas/{upload.py => pe_upload.py} (100%)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7c428c1db..58358c46a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1856,7 +1856,9 @@ conda-py36-linux:
       - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./PE_GranularGas PE_Benchmark.cfg --HCSITS --syncNextNeighbor --InelasticCoulombContactByDecoupling | tee GranularGas_HCSITS_NN_ICCBD.txt
       - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./PE_GranularGas PE_Benchmark.cfg --HCSITS --syncNextNeighbor --InelasticGeneralizedMaximumDissipationContact | tee GranularGas_HCSITS_NN_IGMDC.txt
       - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./PE_GranularGas PE_Benchmark.cfg --HCSITS --syncShadowOwners --InelasticFrictionlessContact | tee GranularGas_HCSITS_SO_IFC.txt
-      - python3 upload.py
+      - python3 pe_upload.py
+      - mpirun --allow-run-as-root -np 8 --map-by core --bind-to core --report-bindings ./MESA_PD_KernelBenchmark MESA_PD_Benchmark.cfg | tee mesa_pd.txt
+      - python3 mesa_pd_upload.py
    only:
       variables:
          - $ENABLE_BENCHMARKS
@@ -1865,7 +1867,7 @@ conda-py36-linux:
    artifacts:
       paths:
          - $CI_PROJECT_DIR/build/apps/benchmarks/GranularGas/*.txt
-         - $CI_PROJECT_DIR/build/apps/benchmarks/GranularGas/benchmark.sqlite
+         - $CI_PROJECT_DIR/build/apps/benchmarks/GranularGas/*.sqlite
 
 benchmark_intel19:
    <<: *benchmark_definition
diff --git a/apps/benchmarks/GranularGas/MESA_PD_Benchmark.cfg b/apps/benchmarks/GranularGas/MESA_PD_Benchmark.cfg
new file mode 100644
index 000000000..99f8958ae
--- /dev/null
+++ b/apps/benchmarks/GranularGas/MESA_PD_Benchmark.cfg
@@ -0,0 +1,29 @@
+GranularGas
+{
+   simulationCorner < 0, 0, 0 >;
+   simulationDomain < 160, 160, 160 >;
+   blocks < 1,1,1 >;
+   isPeriodic < 1, 1, 1 >;
+   initialRefinementLevel 1;
+   sorting linear;
+
+   LBAlgorithm Morton;
+   baseWeight 1;
+
+   recalculateBlockLevelsInRefresh 1;
+   reevaluateMinTargetLevelsAfterForcedRefinement 1;
+   allowRefreshChangingDepth 1;
+   regridMin 2000;
+   regridMax 100;
+
+   normal  <1,1,1>;
+   radius  0.6;
+   spacing 1.0;
+   vMax    0.0;
+
+   dt                0.0001;
+   simulationSteps    100;
+   visSpacing         100;
+
+   numOuterIterations   1;
+}
diff --git a/apps/benchmarks/GranularGas/PE_Benchmark.cfg b/apps/benchmarks/GranularGas/PE_Benchmark.cfg
index da276e019..458a3a60e 100644
--- a/apps/benchmarks/GranularGas/PE_Benchmark.cfg
+++ b/apps/benchmarks/GranularGas/PE_Benchmark.cfg
@@ -10,8 +10,8 @@ GranularGas
    spacing 1.0;
    vMax    0.0;
 
-   dt                0.1;
-   simulationSteps   1000;
+   dt                 0.1;
+   simulationSteps    100;
    numOuterIterations   1;
    visSpacing         100;
 
diff --git a/apps/benchmarks/GranularGas/mesa_pd_upload.py b/apps/benchmarks/GranularGas/mesa_pd_upload.py
new file mode 100755
index 000000000..492c58e09
--- /dev/null
+++ b/apps/benchmarks/GranularGas/mesa_pd_upload.py
@@ -0,0 +1,52 @@
+#! /usr/bin/env python3
+
+import os
+import time
+import math
+import random
+import re
+from influxdb import InfluxDBClient
+from git import Repo
+
+
+class Upload:
+   def __init__(self):
+      try:
+         self.write_user_pw = os.environ["INFLUXDB_MESAPD_PW"]
+      except KeyError:
+         import sys
+         print('Password for the InfluxDB write_user was not set.\n',
+               'See https://docs.gitlab.com/ee/ci/variables/#secret-variables', file=sys.stderr)
+         exc_info = sys.exc_info()
+         raise exc_info[0].with_traceback(exc_info[1], exc_info[2])
+
+      self.client = InfluxDBClient('i10grafana.informatik.uni-erlangen.de', 8086,
+                                   'mesa_pd', self.write_user_pw, 'mesa_pd')
+
+   def process(self, filename):
+      tts = dict()
+
+      with open(filename) as f:
+         for s in f.readlines():
+            m = re.search(r'\[0\]\s*(\w*)\s*\|[\s\d\.\%]*\|\s*([\d\.]*)', s)
+
+            if (m != None):
+               tts[m.group(1)] = float(m.group(2))
+
+      json_body = [
+         {
+            'measurement': 'mesa_pd_benchmark',
+            'tags': {
+                  'host'            : os.uname()[1],
+                  'image'           : os.environ["DOCKER_IMAGE_NAME"],
+            },
+            'time': int(time.time()),
+            'fields': tts
+         }
+      ]
+      print(tts)
+      self.client.write_points(json_body, time_precision='s')
+
+if __name__ == "__main__":
+   up = Upload()
+   up.process("mesa_pd.txt")
diff --git a/apps/benchmarks/GranularGas/upload.py b/apps/benchmarks/GranularGas/pe_upload.py
similarity index 100%
rename from apps/benchmarks/GranularGas/upload.py
rename to apps/benchmarks/GranularGas/pe_upload.py
-- 
GitLab