Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Slurm sets CPU frequency correctly #47

Merged
merged 6 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions tests/env/cpu_freq_check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/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 by default"
valid_systems = ["archer2:compute"]
valid_prog_environs = ["PrgEnv-cray"]
executable = "./freq_print.sh"

tags = {"production", "maintenance", "craype"}

freq = 2000000

@sanity_function
def assert_finished(self):
"""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"""

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"

tags = {"production", "maintenance", "craype"}

freq = 2250000

@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
def assert_finished(self):
"""Sanity check that SLURM_CPU_FREQ_REQ 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
Loading