Skip to content
Snippets Groups Projects
dashboard_list.py 9.92 KiB
Newer Older
Christoph Alt's avatar
Christoph Alt committed
from typing import List

from dashboards.dashboard_base import (DashboardOptions, build_dashboard,
Christoph Alt's avatar
Christoph Alt committed
                                       build_row_repeat_dashboard,
                                       get_dashboard_variable_query,
                                       get_grid_pos, get_stat_panel)
from dashboards.influx_queries import (Query, get_variable_condition,
                                       join_conditions, join_variable_and,
                                       show_tag_values)
Christoph Alt's avatar
Christoph Alt committed


def _uniform_grid(arch: str, group_by: List[str]):
    dataSource = 'InfluxDB-1'
    measurment_name = f'UniformGrid{arch}'
    row_repeat = "collisionSetup"
    panel_repeat = "host"
    unit = 'MLUPs per Process'

    row_repeat_var = get_dashboard_variable_query(row_repeat,
                                                  show_tag_values(measurment_name, row_repeat),
                                                  dataSource)
    panel_repeat_var = get_dashboard_variable_query(panel_repeat,
                                                    show_tag_values(measurment_name, panel_repeat),
                                                    dataSource)
    other_filter = 'cellsPerBlock_0'
    cellsPerBlock_var = get_dashboard_variable_query(other_filter,
                                                     show_tag_values(measurment_name, other_filter),
                                                     dataSource
                                                     )
    where = join_variable_and([row_repeat, panel_repeat, other_filter])
    query = Query(
        select_='mlupsPerProcess',
        from_=measurment_name,
        where_=where,
        group_by=group_by
    )
    options = DashboardOptions(
        title=f'Uniform Grid {arch}',
        description=f"Benchmark dashboard for the Uniform Grid {arch} Benchmark from walberla",
        tags=[
            arch,
            'benchmark',
            'walberla',
            'Uniform Grid'
        ],
        timezone="browser",
    )
    return build_row_repeat_dashboard(options,
                                      row_repeat_var,
                                      panel_repeat_var,
                                      dataSource,
                                      measurment_name,
                                      query,
                                      unit,
                                      [cellsPerBlock_var]
                                      )


def dashboard_uniformGridGPU():
    group_by = ["blocks_0",
                "blocks_1",
                "blocks_2",
                "cellsPerBlock_0",
                "cellsPerBlock_1",
                "cellsPerBlock_2",
                "gpuBlockSize_0",
                "gpuBlockSize_1",
                "gpuBlockSize_2",
                "collisionSetup",
                "stencil",
                "streamingPattern",
                ]

    return _uniform_grid("GPU", group_by)


def dashboard_uniformGridCPU():
    group_by = ["blocks_0",
                "blocks_1",
                "blocks_2",
                "cellsPerBlock_0",
                "cellsPerBlock_1",
                "cellsPerBlock_2",
                "periodic_0",
                "periodic_1",
                "periodic_2",
                "collisionSetup",
                "mpi_num_processes",
                "streamingPattern",
                "timeStepStrategy",
                "stencil",
                ]

    return _uniform_grid("CPU", group_by)


def dashboard_granular_gas():
    dataSource = 'InfluxDB-1'
    measurment_name = 'MESA_PD_KernelBenchmark'
    row_repeat = "kernel"
    panel_repeat = "host"
    unit = 'ms'

    row_repeat_var = get_dashboard_variable_query(row_repeat,
                                                  f"SHOW FIELD KEYS FROM {measurment_name}",
                                                  dataSource)
    panel_repeat_var = get_dashboard_variable_query(panel_repeat,
                                                    show_tag_values(measurment_name, panel_repeat),
                                                    dataSource)
    query = Query(
        select_='$kernel',
        from_=measurment_name,
        where_=f'"{panel_repeat}" =~ /^${panel_repeat}$/',
        group_by=['mpi_num_processes', 'omp_max_threads'])
    options = DashboardOptions(
        title='Granular Gas Kernel Benchmark',
        description="Benchmark dashboard for the Granular Gas Benchmark from walberla",
        tags=[
            'CPU',
            'benchmark',
            'walberla',
            'Granular Gas'
        ],
        timezone="browser",
    )
    return build_row_repeat_dashboard(options,
                                      row_repeat_var,
                                      panel_repeat_var,
                                      dataSource,
                                      measurment_name,
                                      query,
                                      unit)


