Skip to content

Commit

Permalink
Adding a test to confirm default CPU frequency set to 2GHz and that s…
Browse files Browse the repository at this point in the history
…lurm can be used to raise this to 2.25Ghz
  • Loading branch information
JPRichings committed Sep 23, 2024
1 parent 518b122 commit 1df5134
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
56 changes: 56 additions & 0 deletions tests/env/cpu_freq_check.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions tests/env/src/freq_print.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

echo SLURM_CPU_FREQ_REQ=$SLURM_CPU_FREQ_REQ

0 comments on commit 1df5134

Please sign in to comment.