Skip to content

Commit

Permalink
Add set_omp_num_threads hook from EESSI#133
Browse files Browse the repository at this point in the history
  • Loading branch information
Caspar van Leeuwen committed Jul 25, 2024
1 parent 7ddeedb commit d62443b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions eessi/testsuite/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Hooks for adding tags, filtering and setting job resources in ReFrame tests
"""
import math
import os
import shlex
import warnings

Expand Down Expand Up @@ -680,6 +681,15 @@ def set_compact_thread_binding(test: rfm.RegressionTest):
log(f'Set environment variable KMP_AFFINITY to {test.env_vars["KMP_AFFINITY"]}')


def set_omp_num_threads(test: rfm.RegressionTest):
"""
Set default number of OpenMP threads equal to number of CPUs per task,
unless OMP_NUM_THREADS is already set
"""
test.env_vars['OMP_NUM_THREADS'] = os.getenv('OMP_NUM_THREADS', test.num_cpus_per_task)
log(f'Set environment variable OMP_NUM_THREADS to {test.env_vars["OMP_NUM_THREADS"]}')


def _check_always_request_gpus(test: rfm.RegressionTest):
"""
Make sure we always request enough GPUs if required for the current GPU partition (cluster-specific policy)
Expand Down

0 comments on commit d62443b

Please sign in to comment.