def dashboard_phasefieldallenchan():
    dataSource = 'InfluxDB-1'
    measurment_name = 'PhaseFieldAllenCahn'
    row_repeat = "cellsPerBlock_0"
    panel_repeat = "host"
    unit = 'MLUPs per Process'

    options = DashboardOptions(
        title='Phase Field Allen Chan',
        description="Benchmark dashboard for the Phasefield Allen Cahn Benchmark from walberla",
        tags=[
            'CPU',
            'benchmark',
            'walberla',
            'PhaseField Allen Cahn'
        ],
        timezone="browser",
    )
    row_repeat_var = get_dashboard_variable_query(row_repeat,
                                                  show_tag_values(measurment_name, row_repeat),
                                                  dataSource)
    panel_repeat_var = get_dashboard_variable_query(panel_repeat,
                                                    show_tag_values(measurment_name, panel_repeat),
                                                    dataSource)
    query = Query(
        select_='mlupsPerProcess',
        from_=measurment_name,
        where_=join_variable_and([row_repeat, panel_repeat]),
        group_by=[
            "blocks_0",
            "blocks_1",
            "blocks_2",
            "cellsPerBlock_0",
            "mpi_num_processes",
            "host",
            "executable",
            "timeStepStrategy",
            "stencil_phase",
            "stencil_hydro"
        ]
    )

    return build_row_repeat_dashboard(options,
                                      row_repeat_var,
                                      panel_repeat_var,
                                      dataSource,
                                      measurment_name,
                                      query,
                                      unit)


def dashboard_phasefieldallenchangpu():
    dataSource = 'InfluxDB-1'
    measurment_name = 'PhaseFieldAllenCahnGPU'
    row_repeat = "cellsPerBlock_0"
    panel_repeat = "host"
    unit = 'MLUPs per Process'

    options = DashboardOptions(
        title='Phase Field Allen Chan GPU',
        description="Benchmark dashboard for the Phasefield Allen Cahn Benchmark from walberla",
        tags=[
            'GPU',
            'benchmark',
            'walberla',
            'PhaseField Allen Cahn'
        ],
        timezone="browser",
    )
    row_repeat_var = get_dashboard_variable_query(row_repeat,
                                                  show_tag_values(measurment_name, row_repeat),
                                                  dataSource)
    panel_repeat_var = get_dashboard_variable_query(panel_repeat,
                                                    show_tag_values(measurment_name, panel_repeat),
                                                    dataSource)
    query = Query(
        select_='mlupsPerProcess',
        from_=measurment_name,
        where_=join_variable_and([row_repeat, panel_repeat]),
        group_by=[
            "blocks_0",
            "blocks_1",
            "blocks_2",
            "gpuBlockSize_0",
            "gpuBlockSize_1",
            "gpuBlockSize_2",
            "cellsPerBlock_0",
            "mpi_num_processes",
            "host",
            "executable",
            "timeStepStrategy",
            "stencil_phase",
            "stencil_hydro"
        ]
    )

    return build_row_repeat_dashboard(options,
                                      row_repeat_var,
                                      panel_repeat_var,
                                      dataSource,
                                      measurment_name,
                                      query,
                                      unit)


def dashboard_general_infos():
    dataSource = 'InfluxDB-1'
    measurment_name = "JOB_INFOS"

    host_var = get_dashboard_variable_query('host',
                                            show_tag_values("", 'host'),
                                            dataSource)

    def get_query(name_base: str):
        return Query(
            select_="duration",
            from_=measurment_name,
Christoph Alt's avatar
Christoph Alt committed
            where_=join_conditions([f'"name" =~ /{name_base}/', f'"name" =~ /${host_var.name}/'],
                                   "AND"),
            group_by=[
                'name'
            ]
        )

    options = DashboardOptions(
        title='Overview',
        description="General Information about walberla benchmarks",
        tags=[
            'walberla',
        ],
        timezone="browser",
    )

    panel_build = get_stat_panel("Build Times",
                                 dataSource,
                                 get_query("build"),
                                 gridPos=get_grid_pos(12, 24, 0, 0),
                                 format='s')
    panel_benchmark = get_stat_panel("Benchmark Runtime",
                                     dataSource,
                                     get_query("benchmark"),
                                     gridPos=get_grid_pos(30, 24, 0, 13),
                                     format='s')
    return build_dashboard(options, panels=[panel_build, panel_benchmark], templating=[host_var])