From 1df51346a3546c931ab8228bb7a7028372a7bb0a Mon Sep 17 00:00:00 2001 From: JPRichings Date: Mon, 23 Sep 2024 16:40:54 +0100 Subject: [PATCH 1/6] Adding a test to confirm default CPU frequency set to 2GHz and that slurm can be used to raise this to 2.25Ghz --- tests/env/cpu_freq_check.py | 56 +++++++++++++++++++++++++++++++++++++ tests/env/src/freq_print.sh | 3 ++ 2 files changed, 59 insertions(+) create mode 100644 tests/env/cpu_freq_check.py create mode 100755 tests/env/src/freq_print.sh diff --git a/tests/env/cpu_freq_check.py b/tests/env/cpu_freq_check.py new file mode 100644 index 0000000..90ce556 --- /dev/null +++ b/tests/env/cpu_freq_check.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +"""Reframe test to check that CPU target environment variable is correctly set""" + +# Based on work from: +# Copyright 2016-2020 Swiss National Supercomputing Centre (CSCS/ETH Zurich) +# ReFrame Project Developers. See the top-level LICENSE file for details. +# SPDX-License-Identifier: BSD-3-Clause + +import reframe as rfm +import reframe.utility.sanity as sn + + +@rfm.simple_test +class CPUFreqTest(rfm.RunOnlyRegressionTest): + """Checks that CPU frequency is set to 2GHz by default""" + + descr = "Checks whether SLURM_CPU_FREQ_REQ is set to 2GHz as default" + valid_systems = ["archer2:compute"] + valid_prog_environs = ["PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc"] + #sourcesdir = None + executable = "./freq_print.sh" + + tags = {"production", "maintenance", "craype"} + + freq = 2000000 + + @sanity_function + def assert_finished(self): + """Sanity check that CPU_CRAY_TARGET is set""" + return sn.assert_found(f"SLURM_CPU_FREQ_REQ={self.freq}", self.stdout) + + + + +@rfm.simple_test +class CPUHighFreqTest(rfm.RunOnlyRegressionTest): + """Checks that CPU frequency is set to 2.25GHz by default""" + + descr = "Checks whether SLURM_CPU_FREQ_REQ is set to 2GHz as default" + valid_systems = ["archer2:compute"] + valid_prog_environs = ["PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc"] + #sourcesdir = None + executable = "./freq_print.sh" + + tags = {"production", "maintenance", "craype"} + + freq = 2250000 + + @run_before('run') + def set_cpu_freq(self): + self.job.launcher.options = ['--cpu-freq=2250000'] + + @sanity_function + def assert_finished(self): + """Sanity check that CPU_CRAY_TARGET is set""" + return sn.assert_found(f"SLURM_CPU_FREQ_REQ={self.freq}", self.stdout) diff --git a/tests/env/src/freq_print.sh b/tests/env/src/freq_print.sh new file mode 100755 index 0000000..b56e829 --- /dev/null +++ b/tests/env/src/freq_print.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo SLURM_CPU_FREQ_REQ=$SLURM_CPU_FREQ_REQ From c1e032d04dc2de73a991823900524b4c114382d5 Mon Sep 17 00:00:00 2001 From: JPRichings Date: Mon, 23 Sep 2024 17:27:59 +0100 Subject: [PATCH 2/6] Edits to comply with syle guide --- tests/env/cpu_freq_check.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tests/env/cpu_freq_check.py b/tests/env/cpu_freq_check.py index 90ce556..db90d40 100644 --- a/tests/env/cpu_freq_check.py +++ b/tests/env/cpu_freq_check.py @@ -17,7 +17,6 @@ class CPUFreqTest(rfm.RunOnlyRegressionTest): descr = "Checks whether SLURM_CPU_FREQ_REQ is set to 2GHz as default" valid_systems = ["archer2:compute"] valid_prog_environs = ["PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc"] - #sourcesdir = None executable = "./freq_print.sh" tags = {"production", "maintenance", "craype"} @@ -29,9 +28,6 @@ def assert_finished(self): """Sanity check that CPU_CRAY_TARGET is set""" return sn.assert_found(f"SLURM_CPU_FREQ_REQ={self.freq}", self.stdout) - - - @rfm.simple_test class CPUHighFreqTest(rfm.RunOnlyRegressionTest): """Checks that CPU frequency is set to 2.25GHz by default""" @@ -39,7 +35,6 @@ class CPUHighFreqTest(rfm.RunOnlyRegressionTest): descr = "Checks whether SLURM_CPU_FREQ_REQ is set to 2GHz as default" valid_systems = ["archer2:compute"] valid_prog_environs = ["PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc"] - #sourcesdir = None executable = "./freq_print.sh" tags = {"production", "maintenance", "craype"} @@ -48,6 +43,7 @@ class CPUHighFreqTest(rfm.RunOnlyRegressionTest): @run_before('run') def set_cpu_freq(self): + """Add slurm command line variable to job script to set frequency to 2.25Ghz""" self.job.launcher.options = ['--cpu-freq=2250000'] @sanity_function From 66e923abffacfba77f8db865f9b4c669d107e22f Mon Sep 17 00:00:00 2001 From: JPRichings Date: Mon, 23 Sep 2024 17:29:59 +0100 Subject: [PATCH 3/6] Edits to comply with style guide --- tests/env/cpu_freq_check.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/env/cpu_freq_check.py b/tests/env/cpu_freq_check.py index db90d40..f111651 100644 --- a/tests/env/cpu_freq_check.py +++ b/tests/env/cpu_freq_check.py @@ -28,6 +28,7 @@ def assert_finished(self): """Sanity check that CPU_CRAY_TARGET is set""" return sn.assert_found(f"SLURM_CPU_FREQ_REQ={self.freq}", self.stdout) + @rfm.simple_test class CPUHighFreqTest(rfm.RunOnlyRegressionTest): """Checks that CPU frequency is set to 2.25GHz by default""" From cd233a9d40033dbf3d164f381321e87bff8d3b60 Mon Sep 17 00:00:00 2001 From: JPRichings Date: Wed, 25 Sep 2024 11:19:03 +0100 Subject: [PATCH 4/6] updated quotes to meet syntax standard --- tests/env/cpu_freq_check.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/env/cpu_freq_check.py b/tests/env/cpu_freq_check.py index f111651..1ebbca7 100644 --- a/tests/env/cpu_freq_check.py +++ b/tests/env/cpu_freq_check.py @@ -42,10 +42,10 @@ class CPUHighFreqTest(rfm.RunOnlyRegressionTest): freq = 2250000 - @run_before('run') + @run_before("run") def set_cpu_freq(self): """Add slurm command line variable to job script to set frequency to 2.25Ghz""" - self.job.launcher.options = ['--cpu-freq=2250000'] + self.job.launcher.options = ["--cpu-freq=2250000"] @sanity_function def assert_finished(self): From df5652a9e8e97ce3bd6087a34b137ad1b657419e Mon Sep 17 00:00:00 2001 From: JPRichings Date: Wed, 25 Sep 2024 13:48:22 +0100 Subject: [PATCH 5/6] reducing number of prg env's used to reduce test duplication --- tests/env/cpu_freq_check.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/env/cpu_freq_check.py b/tests/env/cpu_freq_check.py index 1ebbca7..fb01ff8 100644 --- a/tests/env/cpu_freq_check.py +++ b/tests/env/cpu_freq_check.py @@ -16,7 +16,7 @@ class CPUFreqTest(rfm.RunOnlyRegressionTest): descr = "Checks whether SLURM_CPU_FREQ_REQ is set to 2GHz as default" valid_systems = ["archer2:compute"] - valid_prog_environs = ["PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc"] + valid_prog_environs = ["PrgEnv-cray"] executable = "./freq_print.sh" tags = {"production", "maintenance", "craype"} @@ -35,7 +35,7 @@ class CPUHighFreqTest(rfm.RunOnlyRegressionTest): descr = "Checks whether SLURM_CPU_FREQ_REQ is set to 2GHz as default" valid_systems = ["archer2:compute"] - valid_prog_environs = ["PrgEnv-cray", "PrgEnv-gnu", "PrgEnv-aocc"] + valid_prog_environs = ["PrgEnv-cray"] executable = "./freq_print.sh" tags = {"production", "maintenance", "craype"} From 33efa1e3aaee9e0312af5fc488edcca1e958108e Mon Sep 17 00:00:00 2001 From: JPRichings Date: Wed, 25 Sep 2024 15:13:14 +0100 Subject: [PATCH 6/6] Updated functions doc strings --- tests/env/cpu_freq_check.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/env/cpu_freq_check.py b/tests/env/cpu_freq_check.py index fb01ff8..ac886d2 100644 --- a/tests/env/cpu_freq_check.py +++ b/tests/env/cpu_freq_check.py @@ -14,7 +14,7 @@ class CPUFreqTest(rfm.RunOnlyRegressionTest): """Checks that CPU frequency is set to 2GHz by default""" - descr = "Checks whether SLURM_CPU_FREQ_REQ is set to 2GHz as default" + descr = "Checks whether SLURM_CPU_FREQ_REQ is set to 2GHz by default" valid_systems = ["archer2:compute"] valid_prog_environs = ["PrgEnv-cray"] executable = "./freq_print.sh" @@ -25,15 +25,15 @@ class CPUFreqTest(rfm.RunOnlyRegressionTest): @sanity_function def assert_finished(self): - """Sanity check that CPU_CRAY_TARGET is set""" + """Sanity check that SLURM_CPU_FREQ_REQ is set""" return sn.assert_found(f"SLURM_CPU_FREQ_REQ={self.freq}", self.stdout) @rfm.simple_test class CPUHighFreqTest(rfm.RunOnlyRegressionTest): - """Checks that CPU frequency is set to 2.25GHz by default""" + """Checks that CPU frequency is set to 2.25GHz""" - descr = "Checks whether SLURM_CPU_FREQ_REQ is set to 2GHz as default" + descr = "Checks whether SLURM_CPU_FREQ_REQ can be set to 2.25GHz is set by slurm" valid_systems = ["archer2:compute"] valid_prog_environs = ["PrgEnv-cray"] executable = "./freq_print.sh" @@ -49,5 +49,5 @@ def set_cpu_freq(self): @sanity_function def assert_finished(self): - """Sanity check that CPU_CRAY_TARGET is set""" + """Sanity check that SLURM_CPU_FREQ_REQ is set""" return sn.assert_found(f"SLURM_CPU_FREQ_REQ={self.freq}", self.stdout)