Skip to content

utils

Utility functions for ReFrame tests

check_extras_key_defined(test, extra_key)

Checks if a specific key is defined in the 'extras' dictionary for the current partition (i.e. if test.current_partition.extras[extra_key] is defined) If not, throws an informative error message. Note that partition extras are defined by free text keys, so any string is (potentially) valid.

Arguments: - test: the reframe regression test instance for which should be checked if the key is defined in 'extras' - extra_key: key for which to check in the 'extras' dictionary

Return: - True (bool) if the key is defined - Function does not return (but raises an error) if the attribute is undefined

check_proc_attribute_defined(test, attribute)

Checks if a processor feature is defined (i.e. if test.current_partition.processor. is defined) If not, throws an informative error message.

Arguments: - test: the reframe regression test instance for which should be checked if the processor feature is defined - attribute: attribute of the processor object, as defined by systems.partitions.processor

Return: - True (bool) if the attribute is defined - Function does not return (but raises an error) if the attribute is undefined

Current known attributes in ReFrame are arch, num_cpus, num_cpus_per_core and topology, but this may change in the future.

If ReFrame's autodetect feature is used, all of these should be properly defined, so that's what we advice.

find_modules(regex, name_only=True)

Return all modules matching the regular expression regex. Note that since we use re.search, a module matches if the regex matches the module name at any place. I.e. the match does not have to be at the start of the smodule name

Arguments: - regex: a regular expression - name_only: regular expressions will only be matched on the module name, not the version (default: True).

Note: the name_only feature assumes anything after the last forward '/' is the version, and strips that before doing a match.

Example

Suppose we have the following modules on a system:

gompic/2022a gompi/2022a CGAL/4.14.3-gompi-2022a

The following calls would return the following respective modules

find_modules('gompi') => [gompic/2022a, gompi/2022a] find_modules('gompi$') => [gompi/2022a] find_modules('gompi', name_only = False) => [gompic/2022a, gompi/2022a, CGAL/4.14.3-gompi-2022a] find_modules('^gompi', name_only = False) => [gompic/2022a, gompi/2022a] find_modules('^gompi/', name_only = False) => [gompi/2022a] find_modules('-gompi-2022a', name_only = False) => [CGAL/4.14.3-gompi-2022a]

get_max_avail_gpus_per_node(test)

Returns the maximum available number of GPUs per node for the current partition, taken from 'num_devices' of device GPU_DEV_NAME in the 'devices' attribute of the current partition

is_cuda_required_module(module_name)

Checks if CUDA seems to be required by given module

is_gpu_present(test)

Checks if GPUs are present in the current partition